@splinetool/loader 0.9.456 → 0.9.457

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- var yx=Object.create;var Lc=Object.defineProperty;var gx=Object.getOwnPropertyDescriptor;var xx=Object.getOwnPropertyNames;var vx=Object.getPrototypeOf,bx=Object.prototype.hasOwnProperty;var Pn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Sx=(n,r)=>{for(var e in r)Lc(n,e,{get:r[e],enumerable:!0})},wx=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of xx(r))!bx.call(n,o)&&o!==e&&Lc(n,o,{get:()=>r[o],enumerable:!(t=gx(r,o))||t.enumerable});return n};var ya=(n,r,e)=>(e=n!=null?yx(vx(n)):{},wx(r||!n||!n.__esModule?Lc(e,"default",{value:n,enumerable:!0}):e,n));var kh=Pn((hd,Fh)=>{(function(n,r){typeof hd=="object"?Fh.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(hd,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 c=0;c<e.length;c++)t-=s(e[c]),t<0&&(t+=1),o-=s(e[c]),o<0&&(o+=1),i-=s(e[c]),i<0&&(i+=1);s=null;var u=function(){var l=2091639*t+a*23283064365386963e-26;return t=o,o=i,i=l-(a=l|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[t,o,i,a]},u.importState=function(l){t=+l[0]||0,o=+l[1]||0,i=+l[2]||0,a=+l[3]||0},u}(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 $h=Pn((Al,qh)=>{(function(n,r){typeof Al=="object"&&typeof qh<"u"?r(Al):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Al,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,c,u,l,d,p,f,m,h,y,g,x=r[0].length,S=r.length;if(S<x)throw new TypeError("Invalid matrix: m < n");for(var w=[],b=[],T=[],_=e==="f"?S:x,v=h=p=0;v<S;v++)b[v]=new Array(_).fill(0);for(v=0;v<x;v++)T[v]=new Array(x).fill(0);var N,P=new Array(x).fill(0);for(v=0;v<S;v++)for(a=0;a<x;a++)b[v][a]=r[v][a];for(v=0;v<x;v++){for(w[v]=p,m=0,c=v+1,a=v;a<S;a++)m+=Math.pow(b[a][v],2);if(m<i)p=0;else for(f=(d=b[v][v])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v]=d-p,a=c;a<x;a++){for(m=0,s=v;s<S;s++)m+=b[s][v]*b[s][a];for(d=m/f,s=v;s<S;s++)b[s][a]=b[s][a]+d*b[s][v]}for(P[v]=p,m=0,a=c;a<x;a++)m+=Math.pow(b[v][a],2);if(m<i)p=0;else{for(f=(d=b[v][v+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v+1]=d-p,a=c;a<x;a++)w[a]=b[v][a]/f;for(a=c;a<S;a++){for(m=0,s=c;s<x;s++)m+=b[a][s]*b[v][s];for(s=c;s<x;s++)b[a][s]=b[a][s]+m*w[s]}}h<(y=Math.abs(P[v])+Math.abs(w[v]))&&(h=y)}if(t)for(v=x-1;0<=v;v--){if(p!==0){for(f=b[v][v+1]*p,a=c;a<x;a++)T[a][v]=b[v][a]/f;for(a=c;a<x;a++){for(m=0,s=c;s<x;s++)m+=b[v][s]*T[s][a];for(s=c;s<x;s++)T[s][a]=T[s][a]+m*T[s][v]}}for(a=c;a<x;a++)T[v][a]=0,T[a][v]=0;T[v][v]=1,p=w[v],c=v}if(e){if(e==="f")for(v=x;v<S;v++){for(a=x;a<S;a++)b[v][a]=0;b[v][v]=1}for(v=x-1;0<=v;v--){for(c=v+1,p=P[v],a=c;a<_;a++)b[v][a]=0;if(p!==0){for(f=b[v][v]*p,a=c;a<_;a++){for(m=0,s=c;s<S;s++)m+=b[s][v]*b[s][a];for(d=m/f,s=v;s<S;s++)b[s][a]=b[s][a]+d*b[s][v]}for(a=v;a<S;a++)b[a][v]=b[a][v]/p}else for(a=v;a<S;a++)b[a][v]=0;b[v][v]=b[v][v]+1}}for(o*=h,s=x-1;0<=s;s--)for(var C=0;C<50;C++){for(N=!1,c=s;0<=c;c--){if(Math.abs(w[c])<=o){N=!0;break}if(Math.abs(P[c-1])<=o)break}if(!N){for(l=0,u=c-(m=1),v=c;v<s+1&&(d=m*w[v],w[v]=l*w[v],!(Math.abs(d)<=o));v++)if(p=P[v],P[v]=Math.sqrt(d*d+p*p),l=p/(f=P[v]),m=-d/f,e)for(a=0;a<S;a++)y=b[a][u],g=b[a][v],b[a][u]=y*l+g*m,b[a][v]=-y*m+g*l}if(g=P[s],c===s){if(g<0&&(P[s]=-g,t))for(a=0;a<x;a++)T[a][s]=-T[a][s];break}for(h=P[c],d=(((y=P[s-1])-g)*(y+g)+((p=w[s-1])-(f=w[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((h-g)*(h+g)+f*(y/(d<0?d-p:d+p)-f))/h,v=c+(m=l=1);v<s+1;v++){if(p=w[v],y=P[v],f=m*p,p*=l,g=Math.sqrt(d*d+f*f),d=h*(l=d/(w[v-1]=g))+p*(m=f/g),p=-h*m+p*l,f=y*m,y*=l,t)for(a=0;a<x;a++)h=T[a][v-1],g=T[a][v],T[a][v-1]=h*l+g*m,T[a][v]=-h*m+g*l;if(g=Math.sqrt(d*d+f*f),d=(l=d/(P[v-1]=g))*p+(m=f/g)*y,h=-m*p+l*y,e)for(a=0;a<S;a++)y=b[a][v-1],g=b[a][v],b[a][v-1]=y*l+g*m,b[a][v]=-y*m+g*l}w[c]=0,w[s]=d,P[s]=h}for(v=0;v<x;v++)P[v]<o&&(P[v]=0);return{u:b,q:P,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var Oy=Pn((kd,Ud)=>{(function(n,r){typeof kd=="object"&&typeof Ud<"u"?Ud.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(kd,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 c=t-1>>1,u=i[c];if(a(s,u)>=0)break;i[t]=u,t=c}i[t]=s},n.prototype._down=function(t){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,c=i[t];t<s;){var u=(t<<1)+1,l=i[u],d=u+1;if(d<this.length&&a(i[d],l)<0&&(u=d,l=i[d]),a(l,c)>=0)break;i[t]=l,t=u}i[t]=c};function r(e,t){return e<t?-1:e>t?1:0}return n})});var Cy=Pn((Gk,Hd)=>{"use strict";var Vl=Oy();Vl.default&&(Vl=Vl.default);Hd.exports=Ay;Hd.exports.default=Ay;function Ay(n,r,e){r=r||1;for(var t,o,i,a,s=0;s<n[0].length;s++){var c=n[0][s];(!s||c[0]<t)&&(t=c[0]),(!s||c[1]<o)&&(o=c[1]),(!s||c[0]>i)&&(i=c[0]),(!s||c[1]>a)&&(a=c[1])}var u=i-t,l=a-o,d=Math.min(u,l),p=d/2;if(d===0){var f=[t,o];return f.distance=0,f}for(var m=new Vl(void 0,BP),h=t;h<i;h+=d)for(var y=o;y<a;y+=d)m.push(new Ro(h+p,y+p,p,n));var g=GP(n),x=new Ro(t+u/2,o+l/2,0,n);x.d>g.d&&(g=x);for(var S=m.length;m.length;){var w=m.pop();w.d>g.d&&(g=w,e&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,S)),!(w.max-g.d<=r)&&(p=w.h/2,m.push(new Ro(w.x-p,w.y-p,p,n)),m.push(new Ro(w.x+p,w.y-p,p,n)),m.push(new Ro(w.x-p,w.y+p,p,n)),m.push(new Ro(w.x+p,w.y+p,p,n)),S+=4)}e&&(console.log("num probes: "+S),console.log("best distance: "+g.d));var b=[g.x,g.y];return b.distance=g.d,b}function BP(n,r){return r.max-n.max}function Ro(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=RP(n,r,t),this.max=this.d+this.h*Math.SQRT2}function RP(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,c=a.length,u=c-1;s<c;u=s++){var l=a[s],d=a[u];l[1]>r!=d[1]>r&&n<(d[0]-l[0])*(r-l[1])/(d[1]-l[1])+l[0]&&(t=!t),o=Math.min(o,VP(n,r,l,d))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function GP(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 c=o[i],u=o[s],l=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*l,t+=(c[1]+u[1])*l,r+=l*3}return r===0?new Ro(o[0][0],o[0][1],0,n):new Ro(e/r,t/r,0,n)}function VP(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 c=((n-o)*a+(r-i)*s)/(a*a+s*s);c>1?(o=t[0],i=t[1]):c>0&&(o+=a*c,i+=s*c)}return a=n-o,s=r-i,a*a+s*s}});var Hg=Pn(uc=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var l=this||r;return l._counter=1e3,l._html5AudioPool=[],l.html5PoolSize=10,l._codecs={},l._howls=[],l._muted=!1,l._volume=1,l._canPlayEvent="canplaythrough",l._navigator=typeof window<"u"&&window.navigator?window.navigator:null,l.masterGain=null,l.noAudio=!1,l.usingWebAudio=!0,l.autoSuspend=!0,l.ctx=null,l.autoUnlock=!0,l._setup(),l},volume:function(l){var d=this||r;if(l=parseFloat(l),d.ctx||u(),typeof l<"u"&&l>=0&&l<=1){if(d._volume=l,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(l,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.volume=h._volume*l)}return d}return d._volume},mute:function(l){var d=this||r;d.ctx||u(),d._muted=l,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(l?0:d._volume,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.muted=l?!0:h._muted)}return d},stop:function(){for(var l=this||r,d=0;d<l._howls.length;d++)l._howls[d].stop();return l},unload:function(){for(var l=this||r,d=l._howls.length-1;d>=0;d--)l._howls[d].unload();return l.usingWebAudio&&l.ctx&&typeof l.ctx.close<"u"&&(l.ctx.close(),l.ctx=null,u()),l},codecs:function(l){return(this||r)._codecs[l.replace(/^x-/,"")]},_setup:function(){var l=this||r;if(l.state=l.ctx&&l.ctx.state||"suspended",l._autoSuspend(),!l.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(l._canPlayEvent="canplay")}catch{l.noAudio=!0}else l.noAudio=!0;try{var d=new Audio;d.muted&&(l.noAudio=!0)}catch{}return l.noAudio||l._setupCodecs(),l},_setupCodecs:function(){var l=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return l}if(!d||typeof d.canPlayType!="function")return l;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=l._navigator?l._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),h=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),x=y&&g&&parseInt(g[1],10)<15;return l._codecs={mp3:!!(!h&&(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:!!(!x&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&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$/,"")},l},_unlockAudio:function(){var l=this||r;if(!(l._audioUnlocked||!l.ctx)){l._audioUnlocked=!1,l.autoUnlock=!1,!l._mobileUnloaded&&l.ctx.sampleRate!==44100&&(l._mobileUnloaded=!0,l.unload()),l._scratchBuffer=l.ctx.createBuffer(1,1,22050);var d=function(p){for(;l._html5AudioPool.length<l.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,l._releaseHtml5Audio(f)}catch{l.noAudio=!0;break}for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var h=l._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=l._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}l._autoResume();var x=l.ctx.createBufferSource();x.buffer=l._scratchBuffer,x.connect(l.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof l.ctx.resume=="function"&&l.ctx.resume(),x.onended=function(){x.disconnect(0),l._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var S=0;S<l._howls.length;S++)l._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),l}},_obtainHtml5Audio:function(){var l=this||r;if(l._html5AudioPool.length)return l._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(l){var d=this||r;return l._unlocked&&d._html5AudioPool.push(l),d},_autoSuspend:function(){var l=this;if(!(!l.autoSuspend||!l.ctx||typeof l.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<l._howls.length;d++)if(l._howls[d]._webAudio){for(var p=0;p<l._howls[d]._sounds.length;p++)if(!l._howls[d]._sounds[p]._paused)return l}return l._suspendTimer&&clearTimeout(l._suspendTimer),l._suspendTimer=setTimeout(function(){if(!!l.autoSuspend){l._suspendTimer=null,l.state="suspending";var f=function(){l.state="suspended",l._resumeAfterSuspend&&(delete l._resumeAfterSuspend,l._autoResume())};l.ctx.suspend().then(f,f)}},3e4),l}},_autoResume:function(){var l=this;if(!(!l.ctx||typeof l.ctx.resume>"u"||!r.usingWebAudio))return l.state==="running"&&l.ctx.state!=="interrupted"&&l._suspendTimer?(clearTimeout(l._suspendTimer),l._suspendTimer=null):l.state==="suspended"||l.state==="running"&&l.ctx.state==="interrupted"?(l.ctx.resume().then(function(){l.state="running";for(var d=0;d<l._howls.length;d++)l._howls[d]._emit("resume")}),l._suspendTimer&&(clearTimeout(l._suspendTimer),l._suspendTimer=null)):l.state==="suspending"&&(l._resumeAfterSuspend=!0),l}};var r=new n,e=function(l){var d=this;if(!l.src||l.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(l)};e.prototype={init:function(l){var d=this;return r.ctx||u(),d._autoplay=l.autoplay||!1,d._format=typeof l.format!="string"?l.format:[l.format],d._html5=l.html5||!1,d._muted=l.mute||!1,d._loop=l.loop||!1,d._pool=l.pool||5,d._preload=typeof l.preload=="boolean"||l.preload==="metadata"?l.preload:!0,d._rate=l.rate||1,d._sprite=l.sprite||{},d._src=typeof l.src!="string"?l.src:[l.src],d._volume=l.volume!==void 0?l.volume:1,d._xhr={method:l.xhr&&l.xhr.method?l.xhr.method:"GET",headers:l.xhr&&l.xhr.headers?l.xhr.headers:null,withCredentials:l.xhr&&l.xhr.withCredentials?l.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=l.onend?[{fn:l.onend}]:[],d._onfade=l.onfade?[{fn:l.onfade}]:[],d._onload=l.onload?[{fn:l.onload}]:[],d._onloaderror=l.onloaderror?[{fn:l.onloaderror}]:[],d._onplayerror=l.onplayerror?[{fn:l.onplayerror}]:[],d._onpause=l.onpause?[{fn:l.onpause}]:[],d._onplay=l.onplay?[{fn:l.onplay}]:[],d._onstop=l.onstop?[{fn:l.onstop}]:[],d._onmute=l.onmute?[{fn:l.onmute}]:[],d._onvolume=l.onvolume?[{fn:l.onvolume}]:[],d._onrate=l.onrate?[{fn:l.onrate}]:[],d._onseek=l.onseek?[{fn:l.onseek}]:[],d._onunlock=l.onunlock?[{fn:l.onunlock}]:[],d._onresume=[],d._webAudio=r.usingWebAudio&&!d._html5,typeof r.ctx<"u"&&r.ctx&&r.autoUnlock&&r._unlockAudio(),r._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 l=this,d=null;if(r.noAudio){l._emit("loaderror",null,"No audio support.");return}typeof l._src=="string"&&(l._src=[l._src]);for(var p=0;p<l._src.length;p++){var f,m;if(l._format&&l._format[p])f=l._format[p];else{if(m=l._src[p],typeof m!="string"){l._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(m),f||(f=/\.([^.]+)$/.exec(m.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&&r.codecs(f)){d=l._src[p];break}}if(!d){l._emit("loaderror",null,"No codec support for selected audio sources.");return}return l._src=d,l._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(l._html5=!0,l._webAudio=!1),new t(l),l._webAudio&&i(l),l},play:function(l,d){var p=this,f=null;if(typeof l=="number")f=l,l=null;else{if(typeof l=="string"&&p._state==="loaded"&&!p._sprite[l])return null;if(typeof l>"u"&&(l="__default",!p._playLock)){for(var m=0,h=0;h<p._sounds.length;h++)p._sounds[h]._paused&&!p._sounds[h]._ended&&(m++,f=p._sounds[h]._id);m===1?l=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!l&&(l=y._sprite||"__default"),p._state!=="loaded"){y._sprite=l,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&&r._autoResume();var x=Math.max(0,y._seek>0?y._seek:p._sprite[l][0]/1e3),S=Math.max(0,(p._sprite[l][0]+p._sprite[l][1])/1e3-x),w=S*1e3/Math.abs(y._rate),b=p._sprite[l][0]/1e3,T=(p._sprite[l][0]+p._sprite[l][1])/1e3;y._sprite=l,y._ended=!1;var _=function(){y._paused=!1,y._seek=x,y._start=b,y._stop=T,y._loop=!!(y._loop||p._sprite[l][2])};if(x>=T){p._ended(y);return}var v=y._node;if(p._webAudio){var N=function(){p._playLock=!1,_(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;v.gain.setValueAtTime(A,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof v.bufferSource.start>"u"?y._loop?v.bufferSource.noteGrainOn(0,x,86400):v.bufferSource.noteGrainOn(0,x,S):y._loop?v.bufferSource.start(0,x,86400):v.bufferSource.start(0,x,S),w!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};r.state==="running"&&r.ctx.state!=="interrupted"?N():(p._playLock=!0,p.once("resume",N),p._clearTimer(y._id))}else{var P=function(){v.currentTime=x,v.muted=y._muted||p._muted||r._muted||v.muted,v.volume=y._volume*r.volume(),v.playbackRate=y._rate;try{var A=v.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,_(),A.then(function(){p._playLock=!1,v._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,_(),p._emit("play",y._id)),v.playbackRate=y._rate,v.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}l!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),v.removeEventListener("ended",p._endTimers[y._id],!1)},v.addEventListener("ended",p._endTimers[y._id],!1))}catch(M){p._emit("playerror",y._id,M)}};v.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(v.src=p._src,v.load());var C=window&&window.ejecta||!v.readyState&&r._navigator.isCocoonJS;if(v.readyState>=3||C)P();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",P(),v.removeEventListener(r._canPlayEvent,O,!1)};v.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(l)}}),d;for(var p=d._getSoundIds(l),f=0;f<p.length;f++){d._clearTimer(p[f]);var m=d._soundById(p[f]);if(m&&!m._paused&&(m._seek=d.seek(p[f]),m._rateSeek=0,m._paused=!0,d._stopFade(p[f]),m._node))if(d._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||d._emit("pause",m?m._id:null)}return d},stop:function(l,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(l)}}),p;for(var f=p._getSoundIds(l),m=0;m<f.length;m++){p._clearTimer(f[m]);var h=p._soundById(f[m]);h&&(h._seek=h._start||0,h._rateSeek=0,h._paused=!0,h._ended=!0,p._stopFade(f[m]),h._node&&(p._webAudio?h._node.bufferSource&&(typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),p._cleanBuffer(h._node)):(!isNaN(h._node.duration)||h._node.duration===1/0)&&(h._node.currentTime=h._start||0,h._node.pause(),h._node.duration===1/0&&p._clearSound(h._node))),d||p._emit("stop",h._id))}return p},mute:function(l,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(l,d)}}),p;if(typeof d>"u")if(typeof l=="boolean")p._muted=l;else return p._muted;for(var f=p._getSoundIds(d),m=0;m<f.length;m++){var h=p._soundById(f[m]);h&&(h._muted=l,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(l?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:l),p._emit("mute",h._id))}return p},volume:function(){var l=this,d=arguments,p,f;if(d.length===0)return l._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=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(l._state!=="loaded"||l._playLock)return l._queue.push({event:"volume",action:function(){l.volume.apply(l,d)}}),l;typeof f>"u"&&(l._volume=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)y=l._soundById(f[g]),y&&(y._volume=p,d[2]||l._stopFade(f[g]),l._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),l._emit("volume",y._id))}else return y=f?l._soundById(f):l._sounds[0],y?y._volume:0;return l},fade:function(l,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(l,d,p,f)}}),m;l=Math.min(Math.max(0,parseFloat(l)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(l,f);for(var h=m._getSoundIds(f),y=0;y<h.length;y++){var g=m._soundById(h[y]);if(g){if(f||m._stopFade(h[y]),m._webAudio&&!g._muted){var x=r.ctx.currentTime,S=x+p/1e3;g._volume=l,g._node.gain.setValueAtTime(l,x),g._node.gain.linearRampToValueAtTime(d,S)}m._startFadeInterval(g,l,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(l,d,p,f,m,h){var y=this,g=d,x=p-d,S=Math.abs(x/.01),w=Math.max(4,S>0?f/S:f),b=Date.now();l._fadeTo=p,l._interval=setInterval(function(){var T=(Date.now()-b)/f;b=Date.now(),g+=x*T,g=Math.round(g*100)/100,x<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?l._volume=g:y.volume(g,l._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(l._interval),l._interval=null,l._fadeTo=null,y.volume(p,l._id),y._emit("fade",l._id))},w)},_stopFade:function(l){var d=this,p=d._soundById(l);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,l),p._fadeTo=null,d._emit("fade",l)),d},loop:function(){var l=this,d=arguments,p,f,m;if(d.length===0)return l._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],l._loop=p;else return m=l._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=l._getSoundIds(f),y=0;y<h.length;y++)m=l._soundById(h[y]),m&&(m._loop=p,l._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=p,p&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,l.playing(h[y])&&(l.pause(h[y],!0),l.play(h[y],!0)))));return l},rate:function(){var l=this,d=arguments,p,f;if(d.length===0)f=l._sounds[0]._id;else if(d.length===1){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=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(l._state!=="loaded"||l._playLock)return l._queue.push({event:"rate",action:function(){l.rate.apply(l,d)}}),l;typeof f>"u"&&(l._rate=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=l._soundById(f[g]),y){l.playing(f[g])&&(y._rateSeek=l.seek(f[g]),y._playStart=l._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,l._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var x=l.seek(f[g]),S=(l._sprite[y._sprite][0]+l._sprite[y._sprite][1])/1e3-x,w=S*1e3/Math.abs(y._rate);(l._endTimers[f[g]]||!y._paused)&&(l._clearTimer(f[g]),l._endTimers[f[g]]=setTimeout(l._ended.bind(l,y),w)),l._emit("rate",y._id)}}else return y=l._soundById(f),y?y._rate:l._rate;return l},seek:function(){var l=this,d=arguments,p,f;if(d.length===0)l._sounds.length&&(f=l._sounds[0]._id);else if(d.length===1){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):l._sounds.length&&(f=l._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"&&(l._state!=="loaded"||l._playLock))return l._queue.push({event:"seek",action:function(){l.seek.apply(l,d)}}),l;var y=l._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=l.playing(f);g&&l.pause(f,!0),y._seek=p,y._ended=!1,l._clearTimer(f),!l._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var x=function(){g&&l.play(f,!0),l._emit("seek",f)};if(g&&!l._webAudio){var S=function(){l._playLock?setTimeout(S,0):x()};setTimeout(S,0)}else x()}else if(l._webAudio){var w=l.playing(f)?r.ctx.currentTime-y._playStart:0,b=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(b+w*Math.abs(y._rate))}else return y._node.currentTime;return l},playing:function(l){var d=this;if(typeof l=="number"){var p=d._soundById(l);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(l){var d=this,p=d._duration,f=d._soundById(l);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var l=this,d=l._sounds,p=0;p<d.length;p++)d[p]._paused||l.stop(d[p]._id),l._webAudio||(l._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(r._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),r._releaseHtml5Audio(d[p]._node)),delete d[p]._node,l._clearTimer(d[p]._id);var f=r._howls.indexOf(l);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===l._src||l._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[l._src],r.noAudio=!1,l._state="unloaded",l._sounds=[],l=null,null},on:function(l,d,p,f){var m=this,h=m["_on"+l];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(l,d,p){var f=this,m=f["_on"+l],h=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(h=0;h<m.length;h++){var y=p===m[h].id;if(d===m[h].fn&&y||!d&&y){m.splice(h,1);break}}else if(l)f["_on"+l]=[];else{var g=Object.keys(f);for(h=0;h<g.length;h++)g[h].indexOf("_on")===0&&Array.isArray(f[g[h]])&&(f[g[h]]=[])}return f},once:function(l,d,p){var f=this;return f.on(l,d,p,1),f},_emit:function(l,d,p){for(var f=this,m=f["_on"+l],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||l==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(l,m[h].fn,m[h].id));return f._loadQueue(l),f},_loadQueue:function(l){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===l&&(d._queue.shift(),d._loadQueue()),l||p.action()}return d},_ended:function(l){var d=this,p=l._sprite;if(!d._webAudio&&l._node&&!l._node.paused&&!l._node.ended&&l._node.currentTime<l._stop)return setTimeout(d._ended.bind(d,l),100),d;var f=!!(l._loop||d._sprite[p][2]);if(d._emit("end",l._id),!d._webAudio&&f&&d.stop(l._id,!0).play(l._id),d._webAudio&&f){d._emit("play",l._id),l._seek=l._start||0,l._rateSeek=0,l._playStart=r.ctx.currentTime;var m=(l._stop-l._start)*1e3/Math.abs(l._rate);d._endTimers[l._id]=setTimeout(d._ended.bind(d,l),m)}return d._webAudio&&!f&&(l._paused=!0,l._ended=!0,l._seek=l._start||0,l._rateSeek=0,d._clearTimer(l._id),d._cleanBuffer(l._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(l._id,!0),d},_clearTimer:function(l){var d=this;if(d._endTimers[l]){if(typeof d._endTimers[l]!="function")clearTimeout(d._endTimers[l]);else{var p=d._soundById(l);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[l],!1)}delete d._endTimers[l]}return d},_soundById:function(l){for(var d=this,p=0;p<d._sounds.length;p++)if(l===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var l=this;l._drain();for(var d=0;d<l._sounds.length;d++)if(l._sounds[d]._ended)return l._sounds[d].reset();return new t(l)},_drain:function(){var l=this,d=l._pool,p=0,f=0;if(!(l._sounds.length<d)){for(f=0;f<l._sounds.length;f++)l._sounds[f]._ended&&p++;for(f=l._sounds.length-1;f>=0;f--){if(p<=d)return;l._sounds[f]._ended&&(l._webAudio&&l._sounds[f]._node&&l._sounds[f]._node.disconnect(0),l._sounds.splice(f,1),p--)}}},_getSoundIds:function(l){var d=this;if(typeof l>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[l]},_refreshBuffer:function(l){var d=this;return l._node.bufferSource=r.ctx.createBufferSource(),l._node.bufferSource.buffer=o[d._src],l._panner?l._node.bufferSource.connect(l._panner):l._node.bufferSource.connect(l._node),l._node.bufferSource.loop=l._loop,l._loop&&(l._node.bufferSource.loopStart=l._start||0,l._node.bufferSource.loopEnd=l._stop||0),l._node.bufferSource.playbackRate.setValueAtTime(l._rate,r.ctx.currentTime),d},_cleanBuffer:function(l){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&l.bufferSource&&(l.bufferSource.onended=null,l.bufferSource.disconnect(0),p))try{l.bufferSource.buffer=r._scratchBuffer}catch{}return l.bufferSource=null,d},_clearSound:function(l){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(l.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(l){this._parent=l,this.init()};t.prototype={init:function(){var l=this,d=l._parent;return l._muted=d._muted,l._loop=d._loop,l._volume=d._volume,l._rate=d._rate,l._seek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,d._sounds.push(l),l.create(),l},create:function(){var l=this,d=l._parent,p=r._muted||l._muted||l._parent._muted?0:l._volume;return d._webAudio?(l._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),l._node.gain.setValueAtTime(p,r.ctx.currentTime),l._node.paused=!0,l._node.connect(r.masterGain)):r.noAudio||(l._node=r._obtainHtml5Audio(),l._errorFn=l._errorListener.bind(l),l._node.addEventListener("error",l._errorFn,!1),l._loadFn=l._loadListener.bind(l),l._node.addEventListener(r._canPlayEvent,l._loadFn,!1),l._endFn=l._endListener.bind(l),l._node.addEventListener("ended",l._endFn,!1),l._node.src=d._src,l._node.preload=d._preload===!0?"auto":d._preload,l._node.volume=p*r.volume(),l._node.load()),l},reset:function(){var l=this,d=l._parent;return l._muted=d._muted,l._loop=d._loop,l._volume=d._volume,l._rate=d._rate,l._seek=0,l._rateSeek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,l},_errorListener:function(){var l=this;l._parent._emit("loaderror",l._id,l._node.error?l._node.error.code:0),l._node.removeEventListener("error",l._errorFn,!1)},_loadListener:function(){var l=this,d=l._parent;d._duration=Math.ceil(l._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()),l._node.removeEventListener(r._canPlayEvent,l._loadFn,!1)},_endListener:function(){var l=this,d=l._parent;d._duration===1/0&&(d._duration=Math.ceil(l._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(l)),l._node.removeEventListener("ended",l._endFn,!1)}};var o={},i=function(l){var d=l._src;if(o[d]){l._duration=o[d].duration,c(l);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),m=0;m<p.length;++m)f[m]=p.charCodeAt(m);s(f.buffer,l)}else{var h=new XMLHttpRequest;h.open(l._xhr.method,d,!0),h.withCredentials=l._xhr.withCredentials,h.responseType="arraybuffer",l._xhr.headers&&Object.keys(l._xhr.headers).forEach(function(y){h.setRequestHeader(y,l._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){l._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}s(h.response,l)},h.onerror=function(){l._webAudio&&(l._html5=!0,l._webAudio=!1,l._sounds=[],delete o[d],l.load())},a(h)}},a=function(l){try{l.send()}catch{l.onerror()}},s=function(l,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&d._sounds.length>0?(o[d._src]=m,c(d,m)):p()};typeof Promise<"u"&&r.ctx.decodeAudioData.length===1?r.ctx.decodeAudioData(l).then(f).catch(p):r.ctx.decodeAudioData(l,f,p)},c=function(l,d){d&&!l._duration&&(l._duration=d.duration),Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue())},u=function(){if(!!r.usingWebAudio){try{typeof AudioContext<"u"?r.ctx=new AudioContext:typeof webkitAudioContext<"u"?r.ctx=new webkitAudioContext:r.usingWebAudio=!1}catch{r.usingWebAudio=!1}r.ctx||(r.usingWebAudio=!1);var l=/iP(hone|od|ad)/.test(r._navigator&&r._navigator.platform),d=r._navigator&&r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(l&&p&&p<9){var f=/safari/.test(r._navigator&&r._navigator.userAgent.toLowerCase());r._navigator&&!f&&(r.usingWebAudio=!1)}r.usingWebAudio&&(r.masterGain=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),r.masterGain.gain.setValueAtTime(r._muted?0:r._volume,r.ctx.currentTime),r.masterGain.connect(r.ctx.destination)),r._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:r,Howl:e}}),typeof uc<"u"&&(uc.Howler=r,uc.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=r,global.Howl=e,global.Sound=t):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=r,window.Howl=e,window.Sound=t)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(r){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(r);return e},HowlerGlobal.prototype.pos=function(r,e,t){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,t=typeof t!="number"?o._pos[2]:t,typeof r=="number")o._pos=[r,e,t],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(r,e,t,o,i,a){var s=this;if(!s.ctx||!s.ctx.listener)return s;var c=s._orientation;if(e=typeof e!="number"?c[1]:e,t=typeof t!="number"?c[2]:t,o=typeof o!="number"?c[3]:o,i=typeof i!="number"?c[4]:i,a=typeof a!="number"?c[5]:a,typeof r=="number")s._orientation=[r,e,t,o,i,a],typeof s.ctx.listener.forwardX<"u"?(s.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(t,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(r,e,t,o,i,a);else return c;return s},Howl.prototype.init=function(r){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._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},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],r.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(r,e){var t=this;if(!t._webAudio)return t;if(t._state!=="loaded")return t._queue.push({event:"stereo",action:function(){t.stereo(r,e)}}),t;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof r=="number")t._stereo=r,t._pos=[r,0,0];else return t._stereo;for(var i=t._getSoundIds(e),a=0;a<i.length;a++){var s=t._soundById(i[a]);if(s)if(typeof r=="number")s._stereo=r,s._pos=[r,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(r,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(r,0,0):s._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",s._id);else return s._stereo}return t},Howl.prototype.pos=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(r,e,t,o)}}),i;if(e=typeof e!="number"?0:e,t=typeof t!="number"?-.5:t,typeof o>"u")if(typeof r=="number")i._pos=[r,e,t];else return i._pos;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var c=i._soundById(a[s]);if(c)if(typeof r=="number")c._pos=[r,e,t],c._node&&((!c._panner||c._panner.pan)&&n(c,"spatial"),typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setPosition(r,e,t)),i._emit("pos",c._id);else return c._pos}return i},Howl.prototype.orientation=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(r,e,t,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,t=typeof t!="number"?i._orientation[2]:t,typeof o>"u")if(typeof r=="number")i._orientation=[r,e,t];else return i._orientation;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var c=i._soundById(a[s]);if(c)if(typeof r=="number")c._orientation=[r,e,t],c._node&&(c._panner||(c._pos||(c._pos=i._pos||[0,0,-.5]),n(c,"spatial")),typeof c._panner.orientationX<"u"?(c._panner.orientationX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.orientationZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setOrientation(r,e,t)),i._emit("orientation",c._id);else return c._orientation}return i},Howl.prototype.pannerAttr=function(){var r=this,e=arguments,t,o,i;if(!r._webAudio)return r;if(e.length===0)return r._pannerAttr;if(e.length===1)if(typeof e[0]=="object")t=e[0],typeof o>"u"&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:typeof t.pannerAttr.coneInnerAngle<"u"?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:typeof t.pannerAttr.coneOuterAngle<"u"?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:typeof t.pannerAttr.coneOuterGain<"u"?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:typeof t.pannerAttr.distanceModel<"u"?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:typeof t.pannerAttr.maxDistance<"u"?t.pannerAttr.maxDistance:r._maxDistance,refDistance:typeof t.pannerAttr.refDistance<"u"?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:typeof t.pannerAttr.rolloffFactor<"u"?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:typeof t.pannerAttr.panningModel<"u"?t.pannerAttr.panningModel:r._panningModel});else return i=r._soundById(parseInt(e[0],10)),i?i._pannerAttr:r._pannerAttr;else e.length===2&&(t=e[0],o=parseInt(e[1],10));for(var a=r._getSoundIds(o),s=0;s<a.length;s++)if(i=r._soundById(a[s]),i){var c=i._pannerAttr;c={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:c.coneInnerAngle,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:c.coneOuterAngle,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:c.coneOuterGain,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:c.distanceModel,maxDistance:typeof t.maxDistance<"u"?t.maxDistance:c.maxDistance,refDistance:typeof t.refDistance<"u"?t.refDistance:c.refDistance,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:c.rolloffFactor,panningModel:typeof t.panningModel<"u"?t.panningModel:c.panningModel};var u=i._panner;u?(u.coneInnerAngle=c.coneInnerAngle,u.coneOuterAngle=c.coneOuterAngle,u.coneOuterGain=c.coneOuterGain,u.distanceModel=c.distanceModel,u.maxDistance=c.maxDistance,u.refDistance=c.refDistance,u.rolloffFactor=c.rolloffFactor,u.panningModel=c.panningModel):(i._pos||(i._pos=r._pos||[0,0,-.5]),n(i,"spatial"))}return r},Sound.prototype.init=function(r){return function(){var e=this,t=e._parent;e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,r.call(this),e._stereo?t.stereo(e._stereo):e._pos&&t.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(r){return function(){var e=this,t=e._parent;return e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,e._stereo?t.stereo(e._stereo):e._pos?t.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,t._refreshBuffer(e)),r.call(this)}}(Sound.prototype.reset);var n=function(r,e){e=e||"spatial",e==="spatial"?(r._panner=Howler.ctx.createPanner(),r._panner.coneInnerAngle=r._pannerAttr.coneInnerAngle,r._panner.coneOuterAngle=r._pannerAttr.coneOuterAngle,r._panner.coneOuterGain=r._pannerAttr.coneOuterGain,r._panner.distanceModel=r._pannerAttr.distanceModel,r._panner.maxDistance=r._pannerAttr.maxDistance,r._panner.refDistance=r._pannerAttr.refDistance,r._panner.rolloffFactor=r._pannerAttr.rolloffFactor,r._panner.panningModel=r._pannerAttr.panningModel,typeof r._panner.positionX<"u"?(r._panner.positionX.setValueAtTime(r._pos[0],Howler.ctx.currentTime),r._panner.positionY.setValueAtTime(r._pos[1],Howler.ctx.currentTime),r._panner.positionZ.setValueAtTime(r._pos[2],Howler.ctx.currentTime)):r._panner.setPosition(r._pos[0],r._pos[1],r._pos[2]),typeof r._panner.orientationX<"u"?(r._panner.orientationX.setValueAtTime(r._orientation[0],Howler.ctx.currentTime),r._panner.orientationY.setValueAtTime(r._orientation[1],Howler.ctx.currentTime),r._panner.orientationZ.setValueAtTime(r._orientation[2],Howler.ctx.currentTime)):r._panner.setOrientation(r._orientation[0],r._orientation[1],r._orientation[2])):(r._panner=Howler.ctx.createStereoPanner(),r._panner.pan.setValueAtTime(r._stereo,Howler.ctx.currentTime)),r._panner.connect(r._node),r._paused||r._parent.pause(r._id,!0).play(r._id,!0)}})()});var ix=Pn((sre,nx)=>{nx.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}});import{FileLoader as XN,Loader as KN}from"three";function lp(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Dt(n,r){return Object.setPrototypeOf(n,r),n}function gs(n){return Array.isArray(n)?n:[n]}function cp(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 Tx=typeof global=="object"&&global&&global.Object===Object&&global,xs=Tx;var _x=typeof self=="object"&&self&&self.Object===Object&&self,Px=xs||_x||Function("return this")(),Qe=Px;var Ox=Qe.Symbol,st=Ox;var dp=Object.prototype,Ax=dp.hasOwnProperty,Cx=dp.toString,ga=st?st.toStringTag:void 0;function Nx(n){var r=Ax.call(n,ga),e=n[ga];try{n[ga]=void 0;var t=!0}catch{}var o=Cx.call(n);return t&&(r?n[ga]=e:delete n[ga]),o}var up=Nx;var Ix=Object.prototype,Mx=Ix.toString;function Ex(n){return Mx.call(n)}var pp=Ex;var Lx="[object Null]",Dx="[object Undefined]",fp=st?st.toStringTag:void 0;function Bx(n){return n==null?n===void 0?Dx:Lx:fp&&fp in Object(n)?up(n):pp(n)}var Ut=Bx;function Rx(n){return n!=null&&typeof n=="object"}var yt=Rx;var Gx="[object Symbol]";function Vx(n){return typeof n=="symbol"||yt(n)&&Ut(n)==Gx}var On=Vx;function zx(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 vs=zx;var jx=Array.isArray,He=jx;var Fx=1/0,mp=st?st.prototype:void 0,hp=mp?mp.toString:void 0;function yp(n){if(typeof n=="string")return n;if(He(n))return vs(n,yp)+"";if(On(n))return hp?hp.call(n):"";var r=n+"";return r=="0"&&1/n==-Fx?"-0":r}var gp=yp;function kx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Ht=kx;function Ux(n){return n}var xp=Ux;var Hx="[object AsyncFunction]",Wx="[object Function]",qx="[object GeneratorFunction]",$x="[object Proxy]";function Yx(n){if(!Ht(n))return!1;var r=Ut(n);return r==Wx||r==qx||r==Hx||r==$x}var bs=Yx;var Xx=Qe["__core-js_shared__"],Ss=Xx;var vp=function(){var n=/[^.]+$/.exec(Ss&&Ss.keys&&Ss.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Kx(n){return!!vp&&vp in n}var bp=Kx;var Zx=Function.prototype,Qx=Zx.toString;function Jx(n){if(n!=null){try{return Qx.call(n)}catch{}try{return n+""}catch{}}return""}var Yr=Jx;var ev=/[\\^$.*+?()[\]{}|]/g,tv=/^\[object .+?Constructor\]$/,rv=Function.prototype,ov=Object.prototype,nv=rv.toString,iv=ov.hasOwnProperty,av=RegExp("^"+nv.call(iv).replace(ev,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sv(n){if(!Ht(n)||bp(n))return!1;var r=bs(n)?av:tv;return r.test(Yr(n))}var Sp=sv;function lv(n,r){return n?.[r]}var wp=lv;function cv(n,r){var e=wp(n,r);return Sp(e)?e:void 0}var Bt=cv;var dv=Bt(Qe,"WeakMap"),ws=dv;var Tp=Object.create,uv=function(){function n(){}return function(r){if(!Ht(r))return{};if(Tp)return Tp(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),_p=uv;function pv(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 Pp=pv;function fv(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Op=fv;var mv=800,hv=16,yv=Date.now;function gv(n){var r=0,e=0;return function(){var t=yv(),o=hv-(t-e);if(e=t,o>0){if(++r>=mv)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Ap=gv;function xv(n){return function(){return n}}var Cp=xv;var vv=function(){try{var n=Bt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),An=vv;var bv=An?function(n,r){return An(n,"toString",{configurable:!0,enumerable:!1,value:Cp(r),writable:!0})}:xp,Np=bv;var Sv=Ap(Np),Ip=Sv;function wv(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var Mp=wv;var Tv=9007199254740991,_v=/^(?:0|[1-9]\d*)$/;function Pv(n,r){var e=typeof n;return r=r??Tv,!!r&&(e=="number"||e!="symbol"&&_v.test(n))&&n>-1&&n%1==0&&n<r}var Cn=Pv;function Ov(n,r,e){r=="__proto__"&&An?An(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var Ts=Ov;function Av(n,r){return n===r||n!==n&&r!==r}var Nn=Av;var Cv=Object.prototype,Nv=Cv.hasOwnProperty;function Iv(n,r,e){var t=n[r];(!(Nv.call(n,r)&&Nn(t,e))||e===void 0&&!(r in n))&&Ts(n,r,e)}var In=Iv;function Mv(n,r,e,t){var o=!e;e||(e={});for(var i=-1,a=r.length;++i<a;){var s=r[i],c=t?t(e[s],n[s],s,e,n):void 0;c===void 0&&(c=n[s]),o?Ts(e,s,c):In(e,s,c)}return e}var Sr=Mv;var Ep=Math.max;function Ev(n,r,e){return r=Ep(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Ep(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),Pp(n,this,s)}}var Lp=Ev;var Lv=9007199254740991;function Dv(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Lv}var Mn=Dv;function Bv(n){return n!=null&&Mn(n.length)&&!bs(n)}var _s=Bv;var Rv=Object.prototype;function Gv(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||Rv;return n===e}var En=Gv;function Vv(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Dp=Vv;var zv="[object Arguments]";function jv(n){return yt(n)&&Ut(n)==zv}var Dc=jv;var Bp=Object.prototype,Fv=Bp.hasOwnProperty,kv=Bp.propertyIsEnumerable,Uv=Dc(function(){return arguments}())?Dc:function(n){return yt(n)&&Fv.call(n,"callee")&&!kv.call(n,"callee")},Ln=Uv;function Hv(){return!1}var Rp=Hv;var zp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gp=zp&&typeof module=="object"&&module&&!module.nodeType&&module,Wv=Gp&&Gp.exports===zp,Vp=Wv?Qe.Buffer:void 0,qv=Vp?Vp.isBuffer:void 0,$v=qv||Rp,qo=$v;var Yv="[object Arguments]",Xv="[object Array]",Kv="[object Boolean]",Zv="[object Date]",Qv="[object Error]",Jv="[object Function]",eb="[object Map]",tb="[object Number]",rb="[object Object]",ob="[object RegExp]",nb="[object Set]",ib="[object String]",ab="[object WeakMap]",sb="[object ArrayBuffer]",lb="[object DataView]",cb="[object Float32Array]",db="[object Float64Array]",ub="[object Int8Array]",pb="[object Int16Array]",fb="[object Int32Array]",mb="[object Uint8Array]",hb="[object Uint8ClampedArray]",yb="[object Uint16Array]",gb="[object Uint32Array]",ze={};ze[cb]=ze[db]=ze[ub]=ze[pb]=ze[fb]=ze[mb]=ze[hb]=ze[yb]=ze[gb]=!0;ze[Yv]=ze[Xv]=ze[sb]=ze[Kv]=ze[lb]=ze[Zv]=ze[Qv]=ze[Jv]=ze[eb]=ze[tb]=ze[rb]=ze[ob]=ze[nb]=ze[ib]=ze[ab]=!1;function xb(n){return yt(n)&&Mn(n.length)&&!!ze[Ut(n)]}var jp=xb;function vb(n){return function(r){return n(r)}}var Dn=vb;var Fp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xa=Fp&&typeof module=="object"&&module&&!module.nodeType&&module,bb=xa&&xa.exports===Fp,Bc=bb&&xs.process,Sb=function(){try{var n=xa&&xa.require&&xa.require("util").types;return n||Bc&&Bc.binding&&Bc.binding("util")}catch{}}(),Xr=Sb;var kp=Xr&&Xr.isTypedArray,wb=kp?Dn(kp):jp,Ps=wb;var Tb=Object.prototype,_b=Tb.hasOwnProperty;function Pb(n,r){var e=He(n),t=!e&&Ln(n),o=!e&&!t&&qo(n),i=!e&&!t&&!o&&Ps(n),a=e||t||o||i,s=a?Dp(n.length,String):[],c=s.length;for(var u in n)(r||_b.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Cn(u,c)))&&s.push(u);return s}var Os=Pb;function Ob(n,r){return function(e){return n(r(e))}}var As=Ob;var Ab=As(Object.keys,Object),Up=Ab;var Cb=Object.prototype,Nb=Cb.hasOwnProperty;function Ib(n){if(!En(n))return Up(n);var r=[];for(var e in Object(n))Nb.call(n,e)&&e!="constructor"&&r.push(e);return r}var Hp=Ib;function Mb(n){return _s(n)?Os(n):Hp(n)}var Bn=Mb;function Eb(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var Wp=Eb;var Lb=Object.prototype,Db=Lb.hasOwnProperty;function Bb(n){if(!Ht(n))return Wp(n);var r=En(n),e=[];for(var t in n)t=="constructor"&&(r||!Db.call(n,t))||e.push(t);return e}var qp=Bb;function Rb(n){return _s(n)?Os(n,!0):qp(n)}var Rn=Rb;var Gb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vb=/^\w*$/;function zb(n,r){if(He(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||On(n)?!0:Vb.test(n)||!Gb.test(n)||r!=null&&n in Object(r)}var $p=zb;var jb=Bt(Object,"create"),Kr=jb;function Fb(){this.__data__=Kr?Kr(null):{},this.size=0}var Yp=Fb;function kb(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Xp=kb;var Ub="__lodash_hash_undefined__",Hb=Object.prototype,Wb=Hb.hasOwnProperty;function qb(n){var r=this.__data__;if(Kr){var e=r[n];return e===Ub?void 0:e}return Wb.call(r,n)?r[n]:void 0}var Kp=qb;var $b=Object.prototype,Yb=$b.hasOwnProperty;function Xb(n){var r=this.__data__;return Kr?r[n]!==void 0:Yb.call(r,n)}var Zp=Xb;var Kb="__lodash_hash_undefined__";function Zb(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Kr&&r===void 0?Kb:r,this}var Qp=Zb;function Gn(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])}}Gn.prototype.clear=Yp;Gn.prototype.delete=Xp;Gn.prototype.get=Kp;Gn.prototype.has=Zp;Gn.prototype.set=Qp;var Rc=Gn;function Qb(){this.__data__=[],this.size=0}var Jp=Qb;function Jb(n,r){for(var e=n.length;e--;)if(Nn(n[e][0],r))return e;return-1}var mo=Jb;var eS=Array.prototype,tS=eS.splice;function rS(n){var r=this.__data__,e=mo(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():tS.call(r,e,1),--this.size,!0}var ef=rS;function oS(n){var r=this.__data__,e=mo(r,n);return e<0?void 0:r[e][1]}var tf=oS;function nS(n){return mo(this.__data__,n)>-1}var rf=nS;function iS(n,r){var e=this.__data__,t=mo(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var of=iS;function Vn(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])}}Vn.prototype.clear=Jp;Vn.prototype.delete=ef;Vn.prototype.get=tf;Vn.prototype.has=rf;Vn.prototype.set=of;var ho=Vn;var aS=Bt(Qe,"Map"),yo=aS;function sS(){this.size=0,this.__data__={hash:new Rc,map:new(yo||ho),string:new Rc}}var nf=sS;function lS(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var af=lS;function cS(n,r){var e=n.__data__;return af(r)?e[typeof r=="string"?"string":"hash"]:e.map}var go=cS;function dS(n){var r=go(this,n).delete(n);return this.size-=r?1:0,r}var sf=dS;function uS(n){return go(this,n).get(n)}var lf=uS;function pS(n){return go(this,n).has(n)}var cf=pS;function fS(n,r){var e=go(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var df=fS;function zn(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])}}zn.prototype.clear=nf;zn.prototype.delete=sf;zn.prototype.get=lf;zn.prototype.has=cf;zn.prototype.set=df;var $o=zn;var mS="Expected a function";function Gc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(mS);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(Gc.Cache||$o),e}Gc.Cache=$o;var uf=Gc;var hS=500;function yS(n){var r=uf(n,function(t){return e.size===hS&&e.clear(),t}),e=r.cache;return r}var pf=yS;var gS=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xS=/\\(\\)?/g,vS=pf(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(gS,function(e,t,o,i){r.push(o?i.replace(xS,"$1"):t||e)}),r}),ff=vS;function bS(n){return n==null?"":gp(n)}var mf=bS;function SS(n,r){return He(n)?n:$p(n,r)?[n]:ff(mf(n))}var Kt=SS;var wS=1/0;function TS(n){if(typeof n=="string"||On(n))return n;var r=n+"";return r=="0"&&1/n==-wS?"-0":r}var xo=TS;function _S(n,r){r=Kt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[xo(r[e++])];return e&&e==t?n:void 0}var Cs=_S;function PS(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var jn=PS;var hf=st?st.isConcatSpreadable:void 0;function OS(n){return He(n)||Ln(n)||!!(hf&&n&&n[hf])}var yf=OS;function gf(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=yf),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?gf(s,r-1,e,t,o):jn(o,s):t||(o[o.length]=s)}return o}var xf=gf;function AS(n){var r=n==null?0:n.length;return r?xf(n,1):[]}var vf=AS;function CS(n){return Ip(Lp(n,void 0,vf),n+"")}var Ns=CS;var NS=As(Object.getPrototypeOf,Object),Fn=NS;var IS="[object Object]",MS=Function.prototype,ES=Object.prototype,bf=MS.toString,LS=ES.hasOwnProperty,DS=bf.call(Object);function BS(n){if(!yt(n)||Ut(n)!=IS)return!1;var r=Fn(n);if(r===null)return!0;var e=LS.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&bf.call(e)==DS}var Sf=BS;function RS(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 wf=RS;function GS(){this.__data__=new ho,this.size=0}var Tf=GS;function VS(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var _f=VS;function zS(n){return this.__data__.get(n)}var Pf=zS;function jS(n){return this.__data__.has(n)}var Of=jS;var FS=200;function kS(n,r){var e=this.__data__;if(e instanceof ho){var t=e.__data__;if(!yo||t.length<FS-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new $o(t)}return e.set(n,r),this.size=e.size,this}var Af=kS;function kn(n){var r=this.__data__=new ho(n);this.size=r.size}kn.prototype.clear=Tf;kn.prototype.delete=_f;kn.prototype.get=Pf;kn.prototype.has=Of;kn.prototype.set=Af;var Un=kn;function US(n,r){return n&&Sr(r,Bn(r),n)}var Cf=US;function HS(n,r){return n&&Sr(r,Rn(r),n)}var Nf=HS;var Lf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,If=Lf&&typeof module=="object"&&module&&!module.nodeType&&module,WS=If&&If.exports===Lf,Mf=WS?Qe.Buffer:void 0,Ef=Mf?Mf.allocUnsafe:void 0;function qS(n,r){if(r)return n.slice();var e=n.length,t=Ef?Ef(e):new n.constructor(e);return n.copy(t),t}var Df=qS;function $S(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 Bf=$S;function YS(){return[]}var Is=YS;var XS=Object.prototype,KS=XS.propertyIsEnumerable,Rf=Object.getOwnPropertySymbols,ZS=Rf?function(n){return n==null?[]:(n=Object(n),Bf(Rf(n),function(r){return KS.call(n,r)}))}:Is,Hn=ZS;function QS(n,r){return Sr(n,Hn(n),r)}var Gf=QS;var JS=Object.getOwnPropertySymbols,ew=JS?function(n){for(var r=[];n;)jn(r,Hn(n)),n=Fn(n);return r}:Is,Ms=ew;function tw(n,r){return Sr(n,Ms(n),r)}var Vf=tw;function rw(n,r,e){var t=r(n);return He(n)?t:jn(t,e(n))}var Es=rw;function ow(n){return Es(n,Bn,Hn)}var va=ow;function nw(n){return Es(n,Rn,Ms)}var Ls=nw;var iw=Bt(Qe,"DataView"),Ds=iw;var aw=Bt(Qe,"Promise"),Bs=aw;var sw=Bt(Qe,"Set"),Rs=sw;var zf="[object Map]",lw="[object Object]",jf="[object Promise]",Ff="[object Set]",kf="[object WeakMap]",Uf="[object DataView]",cw=Yr(Ds),dw=Yr(yo),uw=Yr(Bs),pw=Yr(Rs),fw=Yr(ws),Yo=Ut;(Ds&&Yo(new Ds(new ArrayBuffer(1)))!=Uf||yo&&Yo(new yo)!=zf||Bs&&Yo(Bs.resolve())!=jf||Rs&&Yo(new Rs)!=Ff||ws&&Yo(new ws)!=kf)&&(Yo=function(n){var r=Ut(n),e=r==lw?n.constructor:void 0,t=e?Yr(e):"";if(t)switch(t){case cw:return Uf;case dw:return zf;case uw:return jf;case pw:return Ff;case fw:return kf}return r});var Zr=Yo;var mw=Object.prototype,hw=mw.hasOwnProperty;function yw(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hw.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Hf=yw;var gw=Qe.Uint8Array,Wn=gw;function xw(n){var r=new n.constructor(n.byteLength);return new Wn(r).set(new Wn(n)),r}var qn=xw;function vw(n,r){var e=r?qn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Wf=vw;var bw=/\w*$/;function Sw(n){var r=new n.constructor(n.source,bw.exec(n));return r.lastIndex=n.lastIndex,r}var qf=Sw;var $f=st?st.prototype:void 0,Yf=$f?$f.valueOf:void 0;function ww(n){return Yf?Object(Yf.call(n)):{}}var Xf=ww;function Tw(n,r){var e=r?qn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Kf=Tw;var _w="[object Boolean]",Pw="[object Date]",Ow="[object Map]",Aw="[object Number]",Cw="[object RegExp]",Nw="[object Set]",Iw="[object String]",Mw="[object Symbol]",Ew="[object ArrayBuffer]",Lw="[object DataView]",Dw="[object Float32Array]",Bw="[object Float64Array]",Rw="[object Int8Array]",Gw="[object Int16Array]",Vw="[object Int32Array]",zw="[object Uint8Array]",jw="[object Uint8ClampedArray]",Fw="[object Uint16Array]",kw="[object Uint32Array]";function Uw(n,r,e){var t=n.constructor;switch(r){case Ew:return qn(n);case _w:case Pw:return new t(+n);case Lw:return Wf(n,e);case Dw:case Bw:case Rw:case Gw:case Vw:case zw:case jw:case Fw:case kw:return Kf(n,e);case Ow:return new t;case Aw:case Iw:return new t(n);case Cw:return qf(n);case Nw:return new t;case Mw:return Xf(n)}}var Zf=Uw;function Hw(n){return typeof n.constructor=="function"&&!En(n)?_p(Fn(n)):{}}var Qf=Hw;var Ww="[object Map]";function qw(n){return yt(n)&&Zr(n)==Ww}var Jf=qw;var em=Xr&&Xr.isMap,$w=em?Dn(em):Jf,tm=$w;var Yw="[object Set]";function Xw(n){return yt(n)&&Zr(n)==Yw}var rm=Xw;var om=Xr&&Xr.isSet,Kw=om?Dn(om):rm,nm=Kw;var Zw=1,Qw=2,Jw=4,im="[object Arguments]",e1="[object Array]",t1="[object Boolean]",r1="[object Date]",o1="[object Error]",am="[object Function]",n1="[object GeneratorFunction]",i1="[object Map]",a1="[object Number]",sm="[object Object]",s1="[object RegExp]",l1="[object Set]",c1="[object String]",d1="[object Symbol]",u1="[object WeakMap]",p1="[object ArrayBuffer]",f1="[object DataView]",m1="[object Float32Array]",h1="[object Float64Array]",y1="[object Int8Array]",g1="[object Int16Array]",x1="[object Int32Array]",v1="[object Uint8Array]",b1="[object Uint8ClampedArray]",S1="[object Uint16Array]",w1="[object Uint32Array]",Ge={};Ge[im]=Ge[e1]=Ge[p1]=Ge[f1]=Ge[t1]=Ge[r1]=Ge[m1]=Ge[h1]=Ge[y1]=Ge[g1]=Ge[x1]=Ge[i1]=Ge[a1]=Ge[sm]=Ge[s1]=Ge[l1]=Ge[c1]=Ge[d1]=Ge[v1]=Ge[b1]=Ge[S1]=Ge[w1]=!0;Ge[o1]=Ge[am]=Ge[u1]=!1;function Gs(n,r,e,t,o,i){var a,s=r&Zw,c=r&Qw,u=r&Jw;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!Ht(n))return n;var l=He(n);if(l){if(a=Hf(n),!s)return Op(n,a)}else{var d=Zr(n),p=d==am||d==n1;if(qo(n))return Df(n,s);if(d==sm||d==im||p&&!o){if(a=c||p?{}:Qf(n),!s)return c?Vf(n,Nf(a,n)):Gf(n,Cf(a,n))}else{if(!Ge[d])return o?n:{};a=Zf(n,d,s)}}i||(i=new Un);var f=i.get(n);if(f)return f;i.set(n,a),nm(n)?n.forEach(function(y){a.add(Gs(y,r,e,y,n,i))}):tm(n)&&n.forEach(function(y,g){a.set(g,Gs(y,r,e,g,n,i))});var m=u?c?Ls:va:c?Rn:Bn,h=l?void 0:m(n);return Mp(h||n,function(y,g){h&&(g=y,y=n[g]),In(a,g,Gs(y,r,e,g,n,i))}),a}var Vs=Gs;var T1=1,_1=4;function P1(n){return Vs(n,T1|_1)}var Qr=P1;var O1="__lodash_hash_undefined__";function A1(n){return this.__data__.set(n,O1),this}var lm=A1;function C1(n){return this.__data__.has(n)}var cm=C1;function zs(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new $o;++r<e;)this.add(n[r])}zs.prototype.add=zs.prototype.push=lm;zs.prototype.has=cm;var dm=zs;function N1(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 um=N1;function I1(n,r){return n.has(r)}var pm=I1;var M1=1,E1=2;function L1(n,r,e,t,o,i){var a=e&M1,s=n.length,c=r.length;if(s!=c&&!(a&&c>s))return!1;var u=i.get(n),l=i.get(r);if(u&&l)return u==r&&l==n;var d=-1,p=!0,f=e&E1?new dm:void 0;for(i.set(n,r),i.set(r,n);++d<s;){var m=n[d],h=r[d];if(t)var y=a?t(h,m,d,r,n,i):t(m,h,d,n,r,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!um(r,function(g,x){if(!pm(f,x)&&(m===g||o(m,g,e,t,i)))return f.push(x)})){p=!1;break}}else if(!(m===h||o(m,h,e,t,i))){p=!1;break}}return i.delete(n),i.delete(r),p}var js=L1;function D1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var fm=D1;function B1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var mm=B1;var R1=1,G1=2,V1="[object Boolean]",z1="[object Date]",j1="[object Error]",F1="[object Map]",k1="[object Number]",U1="[object RegExp]",H1="[object Set]",W1="[object String]",q1="[object Symbol]",$1="[object ArrayBuffer]",Y1="[object DataView]",hm=st?st.prototype:void 0,Vc=hm?hm.valueOf:void 0;function X1(n,r,e,t,o,i,a){switch(e){case Y1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case $1:return!(n.byteLength!=r.byteLength||!i(new Wn(n),new Wn(r)));case V1:case z1:case k1:return Nn(+n,+r);case j1:return n.name==r.name&&n.message==r.message;case U1:case W1:return n==r+"";case F1:var s=fm;case H1:var c=t&R1;if(s||(s=mm),n.size!=r.size&&!c)return!1;var u=a.get(n);if(u)return u==r;t|=G1,a.set(n,r);var l=js(s(n),s(r),t,o,i,a);return a.delete(n),l;case q1:if(Vc)return Vc.call(n)==Vc.call(r)}return!1}var ym=X1;var K1=1,Z1=Object.prototype,Q1=Z1.hasOwnProperty;function J1(n,r,e,t,o,i){var a=e&K1,s=va(n),c=s.length,u=va(r),l=u.length;if(c!=l&&!a)return!1;for(var d=c;d--;){var p=s[d];if(!(a?p in r:Q1.call(r,p)))return!1}var f=i.get(n),m=i.get(r);if(f&&m)return f==r&&m==n;var h=!0;i.set(n,r),i.set(r,n);for(var y=a;++d<c;){p=s[d];var g=n[p],x=r[p];if(t)var S=a?t(x,g,p,r,n,i):t(g,x,p,n,r,i);if(!(S===void 0?g===x||o(g,x,e,t,i):S)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,b=r.constructor;w!=b&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof b=="function"&&b instanceof b)&&(h=!1)}return i.delete(n),i.delete(r),h}var gm=J1;var eT=1,xm="[object Arguments]",vm="[object Array]",Fs="[object Object]",tT=Object.prototype,bm=tT.hasOwnProperty;function rT(n,r,e,t,o,i){var a=He(n),s=He(r),c=a?vm:Zr(n),u=s?vm:Zr(r);c=c==xm?Fs:c,u=u==xm?Fs:u;var l=c==Fs,d=u==Fs,p=c==u;if(p&&qo(n)){if(!qo(r))return!1;a=!0,l=!1}if(p&&!l)return i||(i=new Un),a||Ps(n)?js(n,r,e,t,o,i):ym(n,r,c,e,t,o,i);if(!(e&eT)){var f=l&&bm.call(n,"__wrapped__"),m=d&&bm.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Un),o(h,y,e,t,i)}}return p?(i||(i=new Un),gm(n,r,e,t,o,i)):!1}var Sm=rT;function wm(n,r,e,t,o){return n===r?!0:n==null||r==null||!yt(n)&&!yt(r)?n!==n&&r!==r:Sm(n,r,e,t,wm,o)}var Tm=wm;function oT(n,r){return n!=null&&r in Object(n)}var _m=oT;function nT(n,r,e){r=Kt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=xo(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&&Mn(o)&&Cn(a,o)&&(He(n)||Ln(n)))}var Pm=nT;function iT(n,r){return n!=null&&Pm(n,r,_m)}var Om=iT;function aT(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Am=aT;function sT(n,r){return r.length<2?n:Cs(n,wf(r,0,-1))}var Cm=sT;function lT(n,r){return Tm(n,r)}var zc=lT;function cT(n,r){return r=Kt(r,n),n=Cm(n,r),n==null||delete n[xo(Am(r))]}var Nm=cT;function dT(n){return Sf(n)?void 0:n}var Im=dT;var uT=1,pT=2,fT=4,mT=Ns(function(n,r){var e={};if(n==null)return e;var t=!1;r=vs(r,function(i){return i=Kt(i,n),t||(t=i.length>1),i}),Sr(n,Ls(n),e),t&&(e=Vs(e,uT|pT|fT,Im));for(var o=r.length;o--;)Nm(e,r[o]);return e}),$n=mT;function hT(n,r,e,t){if(!Ht(n))return n;r=Kt(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var c=xo(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=a){var l=s[c];u=t?t(l,c,s):void 0,u===void 0&&(u=Ht(l)?l:Cn(r[o+1])?[]:{})}In(s,c,u),s=s[c]}return n}var Mm=hT;function yT(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=Cs(n,a);e(s,a)&&Mm(i,Kt(a,n),s)}return i}var Em=yT;function gT(n,r){return Em(n,r,function(e,t){return Om(n,t)})}var Lm=gT;var xT=Ns(function(n,r){return n==null?{}:Lm(n,r)}),nr=xT;var fe=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,fe.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,fe.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,fe.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function ba(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"&&ba(t)}return Object.freeze(n)}function Dm(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 Yn=class extends Error{};function ks(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function wr(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 Xn(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 Bm(){return typeof process<"u"}function Rm(n,r){for(let e of n)r(e.id,e.data)!==!0&&Rm(e.children,r)}function Gm(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Gm(e,r)}var Fe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Fe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ba(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&&Gm(o,t)}}traverse(e){Rm(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(l=>l.id===e);if(s<0)throw new Error("not expected");let c=a[s];return a=[...a],a[s]={...c,data:t},this.modifyArrayBy(i,a)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let s=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(l=>l.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,Fe.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 c=t,u=this.childrenArray(c),l={fi:o,id:i,data:a,children:s};return u=[...u,l],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(l),{data:this.modifyArrayBy(c,u),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(u=>u.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 f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new Yn("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,c=this.childrenArray(a),u=c.findIndex(f=>f.id===i);c=[...c];let l=c.splice(u,1)[0],d=this.modifyArrayBy(a,c);a=t,c=d.childrenArray(a);let p=l.fi;return l={...l,fi:o},c=[...c,l],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(l),d=d.modifyArrayBy(a,c),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,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)=>Dm(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 wr(0,o,o);{let a=i[0].fi;return wr(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(c=>c.fi>a.fi);if(s===void 0){let c=i[i.length-1].fi;return wr(c,c+o,o)}else return wr(a.fi,s.fi,o)}}};var Kn;(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 c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=a[u],a[u]=o[c],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 c of Object.keys(o)){i[c]=a[c];let u=o[c];u===void 0?delete a[c]:a[c]=u,s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Kn||(Kn={}));var he=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,he.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ba(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(u=>u.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,he.prototype);let t=e;return Bm()||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((u,l)=>u.fi-l.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(c=>c.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(l=>l.id===o);if(a===-1)return null;let s=i[a].fi,c={...i[a],fi:t};return i[a]=c,i.sort((l,d)=>l.fi-d.fi),e.localIndex=i.indexOf(c),{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 wr(0,t,t);{let i=o[0].fi;return wr(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 wr(s,s+t,t)}else return wr(i.fi,a.fi,t)}}};function Zn(n){return n&&typeof n=="object"&&n instanceof Re}var Re=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&&!Zn(t))return null;o+=1}t=t?ks(t):new Re;for(let[c,u]of Object.entries(r.props)){let l=t[c];i[c]=l,u===void 0?delete t[c]:t[c]=u}for(;o>0;){if(Object.keys(t).length===0){let c=e[o-1];c&&(t=ks(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=ks(c);u[r.path[o-1]]=t,t=u}else{let u=new Re;u[r.path[o-1]]=t,t=u}}o-=1}let a=Object.setPrototypeOf(t,Re.prototype),s={...r,props:i};return{data:a,actual:r,reverse:s}}},Tr;(t=>{function n(o,i){return Sa(o,i)??o}t.apply=n;function r(o,i){return Fc(o,i)}t.merge=r;function e(o,i){let a=0,s=i.path,c=o;for(;a<s.length&&c!==void 0;){if(c=Je.zoomOnce(c,s[a]),c===void 0)return i;if(!Zn(c))return;a+=1}if(c===void 0)return i;if(!!Zn(c))if(i.type===0){let u={...i.props};for(let l of Object.keys(c))delete u[l];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=jc([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(Tr||(Tr={}));function jc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=Sa(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=jc(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 vT(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=Sa(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 Sa(n,r){if(!Zn(r))return r;if(n instanceof Fe){let e=jc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof he)return vT(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=Sa(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 Re)return Fc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=Sa(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 Fc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Zn(r))return r;if(!Zn(n))return Tr.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 Re;for(let o of e){let i=Fc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Vm(n,r){let e={cur:[],result:[],len:0};return n=wa(n,r,e)??n,[n,e.result]}function Us(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Hs(n){n&&(n.len-=1)}function bT(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function zm(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 c=wa(i.data,r,Us(e,a));Hs(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=zm(i.children,r,e);return u!==void 0?t=!0:u=i.children,{...i,id:a,data:c,children:u}});if(t)return o}function ST(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 c=wa(i.data,r,Us(e,a));return Hs(e),t=t||c!==void 0,c===void 0&&(c=i.data),{...i,id:a,data:c}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function wa(n,r,e){if(n instanceof Fe){let t=zm(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof he)return ST(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=wa(i,r,Us(e,a));return Hs(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"&&!Xn(n)){let t={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"&&i!=="text"){let s=r[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let c=wa(a,r,Us(e,i));Hs(e),o=o||c!==void 0,c===void 0&&(c=a),t[i]=c}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&&bT(e),t}else return}}var Ws;(r=>{function n(e,t){let o=Je.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})(Ws||(Ws={}));var et;(s=>{function n(c,u){return{...c,path:c.path.slice(u)}}s.drop=n;function r(c,u){return e(c,u)?.data??c}s.applySimple=r;function e(c,u){let l=u.path;for(var d=[];;){let p;if(c instanceof Re&&u.type===0&&(p=c.runOp({...u,path:l.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===l.length&&(c instanceof Fe||c instanceof he||c instanceof fe?p=c.runOp(u):p=Kn.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=l[y],x=d[y];if(x instanceof Fe){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof he){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof fe){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof Re){let S={...x,[g]:h};h=Object.setPrototypeOf(S,Re.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let S=h;h=[...x],h[g]=S}else h={...x,[g]:h};else return null}return{data:h,actual:{...p.actual,path:l},reverse:{...p.reverse,path:l}}}else return null;let f=l[d.length],m;if(c instanceof Fe){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof he){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else c!==null&&(m=c[f]);if(m!==void 0)d.push(c),c=m;else return null}}s.apply=e;function t(c,u){for(let l=0;l<c.length&&l<u.length;l++)if(c[l]!==u[l])return!0;return!1}s.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let l=0;l<c.length;l++)if(c[l]!==u[l])return!1;return!0}s.pathEq=o;function i(c,u){return t(c.path,u.path)}s.commutative=i;function a(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(l=>u.props[l]!==void 0):!1}s.subsumed=a})(et||(et={}));var Ta;(c=>{function n(){return[]}c.empty=n;function r(u,l){let d=[];for(let p of u){let[f,...m]=p.path;f===l&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,l){return u.map(d=>({...d,path:[l,...d.path]}))}c.addPrefix=e;function t(u,l){return[...u,...l]}c.concat=t;function o(u,l){return[...u.filter(p=>!l.some(f=>et.subsumed(p,f))),...l]}c.compress=o;function i(u,l){return u.every(d=>l.every(p=>et.commutative(d,p)))}c.commutative=i;function a(u,l){for(let d of l){let p=s(u,d);p!==null&&(u=p.data)}return u}c.applyAll=a;function s(u,l){var d=u;let p=[],f=[];for(let m of l)try{if(m.type===3){let h,y;m.path[m.path.length-1]==="variables"?h=Je.zoom(d,[...m.path,m.id,"value"]):h=Je.zoom(d,[...m.path,m.id]);let g=et.apply(d,{...m,type:2});if(g!==null){d=g.data;let[x,S]=Vm(d,{[m.id]:h});d=x;for(let w=0;w<S.length;w++){let b=S[w],T=b.pop();if(typeof T=="number"){let _=[T];for(let N=w+1;N<S.length;N++){let P=S[N],C=P[P.length-1];if(typeof C=="number"&&Je.equal(b,P.slice(0,P.length-1)))_.push(C),S.splice(N,1);else break}let v=Je.zoom(d,b);y=v.map((N,P)=>_.includes(P)?m.id:N),h=v,T=b.pop()}else y=m.id;p.push({type:0,path:b,props:{[T]:h}}),f.push({type:0,path:b,props:{[T]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let h=et.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof Yn)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=s})(Ta||(Ta={}));var jm=Symbol(),wT=Symbol(),$s=Symbol(),Xo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof qs);){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[$s];t&&t(),delete this._children[r]}}}},Uc=class extends Xo{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,Kn.runOp(this._current,r),r.path)}},Hc=class extends Xo{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,fe.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Fm={get(n,r){if(r===$s)return()=>{n._parent=null};if(r===jm)return n._current;if(r===wT)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=Ys(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]}}},TT={...Fm,set(n,r,e){let t={type:0,props:{[r]:We(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}},_T={...Fm,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}},Qn=class extends Xo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[$s]=()=>{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=Ys(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)}},Jn=class extends Xo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[$s]=()=>{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=Ys(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 kc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Je.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var qs=class extends Xo{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){kc(this.ts,e,r),kc(this.actual,t,r),kc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Ys(n,r,e){return e instanceof Fe?new Qn(n,r,e):e instanceof he?new Jn(n,r,e):e instanceof fe?new Proxy(new Hc(n,r,e),_T):e!==null&&typeof e=="object"?Xn(e)?e:new Proxy(new Uc(n,r,e),TT):e}function Wc(n){let r=new qs(n);return[Ys(r,"",n),r]}function vo(n,r){let[e,t]=Wc(n);return r(e),t.result()}function We(n){return n instanceof Qn||n instanceof Jn?n._current:n!==null&&typeof n=="object"?n[jm]:n}var Je;(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 c=t(s,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...a};return Object.keys(c).forEach(l=>{delete u[l]}),u}else return a}o.removeOverridden=r;function e(i,a){if((i instanceof Fe||i instanceof Qn)&&typeof a=="string")return i.data(a);if((i instanceof he||i instanceof Jn)&&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})(Je||(Je={}));function km(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 _t(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 Xs=class{},_a=class extends Xs{constructor(e){super();this.id=e}},Pa=class extends Xs{constructor(e){super();this.data=e}};var $c;try{$c=new TextDecoder}catch{}var re,So,I=0;var Km=[],Yc=Km,Xc=0,Rt={},Ie,bo,Zt=0,_r=0,Wt,Jr,Ot=[],Ee,Um={useRecords:!1,mapsAsObjects:!0},Oa=class{},Zc=new Oa;Zc.name="MessagePack 0xC1";var ei=!1,Pr=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(re)return th(()=>(Zs(),this?this.unpack(r,e):Pr.prototype.unpack.call(Um,r,e)));So=e>-1?e:r.length,I=0,Xc=0,_r=0,bo=null,Yc=Km,Wt=null,re=r;try{Ee=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw re=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 Pr){if(Rt=this,this.structures)return Ie=this.structures,Ks();(!Ie||Ie.length>0)&&(Ie=[])}else Rt=Um,(!Ie||Ie.length>0)&&(Ie=[]);return Ks()}unpackMultiple(r,e){let t,o=0;try{ei=!0;let i=r.length,a=this?this.unpack(r,i):el.unpack(r,i);if(e){for(e(a);I<i;)if(o=I,e(Ks())===!1)return}else{for(t=[a];I<i;)o=I,t.push(Ks());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{ei=!1,Zs()}}_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 Ks(){try{if(!Rt.trusted&&!ei){let r=Ie.sharedLength||0;r<Ie.length&&(Ie.length=r)}let n=qe();if(I==So)Ie.restoreStructures&&Hm(),Ie=null,re=null,Jr&&(Jr=null);else if(I>So){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!ei)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ie.restoreStructures&&Hm(),Zs(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Hm(){for(let n in Ie.restoreStructures)Ie[n]=Ie.restoreStructures[n];Ie.restoreStructures=null}function qe(){let n=re[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Ie[n&63]||Rt.getStructures&&Zm()[n&63];return r?(r.read||(r.read=Qc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Rt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Jm()]=qe();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(qe(),qe());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=qe();return r}else if(n<192){let r=n-160;if(_r>=I)return bo.slice(I-Zt,(I+=r)-Zt);if(_r==0&&So<140){let e=r<16?Jc(r):Qm(r);if(e!=null)return e}return Kc(r)}else{let r;switch(n){case 192:return null;case 193:return Wt?(r=qe(),r>0?Wt[1].slice(Wt.position1,Wt.position1+=r):Wt[0].slice(Wt.position0,Wt.position0-=r)):Zc;case 194:return!1;case 195:return!0;case 196:return qc(re[I++]);case 197:return r=Ee.getUint16(I),I+=2,qc(r);case 198:return r=Ee.getUint32(I),I+=4,qc(r);case 199:return Ko(re[I++]);case 200:return r=Ee.getUint16(I),I+=2,Ko(r);case 201:return r=Ee.getUint32(I),I+=4,Ko(r);case 202:if(r=Ee.getFloat32(I),Rt.useFloat32>2){let e=Js[(re[I]&127)<<1|re[I+1]>>7];return I+=4,(e*r+(r>0?.5:-.5)>>0)/e}return I+=4,r;case 203:return r=Ee.getFloat64(I),I+=8,r;case 204:return re[I++];case 205:return r=Ee.getUint16(I),I+=2,r;case 206:return r=Ee.getUint32(I),I+=4,r;case 207:return Rt.int64AsNumber?(r=Ee.getUint32(I)*4294967296,r+=Ee.getUint32(I+4)):r=Ee.getBigUint64(I),I+=8,r;case 208:return Ee.getInt8(I++);case 209:return r=Ee.getInt16(I),I+=2,r;case 210:return r=Ee.getInt32(I),I+=4,r;case 211:return Rt.int64AsNumber?(r=Ee.getInt32(I)*4294967296,r+=Ee.getUint32(I+4)):r=Ee.getBigInt64(I),I+=8,r;case 212:if(r=re[I++],r==114)return Xm(re[I++]&63);{let e=Ot[r];if(e)return e.read?(I++,e.read(qe())):e.noBuffer?(I++,e()):e(re.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=re[I],r==114?(I++,Xm(re[I++]&63,re[I++])):Ko(2);case 214:return Ko(4);case 215:return Ko(8);case 216:return Ko(16);case 217:return r=re[I++],_r>=I?bo.slice(I-Zt,(I+=r)-Zt):OT(r);case 218:return r=Ee.getUint16(I),I+=2,_r>=I?bo.slice(I-Zt,(I+=r)-Zt):AT(r);case 219:return r=Ee.getUint32(I),I+=4,_r>=I?bo.slice(I-Zt,(I+=r)-Zt):CT(r);case 220:return r=Ee.getUint16(I),I+=2,qm(r);case 221:return r=Ee.getUint32(I),I+=4,qm(r);case 222:return r=Ee.getUint16(I),I+=2,$m(r);case 223:return r=Ee.getUint32(I),I+=4,$m(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 PT=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Qc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>PT.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(qe);return n.highByte===0&&(n.read=Wm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=qe()}return t}return e.count=0,n.highByte===0?Wm(r,e):e}var Wm=(n,r)=>function(){let e=re[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ie[t]||Zm()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Qc(o,n)),o.read()};function Zm(){let n=th(()=>(re=null,Rt.getStructures()));return Ie=Rt._mergeStructures(n,Ie)}var Kc=Qs,OT=Qs,AT=Qs,CT=Qs;function Qs(n){let r;if(n<16&&(r=Jc(n)))return r;if(n>64&&$c)return $c.decode(re.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=re[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=re[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=re[I++]&63,a=re[I++]&63;t.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=re[I++]&63,a=re[I++]&63,s=re[I++]&63,c=(o&7)<<18|i<<12|a<<6|s;c>65535&&(c-=65536,t.push(c>>>10&1023|55296),c=56320|c&1023),t.push(c)}else t.push(o);t.length>=4096&&(r+=lt.apply(String,t),t.length=0)}return t.length>0&&(r+=lt.apply(String,t)),r}function qm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=qe();return r}function $m(n){if(Rt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Jm()]=qe();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(qe(),qe());return r}}var lt=String.fromCharCode;function Qm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=re[I++];if((o&128)>0){I=r;return}e[t]=o}return lt.apply(String,e)}function Jc(n){if(n<4)if(n<2){if(n===0)return"";{let r=re[I++];if((r&128)>1){I-=1;return}return lt(r)}}else{let r=re[I++],e=re[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return lt(r,e);let t=re[I++];if((t&128)>0){I-=3;return}return lt(r,e,t)}else{let r=re[I++],e=re[I++],t=re[I++],o=re[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return lt(r,e,t,o);{let i=re[I++];if((i&128)>0){I-=5;return}return lt(r,e,t,o,i)}}else if(n<8){let i=re[I++],a=re[I++];if((i&128)>0||(a&128)>0){I-=6;return}if(n<7)return lt(r,e,t,o,i,a);let s=re[I++];if((s&128)>0){I-=7;return}return lt(r,e,t,o,i,a,s)}else{let i=re[I++],a=re[I++],s=re[I++],c=re[I++];if((i&128)>0||(a&128)>0||(s&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return lt(r,e,t,o,i,a,s,c);{let u=re[I++];if((u&128)>0){I-=9;return}return lt(r,e,t,o,i,a,s,c,u)}}else if(n<12){let u=re[I++],l=re[I++];if((u&128)>0||(l&128)>0){I-=10;return}if(n<11)return lt(r,e,t,o,i,a,s,c,u,l);let d=re[I++];if((d&128)>0){I-=11;return}return lt(r,e,t,o,i,a,s,c,u,l,d)}else{let u=re[I++],l=re[I++],d=re[I++],p=re[I++];if((u&128)>0||(l&128)>0||(d&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return lt(r,e,t,o,i,a,s,c,u,l,d,p);{let f=re[I++];if((f&128)>0){I-=13;return}return lt(r,e,t,o,i,a,s,c,u,l,d,p,f)}}else{let f=re[I++],m=re[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return lt(r,e,t,o,i,a,s,c,u,l,d,p,f,m);let h=re[I++];if((h&128)>0){I-=15;return}return lt(r,e,t,o,i,a,s,c,u,l,d,p,f,m,h)}}}}}function qc(n){return Rt.copyBuffers?Uint8Array.prototype.slice.call(re,I,I+=n):re.subarray(I,I+=n)}function Ko(n){let r=re[I++];if(Ot[r])return Ot[r](re.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var Ym=new Array(4096);function Jm(){let n=re[I++];if(n>=160&&n<192){if(n=n-160,_r>=I)return bo.slice(I-Zt,(I+=n)-Zt);if(!(_r==0&&So<180))return Kc(n)}else return I--,qe();let r=(n<<5^(n>1?Ee.getUint16(I):n>0?re[I]:0))&4095,e=Ym[r],t=I,o=I+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ee.getUint32(t),i!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=re[t++],i!=e[a++]){t=1879048192;break}if(t===o)return I=t,e.string;o-=3,t=I}for(e=[],Ym[r]=e,e.bytes=n;t<o;)i=Ee.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=re[t++],e.push(i);let s=n<16?Jc(n):Qm(n);return s!=null?e.string=s:e.string=Kc(n)}var Xm=(n,r)=>{var e=qe();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Ie[n];return o&&o.isShared&&((Ie.restoreStructures||(Ie.restoreStructures=[]))[n]=o),Ie[n]=e,e.read=Qc(e,t),e.read()},eh=typeof self=="object"?self:global;Ot[0]=()=>{};Ot[0].noBuffer=!0;Ot[101]=()=>{let n=qe();return(eh[n[0]]||Error)(n[1])};Ot[105]=n=>{let r=Ee.getUint32(I-4);Jr||(Jr=new Map);let e=re[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Jr.set(r,o);let i=qe();return o.used?Object.assign(t,i):(o.target=i,i)};Ot[112]=n=>{let r=Ee.getUint32(I-4),e=Jr.get(r);return e.used=!0,e.target};Ot[115]=()=>new Set(qe());var ed=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Ot[116]=n=>{let r=n[0],e=ed[r];if(!e)throw new Error("Could not find typed array for code "+r);return new eh[e](Uint8Array.prototype.slice.call(n,1).buffer)};Ot[120]=()=>{let n=qe();return new RegExp(n[0],n[1])};Ot[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,Wt=[qe(),qe()],Wt.position0=0,Wt.position1=0;let t=I;I=e;try{return qe()}finally{I=t}};Ot[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 th(n){let r=So,e=I,t=Xc,o=Zt,i=_r,a=bo,s=Yc,c=Jr,u=Wt,l=new Uint8Array(re.slice(0,So)),d=Ie,p=Ie.slice(0,Ie.length),f=Rt,m=ei,h=n();return So=r,I=e,Xc=t,Zt=o,_r=i,bo=a,Yc=s,Jr=c,Wt=u,re=l,ei=m,Ie=d,Ie.splice(0,Ie.length,...p),Rt=f,Ee=new DataView(re.buffer,re.byteOffset,re.byteLength),h}function Zs(){re=null,Jr=null,Ie=null}function rh(n){n.unpack?Ot[n.type]=n.unpack:Ot[n.type]=n}var Js=new Array(147);for(let n=0;n<256;n++)Js[n]=+("1e"+Math.floor(45.15-n*.30103));var el=new Pr({useRecords:!1}),NT=el.unpack,IT=el.unpackMultiple,MT=el.unpack,tl={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},ET=new Float32Array(1),hG=new Uint8Array(ET.buffer,0,4);var rl;try{rl=new TextEncoder}catch{}var ol,rd,nl=typeof Buffer<"u",td=nl?Buffer.allocUnsafeSlow:Uint8Array,ah=nl?Buffer:Uint8Array,oh=nl?4294967296:2144337920,G,Xe,E=0,Or,Ar=null,LT=/[\u0080-\uFFFF]/,Aa=Symbol("record-id"),Zo=class extends Pr{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,c=0,u=ah.prototype.utf8Write?function(v,N,P){return G.utf8Write(v,N,P)}:rl&&rl.encodeInto?function(v,N){return rl.encodeInto(v,G.subarray(N)).written}:!1,l=this;r||(r={});let d=r&&r.sequential,p=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=r.maxOwnStructures;m==null&&(m=p?32:64),d&&!r.saveStructures&&(this.structures=[]);let h=f>32||m+f>64,y=f+64,g=f+m+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],S=0,w=0;this.pack=this.encode=function(v,N){if(G||(G=new td(8192),Xe=new DataView(G.buffer,0,8192),E=0),Or=G.length-10,Or-E<2048?(G=new td(G.length),Xe=new DataView(G.buffer,0,G.length),Or=G.length-10,E=0):E=E+7&2147483640,t=E,s=l.structuredClone?new Map:null,l.bundleStrings?(Ar=["",""],G[E++]=214,G[E++]=98,Ar.position=E-t,E+=4):Ar=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let P=o.sharedLength||0;if(P>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 C=0;C<P;C++){let O=o[C];if(!O)continue;let A,M=o.transitions;for(let L=0,X=O.length;L<X;L++){let R=O[L];A=M[R],A||(A=M[R]=Object.create(null)),M=A}M[Aa]=C+64}c=P}d||(o.nextId=P+64)}i&&(i=!1),a=o||[];try{if(b(v),Ar){Xe.setUint32(Ar.position+t,E-Ar.position-t);let P=Ar;Ar=null,b(P[0]),b(P[1])}if(l.offset=E,s&&s.idsToInsert){E+=s.idsToInsert.length*6,E>Or&&_(E),l.offset=E;let P=BT(G.subarray(t,E),s.idsToInsert);return s=null,P}return N&lh?(G.start=t,G.end=E,G):G.subarray(t,E)}finally{if(o){if(w<10&&w++,S>1e4)o.transitions=null,w=0,S=0,x.length>0&&(x=[]);else if(x.length>0&&!d){for(let P=0,C=x.length;P<C;P++)x[P][Aa]=0;x=[]}if(i&&l.saveStructures){let P=o.sharedLength||f;o.length>P&&(o=o.slice(0,P));let C=G.subarray(t,E);return l.saveStructures(o,c)===!1?(l._mergeStructures(l.getStructures()),l.pack(v)):(c=P,C)}}N&kT&&(E=t)}};let b=v=>{E>Or&&(G=_(E));var N=typeof v,P;if(N==="string"){let C=v.length;if(Ar&&C>=8&&C<4096){let M=LT.test(v);Ar[M?0:1]+=v,G[E++]=193,b(M?-C:C);return}let O;C<32?O=1:C<256?O=2:C<65536?O=3:O=5;let A=C*3;if(E+A>Or&&(G=_(E+A)),C<64||!u){let M,L,X,R=E+O;for(M=0;M<C;M++)L=v.charCodeAt(M),L<128?G[R++]=L:L<2048?(G[R++]=L>>6|192,G[R++]=L&63|128):(L&64512)===55296&&((X=v.charCodeAt(M+1))&64512)===56320?(L=65536+((L&1023)<<10)+(X&1023),M++,G[R++]=L>>18|240,G[R++]=L>>12&63|128,G[R++]=L>>6&63|128,G[R++]=L&63|128):(G[R++]=L>>12|224,G[R++]=L>>6&63|128,G[R++]=L&63|128);P=R-E-O}else P=u(v,E+O,A);P<32?G[E++]=160|P:P<256?(O<2&&G.copyWithin(E+2,E+1,E+1+P),G[E++]=217,G[E++]=P):P<65536?(O<3&&G.copyWithin(E+3,E+2,E+2+P),G[E++]=218,G[E++]=P>>8,G[E++]=P&255):(O<5&&G.copyWithin(E+5,E+3,E+3+P),G[E++]=219,Xe.setUint32(E,P),E+=4),E+=P}else if(N==="number")if(v>>>0===v)v<64?G[E++]=v:v<256?(G[E++]=204,G[E++]=v):v<65536?(G[E++]=205,G[E++]=v>>8,G[E++]=v&255):(G[E++]=206,Xe.setUint32(E,v),E+=4);else if(v>>0===v)v>=-32?G[E++]=256+v:v>=-128?(G[E++]=208,G[E++]=v+256):v>=-32768?(G[E++]=209,Xe.setInt16(E,v),E+=2):(G[E++]=210,Xe.setInt32(E,v),E+=4);else{let C;if((C=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){G[E++]=202,Xe.setFloat32(E,v);let O;if(C<4||(O=v*Js[(G[E]&127)<<1|G[E+1]>>7])>>0===O){E+=4;return}else E--}G[E++]=203,Xe.setFloat64(E,v),E+=8}else if(N==="object")if(!v)G[E++]=192;else{if(s){let O=s.get(v);if(O){if(!O.id){let A=s.idsToInsert||(s.idsToInsert=[]);O.id=A.push(O)}G[E++]=214,G[E++]=112,Xe.setUint32(E,O.id),E+=4;return}else s.set(v,{offset:E-t})}let C=v.constructor;if(C===Object)T(v,!0);else if(C===Array){P=v.length,P<16?G[E++]=144|P:P<65536?(G[E++]=220,G[E++]=P>>8,G[E++]=P&255):(G[E++]=221,Xe.setUint32(E,P),E+=4);for(let O=0;O<P;O++)b(v[O])}else if(C===Map){P=v.size,P<16?G[E++]=128|P:P<65536?(G[E++]=222,G[E++]=P>>8,G[E++]=P&255):(G[E++]=223,Xe.setUint32(E,P),E+=4);for(let[O,A]of v)b(O),b(A)}else{for(let O=0,A=ol.length;O<A;O++){let M=rd[O];if(v instanceof M){let L=ol[O];if(L.write){L.type&&(G[E++]=212,G[E++]=L.type,G[E++]=0),b(L.write.call(this,v));return}let X=G,R=Xe,Z=E;G=null;let z;try{z=L.pack.call(this,v,V=>(G=X,X=null,E+=V,E>Or&&_(E),{target:G,targetView:Xe,position:E-V}),b)}finally{X&&(G=X,Xe=R,E=Z,Or=G.length-10)}z&&(z.length+E>Or&&_(z.length+E),E=DT(z,G,E,L.type));return}}T(v,!v.hasOwnProperty)}}else if(N==="boolean")G[E++]=v?195:194;else if(N==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))G[E++]=211,Xe.setBigInt64(E,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)G[E++]=207,Xe.setBigUint64(E,v);else if(this.largeBigIntToFloat)G[E++]=203,Xe.setFloat64(E,Number(v));else throw new RangeError(v+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");E+=8}else if(N==="undefined")this.encodeUndefinedAsNil?G[E++]=192:(G[E++]=212,G[E++]=0,G[E++]=0);else if(N==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},T=this.useRecords===!1?this.variableMapSize?v=>{let N=Object.keys(v),P=N.length;P<16?G[E++]=128|P:P<65536?(G[E++]=222,G[E++]=P>>8,G[E++]=P&255):(G[E++]=223,Xe.setUint32(E,P),E+=4);let C;for(let O=0;O<P;O++)b(C=N[O]),b(v[C])}:(v,N)=>{G[E++]=222;let P=E-t;E+=2;let C=0;for(let O in v)(N||v.hasOwnProperty(O))&&(b(O),b(v[O]),C++);G[P+++t]=C>>8,G[P+t]=C&255}:v=>{let N=Object.keys(v),P,C=a.transitions||(a.transitions=Object.create(null)),O=0;for(let M=0,L=N.length;M<L;M++){let X=N[M];P=C[X],P||(P=C[X]=Object.create(null),O++),C=P}let A=C[Aa];if(A)A>=96&&h?(G[E++]=((A-=96)&31)+96,G[E++]=A>>5):G[E++]=A;else{A=a.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(A=a.nextOwnId,A<g||(A=y),a.nextOwnId=A+1):(A>=g&&(A=y),a.nextId=A+1);let M=N.highByte=A>=96&&h?A-96>>5:-1;C[Aa]=A,a[A-64]=N,A<y?(N.isShared=!0,a.sharedLength=A-63,i=!0,M>=0?(G[E++]=(A&31)+96,G[E++]=M):G[E++]=A):(M>=0?(G[E++]=213,G[E++]=114,G[E++]=(A&31)+96,G[E++]=M):(G[E++]=212,G[E++]=114,G[E++]=A),O&&(S+=w*O),x.length>=m&&(x.shift()[Aa]=0),x.push(C),b(N))}for(let M=0,L=N.length;M<L;M++)b(v[N[M]])},_=v=>{let N;if(v>16777216){if(v-t>oh)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(oh,Math.round(Math.max((v-t)*(v>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(v-t<<2,G.length-1)>>12)+1<<12;let P=new td(N);return Xe=new DataView(P.buffer,0,N),G.copy?G.copy(P,0,t,v):P.set(G.slice(t,v)),E-=t,t=0,Or=P.length-10,G=P}}useBuffer(r){G=r,Xe=new DataView(G.buffer,G.byteOffset,G.byteLength),E=0}};rd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Oa];ol=[{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?nh(n,16,r):ih(nl?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==ah&&this.structuredClone?nh(n,ed.indexOf(e.name),r):ih(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function nh(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 ih(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 DT(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 BT(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 wo(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)");rd.unshift(n.Class),ol.unshift(n)}rh(n)}var sh=new Zo({useRecords:!1}),RT=sh.pack,GT=sh.pack;var{NEVER:VT,ALWAYS:zT,DECIMAL_ROUND:jT,DECIMAL_FIT:FT}=tl,lh=512,kT=1024;var ch=new Zo({structuredClone:!0});wo({Class:fe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,fe.prototype),n}});wo({Class:he.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,he.prototype),n}});wo({Class:Fe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Fe.prototype),n}});wo({Class:_a.prototype.constructor,type:4,write(n){return n.id},read(n){return new _a(n)}});wo({Class:Pa.prototype.constructor,type:5,write(n){return n.data},read(n){return new Pa(n)}});wo({Class:Re.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.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 od(n){if(Xn(n))return n;if(Array.isArray(n))return n.map(od);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=od(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var il;(t=>{function n(o){return ch.pack(o)}t.serialize=n;function r(o){return ch.unpack(o)}t.deserialize=r;function e(o){return UT(n(od(o))).toString()}t.checksum=e})(il||(il={}));var Po="personal camera",Oo="a218fcc3-276b-49b9-b485-49037fd14f5f",hh=2960946,rt=5526619;var dh;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i]}e.lerp=r})(dh||(dh={}));var To;(s=>{function n(c,u){return c[0]===u[0]&&c[1]===u[1]&&c[2]===u[2]}s.isEqual=n;function r(c,u){return[c[0]+u[0],c[1]+u[1],c[2]+u[2]]}s.add=r;function e(c,u){return[c[0]-u[0],c[1]-u[1],c[2]-u[2]]}s.sub=e;function t(c,u){return[c[0]/u[0],c[1]/u[1],c[2]/u[2]]}s.div=t;function o(c,u){return[c[0]*u[0],c[1]*u[1],c[2]*u[2]]}s.mul=o;function i(c,u){return Math.hypot(c[0]-u[0],c[1]-u[1],c[2]-u[2])}s.dist=i;function a(c,u,l){return[c[0]+(u[0]-c[0])*l,c[1]+(u[1]-c[1])*l,c[2]+(u[2]-c[2])*l]}s.lerp=a})(To||(To={}));var uh;(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})(uh||(uh={}));var _o;(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 c=0,u=a.length;c<u;c+=3){let l=i[3]*a[c]+i[7]*a[c+1]+i[11]*a[c+2]+i[15];s[c]=(i[0]*a[c]+i[4]*a[c+1]+i[8]*a[c+2]+i[12])/l,s[c+1]=(i[1]*a[c]+i[5]*a[c+1]+i[9]*a[c+2]+i[13])/l,s[c+2]=(i[2]*a[c]+i[6]*a[c+1]+i[10]*a[c+2]+i[14])/l}return s}o.applyMatrix4=t})(_o||(_o={}));var ct;(l=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}l.isRGB=n,l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.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}}l.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}l.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}l.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}l.toHex=s;function c(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}l.equals=c;function u(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f}}l.lerp=u})(ct||(ct={}));var At;(s=>{s.white={...ct.white,a:1},s.transparent={...ct.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}s.from0to1=e;function t(c,u){return{...ct.fromHex(c),a:u}}s.fromHexAndA=t;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}}s.toRgb255a1=o;function i(c,u){return ct.equals(c,u)&&c.a===u.a}s.equals=i;function a(c,u,l){return{r:c.r+(u.r-c.r)*l,g:c.g+(u.g-c.g)*l,b:c.b+(u.b-c.b)*l,a:c.a+(u.a-c.a)*l}}s.lerp=a})(At||(At={}));var al;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(al||(al={}));var ph;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(ph||(ph={}));var fh;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(fh||(fh={}));var mh;(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]))(mh||(mh={}));function yh(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 ir;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(ir||(ir={}));var Ao;(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:i.orthographic.zoom}o.getZoom=t})(Ao||(Ao={}));var Cr;(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(HT.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;WT.forEach(c=>{Object.assign(i.radial,{[c]:s[c]??a[c]})})}if(i.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;qT.forEach(c=>{Object.assign(i.linear,{[c]:s[c]??a[c]})})}if(i.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;$T.forEach(c=>{Object.assign(i.grid,{[c]:s[c]??a[c]})})}if(i.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;YT.forEach(c=>{Object.assign(i.toObject,{[c]:s[c]??a[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;XT.forEach(c=>{Object.assign(i.randomnessObject,{[c]:s[c]??a[c]})})}return i}e.merge=r})(Cr||(Cr={}));var sl;(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 c=o[s];c&&Object.keys(c).length>0&&a.push({type:0,path:[...i,s],props:c})}return a}t.toOps=e})(sl||(sl={}));var HT=["count"],WT=["radius","start","end","position","scale","rotation"],qT=["position","scale","rotation"],$T=["count","size"],YT=["count","position","scale","rotation"],XT=["strength","scale","rotation","position","movement","seed","freqScale"];var ll;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(ll||(ll={}));var cl;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:At.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:At.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:At.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(cl||(cl={}));var Co;(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]})(Co||(Co={}));var nd;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(nd||(nd={}));var id;(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})(id||(id={}));var dl;(r=>r.defaultData={...id.defaultData,...nd.defaultData})(dl||(dl={}));var gh;(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})(gh||(gh={}));var ti;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ti||(ti={}));var xh;(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==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(xh||(xh={}));function bh(n){return n.type!=="displace"}var vh;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(vh||(vh={}));var Sh=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],wh=["wrapping","image","video","name"],Ct;(o=>{function n(i,a){let{texture:s,...c}=a;if(Object.assign(i,c),s){let u=i.texture;u&&Object.assign(u,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]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ti.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:ct.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:{...ct.fromHex(6710886),a:1},colorB:{...ct.fromHex(6710886),a:1},colorC:{...ct.fromHex(16777215),a:1},colorD:{...ct.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:At.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:At.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:At.fromHexAndA(0,1),contourColor:At.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ct.fromHex(0),a:1},colorB:{...ct.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}}}})(Ct||(Ct={}));var gt;(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 l="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{l+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>l+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?l+=`${m.toFixed(4)}`:l+=`${m}`}):l+=`${f}`})}),l}c.getHash=r;function e(){return{layers:new he}}c.defaultEmptyData=e;function t(u="layer1",l="layer2"){return i("phong",u,l)}c.defaultData=t;function o(u,l){return{...u,name:l}}c.withName=o;function i(u,l="layer1",d="layer2"){let p=new he;return p.push({fi:0,data:Ct.defaultData("light",u),id:l}),p.push({fi:1,data:Ct.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function a(u,l="phong",d="layer1",p="layer2"){let f=Ct.defaultData("texture");Object.assign(f.texture,{image:u});let m=new he;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ct.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerTextureData=a;function s(u,l="phong",d="layer1",p="layer2"){let f=Ct.defaultData("video");Object.assign(f.texture,{video:u});let m=new he;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ct.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=s})(gt||(gt={}));var ri;(r=>{function n(){return{points:new he,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(ri||(ri={}));var oi;(r=>{function n(){return{points:new he,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(oi||(oi={}));var ad={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var ul;(r=>{function n(e,t){let o={...e};return KT.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(ul||(ul={}));var pl={shape:ad,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},KT=["depth","offset","angle","twist","startScale","endScale"];var Ca;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}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})(Ca||(Ca={}));var fl;(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,ul.merge(o.extrusion,t.extrusion))),o}r.merge=n})(fl||(fl={}));var No;(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==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:oi.defaultData(),extrusion:pl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ri.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})(No||(No={}));var ml;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:ct.white,near:.1,far:2e3})(ml||(ml={}));var hl;(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}}})(hl||(hl={}));var sd;(r=>r.defaultData={softShadowQuality:"low"})(sd||(sd={}));var ld;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(ld||(ld={}));var cd;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(cd||(cd={}));var Na;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Na||(Na={}));var dd;(r=>r.defaultData={playCamera:Po,gameControlObject:null})(dd||(dd={}));var yl;(r=>r.defaultData={backgroundColor:At.fromHexAndA(hh,1),postprocessing:hl.defaultData,fog:ml.defaultData,globalPhysics:Na.defaultData,ambient:ld.defaultData,ao:cd.defaultData,shadow:sd.defaultData,publish:dd.defaultData})(yl||(yl={}));var Th;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Th||(Th={}));var ni;(o=>{o.identity={...al.identity,hiddenMatrix:_o.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 lp({position:To.isEqual(i.position,a.position)?void 0:a.position,rotation:To.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:To.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:_o.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(ni||(ni={}));var xt;(r=>r.defaultData={states:new he,events:new he,visible:!0,raycastLock:!1,physics:Co.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ni.identity,cloner:null})(xt||(xt={}));var gl;(r=>r.defaultData={type:"Empty",...xt.defaultData})(gl||(gl={}));var _h;(r=>r.defaultData={type:"Component",...xt.defaultData})(_h||(_h={}));var Qo;(r=>r.defaultData={type:"Mesh",...xt.defaultData,...dl.defaultData})(Qo||(Qo={}));var Jo;(r=>r.defaultData={...xt.defaultData,...ni.identity,position:[0,0,Ao.DefaultTargetOffset],...Ao.defaultData})(Jo||(Jo={}));var xl;(e=>{function n(t){return{...xt.defaultData,...cl.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(xl||(xl={}));var ii;(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})(ii||(ii={}));var Nr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...xt.defaultData,...s,component:a,overrides:new Re,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(a){let s=ni.fromObject(a.data);return t(a.id,s)}i.fromComponentData=o})(Nr||(Nr={}));var eo;(r=>r.defaultData={type:"Page",...xt.defaultData,physics:{...Co.defaultData,fusedBody:!1},...yl.defaultData,camera:Jo.defaultData})(eo||(eo={}));var vl;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:_o.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Co.defaultData,states:new he,events:new he,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Ao.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",...xt.defaultData,...Qo.defaultData,geometry:No.defaultData("RectangleGeometry"),material:gt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...xt.defaultData,...Qo.defaultData,geometry:No.defaultData("BooleanGeometry"),material:gt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...xt.defaultData,...Qo.defaultData,geometry:No.defaultData("TextGeometry"),material:gt.defaultTwoLayerData("phong","layer1","layer2")}))(vl||(vl={}));var en;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new Re}),"materials"in i&&(s.materials=i.materials.map(c=>({layers:new Re})))):ir.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=vo(s.material,c=>{if(typeof c!="string")for(let[u,l]of Object.entries(a.material.layers)){let d=c.layers.data(u);d&&Ct.patch(d,l)}}).data),s.materials&&a.materials&&(s.materials=vo(s.materials,c=>{for(let u=0;u<s.materials.length;u++){let l=a.materials[u];if(typeof l!="string")for(let[d,p]of Object.entries(l.layers)){let f=c[u]?.layers?.data(d);f&&Ct.patch(f,p)}}}).data),s}function e(i,a){let s,c=[],u={orthographic:0,perspective:0,geometry:0};function l(d,p){for(let[f,m]of Object.entries(p.layers)){let{texture:h,...y}=m;if(h!==void 0&&Object.keys(h).length>0){let g={path:[...d,"layers",f,"texture"],props:h,type:0};c.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};c.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")c.push(...sl.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")l(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))l(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};c.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};c.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},c.push(s)),s.props[d]=p;return c}o.toOps=e;function t(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ni.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})}),ir.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let c=a;c.orthographic?.zoom!==void 0&&(s.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(s.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(s.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:fl.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Cr.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Cr.merge(s.cloner,a.cloner)});else if(ll.is(i.type)){let c=a;c.intensity!==void 0&&(s.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?s.color=c.color:s.color=ct.clone(c.color))}return s}o.patch=t})(en||(en={}));var si;(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,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(si||(si={}));var Ir;(r=>r.defaultData={orbitControls:si.defaultData,playPage:Oo,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})(Ir||(Ir={}));var ud;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(ud||(ud={}));var pd;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(pd||(pd={}));var Io;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...ud.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:pd.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Io||(Io={}));var Ph;(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 c=li.getComponentData(t,s.component)?.data;c&&i(a,s,c.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(Ph||(Ph={}));var Mo;(s=>{s.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let u=[],l=vl.defaultMeshObject;c.withLight===!0&&u.push({fi:-1,data:xl.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),c.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:l,children:[]});let d=new Fe;return d.push({fi:1,id:Oo,data:{...eo.defaultData,name:"Scene 1"},children:u}),d}s.defaultData={objects:r(),publish:Ir.defaultData,styles:Io.defaultData()},s.emptyDataWithoutPage=function(){return{objects:new Fe,publish:Ir.defaultData,styles:Io.defaultData()}},s.emptyDataWithPage=function(c){return{objects:r(c),publish:Ir.defaultData,styles:Io.defaultData()}};function i(c){return{...s.defaultData,objects:Dt(c,Fe.prototype)}}s.withObjs=i;function a(c,u){return i([{id:c,data:u,children:[],fi:0}])}s.withObj=a})(Mo||(Mo={}));var ci;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ci||(ci={}));var di;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(di||(di={}));var bl;(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})(bl||(bl={}));var fd;(r=>r.all=["images","videos","colors","audios","fonts","materials","variables"])(fd||(fd={}));var Oh;(r=>r.all=[...fd.all,"components"])(Oh||(Oh={}));var Ah;(r=>{function n(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe}}r.defaultData=n})(Ah||(Ah={}));var Eo;(r=>{function n(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe}}r.defaultData=n})(Eo||(Eo={}));var ar;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Dt(a,fe.prototype)}i.defaultColors=n;function r(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...di.emptyImage,name:"AI generated image"}),Dt(s,fe.prototype)}i.defaultImages=r;function e(){return{catelogs:new fe,materials:new fe,images:new fe,videos:new fe,colors:new fe,audios:new fe,fonts:new fe,variables:new he,lib:Eo.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 c=Math.floor(a/3600),u=Math.floor((a-c*3600)/60),l=Math.round(a-c*3600-u*60);return{textValue:[c,u,l]}}else if(s.format==="mm:ss"){let c=Math.floor(a/60),u=Math.round(a-c*60);return{textValue:[c,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(ar||(ar={}));import{MathUtils as Tl}from"three";var Sl;(r=>r.list=["idle","move","jump","run"])(Sl||(Sl={}));var wl;(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 he,move:new he,jump:new he,run:new he},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:At.fromHexAndA(3728051,1)}}))(wl||(wl={}));function Ch(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={...nr(We(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={...We(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function to(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function ro(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=gt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=gt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=gt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&r(o.material)})})}function ZT(n){Object.assign(n.scene.publish,{orbitControls:{...si.defaultData,...We(n.scene.publish.orbitControls)}})}function QT(n){Object.assign(n.scene.publish.settings,{video:{...Ir.defaultData.settings.video,...We(n.scene.publish.settings.video)}})}function JT(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((Sh.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(wh.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 e_(n){n.scene.publish.withBackground=!0}function t_(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function r_(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 o_(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 n_(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=We(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=We(e).booleanExclude!==!0)}})}function i_(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 a_(n){function r(t){Object.setPrototypeOf(t,Re.prototype),t.texture&&Object.setPrototypeOf(t.texture,Re.prototype)}function e(t){Object.setPrototypeOf(t,Re.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=We(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let c=a.materials[s],u=We(c).layers;e(u),c.layers=u}})})}function Nh(n){n.layers===void 0&&Object.assign(n,gt.defaultTwoLayerData("lambert"))}function md(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={...We(r),colors:e,steps:t};Object.assign(r,o)}})}function s_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Ih(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&md(t)}):"material"in e&&typeof e.material!="string"&&md(e.material)}),Object.values(n.shared.materials).forEach(r=>md(r))}function l_(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 c_(n){n.shared.audios=Dt({},fe.prototype)}function d_(n){n.shared.videos=Dt({},fe.prototype)}function u_(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 p_(n){Object.entries(We(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(We(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function f_(n){n.scene.publish.settings.web.preload=!1}function Mh(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 Eh(n){n.layers&&n.layers.forEach(r=>{bh(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 m_(n){n.shared.fonts=Dt({},fe.prototype)}function h_(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 y_(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=gt.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=h_(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let c={name:o.name,...xt.defaultData,...Qo.defaultData,flatShading:!1,wireframe:!1,geometry:{...No.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:We(o.states),events:We(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=We(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:c,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function g_(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 he,move:new he,jump:new he}});else{let i=new he;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:Tl.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},l={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(l,nr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(l,{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,...l},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new he({fi:0,id:Tl.generateUUID(),data:u},{fi:1,id:Tl.generateUUID(),data:p})};i.push({fi:c,id:s,data:f})}),delete o.targets)}})})}function x_(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let a=new he,s=[];if(e.events.forEach((c,u,l)=>{if(c.type==="Audio"&&c.trigger===i){let d;s.push(u),c.interaction==="play"?d={...nr(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(d={...nr(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:l,id:u,data:d})}}),s.forEach(c=>e.events.delete(c)),a.length){let c=e.events.find(u=>u.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:Tl.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Lh(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Ct.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Dh(n){to(n,Lh),ro(n,Lh)}function v_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function b_(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 S_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=gt.defaultTwoLayerData("phong"))})}function w_(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 T_(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 __(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 P_(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function O_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function A_(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function C_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=wl.defaultDataThirdPerson.navmesh)})})}function N_(n){n.scene.styles||(n.scene.styles=Io.defaultData())}function Bh(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function I_(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}),ro(n,Bh),to(n,Bh)}function M_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new he})})})}function E_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Rh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function Gh(n,r){if(r<1&&(ro(n,Ch),to(n,Ch),n.schema=1),r<2&&(ZT(n),n.schema=2),r<3&&(JT(n),n.schema=3),r<4&&(e_(n),n.schema=4),r<5&&(t_(n),n.schema=5),r<6&&(r_(n),n.schema=6),r<7&&(o_(n),n.schema=7),r<8&&(n.schema=8),r<9&&(Ih(n),n.schema=9),r<10&&(s_(n),n.schema=10),r<11&&(l_(n),n.schema=11),r<12&&(Ih(n),n.schema=12),r<13&&(c_(n),n.schema=13),r<14&&(u_(n),n.schema=14),r<15&&(p_(n),n.schema=15),r<16&&(f_(n),n.schema=16),r<17&&(ro(n,Mh),to(n,Mh),n.schema=17),r<18&&(ro(n,Nh),to(n,Nh),n.schema=18),r<19&&(QT(n),n.schema=19),r<20&&(m_(n),y_(n),n.schema=20),r<21&&(g_(n),x_(n),n.schema=21),r<22&&(Dh(n),n.schema=22),r<23&&(v_(n),n.schema=23),r<24&&(b_(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(d_(n),r<25&&(n.schema=25)),r<26&&(n_(n),n.schema=26),r<27&&(i_(n),n.schema=27),r<28&&(Dh(n),n.schema=28),r<29&&(a_(n),n.schema=29),r<30&&(S_(n),n.schema=30),r<31&&(w_(n),n.schema=31),r<33&&(T_(n),n.schema=33),r<34&&(__(n),n.schema=34),r<35&&(P_(n),n.schema=35),r<36&&(O_(n),n.schema=36),r<37&&(A_(n),n.schema=37),r<38&&(ro(n,Eh),to(n,Eh),n.schema=38),r<39&&(C_(n),n.schema=39),r<40&&(N_(n),n.schema=40),r<41&&(I_(n),n.schema=41),r<42&&(M_(n),n.schema=42),r<43&&(E_(n),n.schema=43),r<99){ro(n,Rh),to(n,Rh),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Po);let e=We(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=Oo,t.insertBefore(null,null,[{id:Oo,data:{...eo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:nr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:nr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Na.defaultData,...nr(n.scene.environment,"usePhysics","gravity")},camera:We(n.scene.ownerCamera)??eo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Mo.TRASH_CAN_ID&&t.move(Oo,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,Co.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function Vh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function L_(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 zh(n){let r=180/Math.PI;n.rotation=n.rotation.slice(0,3).map(t=>t*r),n.states.forEach(t=>{t.rotation!==void 0&&(t.rotation=t.rotation.slice(0,3).map(o=>o*r))});let e=n.geometry;e&&e.type==="SphereGeometry"&&(e.thetaLength=e.thetaLength*r),e&&e.type==="TorusGeometry"&&(e.arc=e.arc*r),e&&e.type==="PathGeometry"&&(e.extrusion.angle*=r,e.extrusion.twist*=r),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),n.events?.forEach(t=>{(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress"||t.type==="KeyDown"||t.type==="KeyUp"||t.type==="KeyPress"||t.type==="Collision"||t.type==="Trigger")&&(t.runMode=t.toggle?"Toggle":"Once")})}function D_(n){n.shared.variables=Dt({},fe.prototype)}function B_(n){let r=We(n.shared.variables);n.shared.variables=Dt(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),he.prototype)}var oo=107;function jh(n,r){r(n.data);for(let e of n.children)jh(e,r)}function R_(n){let r=n.schema??104;r!==oo&&r<105&&(jh(n.asset,zh),n.schema=105)}function _l(n){let r=n.schema??0;if(r!==oo){console.warn("updating from ",r,"to ",oo),Gh(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Ir.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(ro(n,Vh),to(n,Vh),n.schema=101),r<102&&(L_(n),n.schema=102),r<104&&(n.shared.catelogs=new fe,n.shared.lib=Eo.defaultData(),n.schema=104),r<105&&(D_(n),n.scene.objects.traverse((e,t)=>{zh(t)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))R_(e);r<106&&(B_(n),n.schema=106),r<107&&(n.shared.lib.variables=Eo.defaultData().variables,n.schema=107)}}var li;(s=>{s.defaultData={schema:oo,scene:Mo.defaultData,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ci.defaultData),shared:{...ar.emptyData(),colors:ar.defaultColors()}},s.emptyDataForImports=function(c){let u=Mo.emptyDataWithPage(c);return{schema:oo,scene:u,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ci.defaultData),shared:{...ar.emptyData(),colors:ar.defaultColors(),images:ar.defaultImages(c)}}},s.emptyData=function(){return{schema:oo,scene:Mo.emptyDataWithPage(),frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ci.defaultData),shared:ar.emptyData()}},s.collabHelper={...Ta,updateSchema(c){return(c.schema??0)<oo?vo(c,_l):(c.schema??0)-oo}};function o(c){let u=s.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}s.updateSchemaDirectly=o;function i(c){return{...c,shared:{...c.shared,lib:Eo.defaultData()}}}s.withoutLib=i;function a(c,u){let l=c.scene.objects.get(u);if(l&&l.data.type==="Component")return l;{let d=c.shared.lib.components[u];if(d)return d.asset}}s.getComponentData=a})(li||(li={}));var ia=ya(kh());import{Object3D as NC,Vector3 as Xt,Euler as Xu,MathUtils as v0,Matrix4 as wn}from"three";var G_=.5*(Math.sqrt(3)-1),Ia=(3-Math.sqrt(3))/6,V_=1/3,Mr=1/6,Qj=(Math.sqrt(5)-1)/4,Jj=(5-Math.sqrt(5))/20,Ma=n=>Math.floor(n)|0,Uh=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]),yd=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 Pl(n=Math.random){let r=Wh(n),e=new Float64Array(r).map(o=>Uh[o%12*2]),t=new Float64Array(r).map(o=>Uh[o%12*2+1]);return function(i,a){let s=0,c=0,u=0,l=(i+a)*G_,d=Ma(i+l),p=Ma(a+l),f=(d+p)*Ia,m=d-f,h=p-f,y=i-m,g=a-h,x,S;y>g?(x=1,S=0):(x=0,S=1);let w=y-x+Ia,b=g-S+Ia,T=y-1+2*Ia,_=g-1+2*Ia,v=d&255,N=p&255,P=.5-y*y-g*g;if(P>=0){let A=v+r[N],M=e[A],L=t[A];P*=P,s=P*P*(M*y+L*g)}let C=.5-w*w-b*b;if(C>=0){let A=v+x+r[N+S],M=e[A],L=t[A];C*=C,c=C*C*(M*w+L*b)}let O=.5-T*T-_*_;if(O>=0){let A=v+1+r[N+1],M=e[A],L=t[A];O*=O,u=O*O*(M*T+L*_)}return 70*(s+c+u)}}function Hh(n=Math.random){let r=Wh(n),e=new Float64Array(r).map(i=>yd[i%12*3]),t=new Float64Array(r).map(i=>yd[i%12*3+1]),o=new Float64Array(r).map(i=>yd[i%12*3+2]);return function(a,s,c){let u,l,d,p,f=(a+s+c)*V_,m=Ma(a+f),h=Ma(s+f),y=Ma(c+f),g=(m+h+y)*Mr,x=m-g,S=h-g,w=y-g,b=a-x,T=s-S,_=c-w,v,N,P,C,O,A;b>=T?T>=_?(v=1,N=0,P=0,C=1,O=1,A=0):b>=_?(v=1,N=0,P=0,C=1,O=0,A=1):(v=0,N=0,P=1,C=1,O=0,A=1):T<_?(v=0,N=0,P=1,C=0,O=1,A=1):b<_?(v=0,N=1,P=0,C=0,O=1,A=1):(v=0,N=1,P=0,C=1,O=1,A=0);let M=b-v+Mr,L=T-N+Mr,X=_-P+Mr,R=b-C+2*Mr,Z=T-O+2*Mr,z=_-A+2*Mr,V=b-1+3*Mr,W=T-1+3*Mr,$=_-1+3*Mr,Y=m&255,q=h&255,k=y&255,U=.6-b*b-T*T-_*_;if(U<0)u=0;else{let D=Y+r[q+r[k]];U*=U,u=U*U*(e[D]*b+t[D]*T+o[D]*_)}let B=.6-M*M-L*L-X*X;if(B<0)l=0;else{let D=Y+v+r[q+N+r[k+P]];B*=B,l=B*B*(e[D]*M+t[D]*L+o[D]*X)}let F=.6-R*R-Z*Z-z*z;if(F<0)d=0;else{let D=Y+C+r[q+O+r[k+A]];F*=F,d=F*F*(e[D]*R+t[D]*Z+o[D]*z)}let j=.6-V*V-W*W-$*$;if(j<0)p=0;else{let D=Y+1+r[q+1+r[k+1]];j*=j,p=j*j*(e[D]*V+t[D]*W+o[D]*$)}return 32*(u+l+d+p)}}function Wh(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}import{Triangle as z_}from"three";var sr=new z_,Ol=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;sr.a.fromBufferAttribute(r,o),sr.b.fromBufferAttribute(r,o+1),sr.c.fromBufferAttribute(r,o+2),i*=sr.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),sr.a.fromBufferAttribute(this.positionAttribute,r*3),sr.b.fromBufferAttribute(this.positionAttribute,r*3+1),sr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(sr.a,o).addScaledVector(sr.b,i).addScaledVector(sr.c,1-(o+i)),sr.getNormal(t),this}};import{Object3D as H_}from"three";var Yh=ya($h());import{Object3D as j_,Matrix4 as Er}from"three";var F_=new Er,k_=new Er,U_=new Er,ui;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(ui||(ui={}));var pi=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Er;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Er;this.matrixWorldRigid=new Er;this.shearScale=new Er;this.shearScaleInv=new Er}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof j_&&(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)ui.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)ui.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,Yh.SVD)(o),c=F_.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=k_.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),l=U_.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,l).copyPosition(this.matrixWorld),s.every(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Er().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Er?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,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var gd=class extends pi(H_){},W_=n=>n.type==="Mesh",no=class extends gd{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 no(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 W_(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as QO,BufferGeometry as JO,MeshBasicMaterial as eA}from"three";import{Matrix4 as KO,Mesh as ZO}from"three";import{Matrix4 as Nl,Vector3 as Zh,Euler as Z_,MathUtils as La}from"three";import{Box3 as q_,Line3 as $_,Matrix4 as xd,Vector3 as qt}from"three";var tn=new qt,rn=new qt,fi=new xd,Kh=[new qt(-1,1,1),new qt(-1,-1,1),new qt(1,-1,1),new qt(1,1,1),new qt(-1,1,-1),new qt(-1,-1,-1),new qt(1,-1,-1),new qt(1,1,-1)],Y_=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],X_=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Xh=(n,r,e)=>{n.updateEntityBoxSize(tn,rn),fi.copy(r).multiply(n.matrixWorld),rn.x===0&&rn.y===0&&rn.z===0?e.push(new qt(tn.x,tn.y,tn.z).applyMatrix4(fi)):Kh.forEach(t=>{e.push(t.clone().multiply(rn).add(tn).applyMatrix4(fi))})},Ea=class extends q_{constructor(){super(...arguments);this.matrix=new xd;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 xd().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 qt);return}Xh(a,t,i)}}):Xh(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(fi.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(rn).multiplyScalar(.5),this.getCenter(tn),fi.copy(this.matrix).setPosition(tn),this.vertices=Kh.map(e=>e.clone().multiply(rn).applyMatrix4(fi))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Y_.map(([e,t])=>new $_(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new qt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=X_.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var lr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as K_,CubicBezierCurve3 as vd,Vector3 as cr}from"three";var Sd=class extends K_{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,c=this.curves;s<c.length;s++){let u=c[s],l=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(r*l/a),p=u.getPoints(d);for(let f=0;f<p.length;f++){let m=p[f];t&&t.equals(m)||(e.push(m),t=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var wd=.001;function Td(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=wd}function bd(n,r){let e=new cr(...n.position),t=new cr(...n.controlNext.position),o=new cr(...r.controlPrevious.position),i=new cr(...r.position);return Td(e,t,i)&&Td(e,o,i)}function Cl(n){let r=n.points.map(l=>new cr(...l.data.position)),e=[n.points[0]],t=new cr(...e[0].data.position);for(let l=0;l<n.points.length-1;l++)Td(t,r[l],r[l+1])||(e.push(n.points[l]),t=r[l]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let l=0;l<a;l++){let d=e[l].data,p=new cr(...d.position),f=new cr(...d.controlPrevious.position),m=new cr(...d.controlNext.position),h={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!n.isClosed&&(l===0||l===a-1)){s[l]={...h,removedLength:0};continue}let y=o&&l==0?a-1:l-1,g=o&&l==a-1?0:l+1,x=e[y].data,S=e[g].data,w=new cr(...x.position),b=new cr(...S.position),T=w.clone().sub(p).normalize(),_=b.clone().sub(p).normalize();Object.assign(h,{prevDir:T,nextDir:_});let v=bd(x,d),N=bd(d,S);if(!v||!N)s[l]={...h,removedLength:0};else{let P=T.clone().add(_).normalize(),C=P.clone().cross(T).length()/T.dot(P);s[l]={...h,tan:C,removedLength:d.roundness/C}}}for(let l=0;l<i;l++){let d=l,p=o&&l===a-1?0:l+1,f=s[d],m=s[p];if(f.removedLength!==0||m.removedLength!==0){let h=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,h/2),m.removedLength=Math.min(m.removedLength,h/2)}}let c=[];for(let l=0;l<i;l++){let d=l,p=o&&l===a-1?0:l+1,f=s[d],m=s[p],h=null;if(!bd(e[d].data,e[p].data))f.position.distanceTo(m.position)>wd&&(h=new vd(f.position,f.controlNext,m.controlPrevious,m.position));else{let y=f.position.clone(),g=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&g.add(m.prevDir.clone().setLength(m.removedLength))),y.distanceTo(g)>wd&&(h=new vd(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*l+1]=h}for(let l=0;l<a;l++){let d=s[l];if(d.removedLength===0){c[2*l]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),h=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(m,.5),x=f.distanceTo(m)/2,S=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(x,2))).add(g),w=y.clone().multiplyScalar(-h).add(S),b=p.distanceTo(w)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),_=T.clone().lerp(w,2),v=f.clone().lerp(T,4/3),N=m.clone().lerp(_,4/3);c[2*l]=new vd(f,v,N,m)}let u=new Sd;return c.forEach(l=>{l&&u.add(l)}),u}var Te;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Te||(Te={}));var mi=n=>Te.is(n),Q_={type:"completeState",isfromEntity:!0},J_=["x","y","z"],_d=new Zh,eP=new Zh().set(0,1,0),hi=n=>class extends pi(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 Ea;this._recursiveBBox=new Ea;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(Te.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Te.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(Te.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)en.toOps(this.data,a.data).forEach(c=>{let u=Ws.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=en.patch(this.data,a),en.toOps(this.data,a).forEach(c=>{this.updateByPatchedOp(c,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=>{mi(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(Te.is(o[i]))return o[i];if(Te.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Te.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)mi(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Te.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)mi(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)mi(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)mi(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}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=>mi(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*La.RAD2DEG,this.rotation.y*La.RAD2DEG,this.rotation.z*La.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return $n(o,t)}getTransformValues(t,o,i){return o[t].map((a,s)=>i?.shared.getVariable(a,[this.uuid,t,J_[s]])??a)}updateTransformState(t,o){let i=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),i=!0),t.rotation&&(_d.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar(La.DEG2RAD),this.rotation.setFromVector3(_d),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??_o.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)Te.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Te.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return $n(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 c=t,u=_t(t.path,["states","*"]);if(u!==null){if(t.type===0){let[l]=u;if(this?.stateSelection===l){let d={...t.props};if(delete d.name,Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Je.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(d[m]=f[m])}}c={...t,props:d,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:p,...f}=l;l=f}if(t.props.material!==void 0&&"material"in l){let{material:p,...f}=l;l=f}let d=Je.removeOverridden(t.path,t.props,l);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,en.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),_t(t.path,["overrides"])){let l=[],d=[...t.path];for(l.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)l.push(d[1]),d.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){l[l.length-1]=p;let f=i.scene.findInstance([this.uuid,...l]);f&&(f.overrideData=t.props[p],f.updateState(Tr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...l]);if(p){let f=Je.zoom(p.component.data,d);if(t={...t,path:d},t.type===0){let m=t.props;if(f)for(let[h,y]of Object.entries(t.props))y===void 0&&(m===t.props&&(m={...t.props}),m[h]=f[h]);t={...t,props:m}}p.overrideData=ii.resolve(o.overrides,l),p.updateByOp(t,et.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let d;for(let p of Nr.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(l={...t,props:d})}else for(let d of Nr.rootOverrideProps)if(_t(t.path,[d])){l=t;break}l!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Tr.filterOp(d.overrideData,l);p&&d.updateByOp(p,et.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Tr.filterOp(d.overrideData,t);if(p){let f;s===d.data&&t===p?f=o:f=et.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!ir.is(t.props.type)&&lr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){lr.changeEntityProptotype(this,o,i);for(let a of this.children)Te.is(a)&&a.updateVisible()}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),_t(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),_t(t.path,["cloner"])!==null){let a=et.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()}}updatePathSnapping(t){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,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let c=t.find(o);if(!c||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=c.data;if(u.geometry.path.points.length<=1)return;let l=Cl(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=l.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new Nl;c.updateMatrixWorld();let m=new Nl().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new Nl().extractRotation(c.matrixWorld),g=l.getTangentAt(d).applyMatrix4(y).add(p),x=new Nl().lookAt(p,g,eP),S=_d.setFromEuler(new Z_().setFromRotationMatrix(x)).multiplyScalar(La.RAD2DEG);h={...h,rotation:S.toArray()}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(Q_)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}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(),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible()),this.updateTransformState(t,o)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof lr.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 lr.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)}};import{BufferGeometry as oP,ConeGeometry as nP,Float32BufferAttribute as iP,MathUtils as aP}from"three";import{BufferGeometry as Jh,CylinderGeometry as tP,Float32BufferAttribute as Ml,MathUtils as rP,Vector2 as dr,Vector3 as Il}from"three";var ey=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=rP.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:c,radiusTop:u,radiusBottom:l,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return c===0?(m=new Jh,m.setAttribute("position",new Ml([],3))):d||f?m=new Da(u,l,t,o,i,a,s,c*Math.PI/180,d,d,p,f):m=new tP(u,l,t,o,i,a,s,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Lo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Qh(n){return new dr(n.y,-n.x)}var Da=class extends Jh{constructor(r,e,t,o,i,a,s,c,u,l,d,p,f=!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,c=c!==void 0?c:Math.PI*2,a&&(u=0,l=0);let m=[],h=[],y=[],g=[],x=0,S=t/2,w=new Il,b=new Il;f&&r==0&&(r=u),f&&e==0&&(e=l);let T=new dr(r,S),_=new dr(e,-S),v=null,N=null,P=null,C=null,O=T.clone().sub(_),A=0,M=0,L=0;p>0&&(A=Math.min(r,e)*(1-p),M=r-A,L=e-A);let X=T.clone();X.x-=A;let R=Math.PI-O.angle(),Z=O.angle(),z=Math.tan(Z/2),V=Math.tan(R/2),W=z+V,$=p?W:V,Y=p?W:z;if(u=Math.min(u,(r-M)/$,O.length()/W),l=Math.min(l,(e-L)/Y,O.length()/W),u>0){let j=u/z;v=T.clone().sub(new dr(j,u)),p&&(P=v.clone(),P.x-=A-W*u),T.sub(O.clone().setLength(j))}if(l>0){let j=l/V;N=_.clone().sub(new dr(j,-l)),_.add(O.clone().setLength(j)),p&&(C=N.clone(),C.x-=A-W*l,X.sub(O.clone().setLength(j)))}O=T.clone().sub(_);let q=O.length()<.5,k=[];for(let j=0;j<=o;j++){let D=[],oe=j/o,ee=oe*c+s,K=new dr(Math.sin(ee),Math.cos(ee));C&&N?(U(D,oe,K,R,l,C,-1,!0),U(D,oe,K,Z,l,N,-1,!1)):N?(B(D,K,N.x,0,-1),U(D,oe,K,Z,l,N,-1,!1)):a||B(D,K,e,L,-1);let te=Qh(O).normalize();if(Lo(te,K,w),!q)for(let Q=0;Q<=i;Q++){let se=Q/i,ne=O.clone().multiplyScalar(se).add(_);Lo(ne,K,b),h.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(oe,.5+b.y/t),D.push(x++)}if(P&&v?(U(D,oe,K,R,u,v,1,!1),U(D,oe,K,Z,u,P,1,!0)):v?(U(D,oe,K,R,u,v,1,!1),B(D,K,v.x,0,1)):a||B(D,K,r,M,1),p&&!q){let Q=Qh(O).multiplyScalar(-1).normalize();Lo(Q,K,w);for(let se=0;se<=i;se++){let ne=se/i,ie=O.clone().multiplyScalar(-ne).add(X);Lo(ie,K,b),h.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(oe,.5+b.y/t),D.push(x++)}}p&&!a&&D.push(D[0]),k.push(D)}for(let j=0;j<k.length-1;j++)for(let D=0;D<k[0].length-1;D++){if(a&&p&&D==i)continue;let oe=k[j][D],ee=k[j+1][D],K=k[j+1][D+1],te=k[j][D+1],Q=h[K*3+0],se=h[K*3+2];m.push(oe,ee,te),(Q!=0||se!=0)&&m.push(ee,K,te)}c<Math.PI*2&&(F(-1,k[0],s),F(1,k[k.length-1],s+c)),this.setIndex(m),this.setAttribute("position",new Ml(h,3)),this.setAttribute("normal",new Ml(y,3)),this.setAttribute("uv",new Ml(g,2));function U(j,D,oe,ee,K,te,Q,se){for(let ne=0;ne<d+1;ne++){let ie=ne/d,ce=Q<0?ie:1-ie;se&&(ce-=1),ce*=ee;let le=new dr(Math.sin(ce),Math.cos(ce)*Q),de=le.clone().multiplyScalar(K).add(te);Lo(de,oe,b),h.push(b.x,b.y,b.z),Lo(le,oe,w),y.push(w.x,w.y,w.z),g.push(D,.5+b.y/t),j.push(x++)}}function B(j,D,oe,ee,K){let te=new Il,Q=new dr,se=[oe,ee];K<0&&se.reverse();for(let ne of se)Q.set(ne,S*K),Lo(Q,D,te),h.push(te.x,te.y,te.z),y.push(0,K,0),g.push(.5,.5),j.push(x++)}function F(j,D,oe){let ee=new dr(Math.sin(oe),Math.cos(oe)),K=new dr(-Math.cos(oe),Math.sin(oe)),te=new Il,Q=j<0?(ie,ce,le)=>m.push(ie,ce,le):(ie,ce,le)=>m.push(ie,le,ce),se=new dr((r+e+M+L)/4,0);Lo(se,ee,te),h.push(te.x,te.y,te.z),y.push(K.x,0,K.y),g.push(.5,.5);let ne=x++;for(let ie of D){let ce=h.slice(ie*3,ie*3+3);h.push(...ce),y.push(K.x,0,K.y);let le=g.slice(ie*2,ie*2+2);g.push(...le),x++}for(let ie=ne+1;ie<x-1;ie++)Q(ne,ie,ie+1);Q(ne,x-1,ne+1)}}};var ty=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=aP.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:c,cornerRadiusTop:u,cornerRadiusBottom:l,cornerSegments:d}=n.parameters,p;return c===0?(p=new oP,p.setAttribute("position",new iP([],3))):u>0||l>0||c<360?p=new Da(0,r/2,t,o,i,a,s,c*Math.PI/180,u,l,d,0,!0):p=new nP(r/2,t,o,i,a),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as sP,BufferGeometry as lP,Float32BufferAttribute as Pd,Vector3 as Ba}from"three";var ry=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:c}=n.parameters,u;return s==0?u=new sP(r,e,t,o,i,a):u=new Ad(r,e,t,o,i,a,s,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Od=Math.PI/2,Ad=class extends lP{constructor(r=1,e=1,t=1,o=1,i=1,a=1,s=0,c=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),c=Math.floor(c),s=Math.min(s,r/2,e/2,t/2);let l=[],d=[],p=[],f=[],m=0,h=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),x(1,1,1),x(-1,1,1),x(1,-1,1),x(-1,-1,1),x(1,1,-1),x(-1,1,-1),x(1,-1,-1),x(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new Pd(d,3)),this.setAttribute("normal",new Pd(p,3)),this.setAttribute("uv",new Pd(f,2));function y(S,w,b,T,_,v,N,P,C,O,A){let M=(v-2*s)/C,L=(N-2*s)/O,X=v/2-s,R=N/2-s,Z=P/2,z=C+1,V=O+1,W=0,$=0,Y=new Ba;for(let q=0;q<V;q++){let k=q*L-R;for(let U=0;U<z;U++){let B=U*M-X;Y[S]=B*T,Y[w]=k*_,Y[b]=Z,d.push(Y.x,Y.y,Y.z),Y[S]=0,Y[w]=0,Y[b]=P>0?1:-1,p.push(Y.x,Y.y,Y.z),f.push(U/C),f.push(1-q/O),W+=1}}for(let q=0;q<O;q++)for(let k=0;k<C;k++){let U=m+k+z*q,B=m+k+z*(q+1),F=m+(k+1)+z*(q+1),j=m+(k+1)+z*q;l.push(U,B,j),l.push(B,F,j),$+=6}u.addGroup(h,$,A),h+=$,m+=W}function g(S,w,b,T,_,v,N,P,C,O,A){let M=(N-2*s)/O,L=N/2-s,X=P/2-s,R=C/2,Z=O+1,z=0,V=0,W=new Ba,$=new Ba;for(let Y=0;Y<c+1;Y++){let q=Y/c*Od,k=Math.sin(q)*s,U=(1-Math.cos(q))*s,B=Math.sin(q),F=Math.cos(q);W[w]=(X+k)*_,W[b]=(R-U)*v,$[S]=0,$[w]=B*Math.sign(W[w]),$[b]=F*Math.sign(W[b]);for(let j=0;j<Z;j++){let D=j*M-L;W[S]=D*T,d.push(W.x,W.y,W.z),p.push($.x,$.y,$.z),f.push(j/O),f.push(0),z+=1}}for(let Y=0;Y<c;Y++)for(let q=0;q<O;q++){let k=m+q+Z*Y,U=m+q+Z*(Y+1),B=m+(q+1)+Z*(Y+1),F=m+(q+1)+Z*Y;l.push(k,U,F),l.push(U,B,F),V+=6}u.addGroup(h,V,A),h+=V,m+=z}function x(S,w,b){let T=new Ba,_=new Ba(r/2,e/2,t/2);_.subScalar(s);let v=[],N=S*w*b>0?(C,O,A)=>l.push(C,O,A):(C,O,A)=>l.push(C,A,O);for(let C=0;C<=c;C++){let O=[],A=Od*(1-C/c),M=Math.cos(A),L=Math.sin(A),X=0;for(let R=0;R<=C;R++){let Z=Math.cos(X),z=Math.sin(X);T.x=M*Z,T.y=L,T.z=M*z;let V=_.clone().addScaledVector(T,s);d.push(S*V.x,w*V.y,b*V.z),p.push(S*T.x,w*T.y,b*T.z),f.push(0,0),O.push(m++),X+=Od/C}v.push(O)}let P=v.length-1;for(let C=0;C<P;C++){let O=v[C],A=v[C+1],M=O.length-1;N(O[0],A[1],A[0]);for(let L=1;L<=M;L++)N(O[L-1],O[L],A[L]),N(O[L],A[L+1],A[L])}}}};import{BufferGeometry as cP,Float32BufferAttribute as Cd,Triangle as dP,Vector3 as io,Vector2 as Nd}from"three";var Do=class extends cP{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],c=[],u=[];l(),d(),this.setAttribute("position",new Cd(s,3)),this.setAttribute("normal",new Cd(u,3)),this.setAttribute("uv",new Cd(c,2));return;function l(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new io,h=m.clone(),y=new dP,g=i*o,x=o-g,S=a+1,w=new io,b=(z,V)=>w.subVectors(z,V).normalize(),T=(z,V)=>Array(z).fill(void 0).map(V),_=T(r.length/3,(z,V)=>new io().fromArray(r,V*3).setLength(o)),v=[],N=1e6;for(let z=0;z<_.length;z++){let V=_[z],W=[],$,Y,q,k=1e10,U=-1;for(;(U=e.indexOf(z,U+1))!=-1;){let D=U-U%3;$=e[D+(U+1)%3],Y=e[D+(U+2)%3],q=V.distanceToSquared(_[$]),k=Math.min(k,q),W.push([$,Y,q])}k+=1e-6;let B=[],F=0,j=W.length;for(let D=0;D<j;D++){[$,Y,q]=W[F];let oe=v[$]?.includes(z)==!0;q<=k&&B.push($+ +oe*N),F=W.findIndex(ee=>ee[0]==Y)}v.push(B)}let P=[];{let z=0,V=0,W,$,Y=f==3;for(let q=0;q<=a;q++){W=q*(q+1)/2,$=(q+1)*(q+2)/2;for(let k=0;k<a-q;k++)[z,V]=[W+k+q+2,$+k+q+3],P.push(W,$,...Y?[V,W]:[z,$],V,z),[W,$]=[z,V];P.push(W,$,W+a+2)}}let C=m.clone(),O=m.clone(),A=m.clone(),M=m.clone(),L=m.clone(),X=[],R=T(_.length,()=>T(f,()=>m.clone()));for(let z=0;z<_.length;z++){m.copy(_[z]).normalize(),C.copy(m).multiplyScalar(x);let V=v[z];for(let B=0;B<V.length;B++){let F=V[B],j=V[(B+1)%f];y.setFromPointsAndIndices(_,z,F%N,j%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(C,R[z][B])}let W=[],$=[],Y=[],q=new io;a==0&&[...R[z]].reduce((B,F)=>B.add(F),q).multiplyScalar(1/f);for(let B=0;B<f;B++){let F=[],j=(B-1+f)%f,D=R[z][j],oe=R[z][B];m.copy(D).sub(C),h.copy(oe).sub(C);let ee=C.angleTo(m),K=m.angleTo(h),te=Math.cos(ee)*g;a==0?O.copy(q):O.copy(C).setLength(x+te),$.push(te);let Q=[O,D,oe];for(let se=0;se<2;se++){let ne=Q[se],ie=Q[se+1];M.subVectors(ne,C),L.subVectors(ie,C),A.crossVectors(M,L).normalize();for(let ce=0;ce<S;ce++){let le=[ee,K][se]*ce/S;m.copy(M).applyAxisAngle(A,le).add(C),W.push(m.clone()),se&&(b(m,C),F.push([ce==0?ne:m.clone(),w.clone()]))}se&&(b(ie,C),F.push([ie,w.clone()]))}Y.push(F)}X.push(Y);let k=2*S,U=2;for(let B=0;B<f;B++){let F=k*B,j=k*((B+1)%f),D=[W[F]];for(let ee=1;ee<S;ee++){M=W[F+ee],L=W[j+ee],D.push(M);for(let K=1,te=ee-U+1;K<=te;K++)m.lerpVectors(M,L,K/(te+1)),m.sub(C).setLength($[B]).add(C),D.push(m.clone());D.push(L)}for(let ee=0;ee<S;ee++)D.push(W[ee+S+F]);D.push(W[j+S]);let oe=P.map(ee=>D[ee]);s.push(...oe.map(ee=>[ee.x,ee.y,ee.z]).flat()),u.push(...oe.map(ee=>(b(ee,C),[w.x,w.y,w.z])).flat())}}let Z=[];for(let z=0;z<v.length;z++)for(let V=0;V<f;V++){let W=v[z][V];if(W<N){let $=v[W].findIndex(k=>k%N==z),Y=X[z][V],q=X[W][$];for(let k=0;k<S;k++){let U=Y[k],B=q[S-k],F=Y[k+1],j=q[S-(k+1)];[U,B,F,F,B,j].forEach(D=>{s.push(D[0].x,D[0].y,D[0].z),u.push(D[1].x,D[1].y,D[1].z)})}Z.push(Y[0][0],q[S][0],Y[S][0],q[0][0])}}for(;Z.length;){let z,V,W,$;[z,V]=Z.splice(0,2);let Y=[z];for(;z!=V;)Y.push(V),W=Z.indexOf(V),$=W%2,V=Z.splice(W-$,2)[1-$];w.subVectors(Y[0],Y[1]).cross(m.subVectors(Y[0],Y[2])).normalize();let q=w.dot(Y[0])<0;q&&w.negate();for(let k=1;k<=Y.length-2;k++)[Y[k+ +q],Y[k+1-+q],Y[0]].forEach(U=>{s.push(U.x,U.y,U.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new io;for(let _=0;_<s.length;_+=3){p.x=s[_+0],p.y=s[_+1],p.z=s[_+2];let v=b(p)/2/Math.PI+.5,N=T(p)/Math.PI+.5;c.push(v,1-N)}let f=new io,m=new io,h=new io,y=new io,g=new Nd,x=new Nd,S=new Nd,w=(_,v,N,P)=>{P<0&&_.x===1&&(c[v]=_.x-1),N.x===0&&N.z===0&&(c[v]=P/2/Math.PI+.5)};for(let _=0,v=0;_<s.length;_+=9,v+=6){f.set(s[_+0],s[_+1],s[_+2]),m.set(s[_+3],s[_+4],s[_+5]),h.set(s[_+6],s[_+7],s[_+8]),g.set(c[v+0],c[v+1]),x.set(c[v+2],c[v+3]),S.set(c[v+4],c[v+5]),y.copy(f).add(m).add(h).divideScalar(3);let N=b(y);w(g,v+0,f,N),w(x,v+2,m,N),w(S,v+4,h,N)}for(let _=0;_<c.length;_+=6){let v=c[_+0],N=c[_+2],P=c[_+4],C=Math.max(v,N,P),O=Math.min(v,N,P);C>.9&&O<.1&&(v<.2&&(c[_+0]+=1),N<.2&&(c[_+2]+=1),P<.2&&(c[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}function T(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new Do(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as uP}from"three";var oy=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 Ra(r*.5,i,a):new uP(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Ra=class extends Do{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],c="DodecahedronGeometry";super(a,s,c,r,e,t),this.type=c}static fromJSON(r){return new Ra(r.radius,r.corner,r.cornerSides)}};import{Plane as wP,Shape as xy,Vector2 as ao,Vector3 as TP,MathUtils as Rd,LineCurve as Gd,QuadraticBezierCurve as vy,CubicBezierCurve as Bl}from"three";import{CubicBezierCurve as El,EllipseCurve as pP,LineCurve as Ll,LineCurve3 as fP,MathUtils as mP,QuadraticBezierCurve as Md,SplineCurve as hP,Vector2 as Pt,Vector3 as ay}from"three";var Ga=1e-12,yi=class{constructor(r){this.position=new Pt;this.startPosition=new Pt;this.uuid=mP.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 yi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},gi=class extends yi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new gi(this.parent).copy(this)}},ur=class extends yi{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new gi(this),new gi(this))}static create(e,t){let o=new ur(e,new Pt(...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 ur(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 Pt,t=new Pt){let[o,i]=this.computeTangents();return o&&i&&(ny(o,e),ny(i,t)),[e,t]}computeTangent(e=new Pt){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Pt){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function ny(n,r=new Pt){let e=n.length();return r.set(-n.y/e,n.x/e)}var Ed=n=>n,xi=new Pt,Dl=new Pt,yP=new Pt,gP=new Pt,xP=new Pt,vP=new Pt,sy=new ay,ly=new ay;function cy(n){let r=new Pt;r.addVectors(n.v0,xi.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Pt;return e.addVectors(n.v2,Dl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new El(n.v0,r,e,n.v2)}function Va(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function bP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function SP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Ld(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 dy(n,r,e){return iy(n,r)&&iy(r,e)&&Id(n.position,r.position,e.position)}function Id(n,r,e){return xi.copy(r).sub(n).cross(Dl.copy(e).sub(n))===0}function uy(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,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(s+c,a+u),o.set(s-c,a-u),[t,o]}function py(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function fy(n,r,e,t,o,i){let a=r.x-n.x,s=r.y-n.y,c=e.x-n.x,u=e.y-n.y,l=Math.sqrt((a+c)*(a+c)+(s+u)*(s+u)),d;return Ld(r,n,e)>Math.PI&&(l*=-1),Va(u,s)?d=(s+u)*(t/l-.5)*8/3/(a-c):d=(a+c)*(t/l-.5)*8/3/(u-s),o.set(r.x-d*s,r.y+d*a),i.set(e.x+d*u,e.y-d*c),[o,i]}function Dd(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function iy(n,r){return Id(n.position,n.controls[1].position,r.position)&&Id(n.position,r.controls[0].position,r.position)}function my(n,r,e,t,o=.5){let i=xi.subVectors(r,n).multiplyScalar(o).add(n),a=Dl.subVectors(e,r).multiplyScalar(o).add(r),s=yP.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=gP.subVectors(a,i).multiplyScalar(o).add(i),l=xP.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=vP.subVectors(l,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,l.x,l.y,d.x,d.y,t.x,t.y]}function hy(n,r,e=12,t=!0){let o=ly.set(0,0,0),i,a=0,s=[];for(let c=0;c<r.length;c++){let u=Ed(r[c]),l=xi,d=Bo(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof El||u instanceof Md||u instanceof Ll){if(u.getPoint(p/d,l),o.set(l.x,l.y,0),i!==void 0&&SP(i,o))continue;i===void 0&&(i=sy),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 yy(n,r,e,t=12,o=!0){let i=ly.set(0,0,0),a=0,s=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,l=Ed(r[c]),d=xi,p=Bo(l,t);s.push(p);for(let f=0;f<=p;f++)if(l instanceof El||l instanceof Md||l instanceof Ll){if(l.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=sy:(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 Bd(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 c=Bo(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),s+=c}a.curveAfter!==void 0&&(s+=Bo(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=Bo(n[0].roundedCurveCorner,r)*.5),t}function Bo(n,r=12){return n&&n instanceof pP?r*2:n&&(n instanceof Ll||n instanceof fP)?1:n&&n instanceof hP?r*n.points.length:r}function gy(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Ed(r[a]),c=Bo(s,e),u=xi;for(let l=0;l<=c;l++)if(s instanceof El||s instanceof Md||s instanceof Ll){if(s.getPoint(l/c,u),o!==void 0&&bP(o,u,Ga))continue;o===void 0&&(o=Dl),o.copy(u),n.push(u.x,u.y),i++}}return Va(n[0],n[n.length-2],Ga)&&Va(n[1],n[n.length-1],Ga)&&(n.pop(),n.pop()),t&&i>1&&!(Va(n[i-1],n[1],Ga)&&Va(n[i-2],n[0],Ga))&&(n.push(n[0],n[1]),i++),n}var Vd=new ao,_P=new ao,PP=new ao,OP=new ao,AP=new ao,CP=new ao,Ce=class extends xy{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new wP(new TP(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Rd.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Ce;return i.isClosed=e.isClosed,i.points=e.points.map(a=>ur.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Ce.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 c=this.shapeHoles[a],u=c.points.length,l=c.getPointIndexById(e);if(l<0)i+=u;else return l+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=Vd.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=Rd.generateUUID()){let i;e instanceof ao?i=e:i=new ao(e,t);let a=new ur(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 hy(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Bd(this.points,e,!1),this.roundedCurveDivisions=Bd(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return yy(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),gy(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=Bo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let l=i[c];if(s<o+l)return[c,(s-o+1)/l];o+=l}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,c=s[e];if(Dd(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(Vd.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(t-u)/c}dispose(){}_applyCurveForPoint(e,t){Dd(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],c=this.points[o+1]??this.points[0],u=a.roundness,l=s&&c&&dy(s,a,c);if(!a.controlsMoved()&&u>0&&!l){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,m=a.roundedCurveAfter,h=d.getLength(),y=p.getLength(),g=Math.min(u,h*.499),x=Math.min(u,y*.499),S=Math.min(g,x),w=1-S/h,b=S/y,T=d.getPointAt(w,Vd),_=p.getPointAt(b,_P);this._subSplitCurve(d,f,w,T,void 0),this._subSplitCurve(p,m,b,void 0,_);let v;if(this.useCubicForRoundedCorners){let N=Ld(T,a.position,_)/2,P=Math.tan(N)*T.distanceTo(a.position),[C,O]=uy(T,_,P,PP,OP),A=py(C,O,a.position),[M,L]=fy(A,T,_,P,AP,CP);v=new Bl(T.clone(),M.clone(),L.clone(),_.clone())}else v=new vy(T.clone(),a.position.clone(),_.clone());a.roundedCurveCorner=v,this.roundedCurves.splice(o+t,0,v),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Gd)i!==void 0&&t.v2.copy(i),a!==void 0&&t.v1.copy(a);else{let s=e,c=t,u=s.getUtoTmapping(o,0),l=my(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(c.v0.set(l[0],l[1]),c.v1.set(l[2],l[3]),c.v2.set(l[4],l[5]),c.v3.set(l[6],l[7])),a!==void 0&&(c.v0.set(l[6],l[7]),c.v1.set(l[8],l[9]),c.v2.set(l[10],l[11]),c.v3.set(l[12],l[13])),c}return t}clone(){let e=new Ce(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],c=e.points[i+2],u=e.points[i+3],l=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new ur(Rd.generateUUID(),new ao(a,s));f.controls[0].position.set(c,u),f.controls[1].position.set(l,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Ce;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,a)=>{a instanceof Bl&&a.v3.equals(i.position)&&i.controls[0].position.copy(a.v2)},o=i=>{let a=[],s,c;for(s=0,c=i.length;s<c;s++)i[s]instanceof vy&&(i[s]=cy(i[s]));for(s=0,c=i.length;s<c;s++){let d=i[s],p=s>0?i[s-1]:null,f;d instanceof Bl?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Gd&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),a.push(f))}let u=i[i.length-1],l=!1;return u instanceof Bl?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),l=!0):u instanceof Gd&&u.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a};return this.points=o(e.curves),e instanceof xy&&(this.shapeHoles=e.holes.map(i=>{let a=new Ce;return a.fromShape(i),a})),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 jd=Math.PI*2;function zd({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function NP(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 by(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 IP(n,r,e,t,o,i,a,s,c,u){let l=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),m=l*d-l*f-d*p;m<0&&(m=0),m/=l*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*s,y=m*-i/o*a,g=h+(n+e)/2,x=y+(r+t)/2,S=(a-h)/o,w=(s-y)/i,b=(-a-h)/o,T=(-s-y)/i,_=by(1,0,S,w),v=by(S,w,b,T);return!u&&v>0&&(v-=jd),u&&v<0&&(v+=jd),{centerx:g,centery:x,ang1:_,ang2:v}}function Sy({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,l=(r-t)/2;if(u===0&&l===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(l,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=IP(n,r,e,t,o,i,u,l,a,s),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(jd/4);Math.abs(1-g)<1e-7&&(g=1);let x=Math.max(Math.ceil(g),1);m/=x;for(let S=0;S<x;S++)c.push(NP(f,m)),f+=m;return c.map(S=>{let{x:w,y:b}=zd(S[0],o,i,h,y),{x:T,y:_}=zd(S[1],o,i,h,y),{x:v,y:N}=zd(S[2],o,i,h,y);return{x1:w,y1:b,x2:T,y2:_,x:v,y:N}})}import{BufferAttribute as jl,BufferGeometry as jP}from"three";var _e;(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"})(_e||(_e={}));var ke;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ke||(ke={}));function me(n,r){if(!n)throw r||"Assertion Failed!"}var ue=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){me(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){me(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){me(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){me(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,c;n.vertLeq(r,e)||(c=r,r=e,e=c),n.vertLeq(t,o)||(c=t,t=o,o=c),n.vertLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),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)||(c=r,r=e,e=c),n.transLeq(t,o)||(c=t,t=o,o=c),n.transLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),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}(),za=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}(),Rl=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}(),vi=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}(),wy=function(){function n(){var r=new vi,e=new za,t=new Rl(0),o=new Rl(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 Rl(0),t=new Rl(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;me(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;me(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 vi,e=new vi,t=new za,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 vi;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new za;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 za;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 vi;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 za;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,c;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),c=this.countFaceVerts_(i.Lface),s+c-2<=r&&ue.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&ue.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,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){me(o.prev===i),c=o.anEdge;do me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c),me(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(me(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){me(a.prev===s),c=a.anEdge;do me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c),me(c.Org===a),c=c.Onext;while(c!==a.anEdge)}for(me(a.prev===s&&a.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)me(c.Sym.next===u.Sym),me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Org!==null),me(c.Dst!==null),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c);me(c.Sym.next===u.Sym&&c.Sym===this.eHeadSym&&c.Sym.Sym===c&&c.Org===null&&c.Dst===null&&c.Lface===null&&c.Rface===null)},n}(),Ty=function(){function n(){this.handle=null}return n}(),_y=function(){function n(){this.key=null,this.node=0}return n}(),MP=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 Ty,this.handles[t]=new _y;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,me(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 Ty;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new _y}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;me(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}(),Fd=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}(),Py=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),EP=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new Py,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 Py;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}(),LP=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?ue.vertLeq(i.Org,a.Org)?ue.edgeSign(a.Dst,i.Org,a.Org)<=0:ue.edgeSign(i.Dst,a.Org,i.Org)>=0:ue.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ue.edgeSign(i.Dst,o,i.Org)>=0;var s=ue.edgeEval(i.Dst,o,i.Org),c=ue.edgeEval(a.Dst,o,a.Org);return s>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&me(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){me(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 Fd;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 _e.ODD:return(e&1)!==0;case _e.NONZERO:return e!==0;case _e.POSITIVE:return e>0;case _e.NEGATIVE:return e<0;case _e.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,c,u,l,d=!0;u=t;do me(ue.vertLeq(u.Org,u.Dst)),n.addRegionBelow(r,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),c=e,l=i;s=n.regionBelow(c),u=s.eUp.Sym,u.Org===l.Org;)u.Onext!==l&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(l.Oprev,u)),s.windingNumber=c.windingNumber-u.winding,s.inside=n.isWindingInside(r,s.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,l),n.deleteRegion(r,c),r.mesh.delete(l)),d=!1,c=s,l=u;c.dirty=!0,me(c.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=ue.vertL1dist(e,r),i=ue.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(ue.vertLeq(o.Org,i.Org)){if(ue.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ue.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(ue.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(me(!ue.vertEq(o.Dst,i.Dst)),ue.vertLeq(o.Dst,i.Dst)){if(ue.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(ue.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,c=o.Dst,u=i.Dst,l,d,p=new vi,f,m;if(me(!ue.vertEq(u,c)),me(ue.edgeSign(c,r.event,a)<=0),me(ue.edgeSign(u,r.event,s)>=0),me(a!==r.event&&s!==r.event),me(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(l=Math.min(a.t,c.t),d=Math.max(s.t,u.t),l>d))return!1;if(ue.vertLeq(a,s)){if(ue.edgeSign(u,a,s)>0)return!1}else if(ue.edgeSign(c,s,a)<0)return!1;return n.debugEvent(r),ue.intersect(c,a,u,s,p),me(Math.min(a.t,c.t)<=p.t),me(p.t<=Math.max(s.t,u.t)),me(Math.min(u.s,c.s)<=p.s),me(p.s<=Math.max(s.s,a.s)),ue.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=ue.vertLeq(a,s)?a:s,ue.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ue.vertEq(p,a)||ue.vertEq(p,s)?(n.checkForRightSplice(r,e),!1):!ue.vertEq(c,r.event)&&ue.edgeSign(c,r.event,p)>=0||!ue.vertEq(u,r.event)&&ue.edgeSign(u,r.event,p)<=0?u===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):c===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,m,!0),!0):(ue.edgeSign(c,r.event,p)>=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),ue.edgeSign(u,r.event,p)<=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=p.s,o.Org.t=p.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,a,c,s,u),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,c=a.eUp,u=!1;if(s.Dst!==c.Dst&&n.checkForIntersect(r,e),ue.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),u=!0),ue.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,a,null),u=!0),u){n.addRightEdges(r,e,t.Onext,i,i,!0);return}ue.vertLeq(c.Org,s.Org)?o=c.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,c;if(o=e.eUp,ue.vertEq(o.Org,t)){me(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!ue.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}me(!1),e=n.topRightRegion(e),c=n.regionBelow(e),a=c.eUp.Sym,i=s=a.Onext,c.fixUpperEdge&&(me(i!==a),n.deleteRegion(r,c),r.mesh.delete(a),a=i.Oprev),r.mesh.splice(t.anEdge,a),ue.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,a,s,c,u=new Fd;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,ue.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=ue.vertLeq(s.Dst,a.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var l=r.mesh.connect(s.Dnext,e.anEdge);c=l.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,c):n.computeWinding(r,n.addRegionBelow(r,t,c)),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);me(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 Fd,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 EP(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||(me(e.fixUpperEdge),me(++t===1)),me(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,ue.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 MP(i,ue.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,me(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||!ue.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}(),DP=function(){function n(){this.mesh=new wy,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=_e.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,c=[0,0,0],u=[0,0,0],l=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],h=this.mesh.vHead;e=h.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,m[y]=e,c[y]=i,f[y]=e;for(e=h.next;e!==h;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,m[g]=e),i>c[g]&&(c[g]=i,f[g]=e);var x=0;if(c[1]-u[1]>c[0]-u[0]&&(x=1),c[2]-u[2]>c[x]-u[x]&&(x=2),u[x]>=c[x]){r[0]=0,r[1]=0,r[2]=1;return}for(s=0,t=m[x],o=f[x],l[0]=t.coords[0]-o.coords[0],l[1]=t.coords[1]-o.coords[1],l[2]=t.coords[2]-o.coords[2],e=h.next;e!==h;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]=l[1]*d[2]-l[2]*d[1],p[1]=l[2]*d[0]-l[0]*d[2],p[2]=l[0]*d[1]-l[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,r[0]=p[0],r[1]=p[1],r[2]=p[2]);s<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(l)]=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 c=!0,u=r.next;u!==r;u=u.next)c?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,c=!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(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(;ue.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ue.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(ue.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ue.edgeGoesLeft(o.Lnext)||ue.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&&(ue.edgeGoesRight(t.Lprev)||ue.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,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(l.n=-1,!!l.inside){i=l.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),c++,i=i.Lnext}while(i!==l.anEdge);if(c>t)throw"Face vertex greater that support polygon";l.n=a,++a}this.elementCount=a,e===ke.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 u=r.vHead.next;u!==r.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,l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){i=l.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==l.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===ke.CONNECTED_POLYGONS){i=l.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==l.anEdge);for(var m=c;m<t;++m)this.elements[p++]=-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 c=0,u=0,l=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[c++]=t.Org.coords[0],this.vertices[c++]=t.Org.coords[1],e>2&&(this.vertices[c++]=t.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,a++,t=t.Lnext;while(t!==o);this.elements[l++]=i,this.elements[l++]=a,i+=a}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new wy),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=_e.ODD),e===void 0&&(e=ke.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_(),LP.computeInterior(this,a);var s=this.mesh;return e===ke.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===ke.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},n}();function pr(n){var r=n.windingRule,e=r===void 0?_e.ODD:r,t=n.elementType,o=t===void 0?ke.POLYGONS:t,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,c=s===void 0?2:s,u=n.normal,l=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,m=f===void 0?!0:f,h=n.debug,y=h===void 0?!1:h;if(!p&&m)throw new Error("Contours can't be empty");if(!!p){var g=new DP;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<p.length;x++)g.addContour(c||2,p[x]);return g.tesselate(e,o,a,c,l,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var Ak=_e.ODD,Ck=_e.NONZERO,Nk=_e.POSITIVE,Ik=_e.NEGATIVE,Mk=_e.ABS_GEQ_TWO,Ek=ke.POLYGONS,Lk=ke.CONNECTED_POLYGONS,Dk=ke.BOUNDARY_CONTOURS;import{BufferAttribute as zl,BufferGeometry as zP}from"three";var Gl=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*Gl.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*Gl.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*r);a+=3*r;let c=new Float32Array(o,a*i,3*r);a+=3*r;let u=new Float32Array(o,a*i,2*r);e?(s.set(this.positions.subarray(0,this.size*3)),c.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),c.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=c,this.uvs=u,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)}},ja=Gl;ja.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Ny=ya(Cy()),Fa={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},qd={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},$d={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},Wd=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Go=class extends zP{constructor(e,t,o=0,i=12,a=3,s=_e.ODD,c=!1){super();this.forPathBevel=c;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),l=this._shape.shapeHoles.map(C=>{let O=C.extractShapePointsToFlatArray([],i),A=[];for(let M=O.length-1;M>=1;M-=2){let L=O[M-1],X=O[M-0];A.push(L,X)}return A}),d=[],p=[];for(let C=0;C<u.length;C+=2)p.push([u[C],u[C+1]]);d.push(p);for(let C=0;C<l.length;C++){let O=l[C],A=[];for(let M=0;M<O.length;M+=2)A.push([O[M],O[M+1]]);d.push(A)}let f=d[0].length?(0,Ny.default)(d).distance:o;o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,t/2),this._bevelSegments=Math.floor(a));let m;try{m=pr({windingRule:s,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{m=Fa}let h;try{h=pr({windingRule:_e.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{h=qd}if(!m)throw new Error("error generating geometry");let y=m.elementCount;if(h){m.elementCount+=h.elementCount;for(let C=0;C<h.elements.length;C++){let O=h.elements[C],A=C%2===0?m.vertexCount:0;m.elements.push(O+A)}for(let C=0;C<h.vertexIndices.length;C++){let O=h.vertexIndices[C],A=m.vertexCount;m.vertexIndices.push(O+A)}for(let C=0;C<h.vertices.length;C++){let O=h.vertices[C];m.vertices.push(O)}}let g=1/0,x=-1/0,S=1/0,w=-1/0;for(let C=0,O=m.vertexCount;C<O;C++){let A=C*2,M=m.vertices[A+0],L=m.vertices[A+1];M<g&&(g=M),M>x&&(x=M),L<S&&(S=L),L>w&&(w=L)}this._minX=g,this._minY=S,this._width=x-g,this._height=w-S,this._buffer=new ja(this._computeBufferEstimatedSize(m));let b=[],T=[];for(let C=m.elementCount-1;C>=0;C--){let O=C>=y,A=C*2,M=m.elements[A+0],L=m.elements[A+1],X=M+L,R={start:M,count:L,normals:[],continuous:[],concave:[]},Z=M,z=X-1,V=M+1,W=this._shape.roundedCurves.length;do{let U=Z-M,B=m.vertices[z*2+0],F=m.vertices[z*2+1],j=m.vertices[Z*2+0],D=m.vertices[Z*2+1],oe=m.vertices[V*2+0],ee=m.vertices[V*2+1],K=j-B,te=D-F,Q=Math.sqrt(K*K+te*te);K/=Q,te/=Q;let se=j-oe,ne=D-ee,ie=Math.sqrt(se*se+ne*ne);se/=ie,ne/=ie,R.normals[U*2+0]=-ne,R.normals[U*2+1]=se,R.concave[U]=K*ne-te*se>0;let ce=m.vertexIndices[Z];if(Array.isArray(ce))R.continuous[U]=!1;else{let[le,de]=this._shape.getCurveIndexFromVertexId(ce-1,!0);if(de>0&&de<1)R.continuous[U]=!0;else{let ye=de===1?le+1:le-1;ye=(ye+W)%W;let Pe=de===1?0:1,Ve=this._shape.roundedCurves[le].getTangent(de),Oe=this._shape.roundedCurves[ye].getTangent(Pe);R.continuous[U]=Ve.dot(Oe)>.95}}O&&(R.normals[U*2+0]*=-1,R.normals[U*2+1]*=-1),[z,Z,V]=[Z,V,V+1],V>=X&&(V-=L)}while(V!==M+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:m.vertices.slice(M*2,X*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((U,B)=>[B,B]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:m.vertices.slice(M*2,X*2)});let Y=0;for(let U=1;U<=this._bevelSegments;U++){let B=U/this._bevelSegments*Math.PI/2,F=(1-Math.cos(B))*this._bevel,j=[],D=[],oe=[],ee=[],K=0;for(let Q=0;Q<L;Q++){let se=Q*2,ne=(Q-1+L)%L*2,ie=m.vertices[R.start*2+se+0],ce=m.vertices[R.start*2+se+1],le=-R.normals[ne+0]*F,de=-R.normals[ne+1]*F,ye=-R.normals[se+0]*F,Pe=-R.normals[se+1]*F;if(R.concave[Q]||!R.concave[Q]&&O){let Ve=Math.atan2(de,le),Oe=Math.atan2(Pe,ye);Oe>Ve&&(Oe-=Math.PI*2);let Be=Oe-Ve;if(R.continuous[Q]||O){let Et=Ve+Be/2,be=Math.cos(Et)*F,tt=Math.sin(Et)*F;j[2*K+0]=ie+be*(O?-1:1),j[2*K+1]=ce+tt*(O?-1:1),ee[K]=Q,K++}else{let Et=Math.max(1,Math.floor(i/4*Math.abs(Be)/Math.PI));for(let be=0;be<=Et;be++){let tt=Ve+Be*(be/Et),at=Math.cos(tt)*F,_n=Math.sin(tt)*F;j[2*K+0]=ie+at,j[2*K+1]=ce+_n,ee[K]=Q,K++}}}else j[2*K+0]=ie+le,j[2*K+1]=ce+de,ee[K]=Q,D[Q]=K,K++,j[2*K+0]=ie,j[2*K+1]=ce,ee[K]=Q,K++,j[2*K+0]=ie+ye,j[2*K+1]=ce+Pe,ee[K]=Q,oe[Q]=K,K++}let te=pr({windingRule:_e.POSITIVE,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[j],edgeCreateCallback:Q=>{let ne=Q.Org.idx,ie=ee[ne],ce=ee[(ne+1)%ee.length];Q.idx=[ie,ce],Q.Sym.idx=[ce,ie]},vertexIdCallback:Q=>{let se=Q.Lprev.idx;return[se?se[1]:0,Q.idx?Q.idx[0]:0]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${U}'th loop`);if(!te.vertexCount){let Q=(U-1)/this._bevelSegments*Math.PI/2;Y=(1-Math.sin(Q))*this._bevel;break}for(let Q=0;Q<te.vertexIndices.length;Q++){let[se,ne]=te.vertexIndices[Q];if(se===ne)continue;let ie=ne;ne<se&&(ie+=L);for(let ce=se;ce<ie;ce++){let le=ce%L,de=(ce+1)%L;if(!R.continuous[le]||!R.continuous[de]){te.vertexIndices[Q]=[se,le],te.vertexIndices.splice(Q+1,0,[de,ne]),te.vertices.splice((Q+1)*2,0,te.vertices[Q*2],te.vertices[Q*2+1]);break}}}$.push({bevelI:U,angle:B,size:F,boundary:te,reverseMap:ee,insetPoints:j})}let q=(U,B,F)=>{let j=0,D=U.boundary.vertexIndices.length;for(;j<D&&F(U.boundary.vertexIndices[B]);)B=(B+1)%D,j++;return j},k=b.length;for(let U=1;U<$.length;U++){let B=$[U-1],F=$[U],j=B.boundary.vertexIndices.length,D=F.boundary.vertexIndices.length;if(!j||!D)break;let oe=R.concave.length,ee=0,K=Wd(ee,L);for(;!B.boundary.vertexIndices.filter(K).length||!F.boundary.vertexIndices.filter(K).length;)ee++,K=Wd(ee,L);let te=B.boundary.vertexIndices.findIndex(K),Q=F.boundary.vertexIndices.findIndex(K);do te=(te+1)%j;while(K(B.boundary.vertexIndices[te]));do Q=(Q+1)%D;while(K(F.boundary.vertexIndices[Q]));ee=(ee+1)%L;let se=ee,ne=0,ie=this._buildBevelVert(R,B,(te-1+j)%j,void 0,ne),ce=this._buildBevelVert(R,F,(Q-1+D)%D,void 0,ne),le=ie,de=ce,ye,Pe,Ve=!1;do{ne=(ee||oe)/oe,K=Wd(ee,L);let Oe=q(B,te,K),Be=q(F,Q,K),Et=Ve;if(Ve=!1,Oe&&!Be){for(let be=0;be<Oe;be++)ye=this._buildBevelVert(R,B,(te+be)%j,be/(Oe-1),ne),b.push(le.topN,ye.topP,de.topN),c===!1&&b.push(ye.bottomP,le.bottomN,de.bottomN),le=ye;Ve=!0}else if(!Oe&&Be)for(let be=0;be<Be;be++)Pe=this._buildBevelVert(R,F,(Q+be)%D,be/(Be-1),ne),b.push(de.topN,le.topP,Pe.topP),c===!1&&b.push(le.bottomP,de.bottomN,Pe.bottomP),de=Pe;else if(Oe&&Be)if(ye=this._buildBevelVert(R,B,te,0,ne),Pe=this._buildBevelVert(R,F,Q,0,ne),Et?(b.push(le.topN,Pe.topP,de.topN),b.push(le.topN,ye.topP,Pe.topP),c===!1&&(b.push(Pe.bottomP,le.bottomN,de.bottomN),b.push(Pe.bottomP,ye.bottomP,le.bottomN))):(b.push(de.topN,le.topN,ye.topP),b.push(de.topN,ye.topP,Pe.topP),c===!1&&(b.push(ye.bottomP,le.bottomN,de.bottomN),b.push(ye.bottomP,de.bottomN,Pe.bottomP))),le=ye,de=Pe,Oe===Be)for(let be=1;be<Oe;be++)ye=this._buildBevelVert(R,B,(te+be)%j,be/(Oe-1),ne),Pe=this._buildBevelVert(R,F,(Q+be)%D,be/(Be-1),ne),b.push(le.topN,ye.topP,de.topN),b.push(de.topN,ye.topP,Pe.topP),c===!1&&(b.push(ye.bottomP,le.bottomN,de.bottomN),b.push(ye.bottomP,de.bottomN,Pe.bottomP)),le=ye,de=Pe;else if(Oe>Be){let be=Oe/Be,tt=0;for(let at=1;at<Oe;at++)ye=this._buildBevelVert(R,B,(te+at)%j,at/(Oe-1),ne),b.push(le.topN,ye.topP,de.topN),c===!1&&b.push(ye.bottomP,le.bottomN,de.bottomN),le=ye,at>(tt+1)*be&&(tt++,Pe=this._buildBevelVert(R,F,(Q+tt)%D,tt/(Be-1),ne),b.push(de.topN,ye.topP,Pe.topP),c===!1&&b.push(ye.bottomP,de.bottomN,Pe.bottomP),de=Pe)}else{let be=Be/Oe,tt=0;for(let at=1;at<Be;at++)Pe=this._buildBevelVert(R,F,(Q+at)%D,at/(Be-1),ne),b.push(de.topN,ye.topP,Pe.topP),c===!1&&b.push(ye.bottomP,de.bottomN,Pe.bottomP),de=Pe,at>(tt+1)*be&&(tt++,ye=this._buildBevelVert(R,B,(te+tt)%j,tt/(Oe-1),ne),b.push(le.topN,ye.topP,de.topN),c===!1&&b.push(ye.bottomP,le.bottomN,de.bottomN),le=ye)}te=(te+Oe)%j,Q=(Q+Be)%D,ee=(ee+1)%oe}while(ee!==se)}if(c===!1&&this._depth>this._bevel*2&&this._buildWall($,R,b),O){let U=[];for(let B=b.length-1;B>=k+2;B-=3){let F=b[B-2],j=b[B-1],D=b[B-0];U.push(D,j,F)}b.splice(k,b.length-k,...U)}if(O){let U=[];for(let B=$[$.length-1].boundary.vertices.length-1;B>=1;B-=2){let F=$[$.length-1].boundary.vertices[B-1],j=$[$.length-1].boundary.vertices[B-0];U.push(F,j)}T.push(U)}if(!O){let U=$[$.length-1],B;try{B=pr({windingRule:$.length>1?_e.POSITIVE:_e.ODD,elementType:ke.POLYGONS,vertexSize:2,strict:!0,contours:[U.insetPoints,...T]})}catch{B=$d}if(!B)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let F=0;F<B.elementCount*3;F+=3){let j=this._buildSurfaceVert(B,B.elements[F+0],Y),D=this._buildSurfaceVert(B,B.elements[F+1],Y),oe=this._buildSurfaceVert(B,B.elements[F+2],Y);b.push(j.top,D.top,oe.top),c===!1&&b.push(oe.bottom,D.bottom,j.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new zl(Uint32Array.from(b),1),v=new zl(this._buffer.positions,3),N=new zl(this._buffer.normals,3),P=new zl(this._buffer.uvs,2);v.needsUpdate=!0,N.needsUpdate=!0,P.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",v),this.setAttribute("normal",N),this.setAttribute("uv",P),this.setIndex(_)}_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 c=this._buildBevelVert(t,i,a),u=this._buildBevelVert(t,i,(a+1)%s);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.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],c=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let l=this._buffer.get(this.forPathBevel?1:2),d=l*3,p=l*2,f={top:l+0,bottom:l+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]=c,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]=c,this._buffer.uvs[p+3]=u),this.vertexCache[i]=f,f}_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[c,u]=t.boundary.vertexIndices[o],l,d,p,f;c!==u?(d=c,l=u,f=!1,p=e.continuous[d]&&e.continuous[l]):(l=c,d=(l-1+e.count)%e.count,f=e.concave[l]&&t.bevelI>0,p=e.continuous[l]||f);let m=Math.cos(t.angle),h=Math.sin(t.angle),y=o*2,g=l*2,x=d*2,S=t.boundary.vertices[y+0],w=t.boundary.vertices[y+1],b=(1-h)*this._bevel,T=(S-this._minX)/this._width,_=(w-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),_=1);let v=e.normals[g+0],N=e.normals[g+1],P=e.normals[x+0],C=e.normals[x+1];if(f){let X=P-v,R=C-N;v=v+X*(1-i),N=N+R*(1-i);let Z=Math.sqrt(v*v+N*N);v/=Z,N/=Z}let O=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),A=O*3,M=O*2,L={i:o,fi:l,topP:O+0,topN:O+0,bottomP:O+1,bottomN:O+1,pathBevelUCoord:a};return this._buffer.positions[A+0]=S,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=v*m,this._buffer.normals[A+1]=N*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=T,this._buffer.uvs[M+1]=_,this.forPathBevel===!1&&(this._buffer.positions[A+3]=S,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=v*m,this._buffer.normals[A+4]=N*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=_,this._buffer.uvs[M+3]=T),p||(this.forPathBevel?(O+=1,A+=3,M+=2):(O+=2,A+=6,M+=4),L.topP=O+0,L.bottomP=O+1,this._buffer.positions[A+0]=S,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=P*m,this._buffer.normals[A+1]=C*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=T,this._buffer.uvs[M+1]=_,this.forPathBevel===!1&&(this._buffer.positions[A+3]=S,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=P*m,this._buffer.normals[A+4]=C*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=_,this._buffer.uvs[M+3]=T)),this.vertexCache[s]=L,L}clone(){let e=new Go(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Qr(this.userData),e}};var bi=class extends jP{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=_e.ODD;this.elementType=ke.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:_e.ODD,elementType:ke.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),s,c=!0,u=!0,l,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],x=i[y+1];if(l!==void 0&&g!==l&&(c=!1),d!==void 0&&x!==d&&(u=!1),l=g,d=x,!c&&!u)break}if(!c&&!u)try{s=pr({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=Fa}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new jl(new Float32Array(p*3),3),this._normalAttribute=new jl(new Float32Array(p*3),3),this._uvAttribute=new jl(new Float32Array(p*2),2),this._indexAttribute=new jl(new Uint32Array(f*3),1),s){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,b=p;w<b;w++){let T=w*2,_=s.vertices[T+0],v=s.vertices[T+1];_<m&&(m=_),_>h&&(h=_),v<y&&(y=v),v>g&&(g=v)}let x=h-m,S=g-y;for(let w=0,b=p;w<b;w++){let T=w*2,_=s.vertices[T+0],v=s.vertices[T+1],N=(_-m)/x,P=(v-y)/S;this._positionAttribute.setXYZ(w,_,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,N,P)}for(let w=0,b=f;w<b;w++){let T=w*3,_=s.elements[T+0],v=s.elements[T+1],N=s.elements[T+2];this._indexAttribute.setX(T+0,_),this._indexAttribute.setX(T+1,v),this._indexAttribute.setX(T+2,N)}}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 bi(this._shape,this._curveSegments);return e.userData=Qr(this.userData),e}};var Si=class extends Go{constructor(e,t,o=0,i=12,a=3,s=_e.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 c=this._buildBevelVert(t,i,a),u=this._buildBevelVert(t,i,(a+1)%s);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}clone(){let e=new Si(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Qr(this.userData),e}};var Gt=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:_e.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 Ce?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new Ce(t,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let c=a??new Ce(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:s}),shape:c}}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 bi(n.shape,o,{windingRule:a}):s=new Si(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as FP,Float32BufferAttribute as kP,MathUtils as Yd,Vector2 as My}from"three";var Ey=Math.PI*2,Ti=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=Yd.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Ce?n.shape:new Ce,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:c}=n.parameters,u=n.shape,l=r*.5,d=e*.5,p=UP(u,l,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f;return o===0?(f=new FP,f.setAttribute("position",new kP([],3))):f=Gt.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:c}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function UP(n,r,e,t,o,i){if(t>=Ey)return o>30||o%4===0?(WP(n,r,e,i),Math.round(o/4)):Iy(n,t,o,r,e,i);t=Math.max(t,.001);let a={x:0,y:e},s=t+Math.PI*.5,c={x:Math.cos(s)*r,y:Math.sin(s)*e},u=Sy({px:a.x,py:a.y,cx:c.x,cy:c.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?HP(n,a.x,a.y,u,o,r,e,i):Iy(n,t,o,r,e,i)}function HP(n,r,e,t,o,i,a,s){let c=Math.round(o/t.length);n.addPoint(wi(r,e));for(let u=0,l=t.length;u<l;u++){let d=t[u],p=n.points[u],f=wi(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?Ly(n,i,a,s):n.addPoint(wi(0,0)),c}function Iy(n,r,e,t,o,i){let a=-r/e;for(let s=0;s<=e;s++){let c=a*s,u=Math.sin(c)*t,l=Math.cos(c)*o;n.addPoint(wi(u,l))}return r<Ey?i>0?Ly(n,t,o,i):n.addPoint(wi(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Dy(n,t,o,i)),1}function WP(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,c=e*a;n.addPoint(Fl(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(Fl(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(Fl(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(Fl(o,i-e,o+s,i-e,o-s,i-e)),t>0&&Dy(n,r,e,t)}function wi(n,r){return new ur(Yd.generateUUID(),new My(n,r))}function Fl(n,r,e,t,o,i){let a=wi(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function Ly(n,r,e,t){By(n,r,e,t).forEach(i=>n.addPoint(i))}function Dy(n,r,e,t){let o=By(n,r,e,t),i=new Ce;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function By(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new My(o/r,i/e),s=n.points.map(c=>{let u=c.clone();return u.uuid=Yd.generateUUID(),u}).reverse();return s.forEach(c=>{c.position.multiply(a);let u=c.controls[0].position.clone().multiply(a),l=c.controls[1].position.clone().multiply(a);c.controls[0].position.copy(l),c.controls[1].position.copy(u)}),s}import{BufferGeometry as qP,Float32BufferAttribute as Xd,Uint32BufferAttribute as $P,Vector3 as Ry}from"three";var Gy=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:c,pathSegments:u,cornerRadius:l,cornerSegments:d}=n.parameters,p=new ka(!1,r,e,t,o,i,a,s,c,u,l,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Kd=new $P([0,0,0],1),ka=class extends qP{constructor(r=!0,e=1,t=1,o=1,i=1,a=1,s=1,c=1,u=1,l=1,d=1,p=1){if(super(),a===0)return;let f=r&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let m=()=>new Ry,h=new Ry,y=m(),g=m(),x=m(),S,w,b,T,_,v,N,P,C=m(),O=m(),A=m(),M=m(),L=m(),X=m(),R=m(),Z=m(),z=t-2*c+.001,V=z/a,W=Math.ceil(s*a),$=W+1,Y=z/W,q=-z/2,k=l+1,U=2*Math.PI/l,B=Math.PI/2/p,F=.01,j=Math.min((1-d/100)*c,c-F),D=c-j,oe=0,ee=2,K=p*ee+ee,te=k*K/ee,Q=te+k*$,se=Math.max(0,k*($+K)),[ne,ie,ce]=[3,3,2].map(Ye=>Array(se*Ye).fill(0)),le=[],de=i-c;function ye(Ye,kt){let br=Math.PI/2;v=kt*Y,P=2*Math.PI*(v%V)/V+br,v+=q,N=Math.sin(P)*de,_=Math.cos(P)*de,r?Ye.set(_,N,v):Ye.set(_,v,N)}ye(h,-1e-10),ye(y,0),C.copy(h),ye(h,1);let Pe=h.distanceTo(y),Ve=f?0:D+j,Oe=Pe*W+2*Ve,Be=j,Et=Oe-Ve;for(let Ye=0;Ye<=W;Ye++){ye(g,Ye),Z.subVectors(g,C).normalize(),C.copy(g),X.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(Z,X).normalize();let kt=Ye===0,br=Ye===W,cx=kt?3*Math.PI/2:B,dx=kt?Be:Et,ux=kt?k:Q,px=kt?0:se-k,fx=Z.clone().multiplyScalar(kt?-D:D).add(g),mx=Z.clone().multiplyScalar(kt?-1:1).normalize();for(let $r=0;$r<k;$r++){let sp=$r*U;if(O.addVectors(h.copy(X).multiplyScalar(c*Math.cos(sp)),y.copy(R).multiplyScalar(c*Math.sin(sp))),A.copy(O).normalize(),kt||br){f||(oe=px+$r,[0,1,2].forEach(Lt=>{ne[oe*3+Lt]=fx.getComponent(Lt),ie[oe*3+Lt]=mx.getComponent(Lt)}),ce[oe*2]=+br,ce[oe*2+1]=$r/l),y.copy(A).multiplyScalar(j),x.addVectors(g,y);for(let Lt=0;Lt<p;Lt++){let Ec=Lt*B+cx;M.addVectors(h.copy(Z).multiplyScalar(D*Math.sin(Ec)),y.copy(A).multiplyScalar(D*Math.cos(Ec))),L.copy(M).normalize(),y.addVectors(x,M),M.normalize(),oe=ux+Lt*k+$r,[0,1,2].forEach(ys=>{ne[oe*3+ys]=y.getComponent(ys),ie[oe*3+ys]=L.getComponent(ys)});let hx=+kt+Math.sin(Ec);ce[oe*2]=(dx+D*hx)/Oe,ce[oe*2+1]=$r/l}}y.addVectors(g,O),oe=te+Ye*k+$r,[0,1,2].forEach(Lt=>{ne[oe*3+Lt]=y.getComponent(Lt),ie[oe*3+Lt]=A.getComponent(Lt)}),ce[oe*2]=(Ve+Ye*Pe)/Oe,ce[oe*2+1]=$r/l}}let be=$+2*p+ee,tt=1,[at,_n]=[+f,be-1];for(let Ye=at;Ye<=_n-1;Ye++){let kt=f&&Ye===_n-1;for(let br=0;br<k-1;br++)S=Ye*k+br,w=S+1,b=(kt?br:S)+k,T=(kt?br+1:w)+k,Ye===0?le.push(w,T,b):Ye===be-2?le.push(S,w,b):le.push(S,w,b,w,T,b)}this.setIndex(le),this.setAttribute("position",new Xd(ne,3)),this.setAttribute("normal",new Xd(ie,3)),this.setAttribute("uv",new Xd(ce,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,c,u=6*(e-1)*r.radialSegments,l=e,d=l===e;for(let p=0;p<r.radialSegments;p++)i=l*t+p,a=i+1,s=(d?p:i)+t,c=(d?p+1:a)+t,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=c,o[u++]=s;return o.length=u,Kd.array=o,Kd.count=o.length,Kd}};import{IcosahedronGeometry as YP}from"three";var Vy=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 Ua(r*.5,i,a):new YP(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},Ua=class extends Do{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 Ua(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as XP,Shape as KP}from"three";var zy=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 KP;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 XP(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as $y,BufferGeometryLoader as lO,Vector3 as cO,BoxGeometry as Yy}from"three";import{BufferGeometry as nO,Vector2 as eu,Vector3 as qy}from"three";import{Box3 as ZP,BufferAttribute as Ha,BufferGeometry as jy,Color as Jd,EventDispatcher as QP,Float32BufferAttribute as _i,Matrix3 as Fy,Matrix4 as Wy,MathUtils as JP,Object3D as eO,Sphere as tO,Vector2 as $t,Vector3 as vt,Vector4 as rO}from"three";var Lr=new Wy,Zd=new eO,kl=new vt,Vo=class extends QP{constructor(){super(),this.uuid=JP.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 Fy().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 Lr.makeRotationX(r),this.applyMatrix4(Lr),this}rotateY(r){return Lr.makeRotationY(r),this.applyMatrix4(Lr),this}rotateZ(r){return Lr.makeRotationZ(r),this.applyMatrix4(Lr),this}translate(r,e,t){return Lr.makeTranslation(r,e,t),this.applyMatrix4(Lr),this}scale(r,e,t){return Lr.makeScale(r,e,t),this.applyMatrix4(Lr),this}lookAt(r){return Zd.lookAt(r),Zd.updateMatrix(),this.applyMatrix4(Zd.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,c=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new vt().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new Jd().fromBufferAttribute(s,p));function l(p,f,m,h){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=a===void 0?[]:[new vt().fromBufferAttribute(a,p),new vt().fromBufferAttribute(a,f),new vt().fromBufferAttribute(a,m)],x=new Pi(p,f,m,g,y,h);e.faces.push(x),c!==void 0&&e.faceVertexUvs[0].push([new $t().fromBufferAttribute(c,p),new $t().fromBufferAttribute(c,f),new $t().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new $t().fromBufferAttribute(u,p),new $t().fromBufferAttribute(u,f),new $t().fromBufferAttribute(u,m)])}let d=r.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],m=f.start,h=f.count;for(let y=m,g=m+h;y<g;y+=3)t!==void 0?l(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):l(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)l(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)l(p,p+1,p+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(kl).negate(),this.translate(kl.x,kl.y,kl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new Wy;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 vt,e=new vt;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],c=this.vertices[i.c];r.subVectors(c,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 vt;if(r){let t=new vt,o=new vt;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],c=this.vertices[s.a],u=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,u),o.subVectors(c,u),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 Vo;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,c=this.faces.length;s<c;s++){let u=new vt,l={a:new vt,b:new vt,c:new vt};i.push(u),a.push(l)}}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],c=o.faceNormals[i],u=o.vertexNormals[i];c.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,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 ZP),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new tO),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,c=this.faces,u=r.faces,l=this.colors,d=r.colors;e!==void 0&&(o=new Fy().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let h=s[p].clone();e!==void 0&&h.applyMatrix4(e),a.push(h)}for(let p=0,f=d.length;p<f;p++)l.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,x=m.vertexColors,S=new Pi(m.a+i,m.b+i,m.c+i);S.normal.copy(m.normal),o!==void 0&&S.normal.applyMatrix3(o).normalize();for(let w=0,b=g.length;w<b;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),S.vertexNormals.push(h);S.color.copy(m.color);for(let w=0,b=x.length;w<b;w++)y=x[w],S.vertexColors.push(y.clone());S.materialIndex=m.materialIndex+t,c.push(S)}for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let S=0,w=g.length;S<w;S++)x.push(g[S].clone());this.faceVertexUvs[p].push(x)}}}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 c=0,u=this.vertices.length;c<u;c++){let l=this.vertices[c],d=Math.round(l.x*i)+"_"+Math.round(l.y*i)+"_"+Math.round(l.z*i);e[d]===void 0?(e[d]=c,t.push(this.vertices[c]),o[c]=t.length-1):o[c]=o[e[d]]}let a=[];for(let c=0,u=this.faces.length;c<u;c++){let l=this.faces[c];l.a=o[l.a],l.b=o[l.b],l.c=o[l.c];let d=[l.a,l.b,l.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){a.push(c);break}}for(let c=a.length-1;c>=0;c--){let u=a[c];this.faces.splice(u,1);for(let l=0,d=this.faceVertexUvs.length;l<d;l++)this.faceVertexUvs[l].splice(u,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 vt(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let c=0;c<e;c++)r[c]._id=c;function t(c,u){return c.materialIndex-u.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 c=0;c<e;c++){let u=r[c]._id;a&&a.push(o[u]),s&&s.push(i[u])}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 m=this.parameters;for(let h in m)m[h]!==void 0&&(r[h]=m[h]);return r}let e=[];for(let m=0;m<this.vertices.length;m++){let h=this.vertices[m];e.push(h.x,h.y,h.z)}let t=[],o=[],i={},a=[],s={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,x=this.faceVertexUvs[0][m]!==void 0,S=h.normal.length()>0,w=h.vertexNormals.length>0,b=h.color.r!==1||h.color.g!==1||h.color.b!==1,T=h.vertexColors.length>0,_=0;if(_=l(_,0,0),_=l(_,1,y),_=l(_,2,g),_=l(_,3,x),_=l(_,4,S),_=l(_,5,w),_=l(_,6,b),_=l(_,7,T),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),x){let v=this.faceVertexUvs[0][m];t.push(f(v[0]),f(v[1]),f(v[2]))}if(S&&t.push(d(h.normal)),w){let v=h.vertexNormals;t.push(d(v[0]),d(v[1]),d(v[2]))}if(b&&t.push(p(h.color)),T){let v=h.vertexColors;t.push(p(v[0]),p(v[1]),p(v[2]))}}function l(m,h,y){return y?m|1<<h:m&~(1<<h)}function d(m){let h=m.x.toString()+m.y.toString()+m.z.toString();return i[h]!==void 0||(i[h]=o.length/3,o.push(m.x,m.y,m.z)),i[h]}function p(m){let h=m.r.toString()+m.g.toString()+m.b.toString();return s[h]!==void 0||(s[h]=a.length,a.push(m.getHex())),s[h]}function f(m){let h=m.x.toString()+m.y.toString();return u[h]!==void 0||(u[h]=c.length/2,c.push(m.x,m.y)),u[h]}return r.data={},r.data.vertices=e,r.data.normals=o,a.length>0&&(r.data.colors=a),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new Vo().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 p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let t=r.colors;for(let p=0,f=t.length;p<f;p++)this.colors.push(t[p].clone());let o=r.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let S=0,w=g.length;S<w;S++){let b=g[S];x.push(b.clone())}this.faceVertexUvs[p].push(x)}}let i=r.morphTargets;for(let p=0,f=i.length;p<f;p++){let m={};if(m.name=i[p].name,i[p].vertices!==void 0){m.vertices=[];for(let h=0,y=i[p].vertices.length;h<y;h++)m.vertices.push(i[p].vertices[h].clone())}if(i[p].normals!==void 0){m.normals=[];for(let h=0,y=i[p].normals.length;h<y;h++)m.normals.push(i[p].normals[h].clone())}this.morphTargets.push(m)}let a=r.morphNormals;for(let p=0,f=a.length;p<f;p++){let m={};if(a[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=a[p].vertexNormals.length;h<y;h++){let g=a[p].vertexNormals[h],x={};x.a=g.a.clone(),x.b=g.b.clone(),x.c=g.c.clone(),m.vertexNormals.push(x)}}if(a[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=a[p].faceNormals.length;h<y;h++)m.faceNormals.push(a[p].faceNormals[h].clone())}this.morphNormals.push(m)}let s=r.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let u=r.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let l=r.boundingBox;l!==null&&(this.boundingBox=l.clone());let d=r.boundingSphere;return d!==null&&(this.boundingSphere=d.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 Qd().fromGeometry(this),e=new jy,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Ul.call(new Ha(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Ul.call(new Ha(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",ky.call(new Ha(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Uy.call(new Ha(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Uy.call(new Ha(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],a=r.morphTargets[o];for(let s=0,c=a.length;s<c;s++){let u=a[s],l=new _i(u.data.length*3,3);l.name=u.name,i.push(Ul.call(l,u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new _i(r.skinIndices.length*4,4);e.setAttribute("skinIndex",Hy.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new _i(r.skinWeights.length*4,4);e.setAttribute("skinWeight",Hy.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 jy,t=r.geometry;if(r.isPoints||r.isLine){let o=new _i(t.vertices.length*3,3),i=new _i(t.colors.length*3,3);if(e.setAttribute("position",Ul.call(o,t.vertices)),e.setAttribute("color",ky.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new _i(t.lineDistances.length,1);e.setAttribute("lineDistance",oO.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}};Vo.prototype.isGeometry=!0;var Qd=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,c=s.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let l=r.morphNormals,d=l.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:l[g].name,data:[]};this.morphTargets.normal=p}let f=r.skinIndices,m=r.skinWeights,h=f.length===t.length,y=m.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 x=e[g];this.vertices.push(t[x.a],t[x.b],t[x.c]);let S=x.vertexNormals;if(S.length===3)this.normals.push(S[0],S[1],S[2]);else{let b=x.normal;this.normals.push(b,b,b)}let w=x.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let b=x.color;this.colors.push(b,b,b)}if(i===!0){let b=o[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new $t,new $t,new $t))}if(a===!0){let b=o[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new $t,new $t,new $t))}for(let b=0;b<c;b++){let T=s[b].vertices;u[b].data.push(T[x.a],T[x.b],T[x.c])}for(let b=0;b<d;b++){let T=l[b].vertexNormals[g];p[b].data.push(T.a,T.b,T.c)}h&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),y&&this.skinWeights.push(m[x.a],m[x.b],m[x.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}},Pi=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 vt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new Jd,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 oO(n){return this.array.set(n),this}function ky(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 Jd),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function Uy(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 $t),r[e++]=i.x,r[e++]=i.y}return this}function Ul(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 vt),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function Hy(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 rO),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var iO=["a","b","c"];function aO(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function tu(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function ru(n,r,e,t,o,i){let a=Math.min(n,r),s=Math.max(n,r),c=a+"_"+s,u;if(t.has(c))u=t.get(c);else{let l=e[a],d=e[s];u={a:l,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function sO(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],ru(a.a,a.b,n,t,a,e),ru(a.b,a.c,n,t,a,e),ru(a.c,a.a,n,t,a,e)}function Hl(n,r,e,t,o){n.push(new Pi(r,e,t,void 0,void 0,o))}function Oi(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Wl(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var ql=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof nO?r=new Vo().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 qy,t,o,i,a,s,c=r.vertices,u=r.faces,l=r.faceVertexUvs[0],d=l!==void 0&&l.length>0,p=[],f=new Map;sO(c,u,p,f);let m=[],h,y,g,x,S,w,b;for(let F of Array.from(f.keys())){for(y=f.get(F),g=new qy,S=3/8,w=1/8,b=y.faces.length,b!=2&&(S=.5,w=0,b!=1),g.addVectors(y.a,y.b).multiplyScalar(S),e.set(0,0,0),a=0;a<b;a++){for(x=y.faces[a],s=0;s<3&&(h=c[aO(x,iO[s])],!(h!==y.a&&h!==y.b));s++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let T,_,v,N,P,C,O,A=[];for(o=0,i=c.length;o<i;o++){for(C=c[o],P=p[o].edges,t=P.length,t==3?T=3/16:t>3&&(T=3/(8*t)),_=1-t*Number(T),v=T,t<=2&&(t==2?(_=3/4,v=1/8):t==1||t==0),O=C.clone().multiplyScalar(_),e.set(0,0,0),a=0;a<t;a++)N=P[a],h=N.a!==C?N.a:N.b,e.add(h);e.multiplyScalar(Number(v)),O.add(e),A.push(O)}let M=A.concat(m),L=A.length,X,R,Z,z=[],V=[],W,$,Y,q,k=new eu,U=new eu,B=new eu;for(o=0,i=u.length;o<i;o++)x=u[o],X=Number(tu(x.a,x.b,f).newEdge)+L,R=Number(tu(x.b,x.c,f).newEdge)+L,Z=Number(tu(x.c,x.a,f).newEdge)+L,Hl(z,X,R,Z,x.materialIndex),Hl(z,x.a,X,Z,x.materialIndex),Hl(z,x.b,R,X,x.materialIndex),Hl(z,x.c,Z,R,x.materialIndex),d&&(W=l[o],$=W[0],Y=W[1],q=W[2],k.set(Oi($.x,Y.x),Oi($.y,Y.y)),U.set(Oi(Y.x,q.x),Oi(Y.y,q.y)),B.set(Oi($.x,q.x),Oi($.y,q.y)),Wl(V,k,U,B),Wl(V,$,k,B),Wl(V,Y,U,k),Wl(V,q,B,U));r.vertices=M,r.faces=z,d&&(r.faceVertexUvs[0]=V)}};var ot=new cO,Xy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new $y().copy(new Yy(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(ot),t={width:ot.x,height:ot.y,depth:ot.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 $y().copy(new Yy(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ot)):ot.set(a.width,a.height,a.depth),(r!==ot.x||e!==ot.y||t!==ot.z)&&i.scale(ot.x===0?1:r/ot.x,ot.y===0?1:e/ot.y,ot.z===0?1:t/ot.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new ql(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 lO(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(ot);let a=100/ot.x;Object.assign(i.parameters,{width:100,height:ot.y*a,depth:ot.z*a}),r(this.build(i))})}};var $l=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 Ce?n.shape:new Ce,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,c=n.shape,u=r*.5,l=e*.5,d=0,p=0,f=2*Math.PI/t;for(let h=0;h<t;h++){let y=f*h,g=d+Math.sin(y)*u,x=p+Math.cos(y)*l;c.addPoint(c.createPoint(g,x))}c.isClosed=!0;for(let h=0,y=c.points.length;h<y;h++)c.points[h].roundness=o;c.roundness=o,c.update();let m=Gt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as dO,Float32BufferAttribute as ou,Vector2 as Dr,Vector3 as dt}from"three";var Ky=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:c}=n.parameters,u=new iu(r*.5,e,o,i,a,s,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function Wa(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function nu(n,r,e,t,o,i){let a=r.clone().sub(n),s=e.clone().sub(n),c=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,t/Math.sin(u))}}function uO(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var iu=class extends dO{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 c=[],u=[],l=[],d=[],p=0,f=e/2,m=Math.PI/t,h=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,x=Math.PI-g,S=new dt(0,-f,0),w=new dt(0,f,0),b=new Dr(r,-f),T=new Dr(h,-f),_=new Dr(0,w.y).sub(T),v=new Dr(0,w.y).sub(b),N=new Dr(_.y,-_.x).normalize(),P=new Dr(v.y,-v.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;a=Math.min(a,O);let A;{let V=new dt(N.x,N.y,0),W=new dt(Math.cos(y)*V.x,V.y,Math.sin(y)*V.x);A=V.angleTo(W)}let M=a/Math.tan((Math.PI-_.angle())/2),L=a/Math.tan((Math.PI-A)/2),X=new dt;if(!i){u.push(S.x,S.y,S.z),l.push(0,-1,0),d.push(0,0);let V=p++,W=[],$=b.clone(),Y=M/Math.cos(Math.PI/t);$.x-=Y;for(let q=0;q<t;q++){let k=q/t*Math.PI*2+m,U=new Dr(Math.sin(k),Math.cos(k));Wa($,U,X),u.push(X.x,X.y,X.z),l.push(0,-1,0),d.push(0,0),W.push(p++)}for(let q=0;q<W.length;q++)c.push(W[q],V,W[(q+1)%W.length])}let R=[];{let V=new dt,W=new dt,$=new dt,Y=new dt,q=new dt,k=new dt;for(let U=0;U<t;U++){let B=U/t*Math.PI*2+m,F=(U+.5)/t*Math.PI*2+m,j=(U+1)/t*Math.PI*2+m,D=new Dr(Math.sin(B),Math.cos(B)),oe=new Dr(Math.sin(F),Math.cos(F)),ee=new Dr(Math.sin(j),Math.cos(j));Wa(b,D,W),Wa(b,ee,$),Wa(N,oe,V),nu(w,W,$,L,L,Y),u.push(Y.x,Y.y,Y.z),nu(W,w,$,L,M,q),u.push(q.x,q.y,q.z),nu($,W,w,M,L,k),u.push(k.x,k.y,k.z),l.push(V.x,V.y,V.z),l.push(V.x,V.y,V.z),l.push(V.x,V.y,V.z),d.push(0,0),d.push(0,0),d.push(0,0);let K=p++,te=p++,Q=p++;if(c.push(K,te,Q),a>0){{let ie=W.clone().add($).multiplyScalar(.5),ce=w.clone().sub(ie).normalize(),de=S.clone().sub(ie).normalize().add(ce).normalize().multiplyScalar(-1),ye=k.clone().sub(q);Z(ie,ye,de,_.angle())}let se,ne;{let ie=new dt;Wa(P,ee,ie);let ce=k.clone().add(Y).multiplyScalar(.5);ce=uO(ce,$,w);let le=k.clone().sub(Y);[se,ne]=Z(ce,le,ie,A,Y.y)}{let ie=se,ce=ie.clone().setY(0).normalize(),le=new dt(0,-1,0),de=ce.clone().cross(le);z(ie,ce,le,de)}R.concat(ne);{let ie=_.angle(),ce=Math.PI-ie,le=w.clone();le.y-=a/Math.sin(ie-Math.PI/2);let de=new dt,ye=[];for(let Ve=0;Ve<s;Ve++){let Oe=[],Be=Math.PI/2-ce*Ve/s,Et=Math.cos(Be),be=Math.sin(Be),tt=F;for(let at=0;at<=Ve;at++){let _n=Math.cos(tt),Ye=Math.sin(tt);V.x=Et*Ye,V.y=be,V.z=Et*_n,de.copy(le).addScaledVector(V,a),u.push(de.x,de.y,de.z),l.push(V.x,V.y,V.z),d.push(0,0),Oe.push(p++),tt+=Math.PI*2/Ve/t}ye.push(Oe)}ne.reverse(),ye.push(ne);let Pe=ye.length-1;for(let Ve=0;Ve<Pe;Ve++){let Oe=ye[Ve],Be=ye[Ve+1],Et=Oe.length-1;c.push(Be[1],Oe[0],Be[0]);for(let be=1;be<=Et;be++)c.push(Oe[be],Oe[be-1],Be[be]),c.push(Be[be+1],Oe[be],Be[be])}}}}}this.setIndex(c),this.setAttribute("position",new ou(u,3)),this.setAttribute("normal",new ou(l,3)),this.setAttribute("uv",new ou(d,2));function Z(V,W,$,Y,q){let k=-Y/2,U=(Math.PI-Y)/2,B=W.clone().normalize().cross($);V.addScaledVector($,-a/Math.sin(U));let F=new dt,j=new dt,D=1,oe=p,ee=[];for(let K=0;K<=s;K++){let te=k+K/s*Y;j.set(0,0,0),j.addScaledVector(B,Math.sin(te)),j.addScaledVector($,Math.cos(te));for(let Q=0;Q<=D;Q++){let se=Q/D-.5;if(F.copy(V),F.addScaledVector(W,se),F.addScaledVector(j,a),q!=null){let ne=Math.max(0,F.y-q);F.addScaledVector(W,-ne/W.y)}u.push(F.x,F.y,F.z),l.push(j.x,j.y,j.z),d.push(0,0),Q===0&&ee.push(p),p++}}for(let K=0;K<s;K++)for(let te=0;te<D;te++){let Q=oe+te+(D+1)*K,se=Q+(D+1),ne=se+1,ie=Q+1;c.push(Q,se,ie),c.push(se,ne,ie)}return[V.clone().addScaledVector(W,.5),ee]}function z(V,W,$,Y){let q=Math.PI/2,k=v.angle()-q,U=[],B=new dt,F=new dt;for(let D=0;D<=s;D++){let oe=[],ee=D/s;for(let K=0;K<=D;K++){let Q=((D?K/D:0)-.5)*x,se=Math.cos(Q),ne=Math.sin(Q),ie=Math.atan(Math.tan(k)*se),ce=(q+ie)*ee,le=Math.cos(ce),de=Math.sin(ce);B.set(0,0,0),B.addScaledVector(W,de*se),B.addScaledVector($,le),B.addScaledVector(Y,de*ne),F.copy(V).addScaledVector(B,a),u.push(F.x,F.y,F.z),l.push(B.x,B.y,B.z),d.push(0,0),oe.push(p++)}U.push(oe)}let j=U.length-1;for(let D=0;D<j;D++){let oe=U[D],ee=U[D+1],K=oe.length-1;c.push(oe[0],ee[1],ee[0]);for(let te=1;te<=K;te++)c.push(oe[te-1],oe[te],ee[te]),c.push(oe[te],ee[te+1],ee[te])}}}};var Yl=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 Ce?n.shape:new Ce,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:c}=n.parameters,u={x:e*.5,y:t*.5},l={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(w,b,T){return b>e&&T>t?Math.min(w*e/b,w*t/T):b>e?w*e/b:T>t?w*t/T:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=l.x,h=d.x,y=d.y,g=l.y;r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(h,g)),r.addPoint(r.createPoint(m,g)),r.isClosed=!0;let x=!0;for(let w=0,b=r.points.length;w<b;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(x=!1);x&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let S=Gt.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:c}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as pO,Float32BufferAttribute as fO,MathUtils as Zy,SphereGeometry as mO}from"three";var Qy=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=Zy.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:c,thetaLength:u}=n.parameters,l;return u===0?(l=new pO,l.setAttribute("position",new fO([],3))):l=new mO(.5*r,o,i,a,s,c,u*Zy.DEG2RAD),l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as hO}from"three";var Jy=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 hO(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as yO,Float32BufferAttribute as au,Vector3 as gO}from"three";var eg=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 su(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},su=class extends yO{constructor(r=1,e=1,t=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],c=[],u=[],l=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-l,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(F=0,j=0,D=0)=>new gO(F,j,D),m=f(),h=f(),[y,g,x]=[e/2,r/2,t/2],S=-g,w=+g,[b,T,_]=[f(S,-y,+x),f(S,-y,-x),f(S,+y,-x)],v=(F,j=!1)=>Math.sin(F-Math.PI/(1+ +j)),N=(F,j=!1)=>Math.cos(F-Math.PI/(1+ +j));_.y=Math.sin(o)*e-y;let P=Math.cos(o)*e-x,C=b.z-l;o<=p?(_.z=Math.min(P,C),_.z==C&&(_.y-=(P-C)/Math.tan(p-o))):T.z=Math.min(T.z-P-x,b.z-l),m.subVectors(b,T),h.subVectors(_,T);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),M=O/Math.cos(o/2),L=m.clone().normalize().add(h.normalize()).setLength(M).add(T);m.set(0,v(o,!0),N(o,!0)),d.push([_,m.clone()]);let X=(Math.PI-o)/a;for(let F=0;F<=a;F++){let j=p+o+F*X;m.set(0,Math.sin(j)*A,Math.cos(j)*A),m.add(L),h.set(0,v(j),N(j)),d.push([m.clone(),h.clone()])}d.push([b,f(0,1,0)]);let R=Math.sin(X/2)*A*2,Z=d.length-1,z=d[0][0].distanceTo(d[1][0]),V=d[Z-1][0].distanceTo(d[Z][0]),W=z+R*a+V;d[0].push(1);for(let F=0;F<=a;F++)d[F+1].push(1-(z+F*R)/W);d[Z].push(0);let[$,Y,q]=d[0],k,U,B;for(let F=1;F<d.length;F++)[k,U,B]=d[F],s.push(S,$.y,$.z,S,k.y,k.z,w,$.y,$.z,w,$.y,$.z,S,k.y,k.z,w,k.y,k.z),c.push(0,Y.y,Y.z,0,U.y,U.z,0,Y.y,Y.z,0,Y.y,Y.z,0,U.y,U.z,0,U.y,U.z),u.push(0,q,0,B,1,q,1,q,0,B,1,B),[$,Y,q]=[k,U,B];this.setAttribute("position",new au(s,3)),this.setAttribute("normal",new au(c,3)),this.setAttribute("uv",new au(u,2))}};var Xl=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 Ce?n.shape:new Ce,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:c,extrudeBevelSegments:u}=n.parameters,l=n.shape,d=r*.5,p=e*.5,f=0,m=0,h=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*t/100,x=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let w=0;w<o;w++){let b=h*w,T=f+Math.sin(b)*d,_=m+Math.cos(b)*p;l.addPoint(l.createPoint(T,_))}}else for(let w=0;w<o;w++){let b=f+Math.cos(y)*d,T=m+Math.sin(y)*p;l.addPoint(l.createPoint(b,T)),y+=h,b=f+Math.cos(y)*g,T=m+Math.sin(y)*x,w<=o,l.addPoint(l.createPoint(b,T)),y+=h}l.isClosed=!0;for(let w=0,b=l.points.length;w<b;w++)l.points[w].roundness=i;l.roundness=i,l.update();let S=Gt.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as xO}from"three";var tg=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 xO(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as vO,Float32BufferAttribute as bO,MathUtils as SO}from"three";var rg=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:c}=n.parameters,u=wO(r,e,t,r*.5,a,i,0,0,o,s,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function wO(n,r,e,t,o,i,a,s,c,u,l){[r,e]=[e,r],a=r/2;let d=SO.clamp(o/360,0,1);if(d===0){let p=new vO;return p.setAttribute("position",new bO([],3)),p}return d===1&&(u=0),new ka(!0,n,r,e,t,d,i,a,s,c,u,l)}import{TorusKnotGeometry as TO}from"three";var og=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 c=new TO(s,e,t,o,i,a);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var ng=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 Ce?n.shape:new Ce,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,c=n.shape,u=r*.5,l=e*.5;s?(c.addPoint(c.createPoint(-u,l)),c.addPoint(c.createPoint(u,-l)),c.addPoint(c.createPoint(-u,-l))):(c.addPoint(c.createPoint(0,l)),c.addPoint(c.createPoint(u,-l)),c.addPoint(c.createPoint(-u,-l))),c.isClosed=!0;for(let p=0,f=c.points.length;p<f;p++)c.points[p].roundness=t;c.roundness=t,c.update();let d=Gt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as ag,Vector3 as ut,Matrix3 as _O,Matrix4 as on,BufferGeometry as sg,BufferAttribute as Ai,MathUtils as Kl}from"three";function ig(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var PO=new on,OO=new on;function AO(n,r,e){let t=[new ut,new ut,new ut],o=[new ut,new ut,new ut];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],c=Kl.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(c)}),new on().makeBasis(t[0],t[1],t[2])}var lg=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??Ti.create({parameters:ad}).userData.shape;return{path:n.path??oi.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...pl,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new lu(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new sg,{userData:{...n,type:"PathGeometry"}})}},lu=class extends sg{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)||!ig(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,a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),c=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,c-s+1),a+2),l=[],d=[];for(let z=0;z<u;z++){let V=this.inputs.path.isClosed?(z+s)%e.length:Math.min(z+s,e.length-1);l.push(e[V].clone()),d.push(t[V].clone())}let p=(z,V,W)=>{l[z]=l[z].clone().lerp(l[V],W),d[z]=AO(d[z],d[V],W)},f=0,m=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(m||i===0)&&(f=m,p(0,1,f));let h=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(h=y,p(l.length-1,l.length-2,1-h)),o===0){let z=l.length-1;l[z].copy(l[0]),d[z].copy(d[0])}this._applyPathModifiers(d,f,h);let{bevel:g,bevelSides:x}=this.inputs.parameters.extrusion,S=g>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:T,vertices:_}=this._computeShapePoints(w),v=0,N;S==="round"&&(N=new Go(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=N.getAttribute("position").count);let P=0,C=0;T.sort((z,V)=>z.start-V.start),T.forEach(z=>{z.verticesStart=P,z.verticesCount=z.continuous.reduce((V,W,$)=>V+($===0||!W?2:1),0),C+=z.verticesCount,P=C});let O=C*u,A,M=0;if(this._isOpenEnded()&&S==="flat"){try{A=pr({windingRule:_e.ODD,elementType:ke.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{A=$d}M=A.vertexCount}let L=O+2*M+v*2,X=O+2*M,R={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},Z=[];if(T.forEach(z=>{this._extrudeRegion(z,_,d,l,R,Z,this._isGeometryClosed()&&!this._isOpenEnded())}),A&&(this._closeEnd(A,O,Z,R,d[0],l[0],!1),this._closeEnd(A,O+M,Z,R,d[d.length-1],l[l.length-1],!0)),N){R.positions.set(N.getAttribute("position").array,X*3),R.normals.set(N.getAttribute("normal").array,X*3),R.uvs.set(N.getAttribute("uv").array,X*2);let z=Z.length;Z.push(...N.getIndex().array.map($=>$+X)),X+=v,R.positions.set(N.getAttribute("position").array,X*3),R.normals.set(N.getAttribute("normal").array,X*3),R.uvs.set(N.getAttribute("uv").array,X*2);let V=Z.length;Z.push(...N.getIndex().array.map($=>$+X)),this.setAttribute("position",new Ai(R.positions,3)),this.setAttribute("normal",new Ai(R.normals,3)),this.setAttribute("uv",new Ai(R.uvs,2)),this.setIndex(Z);let W=PO;W.copy(d[d.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(W,X,L),W.copy(d[0]).setPosition(l[0]).multiply(OO.makeScale(1,1,-1)),this.applyMatrix4OnRange(W,X-v,X),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new Ai(R.positions,3)),this.setAttribute("normal",new Ai(R.normals,3)),this.setAttribute("uv",new Ai(R.uvs,2)),this.setIndex(Z)}_extractPathPoints(){let t=Cl(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 ut,s=new ut,c=new ut,u=new ut,l=new ut(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(x).normalize(),b=S.clone().sub(g).normalize(),T=w.clone().add(b).normalize();c.copy(T),y===0&&(T.equals(l)||T.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(T).normalize(),v=T.clone().cross(_).normalize();l.copy(v),u.copy(_),y===0&&(a.copy(v),s.copy(T));let N=new on().makeBasis(_,v,T);t.push(N)}let d=i?s:c,p=i?a:new ut(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(p.dot(f));if(isNaN(m))return t;let h=p.clone().cross(f);d.dot(h)>0&&(m*=-1);for(let y=1;y<t.length;y++){let g=new on().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:c,endScale:u}=this.inputs.parameters.extrusion,l=new on,d=new on;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));l.makeRotationZ(Kl.lerp(a,a+s,m)*Kl.DEG2RAD);let h=Kl.lerp(c,u,m);d.makeScale(h,h,h),p.multiply(l).multiply(d)}),e}_computeShapePoints(e=12,t=_e.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let x=y.length-1;x>=1;x-=2){let S=y[x-1],w=y[x-0];g.push(S,w)}return g}),s;try{s=pr({windingRule:t,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=Fa}let c;try{c=pr({windingRule:_e.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{c=qd}if(!s)throw new Error("error generating geometry");let u=s.elementCount;if(c){s.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];s.vertices.push(y)}}let l=1/0,d=-1/0,p=1/0,f=-1/0;for(let h=0,y=s.vertexCount;h<y;h++){let g=h*2,x=s.vertices[g+0],S=s.vertices[g+1];x<l&&(l=x),x>d&&(d=x),S<p&&(p=S),S>f&&(f=S)}let m=[];for(let h=s.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,x=s.elements[g+0],S=s.elements[g+1],w=x+S,b={start:x,count:S,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(b);let T=x,_=w-1,v=x+1,N=o.roundedCurves.length;do{let P=T-x,C=s.vertices[_*2+0],O=s.vertices[_*2+1],A=s.vertices[T*2+0],M=s.vertices[T*2+1],L=s.vertices[v*2+0],X=s.vertices[v*2+1],R=A-C,Z=M-O,z=Math.sqrt(R*R+Z*Z);R/=z,Z/=z;let V=A-L,W=M-X,$=Math.sqrt(V*V+W*W);V/=$,W/=$,b.normals[P*2+0]=-W,b.normals[P*2+1]=V;let Y=s.vertexIndices[T];if(Array.isArray(Y))b.continuous[P]=!1;else{let[q,k]=o.getCurveIndexFromVertexId(Y-1,!0);if(k>0&&k<1)b.continuous[P]=!0;else{let U=k===1?q+1:q-1;U=(U+N)%N;let B=k===1?0:1,F=o.roundedCurves[q].getTangent(k),j=o.roundedCurves[U].getTangent(B);b.continuous[P]=F.dot(j)>.95}}y&&(b.normals[P*2+0]*=-1,b.normals[P*2+1]*=-1),[_,T,v]=[T,v,v+1],v>=w&&(v-=S)}while(v!==x+1)}return{regions:[i,...a],infos:m,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,c=t*3;e.positions[c+0]=o.x,e.positions[c+1]=o.y,e.positions[c+2]=o.z,e.normals[c+0]=i.x,e.normals[c+1]=i.y,e.normals[c+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,i,a,s,c){let u=new ut,l=new ut,d=new ut,p=new ut,f=new ag;o.forEach((h,y)=>{let g=i[y],x=e.verticesStart*o.length+e.verticesCount*y;for(let S=0;S<e.count;S++){let w=(e.start+S)*2;if(u.set(t[w+0],t[w+1],0),d.copy(u).applyMatrix4(h).add(g),e.continuous[S])p.set(e.normals[S*2+0],e.normals[S*2+1],0);else{let b=S===0?(e.start+e.count-1)*2:w-2;l.set(t[b+0],t[b+1],0),p.copy(u).sub(l),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(S===0?1:S/e.count,y/(o.length-1)),this._insertVertex(a,x,d,p,f),x++,!e.continuous[S]||S===0){if(S===0)p.set(e.normals[S*2+0],e.normals[S*2+1],0),f.set(0,y/(o.length-1));else{let b=S===e.count-1?e.start*2:w+2;l.set(t[b+0],t[b+1],0),p.copy(l).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(a,x,d,p,f),x++}}});let m=o.length-1;for(let h=0;h<m;h++){let y=e.verticesStart*o.length+e.verticesCount*h,g=e.verticesStart*o.length+e.verticesCount*(h+1),x=0;for(let S=0;S<e.count;S++){(!e.continuous[S]||S===0)&&x++;let w=S===e.count-1?0:x+1,b=y+x,T=y+w,_=g+w,v=g+x;e.isHole?s.push(b,_,T,b,v,_):s.push(b,T,_,b,_,v),x++}}}_closeEnd(e,t,o,i,a,s,c){let u=e.vertexCount,l=new ut(0,0,c?-1:1).applyMatrix4(a),d=new ut,p=new ag;for(let m=0;m<u;m++){let h=2*m;d.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(a).add(s),this._insertVertex(i,t+m,d,l,p)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let h=3*m,y=f[h+0]+t,g=f[h+(c?1:2)]+t,x=f[h+(c?2:1)]+t;o.push(y,g,x)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new _O().getNormalMatrix(e).elements,s,c,u,l,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,m=p.array,h=d.itemSize;for(let y=t*h,g=o*h;y<g;y+=h){if(y===t)debugger;s=f[y+0],c=f[y+1],u=f[y+2],l=1/(i[3]*s+i[7]*c+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*c+i[8]*u+i[12])*l,f[y+1]=(i[1]*s+i[5]*c+i[9]*u+i[13])*l,f[y+2]=(i[2]*s+i[6]*c+i[10]*u+i[14])*l,s=m[y+0],c=m[y+1],u=m[y+2],m[y+0]=a[0]*s+a[3]*c+a[6]*u,m[y+1]=a[1]*s+a[4]*c+a[7]*u,m[y+2]=a[2]*s+a[5]*c+a[8]*u}d.needsUpdate=!0,p.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),c=o.getX(i+2);o.setXYZ(i,c,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as cg,BufferGeometry as cu}from"three";import{mergeBufferGeometries as CO}from"three/examples/jsm/utils/BufferGeometryUtils.js";function dg(){let n=new cu;return n.setAttribute("position",new cg(new Float32Array([]),3)),n.setIndex(new cg(new Uint16Array([]),1)),n}var NO=dg().attributes,IO=12,MO=1,Ci=class extends cu{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,NO),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:c,text:u,textTransform:l}=e,d=bl.getDisplayedValue(u),p=l===2?d.toUpperCase():l===3?d.toLowerCase():d,f=EO(e,t,p),{shapes:m,charWidths:h,charCoords:y}=t.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,x=(typeof i=="number"?i:1)*.5,S=m.map(T=>new Ce().fromShape(T));this.vectorShapes=S;let w=S.map(T=>Gt.create({shape:T,parameters:{depth:a,extrudeBevelSegments:c,extrudeBevelSize:s,windingRule:a<=0?_e.NONZERO:_e.ODD,subdivisions:this.isLowResolution&&a>0?MO:IO}})),b=w.length?CO(w):dg();b.translate(-g,x,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=h,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([T,_])=>{this.setAttribute(T,_)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=Dt(new cu,Ci.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 EO(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
1
+ var xx=Object.create;var Dc=Object.defineProperty;var vx=Object.getOwnPropertyDescriptor;var bx=Object.getOwnPropertyNames;var Sx=Object.getPrototypeOf,wx=Object.prototype.hasOwnProperty;var Pn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Tx=(n,r)=>{for(var e in r)Dc(n,e,{get:r[e],enumerable:!0})},_x=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of bx(r))!wx.call(n,o)&&o!==e&&Dc(n,o,{get:()=>r[o],enumerable:!(t=vx(r,o))||t.enumerable});return n};var ga=(n,r,e)=>(e=n!=null?xx(Sx(n)):{},_x(r||!n||!n.__esModule?Dc(e,"default",{value:n,enumerable:!0}):e,n));var Hh=Pn((yd,Uh)=>{(function(n,r){typeof yd=="object"?Uh.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(yd,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 c=0;c<e.length;c++)t-=s(e[c]),t<0&&(t+=1),o-=s(e[c]),o<0&&(o+=1),i-=s(e[c]),i<0&&(i+=1);s=null;var u=function(){var l=2091639*t+a*23283064365386963e-26;return t=o,o=i,i=l-(a=l|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[t,o,i,a]},u.importState=function(l){t=+l[0]||0,o=+l[1]||0,i=+l[2]||0,a=+l[3]||0},u}(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 Xh=Pn((Cl,Yh)=>{(function(n,r){typeof Cl=="object"&&typeof Yh<"u"?r(Cl):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Cl,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,c,u,l,d,p,f,m,h,y,g,x=r[0].length,S=r.length;if(S<x)throw new TypeError("Invalid matrix: m < n");for(var w=[],b=[],T=[],_=e==="f"?S:x,v=h=p=0;v<S;v++)b[v]=new Array(_).fill(0);for(v=0;v<x;v++)T[v]=new Array(x).fill(0);var N,P=new Array(x).fill(0);for(v=0;v<S;v++)for(a=0;a<x;a++)b[v][a]=r[v][a];for(v=0;v<x;v++){for(w[v]=p,m=0,c=v+1,a=v;a<S;a++)m+=Math.pow(b[a][v],2);if(m<i)p=0;else for(f=(d=b[v][v])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v]=d-p,a=c;a<x;a++){for(m=0,s=v;s<S;s++)m+=b[s][v]*b[s][a];for(d=m/f,s=v;s<S;s++)b[s][a]=b[s][a]+d*b[s][v]}for(P[v]=p,m=0,a=c;a<x;a++)m+=Math.pow(b[v][a],2);if(m<i)p=0;else{for(f=(d=b[v][v+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v+1]=d-p,a=c;a<x;a++)w[a]=b[v][a]/f;for(a=c;a<S;a++){for(m=0,s=c;s<x;s++)m+=b[a][s]*b[v][s];for(s=c;s<x;s++)b[a][s]=b[a][s]+m*w[s]}}h<(y=Math.abs(P[v])+Math.abs(w[v]))&&(h=y)}if(t)for(v=x-1;0<=v;v--){if(p!==0){for(f=b[v][v+1]*p,a=c;a<x;a++)T[a][v]=b[v][a]/f;for(a=c;a<x;a++){for(m=0,s=c;s<x;s++)m+=b[v][s]*T[s][a];for(s=c;s<x;s++)T[s][a]=T[s][a]+m*T[s][v]}}for(a=c;a<x;a++)T[v][a]=0,T[a][v]=0;T[v][v]=1,p=w[v],c=v}if(e){if(e==="f")for(v=x;v<S;v++){for(a=x;a<S;a++)b[v][a]=0;b[v][v]=1}for(v=x-1;0<=v;v--){for(c=v+1,p=P[v],a=c;a<_;a++)b[v][a]=0;if(p!==0){for(f=b[v][v]*p,a=c;a<_;a++){for(m=0,s=c;s<S;s++)m+=b[s][v]*b[s][a];for(d=m/f,s=v;s<S;s++)b[s][a]=b[s][a]+d*b[s][v]}for(a=v;a<S;a++)b[a][v]=b[a][v]/p}else for(a=v;a<S;a++)b[a][v]=0;b[v][v]=b[v][v]+1}}for(o*=h,s=x-1;0<=s;s--)for(var C=0;C<50;C++){for(N=!1,c=s;0<=c;c--){if(Math.abs(w[c])<=o){N=!0;break}if(Math.abs(P[c-1])<=o)break}if(!N){for(l=0,u=c-(m=1),v=c;v<s+1&&(d=m*w[v],w[v]=l*w[v],!(Math.abs(d)<=o));v++)if(p=P[v],P[v]=Math.sqrt(d*d+p*p),l=p/(f=P[v]),m=-d/f,e)for(a=0;a<S;a++)y=b[a][u],g=b[a][v],b[a][u]=y*l+g*m,b[a][v]=-y*m+g*l}if(g=P[s],c===s){if(g<0&&(P[s]=-g,t))for(a=0;a<x;a++)T[a][s]=-T[a][s];break}for(h=P[c],d=(((y=P[s-1])-g)*(y+g)+((p=w[s-1])-(f=w[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((h-g)*(h+g)+f*(y/(d<0?d-p:d+p)-f))/h,v=c+(m=l=1);v<s+1;v++){if(p=w[v],y=P[v],f=m*p,p*=l,g=Math.sqrt(d*d+f*f),d=h*(l=d/(w[v-1]=g))+p*(m=f/g),p=-h*m+p*l,f=y*m,y*=l,t)for(a=0;a<x;a++)h=T[a][v-1],g=T[a][v],T[a][v-1]=h*l+g*m,T[a][v]=-h*m+g*l;if(g=Math.sqrt(d*d+f*f),d=(l=d/(P[v-1]=g))*p+(m=f/g)*y,h=-m*p+l*y,e)for(a=0;a<S;a++)y=b[a][v-1],g=b[a][v],b[a][v-1]=y*l+g*m,b[a][v]=-y*m+g*l}w[c]=0,w[s]=d,P[s]=h}for(v=0;v<x;v++)P[v]<o&&(P[v]=0);return{u:b,q:P,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var Cy=Pn((Ud,Hd)=>{(function(n,r){typeof Ud=="object"&&typeof Hd<"u"?Hd.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(Ud,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 c=t-1>>1,u=i[c];if(a(s,u)>=0)break;i[t]=u,t=c}i[t]=s},n.prototype._down=function(t){for(var o=this,i=o.data,a=o.compare,s=this.length>>1,c=i[t];t<s;){var u=(t<<1)+1,l=i[u],d=u+1;if(d<this.length&&a(i[d],l)<0&&(u=d,l=i[d]),a(l,c)>=0)break;i[t]=l,t=u}i[t]=c};function r(e,t){return e<t?-1:e>t?1:0}return n})});var Iy=Pn((zk,Wd)=>{"use strict";var zl=Cy();zl.default&&(zl=zl.default);Wd.exports=Ny;Wd.exports.default=Ny;function Ny(n,r,e){r=r||1;for(var t,o,i,a,s=0;s<n[0].length;s++){var c=n[0][s];(!s||c[0]<t)&&(t=c[0]),(!s||c[1]<o)&&(o=c[1]),(!s||c[0]>i)&&(i=c[0]),(!s||c[1]>a)&&(a=c[1])}var u=i-t,l=a-o,d=Math.min(u,l),p=d/2;if(d===0){var f=[t,o];return f.distance=0,f}for(var m=new zl(void 0,GP),h=t;h<i;h+=d)for(var y=o;y<a;y+=d)m.push(new Ro(h+p,y+p,p,n));var g=zP(n),x=new Ro(t+u/2,o+l/2,0,n);x.d>g.d&&(g=x);for(var S=m.length;m.length;){var w=m.pop();w.d>g.d&&(g=w,e&&console.log("found best %d after %d probes",Math.round(1e4*w.d)/1e4,S)),!(w.max-g.d<=r)&&(p=w.h/2,m.push(new Ro(w.x-p,w.y-p,p,n)),m.push(new Ro(w.x+p,w.y-p,p,n)),m.push(new Ro(w.x-p,w.y+p,p,n)),m.push(new Ro(w.x+p,w.y+p,p,n)),S+=4)}e&&(console.log("num probes: "+S),console.log("best distance: "+g.d));var b=[g.x,g.y];return b.distance=g.d,b}function GP(n,r){return r.max-n.max}function Ro(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=VP(n,r,t),this.max=this.d+this.h*Math.SQRT2}function VP(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var a=e[i],s=0,c=a.length,u=c-1;s<c;u=s++){var l=a[s],d=a[u];l[1]>r!=d[1]>r&&n<(d[0]-l[0])*(r-l[1])/(d[1]-l[1])+l[0]&&(t=!t),o=Math.min(o,jP(n,r,l,d))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function zP(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 c=o[i],u=o[s],l=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*l,t+=(c[1]+u[1])*l,r+=l*3}return r===0?new Ro(o[0][0],o[0][1],0,n):new Ro(e/r,t/r,0,n)}function jP(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 c=((n-o)*a+(r-i)*s)/(a*a+s*s);c>1?(o=t[0],i=t[1]):c>0&&(o+=a*c,i+=s*c)}return a=n-o,s=r-i,a*a+s*s}});var qg=Pn(pc=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var l=this||r;return l._counter=1e3,l._html5AudioPool=[],l.html5PoolSize=10,l._codecs={},l._howls=[],l._muted=!1,l._volume=1,l._canPlayEvent="canplaythrough",l._navigator=typeof window<"u"&&window.navigator?window.navigator:null,l.masterGain=null,l.noAudio=!1,l.usingWebAudio=!0,l.autoSuspend=!0,l.ctx=null,l.autoUnlock=!0,l._setup(),l},volume:function(l){var d=this||r;if(l=parseFloat(l),d.ctx||u(),typeof l<"u"&&l>=0&&l<=1){if(d._volume=l,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(l,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.volume=h._volume*l)}return d}return d._volume},mute:function(l){var d=this||r;d.ctx||u(),d._muted=l,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(l?0:d._volume,r.ctx.currentTime);for(var p=0;p<d._howls.length;p++)if(!d._howls[p]._webAudio)for(var f=d._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=d._howls[p]._soundById(f[m]);h&&h._node&&(h._node.muted=l?!0:h._muted)}return d},stop:function(){for(var l=this||r,d=0;d<l._howls.length;d++)l._howls[d].stop();return l},unload:function(){for(var l=this||r,d=l._howls.length-1;d>=0;d--)l._howls[d].unload();return l.usingWebAudio&&l.ctx&&typeof l.ctx.close<"u"&&(l.ctx.close(),l.ctx=null,u()),l},codecs:function(l){return(this||r)._codecs[l.replace(/^x-/,"")]},_setup:function(){var l=this||r;if(l.state=l.ctx&&l.ctx.state||"suspended",l._autoSuspend(),!l.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(l._canPlayEvent="canplay")}catch{l.noAudio=!0}else l.noAudio=!0;try{var d=new Audio;d.muted&&(l.noAudio=!0)}catch{}return l.noAudio||l._setupCodecs(),l},_setupCodecs:function(){var l=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return l}if(!d||typeof d.canPlayType!="function")return l;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=l._navigator?l._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),h=m&&parseInt(m[0].split("/")[1],10)<33,y=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,g=f.match(/Version\/(.*?) /),x=y&&g&&parseInt(g[1],10)<15;return l._codecs={mp3:!!(!h&&(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:!!(!x&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&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$/,"")},l},_unlockAudio:function(){var l=this||r;if(!(l._audioUnlocked||!l.ctx)){l._audioUnlocked=!1,l.autoUnlock=!1,!l._mobileUnloaded&&l.ctx.sampleRate!==44100&&(l._mobileUnloaded=!0,l.unload()),l._scratchBuffer=l.ctx.createBuffer(1,1,22050);var d=function(p){for(;l._html5AudioPool.length<l.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,l._releaseHtml5Audio(f)}catch{l.noAudio=!0;break}for(var m=0;m<l._howls.length;m++)if(!l._howls[m]._webAudio)for(var h=l._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=l._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}l._autoResume();var x=l.ctx.createBufferSource();x.buffer=l._scratchBuffer,x.connect(l.ctx.destination),typeof x.start>"u"?x.noteOn(0):x.start(0),typeof l.ctx.resume=="function"&&l.ctx.resume(),x.onended=function(){x.disconnect(0),l._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var S=0;S<l._howls.length;S++)l._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),l}},_obtainHtml5Audio:function(){var l=this||r;if(l._html5AudioPool.length)return l._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(l){var d=this||r;return l._unlocked&&d._html5AudioPool.push(l),d},_autoSuspend:function(){var l=this;if(!(!l.autoSuspend||!l.ctx||typeof l.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<l._howls.length;d++)if(l._howls[d]._webAudio){for(var p=0;p<l._howls[d]._sounds.length;p++)if(!l._howls[d]._sounds[p]._paused)return l}return l._suspendTimer&&clearTimeout(l._suspendTimer),l._suspendTimer=setTimeout(function(){if(!!l.autoSuspend){l._suspendTimer=null,l.state="suspending";var f=function(){l.state="suspended",l._resumeAfterSuspend&&(delete l._resumeAfterSuspend,l._autoResume())};l.ctx.suspend().then(f,f)}},3e4),l}},_autoResume:function(){var l=this;if(!(!l.ctx||typeof l.ctx.resume>"u"||!r.usingWebAudio))return l.state==="running"&&l.ctx.state!=="interrupted"&&l._suspendTimer?(clearTimeout(l._suspendTimer),l._suspendTimer=null):l.state==="suspended"||l.state==="running"&&l.ctx.state==="interrupted"?(l.ctx.resume().then(function(){l.state="running";for(var d=0;d<l._howls.length;d++)l._howls[d]._emit("resume")}),l._suspendTimer&&(clearTimeout(l._suspendTimer),l._suspendTimer=null)):l.state==="suspending"&&(l._resumeAfterSuspend=!0),l}};var r=new n,e=function(l){var d=this;if(!l.src||l.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(l)};e.prototype={init:function(l){var d=this;return r.ctx||u(),d._autoplay=l.autoplay||!1,d._format=typeof l.format!="string"?l.format:[l.format],d._html5=l.html5||!1,d._muted=l.mute||!1,d._loop=l.loop||!1,d._pool=l.pool||5,d._preload=typeof l.preload=="boolean"||l.preload==="metadata"?l.preload:!0,d._rate=l.rate||1,d._sprite=l.sprite||{},d._src=typeof l.src!="string"?l.src:[l.src],d._volume=l.volume!==void 0?l.volume:1,d._xhr={method:l.xhr&&l.xhr.method?l.xhr.method:"GET",headers:l.xhr&&l.xhr.headers?l.xhr.headers:null,withCredentials:l.xhr&&l.xhr.withCredentials?l.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=l.onend?[{fn:l.onend}]:[],d._onfade=l.onfade?[{fn:l.onfade}]:[],d._onload=l.onload?[{fn:l.onload}]:[],d._onloaderror=l.onloaderror?[{fn:l.onloaderror}]:[],d._onplayerror=l.onplayerror?[{fn:l.onplayerror}]:[],d._onpause=l.onpause?[{fn:l.onpause}]:[],d._onplay=l.onplay?[{fn:l.onplay}]:[],d._onstop=l.onstop?[{fn:l.onstop}]:[],d._onmute=l.onmute?[{fn:l.onmute}]:[],d._onvolume=l.onvolume?[{fn:l.onvolume}]:[],d._onrate=l.onrate?[{fn:l.onrate}]:[],d._onseek=l.onseek?[{fn:l.onseek}]:[],d._onunlock=l.onunlock?[{fn:l.onunlock}]:[],d._onresume=[],d._webAudio=r.usingWebAudio&&!d._html5,typeof r.ctx<"u"&&r.ctx&&r.autoUnlock&&r._unlockAudio(),r._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 l=this,d=null;if(r.noAudio){l._emit("loaderror",null,"No audio support.");return}typeof l._src=="string"&&(l._src=[l._src]);for(var p=0;p<l._src.length;p++){var f,m;if(l._format&&l._format[p])f=l._format[p];else{if(m=l._src[p],typeof m!="string"){l._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}f=/^data:audio\/([^;,]+);/i.exec(m),f||(f=/\.([^.]+)$/.exec(m.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&&r.codecs(f)){d=l._src[p];break}}if(!d){l._emit("loaderror",null,"No codec support for selected audio sources.");return}return l._src=d,l._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(l._html5=!0,l._webAudio=!1),new t(l),l._webAudio&&i(l),l},play:function(l,d){var p=this,f=null;if(typeof l=="number")f=l,l=null;else{if(typeof l=="string"&&p._state==="loaded"&&!p._sprite[l])return null;if(typeof l>"u"&&(l="__default",!p._playLock)){for(var m=0,h=0;h<p._sounds.length;h++)p._sounds[h]._paused&&!p._sounds[h]._ended&&(m++,f=p._sounds[h]._id);m===1?l=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!l&&(l=y._sprite||"__default"),p._state!=="loaded"){y._sprite=l,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&&r._autoResume();var x=Math.max(0,y._seek>0?y._seek:p._sprite[l][0]/1e3),S=Math.max(0,(p._sprite[l][0]+p._sprite[l][1])/1e3-x),w=S*1e3/Math.abs(y._rate),b=p._sprite[l][0]/1e3,T=(p._sprite[l][0]+p._sprite[l][1])/1e3;y._sprite=l,y._ended=!1;var _=function(){y._paused=!1,y._seek=x,y._start=b,y._stop=T,y._loop=!!(y._loop||p._sprite[l][2])};if(x>=T){p._ended(y);return}var v=y._node;if(p._webAudio){var N=function(){p._playLock=!1,_(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;v.gain.setValueAtTime(A,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof v.bufferSource.start>"u"?y._loop?v.bufferSource.noteGrainOn(0,x,86400):v.bufferSource.noteGrainOn(0,x,S):y._loop?v.bufferSource.start(0,x,86400):v.bufferSource.start(0,x,S),w!==1/0&&(p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w)),d||setTimeout(function(){p._emit("play",y._id),p._loadQueue()},0)};r.state==="running"&&r.ctx.state!=="interrupted"?N():(p._playLock=!0,p.once("resume",N),p._clearTimer(y._id))}else{var P=function(){v.currentTime=x,v.muted=y._muted||p._muted||r._muted||v.muted,v.volume=y._volume*r.volume(),v.playbackRate=y._rate;try{var A=v.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,_(),A.then(function(){p._playLock=!1,v._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,_(),p._emit("play",y._id)),v.playbackRate=y._rate,v.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}l!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),v.removeEventListener("ended",p._endTimers[y._id],!1)},v.addEventListener("ended",p._endTimers[y._id],!1))}catch(M){p._emit("playerror",y._id,M)}};v.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(v.src=p._src,v.load());var C=window&&window.ejecta||!v.readyState&&r._navigator.isCocoonJS;if(v.readyState>=3||C)P();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",P(),v.removeEventListener(r._canPlayEvent,O,!1)};v.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(l){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(l)}}),d;for(var p=d._getSoundIds(l),f=0;f<p.length;f++){d._clearTimer(p[f]);var m=d._soundById(p[f]);if(m&&!m._paused&&(m._seek=d.seek(p[f]),m._rateSeek=0,m._paused=!0,d._stopFade(p[f]),m._node))if(d._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),d._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||d._emit("pause",m?m._id:null)}return d},stop:function(l,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(l)}}),p;for(var f=p._getSoundIds(l),m=0;m<f.length;m++){p._clearTimer(f[m]);var h=p._soundById(f[m]);h&&(h._seek=h._start||0,h._rateSeek=0,h._paused=!0,h._ended=!0,p._stopFade(f[m]),h._node&&(p._webAudio?h._node.bufferSource&&(typeof h._node.bufferSource.stop>"u"?h._node.bufferSource.noteOff(0):h._node.bufferSource.stop(0),p._cleanBuffer(h._node)):(!isNaN(h._node.duration)||h._node.duration===1/0)&&(h._node.currentTime=h._start||0,h._node.pause(),h._node.duration===1/0&&p._clearSound(h._node))),d||p._emit("stop",h._id))}return p},mute:function(l,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(l,d)}}),p;if(typeof d>"u")if(typeof l=="boolean")p._muted=l;else return p._muted;for(var f=p._getSoundIds(d),m=0;m<f.length;m++){var h=p._soundById(f[m]);h&&(h._muted=l,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(l?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:l),p._emit("mute",h._id))}return p},volume:function(){var l=this,d=arguments,p,f;if(d.length===0)return l._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=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(l._state!=="loaded"||l._playLock)return l._queue.push({event:"volume",action:function(){l.volume.apply(l,d)}}),l;typeof f>"u"&&(l._volume=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)y=l._soundById(f[g]),y&&(y._volume=p,d[2]||l._stopFade(f[g]),l._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),l._emit("volume",y._id))}else return y=f?l._soundById(f):l._sounds[0],y?y._volume:0;return l},fade:function(l,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(l,d,p,f)}}),m;l=Math.min(Math.max(0,parseFloat(l)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(l,f);for(var h=m._getSoundIds(f),y=0;y<h.length;y++){var g=m._soundById(h[y]);if(g){if(f||m._stopFade(h[y]),m._webAudio&&!g._muted){var x=r.ctx.currentTime,S=x+p/1e3;g._volume=l,g._node.gain.setValueAtTime(l,x),g._node.gain.linearRampToValueAtTime(d,S)}m._startFadeInterval(g,l,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(l,d,p,f,m,h){var y=this,g=d,x=p-d,S=Math.abs(x/.01),w=Math.max(4,S>0?f/S:f),b=Date.now();l._fadeTo=p,l._interval=setInterval(function(){var T=(Date.now()-b)/f;b=Date.now(),g+=x*T,g=Math.round(g*100)/100,x<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?l._volume=g:y.volume(g,l._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(l._interval),l._interval=null,l._fadeTo=null,y.volume(p,l._id),y._emit("fade",l._id))},w)},_stopFade:function(l){var d=this,p=d._soundById(l);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,l),p._fadeTo=null,d._emit("fade",l)),d},loop:function(){var l=this,d=arguments,p,f,m;if(d.length===0)return l._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],l._loop=p;else return m=l._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=l._getSoundIds(f),y=0;y<h.length;y++)m=l._soundById(h[y]),m&&(m._loop=p,l._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=p,p&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,l.playing(h[y])&&(l.pause(h[y],!0),l.play(h[y],!0)))));return l},rate:function(){var l=this,d=arguments,p,f;if(d.length===0)f=l._sounds[0]._id;else if(d.length===1){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=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(l._state!=="loaded"||l._playLock)return l._queue.push({event:"rate",action:function(){l.rate.apply(l,d)}}),l;typeof f>"u"&&(l._rate=p),f=l._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=l._soundById(f[g]),y){l.playing(f[g])&&(y._rateSeek=l.seek(f[g]),y._playStart=l._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,l._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var x=l.seek(f[g]),S=(l._sprite[y._sprite][0]+l._sprite[y._sprite][1])/1e3-x,w=S*1e3/Math.abs(y._rate);(l._endTimers[f[g]]||!y._paused)&&(l._clearTimer(f[g]),l._endTimers[f[g]]=setTimeout(l._ended.bind(l,y),w)),l._emit("rate",y._id)}}else return y=l._soundById(f),y?y._rate:l._rate;return l},seek:function(){var l=this,d=arguments,p,f;if(d.length===0)l._sounds.length&&(f=l._sounds[0]._id);else if(d.length===1){var m=l._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):l._sounds.length&&(f=l._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"&&(l._state!=="loaded"||l._playLock))return l._queue.push({event:"seek",action:function(){l.seek.apply(l,d)}}),l;var y=l._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=l.playing(f);g&&l.pause(f,!0),y._seek=p,y._ended=!1,l._clearTimer(f),!l._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var x=function(){g&&l.play(f,!0),l._emit("seek",f)};if(g&&!l._webAudio){var S=function(){l._playLock?setTimeout(S,0):x()};setTimeout(S,0)}else x()}else if(l._webAudio){var w=l.playing(f)?r.ctx.currentTime-y._playStart:0,b=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(b+w*Math.abs(y._rate))}else return y._node.currentTime;return l},playing:function(l){var d=this;if(typeof l=="number"){var p=d._soundById(l);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(l){var d=this,p=d._duration,f=d._soundById(l);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var l=this,d=l._sounds,p=0;p<d.length;p++)d[p]._paused||l.stop(d[p]._id),l._webAudio||(l._clearSound(d[p]._node),d[p]._node.removeEventListener("error",d[p]._errorFn,!1),d[p]._node.removeEventListener(r._canPlayEvent,d[p]._loadFn,!1),d[p]._node.removeEventListener("ended",d[p]._endFn,!1),r._releaseHtml5Audio(d[p]._node)),delete d[p]._node,l._clearTimer(d[p]._id);var f=r._howls.indexOf(l);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===l._src||l._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[l._src],r.noAudio=!1,l._state="unloaded",l._sounds=[],l=null,null},on:function(l,d,p,f){var m=this,h=m["_on"+l];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(l,d,p){var f=this,m=f["_on"+l],h=0;if(typeof d=="number"&&(p=d,d=null),d||p)for(h=0;h<m.length;h++){var y=p===m[h].id;if(d===m[h].fn&&y||!d&&y){m.splice(h,1);break}}else if(l)f["_on"+l]=[];else{var g=Object.keys(f);for(h=0;h<g.length;h++)g[h].indexOf("_on")===0&&Array.isArray(f[g[h]])&&(f[g[h]]=[])}return f},once:function(l,d,p){var f=this;return f.on(l,d,p,1),f},_emit:function(l,d,p){for(var f=this,m=f["_on"+l],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||l==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(l,m[h].fn,m[h].id));return f._loadQueue(l),f},_loadQueue:function(l){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===l&&(d._queue.shift(),d._loadQueue()),l||p.action()}return d},_ended:function(l){var d=this,p=l._sprite;if(!d._webAudio&&l._node&&!l._node.paused&&!l._node.ended&&l._node.currentTime<l._stop)return setTimeout(d._ended.bind(d,l),100),d;var f=!!(l._loop||d._sprite[p][2]);if(d._emit("end",l._id),!d._webAudio&&f&&d.stop(l._id,!0).play(l._id),d._webAudio&&f){d._emit("play",l._id),l._seek=l._start||0,l._rateSeek=0,l._playStart=r.ctx.currentTime;var m=(l._stop-l._start)*1e3/Math.abs(l._rate);d._endTimers[l._id]=setTimeout(d._ended.bind(d,l),m)}return d._webAudio&&!f&&(l._paused=!0,l._ended=!0,l._seek=l._start||0,l._rateSeek=0,d._clearTimer(l._id),d._cleanBuffer(l._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(l._id,!0),d},_clearTimer:function(l){var d=this;if(d._endTimers[l]){if(typeof d._endTimers[l]!="function")clearTimeout(d._endTimers[l]);else{var p=d._soundById(l);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[l],!1)}delete d._endTimers[l]}return d},_soundById:function(l){for(var d=this,p=0;p<d._sounds.length;p++)if(l===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var l=this;l._drain();for(var d=0;d<l._sounds.length;d++)if(l._sounds[d]._ended)return l._sounds[d].reset();return new t(l)},_drain:function(){var l=this,d=l._pool,p=0,f=0;if(!(l._sounds.length<d)){for(f=0;f<l._sounds.length;f++)l._sounds[f]._ended&&p++;for(f=l._sounds.length-1;f>=0;f--){if(p<=d)return;l._sounds[f]._ended&&(l._webAudio&&l._sounds[f]._node&&l._sounds[f]._node.disconnect(0),l._sounds.splice(f,1),p--)}}},_getSoundIds:function(l){var d=this;if(typeof l>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[l]},_refreshBuffer:function(l){var d=this;return l._node.bufferSource=r.ctx.createBufferSource(),l._node.bufferSource.buffer=o[d._src],l._panner?l._node.bufferSource.connect(l._panner):l._node.bufferSource.connect(l._node),l._node.bufferSource.loop=l._loop,l._loop&&(l._node.bufferSource.loopStart=l._start||0,l._node.bufferSource.loopEnd=l._stop||0),l._node.bufferSource.playbackRate.setValueAtTime(l._rate,r.ctx.currentTime),d},_cleanBuffer:function(l){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&l.bufferSource&&(l.bufferSource.onended=null,l.bufferSource.disconnect(0),p))try{l.bufferSource.buffer=r._scratchBuffer}catch{}return l.bufferSource=null,d},_clearSound:function(l){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(l.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(l){this._parent=l,this.init()};t.prototype={init:function(){var l=this,d=l._parent;return l._muted=d._muted,l._loop=d._loop,l._volume=d._volume,l._rate=d._rate,l._seek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,d._sounds.push(l),l.create(),l},create:function(){var l=this,d=l._parent,p=r._muted||l._muted||l._parent._muted?0:l._volume;return d._webAudio?(l._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),l._node.gain.setValueAtTime(p,r.ctx.currentTime),l._node.paused=!0,l._node.connect(r.masterGain)):r.noAudio||(l._node=r._obtainHtml5Audio(),l._errorFn=l._errorListener.bind(l),l._node.addEventListener("error",l._errorFn,!1),l._loadFn=l._loadListener.bind(l),l._node.addEventListener(r._canPlayEvent,l._loadFn,!1),l._endFn=l._endListener.bind(l),l._node.addEventListener("ended",l._endFn,!1),l._node.src=d._src,l._node.preload=d._preload===!0?"auto":d._preload,l._node.volume=p*r.volume(),l._node.load()),l},reset:function(){var l=this,d=l._parent;return l._muted=d._muted,l._loop=d._loop,l._volume=d._volume,l._rate=d._rate,l._seek=0,l._rateSeek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,l},_errorListener:function(){var l=this;l._parent._emit("loaderror",l._id,l._node.error?l._node.error.code:0),l._node.removeEventListener("error",l._errorFn,!1)},_loadListener:function(){var l=this,d=l._parent;d._duration=Math.ceil(l._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()),l._node.removeEventListener(r._canPlayEvent,l._loadFn,!1)},_endListener:function(){var l=this,d=l._parent;d._duration===1/0&&(d._duration=Math.ceil(l._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(l)),l._node.removeEventListener("ended",l._endFn,!1)}};var o={},i=function(l){var d=l._src;if(o[d]){l._duration=o[d].duration,c(l);return}if(/^data:[^;]+;base64,/.test(d)){for(var p=atob(d.split(",")[1]),f=new Uint8Array(p.length),m=0;m<p.length;++m)f[m]=p.charCodeAt(m);s(f.buffer,l)}else{var h=new XMLHttpRequest;h.open(l._xhr.method,d,!0),h.withCredentials=l._xhr.withCredentials,h.responseType="arraybuffer",l._xhr.headers&&Object.keys(l._xhr.headers).forEach(function(y){h.setRequestHeader(y,l._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){l._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}s(h.response,l)},h.onerror=function(){l._webAudio&&(l._html5=!0,l._webAudio=!1,l._sounds=[],delete o[d],l.load())},a(h)}},a=function(l){try{l.send()}catch{l.onerror()}},s=function(l,d){var p=function(){d._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&d._sounds.length>0?(o[d._src]=m,c(d,m)):p()};typeof Promise<"u"&&r.ctx.decodeAudioData.length===1?r.ctx.decodeAudioData(l).then(f).catch(p):r.ctx.decodeAudioData(l,f,p)},c=function(l,d){d&&!l._duration&&(l._duration=d.duration),Object.keys(l._sprite).length===0&&(l._sprite={__default:[0,l._duration*1e3]}),l._state!=="loaded"&&(l._state="loaded",l._emit("load"),l._loadQueue())},u=function(){if(!!r.usingWebAudio){try{typeof AudioContext<"u"?r.ctx=new AudioContext:typeof webkitAudioContext<"u"?r.ctx=new webkitAudioContext:r.usingWebAudio=!1}catch{r.usingWebAudio=!1}r.ctx||(r.usingWebAudio=!1);var l=/iP(hone|od|ad)/.test(r._navigator&&r._navigator.platform),d=r._navigator&&r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=d?parseInt(d[1],10):null;if(l&&p&&p<9){var f=/safari/.test(r._navigator&&r._navigator.userAgent.toLowerCase());r._navigator&&!f&&(r.usingWebAudio=!1)}r.usingWebAudio&&(r.masterGain=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),r.masterGain.gain.setValueAtTime(r._muted?0:r._volume,r.ctx.currentTime),r.masterGain.connect(r.ctx.destination)),r._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:r,Howl:e}}),typeof pc<"u"&&(pc.Howler=r,pc.Howl=e),typeof global<"u"?(global.HowlerGlobal=n,global.Howler=r,global.Howl=e,global.Sound=t):typeof window<"u"&&(window.HowlerGlobal=n,window.Howler=r,window.Howl=e,window.Sound=t)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(r){var e=this;if(!e.ctx||!e.ctx.listener)return e;for(var t=e._howls.length-1;t>=0;t--)e._howls[t].stereo(r);return e},HowlerGlobal.prototype.pos=function(r,e,t){var o=this;if(!o.ctx||!o.ctx.listener)return o;if(e=typeof e!="number"?o._pos[1]:e,t=typeof t!="number"?o._pos[2]:t,typeof r=="number")o._pos=[r,e,t],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(r,e,t,o,i,a){var s=this;if(!s.ctx||!s.ctx.listener)return s;var c=s._orientation;if(e=typeof e!="number"?c[1]:e,t=typeof t!="number"?c[2]:t,o=typeof o!="number"?c[3]:o,i=typeof i!="number"?c[4]:i,a=typeof a!="number"?c[5]:a,typeof r=="number")s._orientation=[r,e,t,o,i,a],typeof s.ctx.listener.forwardX<"u"?(s.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(t,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(r,e,t,o,i,a);else return c;return s},Howl.prototype.init=function(r){return function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._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},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],r.call(this,e)}}(Howl.prototype.init),Howl.prototype.stereo=function(r,e){var t=this;if(!t._webAudio)return t;if(t._state!=="loaded")return t._queue.push({event:"stereo",action:function(){t.stereo(r,e)}}),t;var o=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof e>"u")if(typeof r=="number")t._stereo=r,t._pos=[r,0,0];else return t._stereo;for(var i=t._getSoundIds(e),a=0;a<i.length;a++){var s=t._soundById(i[a]);if(s)if(typeof r=="number")s._stereo=r,s._pos=[r,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(r,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(r,0,0):s._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",s._id);else return s._stereo}return t},Howl.prototype.pos=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"pos",action:function(){i.pos(r,e,t,o)}}),i;if(e=typeof e!="number"?0:e,t=typeof t!="number"?-.5:t,typeof o>"u")if(typeof r=="number")i._pos=[r,e,t];else return i._pos;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var c=i._soundById(a[s]);if(c)if(typeof r=="number")c._pos=[r,e,t],c._node&&((!c._panner||c._panner.pan)&&n(c,"spatial"),typeof c._panner.positionX<"u"?(c._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.positionY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.positionZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setPosition(r,e,t)),i._emit("pos",c._id);else return c._pos}return i},Howl.prototype.orientation=function(r,e,t,o){var i=this;if(!i._webAudio)return i;if(i._state!=="loaded")return i._queue.push({event:"orientation",action:function(){i.orientation(r,e,t,o)}}),i;if(e=typeof e!="number"?i._orientation[1]:e,t=typeof t!="number"?i._orientation[2]:t,typeof o>"u")if(typeof r=="number")i._orientation=[r,e,t];else return i._orientation;for(var a=i._getSoundIds(o),s=0;s<a.length;s++){var c=i._soundById(a[s]);if(c)if(typeof r=="number")c._orientation=[r,e,t],c._node&&(c._panner||(c._pos||(c._pos=i._pos||[0,0,-.5]),n(c,"spatial")),typeof c._panner.orientationX<"u"?(c._panner.orientationX.setValueAtTime(r,Howler.ctx.currentTime),c._panner.orientationY.setValueAtTime(e,Howler.ctx.currentTime),c._panner.orientationZ.setValueAtTime(t,Howler.ctx.currentTime)):c._panner.setOrientation(r,e,t)),i._emit("orientation",c._id);else return c._orientation}return i},Howl.prototype.pannerAttr=function(){var r=this,e=arguments,t,o,i;if(!r._webAudio)return r;if(e.length===0)return r._pannerAttr;if(e.length===1)if(typeof e[0]=="object")t=e[0],typeof o>"u"&&(t.pannerAttr||(t.pannerAttr={coneInnerAngle:t.coneInnerAngle,coneOuterAngle:t.coneOuterAngle,coneOuterGain:t.coneOuterGain,distanceModel:t.distanceModel,maxDistance:t.maxDistance,refDistance:t.refDistance,rolloffFactor:t.rolloffFactor,panningModel:t.panningModel}),r._pannerAttr={coneInnerAngle:typeof t.pannerAttr.coneInnerAngle<"u"?t.pannerAttr.coneInnerAngle:r._coneInnerAngle,coneOuterAngle:typeof t.pannerAttr.coneOuterAngle<"u"?t.pannerAttr.coneOuterAngle:r._coneOuterAngle,coneOuterGain:typeof t.pannerAttr.coneOuterGain<"u"?t.pannerAttr.coneOuterGain:r._coneOuterGain,distanceModel:typeof t.pannerAttr.distanceModel<"u"?t.pannerAttr.distanceModel:r._distanceModel,maxDistance:typeof t.pannerAttr.maxDistance<"u"?t.pannerAttr.maxDistance:r._maxDistance,refDistance:typeof t.pannerAttr.refDistance<"u"?t.pannerAttr.refDistance:r._refDistance,rolloffFactor:typeof t.pannerAttr.rolloffFactor<"u"?t.pannerAttr.rolloffFactor:r._rolloffFactor,panningModel:typeof t.pannerAttr.panningModel<"u"?t.pannerAttr.panningModel:r._panningModel});else return i=r._soundById(parseInt(e[0],10)),i?i._pannerAttr:r._pannerAttr;else e.length===2&&(t=e[0],o=parseInt(e[1],10));for(var a=r._getSoundIds(o),s=0;s<a.length;s++)if(i=r._soundById(a[s]),i){var c=i._pannerAttr;c={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:c.coneInnerAngle,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:c.coneOuterAngle,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:c.coneOuterGain,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:c.distanceModel,maxDistance:typeof t.maxDistance<"u"?t.maxDistance:c.maxDistance,refDistance:typeof t.refDistance<"u"?t.refDistance:c.refDistance,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:c.rolloffFactor,panningModel:typeof t.panningModel<"u"?t.panningModel:c.panningModel};var u=i._panner;u?(u.coneInnerAngle=c.coneInnerAngle,u.coneOuterAngle=c.coneOuterAngle,u.coneOuterGain=c.coneOuterGain,u.distanceModel=c.distanceModel,u.maxDistance=c.maxDistance,u.refDistance=c.refDistance,u.rolloffFactor=c.rolloffFactor,u.panningModel=c.panningModel):(i._pos||(i._pos=r._pos||[0,0,-.5]),n(i,"spatial"))}return r},Sound.prototype.init=function(r){return function(){var e=this,t=e._parent;e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,r.call(this),e._stereo?t.stereo(e._stereo):e._pos&&t.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}}(Sound.prototype.init),Sound.prototype.reset=function(r){return function(){var e=this,t=e._parent;return e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,e._stereo?t.stereo(e._stereo):e._pos?t.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,t._refreshBuffer(e)),r.call(this)}}(Sound.prototype.reset);var n=function(r,e){e=e||"spatial",e==="spatial"?(r._panner=Howler.ctx.createPanner(),r._panner.coneInnerAngle=r._pannerAttr.coneInnerAngle,r._panner.coneOuterAngle=r._pannerAttr.coneOuterAngle,r._panner.coneOuterGain=r._pannerAttr.coneOuterGain,r._panner.distanceModel=r._pannerAttr.distanceModel,r._panner.maxDistance=r._pannerAttr.maxDistance,r._panner.refDistance=r._pannerAttr.refDistance,r._panner.rolloffFactor=r._pannerAttr.rolloffFactor,r._panner.panningModel=r._pannerAttr.panningModel,typeof r._panner.positionX<"u"?(r._panner.positionX.setValueAtTime(r._pos[0],Howler.ctx.currentTime),r._panner.positionY.setValueAtTime(r._pos[1],Howler.ctx.currentTime),r._panner.positionZ.setValueAtTime(r._pos[2],Howler.ctx.currentTime)):r._panner.setPosition(r._pos[0],r._pos[1],r._pos[2]),typeof r._panner.orientationX<"u"?(r._panner.orientationX.setValueAtTime(r._orientation[0],Howler.ctx.currentTime),r._panner.orientationY.setValueAtTime(r._orientation[1],Howler.ctx.currentTime),r._panner.orientationZ.setValueAtTime(r._orientation[2],Howler.ctx.currentTime)):r._panner.setOrientation(r._orientation[0],r._orientation[1],r._orientation[2])):(r._panner=Howler.ctx.createStereoPanner(),r._panner.pan.setValueAtTime(r._stereo,Howler.ctx.currentTime)),r._panner.connect(r._node),r._paused||r._parent.pause(r._id,!0).play(r._id,!0)}})()});var sx=Pn((cre,ax)=>{ax.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}});import{FileLoader as ZN,Loader as QN}from"three";function cp(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Dt(n,r){return Object.setPrototypeOf(n,r),n}function xs(n){return Array.isArray(n)?n:[n]}function dp(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 Px=typeof global=="object"&&global&&global.Object===Object&&global,vs=Px;var Ox=typeof self=="object"&&self&&self.Object===Object&&self,Ax=vs||Ox||Function("return this")(),Qe=Ax;var Cx=Qe.Symbol,st=Cx;var up=Object.prototype,Nx=up.hasOwnProperty,Ix=up.toString,xa=st?st.toStringTag:void 0;function Mx(n){var r=Nx.call(n,xa),e=n[xa];try{n[xa]=void 0;var t=!0}catch{}var o=Ix.call(n);return t&&(r?n[xa]=e:delete n[xa]),o}var pp=Mx;var Ex=Object.prototype,Lx=Ex.toString;function Dx(n){return Lx.call(n)}var fp=Dx;var Bx="[object Null]",Rx="[object Undefined]",mp=st?st.toStringTag:void 0;function Gx(n){return n==null?n===void 0?Rx:Bx:mp&&mp in Object(n)?pp(n):fp(n)}var Ut=Gx;function Vx(n){return n!=null&&typeof n=="object"}var yt=Vx;var zx="[object Symbol]";function jx(n){return typeof n=="symbol"||yt(n)&&Ut(n)==zx}var On=jx;function Fx(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 bs=Fx;var kx=Array.isArray,He=kx;var Ux=1/0,hp=st?st.prototype:void 0,yp=hp?hp.toString:void 0;function gp(n){if(typeof n=="string")return n;if(He(n))return bs(n,gp)+"";if(On(n))return yp?yp.call(n):"";var r=n+"";return r=="0"&&1/n==-Ux?"-0":r}var xp=gp;function Hx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Ht=Hx;function Wx(n){return n}var vp=Wx;var qx="[object AsyncFunction]",$x="[object Function]",Yx="[object GeneratorFunction]",Xx="[object Proxy]";function Kx(n){if(!Ht(n))return!1;var r=Ut(n);return r==$x||r==Yx||r==qx||r==Xx}var Ss=Kx;var Zx=Qe["__core-js_shared__"],ws=Zx;var bp=function(){var n=/[^.]+$/.exec(ws&&ws.keys&&ws.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Qx(n){return!!bp&&bp in n}var Sp=Qx;var Jx=Function.prototype,ev=Jx.toString;function tv(n){if(n!=null){try{return ev.call(n)}catch{}try{return n+""}catch{}}return""}var Yr=tv;var rv=/[\\^$.*+?()[\]{}|]/g,ov=/^\[object .+?Constructor\]$/,nv=Function.prototype,iv=Object.prototype,av=nv.toString,sv=iv.hasOwnProperty,lv=RegExp("^"+av.call(sv).replace(rv,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cv(n){if(!Ht(n)||Sp(n))return!1;var r=Ss(n)?lv:ov;return r.test(Yr(n))}var wp=cv;function dv(n,r){return n?.[r]}var Tp=dv;function uv(n,r){var e=Tp(n,r);return wp(e)?e:void 0}var Bt=uv;var pv=Bt(Qe,"WeakMap"),Ts=pv;var _p=Object.create,fv=function(){function n(){}return function(r){if(!Ht(r))return{};if(_p)return _p(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Pp=fv;function mv(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 Op=mv;function hv(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Ap=hv;var yv=800,gv=16,xv=Date.now;function vv(n){var r=0,e=0;return function(){var t=xv(),o=gv-(t-e);if(e=t,o>0){if(++r>=yv)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Cp=vv;function bv(n){return function(){return n}}var Np=bv;var Sv=function(){try{var n=Bt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),An=Sv;var wv=An?function(n,r){return An(n,"toString",{configurable:!0,enumerable:!1,value:Np(r),writable:!0})}:vp,Ip=wv;var Tv=Cp(Ip),Mp=Tv;function _v(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var Ep=_v;var Pv=9007199254740991,Ov=/^(?:0|[1-9]\d*)$/;function Av(n,r){var e=typeof n;return r=r??Pv,!!r&&(e=="number"||e!="symbol"&&Ov.test(n))&&n>-1&&n%1==0&&n<r}var Cn=Av;function Cv(n,r,e){r=="__proto__"&&An?An(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var _s=Cv;function Nv(n,r){return n===r||n!==n&&r!==r}var Nn=Nv;var Iv=Object.prototype,Mv=Iv.hasOwnProperty;function Ev(n,r,e){var t=n[r];(!(Mv.call(n,r)&&Nn(t,e))||e===void 0&&!(r in n))&&_s(n,r,e)}var In=Ev;function Lv(n,r,e,t){var o=!e;e||(e={});for(var i=-1,a=r.length;++i<a;){var s=r[i],c=t?t(e[s],n[s],s,e,n):void 0;c===void 0&&(c=n[s]),o?_s(e,s,c):In(e,s,c)}return e}var Sr=Lv;var Lp=Math.max;function Dv(n,r,e){return r=Lp(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Lp(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),Op(n,this,s)}}var Dp=Dv;var Bv=9007199254740991;function Rv(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Bv}var Mn=Rv;function Gv(n){return n!=null&&Mn(n.length)&&!Ss(n)}var Ps=Gv;var Vv=Object.prototype;function zv(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||Vv;return n===e}var En=zv;function jv(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Bp=jv;var Fv="[object Arguments]";function kv(n){return yt(n)&&Ut(n)==Fv}var Bc=kv;var Rp=Object.prototype,Uv=Rp.hasOwnProperty,Hv=Rp.propertyIsEnumerable,Wv=Bc(function(){return arguments}())?Bc:function(n){return yt(n)&&Uv.call(n,"callee")&&!Hv.call(n,"callee")},Ln=Wv;function qv(){return!1}var Gp=qv;var jp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vp=jp&&typeof module=="object"&&module&&!module.nodeType&&module,$v=Vp&&Vp.exports===jp,zp=$v?Qe.Buffer:void 0,Yv=zp?zp.isBuffer:void 0,Xv=Yv||Gp,qo=Xv;var Kv="[object Arguments]",Zv="[object Array]",Qv="[object Boolean]",Jv="[object Date]",eb="[object Error]",tb="[object Function]",rb="[object Map]",ob="[object Number]",nb="[object Object]",ib="[object RegExp]",ab="[object Set]",sb="[object String]",lb="[object WeakMap]",cb="[object ArrayBuffer]",db="[object DataView]",ub="[object Float32Array]",pb="[object Float64Array]",fb="[object Int8Array]",mb="[object Int16Array]",hb="[object Int32Array]",yb="[object Uint8Array]",gb="[object Uint8ClampedArray]",xb="[object Uint16Array]",vb="[object Uint32Array]",ze={};ze[ub]=ze[pb]=ze[fb]=ze[mb]=ze[hb]=ze[yb]=ze[gb]=ze[xb]=ze[vb]=!0;ze[Kv]=ze[Zv]=ze[cb]=ze[Qv]=ze[db]=ze[Jv]=ze[eb]=ze[tb]=ze[rb]=ze[ob]=ze[nb]=ze[ib]=ze[ab]=ze[sb]=ze[lb]=!1;function bb(n){return yt(n)&&Mn(n.length)&&!!ze[Ut(n)]}var Fp=bb;function Sb(n){return function(r){return n(r)}}var Dn=Sb;var kp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,va=kp&&typeof module=="object"&&module&&!module.nodeType&&module,wb=va&&va.exports===kp,Rc=wb&&vs.process,Tb=function(){try{var n=va&&va.require&&va.require("util").types;return n||Rc&&Rc.binding&&Rc.binding("util")}catch{}}(),Xr=Tb;var Up=Xr&&Xr.isTypedArray,_b=Up?Dn(Up):Fp,Os=_b;var Pb=Object.prototype,Ob=Pb.hasOwnProperty;function Ab(n,r){var e=He(n),t=!e&&Ln(n),o=!e&&!t&&qo(n),i=!e&&!t&&!o&&Os(n),a=e||t||o||i,s=a?Bp(n.length,String):[],c=s.length;for(var u in n)(r||Ob.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Cn(u,c)))&&s.push(u);return s}var As=Ab;function Cb(n,r){return function(e){return n(r(e))}}var Cs=Cb;var Nb=Cs(Object.keys,Object),Hp=Nb;var Ib=Object.prototype,Mb=Ib.hasOwnProperty;function Eb(n){if(!En(n))return Hp(n);var r=[];for(var e in Object(n))Mb.call(n,e)&&e!="constructor"&&r.push(e);return r}var Wp=Eb;function Lb(n){return Ps(n)?As(n):Wp(n)}var Bn=Lb;function Db(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var qp=Db;var Bb=Object.prototype,Rb=Bb.hasOwnProperty;function Gb(n){if(!Ht(n))return qp(n);var r=En(n),e=[];for(var t in n)t=="constructor"&&(r||!Rb.call(n,t))||e.push(t);return e}var $p=Gb;function Vb(n){return Ps(n)?As(n,!0):$p(n)}var Rn=Vb;var zb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jb=/^\w*$/;function Fb(n,r){if(He(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||On(n)?!0:jb.test(n)||!zb.test(n)||r!=null&&n in Object(r)}var Yp=Fb;var kb=Bt(Object,"create"),Kr=kb;function Ub(){this.__data__=Kr?Kr(null):{},this.size=0}var Xp=Ub;function Hb(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Kp=Hb;var Wb="__lodash_hash_undefined__",qb=Object.prototype,$b=qb.hasOwnProperty;function Yb(n){var r=this.__data__;if(Kr){var e=r[n];return e===Wb?void 0:e}return $b.call(r,n)?r[n]:void 0}var Zp=Yb;var Xb=Object.prototype,Kb=Xb.hasOwnProperty;function Zb(n){var r=this.__data__;return Kr?r[n]!==void 0:Kb.call(r,n)}var Qp=Zb;var Qb="__lodash_hash_undefined__";function Jb(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Kr&&r===void 0?Qb:r,this}var Jp=Jb;function Gn(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])}}Gn.prototype.clear=Xp;Gn.prototype.delete=Kp;Gn.prototype.get=Zp;Gn.prototype.has=Qp;Gn.prototype.set=Jp;var Gc=Gn;function eS(){this.__data__=[],this.size=0}var ef=eS;function tS(n,r){for(var e=n.length;e--;)if(Nn(n[e][0],r))return e;return-1}var mo=tS;var rS=Array.prototype,oS=rS.splice;function nS(n){var r=this.__data__,e=mo(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():oS.call(r,e,1),--this.size,!0}var tf=nS;function iS(n){var r=this.__data__,e=mo(r,n);return e<0?void 0:r[e][1]}var rf=iS;function aS(n){return mo(this.__data__,n)>-1}var of=aS;function sS(n,r){var e=this.__data__,t=mo(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var nf=sS;function Vn(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])}}Vn.prototype.clear=ef;Vn.prototype.delete=tf;Vn.prototype.get=rf;Vn.prototype.has=of;Vn.prototype.set=nf;var ho=Vn;var lS=Bt(Qe,"Map"),yo=lS;function cS(){this.size=0,this.__data__={hash:new Gc,map:new(yo||ho),string:new Gc}}var af=cS;function dS(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var sf=dS;function uS(n,r){var e=n.__data__;return sf(r)?e[typeof r=="string"?"string":"hash"]:e.map}var go=uS;function pS(n){var r=go(this,n).delete(n);return this.size-=r?1:0,r}var lf=pS;function fS(n){return go(this,n).get(n)}var cf=fS;function mS(n){return go(this,n).has(n)}var df=mS;function hS(n,r){var e=go(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var uf=hS;function zn(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])}}zn.prototype.clear=af;zn.prototype.delete=lf;zn.prototype.get=cf;zn.prototype.has=df;zn.prototype.set=uf;var $o=zn;var yS="Expected a function";function Vc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(yS);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(Vc.Cache||$o),e}Vc.Cache=$o;var pf=Vc;var gS=500;function xS(n){var r=pf(n,function(t){return e.size===gS&&e.clear(),t}),e=r.cache;return r}var ff=xS;var vS=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bS=/\\(\\)?/g,SS=ff(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(vS,function(e,t,o,i){r.push(o?i.replace(bS,"$1"):t||e)}),r}),mf=SS;function wS(n){return n==null?"":xp(n)}var hf=wS;function TS(n,r){return He(n)?n:Yp(n,r)?[n]:mf(hf(n))}var Kt=TS;var _S=1/0;function PS(n){if(typeof n=="string"||On(n))return n;var r=n+"";return r=="0"&&1/n==-_S?"-0":r}var xo=PS;function OS(n,r){r=Kt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[xo(r[e++])];return e&&e==t?n:void 0}var Ns=OS;function AS(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var jn=AS;var yf=st?st.isConcatSpreadable:void 0;function CS(n){return He(n)||Ln(n)||!!(yf&&n&&n[yf])}var gf=CS;function xf(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=gf),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?xf(s,r-1,e,t,o):jn(o,s):t||(o[o.length]=s)}return o}var vf=xf;function NS(n){var r=n==null?0:n.length;return r?vf(n,1):[]}var bf=NS;function IS(n){return Mp(Dp(n,void 0,bf),n+"")}var Is=IS;var MS=Cs(Object.getPrototypeOf,Object),Fn=MS;var ES="[object Object]",LS=Function.prototype,DS=Object.prototype,Sf=LS.toString,BS=DS.hasOwnProperty,RS=Sf.call(Object);function GS(n){if(!yt(n)||Ut(n)!=ES)return!1;var r=Fn(n);if(r===null)return!0;var e=BS.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Sf.call(e)==RS}var wf=GS;function VS(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 Tf=VS;function zS(){this.__data__=new ho,this.size=0}var _f=zS;function jS(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Pf=jS;function FS(n){return this.__data__.get(n)}var Of=FS;function kS(n){return this.__data__.has(n)}var Af=kS;var US=200;function HS(n,r){var e=this.__data__;if(e instanceof ho){var t=e.__data__;if(!yo||t.length<US-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new $o(t)}return e.set(n,r),this.size=e.size,this}var Cf=HS;function kn(n){var r=this.__data__=new ho(n);this.size=r.size}kn.prototype.clear=_f;kn.prototype.delete=Pf;kn.prototype.get=Of;kn.prototype.has=Af;kn.prototype.set=Cf;var Un=kn;function WS(n,r){return n&&Sr(r,Bn(r),n)}var Nf=WS;function qS(n,r){return n&&Sr(r,Rn(r),n)}var If=qS;var Df=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mf=Df&&typeof module=="object"&&module&&!module.nodeType&&module,$S=Mf&&Mf.exports===Df,Ef=$S?Qe.Buffer:void 0,Lf=Ef?Ef.allocUnsafe:void 0;function YS(n,r){if(r)return n.slice();var e=n.length,t=Lf?Lf(e):new n.constructor(e);return n.copy(t),t}var Bf=YS;function XS(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 Rf=XS;function KS(){return[]}var Ms=KS;var ZS=Object.prototype,QS=ZS.propertyIsEnumerable,Gf=Object.getOwnPropertySymbols,JS=Gf?function(n){return n==null?[]:(n=Object(n),Rf(Gf(n),function(r){return QS.call(n,r)}))}:Ms,Hn=JS;function ew(n,r){return Sr(n,Hn(n),r)}var Vf=ew;var tw=Object.getOwnPropertySymbols,rw=tw?function(n){for(var r=[];n;)jn(r,Hn(n)),n=Fn(n);return r}:Ms,Es=rw;function ow(n,r){return Sr(n,Es(n),r)}var zf=ow;function nw(n,r,e){var t=r(n);return He(n)?t:jn(t,e(n))}var Ls=nw;function iw(n){return Ls(n,Bn,Hn)}var ba=iw;function aw(n){return Ls(n,Rn,Es)}var Ds=aw;var sw=Bt(Qe,"DataView"),Bs=sw;var lw=Bt(Qe,"Promise"),Rs=lw;var cw=Bt(Qe,"Set"),Gs=cw;var jf="[object Map]",dw="[object Object]",Ff="[object Promise]",kf="[object Set]",Uf="[object WeakMap]",Hf="[object DataView]",uw=Yr(Bs),pw=Yr(yo),fw=Yr(Rs),mw=Yr(Gs),hw=Yr(Ts),Yo=Ut;(Bs&&Yo(new Bs(new ArrayBuffer(1)))!=Hf||yo&&Yo(new yo)!=jf||Rs&&Yo(Rs.resolve())!=Ff||Gs&&Yo(new Gs)!=kf||Ts&&Yo(new Ts)!=Uf)&&(Yo=function(n){var r=Ut(n),e=r==dw?n.constructor:void 0,t=e?Yr(e):"";if(t)switch(t){case uw:return Hf;case pw:return jf;case fw:return Ff;case mw:return kf;case hw:return Uf}return r});var Zr=Yo;var yw=Object.prototype,gw=yw.hasOwnProperty;function xw(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&gw.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Wf=xw;var vw=Qe.Uint8Array,Wn=vw;function bw(n){var r=new n.constructor(n.byteLength);return new Wn(r).set(new Wn(n)),r}var qn=bw;function Sw(n,r){var e=r?qn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var qf=Sw;var ww=/\w*$/;function Tw(n){var r=new n.constructor(n.source,ww.exec(n));return r.lastIndex=n.lastIndex,r}var $f=Tw;var Yf=st?st.prototype:void 0,Xf=Yf?Yf.valueOf:void 0;function _w(n){return Xf?Object(Xf.call(n)):{}}var Kf=_w;function Pw(n,r){var e=r?qn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Zf=Pw;var Ow="[object Boolean]",Aw="[object Date]",Cw="[object Map]",Nw="[object Number]",Iw="[object RegExp]",Mw="[object Set]",Ew="[object String]",Lw="[object Symbol]",Dw="[object ArrayBuffer]",Bw="[object DataView]",Rw="[object Float32Array]",Gw="[object Float64Array]",Vw="[object Int8Array]",zw="[object Int16Array]",jw="[object Int32Array]",Fw="[object Uint8Array]",kw="[object Uint8ClampedArray]",Uw="[object Uint16Array]",Hw="[object Uint32Array]";function Ww(n,r,e){var t=n.constructor;switch(r){case Dw:return qn(n);case Ow:case Aw:return new t(+n);case Bw:return qf(n,e);case Rw:case Gw:case Vw:case zw:case jw:case Fw:case kw:case Uw:case Hw:return Zf(n,e);case Cw:return new t;case Nw:case Ew:return new t(n);case Iw:return $f(n);case Mw:return new t;case Lw:return Kf(n)}}var Qf=Ww;function qw(n){return typeof n.constructor=="function"&&!En(n)?Pp(Fn(n)):{}}var Jf=qw;var $w="[object Map]";function Yw(n){return yt(n)&&Zr(n)==$w}var em=Yw;var tm=Xr&&Xr.isMap,Xw=tm?Dn(tm):em,rm=Xw;var Kw="[object Set]";function Zw(n){return yt(n)&&Zr(n)==Kw}var om=Zw;var nm=Xr&&Xr.isSet,Qw=nm?Dn(nm):om,im=Qw;var Jw=1,e1=2,t1=4,am="[object Arguments]",r1="[object Array]",o1="[object Boolean]",n1="[object Date]",i1="[object Error]",sm="[object Function]",a1="[object GeneratorFunction]",s1="[object Map]",l1="[object Number]",lm="[object Object]",c1="[object RegExp]",d1="[object Set]",u1="[object String]",p1="[object Symbol]",f1="[object WeakMap]",m1="[object ArrayBuffer]",h1="[object DataView]",y1="[object Float32Array]",g1="[object Float64Array]",x1="[object Int8Array]",v1="[object Int16Array]",b1="[object Int32Array]",S1="[object Uint8Array]",w1="[object Uint8ClampedArray]",T1="[object Uint16Array]",_1="[object Uint32Array]",Ge={};Ge[am]=Ge[r1]=Ge[m1]=Ge[h1]=Ge[o1]=Ge[n1]=Ge[y1]=Ge[g1]=Ge[x1]=Ge[v1]=Ge[b1]=Ge[s1]=Ge[l1]=Ge[lm]=Ge[c1]=Ge[d1]=Ge[u1]=Ge[p1]=Ge[S1]=Ge[w1]=Ge[T1]=Ge[_1]=!0;Ge[i1]=Ge[sm]=Ge[f1]=!1;function Vs(n,r,e,t,o,i){var a,s=r&Jw,c=r&e1,u=r&t1;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!Ht(n))return n;var l=He(n);if(l){if(a=Wf(n),!s)return Ap(n,a)}else{var d=Zr(n),p=d==sm||d==a1;if(qo(n))return Bf(n,s);if(d==lm||d==am||p&&!o){if(a=c||p?{}:Jf(n),!s)return c?zf(n,If(a,n)):Vf(n,Nf(a,n))}else{if(!Ge[d])return o?n:{};a=Qf(n,d,s)}}i||(i=new Un);var f=i.get(n);if(f)return f;i.set(n,a),im(n)?n.forEach(function(y){a.add(Vs(y,r,e,y,n,i))}):rm(n)&&n.forEach(function(y,g){a.set(g,Vs(y,r,e,g,n,i))});var m=u?c?Ds:ba:c?Rn:Bn,h=l?void 0:m(n);return Ep(h||n,function(y,g){h&&(g=y,y=n[g]),In(a,g,Vs(y,r,e,g,n,i))}),a}var zs=Vs;var P1=1,O1=4;function A1(n){return zs(n,P1|O1)}var Qr=A1;var C1="__lodash_hash_undefined__";function N1(n){return this.__data__.set(n,C1),this}var cm=N1;function I1(n){return this.__data__.has(n)}var dm=I1;function js(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new $o;++r<e;)this.add(n[r])}js.prototype.add=js.prototype.push=cm;js.prototype.has=dm;var um=js;function M1(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 pm=M1;function E1(n,r){return n.has(r)}var fm=E1;var L1=1,D1=2;function B1(n,r,e,t,o,i){var a=e&L1,s=n.length,c=r.length;if(s!=c&&!(a&&c>s))return!1;var u=i.get(n),l=i.get(r);if(u&&l)return u==r&&l==n;var d=-1,p=!0,f=e&D1?new um:void 0;for(i.set(n,r),i.set(r,n);++d<s;){var m=n[d],h=r[d];if(t)var y=a?t(h,m,d,r,n,i):t(m,h,d,n,r,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!pm(r,function(g,x){if(!fm(f,x)&&(m===g||o(m,g,e,t,i)))return f.push(x)})){p=!1;break}}else if(!(m===h||o(m,h,e,t,i))){p=!1;break}}return i.delete(n),i.delete(r),p}var Fs=B1;function R1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var mm=R1;function G1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var hm=G1;var V1=1,z1=2,j1="[object Boolean]",F1="[object Date]",k1="[object Error]",U1="[object Map]",H1="[object Number]",W1="[object RegExp]",q1="[object Set]",$1="[object String]",Y1="[object Symbol]",X1="[object ArrayBuffer]",K1="[object DataView]",ym=st?st.prototype:void 0,zc=ym?ym.valueOf:void 0;function Z1(n,r,e,t,o,i,a){switch(e){case K1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case X1:return!(n.byteLength!=r.byteLength||!i(new Wn(n),new Wn(r)));case j1:case F1:case H1:return Nn(+n,+r);case k1:return n.name==r.name&&n.message==r.message;case W1:case $1:return n==r+"";case U1:var s=mm;case q1:var c=t&V1;if(s||(s=hm),n.size!=r.size&&!c)return!1;var u=a.get(n);if(u)return u==r;t|=z1,a.set(n,r);var l=Fs(s(n),s(r),t,o,i,a);return a.delete(n),l;case Y1:if(zc)return zc.call(n)==zc.call(r)}return!1}var gm=Z1;var Q1=1,J1=Object.prototype,eT=J1.hasOwnProperty;function tT(n,r,e,t,o,i){var a=e&Q1,s=ba(n),c=s.length,u=ba(r),l=u.length;if(c!=l&&!a)return!1;for(var d=c;d--;){var p=s[d];if(!(a?p in r:eT.call(r,p)))return!1}var f=i.get(n),m=i.get(r);if(f&&m)return f==r&&m==n;var h=!0;i.set(n,r),i.set(r,n);for(var y=a;++d<c;){p=s[d];var g=n[p],x=r[p];if(t)var S=a?t(x,g,p,r,n,i):t(g,x,p,n,r,i);if(!(S===void 0?g===x||o(g,x,e,t,i):S)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,b=r.constructor;w!=b&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof b=="function"&&b instanceof b)&&(h=!1)}return i.delete(n),i.delete(r),h}var xm=tT;var rT=1,vm="[object Arguments]",bm="[object Array]",ks="[object Object]",oT=Object.prototype,Sm=oT.hasOwnProperty;function nT(n,r,e,t,o,i){var a=He(n),s=He(r),c=a?bm:Zr(n),u=s?bm:Zr(r);c=c==vm?ks:c,u=u==vm?ks:u;var l=c==ks,d=u==ks,p=c==u;if(p&&qo(n)){if(!qo(r))return!1;a=!0,l=!1}if(p&&!l)return i||(i=new Un),a||Os(n)?Fs(n,r,e,t,o,i):gm(n,r,c,e,t,o,i);if(!(e&rT)){var f=l&&Sm.call(n,"__wrapped__"),m=d&&Sm.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Un),o(h,y,e,t,i)}}return p?(i||(i=new Un),xm(n,r,e,t,o,i)):!1}var wm=nT;function Tm(n,r,e,t,o){return n===r?!0:n==null||r==null||!yt(n)&&!yt(r)?n!==n&&r!==r:wm(n,r,e,t,Tm,o)}var _m=Tm;function iT(n,r){return n!=null&&r in Object(n)}var Pm=iT;function aT(n,r,e){r=Kt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=xo(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&&Mn(o)&&Cn(a,o)&&(He(n)||Ln(n)))}var Om=aT;function sT(n,r){return n!=null&&Om(n,r,Pm)}var Am=sT;function lT(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Cm=lT;function cT(n,r){return r.length<2?n:Ns(n,Tf(r,0,-1))}var Nm=cT;function dT(n,r){return _m(n,r)}var jc=dT;function uT(n,r){return r=Kt(r,n),n=Nm(n,r),n==null||delete n[xo(Cm(r))]}var Im=uT;function pT(n){return wf(n)?void 0:n}var Mm=pT;var fT=1,mT=2,hT=4,yT=Is(function(n,r){var e={};if(n==null)return e;var t=!1;r=bs(r,function(i){return i=Kt(i,n),t||(t=i.length>1),i}),Sr(n,Ds(n),e),t&&(e=zs(e,fT|mT|hT,Mm));for(var o=r.length;o--;)Im(e,r[o]);return e}),$n=yT;function gT(n,r,e,t){if(!Ht(n))return n;r=Kt(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var c=xo(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=a){var l=s[c];u=t?t(l,c,s):void 0,u===void 0&&(u=Ht(l)?l:Cn(r[o+1])?[]:{})}In(s,c,u),s=s[c]}return n}var Em=gT;function xT(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=Ns(n,a);e(s,a)&&Em(i,Kt(a,n),s)}return i}var Lm=xT;function vT(n,r){return Lm(n,r,function(e,t){return Am(n,t)})}var Dm=vT;var bT=Is(function(n,r){return n==null?{}:Dm(n,r)}),nr=bT;var fe=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,fe.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,fe.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,fe.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function Sa(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"&&Sa(t)}return Object.freeze(n)}function Bm(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 Yn=class extends Error{};function Us(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function wr(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 Xn(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 Rm(){return typeof process<"u"}function Gm(n,r){for(let e of n)r(e.id,e.data)!==!0&&Gm(e.children,r)}function Vm(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Vm(e,r)}var Fe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Fe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Sa(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&&Vm(o,t)}}traverse(e){Gm(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(l=>l.id===e);if(s<0)throw new Error("not expected");let c=a[s];return a=[...a],a[s]={...c,data:t},this.modifyArrayBy(i,a)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let s=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(l=>l.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,Fe.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 c=t,u=this.childrenArray(c),l={fi:o,id:i,data:a,children:s};return u=[...u,l],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(l),{data:this.modifyArrayBy(c,u),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(u=>u.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 f=t;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new Yn("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,c=this.childrenArray(a),u=c.findIndex(f=>f.id===i);c=[...c];let l=c.splice(u,1)[0],d=this.modifyArrayBy(a,c);a=t,c=d.childrenArray(a);let p=l.fi;return l={...l,fi:o},c=[...c,l],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(l),d=d.modifyArrayBy(a,c),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,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)=>Bm(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 wr(0,o,o);{let a=i[0].fi;return wr(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(c=>c.fi>a.fi);if(s===void 0){let c=i[i.length-1].fi;return wr(c,c+o,o)}else return wr(a.fi,s.fi,o)}}};var Kn;(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 c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=a[u],a[u]=o[c],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 c of Object.keys(o)){i[c]=a[c];let u=o[c];u===void 0?delete a[c]:a[c]=u,s=!0}return s?{data:a,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Kn||(Kn={}));var he=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,he.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Sa(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(u=>u.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,he.prototype);let t=e;return Rm()||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((u,l)=>u.fi-l.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(c=>c.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(l=>l.id===o);if(a===-1)return null;let s=i[a].fi,c={...i[a],fi:t};return i[a]=c,i.sort((l,d)=>l.fi-d.fi),e.localIndex=i.indexOf(c),{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 wr(0,t,t);{let i=o[0].fi;return wr(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 wr(s,s+t,t)}else return wr(i.fi,a.fi,t)}}};function Zn(n){return n&&typeof n=="object"&&n instanceof Re}var Re=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&&!Zn(t))return null;o+=1}t=t?Us(t):new Re;for(let[c,u]of Object.entries(r.props)){let l=t[c];i[c]=l,u===void 0?delete t[c]:t[c]=u}for(;o>0;){if(Object.keys(t).length===0){let c=e[o-1];c&&(t=Us(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=Us(c);u[r.path[o-1]]=t,t=u}else{let u=new Re;u[r.path[o-1]]=t,t=u}}o-=1}let a=Object.setPrototypeOf(t,Re.prototype),s={...r,props:i};return{data:a,actual:r,reverse:s}}},Tr;(t=>{function n(o,i){return wa(o,i)??o}t.apply=n;function r(o,i){return kc(o,i)}t.merge=r;function e(o,i){let a=0,s=i.path,c=o;for(;a<s.length&&c!==void 0;){if(c=Je.zoomOnce(c,s[a]),c===void 0)return i;if(!Zn(c))return;a+=1}if(c===void 0)return i;if(!!Zn(c))if(i.type===0){let u={...i.props};for(let l of Object.keys(c))delete u[l];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Fc([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(Tr||(Tr={}));function Fc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=wa(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Fc(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 ST(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=wa(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 wa(n,r){if(!Zn(r))return r;if(n instanceof Fe){let e=Fc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof he)return ST(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=wa(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 Re)return kc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=wa(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 kc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Zn(r))return r;if(!Zn(n))return Tr.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 Re;for(let o of e){let i=kc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function zm(n,r){let e={cur:[],result:[],len:0};return n=Ta(n,r,e)??n,[n,e.result]}function Hs(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Ws(n){n&&(n.len-=1)}function wT(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function jm(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 c=Ta(i.data,r,Hs(e,a));Ws(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=jm(i.children,r,e);return u!==void 0?t=!0:u=i.children,{...i,id:a,data:c,children:u}});if(t)return o}function TT(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 c=Ta(i.data,r,Hs(e,a));return Ws(e),t=t||c!==void 0,c===void 0&&(c=i.data),{...i,id:a,data:c}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function Ta(n,r,e){if(n instanceof Fe){let t=jm(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof he)return TT(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=Ta(i,r,Hs(e,a));return Ws(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"&&!Xn(n)){let t={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"&&i!=="text"){let s=r[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let c=Ta(a,r,Hs(e,i));Ws(e),o=o||c!==void 0,c===void 0&&(c=a),t[i]=c}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&&wT(e),t}else return}}var qs;(r=>{function n(e,t){let o=Je.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})(qs||(qs={}));var et;(s=>{function n(c,u){return{...c,path:c.path.slice(u)}}s.drop=n;function r(c,u){return e(c,u)?.data??c}s.applySimple=r;function e(c,u){let l=u.path;for(var d=[];;){let p;if(c instanceof Re&&u.type===0&&(p=c.runOp({...u,path:l.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===l.length&&(c instanceof Fe||c instanceof he||c instanceof fe?p=c.runOp(u):p=Kn.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=l[y],x=d[y];if(x instanceof Fe){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof he){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof fe){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof Re){let S={...x,[g]:h};h=Object.setPrototypeOf(S,Re.prototype)}else if(typeof x=="object")if(Array.isArray(x)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let S=h;h=[...x],h[g]=S}else h={...x,[g]:h};else return null}return{data:h,actual:{...p.actual,path:l},reverse:{...p.reverse,path:l}}}else return null;let f=l[d.length],m;if(c instanceof Fe){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof he){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else c!==null&&(m=c[f]);if(m!==void 0)d.push(c),c=m;else return null}}s.apply=e;function t(c,u){for(let l=0;l<c.length&&l<u.length;l++)if(c[l]!==u[l])return!0;return!1}s.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let l=0;l<c.length;l++)if(c[l]!==u[l])return!1;return!0}s.pathEq=o;function i(c,u){return t(c.path,u.path)}s.commutative=i;function a(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(l=>u.props[l]!==void 0):!1}s.subsumed=a})(et||(et={}));var _a;(c=>{function n(){return[]}c.empty=n;function r(u,l){let d=[];for(let p of u){let[f,...m]=p.path;f===l&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,l){return u.map(d=>({...d,path:[l,...d.path]}))}c.addPrefix=e;function t(u,l){return[...u,...l]}c.concat=t;function o(u,l){return[...u.filter(p=>!l.some(f=>et.subsumed(p,f))),...l]}c.compress=o;function i(u,l){return u.every(d=>l.every(p=>et.commutative(d,p)))}c.commutative=i;function a(u,l){for(let d of l){let p=s(u,d);p!==null&&(u=p.data)}return u}c.applyAll=a;function s(u,l){var d=u;let p=[],f=[];for(let m of l)try{if(m.type===3){let h,y;m.path[m.path.length-1]==="variables"?h=Je.zoom(d,[...m.path,m.id,"value"]):h=Je.zoom(d,[...m.path,m.id]);let g=et.apply(d,{...m,type:2});if(g!==null){d=g.data;let[x,S]=zm(d,{[m.id]:h});d=x;for(let w=0;w<S.length;w++){let b=S[w],T=b.pop();if(typeof T=="number"){let _=[T];for(let N=w+1;N<S.length;N++){let P=S[N],C=P[P.length-1];if(typeof C=="number"&&Je.equal(b,P.slice(0,P.length-1)))_.push(C),S.splice(N,1);else break}let v=Je.zoom(d,b);y=v.map((N,P)=>_.includes(P)?m.id:N),h=v,T=b.pop()}else y=m.id;p.push({type:0,path:b,props:{[T]:h}}),f.push({type:0,path:b,props:{[T]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let h=et.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof Yn)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=s})(_a||(_a={}));var Fm=Symbol(),_T=Symbol(),Ys=Symbol(),Xo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof $s);){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[Ys];t&&t(),delete this._children[r]}}}},Hc=class extends Xo{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,Kn.runOp(this._current,r),r.path)}},Wc=class extends Xo{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,fe.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},km={get(n,r){if(r===Ys)return()=>{n._parent=null};if(r===Fm)return n._current;if(r===_T)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=Xs(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]}}},PT={...km,set(n,r,e){let t={type:0,props:{[r]:We(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}},OT={...km,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}},Qn=class extends Xo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ys]=()=>{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=Xs(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)}},Jn=class extends Xo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ys]=()=>{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=Xs(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 Uc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Je.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var $s=class extends Xo{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){Uc(this.ts,e,r),Uc(this.actual,t,r),Uc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Xs(n,r,e){return e instanceof Fe?new Qn(n,r,e):e instanceof he?new Jn(n,r,e):e instanceof fe?new Proxy(new Wc(n,r,e),OT):e!==null&&typeof e=="object"?Xn(e)?e:new Proxy(new Hc(n,r,e),PT):e}function qc(n){let r=new $s(n);return[Xs(r,"",n),r]}function vo(n,r){let[e,t]=qc(n);return r(e),t.result()}function We(n){return n instanceof Qn||n instanceof Jn?n._current:n!==null&&typeof n=="object"?n[Fm]:n}var Je;(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 c=t(s,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...a};return Object.keys(c).forEach(l=>{delete u[l]}),u}else return a}o.removeOverridden=r;function e(i,a){if((i instanceof Fe||i instanceof Qn)&&typeof a=="string")return i.data(a);if((i instanceof he||i instanceof Jn)&&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})(Je||(Je={}));function Um(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 _t(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 Ks=class{},Pa=class extends Ks{constructor(e){super();this.id=e}},Oa=class extends Ks{constructor(e){super();this.data=e}};var Yc;try{Yc=new TextDecoder}catch{}var re,So,I=0;var Zm=[],Xc=Zm,Kc=0,Rt={},Ie,bo,Zt=0,_r=0,Wt,Jr,Ot=[],Ee,Hm={useRecords:!1,mapsAsObjects:!0},Aa=class{},Qc=new Aa;Qc.name="MessagePack 0xC1";var ei=!1,Pr=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(re)return rh(()=>(Qs(),this?this.unpack(r,e):Pr.prototype.unpack.call(Hm,r,e)));So=e>-1?e:r.length,I=0,Kc=0,_r=0,bo=null,Xc=Zm,Wt=null,re=r;try{Ee=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw re=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 Pr){if(Rt=this,this.structures)return Ie=this.structures,Zs();(!Ie||Ie.length>0)&&(Ie=[])}else Rt=Hm,(!Ie||Ie.length>0)&&(Ie=[]);return Zs()}unpackMultiple(r,e){let t,o=0;try{ei=!0;let i=r.length,a=this?this.unpack(r,i):tl.unpack(r,i);if(e){for(e(a);I<i;)if(o=I,e(Zs())===!1)return}else{for(t=[a];I<i;)o=I,t.push(Zs());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{ei=!1,Qs()}}_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 Zs(){try{if(!Rt.trusted&&!ei){let r=Ie.sharedLength||0;r<Ie.length&&(Ie.length=r)}let n=qe();if(I==So)Ie.restoreStructures&&Wm(),Ie=null,re=null,Jr&&(Jr=null);else if(I>So){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!ei)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ie.restoreStructures&&Wm(),Qs(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Wm(){for(let n in Ie.restoreStructures)Ie[n]=Ie.restoreStructures[n];Ie.restoreStructures=null}function qe(){let n=re[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Ie[n&63]||Rt.getStructures&&Qm()[n&63];return r?(r.read||(r.read=Jc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Rt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[eh()]=qe();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(qe(),qe());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=qe();return r}else if(n<192){let r=n-160;if(_r>=I)return bo.slice(I-Zt,(I+=r)-Zt);if(_r==0&&So<140){let e=r<16?ed(r):Jm(r);if(e!=null)return e}return Zc(r)}else{let r;switch(n){case 192:return null;case 193:return Wt?(r=qe(),r>0?Wt[1].slice(Wt.position1,Wt.position1+=r):Wt[0].slice(Wt.position0,Wt.position0-=r)):Qc;case 194:return!1;case 195:return!0;case 196:return $c(re[I++]);case 197:return r=Ee.getUint16(I),I+=2,$c(r);case 198:return r=Ee.getUint32(I),I+=4,$c(r);case 199:return Ko(re[I++]);case 200:return r=Ee.getUint16(I),I+=2,Ko(r);case 201:return r=Ee.getUint32(I),I+=4,Ko(r);case 202:if(r=Ee.getFloat32(I),Rt.useFloat32>2){let e=el[(re[I]&127)<<1|re[I+1]>>7];return I+=4,(e*r+(r>0?.5:-.5)>>0)/e}return I+=4,r;case 203:return r=Ee.getFloat64(I),I+=8,r;case 204:return re[I++];case 205:return r=Ee.getUint16(I),I+=2,r;case 206:return r=Ee.getUint32(I),I+=4,r;case 207:return Rt.int64AsNumber?(r=Ee.getUint32(I)*4294967296,r+=Ee.getUint32(I+4)):r=Ee.getBigUint64(I),I+=8,r;case 208:return Ee.getInt8(I++);case 209:return r=Ee.getInt16(I),I+=2,r;case 210:return r=Ee.getInt32(I),I+=4,r;case 211:return Rt.int64AsNumber?(r=Ee.getInt32(I)*4294967296,r+=Ee.getUint32(I+4)):r=Ee.getBigInt64(I),I+=8,r;case 212:if(r=re[I++],r==114)return Km(re[I++]&63);{let e=Ot[r];if(e)return e.read?(I++,e.read(qe())):e.noBuffer?(I++,e()):e(re.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=re[I],r==114?(I++,Km(re[I++]&63,re[I++])):Ko(2);case 214:return Ko(4);case 215:return Ko(8);case 216:return Ko(16);case 217:return r=re[I++],_r>=I?bo.slice(I-Zt,(I+=r)-Zt):CT(r);case 218:return r=Ee.getUint16(I),I+=2,_r>=I?bo.slice(I-Zt,(I+=r)-Zt):NT(r);case 219:return r=Ee.getUint32(I),I+=4,_r>=I?bo.slice(I-Zt,(I+=r)-Zt):IT(r);case 220:return r=Ee.getUint16(I),I+=2,$m(r);case 221:return r=Ee.getUint32(I),I+=4,$m(r);case 222:return r=Ee.getUint16(I),I+=2,Ym(r);case 223:return r=Ee.getUint32(I),I+=4,Ym(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 AT=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Jc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>AT.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(qe);return n.highByte===0&&(n.read=qm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=qe()}return t}return e.count=0,n.highByte===0?qm(r,e):e}var qm=(n,r)=>function(){let e=re[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ie[t]||Qm()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Jc(o,n)),o.read()};function Qm(){let n=rh(()=>(re=null,Rt.getStructures()));return Ie=Rt._mergeStructures(n,Ie)}var Zc=Js,CT=Js,NT=Js,IT=Js;function Js(n){let r;if(n<16&&(r=ed(n)))return r;if(n>64&&Yc)return Yc.decode(re.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=re[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=re[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=re[I++]&63,a=re[I++]&63;t.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=re[I++]&63,a=re[I++]&63,s=re[I++]&63,c=(o&7)<<18|i<<12|a<<6|s;c>65535&&(c-=65536,t.push(c>>>10&1023|55296),c=56320|c&1023),t.push(c)}else t.push(o);t.length>=4096&&(r+=lt.apply(String,t),t.length=0)}return t.length>0&&(r+=lt.apply(String,t)),r}function $m(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=qe();return r}function Ym(n){if(Rt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[eh()]=qe();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(qe(),qe());return r}}var lt=String.fromCharCode;function Jm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=re[I++];if((o&128)>0){I=r;return}e[t]=o}return lt.apply(String,e)}function ed(n){if(n<4)if(n<2){if(n===0)return"";{let r=re[I++];if((r&128)>1){I-=1;return}return lt(r)}}else{let r=re[I++],e=re[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return lt(r,e);let t=re[I++];if((t&128)>0){I-=3;return}return lt(r,e,t)}else{let r=re[I++],e=re[I++],t=re[I++],o=re[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return lt(r,e,t,o);{let i=re[I++];if((i&128)>0){I-=5;return}return lt(r,e,t,o,i)}}else if(n<8){let i=re[I++],a=re[I++];if((i&128)>0||(a&128)>0){I-=6;return}if(n<7)return lt(r,e,t,o,i,a);let s=re[I++];if((s&128)>0){I-=7;return}return lt(r,e,t,o,i,a,s)}else{let i=re[I++],a=re[I++],s=re[I++],c=re[I++];if((i&128)>0||(a&128)>0||(s&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return lt(r,e,t,o,i,a,s,c);{let u=re[I++];if((u&128)>0){I-=9;return}return lt(r,e,t,o,i,a,s,c,u)}}else if(n<12){let u=re[I++],l=re[I++];if((u&128)>0||(l&128)>0){I-=10;return}if(n<11)return lt(r,e,t,o,i,a,s,c,u,l);let d=re[I++];if((d&128)>0){I-=11;return}return lt(r,e,t,o,i,a,s,c,u,l,d)}else{let u=re[I++],l=re[I++],d=re[I++],p=re[I++];if((u&128)>0||(l&128)>0||(d&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return lt(r,e,t,o,i,a,s,c,u,l,d,p);{let f=re[I++];if((f&128)>0){I-=13;return}return lt(r,e,t,o,i,a,s,c,u,l,d,p,f)}}else{let f=re[I++],m=re[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return lt(r,e,t,o,i,a,s,c,u,l,d,p,f,m);let h=re[I++];if((h&128)>0){I-=15;return}return lt(r,e,t,o,i,a,s,c,u,l,d,p,f,m,h)}}}}}function $c(n){return Rt.copyBuffers?Uint8Array.prototype.slice.call(re,I,I+=n):re.subarray(I,I+=n)}function Ko(n){let r=re[I++];if(Ot[r])return Ot[r](re.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var Xm=new Array(4096);function eh(){let n=re[I++];if(n>=160&&n<192){if(n=n-160,_r>=I)return bo.slice(I-Zt,(I+=n)-Zt);if(!(_r==0&&So<180))return Zc(n)}else return I--,qe();let r=(n<<5^(n>1?Ee.getUint16(I):n>0?re[I]:0))&4095,e=Xm[r],t=I,o=I+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ee.getUint32(t),i!=e[a++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=re[t++],i!=e[a++]){t=1879048192;break}if(t===o)return I=t,e.string;o-=3,t=I}for(e=[],Xm[r]=e,e.bytes=n;t<o;)i=Ee.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=re[t++],e.push(i);let s=n<16?ed(n):Jm(n);return s!=null?e.string=s:e.string=Zc(n)}var Km=(n,r)=>{var e=qe();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Ie[n];return o&&o.isShared&&((Ie.restoreStructures||(Ie.restoreStructures=[]))[n]=o),Ie[n]=e,e.read=Jc(e,t),e.read()},th=typeof self=="object"?self:global;Ot[0]=()=>{};Ot[0].noBuffer=!0;Ot[101]=()=>{let n=qe();return(th[n[0]]||Error)(n[1])};Ot[105]=n=>{let r=Ee.getUint32(I-4);Jr||(Jr=new Map);let e=re[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Jr.set(r,o);let i=qe();return o.used?Object.assign(t,i):(o.target=i,i)};Ot[112]=n=>{let r=Ee.getUint32(I-4),e=Jr.get(r);return e.used=!0,e.target};Ot[115]=()=>new Set(qe());var td=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Ot[116]=n=>{let r=n[0],e=td[r];if(!e)throw new Error("Could not find typed array for code "+r);return new th[e](Uint8Array.prototype.slice.call(n,1).buffer)};Ot[120]=()=>{let n=qe();return new RegExp(n[0],n[1])};Ot[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,Wt=[qe(),qe()],Wt.position0=0,Wt.position1=0;let t=I;I=e;try{return qe()}finally{I=t}};Ot[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 rh(n){let r=So,e=I,t=Kc,o=Zt,i=_r,a=bo,s=Xc,c=Jr,u=Wt,l=new Uint8Array(re.slice(0,So)),d=Ie,p=Ie.slice(0,Ie.length),f=Rt,m=ei,h=n();return So=r,I=e,Kc=t,Zt=o,_r=i,bo=a,Xc=s,Jr=c,Wt=u,re=l,ei=m,Ie=d,Ie.splice(0,Ie.length,...p),Rt=f,Ee=new DataView(re.buffer,re.byteOffset,re.byteLength),h}function Qs(){re=null,Jr=null,Ie=null}function oh(n){n.unpack?Ot[n.type]=n.unpack:Ot[n.type]=n}var el=new Array(147);for(let n=0;n<256;n++)el[n]=+("1e"+Math.floor(45.15-n*.30103));var tl=new Pr({useRecords:!1}),MT=tl.unpack,ET=tl.unpackMultiple,LT=tl.unpack,rl={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},DT=new Float32Array(1),gG=new Uint8Array(DT.buffer,0,4);var ol;try{ol=new TextEncoder}catch{}var nl,od,il=typeof Buffer<"u",rd=il?Buffer.allocUnsafeSlow:Uint8Array,sh=il?Buffer:Uint8Array,nh=il?4294967296:2144337920,G,Xe,E=0,Or,Ar=null,BT=/[\u0080-\uFFFF]/,Ca=Symbol("record-id"),Zo=class extends Pr{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,c=0,u=sh.prototype.utf8Write?function(v,N,P){return G.utf8Write(v,N,P)}:ol&&ol.encodeInto?function(v,N){return ol.encodeInto(v,G.subarray(N)).written}:!1,l=this;r||(r={});let d=r&&r.sequential,p=r.structures||r.saveStructures,f=r.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=r.maxOwnStructures;m==null&&(m=p?32:64),d&&!r.saveStructures&&(this.structures=[]);let h=f>32||m+f>64,y=f+64,g=f+m+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let x=[],S=0,w=0;this.pack=this.encode=function(v,N){if(G||(G=new rd(8192),Xe=new DataView(G.buffer,0,8192),E=0),Or=G.length-10,Or-E<2048?(G=new rd(G.length),Xe=new DataView(G.buffer,0,G.length),Or=G.length-10,E=0):E=E+7&2147483640,t=E,s=l.structuredClone?new Map:null,l.bundleStrings?(Ar=["",""],G[E++]=214,G[E++]=98,Ar.position=E-t,E+=4):Ar=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let P=o.sharedLength||0;if(P>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 C=0;C<P;C++){let O=o[C];if(!O)continue;let A,M=o.transitions;for(let L=0,X=O.length;L<X;L++){let R=O[L];A=M[R],A||(A=M[R]=Object.create(null)),M=A}M[Ca]=C+64}c=P}d||(o.nextId=P+64)}i&&(i=!1),a=o||[];try{if(b(v),Ar){Xe.setUint32(Ar.position+t,E-Ar.position-t);let P=Ar;Ar=null,b(P[0]),b(P[1])}if(l.offset=E,s&&s.idsToInsert){E+=s.idsToInsert.length*6,E>Or&&_(E),l.offset=E;let P=GT(G.subarray(t,E),s.idsToInsert);return s=null,P}return N&ch?(G.start=t,G.end=E,G):G.subarray(t,E)}finally{if(o){if(w<10&&w++,S>1e4)o.transitions=null,w=0,S=0,x.length>0&&(x=[]);else if(x.length>0&&!d){for(let P=0,C=x.length;P<C;P++)x[P][Ca]=0;x=[]}if(i&&l.saveStructures){let P=o.sharedLength||f;o.length>P&&(o=o.slice(0,P));let C=G.subarray(t,E);return l.saveStructures(o,c)===!1?(l._mergeStructures(l.getStructures()),l.pack(v)):(c=P,C)}}N&HT&&(E=t)}};let b=v=>{E>Or&&(G=_(E));var N=typeof v,P;if(N==="string"){let C=v.length;if(Ar&&C>=8&&C<4096){let M=BT.test(v);Ar[M?0:1]+=v,G[E++]=193,b(M?-C:C);return}let O;C<32?O=1:C<256?O=2:C<65536?O=3:O=5;let A=C*3;if(E+A>Or&&(G=_(E+A)),C<64||!u){let M,L,X,R=E+O;for(M=0;M<C;M++)L=v.charCodeAt(M),L<128?G[R++]=L:L<2048?(G[R++]=L>>6|192,G[R++]=L&63|128):(L&64512)===55296&&((X=v.charCodeAt(M+1))&64512)===56320?(L=65536+((L&1023)<<10)+(X&1023),M++,G[R++]=L>>18|240,G[R++]=L>>12&63|128,G[R++]=L>>6&63|128,G[R++]=L&63|128):(G[R++]=L>>12|224,G[R++]=L>>6&63|128,G[R++]=L&63|128);P=R-E-O}else P=u(v,E+O,A);P<32?G[E++]=160|P:P<256?(O<2&&G.copyWithin(E+2,E+1,E+1+P),G[E++]=217,G[E++]=P):P<65536?(O<3&&G.copyWithin(E+3,E+2,E+2+P),G[E++]=218,G[E++]=P>>8,G[E++]=P&255):(O<5&&G.copyWithin(E+5,E+3,E+3+P),G[E++]=219,Xe.setUint32(E,P),E+=4),E+=P}else if(N==="number")if(v>>>0===v)v<64?G[E++]=v:v<256?(G[E++]=204,G[E++]=v):v<65536?(G[E++]=205,G[E++]=v>>8,G[E++]=v&255):(G[E++]=206,Xe.setUint32(E,v),E+=4);else if(v>>0===v)v>=-32?G[E++]=256+v:v>=-128?(G[E++]=208,G[E++]=v+256):v>=-32768?(G[E++]=209,Xe.setInt16(E,v),E+=2):(G[E++]=210,Xe.setInt32(E,v),E+=4);else{let C;if((C=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){G[E++]=202,Xe.setFloat32(E,v);let O;if(C<4||(O=v*el[(G[E]&127)<<1|G[E+1]>>7])>>0===O){E+=4;return}else E--}G[E++]=203,Xe.setFloat64(E,v),E+=8}else if(N==="object")if(!v)G[E++]=192;else{if(s){let O=s.get(v);if(O){if(!O.id){let A=s.idsToInsert||(s.idsToInsert=[]);O.id=A.push(O)}G[E++]=214,G[E++]=112,Xe.setUint32(E,O.id),E+=4;return}else s.set(v,{offset:E-t})}let C=v.constructor;if(C===Object)T(v,!0);else if(C===Array){P=v.length,P<16?G[E++]=144|P:P<65536?(G[E++]=220,G[E++]=P>>8,G[E++]=P&255):(G[E++]=221,Xe.setUint32(E,P),E+=4);for(let O=0;O<P;O++)b(v[O])}else if(C===Map){P=v.size,P<16?G[E++]=128|P:P<65536?(G[E++]=222,G[E++]=P>>8,G[E++]=P&255):(G[E++]=223,Xe.setUint32(E,P),E+=4);for(let[O,A]of v)b(O),b(A)}else{for(let O=0,A=nl.length;O<A;O++){let M=od[O];if(v instanceof M){let L=nl[O];if(L.write){L.type&&(G[E++]=212,G[E++]=L.type,G[E++]=0),b(L.write.call(this,v));return}let X=G,R=Xe,Z=E;G=null;let z;try{z=L.pack.call(this,v,V=>(G=X,X=null,E+=V,E>Or&&_(E),{target:G,targetView:Xe,position:E-V}),b)}finally{X&&(G=X,Xe=R,E=Z,Or=G.length-10)}z&&(z.length+E>Or&&_(z.length+E),E=RT(z,G,E,L.type));return}}T(v,!v.hasOwnProperty)}}else if(N==="boolean")G[E++]=v?195:194;else if(N==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))G[E++]=211,Xe.setBigInt64(E,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)G[E++]=207,Xe.setBigUint64(E,v);else if(this.largeBigIntToFloat)G[E++]=203,Xe.setFloat64(E,Number(v));else throw new RangeError(v+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");E+=8}else if(N==="undefined")this.encodeUndefinedAsNil?G[E++]=192:(G[E++]=212,G[E++]=0,G[E++]=0);else if(N==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},T=this.useRecords===!1?this.variableMapSize?v=>{let N=Object.keys(v),P=N.length;P<16?G[E++]=128|P:P<65536?(G[E++]=222,G[E++]=P>>8,G[E++]=P&255):(G[E++]=223,Xe.setUint32(E,P),E+=4);let C;for(let O=0;O<P;O++)b(C=N[O]),b(v[C])}:(v,N)=>{G[E++]=222;let P=E-t;E+=2;let C=0;for(let O in v)(N||v.hasOwnProperty(O))&&(b(O),b(v[O]),C++);G[P+++t]=C>>8,G[P+t]=C&255}:v=>{let N=Object.keys(v),P,C=a.transitions||(a.transitions=Object.create(null)),O=0;for(let M=0,L=N.length;M<L;M++){let X=N[M];P=C[X],P||(P=C[X]=Object.create(null),O++),C=P}let A=C[Ca];if(A)A>=96&&h?(G[E++]=((A-=96)&31)+96,G[E++]=A>>5):G[E++]=A;else{A=a.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(A=a.nextOwnId,A<g||(A=y),a.nextOwnId=A+1):(A>=g&&(A=y),a.nextId=A+1);let M=N.highByte=A>=96&&h?A-96>>5:-1;C[Ca]=A,a[A-64]=N,A<y?(N.isShared=!0,a.sharedLength=A-63,i=!0,M>=0?(G[E++]=(A&31)+96,G[E++]=M):G[E++]=A):(M>=0?(G[E++]=213,G[E++]=114,G[E++]=(A&31)+96,G[E++]=M):(G[E++]=212,G[E++]=114,G[E++]=A),O&&(S+=w*O),x.length>=m&&(x.shift()[Ca]=0),x.push(C),b(N))}for(let M=0,L=N.length;M<L;M++)b(v[N[M]])},_=v=>{let N;if(v>16777216){if(v-t>nh)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(nh,Math.round(Math.max((v-t)*(v>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(v-t<<2,G.length-1)>>12)+1<<12;let P=new rd(N);return Xe=new DataView(P.buffer,0,N),G.copy?G.copy(P,0,t,v):P.set(G.slice(t,v)),E-=t,t=0,Or=P.length-10,G=P}}useBuffer(r){G=r,Xe=new DataView(G.buffer,G.byteOffset,G.byteLength),E=0}};od=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Aa];nl=[{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?ih(n,16,r):ah(il?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==sh&&this.structuredClone?ih(n,td.indexOf(e.name),r):ah(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function ih(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 ah(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 RT(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 GT(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 wo(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)");od.unshift(n.Class),nl.unshift(n)}oh(n)}var lh=new Zo({useRecords:!1}),VT=lh.pack,zT=lh.pack;var{NEVER:jT,ALWAYS:FT,DECIMAL_ROUND:kT,DECIMAL_FIT:UT}=rl,ch=512,HT=1024;var dh=new Zo({structuredClone:!0});wo({Class:fe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,fe.prototype),n}});wo({Class:he.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,he.prototype),n}});wo({Class:Fe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Fe.prototype),n}});wo({Class:Pa.prototype.constructor,type:4,write(n){return n.id},read(n){return new Pa(n)}});wo({Class:Oa.prototype.constructor,type:5,write(n){return n.data},read(n){return new Oa(n)}});wo({Class:Re.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});function WT(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 nd(n){if(Xn(n))return n;if(Array.isArray(n))return n.map(nd);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=nd(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var al;(t=>{function n(o){return dh.pack(o)}t.serialize=n;function r(o){return dh.unpack(o)}t.deserialize=r;function e(o){return WT(n(nd(o))).toString()}t.checksum=e})(al||(al={}));var Po="personal camera",Oo="a218fcc3-276b-49b9-b485-49037fd14f5f",yh=2960946,rt=5526619;var uh;(e=>{function n(t,o){return t[0]===o[0]&&t[1]===o[1]}e.isEqual=n;function r(t,o,i){return[t[0]+(o[0]-t[0])*i,t[1]+(o[1]-t[1])*i]}e.lerp=r})(uh||(uh={}));var To;(s=>{function n(c,u){return c[0]===u[0]&&c[1]===u[1]&&c[2]===u[2]}s.isEqual=n;function r(c,u){return[c[0]+u[0],c[1]+u[1],c[2]+u[2]]}s.add=r;function e(c,u){return[c[0]-u[0],c[1]-u[1],c[2]-u[2]]}s.sub=e;function t(c,u){return[c[0]/u[0],c[1]/u[1],c[2]/u[2]]}s.div=t;function o(c,u){return[c[0]*u[0],c[1]*u[1],c[2]*u[2]]}s.mul=o;function i(c,u){return Math.hypot(c[0]-u[0],c[1]-u[1],c[2]-u[2])}s.dist=i;function a(c,u,l){return[c[0]+(u[0]-c[0])*l,c[1]+(u[1]-c[1])*l,c[2]+(u[2]-c[2])*l]}s.lerp=a})(To||(To={}));var ph;(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})(ph||(ph={}));var _o;(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 c=0,u=a.length;c<u;c+=3){let l=i[3]*a[c]+i[7]*a[c+1]+i[11]*a[c+2]+i[15];s[c]=(i[0]*a[c]+i[4]*a[c+1]+i[8]*a[c+2]+i[12])/l,s[c+1]=(i[1]*a[c]+i[5]*a[c+1]+i[9]*a[c+2]+i[13])/l,s[c+2]=(i[2]*a[c]+i[6]*a[c+1]+i[10]*a[c+2]+i[14])/l}return s}o.applyMatrix4=t})(_o||(_o={}));var ct;(l=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}l.isRGB=n,l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.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}}l.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}l.clone=i;function a(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}l.fromHex=a;function s(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}l.toHex=s;function c(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}l.equals=c;function u(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f}}l.lerp=u})(ct||(ct={}));var At;(s=>{s.white={...ct.white,a:1},s.transparent={...ct.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}s.from0to1=e;function t(c,u){return{...ct.fromHex(c),a:u}}s.fromHexAndA=t;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}}s.toRgb255a1=o;function i(c,u){return ct.equals(c,u)&&c.a===u.a}s.equals=i;function a(c,u,l){return{r:c.r+(u.r-c.r)*l,g:c.g+(u.g-c.g)*l,b:c.b+(u.b-c.b)*l,a:c.a+(u.a-c.a)*l}}s.lerp=a})(At||(At={}));var sl;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(sl||(sl={}));var fh;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(fh||(fh={}));var mh;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(mh||(mh={}));var hh;(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]))(hh||(hh={}));function gh(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 ir;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(ir||(ir={}));var Ao;(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:i.orthographic.zoom}o.getZoom=t})(Ao||(Ao={}));var Cr;(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(qT.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;$T.forEach(c=>{Object.assign(i.radial,{[c]:s[c]??a[c]})})}if(i.linear={...t.linear},o.linear){let a=t.linear,s=o.linear;YT.forEach(c=>{Object.assign(i.linear,{[c]:s[c]??a[c]})})}if(i.grid={...t.grid},o.grid){let a=t.grid,s=o.grid;XT.forEach(c=>{Object.assign(i.grid,{[c]:s[c]??a[c]})})}if(i.toObject={...t.toObject},o.toObject){let a=t.toObject,s=o.toObject;KT.forEach(c=>{Object.assign(i.toObject,{[c]:s[c]??a[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let a=t.randomnessObject,s=o.randomnessObject;ZT.forEach(c=>{Object.assign(i.randomnessObject,{[c]:s[c]??a[c]})})}return i}e.merge=r})(Cr||(Cr={}));var ll;(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 c=o[s];c&&Object.keys(c).length>0&&a.push({type:0,path:[...i,s],props:c})}return a}t.toOps=e})(ll||(ll={}));var qT=["count"],$T=["radius","start","end","position","scale","rotation"],YT=["position","scale","rotation"],XT=["count","size"],KT=["count","position","scale","rotation"],ZT=["strength","scale","rotation","position","movement","seed","freqScale"];var cl;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(cl||(cl={}));var dl;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:At.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(t==="SpotLight")return{type:t,color:At.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:At.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(dl||(dl={}));var Co;(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]})(Co||(Co={}));var id;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(id||(id={}));var ad;(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})(ad||(ad={}));var ul;(r=>r.defaultData={...ad.defaultData,...id.defaultData})(ul||(ul={}));var xh;(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})(xh||(xh={}));var ti;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ti||(ti={}));var vh;(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==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}r.is=n})(vh||(vh={}));function Sh(n){return n.type!=="displace"}var bh;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(bh||(bh={}));var wh=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Th=["wrapping","image","video","name"],Ct;(o=>{function n(i,a){let{texture:s,...c}=a;if(Object.assign(i,c),s){let u=i.texture;u&&Object.assign(u,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]},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:ti.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...a,type:"color",color:ct.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:{...ct.fromHex(6710886),a:1},colorB:{...ct.fromHex(6710886),a:1},colorC:{...ct.fromHex(16777215),a:1},colorD:{...ct.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:At.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:At.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:At.fromHexAndA(0,1),contourColor:At.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...ct.fromHex(0),a:1},colorB:{...ct.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}}}})(Ct||(Ct={}));var gt;(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 l="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{l+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>l+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?l+=`${m.toFixed(4)}`:l+=`${m}`}):l+=`${f}`})}),l}c.getHash=r;function e(){return{layers:new he}}c.defaultEmptyData=e;function t(u="layer1",l="layer2"){return i("phong",u,l)}c.defaultData=t;function o(u,l){return{...u,name:l}}c.withName=o;function i(u,l="layer1",d="layer2"){let p=new he;return p.push({fi:0,data:Ct.defaultData("light",u),id:l}),p.push({fi:1,data:Ct.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function a(u,l="phong",d="layer1",p="layer2"){let f=Ct.defaultData("texture");Object.assign(f.texture,{image:u});let m=new he;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ct.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerTextureData=a;function s(u,l="phong",d="layer1",p="layer2"){let f=Ct.defaultData("video");Object.assign(f.texture,{video:u});let m=new he;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ct.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=s})(gt||(gt={}));var ri;(r=>{function n(){return{points:new he,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(ri||(ri={}));var oi;(r=>{function n(){return{points:new he,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(oi||(oi={}));var sd={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var pl;(r=>{function n(e,t){let o={...e};return QT.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(pl||(pl={}));var fl={shape:sd,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},QT=["depth","offset","angle","twist","startScale","endScale"];var Na;(e=>{function n(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}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})(Na||(Na={}));var ml;(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,pl.merge(o.extrusion,t.extrusion))),o}r.merge=n})(ml||(ml={}));var No;(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==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:oi.defaultData(),extrusion:fl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:ri.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})(No||(No={}));var hl;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:ct.white,near:.1,far:2e3})(hl||(hl={}));var yl;(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}}})(yl||(yl={}));var ld;(r=>r.defaultData={softShadowQuality:"low"})(ld||(ld={}));var cd;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(cd||(cd={}));var dd;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(dd||(dd={}));var Ia;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Ia||(Ia={}));var ud;(r=>r.defaultData={playCamera:Po,gameControlObject:null})(ud||(ud={}));var gl;(r=>r.defaultData={backgroundColor:At.fromHexAndA(yh,1),postprocessing:yl.defaultData,fog:hl.defaultData,globalPhysics:Ia.defaultData,ambient:cd.defaultData,ao:dd.defaultData,shadow:ld.defaultData,publish:ud.defaultData})(gl||(gl={}));var _h;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(_h||(_h={}));var ni;(o=>{o.identity={...sl.identity,hiddenMatrix:_o.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 cp({position:To.isEqual(i.position,a.position)?void 0:a.position,rotation:To.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:To.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:_o.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=t})(ni||(ni={}));var xt;(r=>r.defaultData={states:new he,events:new he,visible:!0,raycastLock:!1,physics:Co.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ni.identity,cloner:null})(xt||(xt={}));var xl;(r=>r.defaultData={type:"Empty",...xt.defaultData})(xl||(xl={}));var Ph;(r=>r.defaultData={type:"Component",...xt.defaultData})(Ph||(Ph={}));var Qo;(r=>r.defaultData={type:"Mesh",...xt.defaultData,...ul.defaultData})(Qo||(Qo={}));var Jo;(r=>r.defaultData={...xt.defaultData,...ni.identity,position:[0,0,Ao.DefaultTargetOffset],...Ao.defaultData})(Jo||(Jo={}));var vl;(e=>{function n(t){return{...xt.defaultData,...dl.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(vl||(vl={}));var ii;(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})(ii||(ii={}));var Nr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(a,s){return{...xt.defaultData,...s,component:a,overrides:new Re,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(a){let s=ni.fromObject(a.data);return t(a.id,s)}i.fromComponentData=o})(Nr||(Nr={}));var eo;(r=>r.defaultData={type:"Page",...xt.defaultData,physics:{...Co.defaultData,fusedBody:!1},...gl.defaultData,camera:Jo.defaultData})(eo||(eo={}));var bl;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:_o.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Co.defaultData,states:new he,events:new he,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Ao.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",...xt.defaultData,...Qo.defaultData,geometry:No.defaultData("RectangleGeometry"),material:gt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...xt.defaultData,...Qo.defaultData,geometry:No.defaultData("BooleanGeometry"),material:gt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...xt.defaultData,...Qo.defaultData,geometry:No.defaultData("TextGeometry"),material:gt.defaultTwoLayerData("phong","layer1","layer2")}))(bl||(bl={}));var en;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new Re}),"materials"in i&&(s.materials=i.materials.map(c=>({layers:new Re})))):ir.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=vo(s.material,c=>{if(typeof c!="string")for(let[u,l]of Object.entries(a.material.layers)){let d=c.layers.data(u);d&&Ct.patch(d,l)}}).data),s.materials&&a.materials&&(s.materials=vo(s.materials,c=>{for(let u=0;u<s.materials.length;u++){let l=a.materials[u];if(typeof l!="string")for(let[d,p]of Object.entries(l.layers)){let f=c[u]?.layers?.data(d);f&&Ct.patch(f,p)}}}).data),s}function e(i,a){let s,c=[],u={orthographic:0,perspective:0,geometry:0};function l(d,p){for(let[f,m]of Object.entries(p.layers)){let{texture:h,...y}=m;if(h!==void 0&&Object.keys(h).length>0){let g={path:[...d,"layers",f,"texture"],props:h,type:0};c.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};c.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")c.push(...ll.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")l(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))l(["materials",f],m);else if(u[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};c.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};c.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},c.push(s)),s.props[d]=p;return c}o.toOps=e;function t(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ni.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})}),ir.is(i.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let c=a;c.orthographic?.zoom!==void 0&&(s.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(s.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(s.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:ml.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=r(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Cr.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Cr.merge(s.cloner,a.cloner)});else if(cl.is(i.type)){let c=a;c.intensity!==void 0&&(s.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?s.color=c.color:s.color=ct.clone(c.color))}return s}o.patch=t})(en||(en={}));var si;(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,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(si||(si={}));var Ir;(r=>r.defaultData={orbitControls:si.defaultData,playPage:Oo,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})(Ir||(Ir={}));var pd;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(pd||(pd={}));var fd;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(fd||(fd={}));var Io;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...pd.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:fd.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Io||(Io={}));var Oh;(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 c=li.getComponentData(t,s.component)?.data;c&&i(a,s,c.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(Oh||(Oh={}));var Mo;(s=>{s.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let u=[],l=bl.defaultMeshObject;c.withLight===!0&&u.push({fi:-1,data:vl.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),c.withSquare===!0&&u.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:l,children:[]});let d=new Fe;return d.push({fi:1,id:Oo,data:{...eo.defaultData,name:"Scene 1"},children:u}),d}s.defaultData={objects:r(),publish:Ir.defaultData,styles:Io.defaultData()},s.emptyDataWithoutPage=function(){return{objects:new Fe,publish:Ir.defaultData,styles:Io.defaultData()}},s.emptyDataWithPage=function(c){return{objects:r(c),publish:Ir.defaultData,styles:Io.defaultData()}};function i(c){return{...s.defaultData,objects:Dt(c,Fe.prototype)}}s.withObjs=i;function a(c,u){return i([{id:c,data:u,children:[],fi:0}])}s.withObj=a})(Mo||(Mo={}));var ci;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ci||(ci={}));var di;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(di||(di={}));var Sl;(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})(Sl||(Sl={}));var md;(r=>r.all=["images","videos","colors","audios","fonts","materials","variables"])(md||(md={}));var Ah;(r=>r.all=[...md.all,"components"])(Ah||(Ah={}));var Ch;(r=>{function n(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe}}r.defaultData=n})(Ch||(Ch={}));var Eo;(r=>{function n(){return{images:new fe,videos:new fe,colors:new fe,audios:new fe,fonts:new fe,materials:new fe,components:new fe,variables:new fe}}r.defaultData=n})(Eo||(Eo={}));var ar;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Dt(a,fe.prototype)}i.defaultColors=n;function r(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...di.emptyImage,name:"AI generated image"}),Dt(s,fe.prototype)}i.defaultImages=r;function e(){return{catelogs:new fe,materials:new fe,images:new fe,videos:new fe,colors:new fe,audios:new fe,fonts:new fe,variables:new he,lib:Eo.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 c=Math.floor(a/3600),u=Math.floor((a-c*3600)/60),l=Math.round(a-c*3600-u*60);return{textValue:[c,u,l]}}else if(s.format==="mm:ss"){let c=Math.floor(a/60),u=Math.round(a-c*60);return{textValue:[c,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(ar||(ar={}));import{MathUtils as _l}from"three";var wl;(r=>r.list=["idle","move","jump","run"])(wl||(wl={}));var Tl;(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 he,move:new he,jump:new he,run:new he},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:At.fromHexAndA(3728051,1)}}))(Tl||(Tl={}));function Nh(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={...nr(We(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={...We(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function to(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function ro(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=gt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=gt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=gt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&r(o.material)})})}function JT(n){Object.assign(n.scene.publish,{orbitControls:{...si.defaultData,...We(n.scene.publish.orbitControls)}})}function e_(n){Object.assign(n.scene.publish.settings,{video:{...Ir.defaultData.settings.video,...We(n.scene.publish.settings.video)}})}function t_(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((wh.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(Th.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 r_(n){n.scene.publish.withBackground=!0}function o_(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function n_(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 i_(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 a_(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=We(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=We(e).booleanExclude!==!0)}})}function s_(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 l_(n){function r(t){Object.setPrototypeOf(t,Re.prototype),t.texture&&Object.setPrototypeOf(t.texture,Re.prototype)}function e(t){Object.setPrototypeOf(t,Re.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=We(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let c=a.materials[s],u=We(c).layers;e(u),c.layers=u}})})}function Ih(n){n.layers===void 0&&Object.assign(n,gt.defaultTwoLayerData("lambert"))}function hd(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={...We(r),colors:e,steps:t};Object.assign(r,o)}})}function c_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Mh(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&hd(t)}):"material"in e&&typeof e.material!="string"&&hd(e.material)}),Object.values(n.shared.materials).forEach(r=>hd(r))}function d_(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 u_(n){n.shared.audios=Dt({},fe.prototype)}function p_(n){n.shared.videos=Dt({},fe.prototype)}function f_(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 m_(n){Object.entries(We(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(We(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function h_(n){n.scene.publish.settings.web.preload=!1}function Eh(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 Lh(n){n.layers&&n.layers.forEach(r=>{Sh(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 y_(n){n.shared.fonts=Dt({},fe.prototype)}function g_(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 x_(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=gt.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=g_(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let c={name:o.name,...xt.defaultData,...Qo.defaultData,flatShading:!1,wireframe:!1,geometry:{...No.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:We(o.states),events:We(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=We(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:c,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function v_(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 he,move:new he,jump:new he}});else{let i=new he;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:_l.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},l={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(l,nr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(l,{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,...l},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new he({fi:0,id:_l.generateUUID(),data:u},{fi:1,id:_l.generateUUID(),data:p})};i.push({fi:c,id:s,data:f})}),delete o.targets)}})})}function b_(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let a=new he,s=[];if(e.events.forEach((c,u,l)=>{if(c.type==="Audio"&&c.trigger===i){let d;s.push(u),c.interaction==="play"?d={...nr(c,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in c?c.after:void 0,toggle:"after"in c?c.toggle:void 0,type:"Audio"}:(c.interaction==="pause"||c.interaction==="stop")&&(d={...nr(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:l,id:u,data:d})}}),s.forEach(c=>e.events.delete(c)),a.length){let c=e.events.find(u=>u.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:_l.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Dh(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Ct.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function Bh(n){to(n,Dh),ro(n,Dh)}function S_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function w_(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 T_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=gt.defaultTwoLayerData("phong"))})}function __(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 P_(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 O_(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 A_(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function C_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function N_(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function I_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=Tl.defaultDataThirdPerson.navmesh)})})}function M_(n){n.scene.styles||(n.scene.styles=Io.defaultData())}function Rh(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function E_(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}),ro(n,Rh),to(n,Rh)}function L_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new he})})})}function D_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Gh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function Vh(n,r){if(r<1&&(ro(n,Nh),to(n,Nh),n.schema=1),r<2&&(JT(n),n.schema=2),r<3&&(t_(n),n.schema=3),r<4&&(r_(n),n.schema=4),r<5&&(o_(n),n.schema=5),r<6&&(n_(n),n.schema=6),r<7&&(i_(n),n.schema=7),r<8&&(n.schema=8),r<9&&(Mh(n),n.schema=9),r<10&&(c_(n),n.schema=10),r<11&&(d_(n),n.schema=11),r<12&&(Mh(n),n.schema=12),r<13&&(u_(n),n.schema=13),r<14&&(f_(n),n.schema=14),r<15&&(m_(n),n.schema=15),r<16&&(h_(n),n.schema=16),r<17&&(ro(n,Eh),to(n,Eh),n.schema=17),r<18&&(ro(n,Ih),to(n,Ih),n.schema=18),r<19&&(e_(n),n.schema=19),r<20&&(y_(n),x_(n),n.schema=20),r<21&&(v_(n),b_(n),n.schema=21),r<22&&(Bh(n),n.schema=22),r<23&&(S_(n),n.schema=23),r<24&&(w_(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(p_(n),r<25&&(n.schema=25)),r<26&&(a_(n),n.schema=26),r<27&&(s_(n),n.schema=27),r<28&&(Bh(n),n.schema=28),r<29&&(l_(n),n.schema=29),r<30&&(T_(n),n.schema=30),r<31&&(__(n),n.schema=31),r<33&&(P_(n),n.schema=33),r<34&&(O_(n),n.schema=34),r<35&&(A_(n),n.schema=35),r<36&&(C_(n),n.schema=36),r<37&&(N_(n),n.schema=37),r<38&&(ro(n,Lh),to(n,Lh),n.schema=38),r<39&&(I_(n),n.schema=39),r<40&&(M_(n),n.schema=40),r<41&&(E_(n),n.schema=41),r<42&&(L_(n),n.schema=42),r<43&&(D_(n),n.schema=43),r<99){ro(n,Gh),to(n,Gh),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Po);let e=We(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=Oo,t.insertBefore(null,null,[{id:Oo,data:{...eo.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:nr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:nr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ia.defaultData,...nr(n.scene.environment,"usePhysics","gravity")},camera:We(n.scene.ownerCamera)??eo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Mo.TRASH_CAN_ID&&t.move(Oo,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,Co.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function zh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function B_(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"))})}var ui=180/Math.PI;function jh(n){n.rotation=n.rotation.slice(0,3).map(r=>r*ui)}function Fh(n){jh(n),n.type==="Page"&&jh(n.camera),n.states.forEach(e=>{e.rotation!==void 0&&(e.rotation=e.rotation.slice(0,3).map(t=>t*ui))});let r=n.geometry;r&&r.type==="SphereGeometry"&&(r.thetaLength=r.thetaLength*ui),r&&r.type==="TorusGeometry"&&(r.arc=r.arc*ui),r&&r.type==="PathGeometry"&&(r.extrusion.angle*=ui,r.extrusion.twist*=ui),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),n.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Once")})}function R_(n){n.shared.variables=Dt({},fe.prototype)}function G_(n){let r=We(n.shared.variables);n.shared.variables=Dt(Object.entries(r??{}).map(([e,t],o)=>({fi:o,id:e,data:t})),he.prototype)}var oo=107;function kh(n,r){r(n.data);for(let e of n.children)kh(e,r)}function V_(n){let r=n.schema??104;r!==oo&&r<105&&(kh(n.asset,Fh),n.schema=105)}function Pl(n){let r=n.schema??0;if(r!==oo){console.warn("updating from ",r,"to ",oo),Vh(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Ir.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(ro(n,zh),to(n,zh),n.schema=101),r<102&&(B_(n),n.schema=102),r<104&&(n.shared.catelogs=new fe,n.shared.lib=Eo.defaultData(),n.schema=104),r<105&&(R_(n),n.scene.objects.traverse((e,t)=>{Fh(t)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))V_(e);r<106&&(G_(n),n.schema=106),r<107&&(n.shared.lib.variables=Eo.defaultData().variables,n.schema=107)}}var li;(s=>{s.defaultData={schema:oo,scene:Mo.defaultData,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ci.defaultData),shared:{...ar.emptyData(),colors:ar.defaultColors()}},s.emptyDataForImports=function(c){let u=Mo.emptyDataWithPage(c);return{schema:oo,scene:u,frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ci.defaultData),shared:{...ar.emptyData(),colors:ar.defaultColors(),images:ar.defaultImages(c)}}},s.emptyData=function(){return{schema:oo,scene:Mo.emptyDataWithPage(),frames:new fe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ci.defaultData),shared:ar.emptyData()}},s.collabHelper={..._a,updateSchema(c){return(c.schema??0)<oo?vo(c,Pl):(c.schema??0)-oo}};function o(c){let u=s.collabHelper.updateSchema(c);return typeof u=="number"?u===0?c:null:u.data}s.updateSchemaDirectly=o;function i(c){return{...c,shared:{...c.shared,lib:Eo.defaultData()}}}s.withoutLib=i;function a(c,u){let l=c.scene.objects.get(u);if(l&&l.data.type==="Component")return l;{let d=c.shared.lib.components[u];if(d)return d.asset}}s.getComponentData=a})(li||(li={}));var aa=ga(Hh());import{Object3D as MC,Vector3 as Xt,Euler as Ku,MathUtils as S0,Matrix4 as wn}from"three";var z_=.5*(Math.sqrt(3)-1),Ma=(3-Math.sqrt(3))/6,j_=1/3,Mr=1/6,eF=(Math.sqrt(5)-1)/4,tF=(5-Math.sqrt(5))/20,Ea=n=>Math.floor(n)|0,Wh=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]),gd=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 Ol(n=Math.random){let r=$h(n),e=new Float64Array(r).map(o=>Wh[o%12*2]),t=new Float64Array(r).map(o=>Wh[o%12*2+1]);return function(i,a){let s=0,c=0,u=0,l=(i+a)*z_,d=Ea(i+l),p=Ea(a+l),f=(d+p)*Ma,m=d-f,h=p-f,y=i-m,g=a-h,x,S;y>g?(x=1,S=0):(x=0,S=1);let w=y-x+Ma,b=g-S+Ma,T=y-1+2*Ma,_=g-1+2*Ma,v=d&255,N=p&255,P=.5-y*y-g*g;if(P>=0){let A=v+r[N],M=e[A],L=t[A];P*=P,s=P*P*(M*y+L*g)}let C=.5-w*w-b*b;if(C>=0){let A=v+x+r[N+S],M=e[A],L=t[A];C*=C,c=C*C*(M*w+L*b)}let O=.5-T*T-_*_;if(O>=0){let A=v+1+r[N+1],M=e[A],L=t[A];O*=O,u=O*O*(M*T+L*_)}return 70*(s+c+u)}}function qh(n=Math.random){let r=$h(n),e=new Float64Array(r).map(i=>gd[i%12*3]),t=new Float64Array(r).map(i=>gd[i%12*3+1]),o=new Float64Array(r).map(i=>gd[i%12*3+2]);return function(a,s,c){let u,l,d,p,f=(a+s+c)*j_,m=Ea(a+f),h=Ea(s+f),y=Ea(c+f),g=(m+h+y)*Mr,x=m-g,S=h-g,w=y-g,b=a-x,T=s-S,_=c-w,v,N,P,C,O,A;b>=T?T>=_?(v=1,N=0,P=0,C=1,O=1,A=0):b>=_?(v=1,N=0,P=0,C=1,O=0,A=1):(v=0,N=0,P=1,C=1,O=0,A=1):T<_?(v=0,N=0,P=1,C=0,O=1,A=1):b<_?(v=0,N=1,P=0,C=0,O=1,A=1):(v=0,N=1,P=0,C=1,O=1,A=0);let M=b-v+Mr,L=T-N+Mr,X=_-P+Mr,R=b-C+2*Mr,Z=T-O+2*Mr,z=_-A+2*Mr,V=b-1+3*Mr,W=T-1+3*Mr,$=_-1+3*Mr,Y=m&255,q=h&255,k=y&255,U=.6-b*b-T*T-_*_;if(U<0)u=0;else{let D=Y+r[q+r[k]];U*=U,u=U*U*(e[D]*b+t[D]*T+o[D]*_)}let B=.6-M*M-L*L-X*X;if(B<0)l=0;else{let D=Y+v+r[q+N+r[k+P]];B*=B,l=B*B*(e[D]*M+t[D]*L+o[D]*X)}let F=.6-R*R-Z*Z-z*z;if(F<0)d=0;else{let D=Y+C+r[q+O+r[k+A]];F*=F,d=F*F*(e[D]*R+t[D]*Z+o[D]*z)}let j=.6-V*V-W*W-$*$;if(j<0)p=0;else{let D=Y+1+r[q+1+r[k+1]];j*=j,p=j*j*(e[D]*V+t[D]*W+o[D]*$)}return 32*(u+l+d+p)}}function $h(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}import{Triangle as F_}from"three";var sr=new F_,Al=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;sr.a.fromBufferAttribute(r,o),sr.b.fromBufferAttribute(r,o+1),sr.c.fromBufferAttribute(r,o+2),i*=sr.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),sr.a.fromBufferAttribute(this.positionAttribute,r*3),sr.b.fromBufferAttribute(this.positionAttribute,r*3+1),sr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(sr.a,o).addScaledVector(sr.b,i).addScaledVector(sr.c,1-(o+i)),sr.getNormal(t),this}};import{Object3D as q_}from"three";var Kh=ga(Xh());import{Object3D as k_,Matrix4 as Er}from"three";var U_=new Er,H_=new Er,W_=new Er,pi;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(pi||(pi={}));var fi=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Er;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Er;this.matrixWorldRigid=new Er;this.shearScale=new Er;this.shearScaleInv=new Er}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof k_&&(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)pi.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)pi.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,Kh.SVD)(o),c=U_.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=H_.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),l=W_.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,l).copyPosition(this.matrixWorld),s.every(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Er().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Er?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,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var xd=class extends fi(q_){},$_=n=>n.type==="Mesh",no=class extends xd{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 no(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 $_(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};import{Box3 as eA,BufferGeometry as tA,MeshBasicMaterial as rA}from"three";import{Matrix4 as QO,Mesh as JO}from"three";import{Matrix4 as Il,Vector3 as Jh,Euler as J_,MathUtils as Da}from"three";import{Box3 as Y_,Line3 as X_,Matrix4 as vd,Vector3 as qt}from"three";var tn=new qt,rn=new qt,mi=new vd,Qh=[new qt(-1,1,1),new qt(-1,-1,1),new qt(1,-1,1),new qt(1,1,1),new qt(-1,1,-1),new qt(-1,-1,-1),new qt(1,-1,-1),new qt(1,1,-1)],K_=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Z_=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Zh=(n,r,e)=>{n.updateEntityBoxSize(tn,rn),mi.copy(r).multiply(n.matrixWorld),rn.x===0&&rn.y===0&&rn.z===0?e.push(new qt(tn.x,tn.y,tn.z).applyMatrix4(mi)):Qh.forEach(t=>{e.push(t.clone().multiply(rn).add(tn).applyMatrix4(mi))})},La=class extends Y_{constructor(){super(...arguments);this.matrix=new vd;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 vd().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 qt);return}Zh(a,t,i)}}):Zh(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(mi.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(rn).multiplyScalar(.5),this.getCenter(tn),mi.copy(this.matrix).setPosition(tn),this.vertices=Qh.map(e=>e.clone().multiply(rn).applyMatrix4(mi))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=K_.map(([e,t])=>new X_(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new qt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Z_.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var lr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as Q_,CubicBezierCurve3 as bd,Vector3 as cr}from"three";var wd=class extends Q_{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,c=this.curves;s<c.length;s++){let u=c[s],l=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(r*l/a),p=u.getPoints(d);for(let f=0;f<p.length;f++){let m=p[f];t&&t.equals(m)||(e.push(m),t=m)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var Td=.001;function _d(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Td}function Sd(n,r){let e=new cr(...n.position),t=new cr(...n.controlNext.position),o=new cr(...r.controlPrevious.position),i=new cr(...r.position);return _d(e,t,i)&&_d(e,o,i)}function Nl(n){let r=n.points.map(l=>new cr(...l.data.position)),e=[n.points[0]],t=new cr(...e[0].data.position);for(let l=0;l<n.points.length-1;l++)_d(t,r[l],r[l+1])||(e.push(n.points[l]),t=r[l]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let l=0;l<a;l++){let d=e[l].data,p=new cr(...d.position),f=new cr(...d.controlPrevious.position),m=new cr(...d.controlNext.position),h={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!n.isClosed&&(l===0||l===a-1)){s[l]={...h,removedLength:0};continue}let y=o&&l==0?a-1:l-1,g=o&&l==a-1?0:l+1,x=e[y].data,S=e[g].data,w=new cr(...x.position),b=new cr(...S.position),T=w.clone().sub(p).normalize(),_=b.clone().sub(p).normalize();Object.assign(h,{prevDir:T,nextDir:_});let v=Sd(x,d),N=Sd(d,S);if(!v||!N)s[l]={...h,removedLength:0};else{let P=T.clone().add(_).normalize(),C=P.clone().cross(T).length()/T.dot(P);s[l]={...h,tan:C,removedLength:d.roundness/C}}}for(let l=0;l<i;l++){let d=l,p=o&&l===a-1?0:l+1,f=s[d],m=s[p];if(f.removedLength!==0||m.removedLength!==0){let h=f.position.distanceTo(m.position);f.removedLength=Math.min(f.removedLength,h/2),m.removedLength=Math.min(m.removedLength,h/2)}}let c=[];for(let l=0;l<i;l++){let d=l,p=o&&l===a-1?0:l+1,f=s[d],m=s[p],h=null;if(!Sd(e[d].data,e[p].data))f.position.distanceTo(m.position)>Td&&(h=new bd(f.position,f.controlNext,m.controlPrevious,m.position));else{let y=f.position.clone(),g=m.position.clone();(f.removedLength!==0||m.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),m.prevDir&&g.add(m.prevDir.clone().setLength(m.removedLength))),y.distanceTo(g)>Td&&(h=new bd(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*l+1]=h}for(let l=0;l<a;l++){let d=s[l];if(d.removedLength===0){c[2*l]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),m=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),h=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(m,.5),x=f.distanceTo(m)/2,S=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(x,2))).add(g),w=y.clone().multiplyScalar(-h).add(S),b=p.distanceTo(w)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),_=T.clone().lerp(w,2),v=f.clone().lerp(T,4/3),N=m.clone().lerp(_,4/3);c[2*l]=new bd(f,v,N,m)}let u=new wd;return c.forEach(l=>{l&&u.add(l)}),u}var Te;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Te||(Te={}));var hi=n=>Te.is(n),eP={type:"completeState",isfromEntity:!0},tP=["x","y","z"],Pd=new Jh,rP=new Jh().set(0,1,0),yi=n=>class extends fi(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 La;this._recursiveBBox=new La;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(Te.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Te.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(Te.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)en.toOps(this.data,a.data).forEach(c=>{let u=qs.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(t!==null){let a=this.data.states.data(t);a&&(this.dataPatched=en.patch(this.data,a),en.toOps(this.data,a).forEach(c=>{this.updateByPatchedOp(c,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=>{hi(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(Te.is(o[i]))return o[i];if(Te.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Te.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)hi(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Te.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)hi(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)hi(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)hi(o)&&o.visible&&o.traverseVisibleEntity(t)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}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=>hi(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*Da.RAD2DEG,this.rotation.y*Da.RAD2DEG,this.rotation.z*Da.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return $n(o,t)}getTransformValues(t,o,i){return o[t].map((a,s)=>i?.shared.getVariable(a,[this.uuid,t,tP[s]])??a)}updateTransformState(t,o){let i=!1;return t.position&&(this.position.fromArray(this.getTransformValues("position",t,o)),i=!0),t.rotation&&(Pd.fromArray(this.getTransformValues("rotation",t,o)).multiplyScalar(Da.DEG2RAD),this.rotation.setFromVector3(Pd),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??_o.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)Te.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Te.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return $n(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 c=t,u=_t(t.path,["states","*"]);if(u!==null){if(t.type===0){let[l]=u;if(this?.stateSelection===l){let d={...t.props};if(delete d.name,Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Je.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(d[m]=f[m])}}c={...t,props:d,path:t.path.slice(2)}}}}else if(t.type===0){let l=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(l!==void 0){if(t.props.name!==void 0&&l.name){let{name:p,...f}=l;l=f}if(t.props.material!==void 0&&"material"in l){let{material:p,...f}=l;l=f}let d=Je.removeOverridden(t.path,t.props,l);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,en.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),_t(t.path,["overrides"])){let l=[],d=[...t.path];for(l.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)l.push(d[1]),d.splice(0,2);if(l[l.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){l[l.length-1]=p;let f=i.scene.findInstance([this.uuid,...l]);f&&(f.overrideData=t.props[p],f.updateState(Tr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...l]);if(p){let f=Je.zoom(p.component.data,d);if(t={...t,path:d},t.type===0){let m=t.props;if(f)for(let[h,y]of Object.entries(t.props))y===void 0&&(m===t.props&&(m={...t.props}),m[h]=f[h]);t={...t,props:m}}p.overrideData=ii.resolve(o.overrides,l),p.updateByOp(t,et.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let d;for(let p of Nr.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(l={...t,props:d})}else for(let d of Nr.rootOverrideProps)if(_t(t.path,[d])){l=t;break}l!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Tr.filterOp(d.overrideData,l);p&&d.updateByOp(p,et.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Tr.filterOp(d.overrideData,t);if(p){let f;s===d.data&&t===p?f=o:f=et.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(t,o,i){if(this.dataPatched=o,t.path.length===0&&t.type===0)t.props.type!==void 0&&!ir.is(t.props.type)&&lr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){lr.changeEntityProptotype(this,o,i);for(let a of this.children)Te.is(a)&&a.updateVisible()}this.updateByPatchedOp(t,o,i)}updateByPatchedOp(t,o,i){if(t.path.length===0&&t.type===0&&this.updateState(t.props,i),_t(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),_t(t.path,["cloner"])!==null){let a=et.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()}}updatePathSnapping(t){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,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let c=t.find(o);if(!c||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let u=c.data;if(u.geometry.path.points.length<=1)return;let l=Nl(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=l.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new Il;c.updateMatrixWorld();let m=new Il().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new Il().extractRotation(c.matrixWorld),g=l.getTangentAt(d).applyMatrix4(y).add(p),x=new Il().lookAt(p,g,rP),S=Pd.setFromEuler(new J_().setFromRotationMatrix(x)).multiplyScalar(Da.RAD2DEG);h={...h,rotation:S.toArray()}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(eP)})}updateVisible(){this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0)}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(),this.resetBBoxNeedsUpdate()),o&&"cloner"in t&&t.cloner!==void 0&&(this.setFromClonerState(t.cloner,o),this.updateVisible()),this.updateTransformState(t,o)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof lr.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 lr.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)}};import{BufferGeometry as iP,ConeGeometry as aP,Float32BufferAttribute as sP,MathUtils as lP}from"three";import{BufferGeometry as ty,CylinderGeometry as oP,Float32BufferAttribute as El,MathUtils as nP,Vector2 as dr,Vector3 as Ml}from"three";var ry=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=nP.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:c,radiusTop:u,radiusBottom:l,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return c===0?(m=new ty,m.setAttribute("position",new El([],3))):d||f?m=new Ba(u,l,t,o,i,a,s,c*Math.PI/180,d,d,p,f):m=new oP(u,l,t,o,i,a,s,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Lo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function ey(n){return new dr(n.y,-n.x)}var Ba=class extends ty{constructor(r,e,t,o,i,a,s,c,u,l,d,p,f=!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,c=c!==void 0?c:Math.PI*2,a&&(u=0,l=0);let m=[],h=[],y=[],g=[],x=0,S=t/2,w=new Ml,b=new Ml;f&&r==0&&(r=u),f&&e==0&&(e=l);let T=new dr(r,S),_=new dr(e,-S),v=null,N=null,P=null,C=null,O=T.clone().sub(_),A=0,M=0,L=0;p>0&&(A=Math.min(r,e)*(1-p),M=r-A,L=e-A);let X=T.clone();X.x-=A;let R=Math.PI-O.angle(),Z=O.angle(),z=Math.tan(Z/2),V=Math.tan(R/2),W=z+V,$=p?W:V,Y=p?W:z;if(u=Math.min(u,(r-M)/$,O.length()/W),l=Math.min(l,(e-L)/Y,O.length()/W),u>0){let j=u/z;v=T.clone().sub(new dr(j,u)),p&&(P=v.clone(),P.x-=A-W*u),T.sub(O.clone().setLength(j))}if(l>0){let j=l/V;N=_.clone().sub(new dr(j,-l)),_.add(O.clone().setLength(j)),p&&(C=N.clone(),C.x-=A-W*l,X.sub(O.clone().setLength(j)))}O=T.clone().sub(_);let q=O.length()<.5,k=[];for(let j=0;j<=o;j++){let D=[],oe=j/o,ee=oe*c+s,K=new dr(Math.sin(ee),Math.cos(ee));C&&N?(U(D,oe,K,R,l,C,-1,!0),U(D,oe,K,Z,l,N,-1,!1)):N?(B(D,K,N.x,0,-1),U(D,oe,K,Z,l,N,-1,!1)):a||B(D,K,e,L,-1);let te=ey(O).normalize();if(Lo(te,K,w),!q)for(let Q=0;Q<=i;Q++){let se=Q/i,ne=O.clone().multiplyScalar(se).add(_);Lo(ne,K,b),h.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(oe,.5+b.y/t),D.push(x++)}if(P&&v?(U(D,oe,K,R,u,v,1,!1),U(D,oe,K,Z,u,P,1,!0)):v?(U(D,oe,K,R,u,v,1,!1),B(D,K,v.x,0,1)):a||B(D,K,r,M,1),p&&!q){let Q=ey(O).multiplyScalar(-1).normalize();Lo(Q,K,w);for(let se=0;se<=i;se++){let ne=se/i,ie=O.clone().multiplyScalar(-ne).add(X);Lo(ie,K,b),h.push(b.x,b.y,b.z),y.push(w.x,w.y,w.z),g.push(oe,.5+b.y/t),D.push(x++)}}p&&!a&&D.push(D[0]),k.push(D)}for(let j=0;j<k.length-1;j++)for(let D=0;D<k[0].length-1;D++){if(a&&p&&D==i)continue;let oe=k[j][D],ee=k[j+1][D],K=k[j+1][D+1],te=k[j][D+1],Q=h[K*3+0],se=h[K*3+2];m.push(oe,ee,te),(Q!=0||se!=0)&&m.push(ee,K,te)}c<Math.PI*2&&(F(-1,k[0],s),F(1,k[k.length-1],s+c)),this.setIndex(m),this.setAttribute("position",new El(h,3)),this.setAttribute("normal",new El(y,3)),this.setAttribute("uv",new El(g,2));function U(j,D,oe,ee,K,te,Q,se){for(let ne=0;ne<d+1;ne++){let ie=ne/d,ce=Q<0?ie:1-ie;se&&(ce-=1),ce*=ee;let le=new dr(Math.sin(ce),Math.cos(ce)*Q),de=le.clone().multiplyScalar(K).add(te);Lo(de,oe,b),h.push(b.x,b.y,b.z),Lo(le,oe,w),y.push(w.x,w.y,w.z),g.push(D,.5+b.y/t),j.push(x++)}}function B(j,D,oe,ee,K){let te=new Ml,Q=new dr,se=[oe,ee];K<0&&se.reverse();for(let ne of se)Q.set(ne,S*K),Lo(Q,D,te),h.push(te.x,te.y,te.z),y.push(0,K,0),g.push(.5,.5),j.push(x++)}function F(j,D,oe){let ee=new dr(Math.sin(oe),Math.cos(oe)),K=new dr(-Math.cos(oe),Math.sin(oe)),te=new Ml,Q=j<0?(ie,ce,le)=>m.push(ie,ce,le):(ie,ce,le)=>m.push(ie,le,ce),se=new dr((r+e+M+L)/4,0);Lo(se,ee,te),h.push(te.x,te.y,te.z),y.push(K.x,0,K.y),g.push(.5,.5);let ne=x++;for(let ie of D){let ce=h.slice(ie*3,ie*3+3);h.push(...ce),y.push(K.x,0,K.y);let le=g.slice(ie*2,ie*2+2);g.push(...le),x++}for(let ie=ne+1;ie<x-1;ie++)Q(ne,ie,ie+1);Q(ne,x-1,ne+1)}}};var oy=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=lP.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:c,cornerRadiusTop:u,cornerRadiusBottom:l,cornerSegments:d}=n.parameters,p;return c===0?(p=new iP,p.setAttribute("position",new sP([],3))):u>0||l>0||c<360?p=new Ba(0,r/2,t,o,i,a,s,c*Math.PI/180,u,l,d,0,!0):p=new aP(r/2,t,o,i,a),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as cP,BufferGeometry as dP,Float32BufferAttribute as Od,Vector3 as Ra}from"three";var ny=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:c}=n.parameters,u;return s==0?u=new cP(r,e,t,o,i,a):u=new Cd(r,e,t,o,i,a,s,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Ad=Math.PI/2,Cd=class extends dP{constructor(r=1,e=1,t=1,o=1,i=1,a=1,s=0,c=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),c=Math.floor(c),s=Math.min(s,r/2,e/2,t/2);let l=[],d=[],p=[],f=[],m=0,h=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),x(1,1,1),x(-1,1,1),x(1,-1,1),x(-1,-1,1),x(1,1,-1),x(-1,1,-1),x(1,-1,-1),x(-1,-1,-1)),this.setIndex(l),this.setAttribute("position",new Od(d,3)),this.setAttribute("normal",new Od(p,3)),this.setAttribute("uv",new Od(f,2));function y(S,w,b,T,_,v,N,P,C,O,A){let M=(v-2*s)/C,L=(N-2*s)/O,X=v/2-s,R=N/2-s,Z=P/2,z=C+1,V=O+1,W=0,$=0,Y=new Ra;for(let q=0;q<V;q++){let k=q*L-R;for(let U=0;U<z;U++){let B=U*M-X;Y[S]=B*T,Y[w]=k*_,Y[b]=Z,d.push(Y.x,Y.y,Y.z),Y[S]=0,Y[w]=0,Y[b]=P>0?1:-1,p.push(Y.x,Y.y,Y.z),f.push(U/C),f.push(1-q/O),W+=1}}for(let q=0;q<O;q++)for(let k=0;k<C;k++){let U=m+k+z*q,B=m+k+z*(q+1),F=m+(k+1)+z*(q+1),j=m+(k+1)+z*q;l.push(U,B,j),l.push(B,F,j),$+=6}u.addGroup(h,$,A),h+=$,m+=W}function g(S,w,b,T,_,v,N,P,C,O,A){let M=(N-2*s)/O,L=N/2-s,X=P/2-s,R=C/2,Z=O+1,z=0,V=0,W=new Ra,$=new Ra;for(let Y=0;Y<c+1;Y++){let q=Y/c*Ad,k=Math.sin(q)*s,U=(1-Math.cos(q))*s,B=Math.sin(q),F=Math.cos(q);W[w]=(X+k)*_,W[b]=(R-U)*v,$[S]=0,$[w]=B*Math.sign(W[w]),$[b]=F*Math.sign(W[b]);for(let j=0;j<Z;j++){let D=j*M-L;W[S]=D*T,d.push(W.x,W.y,W.z),p.push($.x,$.y,$.z),f.push(j/O),f.push(0),z+=1}}for(let Y=0;Y<c;Y++)for(let q=0;q<O;q++){let k=m+q+Z*Y,U=m+q+Z*(Y+1),B=m+(q+1)+Z*(Y+1),F=m+(q+1)+Z*Y;l.push(k,U,F),l.push(U,B,F),V+=6}u.addGroup(h,V,A),h+=V,m+=z}function x(S,w,b){let T=new Ra,_=new Ra(r/2,e/2,t/2);_.subScalar(s);let v=[],N=S*w*b>0?(C,O,A)=>l.push(C,O,A):(C,O,A)=>l.push(C,A,O);for(let C=0;C<=c;C++){let O=[],A=Ad*(1-C/c),M=Math.cos(A),L=Math.sin(A),X=0;for(let R=0;R<=C;R++){let Z=Math.cos(X),z=Math.sin(X);T.x=M*Z,T.y=L,T.z=M*z;let V=_.clone().addScaledVector(T,s);d.push(S*V.x,w*V.y,b*V.z),p.push(S*T.x,w*T.y,b*T.z),f.push(0,0),O.push(m++),X+=Ad/C}v.push(O)}let P=v.length-1;for(let C=0;C<P;C++){let O=v[C],A=v[C+1],M=O.length-1;N(O[0],A[1],A[0]);for(let L=1;L<=M;L++)N(O[L-1],O[L],A[L]),N(O[L],A[L+1],A[L])}}}};import{BufferGeometry as uP,Float32BufferAttribute as Nd,Triangle as pP,Vector3 as io,Vector2 as Id}from"three";var Do=class extends uP{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],c=[],u=[];l(),d(),this.setAttribute("position",new Nd(s,3)),this.setAttribute("normal",new Nd(u,3)),this.setAttribute("uv",new Nd(c,2));return;function l(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new io,h=m.clone(),y=new pP,g=i*o,x=o-g,S=a+1,w=new io,b=(z,V)=>w.subVectors(z,V).normalize(),T=(z,V)=>Array(z).fill(void 0).map(V),_=T(r.length/3,(z,V)=>new io().fromArray(r,V*3).setLength(o)),v=[],N=1e6;for(let z=0;z<_.length;z++){let V=_[z],W=[],$,Y,q,k=1e10,U=-1;for(;(U=e.indexOf(z,U+1))!=-1;){let D=U-U%3;$=e[D+(U+1)%3],Y=e[D+(U+2)%3],q=V.distanceToSquared(_[$]),k=Math.min(k,q),W.push([$,Y,q])}k+=1e-6;let B=[],F=0,j=W.length;for(let D=0;D<j;D++){[$,Y,q]=W[F];let oe=v[$]?.includes(z)==!0;q<=k&&B.push($+ +oe*N),F=W.findIndex(ee=>ee[0]==Y)}v.push(B)}let P=[];{let z=0,V=0,W,$,Y=f==3;for(let q=0;q<=a;q++){W=q*(q+1)/2,$=(q+1)*(q+2)/2;for(let k=0;k<a-q;k++)[z,V]=[W+k+q+2,$+k+q+3],P.push(W,$,...Y?[V,W]:[z,$],V,z),[W,$]=[z,V];P.push(W,$,W+a+2)}}let C=m.clone(),O=m.clone(),A=m.clone(),M=m.clone(),L=m.clone(),X=[],R=T(_.length,()=>T(f,()=>m.clone()));for(let z=0;z<_.length;z++){m.copy(_[z]).normalize(),C.copy(m).multiplyScalar(x);let V=v[z];for(let B=0;B<V.length;B++){let F=V[B],j=V[(B+1)%f];y.setFromPointsAndIndices(_,z,F%N,j%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(C,R[z][B])}let W=[],$=[],Y=[],q=new io;a==0&&[...R[z]].reduce((B,F)=>B.add(F),q).multiplyScalar(1/f);for(let B=0;B<f;B++){let F=[],j=(B-1+f)%f,D=R[z][j],oe=R[z][B];m.copy(D).sub(C),h.copy(oe).sub(C);let ee=C.angleTo(m),K=m.angleTo(h),te=Math.cos(ee)*g;a==0?O.copy(q):O.copy(C).setLength(x+te),$.push(te);let Q=[O,D,oe];for(let se=0;se<2;se++){let ne=Q[se],ie=Q[se+1];M.subVectors(ne,C),L.subVectors(ie,C),A.crossVectors(M,L).normalize();for(let ce=0;ce<S;ce++){let le=[ee,K][se]*ce/S;m.copy(M).applyAxisAngle(A,le).add(C),W.push(m.clone()),se&&(b(m,C),F.push([ce==0?ne:m.clone(),w.clone()]))}se&&(b(ie,C),F.push([ie,w.clone()]))}Y.push(F)}X.push(Y);let k=2*S,U=2;for(let B=0;B<f;B++){let F=k*B,j=k*((B+1)%f),D=[W[F]];for(let ee=1;ee<S;ee++){M=W[F+ee],L=W[j+ee],D.push(M);for(let K=1,te=ee-U+1;K<=te;K++)m.lerpVectors(M,L,K/(te+1)),m.sub(C).setLength($[B]).add(C),D.push(m.clone());D.push(L)}for(let ee=0;ee<S;ee++)D.push(W[ee+S+F]);D.push(W[j+S]);let oe=P.map(ee=>D[ee]);s.push(...oe.map(ee=>[ee.x,ee.y,ee.z]).flat()),u.push(...oe.map(ee=>(b(ee,C),[w.x,w.y,w.z])).flat())}}let Z=[];for(let z=0;z<v.length;z++)for(let V=0;V<f;V++){let W=v[z][V];if(W<N){let $=v[W].findIndex(k=>k%N==z),Y=X[z][V],q=X[W][$];for(let k=0;k<S;k++){let U=Y[k],B=q[S-k],F=Y[k+1],j=q[S-(k+1)];[U,B,F,F,B,j].forEach(D=>{s.push(D[0].x,D[0].y,D[0].z),u.push(D[1].x,D[1].y,D[1].z)})}Z.push(Y[0][0],q[S][0],Y[S][0],q[0][0])}}for(;Z.length;){let z,V,W,$;[z,V]=Z.splice(0,2);let Y=[z];for(;z!=V;)Y.push(V),W=Z.indexOf(V),$=W%2,V=Z.splice(W-$,2)[1-$];w.subVectors(Y[0],Y[1]).cross(m.subVectors(Y[0],Y[2])).normalize();let q=w.dot(Y[0])<0;q&&w.negate();for(let k=1;k<=Y.length-2;k++)[Y[k+ +q],Y[k+1-+q],Y[0]].forEach(U=>{s.push(U.x,U.y,U.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new io;for(let _=0;_<s.length;_+=3){p.x=s[_+0],p.y=s[_+1],p.z=s[_+2];let v=b(p)/2/Math.PI+.5,N=T(p)/Math.PI+.5;c.push(v,1-N)}let f=new io,m=new io,h=new io,y=new io,g=new Id,x=new Id,S=new Id,w=(_,v,N,P)=>{P<0&&_.x===1&&(c[v]=_.x-1),N.x===0&&N.z===0&&(c[v]=P/2/Math.PI+.5)};for(let _=0,v=0;_<s.length;_+=9,v+=6){f.set(s[_+0],s[_+1],s[_+2]),m.set(s[_+3],s[_+4],s[_+5]),h.set(s[_+6],s[_+7],s[_+8]),g.set(c[v+0],c[v+1]),x.set(c[v+2],c[v+3]),S.set(c[v+4],c[v+5]),y.copy(f).add(m).add(h).divideScalar(3);let N=b(y);w(g,v+0,f,N),w(x,v+2,m,N),w(S,v+4,h,N)}for(let _=0;_<c.length;_+=6){let v=c[_+0],N=c[_+2],P=c[_+4],C=Math.max(v,N,P),O=Math.min(v,N,P);C>.9&&O<.1&&(v<.2&&(c[_+0]+=1),N<.2&&(c[_+2]+=1),P<.2&&(c[_+4]+=1))}function b(_){return Math.atan2(_.z,-_.x)}function T(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new Do(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as fP}from"three";var iy=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 Ga(r*.5,i,a):new fP(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Ga=class extends Do{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],c="DodecahedronGeometry";super(a,s,c,r,e,t),this.type=c}static fromJSON(r){return new Ga(r.radius,r.corner,r.cornerSides)}};import{Plane as _P,Shape as by,Vector2 as ao,Vector3 as PP,MathUtils as Gd,LineCurve as Vd,QuadraticBezierCurve as Sy,CubicBezierCurve as Rl}from"three";import{CubicBezierCurve as Ll,EllipseCurve as mP,LineCurve as Dl,LineCurve3 as hP,MathUtils as yP,QuadraticBezierCurve as Ed,SplineCurve as gP,Vector2 as Pt,Vector3 as ly}from"three";var Va=1e-12,gi=class{constructor(r){this.position=new Pt;this.startPosition=new Pt;this.uuid=yP.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 gi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},xi=class extends gi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new xi(this.parent).copy(this)}},ur=class extends gi{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new xi(this),new xi(this))}static create(e,t){let o=new ur(e,new Pt(...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 ur(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 Pt,t=new Pt){let[o,i]=this.computeTangents();return o&&i&&(ay(o,e),ay(i,t)),[e,t]}computeTangent(e=new Pt){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new Pt){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function ay(n,r=new Pt){let e=n.length();return r.set(-n.y/e,n.x/e)}var Ld=n=>n,vi=new Pt,Bl=new Pt,xP=new Pt,vP=new Pt,bP=new Pt,SP=new Pt,cy=new ly,dy=new ly;function uy(n){let r=new Pt;r.addVectors(n.v0,vi.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Pt;return e.addVectors(n.v2,Bl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Ll(n.v0,r,e,n.v2)}function za(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function wP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function TP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Dd(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 py(n,r,e){return sy(n,r)&&sy(r,e)&&Md(n.position,r.position,e.position)}function Md(n,r,e){return vi.copy(r).sub(n).cross(Bl.copy(e).sub(n))===0}function fy(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,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(s+c,a+u),o.set(s-c,a-u),[t,o]}function my(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function hy(n,r,e,t,o,i){let a=r.x-n.x,s=r.y-n.y,c=e.x-n.x,u=e.y-n.y,l=Math.sqrt((a+c)*(a+c)+(s+u)*(s+u)),d;return Dd(r,n,e)>Math.PI&&(l*=-1),za(u,s)?d=(s+u)*(t/l-.5)*8/3/(a-c):d=(a+c)*(t/l-.5)*8/3/(u-s),o.set(r.x-d*s,r.y+d*a),i.set(e.x+d*u,e.y-d*c),[o,i]}function Bd(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function sy(n,r){return Md(n.position,n.controls[1].position,r.position)&&Md(n.position,r.controls[0].position,r.position)}function yy(n,r,e,t,o=.5){let i=vi.subVectors(r,n).multiplyScalar(o).add(n),a=Bl.subVectors(e,r).multiplyScalar(o).add(r),s=xP.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=vP.subVectors(a,i).multiplyScalar(o).add(i),l=bP.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=SP.subVectors(l,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,l.x,l.y,d.x,d.y,t.x,t.y]}function gy(n,r,e=12,t=!0){let o=dy.set(0,0,0),i,a=0,s=[];for(let c=0;c<r.length;c++){let u=Ld(r[c]),l=vi,d=Bo(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof Ll||u instanceof Ed||u instanceof Dl){if(u.getPoint(p/d,l),o.set(l.x,l.y,0),i!==void 0&&TP(i,o))continue;i===void 0&&(i=cy),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 xy(n,r,e,t=12,o=!0){let i=dy.set(0,0,0),a=0,s=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,l=Ld(r[c]),d=vi,p=Bo(l,t);s.push(p);for(let f=0;f<=p;f++)if(l instanceof Ll||l instanceof Ed||l instanceof Dl){if(l.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=cy:(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 Rd(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 c=Bo(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),s+=c}a.curveAfter!==void 0&&(s+=Bo(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=Bo(n[0].roundedCurveCorner,r)*.5),t}function Bo(n,r=12){return n&&n instanceof mP?r*2:n&&(n instanceof Dl||n instanceof hP)?1:n&&n instanceof gP?r*n.points.length:r}function vy(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Ld(r[a]),c=Bo(s,e),u=vi;for(let l=0;l<=c;l++)if(s instanceof Ll||s instanceof Ed||s instanceof Dl){if(s.getPoint(l/c,u),o!==void 0&&wP(o,u,Va))continue;o===void 0&&(o=Bl),o.copy(u),n.push(u.x,u.y),i++}}return za(n[0],n[n.length-2],Va)&&za(n[1],n[n.length-1],Va)&&(n.pop(),n.pop()),t&&i>1&&!(za(n[i-1],n[1],Va)&&za(n[i-2],n[0],Va))&&(n.push(n[0],n[1]),i++),n}var zd=new ao,OP=new ao,AP=new ao,CP=new ao,NP=new ao,IP=new ao,Ce=class extends by{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new _P(new PP(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Gd.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Ce;return i.isClosed=e.isClosed,i.points=e.points.map(a=>ur.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>Ce.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 c=this.shapeHoles[a],u=c.points.length,l=c.getPointIndexById(e);if(l<0)i+=u;else return l+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=zd.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=Gd.generateUUID()){let i;e instanceof ao?i=e:i=new ao(e,t);let a=new ur(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 gy(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Rd(this.points,e,!1),this.roundedCurveDivisions=Rd(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return xy(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),vy(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=Bo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let l=i[c];if(s<o+l)return[c,(s-o+1)/l];o+=l}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,c=s[e];if(Bd(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(zd.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(t-u)/c}dispose(){}_applyCurveForPoint(e,t){Bd(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],c=this.points[o+1]??this.points[0],u=a.roundness,l=s&&c&&py(s,a,c);if(!a.controlsMoved()&&u>0&&!l){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,m=a.roundedCurveAfter,h=d.getLength(),y=p.getLength(),g=Math.min(u,h*.499),x=Math.min(u,y*.499),S=Math.min(g,x),w=1-S/h,b=S/y,T=d.getPointAt(w,zd),_=p.getPointAt(b,OP);this._subSplitCurve(d,f,w,T,void 0),this._subSplitCurve(p,m,b,void 0,_);let v;if(this.useCubicForRoundedCorners){let N=Dd(T,a.position,_)/2,P=Math.tan(N)*T.distanceTo(a.position),[C,O]=fy(T,_,P,AP,CP),A=my(C,O,a.position),[M,L]=hy(A,T,_,P,NP,IP);v=new Rl(T.clone(),M.clone(),L.clone(),_.clone())}else v=new Sy(T.clone(),a.position.clone(),_.clone());a.roundedCurveCorner=v,this.roundedCurves.splice(o+t,0,v),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Vd)i!==void 0&&t.v2.copy(i),a!==void 0&&t.v1.copy(a);else{let s=e,c=t,u=s.getUtoTmapping(o,0),l=yy(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(c.v0.set(l[0],l[1]),c.v1.set(l[2],l[3]),c.v2.set(l[4],l[5]),c.v3.set(l[6],l[7])),a!==void 0&&(c.v0.set(l[6],l[7]),c.v1.set(l[8],l[9]),c.v2.set(l[10],l[11]),c.v3.set(l[12],l[13])),c}return t}clone(){let e=new Ce(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],c=e.points[i+2],u=e.points[i+3],l=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new ur(Gd.generateUUID(),new ao(a,s));f.controls[0].position.set(c,u),f.controls[1].position.set(l,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Ce;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,a)=>{a instanceof Rl&&a.v3.equals(i.position)&&i.controls[0].position.copy(a.v2)},o=i=>{let a=[],s,c;for(s=0,c=i.length;s<c;s++)i[s]instanceof Sy&&(i[s]=uy(i[s]));for(s=0,c=i.length;s<c;s++){let d=i[s],p=s>0?i[s-1]:null,f;d instanceof Rl?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Vd&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),a.push(f))}let u=i[i.length-1],l=!1;return u instanceof Rl?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),l=!0):u instanceof Vd&&u.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a};return this.points=o(e.curves),e instanceof by&&(this.shapeHoles=e.holes.map(i=>{let a=new Ce;return a.fromShape(i),a})),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 Fd=Math.PI*2;function jd({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function MP(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 wy(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 EP(n,r,e,t,o,i,a,s,c,u){let l=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),m=l*d-l*f-d*p;m<0&&(m=0),m/=l*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*s,y=m*-i/o*a,g=h+(n+e)/2,x=y+(r+t)/2,S=(a-h)/o,w=(s-y)/i,b=(-a-h)/o,T=(-s-y)/i,_=wy(1,0,S,w),v=wy(S,w,b,T);return!u&&v>0&&(v-=Fd),u&&v<0&&(v+=Fd),{centerx:g,centery:x,ang1:_,ang2:v}}function Ty({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,l=(r-t)/2;if(u===0&&l===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(l,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=EP(n,r,e,t,o,i,u,l,a,s),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(Fd/4);Math.abs(1-g)<1e-7&&(g=1);let x=Math.max(Math.ceil(g),1);m/=x;for(let S=0;S<x;S++)c.push(MP(f,m)),f+=m;return c.map(S=>{let{x:w,y:b}=jd(S[0],o,i,h,y),{x:T,y:_}=jd(S[1],o,i,h,y),{x:v,y:N}=jd(S[2],o,i,h,y);return{x1:w,y1:b,x2:T,y2:_,x:v,y:N}})}import{BufferAttribute as Fl,BufferGeometry as kP}from"three";var _e;(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"})(_e||(_e={}));var ke;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(ke||(ke={}));function me(n,r){if(!n)throw r||"Assertion Failed!"}var ue=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){me(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){me(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){me(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){me(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,c;n.vertLeq(r,e)||(c=r,r=e,e=c),n.vertLeq(t,o)||(c=t,t=o,o=c),n.vertLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),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)||(c=r,r=e,e=c),n.transLeq(t,o)||(c=t,t=o,o=c),n.transLeq(r,t)||(c=r,r=t,t=c,c=e,e=o,o=c),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}(),ja=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}(),Gl=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}(),bi=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}(),_y=function(){function n(){var r=new bi,e=new ja,t=new Gl(0),o=new Gl(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 Gl(0),t=new Gl(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;me(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;me(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 bi,e=new bi,t=new ja,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 bi;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new ja;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 ja;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 bi;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 ja;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,c;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),c=this.countFaceVerts_(i.Lface),s+c-2<=r&&ue.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&ue.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,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){me(o.prev===i),c=o.anEdge;do me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c),me(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(me(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){me(a.prev===s),c=a.anEdge;do me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c),me(c.Org===a),c=c.Onext;while(c!==a.anEdge)}for(me(a.prev===s&&a.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)me(c.Sym.next===u.Sym),me(c.Sym!==c),me(c.Sym.Sym===c),me(c.Org!==null),me(c.Dst!==null),me(c.Lnext.Onext.Sym===c),me(c.Onext.Sym.Lnext===c);me(c.Sym.next===u.Sym&&c.Sym===this.eHeadSym&&c.Sym.Sym===c&&c.Org===null&&c.Dst===null&&c.Lface===null&&c.Rface===null)},n}(),Py=function(){function n(){this.handle=null}return n}(),Oy=function(){function n(){this.key=null,this.node=0}return n}(),LP=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 Py,this.handles[t]=new Oy;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,me(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 Py;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new Oy}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;me(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}(),kd=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}(),Ay=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),DP=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new Ay,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 Ay;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}(),BP=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?ue.vertLeq(i.Org,a.Org)?ue.edgeSign(a.Dst,i.Org,a.Org)<=0:ue.edgeSign(i.Dst,a.Org,i.Org)>=0:ue.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ue.edgeSign(i.Dst,o,i.Org)>=0;var s=ue.edgeEval(i.Dst,o,i.Org),c=ue.edgeEval(a.Dst,o,a.Org);return s>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&me(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){me(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 kd;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 _e.ODD:return(e&1)!==0;case _e.NONZERO:return e!==0;case _e.POSITIVE:return e>0;case _e.NEGATIVE:return e<0;case _e.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,c,u,l,d=!0;u=t;do me(ue.vertLeq(u.Org,u.Dst)),n.addRegionBelow(r,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),c=e,l=i;s=n.regionBelow(c),u=s.eUp.Sym,u.Org===l.Org;)u.Onext!==l&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(l.Oprev,u)),s.windingNumber=c.windingNumber-u.winding,s.inside=n.isWindingInside(r,s.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,l),n.deleteRegion(r,c),r.mesh.delete(l)),d=!1,c=s,l=u;c.dirty=!0,me(c.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=ue.vertL1dist(e,r),i=ue.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(ue.vertLeq(o.Org,i.Org)){if(ue.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ue.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(ue.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(me(!ue.vertEq(o.Dst,i.Dst)),ue.vertLeq(o.Dst,i.Dst)){if(ue.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(ue.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,c=o.Dst,u=i.Dst,l,d,p=new bi,f,m;if(me(!ue.vertEq(u,c)),me(ue.edgeSign(c,r.event,a)<=0),me(ue.edgeSign(u,r.event,s)>=0),me(a!==r.event&&s!==r.event),me(!e.fixUpperEdge&&!t.fixUpperEdge),a===s||(l=Math.min(a.t,c.t),d=Math.max(s.t,u.t),l>d))return!1;if(ue.vertLeq(a,s)){if(ue.edgeSign(u,a,s)>0)return!1}else if(ue.edgeSign(c,s,a)<0)return!1;return n.debugEvent(r),ue.intersect(c,a,u,s,p),me(Math.min(a.t,c.t)<=p.t),me(p.t<=Math.max(s.t,u.t)),me(Math.min(u.s,c.s)<=p.s),me(p.s<=Math.max(s.s,a.s)),ue.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=ue.vertLeq(a,s)?a:s,ue.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ue.vertEq(p,a)||ue.vertEq(p,s)?(n.checkForRightSplice(r,e),!1):!ue.vertEq(c,r.event)&&ue.edgeSign(c,r.event,p)>=0||!ue.vertEq(u,r.event)&&ue.edgeSign(u,r.event,p)<=0?u===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):c===r.event?(r.mesh.splitEdge(i.Sym),r.mesh.splice(o.Lnext,i.Oprev),t=e,e=n.topRightRegion(e),m=n.regionBelow(e).eUp.Rprev,t.eUp=i.Oprev,i=n.finishLeftRegions(r,t,null),n.addRightEdges(r,e,i.Onext,o.Rprev,m,!0),!0):(ue.edgeSign(c,r.event,p)>=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),ue.edgeSign(u,r.event,p)<=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=p.s,o.Org.t=p.t,o.Org.pqHandle=r.pq.insert(o.Org),n.getIntersectData(r,o.Org,a,c,s,u),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,c=a.eUp,u=!1;if(s.Dst!==c.Dst&&n.checkForIntersect(r,e),ue.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),u=!0),ue.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,a,null),u=!0),u){n.addRightEdges(r,e,t.Onext,i,i,!0);return}ue.vertLeq(c.Org,s.Org)?o=c.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,c;if(o=e.eUp,ue.vertEq(o.Org,t)){me(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!ue.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}me(!1),e=n.topRightRegion(e),c=n.regionBelow(e),a=c.eUp.Sym,i=s=a.Onext,c.fixUpperEdge&&(me(i!==a),n.deleteRegion(r,c),r.mesh.delete(a),a=i.Oprev),r.mesh.splice(t.anEdge,a),ue.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,a,s,c,u=new kd;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(a=t.eUp,s=o.eUp,ue.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=ue.vertLeq(s.Dst,a.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,a.Lnext);else{var l=r.mesh.connect(s.Dnext,e.anEdge);c=l.Sym}i.fixUpperEdge?n.fixUpperEdge(r,i,c):n.computeWinding(r,n.addRegionBelow(r,t,c)),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);me(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 kd,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 DP(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||(me(e.fixUpperEdge),me(++t===1)),me(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,ue.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 LP(i,ue.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,me(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||!ue.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}(),RP=function(){function n(){this.mesh=new _y,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=_e.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,c=[0,0,0],u=[0,0,0],l=[0,0,0],d=[0,0,0],p=[0,0,0],f=[null,null,null],m=[null,null,null],h=this.mesh.vHead;e=h.next;for(var y=0;y<3;++y)i=e.coords[y],u[y]=i,m[y]=e,c[y]=i,f[y]=e;for(e=h.next;e!==h;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,m[g]=e),i>c[g]&&(c[g]=i,f[g]=e);var x=0;if(c[1]-u[1]>c[0]-u[0]&&(x=1),c[2]-u[2]>c[x]-u[x]&&(x=2),u[x]>=c[x]){r[0]=0,r[1]=0,r[2]=1;return}for(s=0,t=m[x],o=f[x],l[0]=t.coords[0]-o.coords[0],l[1]=t.coords[1]-o.coords[1],l[2]=t.coords[2]-o.coords[2],e=h.next;e!==h;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]=l[1]*d[2]-l[2]*d[1],p[1]=l[2]*d[0]-l[0]*d[2],p[2]=l[0]*d[1]-l[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,r[0]=p[0],r[1]=p[1],r[2]=p[2]);s<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(l)]=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 c=!0,u=r.next;u!==r;u=u.next)c?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,c=!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(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(;ue.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ue.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(ue.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ue.edgeGoesLeft(o.Lnext)||ue.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&&(ue.edgeGoesRight(t.Lprev)||ue.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,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(l.n=-1,!!l.inside){i=l.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),c++,i=i.Lnext}while(i!==l.anEdge);if(c>t)throw"Face vertex greater that support polygon";l.n=a,++a}this.elementCount=a,e===ke.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 u=r.vHead.next;u!==r.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,l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){i=l.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==l.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===ke.CONNECTED_POLYGONS){i=l.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==l.anEdge);for(var m=c;m<t;++m)this.elements[p++]=-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 c=0,u=0,l=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[c++]=t.Org.coords[0],this.vertices[c++]=t.Org.coords[1],e>2&&(this.vertices[c++]=t.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,a++,t=t.Lnext;while(t!==o);this.elements[l++]=i,this.elements[l++]=a,i+=a}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new _y),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=_e.ODD),e===void 0&&(e=ke.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_(),BP.computeInterior(this,a);var s=this.mesh;return e===ke.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===ke.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,t,o),!0},n}();function pr(n){var r=n.windingRule,e=r===void 0?_e.ODD:r,t=n.elementType,o=t===void 0?ke.POLYGONS:t,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,c=s===void 0?2:s,u=n.normal,l=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,m=f===void 0?!0:f,h=n.debug,y=h===void 0?!1:h;if(!p&&m)throw new Error("Contours can't be empty");if(!!p){var g=new RP;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var x=0;x<p.length;x++)g.addContour(c||2,p[x]);return g.tesselate(e,o,a,c,l,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var Nk=_e.ODD,Ik=_e.NONZERO,Mk=_e.POSITIVE,Ek=_e.NEGATIVE,Lk=_e.ABS_GEQ_TWO,Dk=ke.POLYGONS,Bk=ke.CONNECTED_POLYGONS,Rk=ke.BOUNDARY_CONTOURS;import{BufferAttribute as jl,BufferGeometry as FP}from"three";var Vl=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*Vl.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*Vl.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*r);a+=3*r;let c=new Float32Array(o,a*i,3*r);a+=3*r;let u=new Float32Array(o,a*i,2*r);e?(s.set(this.positions.subarray(0,this.size*3)),c.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),c.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=c,this.uvs=u,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)}},Fa=Vl;Fa.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var My=ga(Iy()),ka={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},$d={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Yd={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},qd=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Go=class extends FP{constructor(e,t,o=0,i=12,a=3,s=_e.ODD,c=!1){super();this.forPathBevel=c;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),l=this._shape.shapeHoles.map(C=>{let O=C.extractShapePointsToFlatArray([],i),A=[];for(let M=O.length-1;M>=1;M-=2){let L=O[M-1],X=O[M-0];A.push(L,X)}return A}),d=[],p=[];for(let C=0;C<u.length;C+=2)p.push([u[C],u[C+1]]);d.push(p);for(let C=0;C<l.length;C++){let O=l[C],A=[];for(let M=0;M<O.length;M+=2)A.push([O[M],O[M+1]]);d.push(A)}let f=d[0].length?(0,My.default)(d).distance:o;o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,t/2),this._bevelSegments=Math.floor(a));let m;try{m=pr({windingRule:s,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{m=ka}let h;try{h=pr({windingRule:_e.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{h=$d}if(!m)throw new Error("error generating geometry");let y=m.elementCount;if(h){m.elementCount+=h.elementCount;for(let C=0;C<h.elements.length;C++){let O=h.elements[C],A=C%2===0?m.vertexCount:0;m.elements.push(O+A)}for(let C=0;C<h.vertexIndices.length;C++){let O=h.vertexIndices[C],A=m.vertexCount;m.vertexIndices.push(O+A)}for(let C=0;C<h.vertices.length;C++){let O=h.vertices[C];m.vertices.push(O)}}let g=1/0,x=-1/0,S=1/0,w=-1/0;for(let C=0,O=m.vertexCount;C<O;C++){let A=C*2,M=m.vertices[A+0],L=m.vertices[A+1];M<g&&(g=M),M>x&&(x=M),L<S&&(S=L),L>w&&(w=L)}this._minX=g,this._minY=S,this._width=x-g,this._height=w-S,this._buffer=new Fa(this._computeBufferEstimatedSize(m));let b=[],T=[];for(let C=m.elementCount-1;C>=0;C--){let O=C>=y,A=C*2,M=m.elements[A+0],L=m.elements[A+1],X=M+L,R={start:M,count:L,normals:[],continuous:[],concave:[]},Z=M,z=X-1,V=M+1,W=this._shape.roundedCurves.length;do{let U=Z-M,B=m.vertices[z*2+0],F=m.vertices[z*2+1],j=m.vertices[Z*2+0],D=m.vertices[Z*2+1],oe=m.vertices[V*2+0],ee=m.vertices[V*2+1],K=j-B,te=D-F,Q=Math.sqrt(K*K+te*te);K/=Q,te/=Q;let se=j-oe,ne=D-ee,ie=Math.sqrt(se*se+ne*ne);se/=ie,ne/=ie,R.normals[U*2+0]=-ne,R.normals[U*2+1]=se,R.concave[U]=K*ne-te*se>0;let ce=m.vertexIndices[Z];if(Array.isArray(ce))R.continuous[U]=!1;else{let[le,de]=this._shape.getCurveIndexFromVertexId(ce-1,!0);if(de>0&&de<1)R.continuous[U]=!0;else{let ye=de===1?le+1:le-1;ye=(ye+W)%W;let Pe=de===1?0:1,Ve=this._shape.roundedCurves[le].getTangent(de),Oe=this._shape.roundedCurves[ye].getTangent(Pe);R.continuous[U]=Ve.dot(Oe)>.95}}O&&(R.normals[U*2+0]*=-1,R.normals[U*2+1]*=-1),[z,Z,V]=[Z,V,V+1],V>=X&&(V-=L)}while(V!==M+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:m.vertices.slice(M*2,X*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((U,B)=>[B,B]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:m.vertices.slice(M*2,X*2)});let Y=0;for(let U=1;U<=this._bevelSegments;U++){let B=U/this._bevelSegments*Math.PI/2,F=(1-Math.cos(B))*this._bevel,j=[],D=[],oe=[],ee=[],K=0;for(let Q=0;Q<L;Q++){let se=Q*2,ne=(Q-1+L)%L*2,ie=m.vertices[R.start*2+se+0],ce=m.vertices[R.start*2+se+1],le=-R.normals[ne+0]*F,de=-R.normals[ne+1]*F,ye=-R.normals[se+0]*F,Pe=-R.normals[se+1]*F;if(R.concave[Q]||!R.concave[Q]&&O){let Ve=Math.atan2(de,le),Oe=Math.atan2(Pe,ye);Oe>Ve&&(Oe-=Math.PI*2);let Be=Oe-Ve;if(R.continuous[Q]||O){let Et=Ve+Be/2,be=Math.cos(Et)*F,tt=Math.sin(Et)*F;j[2*K+0]=ie+be*(O?-1:1),j[2*K+1]=ce+tt*(O?-1:1),ee[K]=Q,K++}else{let Et=Math.max(1,Math.floor(i/4*Math.abs(Be)/Math.PI));for(let be=0;be<=Et;be++){let tt=Ve+Be*(be/Et),at=Math.cos(tt)*F,_n=Math.sin(tt)*F;j[2*K+0]=ie+at,j[2*K+1]=ce+_n,ee[K]=Q,K++}}}else j[2*K+0]=ie+le,j[2*K+1]=ce+de,ee[K]=Q,D[Q]=K,K++,j[2*K+0]=ie,j[2*K+1]=ce,ee[K]=Q,K++,j[2*K+0]=ie+ye,j[2*K+1]=ce+Pe,ee[K]=Q,oe[Q]=K,K++}let te=pr({windingRule:_e.POSITIVE,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[j],edgeCreateCallback:Q=>{let ne=Q.Org.idx,ie=ee[ne],ce=ee[(ne+1)%ee.length];Q.idx=[ie,ce],Q.Sym.idx=[ce,ie]},vertexIdCallback:Q=>{let se=Q.Lprev.idx;return[se?se[1]:0,Q.idx?Q.idx[0]:0]}});if(!te)throw console.log("Error"),new Error(`error generating bevel geometry for ${U}'th loop`);if(!te.vertexCount){let Q=(U-1)/this._bevelSegments*Math.PI/2;Y=(1-Math.sin(Q))*this._bevel;break}for(let Q=0;Q<te.vertexIndices.length;Q++){let[se,ne]=te.vertexIndices[Q];if(se===ne)continue;let ie=ne;ne<se&&(ie+=L);for(let ce=se;ce<ie;ce++){let le=ce%L,de=(ce+1)%L;if(!R.continuous[le]||!R.continuous[de]){te.vertexIndices[Q]=[se,le],te.vertexIndices.splice(Q+1,0,[de,ne]),te.vertices.splice((Q+1)*2,0,te.vertices[Q*2],te.vertices[Q*2+1]);break}}}$.push({bevelI:U,angle:B,size:F,boundary:te,reverseMap:ee,insetPoints:j})}let q=(U,B,F)=>{let j=0,D=U.boundary.vertexIndices.length;for(;j<D&&F(U.boundary.vertexIndices[B]);)B=(B+1)%D,j++;return j},k=b.length;for(let U=1;U<$.length;U++){let B=$[U-1],F=$[U],j=B.boundary.vertexIndices.length,D=F.boundary.vertexIndices.length;if(!j||!D)break;let oe=R.concave.length,ee=0,K=qd(ee,L);for(;!B.boundary.vertexIndices.filter(K).length||!F.boundary.vertexIndices.filter(K).length;)ee++,K=qd(ee,L);let te=B.boundary.vertexIndices.findIndex(K),Q=F.boundary.vertexIndices.findIndex(K);do te=(te+1)%j;while(K(B.boundary.vertexIndices[te]));do Q=(Q+1)%D;while(K(F.boundary.vertexIndices[Q]));ee=(ee+1)%L;let se=ee,ne=0,ie=this._buildBevelVert(R,B,(te-1+j)%j,void 0,ne),ce=this._buildBevelVert(R,F,(Q-1+D)%D,void 0,ne),le=ie,de=ce,ye,Pe,Ve=!1;do{ne=(ee||oe)/oe,K=qd(ee,L);let Oe=q(B,te,K),Be=q(F,Q,K),Et=Ve;if(Ve=!1,Oe&&!Be){for(let be=0;be<Oe;be++)ye=this._buildBevelVert(R,B,(te+be)%j,be/(Oe-1),ne),b.push(le.topN,ye.topP,de.topN),c===!1&&b.push(ye.bottomP,le.bottomN,de.bottomN),le=ye;Ve=!0}else if(!Oe&&Be)for(let be=0;be<Be;be++)Pe=this._buildBevelVert(R,F,(Q+be)%D,be/(Be-1),ne),b.push(de.topN,le.topP,Pe.topP),c===!1&&b.push(le.bottomP,de.bottomN,Pe.bottomP),de=Pe;else if(Oe&&Be)if(ye=this._buildBevelVert(R,B,te,0,ne),Pe=this._buildBevelVert(R,F,Q,0,ne),Et?(b.push(le.topN,Pe.topP,de.topN),b.push(le.topN,ye.topP,Pe.topP),c===!1&&(b.push(Pe.bottomP,le.bottomN,de.bottomN),b.push(Pe.bottomP,ye.bottomP,le.bottomN))):(b.push(de.topN,le.topN,ye.topP),b.push(de.topN,ye.topP,Pe.topP),c===!1&&(b.push(ye.bottomP,le.bottomN,de.bottomN),b.push(ye.bottomP,de.bottomN,Pe.bottomP))),le=ye,de=Pe,Oe===Be)for(let be=1;be<Oe;be++)ye=this._buildBevelVert(R,B,(te+be)%j,be/(Oe-1),ne),Pe=this._buildBevelVert(R,F,(Q+be)%D,be/(Be-1),ne),b.push(le.topN,ye.topP,de.topN),b.push(de.topN,ye.topP,Pe.topP),c===!1&&(b.push(ye.bottomP,le.bottomN,de.bottomN),b.push(ye.bottomP,de.bottomN,Pe.bottomP)),le=ye,de=Pe;else if(Oe>Be){let be=Oe/Be,tt=0;for(let at=1;at<Oe;at++)ye=this._buildBevelVert(R,B,(te+at)%j,at/(Oe-1),ne),b.push(le.topN,ye.topP,de.topN),c===!1&&b.push(ye.bottomP,le.bottomN,de.bottomN),le=ye,at>(tt+1)*be&&(tt++,Pe=this._buildBevelVert(R,F,(Q+tt)%D,tt/(Be-1),ne),b.push(de.topN,ye.topP,Pe.topP),c===!1&&b.push(ye.bottomP,de.bottomN,Pe.bottomP),de=Pe)}else{let be=Be/Oe,tt=0;for(let at=1;at<Be;at++)Pe=this._buildBevelVert(R,F,(Q+at)%D,at/(Be-1),ne),b.push(de.topN,ye.topP,Pe.topP),c===!1&&b.push(ye.bottomP,de.bottomN,Pe.bottomP),de=Pe,at>(tt+1)*be&&(tt++,ye=this._buildBevelVert(R,B,(te+tt)%j,tt/(Oe-1),ne),b.push(le.topN,ye.topP,de.topN),c===!1&&b.push(ye.bottomP,le.bottomN,de.bottomN),le=ye)}te=(te+Oe)%j,Q=(Q+Be)%D,ee=(ee+1)%oe}while(ee!==se)}if(c===!1&&this._depth>this._bevel*2&&this._buildWall($,R,b),O){let U=[];for(let B=b.length-1;B>=k+2;B-=3){let F=b[B-2],j=b[B-1],D=b[B-0];U.push(D,j,F)}b.splice(k,b.length-k,...U)}if(O){let U=[];for(let B=$[$.length-1].boundary.vertices.length-1;B>=1;B-=2){let F=$[$.length-1].boundary.vertices[B-1],j=$[$.length-1].boundary.vertices[B-0];U.push(F,j)}T.push(U)}if(!O){let U=$[$.length-1],B;try{B=pr({windingRule:$.length>1?_e.POSITIVE:_e.ODD,elementType:ke.POLYGONS,vertexSize:2,strict:!0,contours:[U.insetPoints,...T]})}catch{B=Yd}if(!B)throw new Error("Error generating geometry for surface");l.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let F=0;F<B.elementCount*3;F+=3){let j=this._buildSurfaceVert(B,B.elements[F+0],Y),D=this._buildSurfaceVert(B,B.elements[F+1],Y),oe=this._buildSurfaceVert(B,B.elements[F+2],Y);b.push(j.top,D.top,oe.top),c===!1&&b.push(oe.bottom,D.bottom,j.bottom)}}this.vertexCache={}}this._buffer.shrink();let _=new jl(Uint32Array.from(b),1),v=new jl(this._buffer.positions,3),N=new jl(this._buffer.normals,3),P=new jl(this._buffer.uvs,2);v.needsUpdate=!0,N.needsUpdate=!0,P.needsUpdate=!0,_.needsUpdate=!0,this.setAttribute("position",v),this.setAttribute("normal",N),this.setAttribute("uv",P),this.setIndex(_)}_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 c=this._buildBevelVert(t,i,a),u=this._buildBevelVert(t,i,(a+1)%s);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.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],c=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let l=this._buffer.get(this.forPathBevel?1:2),d=l*3,p=l*2,f={top:l+0,bottom:l+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]=c,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]=c,this._buffer.uvs[p+3]=u),this.vertexCache[i]=f,f}_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[c,u]=t.boundary.vertexIndices[o],l,d,p,f;c!==u?(d=c,l=u,f=!1,p=e.continuous[d]&&e.continuous[l]):(l=c,d=(l-1+e.count)%e.count,f=e.concave[l]&&t.bevelI>0,p=e.continuous[l]||f);let m=Math.cos(t.angle),h=Math.sin(t.angle),y=o*2,g=l*2,x=d*2,S=t.boundary.vertices[y+0],w=t.boundary.vertices[y+1],b=(1-h)*this._bevel,T=(S-this._minX)/this._width,_=(w-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),_=1);let v=e.normals[g+0],N=e.normals[g+1],P=e.normals[x+0],C=e.normals[x+1];if(f){let X=P-v,R=C-N;v=v+X*(1-i),N=N+R*(1-i);let Z=Math.sqrt(v*v+N*N);v/=Z,N/=Z}let O=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),A=O*3,M=O*2,L={i:o,fi:l,topP:O+0,topN:O+0,bottomP:O+1,bottomN:O+1,pathBevelUCoord:a};return this._buffer.positions[A+0]=S,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=v*m,this._buffer.normals[A+1]=N*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=T,this._buffer.uvs[M+1]=_,this.forPathBevel===!1&&(this._buffer.positions[A+3]=S,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=v*m,this._buffer.normals[A+4]=N*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=_,this._buffer.uvs[M+3]=T),p||(this.forPathBevel?(O+=1,A+=3,M+=2):(O+=2,A+=6,M+=4),L.topP=O+0,L.bottomP=O+1,this._buffer.positions[A+0]=S,this._buffer.positions[A+1]=w,this._buffer.positions[A+2]=(this.forPathBevel?this._bevel:this._depth)-b,this._buffer.normals[A+0]=P*m,this._buffer.normals[A+1]=C*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=T,this._buffer.uvs[M+1]=_,this.forPathBevel===!1&&(this._buffer.positions[A+3]=S,this._buffer.positions[A+4]=w,this._buffer.positions[A+5]=b,this._buffer.normals[A+3]=P*m,this._buffer.normals[A+4]=C*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=_,this._buffer.uvs[M+3]=T)),this.vertexCache[s]=L,L}clone(){let e=new Go(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Qr(this.userData),e}};var Si=class extends kP{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=_e.ODD;this.elementType=ke.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:_e.ODD,elementType:ke.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),s,c=!0,u=!0,l,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],x=i[y+1];if(l!==void 0&&g!==l&&(c=!1),d!==void 0&&x!==d&&(u=!1),l=g,d=x,!c&&!u)break}if(!c&&!u)try{s=pr({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=ka}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Fl(new Float32Array(p*3),3),this._normalAttribute=new Fl(new Float32Array(p*3),3),this._uvAttribute=new Fl(new Float32Array(p*2),2),this._indexAttribute=new Fl(new Uint32Array(f*3),1),s){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,b=p;w<b;w++){let T=w*2,_=s.vertices[T+0],v=s.vertices[T+1];_<m&&(m=_),_>h&&(h=_),v<y&&(y=v),v>g&&(g=v)}let x=h-m,S=g-y;for(let w=0,b=p;w<b;w++){let T=w*2,_=s.vertices[T+0],v=s.vertices[T+1],N=(_-m)/x,P=(v-y)/S;this._positionAttribute.setXYZ(w,_,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,N,P)}for(let w=0,b=f;w<b;w++){let T=w*3,_=s.elements[T+0],v=s.elements[T+1],N=s.elements[T+2];this._indexAttribute.setX(T+0,_),this._indexAttribute.setX(T+1,v),this._indexAttribute.setX(T+2,N)}}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 Si(this._shape,this._curveSegments);return e.userData=Qr(this.userData),e}};var wi=class extends Go{constructor(e,t,o=0,i=12,a=3,s=_e.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 c=this._buildBevelVert(t,i,a),u=this._buildBevelVert(t,i,(a+1)%s);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}clone(){let e=new wi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Qr(this.userData),e}};var Gt=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:_e.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 Ce?(a.width!==t||a.height!==o)&&a.applySize(t,o):a=new Ce(t,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let c=a??new Ce(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:s}),shape:c}}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 Si(n.shape,o,{windingRule:a}):s=new wi(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as UP,Float32BufferAttribute as HP,MathUtils as Xd,Vector2 as Ly}from"three";var Dy=Math.PI*2,_i=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=Xd.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof Ce?n.shape:new Ce,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:c}=n.parameters,u=n.shape,l=r*.5,d=e*.5,p=WP(u,l,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f;return o===0?(f=new UP,f.setAttribute("position",new HP([],3))):f=Gt.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:c}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function WP(n,r,e,t,o,i){if(t>=Dy)return o>30||o%4===0?($P(n,r,e,i),Math.round(o/4)):Ey(n,t,o,r,e,i);t=Math.max(t,.001);let a={x:0,y:e},s=t+Math.PI*.5,c={x:Math.cos(s)*r,y:Math.sin(s)*e},u=Ty({px:a.x,py:a.y,cx:c.x,cy:c.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%u.length===0?qP(n,a.x,a.y,u,o,r,e,i):Ey(n,t,o,r,e,i)}function qP(n,r,e,t,o,i,a,s){let c=Math.round(o/t.length);n.addPoint(Ti(r,e));for(let u=0,l=t.length;u<l;u++){let d=t[u],p=n.points[u],f=Ti(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?By(n,i,a,s):n.addPoint(Ti(0,0)),c}function Ey(n,r,e,t,o,i){let a=-r/e;for(let s=0;s<=e;s++){let c=a*s,u=Math.sin(c)*t,l=Math.cos(c)*o;n.addPoint(Ti(u,l))}return r<Dy?i>0?By(n,t,o,i):n.addPoint(Ti(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Ry(n,t,o,i)),1}function $P(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,c=e*a;n.addPoint(kl(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(kl(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(kl(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(kl(o,i-e,o+s,i-e,o-s,i-e)),t>0&&Ry(n,r,e,t)}function Ti(n,r){return new ur(Xd.generateUUID(),new Ly(n,r))}function kl(n,r,e,t,o,i){let a=Ti(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function By(n,r,e,t){Gy(n,r,e,t).forEach(i=>n.addPoint(i))}function Ry(n,r,e,t){let o=Gy(n,r,e,t),i=new Ce;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Gy(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new Ly(o/r,i/e),s=n.points.map(c=>{let u=c.clone();return u.uuid=Xd.generateUUID(),u}).reverse();return s.forEach(c=>{c.position.multiply(a);let u=c.controls[0].position.clone().multiply(a),l=c.controls[1].position.clone().multiply(a);c.controls[0].position.copy(l),c.controls[1].position.copy(u)}),s}import{BufferGeometry as YP,Float32BufferAttribute as Kd,Uint32BufferAttribute as XP,Vector3 as Vy}from"three";var zy=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:c,pathSegments:u,cornerRadius:l,cornerSegments:d}=n.parameters,p=new Ua(!1,r,e,t,o,i,a,s,c,u,l,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Zd=new XP([0,0,0],1),Ua=class extends YP{constructor(r=!0,e=1,t=1,o=1,i=1,a=1,s=1,c=1,u=1,l=1,d=1,p=1){if(super(),a===0)return;let f=r&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let m=()=>new Vy,h=new Vy,y=m(),g=m(),x=m(),S,w,b,T,_,v,N,P,C=m(),O=m(),A=m(),M=m(),L=m(),X=m(),R=m(),Z=m(),z=t-2*c+.001,V=z/a,W=Math.ceil(s*a),$=W+1,Y=z/W,q=-z/2,k=l+1,U=2*Math.PI/l,B=Math.PI/2/p,F=.01,j=Math.min((1-d/100)*c,c-F),D=c-j,oe=0,ee=2,K=p*ee+ee,te=k*K/ee,Q=te+k*$,se=Math.max(0,k*($+K)),[ne,ie,ce]=[3,3,2].map(Ye=>Array(se*Ye).fill(0)),le=[],de=i-c;function ye(Ye,kt){let br=Math.PI/2;v=kt*Y,P=2*Math.PI*(v%V)/V+br,v+=q,N=Math.sin(P)*de,_=Math.cos(P)*de,r?Ye.set(_,N,v):Ye.set(_,v,N)}ye(h,-1e-10),ye(y,0),C.copy(h),ye(h,1);let Pe=h.distanceTo(y),Ve=f?0:D+j,Oe=Pe*W+2*Ve,Be=j,Et=Oe-Ve;for(let Ye=0;Ye<=W;Ye++){ye(g,Ye),Z.subVectors(g,C).normalize(),C.copy(g),X.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(Z,X).normalize();let kt=Ye===0,br=Ye===W,ux=kt?3*Math.PI/2:B,px=kt?Be:Et,fx=kt?k:Q,mx=kt?0:se-k,hx=Z.clone().multiplyScalar(kt?-D:D).add(g),yx=Z.clone().multiplyScalar(kt?-1:1).normalize();for(let $r=0;$r<k;$r++){let lp=$r*U;if(O.addVectors(h.copy(X).multiplyScalar(c*Math.cos(lp)),y.copy(R).multiplyScalar(c*Math.sin(lp))),A.copy(O).normalize(),kt||br){f||(oe=mx+$r,[0,1,2].forEach(Lt=>{ne[oe*3+Lt]=hx.getComponent(Lt),ie[oe*3+Lt]=yx.getComponent(Lt)}),ce[oe*2]=+br,ce[oe*2+1]=$r/l),y.copy(A).multiplyScalar(j),x.addVectors(g,y);for(let Lt=0;Lt<p;Lt++){let Lc=Lt*B+ux;M.addVectors(h.copy(Z).multiplyScalar(D*Math.sin(Lc)),y.copy(A).multiplyScalar(D*Math.cos(Lc))),L.copy(M).normalize(),y.addVectors(x,M),M.normalize(),oe=fx+Lt*k+$r,[0,1,2].forEach(gs=>{ne[oe*3+gs]=y.getComponent(gs),ie[oe*3+gs]=L.getComponent(gs)});let gx=+kt+Math.sin(Lc);ce[oe*2]=(px+D*gx)/Oe,ce[oe*2+1]=$r/l}}y.addVectors(g,O),oe=te+Ye*k+$r,[0,1,2].forEach(Lt=>{ne[oe*3+Lt]=y.getComponent(Lt),ie[oe*3+Lt]=A.getComponent(Lt)}),ce[oe*2]=(Ve+Ye*Pe)/Oe,ce[oe*2+1]=$r/l}}let be=$+2*p+ee,tt=1,[at,_n]=[+f,be-1];for(let Ye=at;Ye<=_n-1;Ye++){let kt=f&&Ye===_n-1;for(let br=0;br<k-1;br++)S=Ye*k+br,w=S+1,b=(kt?br:S)+k,T=(kt?br+1:w)+k,Ye===0?le.push(w,T,b):Ye===be-2?le.push(S,w,b):le.push(S,w,b,w,T,b)}this.setIndex(le),this.setAttribute("position",new Kd(ne,3)),this.setAttribute("normal",new Kd(ie,3)),this.setAttribute("uv",new Kd(ce,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,c,u=6*(e-1)*r.radialSegments,l=e,d=l===e;for(let p=0;p<r.radialSegments;p++)i=l*t+p,a=i+1,s=(d?p:i)+t,c=(d?p+1:a)+t,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=c,o[u++]=s;return o.length=u,Zd.array=o,Zd.count=o.length,Zd}};import{IcosahedronGeometry as KP}from"three";var jy=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 Ha(r*.5,i,a):new KP(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},Ha=class extends Do{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 Ha(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as ZP,Shape as QP}from"three";var Fy=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 QP;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 ZP(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as Xy,BufferGeometryLoader as dO,Vector3 as uO,BoxGeometry as Ky}from"three";import{BufferGeometry as aO,Vector2 as tu,Vector3 as Yy}from"three";import{Box3 as JP,BufferAttribute as Wa,BufferGeometry as ky,Color as eu,EventDispatcher as eO,Float32BufferAttribute as Pi,Matrix3 as Uy,Matrix4 as $y,MathUtils as tO,Object3D as rO,Sphere as oO,Vector2 as $t,Vector3 as vt,Vector4 as nO}from"three";var Lr=new $y,Qd=new rO,Ul=new vt,Vo=class extends eO{constructor(){super(),this.uuid=tO.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 Uy().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 Lr.makeRotationX(r),this.applyMatrix4(Lr),this}rotateY(r){return Lr.makeRotationY(r),this.applyMatrix4(Lr),this}rotateZ(r){return Lr.makeRotationZ(r),this.applyMatrix4(Lr),this}translate(r,e,t){return Lr.makeTranslation(r,e,t),this.applyMatrix4(Lr),this}scale(r,e,t){return Lr.makeScale(r,e,t),this.applyMatrix4(Lr),this}lookAt(r){return Qd.lookAt(r),Qd.updateMatrix(),this.applyMatrix4(Qd.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,c=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new vt().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new eu().fromBufferAttribute(s,p));function l(p,f,m,h){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=a===void 0?[]:[new vt().fromBufferAttribute(a,p),new vt().fromBufferAttribute(a,f),new vt().fromBufferAttribute(a,m)],x=new Oi(p,f,m,g,y,h);e.faces.push(x),c!==void 0&&e.faceVertexUvs[0].push([new $t().fromBufferAttribute(c,p),new $t().fromBufferAttribute(c,f),new $t().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new $t().fromBufferAttribute(u,p),new $t().fromBufferAttribute(u,f),new $t().fromBufferAttribute(u,m)])}let d=r.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],m=f.start,h=f.count;for(let y=m,g=m+h;y<g;y+=3)t!==void 0?l(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):l(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)l(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)l(p,p+1,p+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(Ul).negate(),this.translate(Ul.x,Ul.y,Ul.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new $y;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 vt,e=new vt;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],c=this.vertices[i.c];r.subVectors(c,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 vt;if(r){let t=new vt,o=new vt;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],c=this.vertices[s.a],u=this.vertices[s.b],l=this.vertices[s.c];t.subVectors(l,u),o.subVectors(c,u),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 Vo;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,c=this.faces.length;s<c;s++){let u=new vt,l={a:new vt,b:new vt,c:new vt};i.push(u),a.push(l)}}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],c=o.faceNormals[i],u=o.vertexNormals[i];c.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,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 JP),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new oO),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,c=this.faces,u=r.faces,l=this.colors,d=r.colors;e!==void 0&&(o=new Uy().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let h=s[p].clone();e!==void 0&&h.applyMatrix4(e),a.push(h)}for(let p=0,f=d.length;p<f;p++)l.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,x=m.vertexColors,S=new Oi(m.a+i,m.b+i,m.c+i);S.normal.copy(m.normal),o!==void 0&&S.normal.applyMatrix3(o).normalize();for(let w=0,b=g.length;w<b;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),S.vertexNormals.push(h);S.color.copy(m.color);for(let w=0,b=x.length;w<b;w++)y=x[w],S.vertexColors.push(y.clone());S.materialIndex=m.materialIndex+t,c.push(S)}for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let S=0,w=g.length;S<w;S++)x.push(g[S].clone());this.faceVertexUvs[p].push(x)}}}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 c=0,u=this.vertices.length;c<u;c++){let l=this.vertices[c],d=Math.round(l.x*i)+"_"+Math.round(l.y*i)+"_"+Math.round(l.z*i);e[d]===void 0?(e[d]=c,t.push(this.vertices[c]),o[c]=t.length-1):o[c]=o[e[d]]}let a=[];for(let c=0,u=this.faces.length;c<u;c++){let l=this.faces[c];l.a=o[l.a],l.b=o[l.b],l.c=o[l.c];let d=[l.a,l.b,l.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){a.push(c);break}}for(let c=a.length-1;c>=0;c--){let u=a[c];this.faces.splice(u,1);for(let l=0,d=this.faceVertexUvs.length;l<d;l++)this.faceVertexUvs[l].splice(u,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 vt(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let r=this.faces,e=r.length;for(let c=0;c<e;c++)r[c]._id=c;function t(c,u){return c.materialIndex-u.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 c=0;c<e;c++){let u=r[c]._id;a&&a.push(o[u]),s&&s.push(i[u])}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 m=this.parameters;for(let h in m)m[h]!==void 0&&(r[h]=m[h]);return r}let e=[];for(let m=0;m<this.vertices.length;m++){let h=this.vertices[m];e.push(h.x,h.y,h.z)}let t=[],o=[],i={},a=[],s={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,x=this.faceVertexUvs[0][m]!==void 0,S=h.normal.length()>0,w=h.vertexNormals.length>0,b=h.color.r!==1||h.color.g!==1||h.color.b!==1,T=h.vertexColors.length>0,_=0;if(_=l(_,0,0),_=l(_,1,y),_=l(_,2,g),_=l(_,3,x),_=l(_,4,S),_=l(_,5,w),_=l(_,6,b),_=l(_,7,T),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),x){let v=this.faceVertexUvs[0][m];t.push(f(v[0]),f(v[1]),f(v[2]))}if(S&&t.push(d(h.normal)),w){let v=h.vertexNormals;t.push(d(v[0]),d(v[1]),d(v[2]))}if(b&&t.push(p(h.color)),T){let v=h.vertexColors;t.push(p(v[0]),p(v[1]),p(v[2]))}}function l(m,h,y){return y?m|1<<h:m&~(1<<h)}function d(m){let h=m.x.toString()+m.y.toString()+m.z.toString();return i[h]!==void 0||(i[h]=o.length/3,o.push(m.x,m.y,m.z)),i[h]}function p(m){let h=m.r.toString()+m.g.toString()+m.b.toString();return s[h]!==void 0||(s[h]=a.length,a.push(m.getHex())),s[h]}function f(m){let h=m.x.toString()+m.y.toString();return u[h]!==void 0||(u[h]=c.length/2,c.push(m.x,m.y)),u[h]}return r.data={},r.data.vertices=e,r.data.normals=o,a.length>0&&(r.data.colors=a),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new Vo().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 p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let t=r.colors;for(let p=0,f=t.length;p<f;p++)this.colors.push(t[p].clone());let o=r.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=r.faceVertexUvs.length;p<f;p++){let m=r.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let h=0,y=m.length;h<y;h++){let g=m[h],x=[];for(let S=0,w=g.length;S<w;S++){let b=g[S];x.push(b.clone())}this.faceVertexUvs[p].push(x)}}let i=r.morphTargets;for(let p=0,f=i.length;p<f;p++){let m={};if(m.name=i[p].name,i[p].vertices!==void 0){m.vertices=[];for(let h=0,y=i[p].vertices.length;h<y;h++)m.vertices.push(i[p].vertices[h].clone())}if(i[p].normals!==void 0){m.normals=[];for(let h=0,y=i[p].normals.length;h<y;h++)m.normals.push(i[p].normals[h].clone())}this.morphTargets.push(m)}let a=r.morphNormals;for(let p=0,f=a.length;p<f;p++){let m={};if(a[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=a[p].vertexNormals.length;h<y;h++){let g=a[p].vertexNormals[h],x={};x.a=g.a.clone(),x.b=g.b.clone(),x.c=g.c.clone(),m.vertexNormals.push(x)}}if(a[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=a[p].faceNormals.length;h<y;h++)m.faceNormals.push(a[p].faceNormals[h].clone())}this.morphNormals.push(m)}let s=r.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let u=r.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let l=r.boundingBox;l!==null&&(this.boundingBox=l.clone());let d=r.boundingSphere;return d!==null&&(this.boundingSphere=d.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 Jd().fromGeometry(this),e=new ky,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Hl.call(new Wa(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Hl.call(new Wa(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",Hy.call(new Wa(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Wy.call(new Wa(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Wy.call(new Wa(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],a=r.morphTargets[o];for(let s=0,c=a.length;s<c;s++){let u=a[s],l=new Pi(u.data.length*3,3);l.name=u.name,i.push(Hl.call(l,u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new Pi(r.skinIndices.length*4,4);e.setAttribute("skinIndex",qy.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new Pi(r.skinWeights.length*4,4);e.setAttribute("skinWeight",qy.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 ky,t=r.geometry;if(r.isPoints||r.isLine){let o=new Pi(t.vertices.length*3,3),i=new Pi(t.colors.length*3,3);if(e.setAttribute("position",Hl.call(o,t.vertices)),e.setAttribute("color",Hy.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new Pi(t.lineDistances.length,1);e.setAttribute("lineDistance",iO.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}};Vo.prototype.isGeometry=!0;var Jd=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,c=s.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let l=r.morphNormals,d=l.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:l[g].name,data:[]};this.morphTargets.normal=p}let f=r.skinIndices,m=r.skinWeights,h=f.length===t.length,y=m.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 x=e[g];this.vertices.push(t[x.a],t[x.b],t[x.c]);let S=x.vertexNormals;if(S.length===3)this.normals.push(S[0],S[1],S[2]);else{let b=x.normal;this.normals.push(b,b,b)}let w=x.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let b=x.color;this.colors.push(b,b,b)}if(i===!0){let b=o[0][g];b!==void 0?this.uvs.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new $t,new $t,new $t))}if(a===!0){let b=o[1][g];b!==void 0?this.uvs2.push(b[0],b[1],b[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new $t,new $t,new $t))}for(let b=0;b<c;b++){let T=s[b].vertices;u[b].data.push(T[x.a],T[x.b],T[x.c])}for(let b=0;b<d;b++){let T=l[b].vertexNormals[g];p[b].data.push(T.a,T.b,T.c)}h&&this.skinIndices.push(f[x.a],f[x.b],f[x.c]),y&&this.skinWeights.push(m[x.a],m[x.b],m[x.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}},Oi=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 vt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new eu,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 iO(n){return this.array.set(n),this}function Hy(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 eu),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function Wy(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 $t),r[e++]=i.x,r[e++]=i.y}return this}function Hl(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 vt),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function qy(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 nO),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var sO=["a","b","c"];function lO(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function ru(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function ou(n,r,e,t,o,i){let a=Math.min(n,r),s=Math.max(n,r),c=a+"_"+s,u;if(t.has(c))u=t.get(c);else{let l=e[a],d=e[s];u={a:l,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function cO(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],ou(a.a,a.b,n,t,a,e),ou(a.b,a.c,n,t,a,e),ou(a.c,a.a,n,t,a,e)}function Wl(n,r,e,t,o){n.push(new Oi(r,e,t,void 0,void 0,o))}function Ai(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function ql(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var $l=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof aO?r=new Vo().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 Yy,t,o,i,a,s,c=r.vertices,u=r.faces,l=r.faceVertexUvs[0],d=l!==void 0&&l.length>0,p=[],f=new Map;cO(c,u,p,f);let m=[],h,y,g,x,S,w,b;for(let F of Array.from(f.keys())){for(y=f.get(F),g=new Yy,S=3/8,w=1/8,b=y.faces.length,b!=2&&(S=.5,w=0,b!=1),g.addVectors(y.a,y.b).multiplyScalar(S),e.set(0,0,0),a=0;a<b;a++){for(x=y.faces[a],s=0;s<3&&(h=c[lO(x,sO[s])],!(h!==y.a&&h!==y.b));s++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let T,_,v,N,P,C,O,A=[];for(o=0,i=c.length;o<i;o++){for(C=c[o],P=p[o].edges,t=P.length,t==3?T=3/16:t>3&&(T=3/(8*t)),_=1-t*Number(T),v=T,t<=2&&(t==2?(_=3/4,v=1/8):t==1||t==0),O=C.clone().multiplyScalar(_),e.set(0,0,0),a=0;a<t;a++)N=P[a],h=N.a!==C?N.a:N.b,e.add(h);e.multiplyScalar(Number(v)),O.add(e),A.push(O)}let M=A.concat(m),L=A.length,X,R,Z,z=[],V=[],W,$,Y,q,k=new tu,U=new tu,B=new tu;for(o=0,i=u.length;o<i;o++)x=u[o],X=Number(ru(x.a,x.b,f).newEdge)+L,R=Number(ru(x.b,x.c,f).newEdge)+L,Z=Number(ru(x.c,x.a,f).newEdge)+L,Wl(z,X,R,Z,x.materialIndex),Wl(z,x.a,X,Z,x.materialIndex),Wl(z,x.b,R,X,x.materialIndex),Wl(z,x.c,Z,R,x.materialIndex),d&&(W=l[o],$=W[0],Y=W[1],q=W[2],k.set(Ai($.x,Y.x),Ai($.y,Y.y)),U.set(Ai(Y.x,q.x),Ai(Y.y,q.y)),B.set(Ai($.x,q.x),Ai($.y,q.y)),ql(V,k,U,B),ql(V,$,k,B),ql(V,Y,U,k),ql(V,q,B,U));r.vertices=M,r.faces=z,d&&(r.faceVertexUvs[0]=V)}};var ot=new uO,Zy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Xy().copy(new Ky(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(ot),t={width:ot.x,height:ot.y,depth:ot.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 Xy().copy(new Ky(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(ot)):ot.set(a.width,a.height,a.depth),(r!==ot.x||e!==ot.y||t!==ot.z)&&i.scale(ot.x===0?1:r/ot.x,ot.y===0?1:e/ot.y,ot.z===0?1:t/ot.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new $l(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 dO(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(ot);let a=100/ot.x;Object.assign(i.parameters,{width:100,height:ot.y*a,depth:ot.z*a}),r(this.build(i))})}};var Yl=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 Ce?n.shape:new Ce,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,c=n.shape,u=r*.5,l=e*.5,d=0,p=0,f=2*Math.PI/t;for(let h=0;h<t;h++){let y=f*h,g=d+Math.sin(y)*u,x=p+Math.cos(y)*l;c.addPoint(c.createPoint(g,x))}c.isClosed=!0;for(let h=0,y=c.points.length;h<y;h++)c.points[h].roundness=o;c.roundness=o,c.update();let m=Gt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as pO,Float32BufferAttribute as nu,Vector2 as Dr,Vector3 as dt}from"three";var Qy=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:c}=n.parameters,u=new au(r*.5,e,o,i,a,s,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function qa(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function iu(n,r,e,t,o,i){let a=r.clone().sub(n),s=e.clone().sub(n),c=a.angleTo(s);if(a.normalize(),s.normalize(),t===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,t/Math.sin(u))}}function fO(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var au=class extends pO{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 c=[],u=[],l=[],d=[],p=0,f=e/2,m=Math.PI/t,h=r*Math.cos(Math.PI/t),y=2*Math.PI/t,g=(t-2)*Math.PI/t,x=Math.PI-g,S=new dt(0,-f,0),w=new dt(0,f,0),b=new Dr(r,-f),T=new Dr(h,-f),_=new Dr(0,w.y).sub(T),v=new Dr(0,w.y).sub(b),N=new Dr(_.y,-_.x).normalize(),P=new Dr(v.y,-v.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;a=Math.min(a,O);let A;{let V=new dt(N.x,N.y,0),W=new dt(Math.cos(y)*V.x,V.y,Math.sin(y)*V.x);A=V.angleTo(W)}let M=a/Math.tan((Math.PI-_.angle())/2),L=a/Math.tan((Math.PI-A)/2),X=new dt;if(!i){u.push(S.x,S.y,S.z),l.push(0,-1,0),d.push(0,0);let V=p++,W=[],$=b.clone(),Y=M/Math.cos(Math.PI/t);$.x-=Y;for(let q=0;q<t;q++){let k=q/t*Math.PI*2+m,U=new Dr(Math.sin(k),Math.cos(k));qa($,U,X),u.push(X.x,X.y,X.z),l.push(0,-1,0),d.push(0,0),W.push(p++)}for(let q=0;q<W.length;q++)c.push(W[q],V,W[(q+1)%W.length])}let R=[];{let V=new dt,W=new dt,$=new dt,Y=new dt,q=new dt,k=new dt;for(let U=0;U<t;U++){let B=U/t*Math.PI*2+m,F=(U+.5)/t*Math.PI*2+m,j=(U+1)/t*Math.PI*2+m,D=new Dr(Math.sin(B),Math.cos(B)),oe=new Dr(Math.sin(F),Math.cos(F)),ee=new Dr(Math.sin(j),Math.cos(j));qa(b,D,W),qa(b,ee,$),qa(N,oe,V),iu(w,W,$,L,L,Y),u.push(Y.x,Y.y,Y.z),iu(W,w,$,L,M,q),u.push(q.x,q.y,q.z),iu($,W,w,M,L,k),u.push(k.x,k.y,k.z),l.push(V.x,V.y,V.z),l.push(V.x,V.y,V.z),l.push(V.x,V.y,V.z),d.push(0,0),d.push(0,0),d.push(0,0);let K=p++,te=p++,Q=p++;if(c.push(K,te,Q),a>0){{let ie=W.clone().add($).multiplyScalar(.5),ce=w.clone().sub(ie).normalize(),de=S.clone().sub(ie).normalize().add(ce).normalize().multiplyScalar(-1),ye=k.clone().sub(q);Z(ie,ye,de,_.angle())}let se,ne;{let ie=new dt;qa(P,ee,ie);let ce=k.clone().add(Y).multiplyScalar(.5);ce=fO(ce,$,w);let le=k.clone().sub(Y);[se,ne]=Z(ce,le,ie,A,Y.y)}{let ie=se,ce=ie.clone().setY(0).normalize(),le=new dt(0,-1,0),de=ce.clone().cross(le);z(ie,ce,le,de)}R.concat(ne);{let ie=_.angle(),ce=Math.PI-ie,le=w.clone();le.y-=a/Math.sin(ie-Math.PI/2);let de=new dt,ye=[];for(let Ve=0;Ve<s;Ve++){let Oe=[],Be=Math.PI/2-ce*Ve/s,Et=Math.cos(Be),be=Math.sin(Be),tt=F;for(let at=0;at<=Ve;at++){let _n=Math.cos(tt),Ye=Math.sin(tt);V.x=Et*Ye,V.y=be,V.z=Et*_n,de.copy(le).addScaledVector(V,a),u.push(de.x,de.y,de.z),l.push(V.x,V.y,V.z),d.push(0,0),Oe.push(p++),tt+=Math.PI*2/Ve/t}ye.push(Oe)}ne.reverse(),ye.push(ne);let Pe=ye.length-1;for(let Ve=0;Ve<Pe;Ve++){let Oe=ye[Ve],Be=ye[Ve+1],Et=Oe.length-1;c.push(Be[1],Oe[0],Be[0]);for(let be=1;be<=Et;be++)c.push(Oe[be],Oe[be-1],Be[be]),c.push(Be[be+1],Oe[be],Be[be])}}}}}this.setIndex(c),this.setAttribute("position",new nu(u,3)),this.setAttribute("normal",new nu(l,3)),this.setAttribute("uv",new nu(d,2));function Z(V,W,$,Y,q){let k=-Y/2,U=(Math.PI-Y)/2,B=W.clone().normalize().cross($);V.addScaledVector($,-a/Math.sin(U));let F=new dt,j=new dt,D=1,oe=p,ee=[];for(let K=0;K<=s;K++){let te=k+K/s*Y;j.set(0,0,0),j.addScaledVector(B,Math.sin(te)),j.addScaledVector($,Math.cos(te));for(let Q=0;Q<=D;Q++){let se=Q/D-.5;if(F.copy(V),F.addScaledVector(W,se),F.addScaledVector(j,a),q!=null){let ne=Math.max(0,F.y-q);F.addScaledVector(W,-ne/W.y)}u.push(F.x,F.y,F.z),l.push(j.x,j.y,j.z),d.push(0,0),Q===0&&ee.push(p),p++}}for(let K=0;K<s;K++)for(let te=0;te<D;te++){let Q=oe+te+(D+1)*K,se=Q+(D+1),ne=se+1,ie=Q+1;c.push(Q,se,ie),c.push(se,ne,ie)}return[V.clone().addScaledVector(W,.5),ee]}function z(V,W,$,Y){let q=Math.PI/2,k=v.angle()-q,U=[],B=new dt,F=new dt;for(let D=0;D<=s;D++){let oe=[],ee=D/s;for(let K=0;K<=D;K++){let Q=((D?K/D:0)-.5)*x,se=Math.cos(Q),ne=Math.sin(Q),ie=Math.atan(Math.tan(k)*se),ce=(q+ie)*ee,le=Math.cos(ce),de=Math.sin(ce);B.set(0,0,0),B.addScaledVector(W,de*se),B.addScaledVector($,le),B.addScaledVector(Y,de*ne),F.copy(V).addScaledVector(B,a),u.push(F.x,F.y,F.z),l.push(B.x,B.y,B.z),d.push(0,0),oe.push(p++)}U.push(oe)}let j=U.length-1;for(let D=0;D<j;D++){let oe=U[D],ee=U[D+1],K=oe.length-1;c.push(oe[0],ee[1],ee[0]);for(let te=1;te<=K;te++)c.push(oe[te-1],oe[te],ee[te]),c.push(oe[te],ee[te+1],ee[te])}}}};var Xl=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 Ce?n.shape:new Ce,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:c}=n.parameters,u={x:e*.5,y:t*.5},l={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(w,b,T){return b>e&&T>t?Math.min(w*e/b,w*t/T):b>e?w*e/b:T>t?w*t/T:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=l.x,h=d.x,y=d.y,g=l.y;r.addPoint(r.createPoint(m,y)),r.addPoint(r.createPoint(h,y)),r.addPoint(r.createPoint(h,g)),r.addPoint(r.createPoint(m,g)),r.isClosed=!0;let x=!0;for(let w=0,b=r.points.length;w<b;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(x=!1);x&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let S=Gt.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:c}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as mO,Float32BufferAttribute as hO,MathUtils as Jy,SphereGeometry as yO}from"three";var eg=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=Jy.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:c,thetaLength:u}=n.parameters,l;return u===0?(l=new mO,l.setAttribute("position",new hO([],3))):l=new yO(.5*r,o,i,a,s,c,u*Jy.DEG2RAD),l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as gO}from"three";var tg=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 gO(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as xO,Float32BufferAttribute as su,Vector3 as vO}from"three";var rg=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 lu(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},lu=class extends xO{constructor(r=1,e=1,t=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],c=[],u=[],l=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-l,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(F=0,j=0,D=0)=>new vO(F,j,D),m=f(),h=f(),[y,g,x]=[e/2,r/2,t/2],S=-g,w=+g,[b,T,_]=[f(S,-y,+x),f(S,-y,-x),f(S,+y,-x)],v=(F,j=!1)=>Math.sin(F-Math.PI/(1+ +j)),N=(F,j=!1)=>Math.cos(F-Math.PI/(1+ +j));_.y=Math.sin(o)*e-y;let P=Math.cos(o)*e-x,C=b.z-l;o<=p?(_.z=Math.min(P,C),_.z==C&&(_.y-=(P-C)/Math.tan(p-o))):T.z=Math.min(T.z-P-x,b.z-l),m.subVectors(b,T),h.subVectors(_,T);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),M=O/Math.cos(o/2),L=m.clone().normalize().add(h.normalize()).setLength(M).add(T);m.set(0,v(o,!0),N(o,!0)),d.push([_,m.clone()]);let X=(Math.PI-o)/a;for(let F=0;F<=a;F++){let j=p+o+F*X;m.set(0,Math.sin(j)*A,Math.cos(j)*A),m.add(L),h.set(0,v(j),N(j)),d.push([m.clone(),h.clone()])}d.push([b,f(0,1,0)]);let R=Math.sin(X/2)*A*2,Z=d.length-1,z=d[0][0].distanceTo(d[1][0]),V=d[Z-1][0].distanceTo(d[Z][0]),W=z+R*a+V;d[0].push(1);for(let F=0;F<=a;F++)d[F+1].push(1-(z+F*R)/W);d[Z].push(0);let[$,Y,q]=d[0],k,U,B;for(let F=1;F<d.length;F++)[k,U,B]=d[F],s.push(S,$.y,$.z,S,k.y,k.z,w,$.y,$.z,w,$.y,$.z,S,k.y,k.z,w,k.y,k.z),c.push(0,Y.y,Y.z,0,U.y,U.z,0,Y.y,Y.z,0,Y.y,Y.z,0,U.y,U.z,0,U.y,U.z),u.push(0,q,0,B,1,q,1,q,0,B,1,B),[$,Y,q]=[k,U,B];this.setAttribute("position",new su(s,3)),this.setAttribute("normal",new su(c,3)),this.setAttribute("uv",new su(u,2))}};var Kl=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 Ce?n.shape:new Ce,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:c,extrudeBevelSegments:u}=n.parameters,l=n.shape,d=r*.5,p=e*.5,f=0,m=0,h=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*t/100,x=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let w=0;w<o;w++){let b=h*w,T=f+Math.sin(b)*d,_=m+Math.cos(b)*p;l.addPoint(l.createPoint(T,_))}}else for(let w=0;w<o;w++){let b=f+Math.cos(y)*d,T=m+Math.sin(y)*p;l.addPoint(l.createPoint(b,T)),y+=h,b=f+Math.cos(y)*g,T=m+Math.sin(y)*x,w<=o,l.addPoint(l.createPoint(b,T)),y+=h}l.isClosed=!0;for(let w=0,b=l.points.length;w<b;w++)l.points[w].roundness=i;l.roundness=i,l.update();let S=Gt.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as bO}from"three";var og=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 bO(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as SO,Float32BufferAttribute as wO,MathUtils as TO}from"three";var ng=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:c}=n.parameters,u=_O(r,e,t,r*.5,a,i,0,0,o,s,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function _O(n,r,e,t,o,i,a,s,c,u,l){[r,e]=[e,r],a=r/2;let d=TO.clamp(o/360,0,1);if(d===0){let p=new SO;return p.setAttribute("position",new wO([],3)),p}return d===1&&(u=0),new Ua(!0,n,r,e,t,d,i,a,s,c,u,l)}import{TorusKnotGeometry as PO}from"three";var ig=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 c=new PO(s,e,t,o,i,a);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var ag=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 Ce?n.shape:new Ce,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,c=n.shape,u=r*.5,l=e*.5;s?(c.addPoint(c.createPoint(-u,l)),c.addPoint(c.createPoint(u,-l)),c.addPoint(c.createPoint(-u,-l))):(c.addPoint(c.createPoint(0,l)),c.addPoint(c.createPoint(u,-l)),c.addPoint(c.createPoint(-u,-l))),c.isClosed=!0;for(let p=0,f=c.points.length;p<f;p++)c.points[p].roundness=t;c.roundness=t,c.update();let d=Gt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as lg,Vector3 as ut,Matrix3 as OO,Matrix4 as on,BufferGeometry as cg,BufferAttribute as Ci,MathUtils as Zl}from"three";function sg(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var AO=new on,CO=new on;function NO(n,r,e){let t=[new ut,new ut,new ut],o=[new ut,new ut,new ut];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],c=Zl.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(c)}),new on().makeBasis(t[0],t[1],t[2])}var dg=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??_i.create({parameters:sd}).userData.shape;return{path:n.path??oi.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...fl,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new cu(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new cg,{userData:{...n,type:"PathGeometry"}})}},cu=class extends cg{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)||!sg(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,a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),c=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,c-s+1),a+2),l=[],d=[];for(let z=0;z<u;z++){let V=this.inputs.path.isClosed?(z+s)%e.length:Math.min(z+s,e.length-1);l.push(e[V].clone()),d.push(t[V].clone())}let p=(z,V,W)=>{l[z]=l[z].clone().lerp(l[V],W),d[z]=NO(d[z],d[V],W)},f=0,m=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(m||i===0)&&(f=m,p(0,1,f));let h=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(h=y,p(l.length-1,l.length-2,1-h)),o===0){let z=l.length-1;l[z].copy(l[0]),d[z].copy(d[0])}this._applyPathModifiers(d,f,h);let{bevel:g,bevelSides:x}=this.inputs.parameters.extrusion,S=g>0?this.inputs.parameters.extrusion.capType:"flat",w=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(w=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:b,infos:T,vertices:_}=this._computeShapePoints(w),v=0,N;S==="round"&&(N=new Go(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=N.getAttribute("position").count);let P=0,C=0;T.sort((z,V)=>z.start-V.start),T.forEach(z=>{z.verticesStart=P,z.verticesCount=z.continuous.reduce((V,W,$)=>V+($===0||!W?2:1),0),C+=z.verticesCount,P=C});let O=C*u,A,M=0;if(this._isOpenEnded()&&S==="flat"){try{A=pr({windingRule:_e.ODD,elementType:ke.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{A=Yd}M=A.vertexCount}let L=O+2*M+v*2,X=O+2*M,R={positions:new Float32Array(L*3),normals:new Float32Array(L*3),uvs:new Float32Array(L*2)},Z=[];if(T.forEach(z=>{this._extrudeRegion(z,_,d,l,R,Z,this._isGeometryClosed()&&!this._isOpenEnded())}),A&&(this._closeEnd(A,O,Z,R,d[0],l[0],!1),this._closeEnd(A,O+M,Z,R,d[d.length-1],l[l.length-1],!0)),N){R.positions.set(N.getAttribute("position").array,X*3),R.normals.set(N.getAttribute("normal").array,X*3),R.uvs.set(N.getAttribute("uv").array,X*2);let z=Z.length;Z.push(...N.getIndex().array.map($=>$+X)),X+=v,R.positions.set(N.getAttribute("position").array,X*3),R.normals.set(N.getAttribute("normal").array,X*3),R.uvs.set(N.getAttribute("uv").array,X*2);let V=Z.length;Z.push(...N.getIndex().array.map($=>$+X)),this.setAttribute("position",new Ci(R.positions,3)),this.setAttribute("normal",new Ci(R.normals,3)),this.setAttribute("uv",new Ci(R.uvs,2)),this.setIndex(Z);let W=AO;W.copy(d[d.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(W,X,L),W.copy(d[0]).setPosition(l[0]).multiply(CO.makeScale(1,1,-1)),this.applyMatrix4OnRange(W,X-v,X),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new Ci(R.positions,3)),this.setAttribute("normal",new Ci(R.normals,3)),this.setAttribute("uv",new Ci(R.uvs,2)),this.setIndex(Z)}_extractPathPoints(){let t=Nl(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 ut,s=new ut,c=new ut,u=new ut,l=new ut(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(x).normalize(),b=S.clone().sub(g).normalize(),T=w.clone().add(b).normalize();c.copy(T),y===0&&(T.equals(l)||T.clone().negate().equals(l))&&l.set(0,0,1);let _=l.clone().cross(T).normalize(),v=T.clone().cross(_).normalize();l.copy(v),u.copy(_),y===0&&(a.copy(v),s.copy(T));let N=new on().makeBasis(_,v,T);t.push(N)}let d=i?s:c,p=i?a:new ut(0,1,0),f=d.clone().cross(u).normalize(),m=Math.acos(p.dot(f));if(isNaN(m))return t;let h=p.clone().cross(f);d.dot(h)>0&&(m*=-1);for(let y=1;y<t.length;y++){let g=new on().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:a,twist:s,startScale:c,endScale:u}=this.inputs.parameters.extrusion,l=new on,d=new on;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));l.makeRotationZ(Zl.lerp(a,a+s,m)*Zl.DEG2RAD);let h=Zl.lerp(c,u,m);d.makeScale(h,h,h),p.multiply(l).multiply(d)}),e}_computeShapePoints(e=12,t=_e.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let x=y.length-1;x>=1;x-=2){let S=y[x-1],w=y[x-0];g.push(S,w)}return g}),s;try{s=pr({windingRule:t,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ka}let c;try{c=pr({windingRule:_e.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{c=$d}if(!s)throw new Error("error generating geometry");let u=s.elementCount;if(c){s.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];s.vertices.push(y)}}let l=1/0,d=-1/0,p=1/0,f=-1/0;for(let h=0,y=s.vertexCount;h<y;h++){let g=h*2,x=s.vertices[g+0],S=s.vertices[g+1];x<l&&(l=x),x>d&&(d=x),S<p&&(p=S),S>f&&(f=S)}let m=[];for(let h=s.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,x=s.elements[g+0],S=s.elements[g+1],w=x+S,b={start:x,count:S,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(b);let T=x,_=w-1,v=x+1,N=o.roundedCurves.length;do{let P=T-x,C=s.vertices[_*2+0],O=s.vertices[_*2+1],A=s.vertices[T*2+0],M=s.vertices[T*2+1],L=s.vertices[v*2+0],X=s.vertices[v*2+1],R=A-C,Z=M-O,z=Math.sqrt(R*R+Z*Z);R/=z,Z/=z;let V=A-L,W=M-X,$=Math.sqrt(V*V+W*W);V/=$,W/=$,b.normals[P*2+0]=-W,b.normals[P*2+1]=V;let Y=s.vertexIndices[T];if(Array.isArray(Y))b.continuous[P]=!1;else{let[q,k]=o.getCurveIndexFromVertexId(Y-1,!0);if(k>0&&k<1)b.continuous[P]=!0;else{let U=k===1?q+1:q-1;U=(U+N)%N;let B=k===1?0:1,F=o.roundedCurves[q].getTangent(k),j=o.roundedCurves[U].getTangent(B);b.continuous[P]=F.dot(j)>.95}}y&&(b.normals[P*2+0]*=-1,b.normals[P*2+1]*=-1),[_,T,v]=[T,v,v+1],v>=w&&(v-=S)}while(v!==x+1)}return{regions:[i,...a],infos:m,vertices:s.vertices}}_insertVertex(e,t,o,i,a){let s=t*2,c=t*3;e.positions[c+0]=o.x,e.positions[c+1]=o.y,e.positions[c+2]=o.z,e.normals[c+0]=i.x,e.normals[c+1]=i.y,e.normals[c+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,t,o,i,a,s,c){let u=new ut,l=new ut,d=new ut,p=new ut,f=new lg;o.forEach((h,y)=>{let g=i[y],x=e.verticesStart*o.length+e.verticesCount*y;for(let S=0;S<e.count;S++){let w=(e.start+S)*2;if(u.set(t[w+0],t[w+1],0),d.copy(u).applyMatrix4(h).add(g),e.continuous[S])p.set(e.normals[S*2+0],e.normals[S*2+1],0);else{let b=S===0?(e.start+e.count-1)*2:w-2;l.set(t[b+0],t[b+1],0),p.copy(u).sub(l),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(S===0?1:S/e.count,y/(o.length-1)),this._insertVertex(a,x,d,p,f),x++,!e.continuous[S]||S===0){if(S===0)p.set(e.normals[S*2+0],e.normals[S*2+1],0),f.set(0,y/(o.length-1));else{let b=S===e.count-1?e.start*2:w+2;l.set(t[b+0],t[b+1],0),p.copy(l).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(a,x,d,p,f),x++}}});let m=o.length-1;for(let h=0;h<m;h++){let y=e.verticesStart*o.length+e.verticesCount*h,g=e.verticesStart*o.length+e.verticesCount*(h+1),x=0;for(let S=0;S<e.count;S++){(!e.continuous[S]||S===0)&&x++;let w=S===e.count-1?0:x+1,b=y+x,T=y+w,_=g+w,v=g+x;e.isHole?s.push(b,_,T,b,v,_):s.push(b,T,_,b,_,v),x++}}}_closeEnd(e,t,o,i,a,s,c){let u=e.vertexCount,l=new ut(0,0,c?-1:1).applyMatrix4(a),d=new ut,p=new lg;for(let m=0;m<u;m++){let h=2*m;d.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(a).add(s),this._insertVertex(i,t+m,d,l,p)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let h=3*m,y=f[h+0]+t,g=f[h+(c?1:2)]+t,x=f[h+(c?2:1)]+t;o.push(y,g,x)}}applyMatrix4OnRange(e,t,o){let i=e.elements,a=new OO().getNormalMatrix(e).elements,s,c,u,l,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,m=p.array,h=d.itemSize;for(let y=t*h,g=o*h;y<g;y+=h){if(y===t)debugger;s=f[y+0],c=f[y+1],u=f[y+2],l=1/(i[3]*s+i[7]*c+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*c+i[8]*u+i[12])*l,f[y+1]=(i[1]*s+i[5]*c+i[9]*u+i[13])*l,f[y+2]=(i[2]*s+i[6]*c+i[10]*u+i[14])*l,s=m[y+0],c=m[y+1],u=m[y+2],m[y+0]=a[0]*s+a[3]*c+a[6]*u,m[y+1]=a[1]*s+a[4]*c+a[7]*u,m[y+2]=a[2]*s+a[5]*c+a[8]*u}d.needsUpdate=!0,p.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),c=o.getX(i+2);o.setXYZ(i,c,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as ug,BufferGeometry as du}from"three";import{mergeBufferGeometries as IO}from"three/examples/jsm/utils/BufferGeometryUtils.js";function pg(){let n=new du;return n.setAttribute("position",new ug(new Float32Array([]),3)),n.setIndex(new ug(new Uint16Array([]),1)),n}var MO=pg().attributes,EO=12,LO=1,Ni=class extends du{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,MO),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:c,text:u,textTransform:l}=e,d=Sl.getDisplayedValue(u),p=l===2?d.toUpperCase():l===3?d.toLowerCase():d,f=DO(e,t,p),{shapes:m,charWidths:h,charCoords:y}=t.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,x=(typeof i=="number"?i:1)*.5,S=m.map(T=>new Ce().fromShape(T));this.vectorShapes=S;let w=S.map(T=>Gt.create({shape:T,parameters:{depth:a,extrudeBevelSegments:c,extrudeBevelSize:s,windingRule:a<=0?_e.NONZERO:_e.ODD,subdivisions:this.isLowResolution&&a>0?LO:EO}})),b=w.length?IO(w):pg();b.translate(-g,x,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=h,this.deleteAttribute("extrudeNormal"),Object.entries(b.attributes).forEach(([T,_])=>{this.setAttribute(T,_)}),this.setIndex(b.index),this.computeBoundingSphere()}clone(){let e=Dt(new du,Ni.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 DO(n,r,e){let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
2
2
  `?(t[t.length-1]+=o,o="",i===`
3
- `&&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}import{BufferGeometry as uu,BufferAttribute as mg,Uint32BufferAttribute as pu,Float32BufferAttribute as fu,Matrix4 as RO,Vector3 as $a,Sphere as GO,Box3 as VO,BoxGeometry as zO}from"three";var pg,Ni=new Promise(n=>{pg=n}),ug=!1;var Zl;function fg(){if(ug)return;if(Zl)return Zl;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.456/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,c=await s({wasmBinary:a});pg(c),ug=!0}return Zl=n(),Zl}import{BufferGeometryLoader as LO}from"three";function an(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let l=i;for(let d of u)l=l[d];for(o in l){let d=l[o];yh(d)&&(l[o]=r.getVariable(d,[t.uuid,"geometry",...u,o]))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=Ce.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 LO().parse(i);else if(i.type==="SubdivGeometry"){let u=new Ke(i,e);return u.data=n,u}else if(i.type==="TextGeometry")return new Ci(i,r);let c;try{c=du(s)}catch(u){console.error(u)}if(!c){let u=Ce.createFromState(ri.defaultData(),100,100);s.shape=u,c=du(s)}return c}import{Matrix4 as DO}from"three";var BO=new DO;function qa(n,r,e,t){let o=n.position.array,i=n.normal.array,a=BO.makeScale(r,e,t).invert().elements,s,c,u;for(var l=0,d=o.length;l<d;l+=3)o[l]*=r,o[l+1]*=e,o[l+2]*=t,s=i[l],c=i[l+1],u=i[l+2],i[l]=a[0]*s+a[4]*c+a[8]*u,i[l+1]=a[1]*s+a[5]*c+a[9]*u,i[l+2]=a[2]*s+a[6]*c+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Ql=new VO,Ii=new $a,pe;Ni.then(n=>{pe=n});var hg=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),yg=new Uint32Array([0,1,2,3]),gg=new Uint8Array([4]),Ke=class extends uu{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=To.div(t,o);this.subdividedGeometry&&qa(this.subdividedGeometry.attributes,...i),this.originalGeometry&&qa(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(Ii.fromArray(i));let s=Ii.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}=Ke.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new zO(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&&(Ke.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new GO,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Ql.setFromBufferAttribute(t),Ql.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ql.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ql.getSize(Ii);let i={width:Ii.x,height:Ii.y,depth:Ii.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(pe.free_bvh(t),pe.free_subdivision_surface(t));try{a=Ke.allocate(e,i)}catch(l){console.error(l,e),a=Ke.allocate({positionWASM:hg,indexWASM:yg,verticesPerFaceWASM:gg},i)}if(pe.set_destination_refinement_level(a,0),s=Ke.buildLevel(a,!0,u),e.subdivisions>0)try{pe.set_destination_refinement_level(a,e.subdivisions),c=Ke.buildLevel(a,!1,u)}catch{try{pe.set_destination_refinement_level(a,e.subdivisions-1),c=Ke.buildLevel(a,!1,u)}catch{c=null}}else c=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:c}}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:an(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,c,u,l;({positions:s,triIndices:l}=gu(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:c,verticesPerFace:u}=xu(s,l,i,d),{positions:s,indices:c,verticesPerFace:u}}static allocate(e,t){let o,i,a,s=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=hg,i=yg,a=gg);let u=o.length,l=i.length,d=a.length,p=o.length+s.length+c.length,f=i.length+a.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=pe._malloc(m),x=new Float32Array(pe.HEAPF32.buffer,g,p),S=new Uint32Array(pe.HEAPU32.buffer,g+h,f);x.set(o,0),x.set(s,o.length),x.set(c,o.length+s.length),S.set(i,0),S.set(a,i.length);let w;e?.scaleBaked?.some(T=>T!==1)&&(w=new RO().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let b=w?pe.alloc_subdivision_surface2(g,u,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):pe.alloc_subdivision_surface(g,u,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return pe._free(g),b}static buildLevel(e,t,o,i,a){let s=a?pe.get_mesh_data2(e,t?pe.Level.CONTROL:pe.Level.REFINED,o,a.elements):pe.get_mesh_data(e,t?pe.Level.CONTROL:pe.Level.REFINED,o),c=8,u=pe.HEAPU32.subarray(s>>2,(s>>2)+c),l=u.subarray(4,4+4),d=0,p=pe.HEAPU32[u[d]>>2],f=pe.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let m=pe.HEAPU32[u[d]>>2],h=pe.HEAPF32.subarray(m>>2,(m>>2)+l[d]);d++;let y=pe.HEAPU32[u[d]>>2],g=pe.HEAPU32.subarray(y>>2,(y>>2)+l[d]);d++;let x=pe.HEAPU32[u[d]>>2],S=pe.HEAPU32.subarray(x>>2,(x>>2)+l[d]);if(d++,i===void 0){let w=new uu;if(w.setIndex(new pu(S,1)),w.setAttribute("position",new fu(f,3)),w.setAttribute("normal",new fu(h,3)),t){w.setAttribute("faceMap",new pu(g,1));let b=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new mg(b,4))}return pe.free_mesh_data(s),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,pe.free_mesh_data(s)}static freeSubdivPointer(e){pe.free_bvh(e),pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=pe.get_wireframe_data_for_base_level(e),a=4,s=pe.HEAPU32.subarray(i>>2,(i>>2)+a),c=s.subarray(2,2+2),u=0,l=pe.HEAPU32[s[u]>>2],d=pe.HEAPF32.subarray(l>>2,(l>>2)+c[u]);u++;let p=pe.HEAPU32[s[u]>>2],f=pe.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new uu;m.setAttribute("position",new fu(d,3));let h=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new mg(h,3)),m.setIndex(new pu(f,1)),pe.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(d),t.attributes.position.needsUpdate=!0,pe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||pe.set_destination_refinement_level(e,t);let a=o?pe.get_topological_data2(e,i?pe.Level.CONTROL:pe.Level.REFINED,o.elements):pe.get_topological_data(e,i?pe.Level.CONTROL:pe.Level.REFINED),s=6,c=pe.HEAPU32.subarray(a>>2,(a>>2)+s),u=c.subarray(3,3+3),l=0,d=pe.HEAPU32[c[l]>>2],p=new Float32Array(pe.HEAPF32.subarray(d>>2,(d>>2)+u[l]));l++;let f=pe.HEAPU32[c[l]>>2],m=new Uint32Array(pe.HEAPU32.subarray(f>>2,(f>>2)+u[l]));l++;let h=pe.HEAPU32[c[l]>>2],y=new Uint8Array(pe.HEAPU32.subarray(h>>2,(h>>2)+u[l]));return pe.free_topological_data(a),{positions:p,indices:m,verticesPerFace:y}}};var xg=["getX","getY","getZ"];function gu(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<t;u++){let l=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[xg[p]](l)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[xg[p]](l));e[d]=o,i.push(o),o++}}let c=[];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]||c.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:c}}var Jl=new $a,mu=new $a,hu=new $a,yu=new $a;function xu(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 c=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=c.length/2/u;c=c.filter((f,m)=>Math.floor(m/2)%p===0)}let l=0;for(let p=0;p<c.length;p+=2)l+=(c[p]-c[(p===0?c.length:p)-2])*(c[p+1]+c[(p===0?c.length:p)-1]);n.length=0;let d=0;if(l<0)for(let p=0;p<c.length;p+=2)n.push(c[p],c[p+1],0),o.push(d++);else for(let p=c.length-2;p>=0;p-=2)n.push(c[p],c[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<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let c=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&c++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&c++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&c++,c===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]){Jl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),mu.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),hu.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),yu.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),mu.sub(Jl).normalize(),hu.sub(Jl).normalize(),yu.sub(Jl).normalize();let c=mu.cross(hu).dot(yu);Math.abs(c)>.005||t&&t.some((u,l)=>l%2===1?!1:s>=t[l]&&s<t[l+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 c=[],u=[],l=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(c.push(p),l++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}c.reverse(),o.push(...c,...u),i.push(l,l)}return{indices:o,verticesPerFace:i}}var Qt={};Sx(Qt,{calcBoolean:()=>HO,calcBooleanTopological:()=>UO,freeMeshSet:()=>YO,getMeshSet:()=>WO,hasOpenEdges:()=>qO,transformMeshSet:()=>$O});var jO,vg=new Promise(n=>{jO=n});import{Float32BufferAttribute as bg,Sphere as FO}from"three";var Se,Mi;vg.then(n=>Se=n);function kO(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}=gu(n.getAttribute("position"),o),s;if(r&&e){let{indices:c,verticesPerFace:u}=xu(i,a,n);s=u.length,t=[];for(let l=0,d=0;l<s;l++){t.push(u[l]);for(let p=0;p<u[l];p++)t.push(c[d++])}}else{let c=a.length;t=Array(c+c/3),s=0;for(let u=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=a[u++],t[l++]=a[u++],t[l++]=a[u++]}return{positions:i,faceIndices:t,nFaces:s}}function Sg(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=Se._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Se.HEAPU32.buffer,i,r):new Float32Array(Se.HEAPF32.buffer,i,r)).set(n,0),i}function wg(n){switch(n){case 0:return Se.OP.UNION;case 1:return Se.OP.INTERSECTION;case 2:return Se.OP.A_MINUS_B;case 3:return Se.OP.B_MINUS_A;case 4:return Se.OP.SYMMETRIC_DIFFERENCE;case 5:return Se.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function UO(n,r){Mi===void 0&&(Mi=Se.init_csg());let e=Sg(n),t=Se.csg_calc_topological(Mi,e,n.length,wg(r));Se._free(e);let o=6,i=Se.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,c=Se.HEAPU32[i[s]>>2],u=new Float32Array(Se.HEAPF32.subarray(c>>2,(c>>2)+a[s]));s++;let l=Se.HEAPU32[i[s]>>2],d=new Uint32Array(Se.HEAPU32.subarray(l>>2,(l>>2)+a[s]));s++;let p=Se.HEAPU32[i[s]>>2],f=new Uint8Array(Se.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Se.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function HO(n,r,e,t){Mi===void 0&&(Mi=Se.init_csg());let o=Sg(n),i=Se.csg_calc(Mi,o,n.length,t,wg(r));Se._free(o);let a=5,s=Se.HEAPU32.subarray(i>>2,(i>>2)+a),c=s.subarray(2,2+3),u=0,l=Se.HEAPU32[s[u]>>2],d=Se.HEAPF32.subarray(l>>2,(l>>2)+c[u]);u++;let p=Se.HEAPU32[s[u]>>2],f=Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new bg(d,3)),e.setAttribute("normal",new bg(f,3));let h=Se.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new FO),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},Se.free_mesh_data(i),m}function WO(n,r,e){if(Se===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,t=y.positions,o=Array(y.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,S=0;g<y.verticesPerFace.length;g++){o[S++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[S++]=y.indices[x++]}}else({positions:t,faceIndices:o,nFaces:i}=kO(n,r,e));let a=t.length,s=o.length,c=t.length,u=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Se._malloc(l),m=new Float32Array(Se.HEAPF32.buffer,f,c),h=new Uint32Array(Se.HEAPU32.buffer,f+d,u);return m.set(t,0),h.set(o,0),Se.get_csg_mesh(f,a,f+d,s,i)}function qO(n){return Se.has_open_edges(n)}function $O(n,r){Se.transform_csg_mesh(n,r.elements)}function YO(n){Se.free_csg_mesh(n)}var XO={ConeGeometry:ty,CubeGeometry:ry,CylinderGeometry:ey,DodecahedronGeometry:oy,EllipseGeometry:Ti,HelixGeometry:Gy,IcosahedronGeometry:Vy,LatheGeometry:zy,NonParametricGeometry:Xy,PolygonGeometry:$l,PyramidGeometry:Ky,RectangleGeometry:Yl,SphereGeometry:Qy,PlaneGeometry:Jy,BackdropGeometry:eg,StarGeometry:Xl,TextFrameGeometry:tg,TorusGeometry:rg,TorusKnotGeometry:og,TriangleGeometry:ng,PathGeometry:lg,VectorGeometry:Gt},du=n=>XO[n.type].create(n);function Ei(n){return n!==null&&"booleanOp"in n}var Li=class extends hi(ZO){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new KO}updateVisible(){super.updateVisible(),this.visible=!Ei(this.parent)&&this.visible,Ei(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Qt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ei(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Li&&(e.freeBooleanPointer(),Ei(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Ei(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Ei(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var ec=new QO;function Ya(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,c=-1/0,u=-1/0,l=-1/0;for(let d=r;d<e;d++){let p=n.getX(d),f=n.getY(d),m=n.getZ(d);p<i&&(i=p),f<a&&(a=f),m<s&&(s=m),p>c&&(c=p),f>u&&(u=f),m>l&&(l=m)}ec.min.set(i,a,s),ec.max.set(c,u,l),ec.getCenter(t),ec.getSize(o).multiplyScalar(.5)}var tA=new JO,rA=new eA,bt=class extends Li{constructor(r,e){super(tA,rA),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?Ya(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as hC,Matrix4 as yC,Sphere as a0,Vector3 as gC}from"three";import{BufferAttribute as pC,Float32BufferAttribute as i0,MathUtils as Wu,Vector3 as qu}from"three";import{ShaderMaterial as KA}from"three";import{CubeReflectionMapping as mA,CubeRefractionMapping as hA,CubeUVReflectionMapping as yA,LinearEncoding as Ig,sRGBEncoding as gA}from"three";var Xa=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}};import{MathUtils as oA}from"three";var pt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=oA.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 pt&&(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 vu=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}},nt=new vu;import{Vector2 as Tg}from"three";import{MathUtils as nA}from"three";var ae=class extends pt{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=nA.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),c=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,c)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,c,t);{u=super.generate(e,t,o,s.output,i);let l=this.generate(e,c,o);return e.addNodeCode(u+" = "+l+";"),e.format(u,c,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 Le=class extends ae{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 c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(c.fragment.name,i,t))}};var Ue=class extends Le{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Tg?e:new Tg(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)}};import{Vector3 as _g}from"three";var St=class extends Le{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof _g?e:new _g(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)}};import{Color as iA}from"three";var it=class extends iA{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)}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 Vt=class extends Le{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof it?e:new it(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 aA=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Pg=/[a-z_0-9]+/gi,H=class extends ae{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,c=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 l=[];for(;s=Pg.exec(this.src);)l.push(s);for(let d=0;d<l.length;d++){let p=l[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||nt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&u[p.index+c-1]!=="."&&(u=u.substring(0,p.index+c)+h+u.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&nt.contains(h)&&e.include(nt.get(h))}return t==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",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=aA.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Pg);if(s){let c=0;for(;c<s.length;){let u=s[c++],l;u==="in"||u==="out"||u==="inout"?l=s[c++]:(l=u,u="");let d=s[c++];this.inputs.push({name:d,type:l,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var sA=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,bu=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||bu.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,c,u="",l=sA.exec(e);this.useDefine=a??this.src.charAt(0)==="#",l&&l.length>1?(c=l[1],s=l[2],u=l[3]):(s=this.src,c="f"),this.name=s,this.type=c,this.value=u}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)}},Ae=bu;Ae.PI="PI",Ae.PI2="PI2",Ae.RECIPROCAL_PI="RECIPROCAL_PI",Ae.RECIPROCAL_PI2="RECIPROCAL_PI2",Ae.LOG2="LOG2",Ae.EPSILON="EPSILON";var lA=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
- )*?)}`,"gim"),cA=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Di=class extends ae{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let 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=lA.exec(e);if(t){let o=t[2],i;for(;i=cA.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Bi=class extends ae{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)}};nt.addKeyword("uv",function(){return new Bi});nt.addKeyword("uv2",function(){return new Bi(1)});import{LinearEncoding as dA,sRGBEncoding as uA}from"three";var sn=class extends ae{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??sn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case dA:return["Linear"];case uA:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=sn.Nodes[this.method],s=e.include(a);if(s===sn.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(s+"( "+o+", "+c+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=sn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=sn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Nt=sn;Nt.Nodes={LinearToLinear:new H(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3
+ `&&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}import{BufferGeometry as pu,BufferAttribute as yg,Uint32BufferAttribute as fu,Float32BufferAttribute as mu,Matrix4 as VO,Vector3 as Ya,Sphere as zO,Box3 as jO,BoxGeometry as FO}from"three";var mg,Ii=new Promise(n=>{mg=n}),fg=!1;var Ql;function hg(){if(fg)return;if(Ql)return Ql;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.457/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,c=await s({wasmBinary:a});mg(c),fg=!0}return Ql=n(),Ql}import{BufferGeometryLoader as BO}from"three";function an(n,r,e,t){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let l=i;for(let d of u)l=l[d];for(o in l){let d=l[o];gh(d)&&(l[o]=r.getVariable(d,[t.uuid,"geometry",...u,o]))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=Ce.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 BO().parse(i);else if(i.type==="SubdivGeometry"){let u=new Ke(i,e);return u.data=n,u}else if(i.type==="TextGeometry")return new Ni(i,r);let c;try{c=uu(s)}catch(u){console.error(u)}if(!c){let u=Ce.createFromState(ri.defaultData(),100,100);s.shape=u,c=uu(s)}return c}import{Matrix4 as RO}from"three";var GO=new RO;function $a(n,r,e,t){let o=n.position.array,i=n.normal.array,a=GO.makeScale(r,e,t).invert().elements,s,c,u;for(var l=0,d=o.length;l<d;l+=3)o[l]*=r,o[l+1]*=e,o[l+2]*=t,s=i[l],c=i[l+1],u=i[l+2],i[l]=a[0]*s+a[4]*c+a[8]*u,i[l+1]=a[1]*s+a[5]*c+a[9]*u,i[l+2]=a[2]*s+a[6]*c+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Jl=new jO,Mi=new Ya,pe;Ii.then(n=>{pe=n});var gg=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),xg=new Uint32Array([0,1,2,3]),vg=new Uint8Array([4]),Ke=class extends pu{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=To.div(t,o);this.subdividedGeometry&&$a(this.subdividedGeometry.attributes,...i),this.originalGeometry&&$a(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(Mi.fromArray(i));let s=Mi.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}=Ke.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new FO(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&&(Ke.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new zO,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Jl.setFromBufferAttribute(t),Jl.getCenter(o),e.boundingSphere.radius=o.distanceTo(Jl.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Jl.getSize(Mi);let i={width:Mi.x,height:Mi.y,depth:Mi.z};return this.userData.parameters=i,i}static build(e,t,o,i){let a,s,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(pe.free_bvh(t),pe.free_subdivision_surface(t));try{a=Ke.allocate(e,i)}catch(l){console.error(l,e),a=Ke.allocate({positionWASM:gg,indexWASM:xg,verticesPerFaceWASM:vg},i)}if(pe.set_destination_refinement_level(a,0),s=Ke.buildLevel(a,!0,u),e.subdivisions>0)try{pe.set_destination_refinement_level(a,e.subdivisions),c=Ke.buildLevel(a,!1,u)}catch{try{pe.set_destination_refinement_level(a,e.subdivisions-1),c=Ke.buildLevel(a,!1,u)}catch{c=null}}else c=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:c}}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:an(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,c,u,l;({positions:s,triIndices:l}=xu(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:c,verticesPerFace:u}=vu(s,l,i,d),{positions:s,indices:c,verticesPerFace:u}}static allocate(e,t){let o,i,a,s=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=gg,i=xg,a=vg);let u=o.length,l=i.length,d=a.length,p=o.length+s.length+c.length,f=i.length+a.length,m=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,h=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=pe._malloc(m),x=new Float32Array(pe.HEAPF32.buffer,g,p),S=new Uint32Array(pe.HEAPU32.buffer,g+h,f);x.set(o,0),x.set(s,o.length),x.set(c,o.length+s.length),S.set(i,0),S.set(a,i.length);let w;e?.scaleBaked?.some(T=>T!==1)&&(w=new VO().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let b=w?pe.alloc_subdivision_surface2(g,u,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):pe.alloc_subdivision_surface(g,u,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return pe._free(g),b}static buildLevel(e,t,o,i,a){let s=a?pe.get_mesh_data2(e,t?pe.Level.CONTROL:pe.Level.REFINED,o,a.elements):pe.get_mesh_data(e,t?pe.Level.CONTROL:pe.Level.REFINED,o),c=8,u=pe.HEAPU32.subarray(s>>2,(s>>2)+c),l=u.subarray(4,4+4),d=0,p=pe.HEAPU32[u[d]>>2],f=pe.HEAPF32.subarray(p>>2,(p>>2)+l[d]);d++;let m=pe.HEAPU32[u[d]>>2],h=pe.HEAPF32.subarray(m>>2,(m>>2)+l[d]);d++;let y=pe.HEAPU32[u[d]>>2],g=pe.HEAPU32.subarray(y>>2,(y>>2)+l[d]);d++;let x=pe.HEAPU32[u[d]>>2],S=pe.HEAPU32.subarray(x>>2,(x>>2)+l[d]);if(d++,i===void 0){let w=new pu;if(w.setIndex(new fu(S,1)),w.setAttribute("position",new mu(f,3)),w.setAttribute("normal",new mu(h,3)),t){w.setAttribute("faceMap",new fu(g,1));let b=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new yg(b,4))}return pe.free_mesh_data(s),w.userData.type="SubdivGeometry",w}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(h),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,pe.free_mesh_data(s)}static freeSubdivPointer(e){pe.free_bvh(e),pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=pe.get_wireframe_data_for_base_level(e),a=4,s=pe.HEAPU32.subarray(i>>2,(i>>2)+a),c=s.subarray(2,2+2),u=0,l=pe.HEAPU32[s[u]>>2],d=pe.HEAPF32.subarray(l>>2,(l>>2)+c[u]);u++;let p=pe.HEAPU32[s[u]>>2],f=pe.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new pu;m.setAttribute("position",new mu(d,3));let h=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new yg(h,3)),m.setIndex(new fu(f,1)),pe.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(d),t.attributes.position.needsUpdate=!0,pe.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||pe.set_destination_refinement_level(e,t);let a=o?pe.get_topological_data2(e,i?pe.Level.CONTROL:pe.Level.REFINED,o.elements):pe.get_topological_data(e,i?pe.Level.CONTROL:pe.Level.REFINED),s=6,c=pe.HEAPU32.subarray(a>>2,(a>>2)+s),u=c.subarray(3,3+3),l=0,d=pe.HEAPU32[c[l]>>2],p=new Float32Array(pe.HEAPF32.subarray(d>>2,(d>>2)+u[l]));l++;let f=pe.HEAPU32[c[l]>>2],m=new Uint32Array(pe.HEAPU32.subarray(f>>2,(f>>2)+u[l]));l++;let h=pe.HEAPU32[c[l]>>2],y=new Uint8Array(pe.HEAPU32.subarray(h>>2,(h>>2)+u[l]));return pe.free_topological_data(a),{positions:p,indices:m,verticesPerFace:y}}};var bg=["getX","getY","getZ"];function xu(n,r){let e={},t=r?r.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<t;u++){let l=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[bg[p]](l)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[bg[p]](l));e[d]=o,i.push(o),o++}}let c=[];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]||c.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:c}}var ec=new Ya,hu=new Ya,yu=new Ya,gu=new Ya;function vu(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 c=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=c.length/2/u;c=c.filter((f,m)=>Math.floor(m/2)%p===0)}let l=0;for(let p=0;p<c.length;p+=2)l+=(c[p]-c[(p===0?c.length:p)-2])*(c[p+1]+c[(p===0?c.length:p)-1]);n.length=0;let d=0;if(l<0)for(let p=0;p<c.length;p+=2)n.push(c[p],c[p+1],0),o.push(d++);else for(let p=c.length-2;p>=0;p-=2)n.push(c[p],c[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<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let c=0;if((n[r[s]*3+2]===a||n[r[s]*3+2]===0)&&c++,(n[r[s+1]*3+2]===a||n[r[s+1]*3+2]===0)&&c++,(n[r[s+2]*3+2]===a||n[r[s+2]*3+2]===0)&&c++,c===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]){ec.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),hu.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),yu.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),gu.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),hu.sub(ec).normalize(),yu.sub(ec).normalize(),gu.sub(ec).normalize();let c=hu.cross(yu).dot(gu);Math.abs(c)>.005||t&&t.some((u,l)=>l%2===1?!1:s>=t[l]&&s<t[l+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 c=[],u=[],l=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(c.push(p),l++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}c.reverse(),o.push(...c,...u),i.push(l,l)}return{indices:o,verticesPerFace:i}}var Qt={};Tx(Qt,{calcBoolean:()=>qO,calcBooleanTopological:()=>WO,freeMeshSet:()=>KO,getMeshSet:()=>$O,hasOpenEdges:()=>YO,transformMeshSet:()=>XO});var kO,Sg=new Promise(n=>{kO=n});import{Float32BufferAttribute as wg,Sphere as UO}from"three";var Se,Ei;Sg.then(n=>Se=n);function HO(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}=xu(n.getAttribute("position"),o),s;if(r&&e){let{indices:c,verticesPerFace:u}=vu(i,a,n);s=u.length,t=[];for(let l=0,d=0;l<s;l++){t.push(u[l]);for(let p=0;p<u[l];p++)t.push(c[d++])}}else{let c=a.length;t=Array(c+c/3),s=0;for(let u=0,l=0;l<t.length;)t[l++]=3,s++,t[l++]=a[u++],t[l++]=a[u++],t[l++]=a[u++]}return{positions:i,faceIndices:t,nFaces:s}}function Tg(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=Se._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Se.HEAPU32.buffer,i,r):new Float32Array(Se.HEAPF32.buffer,i,r)).set(n,0),i}function _g(n){switch(n){case 0:return Se.OP.UNION;case 1:return Se.OP.INTERSECTION;case 2:return Se.OP.A_MINUS_B;case 3:return Se.OP.B_MINUS_A;case 4:return Se.OP.SYMMETRIC_DIFFERENCE;case 5:return Se.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function WO(n,r){Ei===void 0&&(Ei=Se.init_csg());let e=Tg(n),t=Se.csg_calc_topological(Ei,e,n.length,_g(r));Se._free(e);let o=6,i=Se.HEAPU32.subarray(t>>2,(t>>2)+o),a=i.subarray(3,3+3),s=0,c=Se.HEAPU32[i[s]>>2],u=new Float32Array(Se.HEAPF32.subarray(c>>2,(c>>2)+a[s]));s++;let l=Se.HEAPU32[i[s]>>2],d=new Uint32Array(Se.HEAPU32.subarray(l>>2,(l>>2)+a[s]));s++;let p=Se.HEAPU32[i[s]>>2],f=new Uint8Array(Se.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Se.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function qO(n,r,e,t){Ei===void 0&&(Ei=Se.init_csg());let o=Tg(n),i=Se.csg_calc(Ei,o,n.length,t,_g(r));Se._free(o);let a=5,s=Se.HEAPU32.subarray(i>>2,(i>>2)+a),c=s.subarray(2,2+3),u=0,l=Se.HEAPU32[s[u]>>2],d=Se.HEAPF32.subarray(l>>2,(l>>2)+c[u]);u++;let p=Se.HEAPU32[s[u]>>2],f=Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new wg(d,3)),e.setAttribute("normal",new wg(f,3));let h=Se.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new UO),e.boundingSphere.center.set(h[0],h[1],h[2]),e.boundingSphere.radius=(h[3]**2+h[4]**2+h[5]**2)**.5,e.userData.parameters={width:h[3]*2,height:h[4]*2,depth:h[5]*2},Se.free_mesh_data(i),m}function $O(n,r,e){if(Se===void 0)return-1;let t,o,i;if(r&&n.userData.positions!==void 0){let y=n.userData;i=y.verticesPerFace.length,t=y.positions,o=Array(y.verticesPerFace.reduce((g,x)=>g+x,0)+i);for(let g=0,x=0,S=0;g<y.verticesPerFace.length;g++){o[S++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[S++]=y.indices[x++]}}else({positions:t,faceIndices:o,nFaces:i}=HO(n,r,e));let a=t.length,s=o.length,c=t.length,u=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Se._malloc(l),m=new Float32Array(Se.HEAPF32.buffer,f,c),h=new Uint32Array(Se.HEAPU32.buffer,f+d,u);return m.set(t,0),h.set(o,0),Se.get_csg_mesh(f,a,f+d,s,i)}function YO(n){return Se.has_open_edges(n)}function XO(n,r){Se.transform_csg_mesh(n,r.elements)}function KO(n){Se.free_csg_mesh(n)}var ZO={ConeGeometry:oy,CubeGeometry:ny,CylinderGeometry:ry,DodecahedronGeometry:iy,EllipseGeometry:_i,HelixGeometry:zy,IcosahedronGeometry:jy,LatheGeometry:Fy,NonParametricGeometry:Zy,PolygonGeometry:Yl,PyramidGeometry:Qy,RectangleGeometry:Xl,SphereGeometry:eg,PlaneGeometry:tg,BackdropGeometry:rg,StarGeometry:Kl,TextFrameGeometry:og,TorusGeometry:ng,TorusKnotGeometry:ig,TriangleGeometry:ag,PathGeometry:dg,VectorGeometry:Gt},uu=n=>ZO[n.type].create(n);function Li(n){return n!==null&&"booleanOp"in n}var Di=class extends yi(JO){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new QO}updateVisible(){super.updateVisible(),this.visible=!Li(this.parent)&&this.visible,Li(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Qt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Li(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Di&&(e.freeBooleanPointer(),Li(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,t){let o=super.updateTransformState(e,t);return o&&Li(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),Li(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var tc=new eA;function Xa(n,r=0,e=n.count,t,o){let i=1/0,a=1/0,s=1/0,c=-1/0,u=-1/0,l=-1/0;for(let d=r;d<e;d++){let p=n.getX(d),f=n.getY(d),m=n.getZ(d);p<i&&(i=p),f<a&&(a=f),m<s&&(s=m),p>c&&(c=p),f>u&&(u=f),m>l&&(l=m)}tc.min.set(i,a,s),tc.max.set(c,u,l),tc.getCenter(t),tc.getSize(o).multiplyScalar(.5)}var oA=new tA,nA=new rA,bt=class extends Di{constructor(r,e){super(oA,nA),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?Xa(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};import{Box3 as gC,Matrix4 as xC,Sphere as l0,Vector3 as vC}from"three";import{BufferAttribute as mC,Float32BufferAttribute as s0,MathUtils as qu,Vector3 as $u}from"three";import{ShaderMaterial as QA}from"three";import{CubeReflectionMapping as yA,CubeRefractionMapping as gA,CubeUVReflectionMapping as xA,LinearEncoding as Eg,sRGBEncoding as vA}from"three";var Ka=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}};import{MathUtils as iA}from"three";var pt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=iA.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 pt&&(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 bu=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}},nt=new bu;import{Vector2 as Pg}from"three";import{MathUtils as aA}from"three";var ae=class extends pt{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=aA.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),c=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,c)||e.context.ignoreCache||s.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let u=this.getTemp(e,o);if(u)return e.format(u,c,t);{u=super.generate(e,t,o,s.output,i);let l=this.generate(e,c,o);return e.addNodeCode(u+" = "+l+";"),e.format(u,c,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 Le=class extends ae{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 c=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(c.fragment.name,i,t))}};var Ue=class extends Le{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Pg?e:new Pg(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)}};import{Vector3 as Og}from"three";var St=class extends Le{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Og?e:new Og(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)}};import{Color as sA}from"three";var it=class extends sA{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)}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 Vt=class extends Le{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof it?e:new it(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 lA=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Ag=/[a-z_0-9]+/gi,H=class extends ae{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,c=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 l=[];for(;s=Ag.exec(this.src);)l.push(s);for(let d=0;d<l.length;d++){let p=l[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&nt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=nt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||nt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&u[p.index+c-1]!=="."&&(u=u.substring(0,p.index+c)+h+u.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&nt.contains(h)&&e.include(nt.get(h))}return t==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",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=lA.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Ag);if(s){let c=0;for(;c<s.length;){let u=s[c++],l;u==="in"||u==="out"||u==="inout"?l=s[c++]:(l=u,u="");let d=s[c++];this.inputs.push({name:d,type:l,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var cA=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Su=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Su.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,c,u="",l=cA.exec(e);this.useDefine=a??this.src.charAt(0)==="#",l&&l.length>1?(c=l[1],s=l[2],u=l[3]):(s=this.src,c="f"),this.name=s,this.type=c,this.value=u}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)}},Ae=Su;Ae.PI="PI",Ae.PI2="PI2",Ae.RECIPROCAL_PI="RECIPROCAL_PI",Ae.RECIPROCAL_PI2="RECIPROCAL_PI2",Ae.LOG2="LOG2",Ae.EPSILON="EPSILON";var dA=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
+ )*?)}`,"gim"),uA=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Bi=class extends ae{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let 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=dA.exec(e);if(t){let o=t[2],i;for(;i=uA.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ri=class extends ae{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)}};nt.addKeyword("uv",function(){return new Ri});nt.addKeyword("uv2",function(){return new Ri(1)});import{LinearEncoding as pA,sRGBEncoding as fA}from"three";var sn=class extends ae{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??sn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case pA:return["Linear"];case fA:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),a=sn.Nodes[this.method],s=e.include(a);if(s===sn.LINEAR_TO_LINEAR)return e.format(o,i,t);if(a.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(s+"( "+o+", "+c+" )",i,t)}else return e.format(s+"( "+o+" )",i,t)}fromEncoding(e){let t=sn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=sn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Nt=sn;Nt.Nodes={LinearToLinear:new H(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
5
5
  `)),sRGBToLinear:new H(["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(`
6
6
  `)),LinearTosRGB:new H(["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(`
7
- `))},Nt.LINEAR_TO_LINEAR="LinearToLinear",Nt.SRGB_TO_LINEAR="sRGBToLinear",Nt.LINEAR_TO_SRGB="LinearTosRGB";var Ne=class extends H{constructor(e="",t,o,i,a){super(e,a,i,o,t);this.nodeType="Expression"}};import{Texture as pA}from"three";var It=class extends Le{constructor(e=new pA,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Bi,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,c;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?c=s+"( "+o+", "+i+", "+a+" )":c=s+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new Nt(new Ne("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,l),e.removeContext(),e.format(c,l,t)}};var J=class extends Le{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 Ka=class extends ae{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,c=s.build(e,t)+"( ",u=[];if(s.inputs){for(let l=0;l<s.inputs.length;l++){let d=s.inputs[l],p=this.inputs[l]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var Su=class extends ae{constructor(e,t,o=Su.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)}},ft=Su;ft.ADD="+",ft.SUB="-",ft.MUL="*",ft.DIV="/";var De=class extends ae{constructor(e,t=De.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 De.MIX:case De.CLAMP:case De.REFRACT:case De.SMOOTHSTEP:case De.FACEFORWARD:return 3;case De.MIN:case De.MAX:case De.MOD:case De.STEP:case De.REFLECT:case De.DISTANCE:case De.DOT:case De.CROSS:case De.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 De.LENGTH:case De.DISTANCE:case De.DOT:return"f";case De.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,c=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case De.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case De.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case De.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case De.STEP:o=this.a.build(e,s===1?"f":l),i=this.b.build(e,l);break;case De.MIN:case De.MAX:case De.MOD:o=this.a.build(e,l),i=this.b.build(e,c===1?"f":l);break;case De.REFRACT:o=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,"f");break;case De.MIX:o=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,u===1?"f":l);break;default:o=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(a=this.c.build(e,l));break}let p=[];p.push(o),i&&p.push(i),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,t)}},ge=De;ge.RAD="radians",ge.DEG="degrees",ge.EXP="exp",ge.EXP2="exp2",ge.LOG="log",ge.LOG2="log2",ge.SQRT="sqrt",ge.INV_SQRT="inversesqrt",ge.FLOOR="floor",ge.CEIL="ceil",ge.NORMALIZE="normalize",ge.FRACT="fract",ge.SATURATE="saturate",ge.SIN="sin",ge.COS="cos",ge.TAN="tan",ge.ASIN="asin",ge.ACOS="acos",ge.ARCTAN="atan",ge.ABS="abs",ge.SIGN="sign",ge.LENGTH="length",ge.NEGATE="negate",ge.INVERT="invert",ge.MIN="min",ge.MAX="max",ge.MOD="mod",ge.STEP="step",ge.REFLECT="reflect",ge.DISTANCE="distance",ge.DOT="dot",ge.CROSS="cross",ge.POW="pow",ge.MIX="mix",ge.CLAMP="clamp",ge.REFRACT="refract",ge.SMOOTHSTEP="smoothstep",ge.FACEFORWARD="faceforward";var Ri=class extends ae{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 Ka(Ri.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new Nt(new Ne("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Nt(new Ne("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Nt(new Ne("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Nt(new Ne("","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 Ne(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ne(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ne(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ne(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new Ne("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return c.keywords.cubeUV_TL=this.colorSpaceTLExp,c.keywords.cubeUV_TR=this.colorSpaceTRExp,c.keywords.cubeUV_BL=this.colorSpaceBLExp,c.keywords.cubeUV_BR=this.colorSpaceBRExp,c.keywords.cubeUV=a,c}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new Ka(Ri.Nodes.roughnessToMip,[i]),s=new ge(a,Ri.Nodes.m0,Ri.Nodes.cubeUV_maxMipLevel,ge.CLAMP),c=new ge(s,ge.FLOOR),u=new ge(s,ge.FRACT),l=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new ft(c,new J(1).setReadonly(!0),ft.ADD)),p=new ge(l,d,u,ge.MIX);return e.format(p.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)}},Gi=Ri;Gi.Nodes=function(){let e=new Di(`struct TextureCubeUVData {
7
+ `))},Nt.LINEAR_TO_LINEAR="LinearToLinear",Nt.SRGB_TO_LINEAR="sRGBToLinear",Nt.LINEAR_TO_SRGB="LinearTosRGB";var Ne=class extends H{constructor(e="",t,o,i,a){super(e,a,i,o,t);this.nodeType="Expression"}};import{Texture as mA}from"three";var It=class extends Le{constructor(e=new mA,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Ri,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,c;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?c=s+"( "+o+", "+i+", "+a+" )":c=s+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new Nt(new Ne("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,l),e.removeContext(),e.format(c,l,t)}};var J=class extends Le{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 Za=class extends ae{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,c=s.build(e,t)+"( ",u=[];if(s.inputs){for(let l=0;l<s.inputs.length;l++){let d=s.inputs[l],p=this.inputs[l]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var wu=class extends ae{constructor(e,t,o=wu.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)}},ft=wu;ft.ADD="+",ft.SUB="-",ft.MUL="*",ft.DIV="/";var De=class extends ae{constructor(e,t=De.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 De.MIX:case De.CLAMP:case De.REFRACT:case De.SMOOTHSTEP:case De.FACEFORWARD:return 3;case De.MIN:case De.MAX:case De.MOD:case De.STEP:case De.REFLECT:case De.DISTANCE:case De.DOT:case De.CROSS:case De.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 De.LENGTH:case De.DISTANCE:case De.DOT:return"f";case De.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,c=this.b?e.getTypeLength(this.b.getType(e)):0,u=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case De.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case De.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case De.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case De.STEP:o=this.a.build(e,s===1?"f":l),i=this.b.build(e,l);break;case De.MIN:case De.MAX:case De.MOD:o=this.a.build(e,l),i=this.b.build(e,c===1?"f":l);break;case De.REFRACT:o=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,"f");break;case De.MIX:o=this.a.build(e,l),i=this.b.build(e,l),a=this.c.build(e,u===1?"f":l);break;default:o=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(a=this.c.build(e,l));break}let p=[];p.push(o),i&&p.push(i),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,t)}},ge=De;ge.RAD="radians",ge.DEG="degrees",ge.EXP="exp",ge.EXP2="exp2",ge.LOG="log",ge.LOG2="log2",ge.SQRT="sqrt",ge.INV_SQRT="inversesqrt",ge.FLOOR="floor",ge.CEIL="ceil",ge.NORMALIZE="normalize",ge.FRACT="fract",ge.SATURATE="saturate",ge.SIN="sin",ge.COS="cos",ge.TAN="tan",ge.ASIN="asin",ge.ACOS="acos",ge.ARCTAN="atan",ge.ABS="abs",ge.SIGN="sign",ge.LENGTH="length",ge.NEGATE="negate",ge.INVERT="invert",ge.MIN="min",ge.MAX="max",ge.MOD="mod",ge.STEP="step",ge.REFLECT="reflect",ge.DISTANCE="distance",ge.DOT="dot",ge.CROSS="cross",ge.POW="pow",ge.MIX="mix",ge.CLAMP="clamp",ge.REFRACT="refract",ge.SMOOTHSTEP="smoothstep",ge.FACEFORWARD="faceforward";var Gi=class extends ae{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 Za(Gi.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new Nt(new Ne("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Nt(new Ne("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Nt(new Ne("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Nt(new Ne("","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 Ne(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ne(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ne(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ne(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new Ne("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return c.keywords.cubeUV_TL=this.colorSpaceTLExp,c.keywords.cubeUV_TR=this.colorSpaceTRExp,c.keywords.cubeUV_BL=this.colorSpaceBLExp,c.keywords.cubeUV_BR=this.colorSpaceBRExp,c.keywords.cubeUV=a,c}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,a=new Za(Gi.Nodes.roughnessToMip,[i]),s=new ge(a,Gi.Nodes.m0,Gi.Nodes.cubeUV_maxMipLevel,ge.CLAMP),c=new ge(s,ge.FLOOR),u=new ge(s,ge.FRACT),l=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new ft(c,new J(1).setReadonly(!0),ft.ADD)),p=new ge(l,d,u,ge.MIX);return e.format(p.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)}},Vi=Gi;Vi.Nodes=function(){let e=new Bi(`struct TextureCubeUVData {
8
8
  vec4 tl;
9
9
  vec4 tr;
10
10
  vec4 br;
@@ -83,7 +83,7 @@ var yx=Object.create;var Lc=Object.defineProperty;var gx=Object.getOwnPropertyDe
83
83
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
84
84
  }
85
85
  return mip;
86
- }`,N);return{bilinearCubeUV:u,roughnessToMip:P,m0:p,cubeUV_maxMipLevel:t}}();var ln=class extends ae{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ln.VIEW}getShared(){return this.scope===ln.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 ln.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case ln.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case ln.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},mt=ln;mt.LOCAL="local",mt.WORLD="world",mt.VIEW="view",mt.NORMAL="normal";nt.addKeyword("viewNormal",function(){return new mt(mt.VIEW)});nt.addKeyword("localNormal",function(){return new mt(mt.NORMAL)});nt.addKeyword("worldNormal",function(){return new mt(mt.WORLD)});var Br=class extends ae{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Br.LOCAL}getType(){switch(this.scope){case Br.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Br.LOCAL:case Br.WORLD:return!1}return!0}generate(e,t,o,i,a){let s;switch(this.scope){case Br.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case Br.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case Br.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Br.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},zt=Br;zt.LOCAL="local",zt.WORLD="world",zt.VIEW="view",zt.PROJECTION="projection";nt.addKeyword("position",function(){return new zt});nt.addKeyword("worldPosition",function(){return new zt(zt.WORLD)});nt.addKeyword("viewPosition",function(){return new zt(zt.VIEW)});var fr=class extends ae{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??fr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case fr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case fr.VECTOR:{let a=new mt(mt.VIEW),s=e.context.roughness,c=a.build(e,"v3"),u=new zt(zt.VIEW).build(e,"v3"),l=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;l&&(d=`normalize( mix( ${d}, ${c}, ${l} * ${l} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case fr.CUBE:{let a=new fr(fr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case fr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new fr(fr.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)}},Rr=fr;Rr.CUBE="cube",Rr.SPHERE="sphere",Rr.VECTOR="vector";var tc=class extends ae{constructor(e=new It,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Gi(this.value,t??new Rr(Rr.VECTOR),o),this.irradianceNode=new Gi(this.value,new mt(mt.WORLD),new J(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))}};import{CubeTexture as fA}from"three";var rc=class extends Le{constructor(e=new fA,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Rr,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 c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Nt(new Ne("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,u),e.removeContext(),e.format(s,u,t)}};var Og=`
86
+ }`,N);return{bilinearCubeUV:u,roughnessToMip:P,m0:p,cubeUV_maxMipLevel:t}}();var ln=class extends ae{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??ln.VIEW}getShared(){return this.scope===ln.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 ln.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case ln.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case ln.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}},mt=ln;mt.LOCAL="local",mt.WORLD="world",mt.VIEW="view",mt.NORMAL="normal";nt.addKeyword("viewNormal",function(){return new mt(mt.VIEW)});nt.addKeyword("localNormal",function(){return new mt(mt.NORMAL)});nt.addKeyword("worldNormal",function(){return new mt(mt.WORLD)});var Br=class extends ae{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Br.LOCAL}getType(){switch(this.scope){case Br.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Br.LOCAL:case Br.WORLD:return!1}return!0}generate(e,t,o,i,a){let s;switch(this.scope){case Br.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case Br.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case Br.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Br.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}},zt=Br;zt.LOCAL="local",zt.WORLD="world",zt.VIEW="view",zt.PROJECTION="projection";nt.addKeyword("position",function(){return new zt});nt.addKeyword("worldPosition",function(){return new zt(zt.WORLD)});nt.addKeyword("viewPosition",function(){return new zt(zt.VIEW)});var fr=class extends ae{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??fr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case fr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case fr.VECTOR:{let a=new mt(mt.VIEW),s=e.context.roughness,c=a.build(e,"v3"),u=new zt(zt.VIEW).build(e,"v3"),l=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;l&&(d=`normalize( mix( ${d}, ${c}, ${l} * ${l} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case fr.CUBE:{let a=new fr(fr.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),i="reflectCubeVec"):i=s;break}case fr.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new fr(fr.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)}},Rr=fr;Rr.CUBE="cube",Rr.SPHERE="sphere",Rr.VECTOR="vector";var rc=class extends ae{constructor(e=new It,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Vi(this.value,t??new Rr(Rr.VECTOR),o),this.irradianceNode=new Vi(this.value,new mt(mt.WORLD),new J(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))}};import{CubeTexture as hA}from"three";var oc=class extends Le{constructor(e=new hA,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Rr,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 c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Nt(new Ne("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,u),e.removeContext(),e.format(s,u,t)}};var Cg=`
87
87
  uniform int frameIndex;
88
88
  uniform vec2 resolution;
89
89
  uniform mat4 previousModelViewMatrix;
@@ -91,7 +91,7 @@ uniform mat4 previousProjectionMatrix;
91
91
 
92
92
  varying vec4 vCurrentPosition;
93
93
  varying vec4 vPreviousPosition;
94
- `,Ag=`
94
+ `,Ng=`
95
95
  layout(location = 1) out vec4 gVelocity;
96
96
 
97
97
  uniform int frameIndex;
@@ -133,7 +133,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
133
133
  return fract(magic.z * fract(dot(screenPos, magic.xy)));
134
134
  }
135
135
 
136
- `,Cg=`
136
+ `,Ig=`
137
137
  // TODO: This could be generated CPU side and passed to the shader every frame
138
138
  const vec2 haltonSequence[16] = vec2[16](
139
139
  vec2( 0.000000,-0.333334),
@@ -170,7 +170,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
170
170
  #endif
171
171
  gl_Position = currentPositionJittered;
172
172
 
173
- `,Ng=`
173
+ `,Mg=`
174
174
  vec2 oldPos = vPreviousPosition.xy;
175
175
  oldPos /= vPreviousPosition.w;
176
176
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -185,7 +185,7 @@ vec2 velocity = (newPos - oldPos);
185
185
  if (gl_FragColor.a <= 0.0) discard;
186
186
 
187
187
  gVelocity = vec4(velocity, 0.0, 1.0);
188
- `;var Mg=["x","y","z","w"],xA=["float","vec2","vec3","vec4"],vA={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},bA={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[]"},oc=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+`
188
+ `;var Lg=["x","y","z","w"],bA=["float","vec2","vec3","vec4"],SA={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},wA={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[]"},nc=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+`
189
189
  `);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",`
190
190
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
191
191
  #define SPE_BLENDING_NORMAL 0
@@ -223,20 +223,20 @@ gVelocity = vec4(velocity, 0.0, 1.0);
223
223
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
224
224
  accumAlpha += (1.0 - accumAlpha) * alpha;
225
225
  }`,""].join(`
226
- `)},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(Og),this.addFragmentParsCode(Ag),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(Cg),this.addFragmentFinalCode(Ng)),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+`
226
+ `)},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(Cg),this.addFragmentParsCode(Ng),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(Ig),this.addFragmentFinalCode(Mg)),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+`
227
227
  `}addVertexNodeCode(r){this.addNodeCode(r,"vertex")}addFragmentNodeCode(r){this.addNodeCode(r,"fragment")}addNodeCode(r,e){this.nodeCode[e??this.shader]+=r+`
228
228
  `}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+`
229
229
  `}addVertexParsCode(r){this.addParsCode(r,"vertex")}addFragmentParsCode(r){this.addParsCode(r,"fragment")}addParsCode(r,e){this.parsCode[e??this.shader]+=r+`
230
230
  `}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),c=s[r];if(!c){let u=s.length;c={name:t||"node"+i+u+(a?"_"+a:""),type:e},s.push(c),s[r]=c}return c}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(`
231
231
  `)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let a=r[o],s=a.type,c=a.name,u=a.size,l=this.getFormatByType(s);if(l===void 0)throw new Error("Node pars "+l+" not found.");l.includes("[]")?t+=e+" "+l.substring(0,l.length-2)+" "+c+`[${u}];
232
232
  `:t+=e+" "+l+" "+c+`;
233
- `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof pt?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,c=s.list.length,u=new Xa({type:e,size:t.size,name:o||"nodeUA"+c+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(u),s[r].push(u),s[r][u.name]=u,this.uniforms[u.name]=u,u}else{let s=this.inputs.uniforms,c=s.list.length,u=new Xa({type:e,name:o||"nodeU"+c+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(u),s[r].push(u),s[r][u.name]=u,this.uniforms[u.name]=u,u}}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"?nt.get(r):r,this.context.include===!1)return r.name;r instanceof H?o=this.includes.functions:r instanceof Ae?o=this.includes.consts:r instanceof Di&&(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 H&&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 xA[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 mA:case hA:return new rc(t);case yA:return new tc(new It(t));default:return new It(t)}else{if(t.isVector2)return new Ue(t);if(t.isVector3)return new St(t);if(t.isVector4)return new Vt(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 vA[r]||r}getFormatByType(r){return bA[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Mg[r]}getIndexByElement(r){return Mg.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=Ig,e===Ig&&this.context.gamma&&(e=gA),e}};import{Vector2 as gr,Vector3 as zr,Vector4 as ea}from"three";var Me=class extends Le{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof it?e:new it(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 c=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return u?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(c.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 we=class extends Le{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)}};import{UniformsLib as PA,UniformsUtils as OA}from"three";var $e=class extends Le{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 mr=class extends Le{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)}};import{Vector3 as SA}from"three";var zo=class extends Le{};var nc=class extends zo{constructor(e){super("v3");this.image=e;this._value=new SA}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 cn=class extends zo{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};import{Matrix3 as wA}from"three";var Vi=class extends Le{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new wA}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)}};import{Matrix4 as TA}from"three";var wt=class extends Le{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new TA}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)}};import{Matrix3 as _A}from"three";function Eg(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var ic=class extends Vi{constructor(e,t){super(new _A);this.repeat=e;this.offset=t;Eg(this.value,e,t)}updateMatrix(){Eg(this.value,this.repeat,this.offset)}};import{Vector4 as Lg}from"three";var hr=class extends Le{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Lg?new Array(e).fill(t):new Array(e).fill(new Lg(0))}};var zi=class extends ae{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 wu=class extends ae{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(wu.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)}},dn=wu;dn.Nodes=function(){return{customColor:new H(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
233
+ `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof pt?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,c=s.list.length,u=new Ka({type:e,size:t.size,name:o||"nodeUA"+c+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(u),s[r].push(u),s[r][u.name]=u,this.uniforms[u.name]=u,u}else{let s=this.inputs.uniforms,c=s.list.length,u=new Ka({type:e,name:o||"nodeU"+c+(a?"_"+a:""),node:t,needsUpdate:i});return s.list.push(u),s[r].push(u),s[r][u.name]=u,this.uniforms[u.name]=u,u}}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"?nt.get(r):r,this.context.include===!1)return r.name;r instanceof H?o=this.includes.functions:r instanceof Ae?o=this.includes.consts:r instanceof Bi&&(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 H&&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 bA[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 yA:case gA:return new oc(t);case xA:return new rc(new It(t));default:return new It(t)}else{if(t.isVector2)return new Ue(t);if(t.isVector3)return new St(t);if(t.isVector4)return new Vt(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 SA[r]||r}getFormatByType(r){return wA[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Lg[r]}getIndexByElement(r){return Lg.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=Eg,e===Eg&&this.context.gamma&&(e=vA),e}};import{Vector2 as gr,Vector3 as zr,Vector4 as ta}from"three";var Me=class extends Le{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof it?e:new it(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 c=e.getNodeData(o),u=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return u?this.generateReadonly(e,t,o,i,a,s):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(c.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 we=class extends Le{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)}};import{UniformsLib as AA,UniformsUtils as CA}from"three";var $e=class extends Le{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 mr=class extends Le{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)}};import{Vector3 as TA}from"three";var zo=class extends Le{};var ic=class extends zo{constructor(e){super("v3");this.image=e;this._value=new TA}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 cn=class extends zo{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};import{Matrix3 as _A}from"three";var zi=class extends Le{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new _A}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)}};import{Matrix4 as PA}from"three";var wt=class extends Le{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new PA}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)}};import{Matrix3 as OA}from"three";function Dg(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var ac=class extends zi{constructor(e,t){super(new OA);this.repeat=e;this.offset=t;Dg(this.value,e,t)}updateMatrix(){Dg(this.value,this.repeat,this.offset)}};import{Vector4 as Bg}from"three";var hr=class extends Le{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Bg?new Array(e).fill(t):new Array(e).fill(new Bg(0))}};var ji=class extends ae{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 Tu=class extends ae{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(Tu.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)}},dn=Tu;dn.Nodes=function(){return{customColor:new H(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
234
234
  float lalpha = alpha * mask;
235
235
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
236
236
  accumAlpha += (1.0 - accumAlpha) * lalpha;
237
237
 
238
238
  return color;
239
- }`)}}();var Tu=class extends ae{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(Tu.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)}},ji=Tu;ji.Nodes=function(){return{customNormal:new H(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
239
+ }`)}}();var _u=class extends ae{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(_u.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)}},Fi=_u;Fi.Nodes=function(){return{customNormal:new H(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
240
240
  vec3 normal = packNormalToRGB( norm ).rgb;
241
241
  normal *= step( vec3(0.5), cnormal );
242
242
 
@@ -245,7 +245,7 @@ gVelocity = vec4(velocity, 0.0, 1.0);
245
245
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
246
246
 
247
247
  return normal;
248
- }`)}}();var Fi=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f){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=c,this.blending=u,this.mat=l,this.isMask=f,this.alpha=d,this.mode=p,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(Fi.Nodes.cylindrical);break;case 2:i=e.include(Fi.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],c=["zy","xz","xy"][this.axis.value],u=new H(`
248
+ }`)}}();var ki=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f){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=c,this.blending=u,this.mat=l,this.isMask=f,this.alpha=d,this.mode=p,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(ki.Nodes.cylindrical);break;case 2:i=e.include(ki.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],c=["zy","xz","xy"][this.axis.value],u=new H(`
249
249
  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) {
250
250
  vec2 projected = (1. + (position.${c})) / 2.;
251
251
  vec2 uvs = ( mat * vec3( (projected * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -269,7 +269,7 @@ gVelocity = vec4(velocity, 0.0, 1.0);
269
269
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
270
270
 
271
271
  return col;
272
- }`);i=e.include(u);break;case 4:i=e.include(Fi.Nodes.triplanar);break;default:i=e.include(Fi.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`,c=s+"0",u=s+"1",l=s+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(d,"vec3"),a.push(c),a.push(u),a.push(l),a.push(d)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),t)}},jo=Fi;jo.Nodes=function(){let e=new H(`
272
+ }`);i=e.include(u);break;case 4:i=e.include(ki.Nodes.triplanar);break;default:i=e.include(ki.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`,c=s+"0",u=s+"1",l=s+"2",d=`${o}_triplanarWeights`;e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(u,"vec2"),e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(d,"vec3"),a.push(c),a.push(u),a.push(l),a.push(d)}else{let s=`${o}_writeUvs`;e.addFragmentVariable(s,"vec2"),a.push(s)}return e.format(i+"("+a.join(",")+")",this.getType(e),t)}},jo=ki;jo.Nodes=function(){let e=new H(`
273
273
  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) {
274
274
  vec3 posN = normalize(position);
275
275
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -424,7 +424,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
424
424
 
425
425
  return col;//n * 0.5 + 0.5;
426
426
  }
427
- `);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var ki=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f){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=c,this.direction=u,this.colors=l,this.steps=d,this.isMask=f,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new H(`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) {
427
+ `);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var Ui=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f){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=c,this.direction=u,this.colors=l,this.steps=d,this.isMask=f,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let o=`g${this.uuid.toString().replace(/-/g,"")}`,i=new H(`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) {
428
428
  vec4 color = colors[0];
429
429
  #ifdef ${o}_IS_VECTOR
430
430
  #ifdef ${o}_LINEAR
@@ -464,7 +464,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
464
464
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
465
465
 
466
466
  return color.rgb;
467
- }`,[ki.Nodes.vectorLinearWorldSpaceDepth,ki.Nodes.vectorLinearObjectSpaceDepth,ki.Nodes.vectorSphericalObjectSpaceDepth,ki.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)}},Ui=ki;Ui.Nodes=function(){let e=new H(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
467
+ }`,[Ui.Nodes.vectorLinearWorldSpaceDepth,Ui.Nodes.vectorLinearObjectSpaceDepth,Ui.Nodes.vectorSphericalObjectSpaceDepth,Ui.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)}},Hi=Ui;Hi.Nodes=function(){let e=new H(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
468
468
  vec3 n = normalize(direction);
469
469
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
470
470
  return ( dist - near ) / ( far - near );
@@ -478,7 +478,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
478
478
  }`),i=new H(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
479
479
  float dist = length(position - origin);
480
480
  return ( dist - near ) / ( far - near );
481
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Za=class extends ae{constructor(e,t,o,i,a,s,c,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=a,this.isMask=u,this.alpha=s,this.mode=c,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 H(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
481
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var Qa=class extends ae{constructor(e,t,o,i,a,s,c,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=a,this.isMask=u,this.alpha=s,this.mode=c,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 H(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
482
482
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
483
483
 
484
484
  float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
@@ -486,7 +486,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
486
486
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
487
487
 
488
488
  return color;
489
- }`),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 _u=class extends ae{constructor(e,t,o,i,a,s,c,u,l){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=c,this.isMask=l,this.alpha=u,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(_u.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)}},Hi=_u;Hi.Nodes=function(){return{gradient:new H(`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) {
489
+ }`),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 Pu=class extends ae{constructor(e,t,o,i,a,s,c,u,l){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=c,this.isMask=l,this.alpha=u,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(Pu.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)}},Wi=Pu;Wi.Nodes=function(){return{gradient:new H(`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) {
490
490
  vec4 color = colors[0];
491
491
  vec2 m = morph / vUv.xy;
492
492
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -528,7 +528,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
528
528
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
529
529
 
530
530
  return color.xyz;
531
- }`)}}();var Pu=class extends ae{constructor(e,t,o,i){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`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Pu.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Wi=Pu;Wi.Nodes=function(){return{matcap:new H(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
531
+ }`)}}();var Ou=class extends ae{constructor(e,t,o,i){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`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(Ou.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let i=[];return i.push(this.texture.generate(e,"t")),i.push("normal"),i.push(this.isMask.build(e,"b")),i.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},qi=Ou;qi.Nodes=function(){return{matcap:new H(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
532
532
  vec3 viewDir = normalize( vViewPosition );
533
533
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
534
534
  vec3 y = cross( viewDir, x );
@@ -540,7 +540,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
540
540
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
541
541
 
542
542
  return matcapColor.rgb;
543
- }`)}}();var Qa=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Qa||{}),ht=function(){let r=new H(`vec3 random3(vec3 c) {
543
+ }`)}}();var Ja=(a=>(a.SIMPLEX="simplex3d",a.SIMPLEX_FRACTAL="simplex3dFractal",a.ASHIMA="simplexAshima",a.FBM="fbm",a.PERLIN="perlin",a.VORONOI="voronoi",a))(Ja||{}),ht=function(){let r=new H(`vec3 random3(vec3 c) {
544
544
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
545
545
  vec3 r;
546
546
  r.z = fract(512.0*j);
@@ -893,7 +893,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
893
893
  return hashwithoutsine13(vec3(p + mb) + seed);
894
894
  }
895
895
  }
896
- `,[f,m,h,y,g,x]);return{simplex:e,simplexFractal:t,simplexAshima:a,fbm:l,perlin:p,voronoi:S}}();var qi=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f,m,h,y,g,x,S,w){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=c,this.colorB=u,this.colorC=l,this.colorD=d,this.noiseType=f,this.voronoiStyle=h,this.highCut=y,this.lowCut=g,this.smoothness=x,this.seed=S,this.quality=w,this.isMask=m,this.alpha=p,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(Qa)[this.noiseType.value],c=s=="voronoi"?`
896
+ `,[f,m,h,y,g,x]);return{simplex:e,simplexFractal:t,simplexAshima:a,fbm:l,perlin:p,voronoi:S}}();var $i=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f,m,h,y,g,x,S,w){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=c,this.colorB=u,this.colorC=l,this.colorD=d,this.noiseType=f,this.voronoiStyle=h,this.highCut=y,this.lowCut=g,this.smoothness=x,this.seed=S,this.quality=w,this.isMask=m,this.alpha=p,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(Ja)[this.noiseType.value],c=s=="voronoi"?`
897
897
  float v = ${s}(st + move, voronoiStyle, smoothness, seed, quality);
898
898
 
899
899
  // Apply clipping to colors
@@ -930,7 +930,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
930
930
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
931
931
 
932
932
  return clamp(color, 0.0, 1.0).rgb;
933
- }`,[ht.simplex,ht.simplexFractal,ht.simplexAshima,ht.fbm,ht.perlin,ht.voronoi]),l=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(l+"("+d.join(",")+")",this.getType(e),t)}};qi.numOctaves=5;var Ou=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f,m,h,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=c,this.outlineSmoothing=u,this.contourDirection=l,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=m,this.depthMap=h,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"),c=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(c,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
933
+ }`,[ht.simplex,ht.simplexFractal,ht.simplexAshima,ht.fbm,ht.perlin,ht.voronoi]),l=e.include(u),d=[];return d.push(this.scale.build(e,"f")),d.push(this.size.build(e,"v3")),d.push(this.move.build(e,"f")),d.push(this.fA.build(e,"v2")),d.push(this.fB.build(e,"v2")),d.push(this.distortion.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.colorC.build(e,"v4")),d.push(this.colorD.build(e,"v4")),d.push(this.voronoiStyle.build(e,"i")),d.push(this.highCut.build(e,"f")),d.push(this.lowCut.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.seed.build(e,"f")),d.push(this.quality.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(l+"("+d.join(",")+")",this.getType(e),t)}};$i.numOctaves=5;var Au=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f,m,h,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=c,this.outlineSmoothing=u,this.contourDirection=l,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=m,this.depthMap=h,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"),c=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(c,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
934
934
  vID = randomColor.r;
935
935
  vec2 ${o}_offset = vec2(0.0);
936
936
  if (${s}) {
@@ -945,7 +945,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
945
945
  // if this offset is the biggest of all the potential offsets
946
946
  gl_Position = ${o}_clipPosition;
947
947
  }
948
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(Ou.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."),""}},$i=Ou;$i.Nodes=function(){let e=new H(`
948
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(Au.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."),""}},Yi=Au;Yi.Nodes=function(){let e=new H(`
949
949
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
950
950
  {
951
951
  vec2 halton = haltonSequence[frameIndex];
@@ -1180,7 +1180,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1180
1180
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1181
1181
 
1182
1182
  return clamp(color, 0.0, 1.0).rgb;
1183
- }`,[s,a,Gr.DrawFunctions.circle,Gr.DrawFunctions.ring,Gr.DrawFunctions.polygon,Gr.DrawFunctions.cross,Gr.DrawFunctions.diamond,Gr.DrawFunctions.checkerboard,Gr.DrawFunctions.line,Gr.DrawFunctions.wave]),l=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(l+"("+d.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)}},Yi=Gr;Yi.DrawFunctions=function(){let e=new H(`float hashwithoutsine12(vec2 p) {
1183
+ }`,[s,a,Gr.DrawFunctions.circle,Gr.DrawFunctions.ring,Gr.DrawFunctions.polygon,Gr.DrawFunctions.cross,Gr.DrawFunctions.diamond,Gr.DrawFunctions.checkerboard,Gr.DrawFunctions.line,Gr.DrawFunctions.wave]),l=e.include(u),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(l+"("+d.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)}},Xi=Gr;Xi.DrawFunctions=function(){let e=new H(`float hashwithoutsine12(vec2 p) {
1184
1184
  vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1185
1185
  p3 += dot(p3, p3.yzx + 33.33);
1186
1186
  return fract((p3.x + p3.y) * p3.z);
@@ -1345,7 +1345,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1345
1345
  float s = mix(size, size * rand, variation);
1346
1346
 
1347
1347
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1348
- }`);return{tileAndCenter:t,circle:o,ring:i,polygon:a,cross:s,diamond:c,checkerboard:u,line:l,wave:d}}();var Au=class extends ae{constructor(e,t,o,i,a,s,c,u){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=u,this.alpha=c,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(Au.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)}},Xi=Au;Xi.Nodes=function(){let e=new H(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1348
+ }`);return{tileAndCenter:t,circle:o,ring:i,polygon:a,cross:s,diamond:c,checkerboard:u,line:l,wave:d}}();var Cu=class extends ae{constructor(e,t,o,i,a,s,c,u){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=u,this.alpha=c,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(Cu.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)}},Ki=Cu;Ki.Nodes=function(){let e=new H(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1349
1349
  vec3 st = position / noiseScale;
1350
1350
  vec3 q = vec3(simplex3d(st),
1351
1351
  simplex3d(st + vec3(1.0)),
@@ -1368,7 +1368,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1368
1368
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1369
1369
 
1370
1370
  return res;
1371
- }`,[e])}}();var Cu=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d){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=c,this.shadowColor=u,this.offset=l,this.alpha=d,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(Cu.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)}},Ki=Cu;Ki.Nodes=function(){let e=new H(`float rand(float n) {
1371
+ }`,[e])}}();var Nu=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d){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=c,this.shadowColor=u,this.offset=l,this.alpha=d,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(Nu.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)}},Zi=Nu;Zi.Nodes=function(){let e=new H(`float rand(float n) {
1372
1372
  return fract(sin(n) * 43758.5453123);
1373
1373
  }`),t=new H(`float hash1(float p) {
1374
1374
  p = fract(p * 0.011);
@@ -1604,7 +1604,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1604
1604
 
1605
1605
  return color.xyz;
1606
1606
 
1607
- }`,[ht.simplex,e,o,a])}}();import{Vector2 as Bg}from"three";var Dg=function(){return{textureBicubic:new H(`float w0( float a ) {
1607
+ }`,[ht.simplex,e,o,a])}}();import{Vector2 as Gg}from"three";var Rg=function(){return{textureBicubic:new H(`float w0( float a ) {
1608
1608
  return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
1609
1609
  }
1610
1610
 
@@ -1668,7 +1668,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1668
1668
  vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
1669
1669
  vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
1670
1670
  return mix( fSample, cSample, fract( lod ) );
1671
- }`)}}();function Rg(n,r){return n>=r?new Bg(r/n,1):new Bg(1,n/r)}var Nu=class extends ae{constructor(e,t,o,i,a,s,c,u){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=c,this.alpha=u,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,ve.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(Nu.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)}},Zi=Nu;Zi.Nodes=function(){let e=new H(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1671
+ }`)}}();function Vg(n,r){return n>=r?new Gg(r/n,1):new Gg(1,n/r)}var Iu=class extends ae{constructor(e,t,o,i,a,s,c,u){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=c,this.alpha=u,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,ve.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(Iu.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)}},Qi=Iu;Qi.Nodes=function(){let e=new H(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1672
1672
  // Slightly modified version of this:
1673
1673
  // https://www.shadertoy.com/view/ltScRG
1674
1674
 
@@ -1728,7 +1728,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1728
1728
  float lod = applyIorToRoughness(roughness, ior);
1729
1729
  return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1730
1730
  #endif
1731
- }`,[Dg.textureBicubic,o,e]),a=new H(`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 ) {
1731
+ }`,[Rg.textureBicubic,o,e]),a=new H(`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 ) {
1732
1732
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1733
1733
  vec3 refractedRayExit = position + transmissionRay;
1734
1734
 
@@ -1759,7 +1759,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1759
1759
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1760
1760
 
1761
1761
  return transmission;
1762
- }`,[a])}}();var Iu=(e=>(e.NOISE="noise",e.MAP="map",e))(Iu||{}),Mu=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p){super("v3");this.displacementTypeIndex=new we(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Iu)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Vi(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=c,this.lowCut=u,this.quality=l}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(Iu)[this.displacementTypeIndex.value]){case"map":{o=e.include(Mu.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(Qa)[this.noiseFunctionIndex.value],c=new H(`vec3 orthogonal(vec3 v) {
1762
+ }`,[a])}}();var Mu=(e=>(e.NOISE="noise",e.MAP="map",e))(Mu||{}),Eu=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p){super("v3");this.displacementTypeIndex=new we(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Mu)[this.displacementTypeIndex.value]==="map"&&(this.mat=new zi(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=a,this.seed=s,this.highCut=c,this.lowCut=u,this.quality=l}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(Mu)[this.displacementTypeIndex.value]){case"map":{o=e.include(Eu.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(Ja)[this.noiseFunctionIndex.value],c=new H(`vec3 orthogonal(vec3 v) {
1763
1763
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1764
1764
  }`),u=s=="voronoi"?`
1765
1765
  float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1788,7 +1788,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1788
1788
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1789
1789
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1790
1790
  return displaced_position;
1791
- }`,[l,c]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Qi=Mu;Qi.Nodes=function(){let e=new H(`vec3 orthogonal(vec3 v) {
1791
+ }`,[l,c]);o=e.include(d),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f")),i.push(this.voronoiStyle.build(e,"i")),i.push(this.smoothness.build(e,"f")),i.push(this.seed.build(e,"f")),i.push(this.highCut.build(e,"f")),i.push(this.lowCut.build(e,"f")),i.push(this.quality.build(e,"i"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}},Ji=Eu;Ji.Nodes=function(){let e=new H(`vec3 orthogonal(vec3 v) {
1792
1792
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1793
1793
  }`),t=new H(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1794
1794
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -1810,7 +1810,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1810
1810
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1811
1811
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1812
1812
  return displaced_position;
1813
- }`,[e,t])}}();var ve={normalRenderTarget:new It,normalRenderTargetDepth:new It,transmissionRenderTarget:new It,aspectRatio:new Ue,transmissionSize:new Ue(2048,2048),transmissionRenderTargetDepth:new It,aoRenderTarget:new It,aoEnabled:new $e,pixelRatioNode:new J(1),resolution:new Ue,penumbraSize:new mr(5,.5),frameIndex:new we(0),transmissionLod:new we(2)};for(let n of Object.values(ve))n.isRenderGlobal=!0;var pn=class extends pt{constructor(){super("basic");this.nodeType="Basic";this.color=new Me(rt),this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt}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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(OA.merge([PA.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1813
+ }`,[e,t])}}();var ve={normalRenderTarget:new It,normalRenderTargetDepth:new It,transmissionRenderTarget:new It,aspectRatio:new Ue,transmissionSize:new Ue(2048,2048),transmissionRenderTargetDepth:new It,aoRenderTarget:new It,aoEnabled:new $e,pixelRatioNode:new J(1),resolution:new Ue,penumbraSize:new mr(5,.5),frameIndex:new we(0),transmissionLod:new we(2)};for(let n of Object.values(ve))n.isRenderGlobal=!0;var pn=class extends pt{constructor(){super("basic");this.nodeType="Basic";this.color=new Me(rt),this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt}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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(CA.merge([AA.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1814
1814
  `));let i=["#include <beginnormal_vertex>",`
1815
1815
  #if !defined( USE_LAYER_DISPLACE )
1816
1816
  #include <defaultnormal_vertex>
@@ -1830,7 +1830,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1830
1830
  `];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(`
1831
1831
  `)}else{this.color===void 0&&(this.color=new Me(rt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=i!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1832
1832
  `));let c=["#include <normal_fragment_begin>",o.code];i&&c.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?c.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):c.push(`vec3 finalColor = ${o.result};`);let u="1.0";this.mask&&(this.mask.analyze(e),u=`luminance(${this.mask.flow(e,"v3").result})`),i?c.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${u} );`):c.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a&&c.push(`gl_FragColor.a *= ${a.result};`),c.push("#include <fog_fragment>","#include <dithering_fragment>"),t=c.join(`
1833
- `)}return t}};import{UniformsLib as Gg,UniformsUtils as AA}from"three";var Ja=class extends pt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Me(rt),this.emissive=new Me(0),this.emissiveIntensity=new J(1),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new $e(!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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(AA.merge([Gg.fog,Gg.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(`
1833
+ `)}return t}};import{UniformsLib as zg,UniformsUtils as NA}from"three";var es=class extends pt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Me(rt),this.emissive=new Me(0),this.emissiveIntensity=new J(1),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new $e(!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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(NA.merge([zg.fog,zg.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(`
1834
1834
  `));let i=["#include <beginnormal_vertex>",`
1835
1835
  #ifndef USE_LAYER_DISPLACE
1836
1836
  #include <defaultnormal_vertex>
@@ -1939,7 +1939,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1939
1939
  outgoingLight *= ao;
1940
1940
  }
1941
1941
  `),l&&f.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&f.push(`gl_FragColor.a *= ${p.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=f.join(`
1942
- `)}return t}};import{UniformsLib as Vg,UniformsUtils as CA}from"three";var so=function(){let n=new H(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1942
+ `)}return t}};import{UniformsLib as jg,UniformsUtils as IA}from"three";var so=function(){let n=new H(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
1943
1943
 
1944
1944
  // Gradient of UVs w.r.t. X coordinate (in screen-space)
1945
1945
  vec2 dSTdx = dFdx(bumpMapUv);
@@ -1970,7 +1970,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1970
1970
 
1971
1971
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
1972
1972
  return normalize( abs( fDet ) * vN - vGrad );
1973
- }`);return{dHdxy:n,perturbNormalArb:r}}();var es=class extends pt{constructor(){super("phong");this.nodeType="Phong";this.color=new Me(rt),this.specular=new Me(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new $e(!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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(CA.merge([Vg.fog,Vg.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(`
1973
+ }`);return{dHdxy:n,perturbNormalArb:r}}();var ts=class extends pt{constructor(){super("phong");this.nodeType="Phong";this.color=new Me(rt),this.specular=new Me(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new $e(!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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(IA.merge([jg.fog,jg.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(`
1974
1974
  `));let i=["#include <beginnormal_vertex>",`
1975
1975
  #include <skinbase_vertex>
1976
1976
  #include <skinnormal_vertex>
@@ -2038,7 +2038,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2038
2038
  outgoingLight *= ao;
2039
2039
  }
2040
2040
  `),l&&f.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&f.push(`gl_FragColor.a *= ${p.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=f.join(`
2041
- `)}return t}};import{UniformsLib as Eu,UniformsUtils as NA}from"three";var ts=class extends pt{constructor(){super("standard");this.nodeType="Standard";this.color=new Me(rt),this.roughness=new J(.3),this.metalness=new J(0),this.reflectivity=new J(.5),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new $e(!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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(NA.merge([Eu.fog,Eu.lights])),Eu.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(`
2041
+ `)}return t}};import{UniformsLib as Lu,UniformsUtils as MA}from"three";var rs=class extends pt{constructor(){super("standard");this.nodeType="Standard";this.color=new Me(rt),this.roughness=new J(.3),this.metalness=new J(0),this.reflectivity=new J(.5),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new $e(!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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(MA.merge([Lu.fog,Lu.lights])),Lu.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(`
2042
2042
  `));let i=["#include <beginnormal_vertex>",`
2043
2043
  #if !defined( USE_LAYER_DISPLACE )
2044
2044
  #include <defaultnormal_vertex>
@@ -2129,7 +2129,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2129
2129
  outgoingLight *= ao;
2130
2130
  }
2131
2131
  `),d&&h.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f&&h.push(`gl_FragColor.a *= ${f.result};`),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=h.join(`
2132
- `)}return t}};import{UniformsLib as zg,UniformsUtils as IA}from"three";var rs=class extends pt{constructor(){super("toon");this.nodeType="Toon";this.color=new Me(rt),this.specular=new Me(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(IA.merge([zg.fog,zg.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(`
2132
+ `)}return t}};import{UniformsLib as Fg,UniformsUtils as EA}from"three";var os=class extends pt{constructor(){super("toon");this.nodeType="Toon";this.color=new Me(rt),this.specular=new Me(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new wt,this.previouseProjectionMatrix=new wt,this.shadingAlpha=new J(1),this.shadingBlend=new we(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:ve.frameIndex}),e.mergeUniform({resolution:ve.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(EA.merge([Fg.fog,Fg.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(`
2133
2133
  `));let i=["#include <beginnormal_vertex>",`
2134
2134
  #ifndef USE_LAYER_DISPLACE
2135
2135
  #include <defaultnormal_vertex>
@@ -2212,11 +2212,11 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2212
2212
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${c.result} );
2213
2213
  }
2214
2214
  `),u&&p.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),l?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
2215
- `)}return t}};import{VideoTexture as MA,Texture as EA}from"three";var ac=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 Du=class extends ac{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Lu;function jg(n){return typeof n=="string"?n:(Lu||(Lu=new Du),Lu.load(n))}var sc=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")}},lc=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 Ji=class extends sc{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let i=[1e3,1001,1002];for(let a of i){let s=this[a];s&&(s.image=this.img,s.needsUpdate=!0)}this.shared.requestRender()};if(this.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=jg(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new MA(this.img,void 0,e,e):o=new EA(this.img,void 0,e,e),this.loaded&&(o.needsUpdate=!0),this[e]=o,o}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var Jt=class extends Ji{};import{Vector2 as lo,Vector3 as Vr,Vector4 as cc}from"three";function Tt(n,r){return r.color(n)}function Fg(n,r){switch(n.type){case"fresnel":return BA(n,r);case"gradient":return RA(n,r);case"depth":return GA(n,r);case"normal":return VA(n,r);case"noise":return zA(n,r);case"rainbow":return jA(n,r);case"toon":return FA(n,r);case"outline":return kA(n,r);case"transmission":return UA(n,r);case"color":return DA(n,r);case"pattern":return HA(n,r)}}function LA(n){return{type:n.type}}function yr(n,r){let{alpha:e,mode:t,isMask:o}=n,i=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...LA(n),alpha:i,mode:t,isMask:o}}function DA(n,r){return{...yr(n,r),color:Tt(n.color,r)}}function BA(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:a}=n;return{...yr(n,r),color:Tt(a,r),bias:e,scale:t,intensity:o,factor:i}}function RA(n,r){let{gradientType:e,smooth:t,colors:o,steps:i,angle:a,offset:s,morph:c}=n;return{...yr(n,r),gradientType:e,smooth:t,colors:o.map(u=>new cc(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new lo(...s),morph:new lo(...c),angle:a}}function GA(n,r){let{gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:s,direction:c,colors:u,steps:l,smooth:d}=n;return{...yr(n,r),gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:new Vr(...s),direction:c?new Vr(...c):new Vr(1,0,0),colors:u.map(p=>p!==void 0?new cc(p[0],p[1],p[2],p[3]):new cc(0,0,0,0)),steps:l.slice(0,u.length),smooth:d}}function VA(n,r){let{cnormal:e}=n;return{...yr(n,r),cnormal:new Vr(e[0],e[1],e[2])}}function zA(n,r){return{...yr(n,r),scale:n.scale,move:n.move,fA:new lo(...n.fA),fB:new lo(...n.fB),size:new Vr(...n.size),distortion:new lo(...n.distortion),colorA:Tt(n.colorA,r),colorB:Tt(n.colorB,r),colorC:Tt(n.colorC,r),colorD:Tt(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 jA(n,r){return{...yr(n,r),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Vr(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Vr(...n.offset)}}function FA(n,r){return{...yr(n,r),positioning:n.positioning,colors:n.colors.map(e=>new cc(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Vr(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Tt(n.shadowColor,r),offset:new Vr(...n.offset)}}function kA(n,r){return{...yr(n,r),outlineColor:Tt(n.outlineColor,r),contourColor:Tt(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Vr(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function UA(n,r){return{...yr(n,r),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function HA(n,r){return{...yr(n,r),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new lo(...n.offset),colorA:Tt(n.colorA,r),colorB:Tt(n.colorB,r),frequency:new lo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new lo(...n.vertical),horizontal:new lo(...n.horizontal),sides:n.sides}}var Fo=class extends it{};import{Vector4 as WA}from"three";var Bu={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Ru={depth:["colors"]};function qA(n,r,e){if(r==="isMask")return!0;let t=Bu[n.type],o=Ru[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 Gu(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),c=t;c.image instanceof Jt||c.image.deref(),c.image=s}if("video"in i){let a=i.video,s=r.video(a),c=t;c.image instanceof Jt||c.image.deref(),c.image=s}if("wrapping"in i){let a=t;a.wrap=i.wrapping}if("repeat"in i||"offset"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),s.updateMatrix()}return o}function kg(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(Vu(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 zo))switch(o=o||qA(e,i,a),s.constructor){case Me:if(typeof a=="string"){let c=r.getColor(a);c&&(s.value=c);break}else{let c=a;s.value instanceof Fo?s.value=new it(c.r,c.g,c.b,c.a):s.setRGBA(c);break}case Vt:if(typeof a=="string"){let c=r.getColor(a);c&&(s.value=c);break}else{let c=a;s.value instanceof Fo?s.value=new it(c.r,c.g,c.b,c.a):s.value.setRGBA(c.r,c.g,c.b,c.a);break}case Ue:{let c=a;s.value.setX(c[0]),s.value.setY(c[1]);break}case St:{let c=a;s.value.setX(c[0]),s.value.setY(c[1]),s.value.setZ(c[2]);break}case It:{Gu(a,r,e);break}case hr:{s.value=a.map(c=>new WA(...c));break}default:{s.value=a;break}}}return o}var os=(n,r)=>(typeof n=="string"?Math.max(0,Math.min(1,Number(r.getVariable(n)??100)/100)):n)??1,jr=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)Vu(a,this,t,i)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Yt.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.image(t.texture.image):o.video(t.texture.video),a=new cn(i,t.texture.wrapping),s=new nc(i),c=new ic(t.texture.repeat,t.texture.offset),u=new J(t.crop?1:0),l=new we(t.projection??0),d=new we(["x","y","z"].indexOf(t.axis)??0),p=new we(t.side??0),f=new Ue(t.size?new gr(t.size[0],t.size[1]):new gr(100,100)),m=new J(t.blending??0),h=new J(os(t.alpha,o)),y=new we(t.mode??0),g=new $e(t.isMask??!1),x=new jo(a,s,u,l,d,p,f,m,c,h,y,g),S=new Ne(x.calpha,"f");return new je(r,e,t,{texture:a,textureSize:s,crop:u,projection:l,axis:d,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},x,y,S,g,o)}else if(t.type==="matcap"){let i=o.image(t.texture.image),a=new cn(i,t.texture.wrapping),s=new J(os(t.alpha,o)),c=new we(t.mode??0),u=new $e(t.isMask??!1),l=new Wi(a,s,c,u),d=new Ne(l.calpha,"f");return new je(r,e,t,{texture:a,alpha:s,mode:c,isMask:u},l,c,d,u,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new St(new zr(...t.offset)),a=new J(t.scale??10),s=new J(t.intensity??8),c=new J(t.movement??1),u=new we(t.noiseType??0),l=new we(t.voronoiStyle??0),d=new J(t.smoothness??.5),p=new J(t.seed??0),f=new J(t.highCut??1),m=new J(t.lowCut??0),h=new we(t.quality??1),y=new Qi(s,c,i,l,d,p,f,m,h,a,u);return new ns(r,e,t,{offset:i,scale:a,intensity:s,movement:c,noiseType:u,voronoiStyle:l,smoothness:d,seed:p,highCut:f,lowCut:m,quality:h},y,o)}else throw new Error;else return XA(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):kg(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Gu(o.props,t.shared,this):!0;return!1}dispose(){if($A(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Jt||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}},je=class extends jr{constructor(e,t,o,i,a,s,c,u,l){super(e,t,o,i,l);this.params=i;this.color=a;this.mode=s;this.alpha=c;this.isMask=u}},ns=class extends jr{constructor(e,t,o,i,a,s){super(e,t,o,i,s);this.position=a}},Yt=class extends jr{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 J(os(o.alpha,i)),c=new we(o.mode),u=new J(o.bumpMapIntensity),l=new J(os(o.alphaOverride,i)),d;if(!o.visible)a=new pn,d={};else if(o.category==="lambert"){a=new Ja;let p=new Me(i.color(o.emissive)??0),f=new $e(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new rs;let p=new J(o.shininess??30),f=new Me(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new ts;let p=new J(o.roughness??.3),f=new J(o.metalness??0),m=new J(o.reflectivity??.5),h=new $e(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:m,occlusion:h},a.roughness=p,a.metalness=f,a.reflectivity=m,a.occlusion=h}else{a=new es;let p=new J(o.shininess??30),f=new Me(o.specular!==void 0?i.color(o.specular)??1118481:1118481),m=new $e(o.occlusion??!0);d={shininess:p,specular:f,occlusion:m},a.shininess=p,a.specular=f,a.occlusion=m}return a.alpha=new J(1),a.shadingAlpha=s,a.shadingBlend=c,a.bumpMapIntensity=u,a.alphaOverride=l,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new Yt(e,t,o,a,d,i)}get category(){return this.node.category}};function $A(n){let r=n instanceof jr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function er(n){return{alpha:new J(n.alpha??1),mode:new we(n.mode??0),isMask:new $e(n.isMask??!1)}}function YA(n,r,e,t,o){switch(n.type){case"color":{let i=new Me(t.color??rt),a=er(t),s=new dn(i,a.alpha),c=new Ne(s.calpha,"f");return new je(r,e,n,{color:i,...a},s,a.mode,c,a.isMask,o)}case"fresnel":{let i=new Me(t.color??16777215),a=new J(t.bias??.1),s=new J(t.scale??1),c=new J(t.intensity??2),u=new J(t.factor??1),l=er(t),d=new Za(i,a,s,c,u,l.alpha,l.mode,l.isMask),p=new Ne(d.calpha,"f");return new je(r,e,n,{color:i,bias:a,scale:s,intensity:c,factor:u,...l},d,l.mode,p,l.isMask,o)}case"rainbow":{let i=new J(t.filmThickness??30),a=new J(t.movement??0),s=new St(t.wavelengths??new zr(0,0,0)),c=new J(t.noiseStrength??0),u=new J(t.noiseScale??1),l=new St(t.offset??new zr(0,0,0)),d=er(t),p=new Xi(i,a,s,c,u,l,d.alpha,d.isMask),f=new Ne(p.calpha,"f");return new je(r,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:c,noiseScale:u,offset:l,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new J(t.thickness??10),a=new J(t.ior??1.5),s=new J(t.roughness??.5),c=ve.transmissionSize,u=ve.transmissionRenderTarget,l=ve.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new Ue(p/d,1):new Ue(1,d/p),m=er(t),h=new Zi(i,a,s,c,u,l,f,m.alpha),y=new Ne(h.calpha,"f");return new je(r,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...m},h,m.mode,y,m.isMask,o)}case"toon":{let i=new we(t.positioning??0),a;t.colors?a=new hr(t.colors.length,t.colors):(a=new hr(10,new ea(0,0,0,1)),a.value[1]=new ea(1,1,1,1));let s;t.steps?s=new mr(t.steps.length,t.steps):(s=new mr(10,1),s.value[0]=0);let c=new St(t.source??new zr(0,0,0)),u=new $e(t.isWorldSpace??!0),l=new J(t.noiseStrength??0),d=new J(t.noiseScale??1),p=new Vt(t.shadowColor),f=new St(t.offset??new zr(0,0,0)),m=er(t),h=new Ki(i,a,s,c,u,l,d,p,f,m.alpha),y=new Ne(h.calpha,"f");return new je(r,e,n,{positioning:i,colors:a,steps:s,source:c,isWorldSpace:u,noiseStrength:l,noiseScale:d,shadowColor:p,offset:f,...m},h,m.mode,y,m.isMask,o)}case"outline":{let i=new Me(t.outlineColor??16777215),a=new Me(t.contourColor??16777215),s=new J(t.outlineWidth??.1),c=new J(t.contourWidth??.1),u=new J(t.outlineThreshold??.1),l=new J(t.contourThreshold??.1),d=new J(t.outlineSmoothing??.1),p=new J(t.contourFrequency??.1),f=new St(t.contourDirection??new zr(0,1,0)),m=new $e(t.positionalLines??!1),h=new $e(t.compensation??!0),y=ve.normalRenderTarget,g=ve.normalRenderTargetDepth,x=ve.pixelRatioNode,S=ve.resolution,w=er(t),b=new $i(i,a,s,c,u,l,d,p,f,m,h,S,y,g,x,w.alpha),T=new Ne(b.calpha,"f");return new je(r,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:c,outlineThreshold:u,contourThreshold:l,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:m,compensation:h,...w},b,w.mode,T,w.isMask,o)}case"depth":{let i=new we(t.gradientType??0),a=new $e(t.smooth??!1),s=new J(t.near??50),c=new J(t.far??200),u=new J(t.isVector??1),l=new J(t.isWorldSpace??0),d=new St(t.origin??new zr),p=new St(t.direction??new zr),f;t.colors?f=new hr(t.colors.length,t.colors):(f=new hr(2,new ea(0,0,0,1)),f.value[1]=new ea(1,1,1,1));let m;t.steps?m=new mr(t.steps.length,t.steps):(m=new mr(2,1),m.value[0]=0);let h=er(t),y=new Ui(i,a,s,c,u,l,d,p,f,m,h.alpha,h.isMask),g=new Ne(y.calpha,"f");return new je(r,e,n,{gradientType:i,smooth:a,near:s,far:c,isVector:u,isWorldSpace:l,origin:d,direction:p,colors:f,steps:m,...h},y,h.mode,g,h.isMask,o)}case"noise":{let i=new J(t.scale??1),a=new St(t.size??new zr(100,100,100)),s=new J(t.move??1),c=new Ue(t.fA??new gr(1.7,9.2)),u=new Ue(t.fB??new gr(8.3,2.8)),l=new Ue(t.distortion??new gr(1,1)),d=new Vt(t.colorA),p=new Vt(t.colorB),f=new Vt(t.colorC),m=new Vt(t.colorD),h=new we(t.noiseType??0),y=new we(t.voronoiStyle??0),g=new J(t.highCut??1),x=new J(t.lowCut??0),S=new J(t.smoothness??.5),w=new J(t.seed??.5),b=new we(t.quality??1),T=er(t),_=new qi(i,a,s,c,u,l,d,p,f,m,T.alpha,h,T.isMask,y,g,x,S,w,b),v=new Ne(_.calpha,"f");return new je(r,e,n,{scale:i,size:a,move:s,fA:c,fB:u,distortion:l,colorA:d,colorB:p,colorC:f,colorD:m,noiseType:h,...T,voronoiStyle:y,highCut:g,lowCut:x,smoothness:S,seed:w,quality:b},_,T.mode,v,T.isMask,o)}case"normal":{let i=new St(t.cnormal??new zr(1,1,1)),a=er(t),s=new ji(i,a.alpha),c=new Ne(s.calpha,"f");return new je(r,e,n,{cnormal:i,...a},s,a.mode,c,a.isMask,o)}case"gradient":{let i=new we(t.gradientType??0),a=new $e(t.smooth??!1),s;t.colors?s=new hr(t.colors.length,t.colors):(s=new hr(10,new ea(0,0,0,1)),s.value[1]=new ea(1,1,1,1));let c;t.steps?c=new mr(t.steps.length,t.steps):(c=new mr(10,1),c.value[0]=0);let u=new Ue(t.offset??new gr(0,0)),l=new Ue(t.morph??new gr(0,0)),d=new J(t.angle??0),p=er(t),f=new Hi(i,a,s,c,u,l,d,p.alpha,p.isMask),m=new Ne(f.calpha,"f");return new je(r,e,n,{gradientType:i,smooth:a,colors:s,steps:c,offset:u,morph:l,angle:d,...p},f,p.mode,m,p.isMask,o)}case"pattern":{let i=new we(t.style??0),a=new we(t.projection??0),s=new we(["x","y","z"].indexOf(t.axis)??0),c=new J(t.blending??0),u=new Ue(t.offset??new gr(0,0)),l=new Vt(t.colorA),d=new Vt(t.colorB),p=new Ue(t.frequency??new gr(10,10)),f=new J(t.size??.5),m=new J(t.variation??0),h=new J(t.smoothness??.5),y=new J(t.zigzag??0),g=new J(t.rotation??0),x=new Ue(t.vertical??new gr(0,1)),S=new Ue(t.horizontal??new gr(0,1)),w=new we(t.sides??6),b=er(t),T=new Yi(i,a,s,c,u,l,d,p,f,m,h,y,g,x,S,w,b.alpha,b.isMask),_=new Ne(T.calpha,"f");return new je(r,e,n,{style:i,projection:a,axis:s,blending:c,offset:u,colorA:l,colorB:d,frequency:p,size:f,variation:m,smoothness:h,zigzag:y,rotation:g,vertical:x,horizontal:S,sides:w,...b},T,b.mode,_,b.isMask,o)}default:{let i=new Me(1,0,0,1),a=er(t),s=new dn(i,a.alpha),c=new Ne(s.calpha,"f");return new je(r,e,n,{color:i,...a},s,a.mode,c,a.isMask,o)}}}function XA(n,r,e,t){let o=Fg(e,t);return YA(e,n,r,o,t)}function Vu(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=os(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 Ug(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,c=r.color(o.data.colorC).a,u=r.color(o.data.colorD).a,l=Math.min(a,Math.min(s,Math.min(c,u)));l<1&&(i=l)}e+=(1-e)*i}}return e<1}var jt=class extends KA{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}},dc=class extends jt{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()}},fn=class extends jt{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 dc(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){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??gt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>jr.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=Ug(e,t.shared),this.saveVariableLocations(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 Yt),this.lightLayer===void 0&&(this.lightLayer=new Yt(0,"",{...Ct.defaultData("light","phong"),visible:!1},new pn,{},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 Yt);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 je&&s.color instanceof jo&&(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=Ug(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=jr.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),c=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,c),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(c=>c.uuid===a);if(s){let c=t.layers.data(a);if(s.updateByOp({...e,path:e.path.slice(2)},c,o)){let l=jr.create(this.layerIdGen++,a,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===a),1,l),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 je?t.color.mask=void 0:t instanceof Yt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof je&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Yt?i.node.mask=new ft(t.color,t.alpha,ft.MUL):i instanceof je&&(i.isMask.value||(i.color.mask=new ft(t.color,t.alpha,ft.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof je),t=this.layers.findIndex(o=>o instanceof Yt);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 je){if(a.isMask.value)continue;o=new zi(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ne("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Yt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof je){if(i.isMask.value)continue;e=new zi(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 ns);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new ft(t,e[o].position,ft.ADD),t=new ft(t,new J(.5).setReadonly(!0),ft.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=(Bu[t.type]??[]).map(u=>t[u]),i=(Ru[t.type]??[]).map(u=>t[u]?.length??0),a=[...o,...i],s="isMask"in t&&t.isMask,c=`"${t.type}-${t.visible}-${s}"`;a.length?e+=`[${c}, "${a.join('","')}"],`:e+=c}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 oc;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 je){let t=e.params.texture;if(t instanceof cn&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(jt.prototype,{properties:{get:function(){return this.fragment.properties}}});var mn=class extends fn{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var $g=ya(Hg());var Wg=new Map;function qg(n){if(typeof n=="string")return n;let r=Wg.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},Wg.set(n,r)),r.url}var hn=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:qg(r),format:"wav"},this.sound=new $g.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()}};import{Box2 as ZA,Vector2 as yn,Path as Yg,Shape as QA,ShapeUtils as JA,Color as eC}from"three";var pc=class{constructor(){this.type="ShapePath";this.color=new eC;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Yg,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(h,y,g,x){let S=h.x,w=y.x,b=g.x,T=x.x,_=h.y,v=y.y,N=g.y,P=x.y,C=(T-b)*(_-N)-(P-N)*(S-b),O=(w-S)*(_-N)-(v-_)*(S-b),A=(P-N)*(w-S)-(T-b)*(v-_),M=C/A,L=O/A;if(A===0&&C!==0||M<=0||M>=1||L<0||L>1)return null;if(C===0&&A===0){for(let X=0;X<2;X++)if(i(X===0?g:x,h,y),t.loc===e.ORIGIN){let R=X===0?g:x;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(S+t.t*(w-S)).toPrecision(10),Z=+(_+t.t*(v-_)).toPrecision(10);return{x:R,y:Z,t:t.t}}return null}else{for(let Z=0;Z<2;Z++)if(i(Z===0?g:x,h,y),t.loc===e.ORIGIN){let z=Z===0?g:x;return{x:z.x,y:z.y,t:t.t}}let X=+(S+M*(w-S)).toPrecision(10),R=+(_+M*(v-_)).toPrecision(10);return{x:X,y:R,t:M}}}function i(h,y,g){let x=g.x-y.x,S=g.y-y.y,w=h.x-y.x,b=h.y-y.y,T=x*b-w*S;if(h.x===y.x&&h.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(h.x===g.x&&h.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(x*w<0||S*b<0){t.loc=e.BEHIND;return}if(Math.sqrt(x*x+S*S)<Math.sqrt(w*w+b*b)){t.loc=e.BEYOND;return}let _;x!==0?_=w/x:_=b/S,t.loc=e.BETWEEN,t.t=_}function a(h,y){let g=[],x=[];for(let S=1;S<h.length;S++){let w=h[S-1],b=h[S];for(let T=1;T<y.length;T++){let _=y[T-1],v=y[T],N=o(w,b,_,v);N!==null&&g.find(P=>P.t<=N.t+Number.EPSILON&&P.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),x.push(new yn(N.x,N.y)))}}return x}function s(h,y,g){let x=new yn;y.getCenter(x);let S=[];return g.forEach(w=>{w.boundingBox.containsPoint(x)&&a(h,w.points).forEach(T=>{S.push({identifier:w.identifier,isCW:w.isCW,point:T})})}),S.sort((w,b)=>w.point.x-b.point.x),S}function c(h,y,g,x,S){(S==null||S==="")&&(S="nonzero");let w=new yn;h.boundingBox.getCenter(w);let b=[new yn(g,w.y),new yn(x,w.y)],T=s(b,h.boundingBox,y);T.sort((O,A)=>O.point.x-A.point.x);let _=[],v=[];T.forEach(O=>{O.identifier===h.identifier?_.push(O):v.push(O)});let N=_[0].point.x,P=[],C=0;for(;C<v.length&&v[C].point.x<N;)P.length>0&&P[P.length-1]===v[C].identifier?P.pop():P.push(v[C].identifier),C++;if(P.push(h.identifier),S==="evenodd"){let O=P.length%2===0,A=P[P.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(S==="nonzero"){let O=!0,A=null,M=null;for(let L=0;L<P.length;L++){let X=P[L];y[X]&&(O?(M=y[X].isCW,O=!1,A=X):M!==y[X].isCW&&(M=y[X].isCW,O=!0))}return{identifier:h.identifier,isHole:O,for:A}}else console.warn('fill-rule: "'+S+'" is currently not implemented.')}let u=0,l=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,x=999999999,S=-999999999,w=999999999;for(let b=0;b<y.length;b++){let T=y[b];T.y>g&&(g=T.y),T.y<x&&(x=T.y),T.x>S&&(S=T.x),T.x<w&&(w=T.x)}d<=S&&(d=S+1),l>=w&&(l=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:JA.isClockWise(y),identifier:u++,boundingBox:new ZA(new yn(w,x),new yn(S,g))})});let f=p.map(h=>c(h,p,l,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new QA;g.curves=h.curves,f.filter(S=>S?.isHole&&S.for===h.identifier).forEach(S=>{if(S){let w=p[S.identifier],b=new Yg;b.curves=w.curves,g.holes.push(b)}}),m.push(g)}}),m}};var Kg,zu=new Promise(n=>{Kg=n}),Xg=!1;var fc;function Zg(){if(Xg)return;if(fc)return fc;async function n(){let e=await import("./opentype.js");Kg(e),Xg=!0}return fc=n(),fc}var is=class{async load(r,e,t=()=>{}){let{load:o}=await zu;o(r,(i,a)=>{i||!a?t(i??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await zu;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 tC(n){return await(await fetch(n)).arrayBuffer()}var rC=new is;async function ju(n){let r,e,t=!1;if(n.url?(r=await tC(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){let o=await rC.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}import{CubicBezierCurve as oC,LineCurve as nC,QuadraticBezierCurve as iC}from"three";function aC(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var mc=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=ju(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=ju(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,c=t.length===i.length;for(let u=0;u<t.length;u++){let l=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[s];if(aC(l,p)||c)a.push({char:d,index:l,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,m=e.charAt(s),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===l&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:l,replacements:h,replacementChars:Array.from(f)}),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(x=>this.getTextWidth(x,e)),s=e.width,c=this.getCharWidth(`
2215
+ `)}return t}};import{VideoTexture as LA,Texture as DA}from"three";var sc=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 Bu=class extends sc{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Du;function kg(n){return typeof n=="string"?n:(Du||(Du=new Bu),Du.load(n))}var lc=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")}},cc=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 ea=class extends lc{constructor(e,t){super(e,t.imageHolderCache);this.data=e;this.shared=t;this.loaded=!1;this.isVideo=!1;this.isVideo=e.type==="video",this.updateSrc(e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;let i=[1e3,1001,1002];for(let a of i){let s=this[a];s&&(s.image=this.img,s.needsUpdate=!0)}this.shared.requestRender()};if(this.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=kg(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new LA(this.img,void 0,e,e):o=new DA(this.img,void 0,e,e),this.loaded&&(o.needsUpdate=!0),this[e]=o,o}}disposeTextures(){this[1e3]?.dispose(),this[1e3]=void 0,this[1001]?.dispose(),this[1001]=void 0,this[1002]?.dispose(),this[1002]=void 0}dispose(){super.dispose(),this.disposeTextures()}};1e3,1001,1002;var Jt=class extends ea{};import{Vector2 as lo,Vector3 as Vr,Vector4 as dc}from"three";function Tt(n,r){return r.color(n)}function Ug(n,r){switch(n.type){case"fresnel":return GA(n,r);case"gradient":return VA(n,r);case"depth":return zA(n,r);case"normal":return jA(n,r);case"noise":return FA(n,r);case"rainbow":return kA(n,r);case"toon":return UA(n,r);case"outline":return HA(n,r);case"transmission":return WA(n,r);case"color":return RA(n,r);case"pattern":return qA(n,r)}}function BA(n){return{type:n.type}}function yr(n,r){let{alpha:e,mode:t,isMask:o}=n,i=typeof e=="string"?(Number(r.getVariable(e))??100)/100:e;return{...BA(n),alpha:i,mode:t,isMask:o}}function RA(n,r){return{...yr(n,r),color:Tt(n.color,r)}}function GA(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:a}=n;return{...yr(n,r),color:Tt(a,r),bias:e,scale:t,intensity:o,factor:i}}function VA(n,r){let{gradientType:e,smooth:t,colors:o,steps:i,angle:a,offset:s,morph:c}=n;return{...yr(n,r),gradientType:e,smooth:t,colors:o.map(u=>new dc(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new lo(...s),morph:new lo(...c),angle:a}}function zA(n,r){let{gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:s,direction:c,colors:u,steps:l,smooth:d}=n;return{...yr(n,r),gradientType:e,near:t,far:o,isVector:i,isWorldSpace:a,origin:new Vr(...s),direction:c?new Vr(...c):new Vr(1,0,0),colors:u.map(p=>p!==void 0?new dc(p[0],p[1],p[2],p[3]):new dc(0,0,0,0)),steps:l.slice(0,u.length),smooth:d}}function jA(n,r){let{cnormal:e}=n;return{...yr(n,r),cnormal:new Vr(e[0],e[1],e[2])}}function FA(n,r){return{...yr(n,r),scale:n.scale,move:n.move,fA:new lo(...n.fA),fB:new lo(...n.fB),size:new Vr(...n.size),distortion:new lo(...n.distortion),colorA:Tt(n.colorA,r),colorB:Tt(n.colorB,r),colorC:Tt(n.colorC,r),colorD:Tt(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 kA(n,r){return{...yr(n,r),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Vr(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Vr(...n.offset)}}function UA(n,r){return{...yr(n,r),positioning:n.positioning,colors:n.colors.map(e=>new dc(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Vr(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Tt(n.shadowColor,r),offset:new Vr(...n.offset)}}function HA(n,r){return{...yr(n,r),outlineColor:Tt(n.outlineColor,r),contourColor:Tt(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Vr(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function WA(n,r){return{...yr(n,r),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function qA(n,r){return{...yr(n,r),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new lo(...n.offset),colorA:Tt(n.colorA,r),colorB:Tt(n.colorB,r),frequency:new lo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new lo(...n.vertical),horizontal:new lo(...n.horizontal),sides:n.sides}}var Fo=class extends it{};import{Vector4 as $A}from"three";var Ru={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Gu={depth:["colors"]};function YA(n,r,e){if(r==="isMask")return!0;let t=Ru[n.type],o=Gu[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 Vu(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),c=t;c.image instanceof Jt||c.image.deref(),c.image=s}if("video"in i){let a=i.video,s=r.video(a),c=t;c.image instanceof Jt||c.image.deref(),c.image=s}if("wrapping"in i){let a=t;a.wrap=i.wrapping}if("repeat"in i||"offset"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),s.updateMatrix()}return o}function Hg(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(zu(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 zo))switch(o=o||YA(e,i,a),s.constructor){case Me:if(typeof a=="string"){let c=r.getColor(a);c&&(s.value=c);break}else{let c=a;s.value instanceof Fo?s.value=new it(c.r,c.g,c.b,c.a):s.setRGBA(c);break}case Vt:if(typeof a=="string"){let c=r.getColor(a);c&&(s.value=c);break}else{let c=a;s.value instanceof Fo?s.value=new it(c.r,c.g,c.b,c.a):s.value.setRGBA(c.r,c.g,c.b,c.a);break}case Ue:{let c=a;s.value.setX(c[0]),s.value.setY(c[1]);break}case St:{let c=a;s.value.setX(c[0]),s.value.setY(c[1]),s.value.setZ(c[2]);break}case It:{Vu(a,r,e);break}case hr:{s.value=a.map(c=>new $A(...c));break}default:{s.value=a;break}}}return o}var ns=(n,r)=>(typeof n=="string"?Math.max(0,Math.min(1,Number(r.getVariable(n)??100)/100)):n)??1,jr=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)zu(a,this,t,i)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return Yt.createLigherLayer(r,e,t,o);if(t.type==="texture"||t.type==="video"){let i=t.type==="texture"?o.image(t.texture.image):o.video(t.texture.video),a=new cn(i,t.texture.wrapping),s=new ic(i),c=new ac(t.texture.repeat,t.texture.offset),u=new J(t.crop?1:0),l=new we(t.projection??0),d=new we(["x","y","z"].indexOf(t.axis)??0),p=new we(t.side??0),f=new Ue(t.size?new gr(t.size[0],t.size[1]):new gr(100,100)),m=new J(t.blending??0),h=new J(ns(t.alpha,o)),y=new we(t.mode??0),g=new $e(t.isMask??!1),x=new jo(a,s,u,l,d,p,f,m,c,h,y,g),S=new Ne(x.calpha,"f");return new je(r,e,t,{texture:a,textureSize:s,crop:u,projection:l,axis:d,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},x,y,S,g,o)}else if(t.type==="matcap"){let i=o.image(t.texture.image),a=new cn(i,t.texture.wrapping),s=new J(ns(t.alpha,o)),c=new we(t.mode??0),u=new $e(t.isMask??!1),l=new qi(a,s,c,u),d=new Ne(l.calpha,"f");return new je(r,e,t,{texture:a,alpha:s,mode:c,isMask:u},l,c,d,u,o)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new St(new zr(...t.offset)),a=new J(t.scale??10),s=new J(t.intensity??8),c=new J(t.movement??1),u=new we(t.noiseType??0),l=new we(t.voronoiStyle??0),d=new J(t.smoothness??.5),p=new J(t.seed??0),f=new J(t.highCut??1),m=new J(t.lowCut??0),h=new we(t.quality??1),y=new Ji(s,c,i,l,d,p,f,m,h,a,u);return new is(r,e,t,{offset:i,scale:a,intensity:s,movement:c,noiseType:u,voronoiStyle:l,smoothness:d,seed:p,highCut:f,lowCut:m,quality:h},y,o)}else throw new Error;else return ZA(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):Hg(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Vu(o.props,t.shared,this):!0;return!1}dispose(){if(XA(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Jt||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}},je=class extends jr{constructor(e,t,o,i,a,s,c,u,l){super(e,t,o,i,l);this.params=i;this.color=a;this.mode=s;this.alpha=c;this.isMask=u}},is=class extends jr{constructor(e,t,o,i,a,s){super(e,t,o,i,s);this.position=a}},Yt=class extends jr{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 J(ns(o.alpha,i)),c=new we(o.mode),u=new J(o.bumpMapIntensity),l=new J(ns(o.alphaOverride,i)),d;if(!o.visible)a=new pn,d={};else if(o.category==="lambert"){a=new es;let p=new Me(i.color(o.emissive)??0),f=new $e(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new os;let p=new J(o.shininess??30),f=new Me(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new rs;let p=new J(o.roughness??.3),f=new J(o.metalness??0),m=new J(o.reflectivity??.5),h=new $e(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:m,occlusion:h},a.roughness=p,a.metalness=f,a.reflectivity=m,a.occlusion=h}else{a=new ts;let p=new J(o.shininess??30),f=new Me(o.specular!==void 0?i.color(o.specular)??1118481:1118481),m=new $e(o.occlusion??!0);d={shininess:p,specular:f,occlusion:m},a.shininess=p,a.specular=f,a.occlusion=m}return a.alpha=new J(1),a.shadingAlpha=s,a.shadingBlend=c,a.bumpMapIntensity=u,a.alphaOverride=l,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new Yt(e,t,o,a,d,i)}get category(){return this.node.category}};function XA(n){let r=n instanceof jr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function er(n){return{alpha:new J(n.alpha??1),mode:new we(n.mode??0),isMask:new $e(n.isMask??!1)}}function KA(n,r,e,t,o){switch(n.type){case"color":{let i=new Me(t.color??rt),a=er(t),s=new dn(i,a.alpha),c=new Ne(s.calpha,"f");return new je(r,e,n,{color:i,...a},s,a.mode,c,a.isMask,o)}case"fresnel":{let i=new Me(t.color??16777215),a=new J(t.bias??.1),s=new J(t.scale??1),c=new J(t.intensity??2),u=new J(t.factor??1),l=er(t),d=new Qa(i,a,s,c,u,l.alpha,l.mode,l.isMask),p=new Ne(d.calpha,"f");return new je(r,e,n,{color:i,bias:a,scale:s,intensity:c,factor:u,...l},d,l.mode,p,l.isMask,o)}case"rainbow":{let i=new J(t.filmThickness??30),a=new J(t.movement??0),s=new St(t.wavelengths??new zr(0,0,0)),c=new J(t.noiseStrength??0),u=new J(t.noiseScale??1),l=new St(t.offset??new zr(0,0,0)),d=er(t),p=new Ki(i,a,s,c,u,l,d.alpha,d.isMask),f=new Ne(p.calpha,"f");return new je(r,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:c,noiseScale:u,offset:l,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new J(t.thickness??10),a=new J(t.ior??1.5),s=new J(t.roughness??.5),c=ve.transmissionSize,u=ve.transmissionRenderTarget,l=ve.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new Ue(p/d,1):new Ue(1,d/p),m=er(t),h=new Qi(i,a,s,c,u,l,f,m.alpha),y=new Ne(h.calpha,"f");return new je(r,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...m},h,m.mode,y,m.isMask,o)}case"toon":{let i=new we(t.positioning??0),a;t.colors?a=new hr(t.colors.length,t.colors):(a=new hr(10,new ta(0,0,0,1)),a.value[1]=new ta(1,1,1,1));let s;t.steps?s=new mr(t.steps.length,t.steps):(s=new mr(10,1),s.value[0]=0);let c=new St(t.source??new zr(0,0,0)),u=new $e(t.isWorldSpace??!0),l=new J(t.noiseStrength??0),d=new J(t.noiseScale??1),p=new Vt(t.shadowColor),f=new St(t.offset??new zr(0,0,0)),m=er(t),h=new Zi(i,a,s,c,u,l,d,p,f,m.alpha),y=new Ne(h.calpha,"f");return new je(r,e,n,{positioning:i,colors:a,steps:s,source:c,isWorldSpace:u,noiseStrength:l,noiseScale:d,shadowColor:p,offset:f,...m},h,m.mode,y,m.isMask,o)}case"outline":{let i=new Me(t.outlineColor??16777215),a=new Me(t.contourColor??16777215),s=new J(t.outlineWidth??.1),c=new J(t.contourWidth??.1),u=new J(t.outlineThreshold??.1),l=new J(t.contourThreshold??.1),d=new J(t.outlineSmoothing??.1),p=new J(t.contourFrequency??.1),f=new St(t.contourDirection??new zr(0,1,0)),m=new $e(t.positionalLines??!1),h=new $e(t.compensation??!0),y=ve.normalRenderTarget,g=ve.normalRenderTargetDepth,x=ve.pixelRatioNode,S=ve.resolution,w=er(t),b=new Yi(i,a,s,c,u,l,d,p,f,m,h,S,y,g,x,w.alpha),T=new Ne(b.calpha,"f");return new je(r,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:c,outlineThreshold:u,contourThreshold:l,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:m,compensation:h,...w},b,w.mode,T,w.isMask,o)}case"depth":{let i=new we(t.gradientType??0),a=new $e(t.smooth??!1),s=new J(t.near??50),c=new J(t.far??200),u=new J(t.isVector??1),l=new J(t.isWorldSpace??0),d=new St(t.origin??new zr),p=new St(t.direction??new zr),f;t.colors?f=new hr(t.colors.length,t.colors):(f=new hr(2,new ta(0,0,0,1)),f.value[1]=new ta(1,1,1,1));let m;t.steps?m=new mr(t.steps.length,t.steps):(m=new mr(2,1),m.value[0]=0);let h=er(t),y=new Hi(i,a,s,c,u,l,d,p,f,m,h.alpha,h.isMask),g=new Ne(y.calpha,"f");return new je(r,e,n,{gradientType:i,smooth:a,near:s,far:c,isVector:u,isWorldSpace:l,origin:d,direction:p,colors:f,steps:m,...h},y,h.mode,g,h.isMask,o)}case"noise":{let i=new J(t.scale??1),a=new St(t.size??new zr(100,100,100)),s=new J(t.move??1),c=new Ue(t.fA??new gr(1.7,9.2)),u=new Ue(t.fB??new gr(8.3,2.8)),l=new Ue(t.distortion??new gr(1,1)),d=new Vt(t.colorA),p=new Vt(t.colorB),f=new Vt(t.colorC),m=new Vt(t.colorD),h=new we(t.noiseType??0),y=new we(t.voronoiStyle??0),g=new J(t.highCut??1),x=new J(t.lowCut??0),S=new J(t.smoothness??.5),w=new J(t.seed??.5),b=new we(t.quality??1),T=er(t),_=new $i(i,a,s,c,u,l,d,p,f,m,T.alpha,h,T.isMask,y,g,x,S,w,b),v=new Ne(_.calpha,"f");return new je(r,e,n,{scale:i,size:a,move:s,fA:c,fB:u,distortion:l,colorA:d,colorB:p,colorC:f,colorD:m,noiseType:h,...T,voronoiStyle:y,highCut:g,lowCut:x,smoothness:S,seed:w,quality:b},_,T.mode,v,T.isMask,o)}case"normal":{let i=new St(t.cnormal??new zr(1,1,1)),a=er(t),s=new Fi(i,a.alpha),c=new Ne(s.calpha,"f");return new je(r,e,n,{cnormal:i,...a},s,a.mode,c,a.isMask,o)}case"gradient":{let i=new we(t.gradientType??0),a=new $e(t.smooth??!1),s;t.colors?s=new hr(t.colors.length,t.colors):(s=new hr(10,new ta(0,0,0,1)),s.value[1]=new ta(1,1,1,1));let c;t.steps?c=new mr(t.steps.length,t.steps):(c=new mr(10,1),c.value[0]=0);let u=new Ue(t.offset??new gr(0,0)),l=new Ue(t.morph??new gr(0,0)),d=new J(t.angle??0),p=er(t),f=new Wi(i,a,s,c,u,l,d,p.alpha,p.isMask),m=new Ne(f.calpha,"f");return new je(r,e,n,{gradientType:i,smooth:a,colors:s,steps:c,offset:u,morph:l,angle:d,...p},f,p.mode,m,p.isMask,o)}case"pattern":{let i=new we(t.style??0),a=new we(t.projection??0),s=new we(["x","y","z"].indexOf(t.axis)??0),c=new J(t.blending??0),u=new Ue(t.offset??new gr(0,0)),l=new Vt(t.colorA),d=new Vt(t.colorB),p=new Ue(t.frequency??new gr(10,10)),f=new J(t.size??.5),m=new J(t.variation??0),h=new J(t.smoothness??.5),y=new J(t.zigzag??0),g=new J(t.rotation??0),x=new Ue(t.vertical??new gr(0,1)),S=new Ue(t.horizontal??new gr(0,1)),w=new we(t.sides??6),b=er(t),T=new Xi(i,a,s,c,u,l,d,p,f,m,h,y,g,x,S,w,b.alpha,b.isMask),_=new Ne(T.calpha,"f");return new je(r,e,n,{style:i,projection:a,axis:s,blending:c,offset:u,colorA:l,colorB:d,frequency:p,size:f,variation:m,smoothness:h,zigzag:y,rotation:g,vertical:x,horizontal:S,sides:w,...b},T,b.mode,_,b.isMask,o)}default:{let i=new Me(1,0,0,1),a=er(t),s=new dn(i,a.alpha),c=new Ne(s.calpha,"f");return new je(r,e,n,{color:i,...a},s,a.mode,c,a.isMask,o)}}}function ZA(n,r,e,t){let o=Ug(e,t);return KA(e,n,r,o,t)}function zu(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=ns(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 Wg(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,c=r.color(o.data.colorC).a,u=r.color(o.data.colorD).a,l=Math.min(a,Math.min(s,Math.min(c,u)));l<1&&(i=l)}e+=(1-e)*i}}return e<1}var jt=class extends QA{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}},uc=class extends jt{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()}},fn=class extends jt{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 uc(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){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??gt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>jr.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=Wg(e,t.shared),this.saveVariableLocations(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 Yt),this.lightLayer===void 0&&(this.lightLayer=new Yt(0,"",{...Ct.defaultData("light","phong"),visible:!1},new pn,{},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 Yt);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 je&&s.color instanceof jo&&(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=Wg(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=jr.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),c=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,c),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(c=>c.uuid===a);if(s){let c=t.layers.data(a);if(s.updateByOp({...e,path:e.path.slice(2)},c,o)){let l=jr.create(this.layerIdGen++,a,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===a),1,l),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 je?t.color.mask=void 0:t instanceof Yt&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof je&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof Yt?i.node.mask=new ft(t.color,t.alpha,ft.MUL):i instanceof je&&(i.isMask.value||(i.color.mask=new ft(t.color,t.alpha,ft.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof je),t=this.layers.findIndex(o=>o instanceof Yt);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 je){if(a.isMask.value)continue;o=new ji(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ne("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof Yt);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof je){if(i.isMask.value)continue;e=new ji(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 is);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new ft(t,e[o].position,ft.ADD),t=new ft(t,new J(.5).setReadonly(!0),ft.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=(Ru[t.type]??[]).map(u=>t[u]),i=(Gu[t.type]??[]).map(u=>t[u]?.length??0),a=[...o,...i],s="isMask"in t&&t.isMask,c=`"${t.type}-${t.visible}-${s}"`;a.length?e+=`[${c}, "${a.join('","')}"],`:e+=c}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 nc;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 je){let t=e.params.texture;if(t instanceof cn&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(jt.prototype,{properties:{get:function(){return this.fragment.properties}}});var mn=class extends fn{constructor(r,e,t){super(r,e,!1),this.uuid=t,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Xg=ga(qg());var $g=new Map;function Yg(n){if(typeof n=="string")return n;let r=$g.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},$g.set(n,r)),r.url}var hn=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:Yg(r),format:"wav"},this.sound=new Xg.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()}};import{Box2 as JA,Vector2 as yn,Path as Kg,Shape as eC,ShapeUtils as tC,Color as rC}from"three";var fc=class{constructor(){this.type="ShapePath";this.color=new rC;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Kg,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(h,y,g,x){let S=h.x,w=y.x,b=g.x,T=x.x,_=h.y,v=y.y,N=g.y,P=x.y,C=(T-b)*(_-N)-(P-N)*(S-b),O=(w-S)*(_-N)-(v-_)*(S-b),A=(P-N)*(w-S)-(T-b)*(v-_),M=C/A,L=O/A;if(A===0&&C!==0||M<=0||M>=1||L<0||L>1)return null;if(C===0&&A===0){for(let X=0;X<2;X++)if(i(X===0?g:x,h,y),t.loc===e.ORIGIN){let R=X===0?g:x;return{x:R.x,y:R.y,t:t.t}}else if(t.loc===e.BETWEEN){let R=+(S+t.t*(w-S)).toPrecision(10),Z=+(_+t.t*(v-_)).toPrecision(10);return{x:R,y:Z,t:t.t}}return null}else{for(let Z=0;Z<2;Z++)if(i(Z===0?g:x,h,y),t.loc===e.ORIGIN){let z=Z===0?g:x;return{x:z.x,y:z.y,t:t.t}}let X=+(S+M*(w-S)).toPrecision(10),R=+(_+M*(v-_)).toPrecision(10);return{x:X,y:R,t:M}}}function i(h,y,g){let x=g.x-y.x,S=g.y-y.y,w=h.x-y.x,b=h.y-y.y,T=x*b-w*S;if(h.x===y.x&&h.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(h.x===g.x&&h.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(x*w<0||S*b<0){t.loc=e.BEHIND;return}if(Math.sqrt(x*x+S*S)<Math.sqrt(w*w+b*b)){t.loc=e.BEYOND;return}let _;x!==0?_=w/x:_=b/S,t.loc=e.BETWEEN,t.t=_}function a(h,y){let g=[],x=[];for(let S=1;S<h.length;S++){let w=h[S-1],b=h[S];for(let T=1;T<y.length;T++){let _=y[T-1],v=y[T],N=o(w,b,_,v);N!==null&&g.find(P=>P.t<=N.t+Number.EPSILON&&P.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),x.push(new yn(N.x,N.y)))}}return x}function s(h,y,g){let x=new yn;y.getCenter(x);let S=[];return g.forEach(w=>{w.boundingBox.containsPoint(x)&&a(h,w.points).forEach(T=>{S.push({identifier:w.identifier,isCW:w.isCW,point:T})})}),S.sort((w,b)=>w.point.x-b.point.x),S}function c(h,y,g,x,S){(S==null||S==="")&&(S="nonzero");let w=new yn;h.boundingBox.getCenter(w);let b=[new yn(g,w.y),new yn(x,w.y)],T=s(b,h.boundingBox,y);T.sort((O,A)=>O.point.x-A.point.x);let _=[],v=[];T.forEach(O=>{O.identifier===h.identifier?_.push(O):v.push(O)});let N=_[0].point.x,P=[],C=0;for(;C<v.length&&v[C].point.x<N;)P.length>0&&P[P.length-1]===v[C].identifier?P.pop():P.push(v[C].identifier),C++;if(P.push(h.identifier),S==="evenodd"){let O=P.length%2===0,A=P[P.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(S==="nonzero"){let O=!0,A=null,M=null;for(let L=0;L<P.length;L++){let X=P[L];y[X]&&(O?(M=y[X].isCW,O=!1,A=X):M!==y[X].isCW&&(M=y[X].isCW,O=!0))}return{identifier:h.identifier,isHole:O,for:A}}else console.warn('fill-rule: "'+S+'" is currently not implemented.')}let u=0,l=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,x=999999999,S=-999999999,w=999999999;for(let b=0;b<y.length;b++){let T=y[b];T.y>g&&(g=T.y),T.y<x&&(x=T.y),T.x>S&&(S=T.x),T.x<w&&(w=T.x)}d<=S&&(d=S+1),l>=w&&(l=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:tC.isClockWise(y),identifier:u++,boundingBox:new JA(new yn(w,x),new yn(S,g))})});let f=p.map(h=>c(h,p,l,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new eC;g.curves=h.curves,f.filter(S=>S?.isHole&&S.for===h.identifier).forEach(S=>{if(S){let w=p[S.identifier],b=new Kg;b.curves=w.curves,g.holes.push(b)}}),m.push(g)}}),m}};var Qg,ju=new Promise(n=>{Qg=n}),Zg=!1;var mc;function Jg(){if(Zg)return;if(mc)return mc;async function n(){let e=await import("./opentype.js");Qg(e),Zg=!0}return mc=n(),mc}var as=class{async load(r,e,t=()=>{}){let{load:o}=await ju;o(r,(i,a)=>{i||!a?t(i??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await ju;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 oC(n){return await(await fetch(n)).arrayBuffer()}var nC=new as;async function Fu(n){let r,e,t=!1;if(n.url?(r=await oC(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){let o=await nC.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}import{CubicBezierCurve as iC,LineCurve as aC,QuadraticBezierCurve as sC}from"three";function lC(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var hc=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Fu(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=Fu(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,c=t.length===i.length;for(let u=0;u<t.length;u++){let l=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[s];if(lC(l,p)||c)a.push({char:d,index:l,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,m=e.charAt(s),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===l&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:l,replacements:h,replacementChars:Array.from(f)}),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(x=>this.getTextWidth(x,e)),s=e.width,c=this.getCharWidth(`
2216
2216
  `,e),u=e.horizontalAlign===1?c:0,l=this.computeSpaceWidthForLine(r,0,e),d=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,r[0],c),p=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),f=[],m=r.map(x=>[]),h=r.map(x=>[]),y;for(let x=0;x<r.length;x++){let S=r[x],w={features:{liga:!0}},b=[];try{b=t.stringToGlyphs(S,w)}catch(_){console.warn(_)}d=this.getLineInitialOffsetX(a[x],s,e.horizontalAlign,S,c);let T=[];try{T=this.reverseLigaturesTable(t,S,b)}catch(_){console.warn(_)}l=this.computeSpaceWidthForLine(r,x,e);for(let _=0;_<b.length;_++){let v=b[_],N=v.index===0?`
2217
2217
  `:v.unicode?String.fromCharCode(v.unicode):void 0,P=T[_],C=0,O=0;_===0&&e.horizontalAlign===2&&v.leftSideBearing!==void 0&&(O=-v.leftSideBearing*o),y&&(C=t.getKerningValue(v,y)*o),d+=O+C;let A=0;if(N===`
2218
2218
  `)A=u;else if(N===" ")A=l;else{let M=this.createPath(v,o,d,p,e);M&&(A=M.offsetX-(C+O),f.push(M.path))}if(P.replacements.length===1)h[x].push([d,p]),m[x].push(A);else{let M=P.replacements.map(Z=>(t.glyphs.get(Z).advanceWidth??0)*o),L=M.reduce((Z,z)=>Z+=z,0),X=M.map(Z=>Z/L),R=d;for(let Z=0;Z<X.length;Z++){let z=A*X[Z];h[x].push([R,p]),m[x].push(z),R+=z}}d+=A,y=v}p-=i}let g=[];for(let x=0,S=f.length;x<S;x++)g.push(...f[x].toShapes());return{shapes:g,charWidths:m,lineWidths:a,charCoords:h}}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(`
2219
- `)>=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,c=r-s,u=-this.ascender*o-c/2;return i===3?-(t-a-u):i===2?-(t*.5-a*.5-u):u}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 pc,c=(r.advanceWidth??1)*e;if(r)for(let u of a.commands){let l=s.currentPath?.currentPoint;if(!(l&&u.type!=="Z"&&l.x===u.x&&-l.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 l=sC(u.curves);l!==void 0&&u.currentPoint.distanceTo(l)>0&&u.lineTo(l.x,l.y)}),{offsetX:c+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,c=this.getTextWidth(i,t);return(s-(c-a*o))/a}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function sC(n){if(n.length){let r=n[0];if(r instanceof nC)return r.v1;if(r instanceof oC||r instanceof iC)return r.v0}}var Fu=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()}},as=class extends Fu{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let i=an(e,t,this.flatShading,o);return i.computeBoundingSphere(),i}};var Qg={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as cC}from"three";var ku=class extends lc{constructor(e){super();this.shared=e}create(e){return new Ji(e,this.shared)}},gn=class{constructor(r,e={}){this.data=r;this.geometryCache=new as(!0);this.geometryCache2=new as(!1);this.imageHolderCache=new ku(this);this.thisContext={scene:Qg,shared:this};this.deletedMaterial=new mn(gt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Jt(di.emptyImage,this);this.deletedVideo=new Jt(ti.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};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);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.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 mn(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 fn(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 Jt(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)}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new Jt(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 Fo(e.r,e.g,e.b,e.a):this.colors[r]=new Fo(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 it(0,0,0,0))}else return"a"in r?new it(r.r,r.g,r.b,r.a):new it(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 hn)return e;{let t=new hn({src:e.data});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof hn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new mc(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 hn&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){this.addVariable(r,e.value)}addVariable(r,e){return this.variables[r]===void 0?(this.variables[r]={value:e,locations:[]},!0):(this.variables[r].value=e,!1)}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];o.traverseMaterial(u=>{let l=u.root??u;l.uuid===s&&l.reset({...u.data},{scene:o,shared:this})});let c=this.materials[s];c&&c.reset({...c.data},{scene:o,shared:this})}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].locations.splice(i,1);continue}if(a[1]!=="geometry"){for(let c=1;c<a.length-1;c++)s=s[a[c]];a[1]==="rotation"&&(t=cC.DEG2RAD*t),s[a[a.length-1]]=t}if(s=o.find(a[0]),Te.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let c=s;s.component&&(c=s.component);let u=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(u.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.instances.forEach(l=>{let d=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(d.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0)})}}}}return!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 t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],i=o.locations?.findIndex(a=>Je.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}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.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]==="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]==="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(et.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.addVariable(r.id,r.data.value):r.path.length===1&&r.type===5&&this.deleteVariable(r.id):r.path[0]==="lib"&&this.updateLibByOp(et.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)}}},Jg=new gn(ar.emptyData());var Ft=class extends bt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),km(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(_t(e.path,["material"])&&this.material instanceof jt)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(et.drop(e,1),t.material,o);else if(_t(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(et.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&&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&&gs(this.material).forEach(e=>{e instanceof jt&&(e instanceof mn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as dC,Matrix4 as Uu,Vector3 as n0,Vector4 as Hu}from"three";var e0=new n0,t0=new Hu,r0=new Hu,uC=new n0,o0=new Uu,Ze=class extends Ft{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.isSkinnedMesh=!0,this.bindMode=t.bindMode,this.bindMatrix=new Uu().fromArray(t.bindMatrix),this.bindMatrixInverse=new Uu)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof dC&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof gn){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 Ca.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Ca.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),_t(e.path,["geometry"])&&this.updateByPatchedOpGeometry(et.drop(e,1),t.geometry,o)}removeInteractionGeometry(){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 l={...this.data.geometry,...i};this.localGeometry=an(l,t,this.data.flatShading,this)}let a,s,c;i.scaleBaked?[a,s,c]=i.scaleBaked:{width:a,height:s,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&qa(this.localGeometry.attributes,a/u.sxPrev,s/u.syPrev,c/u.szPrev),u.sxPrev=a,u.syPrev=s,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=an(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 Ke&&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,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 Hu,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;t0.fromBufferAttribute(i.attributes.skinIndex,e),r0.fromBufferAttribute(i.attributes.skinWeight,e),e0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=r0.getComponent(a);if(s!==0){let c=t0.getComponent(a);o0.multiplyMatrices(o.bones[c].matrixWorld,o.boneInverses[c]),t.addScaledVector(uC.copy(e0).applyMatrix4(o0),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function fC(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]}`,c=new qu(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(c):r.set(s,{normals:[c],result:new qu})}r.forEach((a,s)=>{for(let c of a.normals)a.result.add(c);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]}`,c=r.get(s)?.result;c&&(i[a]=c.x,i[a+1]=c.y,i[a+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new i0(i,3))}function mC(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 qu;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 i0(t,3))}function ta(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof jt)||n.material.getLayersOfType("outline").length===0)return;n instanceof Ze&&n.is2DAndNoDepth?mC(n):fC(n)}function ra(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=[Wu.seededRandom(o),Wu.seededRandom(o+1e4),Wu.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=i[a%3];n.geometry.setAttribute("randomColor",new pC(t,3))}var xC;Ni.then(n=>{xC=n});var Fr=new hC,ss=new gC;function s0(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var xn=class extends Ze{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new yC;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}=Ke.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,ta(this),ra(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=o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){Ke.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Ke.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ke.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ke.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,bt.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 a0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Fr.setFromBufferAttribute(t),Fr.getCenter(o),e.boundingSphere.radius=o.distanceTo(Fr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fr.getSize(ss),this.hasNonUniformScale&&ss.divide(this.scale);let i={width:ss.x,height:ss.y,depth:ss.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;Fr.min.set(e[0],e[2],e[4]),Fr.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Fr.min.applyMatrix4(this.shearScaleInv),Fr.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new a0);let o=t.boundingSphere.center;Fr.getCenter(o),t.boundingSphere.radius=o.distanceTo(Fr.max)}freeSubdivPointer(){this.subdivPointer&&(Ke.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)}};import{Triangle as vC,Vector3 as bn}from"three";var l0=-1,bC=1,c0={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},d0={polygon_center:0,edge:1,vertex:2},ls=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,xe=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-l0)*(e-t)/(bC-l0)+t};function u0(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 SC=new bn,hc=new bn,wC=new bn,TC=new bn;function oa(n,r){let e=wC.fromArray(n),t=TC.fromArray(r);hc.copy(t).sub(e);let o=hc.length();return hc.normalize().multiplyScalar(o*.5),SC.copy(e).add(hc).toArray()}var tr=new vC,yc=new bn,gc=new bn,vn=new bn;function p0(n){let r=[];for(let e=0;e<=n.index.count;e++)if(yc.fromArray(n.index.array,e*3),tr.setFromAttributeAndIndices(n.attributes.position,yc.x,yc.y,yc.z),tr.getNormal(gc),tr.getMidpoint(vn),!(isNaN(vn.x)||isNaN(vn.y)||isNaN(vn.z))){let{a:t,b:o,c:i}=tr,a=t.toArray(),s=o.toArray(),c=i.toArray(),u=t.distanceTo(o),l=o.distanceTo(i),d=i.distanceTo(t),p=oa(a,s),f=oa(s,c),m=oa(c,a),h=[u,l,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,x=[],S=tr.getMidpoint(vn).toArray();y===u&&!g&&(x=[f,m,m],S=p),y===l&&!g&&(x=[p,m,m],S=f),y===d&&!g&&(x=[p,f,f],S=m),g&&(x=[p,f,m]),r.push({vertices:[a,s,c],faceCenters:x,midpoint:S,norm:tr.getNormal(gc).toArray()})}return r}function f0(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){tr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),tr.getNormal(gc),tr.getMidpoint(vn);let o=tr.a.toArray(),i=tr.b.toArray(),a=tr.c.toArray();r.push({vertices:[o,i,a],faceCenters:[oa(o,i),oa(i,a),oa(a,o)],midpoint:vn.toArray(),norm:gc.toArray()})}return r}var _C=4,PC=.5,$u=n=>.5*(1-Math.cos(n*Math.PI)),Yu=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,c=e-i,u=t-a,l,d,p=0,f=.5,m,h,y;for(let g=0;g<_C;g++){let x=o+(i<<4)+(a<<8);l=$u(s),d=$u(c),m=this.perlin[x&4095],m+=l*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=l*(this.perlin[x+16+1&4095]-h),m+=d*(h-m),x+=256,h=this.perlin[x&4095],h+=l*(this.perlin[x+1&4095]-h),y=this.perlin[x+16&4095],y+=l*(this.perlin[x+16+1&4095]-y),h+=d*(y-h),m+=$u(u)*(h-m),p+=m*f,f*=PC,o<<=1,s*=2,i<<=1,c*=2,a<<=1,u*=2,s>=1&&(o++,s--),c>=1&&(i++,c--),u>=1&&(a++,u--)}return p}noiseSeed(r){let e=(()=>{let a,s;return{setSeed(c){s=a=(c??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()}},m0=Yu;import{Vector3 as OC,Matrix4 as AC,Ray as CC}from"three";var h0=new OC,y0=new AC,g0=new CC;function x0(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var na=class extends Ze{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)&&(y0.copy(o).invert(),g0.copy(e.ray).applyMatrix4(y0),g0.intersectBox(this.singleBBox,h0))){let i=h0.applyMatrix4(o),a=e.ray.origin.distanceTo(i);t.push({distance:a,point:i.clone(),object:this})}}};var Mt=1e-4,kr,w0,T0,_0,b0=new Xt,S0=new Xt;Ni.then(n=>{kr=n,w0=[kr.get_face_center,kr.get_edge_midpoint,kr.get_vertex_position],T0=[kr.get_face_normal,kr.get_edge_normal,kr.get_vertex_normal],_0=[kr.face_count,kr.edge_count,kr.vertex_count]});var IC=new wn,MC=new wn,ko=new Xt,Sn=new Xt,cs=new Xt,Ku=new Xt,EC=new Xt,LC=new Xt;var co=new m0,aa=class extends pi(NC){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 no&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof no&&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 no(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 no(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*v0.DEG2RAD,i=t.end*v0.DEG2RAD,a=o-i,s=new Xu(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Xt(0,0,1);break;case"y":c=new Xt(0,1,0);break;default:case"x":c=new Xt(1,0,0);break}let u=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,l=u.noiseType==="perlin";co.noiseSeed(u.seed);let d=Pl((0,ia.default)(u.seed)),p=ls(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=l?co.noise(h):d(h,h),g=f+1;m.scale.x=t.scale[0]+p(g,xe(y,u.scale[0]))||Mt,m.scale.y=t.scale[1]+p(g,xe(y,u.scale[1]))||Mt,m.scale.z=t.scale[2]+p(g,xe(y,u.scale[2]))||Mt,m.position.setScalar(0);let x=a/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,x,0);break;case"y":m.rotation.set(0,0,x);break;case"z":m.rotation.set(x,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(g,xe(y,u.position[0])),m.position.y+=t.position[1]+p(g,xe(y,u.position[1])),m.position.z+=t.position[2]+p(g,xe(y,u.position[2]));let S=p(g,xe(y,u.rotation[0])),w=p(g,xe(y,u.rotation[1])),b=p(g,xe(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=s.x+S,m.rotation.y+=s.y+w,m.rotation.z+=s.z+b):m.rotation.set(s.x+S,s.y+w,s.z+b)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Xu(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";co.noiseSeed(i.seed);let s=Pl((0,ia.default)(i.seed)),c=ls(i.strength,this.parameters.randomness);for(let[u,l]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?co.noise(d):s(d,d),f=u+1,m=c(f,xe(p,i.rotation[0])),h=c(f,xe(p,i.rotation[1])),y=c(f,xe(p,i.rotation[2]));l.scale.x=1+(t.scale[0]-1)*u+c(f,xe(p,i.scale[0]))||Mt,l.scale.y=1+(t.scale[1]-1)*u+c(f,xe(p,i.scale[1]))||Mt,l.scale.z=1+(t.scale[2]-1)*u+c(f,xe(p,i.scale[2]))||Mt,l.rotation.x=o.x*u+m,l.rotation.y=o.y*u+h,l.rotation.z=o.z*u+y,l.position.x=t.position[0]*u+c(f,xe(p,i.position[0])),l.position.y=t.position[1]*u+c(f,xe(p,i.position[1])),l.position.z=t.position[2]*u+c(f,xe(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=ls(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";co.noiseSeed(i.seed);let c=Hh((0,ia.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},l=new Xt(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 m=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=s?co.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+a(t,xe(h,i.scale[0]))||Mt,y.scale.y=1+a(t,xe(h,i.scale[1]))||Mt,y.scale.z=1+a(t,xe(h,i.scale[2]))||Mt;let g=a(t,xe(h,i.rotation[0])),x=a(t,xe(h,i.rotation[1])),S=a(t,xe(h,i.rotation[2]));y.rotation.set(g,x,S),y.position.x=o.size[0]*d-l.x+a(t,xe(h,i.position[0])),y.position.y=o.size[1]*p-l.y+a(t,xe(h,i.position[1])),y.position.z=o.size[2]*f-l.z+a(t,xe(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let l=0;l<o.count[1];l++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(l+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=s?co.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+a(t,xe(f,i.scale[0]))||Mt,m.scale.y=1+a(t,xe(f,i.scale[1]))||Mt,m.scale.z=1+a(t,xe(f,i.scale[2]))||Mt;let h=a(t,xe(f,i.rotation[0])),y=a(t,xe(f,i.rotation[1])),g=a(t,xe(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*u+a(t,xe(f,i.position[0])),m.position.y=-o.size[1]*l+a(t,xe(f,i.position[1])),m.position.z=-o.size[2]*d+a(t,xe(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Xu(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";co.noiseSeed(i.seed);let s=Pl((0,ia.default)(i.seed)),c=ls(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 na)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(),l=[],d=g=>{let x=g.length,S=g.map(T=>T[0]).reduce((T,_)=>T+_,0),w=g.map(T=>T[1]).reduce((T,_)=>T+_,0),b=g.map(T=>T[2]).reduce((T,_)=>T+_,0);return[S/x,w/x,b/x]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let x=u.filter(S=>p(g.pos[0])===p(S.pos[0])&&p(g.pos[1])===p(S.pos[1])&&p(g.pos[2])===p(S.pos[2]));x.length>1?l.push({pos:g.pos,norm:d(x.map(S=>S.norm))}):l.push(g)});let f=u0(l);if(f.length>0){let g=Math.round(f.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 m=new Ol(this.objectForSample).build(),h=c0[t.axis],y=this.children;m.setRandomGenerator((0,ia.default)(this.object.uuid+t.seed));for(let[g,x]of y.entries()){let S=g*(i.freqScale/10)+i.movement,w=a?co.noise(S):s(S,S),b=g+1,T=c(b,xe(w,i.rotation[0])),_=c(b,xe(w,i.rotation[1])),v=c(b,xe(w,i.rotation[2]));t.spreadType==="random"?m.sample(cs,Ku):(f.length&&(cs.fromArray(f[g].pos),Ku.fromArray(f[g].norm)),this.objectForSample instanceof xn&&cs.applyMatrix4(IC.copy(this.objectForSample.matrixWorld).invert())),cs.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(cs),ko.fromArray(h);let N=t.align==="normal"?Ku:this.object.getWorldDirection(LC),P=Sn.fromArray(t.position);Sn.x+=Sn.x+c(b,xe(w,i.position[0])),Sn.y+=Sn.y+c(b,xe(w,i.position[1])),Sn.z+=Sn.z+c(b,xe(w,i.position[2]));let C=Math.acos(N.dot(ko)),O=EC.crossVectors(ko,N).normalize(),A=MC.makeRotationAxis(O,C),M=N.clone().cross(this.object.up).normalize(),L=M.clone().cross(N).normalize(),X=new wn().makeBasis(M,N,L),R=new Xt(ko.y,ko.z,ko.x).normalize(),Z=R.clone().cross(ko).normalize(),z=new wn().makeBasis(R,ko,Z).invert(),V=new wn().multiplyMatrices(X,z);x.rotation.setFromRotationMatrix(V),P.applyMatrix4(A),x.position.add(P),x.rotation.x=x.rotation.x+o.x+T,x.rotation.y=x.rotation.y+o.y+_,x.rotation.z=x.rotation.z+o.z+v,x.scale.setScalar(1),x.scale.x=x.scale.x+t.scale[0]+c(b,xe(w,i.scale[0]))||Mt,x.scale.y=x.scale.y+t.scale[1]+c(b,xe(w,i.scale[1]))||Mt,x.scale.z=x.scale.z+t.scale[2]+c(b,xe(w,i.scale[2]))||Mt,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof xn){let t=this.objectForSample,o=d0[e],i=_0[o],a=w0[o],s=T0[o],c=[],u=i(t.subdivPointerNew);for(let l=0;l<=u-1;l++){let d=a(t.subdivPointerNew,l),p=s(t.subdivPointerNew,l);b0.fromArray(d).applyMatrix4(t.matrixWorld),S0.fromArray(p),c.push({pos:b0.toArray(),norm:S0.toArray()})}return c}else return(this.objectForSample.geometry.index?p0(this.objectForSample.geometry):f0(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=Qr(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 bt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new wn,this.hiddenMatrix=new wn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as BN,Vector3 as RN,Matrix4 as GN,Box3 as VN,MeshBasicMaterial as zN,Skeleton as jN}from"three";import{Camera as WC,OrthographicCamera as qC,PerspectiveCamera as $C,Vector3 as vr,Object3D as C0,Quaternion as YC,Matrix4 as XC}from"three";import{Camera as zC,LineSegments as jC,BufferGeometry as FC,LineBasicMaterial as kC,Color as Qu,Vector3 as UC,Float32BufferAttribute as O0}from"three";import{BoxGeometry as DC}from"three";var Ur=n=>{var r;return r=class extends n{},r.geometryHelper=new DC(30,30,30),r};import{Ray as BC,Sphere as RC,Matrix4 as GC,Vector3 as uo}from"three";var xc=new BC,Zu=new RC,P0=new GC,Hr=(n,r,e,t,o=!1)=>{let i=r,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Zu.copy(i.boundingSphere),Zu.applyMatrix4(a),e.ray.intersectsSphere(Zu)===!1||(P0.copy(a).invert(),xc.copy(e.ray).applyMatrix4(P0),i.boundingBox!==null&&xc.intersectsBox(i.boundingBox)===!1))return;let s,c,u,l,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),x=Math.min(d.count,f.start+f.count);for(m=g,h=x;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),l=d.getX(m+2),s=y(n,e,xc,p,c,u,l),s){s.faceIndex=Math.floor(m/3),t.push(s);return}}else{let x=i.attributes.position,S=new uo,w=new uo,b=new uo,T=new uo,_=2,N=1/((n.scale.x+n.scale.y+n.scale.z)/3),P=N*N,C=Math.max(0,f.start),O=Math.min(x.count,f.start+f.count);for(let A=C,M=O-1;A<M;A+=_){if(S.fromBufferAttribute(x,A),w.fromBufferAttribute(x,A+1),xc.distanceSqToSegment(S,w,T,b)>P)continue;T.applyMatrix4(n.matrixWorld);let X=e.ray.origin.distanceTo(T);X<e.near||X>e.far||t.push({distance:X,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,x,S,w,b,T,_){let v=new uo,N=new uo,P=new uo,C=new uo,O=new uo;if(v.fromBufferAttribute(w,b),N.fromBufferAttribute(w,T),P.fromBufferAttribute(w,_),S.intersectTriangle(v,N,P,!1,C)===null)return null;O.copy(C),O.applyMatrix4(g.matrixWorld);let M=x.ray.origin.distanceTo(O);return M<x.near||M>x.far?null:{faceIndex:1,distance:M,point:O.clone(),object:g}}};var vc=new UC,rr=new zC,Ju=class extends jC{constructor(e){let t=new FC,o=new kC({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},c=new Qu(15711266),u=new Qu(15711266),l=new Qu(2857471);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",l),d("u2","u3",l),d("u3","u1",l);function d(f,m,h){p(f,h),p(m,h)}function p(f,m){i.push(0,0,0),a.push(m.r,m.g,m.b),s[f]===void 0&&(s[f]=[]),s[f].push(i.length/3-1)}t.setAttribute("position",new O0(i,3)),t.setAttribute("color",new O0(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;rr.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;xr("n1",t,e,rr,-i,-a,s),xr("n2",t,e,rr,i,-a,s),xr("n3",t,e,rr,-i,a,s),xr("n4",t,e,rr,i,a,s);let c=s;xr("f1",t,e,rr,-i,-a,c),xr("f2",t,e,rr,i,-a,c),xr("f3",t,e,rr,-i,a,c),xr("f4",t,e,rr,i,a,c);let u=c,l=.5;xr("u1",t,e,rr,i*.7*l,a*1.1,u),xr("u2",t,e,rr,-i*.7*l,a*1.1,u),xr("u3",t,e,rr,0,a*(1.1+.9*l),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function xr(n,r,e,t,o,i,a){vc.set(o,i,a).unproject(t);let s=r[n];if(s!==void 0){let c=e.getAttribute("position");for(let u=0,l=s.length;u<l;u++)c.setXYZ(s[u],vc.x,vc.y,vc.z)}}var bc=class extends Ur(Ju){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){Hr(this.object,this.geometry,e,t,!0)}};import{Box3Helper as A0,BoxGeometry as HC}from"three";var Sc;(r=>r.is=e=>"objectHelper"in e)(Sc||(Sc={}));var Wr=(n,r)=>class extends hi(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 A0&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof HC?(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 A0&&(i.visible=!1)}}};var wc=790,sa=new vr,ep=new vr,tp=new YC,rp=new vr,ds=new vr,op=new vr,po=class extends Wr(WC,bc){constructor(e="",t={...Jo.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new XC,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new qC(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new $C(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 vr(e,t,o)),super.lookAt(e),this.getWorldPosition(sa),this.targetOffset=sa.distanceTo(e)}getTarget(e=new vr){return this.getWorldDirection(ep),this.getWorldPosition(sa),ep.multiplyScalar(this.targetOffset),e.copy(sa).add(ep),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(sa),sa.distanceTo(e)}updateUp(){this.getWorldQuaternion(tp),rp.set(0,0,1).applyQuaternion(tp),ds.copy(C0.DEFAULT_UP),this.isUpVectorFlipped&&ds.negate(),ds.applyQuaternion(tp),op.copy(C0.DEFAULT_UP).projectOnPlane(rp),this.angleOffsetFromUp=op.angleTo(ds),this.angleOffsetFromUp*=op.cross(ds).dot(rp)>=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 vr),i=e.getWorldDirection(new vr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new vr).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new vr,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=-wc*.5*i,this.right=wc*.5*i,this.top=wc*.5*(1/a),this.bottom=-wc*.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 $n(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}}};import{BufferGeometry as N0,Matrix4 as I0,Float32BufferAttribute as KC}from"three";var la=new I0,ZC=new I0;var or=class extends Ft{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new N0;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 or&&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 bt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0){if(la.multiplyMatrices(a.hiddenMatrix,a.matrix),a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Qt.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;Qt.transformMeshSet(a.booleanMeshSetAddress,la),a.booleanMatrixInvOld.copy(la).invert(),a.booleanWasTransformed=!1}else a instanceof or&&a.needsTransformForDownstream===!0?(Qt.transformMeshSet(a.booleanMeshSetAddress,la),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Qt.transformMeshSet(a.booleanMeshSetAddress,ZC.multiplyMatrices(la,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(la).invert(),a.booleanWasTransformed=!1);Qt.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.wasFilteredFromBoolean=!1):a.geometry.userData.wasFilteredFromBoolean=!0}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new KC([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Qt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new N0,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Qt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,ta(this),ra(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as QC}from"three";var M0;(r=>{function n(e){return Te.is(e)&&e instanceof QC}r.is=n})(M0||(M0={}));var ca=(n,r)=>class extends Wr(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 Uo=n=>n instanceof bt,da=n=>n!==null&&n instanceof or;var us=n=>Sc.is(n);import{Group as eN}from"three";import{AxesHelper as JC}from"three";var qr=class extends Ur(JC){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){Hr(this.object,qr.geometryHelper,e,t)}update(){}};var Tn=class extends Wr(eN,qr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};import{Color as mN,Fog as hN,HemisphereLight as yN}from"three";import{ShaderChunk as ps}from"three";var tN=n=>`
2219
+ `)>=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,c=r-s,u=-this.ascender*o-c/2;return i===3?-(t-a-u):i===2?-(t*.5-a*.5-u):u}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 fc,c=(r.advanceWidth??1)*e;if(r)for(let u of a.commands){let l=s.currentPath?.currentPoint;if(!(l&&u.type!=="Z"&&l.x===u.x&&-l.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 l=cC(u.curves);l!==void 0&&u.currentPoint.distanceTo(l)>0&&u.lineTo(l.x,l.y)}),{offsetX:c+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,c=this.getTextWidth(i,t);return(s-(c-a*o))/a}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function cC(n){if(n.length){let r=n[0];if(r instanceof aC)return r.v1;if(r instanceof iC||r instanceof sC)return r.v0}}var ku=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()}},ss=class extends ku{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t,o){let i=an(e,t,this.flatShading,o);return i.computeBoundingSphere(),i}};var e0={markNeedsUpdateRendererDirty:()=>{}};import{MathUtils as uC}from"three";var Uu=class extends cc{constructor(e){super();this.shared=e}create(e){return new ea(e,this.shared)}},gn=class{constructor(r,e={}){this.data=r;this.geometryCache=new ss(!0);this.geometryCache2=new ss(!1);this.imageHolderCache=new Uu(this);this.thisContext={scene:e0,shared:this};this.deletedMaterial=new mn(gt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Jt(di.emptyImage,this);this.deletedVideo=new Jt(ti.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};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);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.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 mn(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 fn(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 Jt(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)}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new Jt(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 Fo(e.r,e.g,e.b,e.a):this.colors[r]=new Fo(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 it(0,0,0,0))}else return"a"in r?new it(r.r,r.g,r.b,r.a):new it(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 hn)return e;{let t=new hn({src:e.data});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof hn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new hc(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 hn&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(r,e){this.addVariable(r,e.value)}addVariable(r,e){return this.variables[r]===void 0?(this.variables[r]={value:e,locations:[]},!0):(this.variables[r].value=e,!1)}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];o.traverseMaterial(u=>{let l=u.root??u;l.uuid===s&&l.reset({...u.data},{scene:o,shared:this})});let c=this.materials[s];c&&c.reset({...c.data},{scene:o,shared:this})}else{let s=o.find(a[0]);if(s===void 0){this.variables[r].locations.splice(i,1);continue}if(a[1]!=="geometry"){for(let c=1;c<a.length-1;c++)s=s[a[c]];a[1]==="rotation"&&(t=uC.DEG2RAD*t),s[a[a.length-1]]=t}if(s=o.find(a[0]),Te.is(s)){if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let c=s;s.component&&(c=s.component);let u=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(u.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.instances.forEach(l=>{let d=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(d.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0)})}}}}return!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 t}for(let t in this.variables){if(e===void 0)break;let o=this.variables[t],i=o.locations?.findIndex(a=>Je.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}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.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]==="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]==="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(et.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.addVariable(r.id,r.data.value):r.path.length===1&&r.type===5&&this.deleteVariable(r.id):r.path[0]==="lib"&&this.updateLibByOp(et.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)}}},t0=new gn(ar.emptyData());var Ft=class extends bt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Um(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(_t(e.path,["material"])&&this.material instanceof jt)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(et.drop(e,1),t.material,o);else if(_t(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(et.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&&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&&xs(this.material).forEach(e=>{e instanceof jt&&(e instanceof mn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as pC,Matrix4 as Hu,Vector3 as a0,Vector4 as Wu}from"three";var r0=new a0,o0=new Wu,n0=new Wu,fC=new a0,i0=new Hu,Ze=class extends Ft{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0,t.bindMode&&t.bindMatrix&&(this.isSkinnedMesh=!0,this.bindMode=t.bindMode,this.bindMatrix=new Hu().fromArray(t.bindMatrix),this.bindMatrixInverse=new Hu)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof pC&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof gn){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 Na.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Na.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),_t(e.path,["geometry"])&&this.updateByPatchedOpGeometry(et.drop(e,1),t.geometry,o)}removeInteractionGeometry(){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 l={...this.data.geometry,...i};this.localGeometry=an(l,t,this.data.flatShading,this)}let a,s,c;i.scaleBaked?[a,s,c]=i.scaleBaked:{width:a,height:s,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&$a(this.localGeometry.attributes,a/u.sxPrev,s/u.syPrev,c/u.szPrev),u.sxPrev=a,u.syPrev=s,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=an(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 Ke&&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,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 Wu,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;o0.fromBufferAttribute(i.attributes.skinIndex,e),n0.fromBufferAttribute(i.attributes.skinWeight,e),r0.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=n0.getComponent(a);if(s!==0){let c=o0.getComponent(a);i0.multiplyMatrices(o.bones[c].matrixWorld,o.boneInverses[c]),t.addScaledVector(fC.copy(r0).applyMatrix4(i0),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function hC(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]}`,c=new $u(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(c):r.set(s,{normals:[c],result:new $u})}r.forEach((a,s)=>{for(let c of a.normals)a.result.add(c);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]}`,c=r.get(s)?.result;c&&(i[a]=c.x,i[a+1]=c.y,i[a+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new s0(i,3))}function yC(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 $u;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 s0(t,3))}function ra(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof jt)||n.material.getLayersOfType("outline").length===0)return;n instanceof Ze&&n.is2DAndNoDepth?yC(n):hC(n)}function oa(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=[qu.seededRandom(o),qu.seededRandom(o+1e4),qu.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=i[a%3];n.geometry.setAttribute("randomColor",new mC(t,3))}var bC;Ii.then(n=>{bC=n});var Fr=new gC,ls=new vC;function c0(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var xn=class extends Ze{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new xC;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}=Ke.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,ra(this),oa(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=o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(t)}}updateMesh(e=!1){Ke.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Ke.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Ke.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Ke.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,bt.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 l0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Fr.setFromBufferAttribute(t),Fr.getCenter(o),e.boundingSphere.radius=o.distanceTo(Fr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fr.getSize(ls),this.hasNonUniformScale&&ls.divide(this.scale);let i={width:ls.x,height:ls.y,depth:ls.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;Fr.min.set(e[0],e[2],e[4]),Fr.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Fr.min.applyMatrix4(this.shearScaleInv),Fr.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new l0);let o=t.boundingSphere.center;Fr.getCenter(o),t.boundingSphere.radius=o.distanceTo(Fr.max)}freeSubdivPointer(){this.subdivPointer&&(Ke.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)}};import{Triangle as SC,Vector3 as bn}from"three";var d0=-1,wC=1,u0={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},p0={polygon_center:0,edge:1,vertex:2},cs=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,xe=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-d0)*(e-t)/(wC-d0)+t};function f0(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 TC=new bn,yc=new bn,_C=new bn,PC=new bn;function na(n,r){let e=_C.fromArray(n),t=PC.fromArray(r);yc.copy(t).sub(e);let o=yc.length();return yc.normalize().multiplyScalar(o*.5),TC.copy(e).add(yc).toArray()}var tr=new SC,gc=new bn,xc=new bn,vn=new bn;function m0(n){let r=[];for(let e=0;e<=n.index.count;e++)if(gc.fromArray(n.index.array,e*3),tr.setFromAttributeAndIndices(n.attributes.position,gc.x,gc.y,gc.z),tr.getNormal(xc),tr.getMidpoint(vn),!(isNaN(vn.x)||isNaN(vn.y)||isNaN(vn.z))){let{a:t,b:o,c:i}=tr,a=t.toArray(),s=o.toArray(),c=i.toArray(),u=t.distanceTo(o),l=o.distanceTo(i),d=i.distanceTo(t),p=na(a,s),f=na(s,c),m=na(c,a),h=[u,l,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,x=[],S=tr.getMidpoint(vn).toArray();y===u&&!g&&(x=[f,m,m],S=p),y===l&&!g&&(x=[p,m,m],S=f),y===d&&!g&&(x=[p,f,f],S=m),g&&(x=[p,f,m]),r.push({vertices:[a,s,c],faceCenters:x,midpoint:S,norm:tr.getNormal(xc).toArray()})}return r}function h0(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){tr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),tr.getNormal(xc),tr.getMidpoint(vn);let o=tr.a.toArray(),i=tr.b.toArray(),a=tr.c.toArray();r.push({vertices:[o,i,a],faceCenters:[na(o,i),na(i,a),na(a,o)],midpoint:vn.toArray(),norm:xc.toArray()})}return r}var OC=4,AC=.5,Yu=n=>.5*(1-Math.cos(n*Math.PI)),Xu=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,c=e-i,u=t-a,l,d,p=0,f=.5,m,h,y;for(let g=0;g<OC;g++){let x=o+(i<<4)+(a<<8);l=Yu(s),d=Yu(c),m=this.perlin[x&4095],m+=l*(this.perlin[x+1&4095]-m),h=this.perlin[x+16&4095],h+=l*(this.perlin[x+16+1&4095]-h),m+=d*(h-m),x+=256,h=this.perlin[x&4095],h+=l*(this.perlin[x+1&4095]-h),y=this.perlin[x+16&4095],y+=l*(this.perlin[x+16+1&4095]-y),h+=d*(y-h),m+=Yu(u)*(h-m),p+=m*f,f*=AC,o<<=1,s*=2,i<<=1,c*=2,a<<=1,u*=2,s>=1&&(o++,s--),c>=1&&(i++,c--),u>=1&&(a++,u--)}return p}noiseSeed(r){let e=(()=>{let a,s;return{setSeed(c){s=a=(c??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()}},y0=Xu;import{Vector3 as CC,Matrix4 as NC,Ray as IC}from"three";var g0=new CC,x0=new NC,v0=new IC;function b0(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var ia=class extends Ze{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)&&(x0.copy(o).invert(),v0.copy(e.ray).applyMatrix4(x0),v0.intersectBox(this.singleBBox,g0))){let i=g0.applyMatrix4(o),a=e.ray.origin.distanceTo(i);t.push({distance:a,point:i.clone(),object:this})}}};var Mt=1e-4,kr,_0,P0,O0,w0=new Xt,T0=new Xt;Ii.then(n=>{kr=n,_0=[kr.get_face_center,kr.get_edge_midpoint,kr.get_vertex_position],P0=[kr.get_face_normal,kr.get_edge_normal,kr.get_vertex_normal],O0=[kr.face_count,kr.edge_count,kr.vertex_count]});var EC=new wn,LC=new wn,ko=new Xt,Sn=new Xt,ds=new Xt,Zu=new Xt,DC=new Xt,BC=new Xt;var co=new y0,sa=class extends fi(MC){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 no&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof no&&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 no(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 no(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*S0.DEG2RAD,i=t.end*S0.DEG2RAD,a=o-i,s=new Ku(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Xt(0,0,1);break;case"y":c=new Xt(0,1,0);break;default:case"x":c=new Xt(1,0,0);break}let u=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,l=u.noiseType==="perlin";co.noiseSeed(u.seed);let d=Ol((0,aa.default)(u.seed)),p=cs(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=l?co.noise(h):d(h,h),g=f+1;m.scale.x=t.scale[0]+p(g,xe(y,u.scale[0]))||Mt,m.scale.y=t.scale[1]+p(g,xe(y,u.scale[1]))||Mt,m.scale.z=t.scale[2]+p(g,xe(y,u.scale[2]))||Mt,m.position.setScalar(0);let x=a/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,x,0);break;case"y":m.rotation.set(0,0,x);break;case"z":m.rotation.set(x,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(g,xe(y,u.position[0])),m.position.y+=t.position[1]+p(g,xe(y,u.position[1])),m.position.z+=t.position[2]+p(g,xe(y,u.position[2]));let S=p(g,xe(y,u.rotation[0])),w=p(g,xe(y,u.rotation[1])),b=p(g,xe(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=s.x+S,m.rotation.y+=s.y+w,m.rotation.z+=s.z+b):m.rotation.set(s.x+S,s.y+w,s.z+b)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Ku(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";co.noiseSeed(i.seed);let s=Ol((0,aa.default)(i.seed)),c=cs(i.strength,this.parameters.randomness);for(let[u,l]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?co.noise(d):s(d,d),f=u+1,m=c(f,xe(p,i.rotation[0])),h=c(f,xe(p,i.rotation[1])),y=c(f,xe(p,i.rotation[2]));l.scale.x=1+(t.scale[0]-1)*u+c(f,xe(p,i.scale[0]))||Mt,l.scale.y=1+(t.scale[1]-1)*u+c(f,xe(p,i.scale[1]))||Mt,l.scale.z=1+(t.scale[2]-1)*u+c(f,xe(p,i.scale[2]))||Mt,l.rotation.x=o.x*u+m,l.rotation.y=o.y*u+h,l.rotation.z=o.z*u+y,l.position.x=t.position[0]*u+c(f,xe(p,i.position[0])),l.position.y=t.position[1]*u+c(f,xe(p,i.position[1])),l.position.z=t.position[2]*u+c(f,xe(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=cs(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";co.noiseSeed(i.seed);let c=qh((0,aa.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},l=new Xt(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 m=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=s?co.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+a(t,xe(h,i.scale[0]))||Mt,y.scale.y=1+a(t,xe(h,i.scale[1]))||Mt,y.scale.z=1+a(t,xe(h,i.scale[2]))||Mt;let g=a(t,xe(h,i.rotation[0])),x=a(t,xe(h,i.rotation[1])),S=a(t,xe(h,i.rotation[2]));y.rotation.set(g,x,S),y.position.x=o.size[0]*d-l.x+a(t,xe(h,i.position[0])),y.position.y=o.size[1]*p-l.y+a(t,xe(h,i.position[1])),y.position.z=o.size[2]*f-l.z+a(t,xe(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let l=0;l<o.count[1];l++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(l+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=s?co.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+a(t,xe(f,i.scale[0]))||Mt,m.scale.y=1+a(t,xe(f,i.scale[1]))||Mt,m.scale.z=1+a(t,xe(f,i.scale[2]))||Mt;let h=a(t,xe(f,i.rotation[0])),y=a(t,xe(f,i.rotation[1])),g=a(t,xe(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*u+a(t,xe(f,i.position[0])),m.position.y=-o.size[1]*l+a(t,xe(f,i.position[1])),m.position.z=-o.size[2]*d+a(t,xe(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Ku(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";co.noiseSeed(i.seed);let s=Ol((0,aa.default)(i.seed)),c=cs(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 ia)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(),l=[],d=g=>{let x=g.length,S=g.map(T=>T[0]).reduce((T,_)=>T+_,0),w=g.map(T=>T[1]).reduce((T,_)=>T+_,0),b=g.map(T=>T[2]).reduce((T,_)=>T+_,0);return[S/x,w/x,b/x]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let x=u.filter(S=>p(g.pos[0])===p(S.pos[0])&&p(g.pos[1])===p(S.pos[1])&&p(g.pos[2])===p(S.pos[2]));x.length>1?l.push({pos:g.pos,norm:d(x.map(S=>S.norm))}):l.push(g)});let f=f0(l);if(f.length>0){let g=Math.round(f.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 m=new Al(this.objectForSample).build(),h=u0[t.axis],y=this.children;m.setRandomGenerator((0,aa.default)(this.object.uuid+t.seed));for(let[g,x]of y.entries()){let S=g*(i.freqScale/10)+i.movement,w=a?co.noise(S):s(S,S),b=g+1,T=c(b,xe(w,i.rotation[0])),_=c(b,xe(w,i.rotation[1])),v=c(b,xe(w,i.rotation[2]));t.spreadType==="random"?m.sample(ds,Zu):(f.length&&(ds.fromArray(f[g].pos),Zu.fromArray(f[g].norm)),this.objectForSample instanceof xn&&ds.applyMatrix4(EC.copy(this.objectForSample.matrixWorld).invert())),ds.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(ds),ko.fromArray(h);let N=t.align==="normal"?Zu:this.object.getWorldDirection(BC),P=Sn.fromArray(t.position);Sn.x+=Sn.x+c(b,xe(w,i.position[0])),Sn.y+=Sn.y+c(b,xe(w,i.position[1])),Sn.z+=Sn.z+c(b,xe(w,i.position[2]));let C=Math.acos(N.dot(ko)),O=DC.crossVectors(ko,N).normalize(),A=LC.makeRotationAxis(O,C),M=N.clone().cross(this.object.up).normalize(),L=M.clone().cross(N).normalize(),X=new wn().makeBasis(M,N,L),R=new Xt(ko.y,ko.z,ko.x).normalize(),Z=R.clone().cross(ko).normalize(),z=new wn().makeBasis(R,ko,Z).invert(),V=new wn().multiplyMatrices(X,z);x.rotation.setFromRotationMatrix(V),P.applyMatrix4(A),x.position.add(P),x.rotation.x=x.rotation.x+o.x+T,x.rotation.y=x.rotation.y+o.y+_,x.rotation.z=x.rotation.z+o.z+v,x.scale.setScalar(1),x.scale.x=x.scale.x+t.scale[0]+c(b,xe(w,i.scale[0]))||Mt,x.scale.y=x.scale.y+t.scale[1]+c(b,xe(w,i.scale[1]))||Mt,x.scale.z=x.scale.z+t.scale[2]+c(b,xe(w,i.scale[2]))||Mt,x.scale.multiply(this.object.scale),x.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof xn){let t=this.objectForSample,o=p0[e],i=O0[o],a=_0[o],s=P0[o],c=[],u=i(t.subdivPointerNew);for(let l=0;l<=u-1;l++){let d=a(t.subdivPointerNew,l),p=s(t.subdivPointerNew,l);w0.fromArray(d).applyMatrix4(t.matrixWorld),T0.fromArray(p),c.push({pos:w0.toArray(),norm:T0.toArray()})}return c}else return(this.objectForSample.geometry.index?m0(this.objectForSample.geometry):h0(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=Qr(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 bt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new wn,this.hiddenMatrix=new wn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as GN,Vector3 as VN,Matrix4 as zN,Box3 as jN,MeshBasicMaterial as FN,Skeleton as kN}from"three";import{Camera as $C,OrthographicCamera as YC,PerspectiveCamera as XC,Vector3 as vr,Object3D as I0,Quaternion as KC,Matrix4 as ZC}from"three";import{Camera as FC,LineSegments as kC,BufferGeometry as UC,LineBasicMaterial as HC,Color as Ju,Vector3 as WC,Float32BufferAttribute as C0}from"three";import{BoxGeometry as RC}from"three";var Ur=n=>{var r;return r=class extends n{},r.geometryHelper=new RC(30,30,30),r};import{Ray as GC,Sphere as VC,Matrix4 as zC,Vector3 as uo}from"three";var vc=new GC,Qu=new VC,A0=new zC,Hr=(n,r,e,t,o=!1)=>{let i=r,a=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),Qu.copy(i.boundingSphere),Qu.applyMatrix4(a),e.ray.intersectsSphere(Qu)===!1||(A0.copy(a).invert(),vc.copy(e.ray).applyMatrix4(A0),i.boundingBox!==null&&vc.intersectsBox(i.boundingBox)===!1))return;let s,c,u,l,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),x=Math.min(d.count,f.start+f.count);for(m=g,h=x;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),l=d.getX(m+2),s=y(n,e,vc,p,c,u,l),s){s.faceIndex=Math.floor(m/3),t.push(s);return}}else{let x=i.attributes.position,S=new uo,w=new uo,b=new uo,T=new uo,_=2,N=1/((n.scale.x+n.scale.y+n.scale.z)/3),P=N*N,C=Math.max(0,f.start),O=Math.min(x.count,f.start+f.count);for(let A=C,M=O-1;A<M;A+=_){if(S.fromBufferAttribute(x,A),w.fromBufferAttribute(x,A+1),vc.distanceSqToSegment(S,w,T,b)>P)continue;T.applyMatrix4(n.matrixWorld);let X=e.ray.origin.distanceTo(T);X<e.near||X>e.far||t.push({distance:X,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,x,S,w,b,T,_){let v=new uo,N=new uo,P=new uo,C=new uo,O=new uo;if(v.fromBufferAttribute(w,b),N.fromBufferAttribute(w,T),P.fromBufferAttribute(w,_),S.intersectTriangle(v,N,P,!1,C)===null)return null;O.copy(C),O.applyMatrix4(g.matrixWorld);let M=x.ray.origin.distanceTo(O);return M<x.near||M>x.far?null:{faceIndex:1,distance:M,point:O.clone(),object:g}}};var bc=new WC,rr=new FC,ep=class extends kC{constructor(e){let t=new UC,o=new HC({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},c=new Ju(15711266),u=new Ju(15711266),l=new Ju(2857471);d("n1","n2",c),d("n2","n4",c),d("n4","n3",c),d("n3","n1",c),d("f1","f2",c),d("f2","f4",c),d("f4","f3",c),d("f3","f1",c),d("n1","f1",c),d("n2","f2",c),d("n3","f3",c),d("n4","f4",c),d("p","n1",u),d("p","n2",u),d("p","n3",u),d("p","n4",u),d("u1","u2",l),d("u2","u3",l),d("u3","u1",l);function d(f,m,h){p(f,h),p(m,h)}function p(f,m){i.push(0,0,0),a.push(m.r,m.g,m.b),s[f]===void 0&&(s[f]=[]),s[f].push(i.length/3-1)}t.setAttribute("position",new C0(i,3)),t.setAttribute("color",new C0(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;rr.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;xr("n1",t,e,rr,-i,-a,s),xr("n2",t,e,rr,i,-a,s),xr("n3",t,e,rr,-i,a,s),xr("n4",t,e,rr,i,a,s);let c=s;xr("f1",t,e,rr,-i,-a,c),xr("f2",t,e,rr,i,-a,c),xr("f3",t,e,rr,-i,a,c),xr("f4",t,e,rr,i,a,c);let u=c,l=.5;xr("u1",t,e,rr,i*.7*l,a*1.1,u),xr("u2",t,e,rr,-i*.7*l,a*1.1,u),xr("u3",t,e,rr,0,a*(1.1+.9*l),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function xr(n,r,e,t,o,i,a){bc.set(o,i,a).unproject(t);let s=r[n];if(s!==void 0){let c=e.getAttribute("position");for(let u=0,l=s.length;u<l;u++)c.setXYZ(s[u],bc.x,bc.y,bc.z)}}var Sc=class extends Ur(ep){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){Hr(this.object,this.geometry,e,t,!0)}};import{Box3Helper as N0,BoxGeometry as qC}from"three";var wc;(r=>r.is=e=>"objectHelper"in e)(wc||(wc={}));var Wr=(n,r)=>class extends yi(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 N0&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof qC?(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 N0&&(i.visible=!1)}}};var Tc=790,la=new vr,tp=new vr,rp=new KC,op=new vr,us=new vr,np=new vr,po=class extends Wr($C,Sc){constructor(e="",t={...Jo.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Ao.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new ZC,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new YC(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new XC(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 vr(e,t,o)),super.lookAt(e),this.getWorldPosition(la),this.targetOffset=la.distanceTo(e)}getTarget(e=new vr){return this.getWorldDirection(tp),this.getWorldPosition(la),tp.multiplyScalar(this.targetOffset),e.copy(la).add(tp),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(la),la.distanceTo(e)}updateUp(){this.getWorldQuaternion(rp),op.set(0,0,1).applyQuaternion(rp),us.copy(I0.DEFAULT_UP),this.isUpVectorFlipped&&us.negate(),us.applyQuaternion(rp),np.copy(I0.DEFAULT_UP).projectOnPlane(op),this.angleOffsetFromUp=np.angleTo(us),this.angleOffsetFromUp*=np.cross(us).dot(op)>=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 vr),i=e.getWorldDirection(new vr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new vr).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new vr,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=-Tc*.5*i,this.right=Tc*.5*i,this.top=Tc*.5*(1/a),this.bottom=-Tc*.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 $n(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}}};import{BufferGeometry as M0,Matrix4 as E0,Float32BufferAttribute as QC}from"three";var ca=new E0,JC=new E0;var or=class extends Ft{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new M0;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 or&&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 bt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0){if(ca.multiplyMatrices(a.hiddenMatrix,a.matrix),a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Qt.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;Qt.transformMeshSet(a.booleanMeshSetAddress,ca),a.booleanMatrixInvOld.copy(ca).invert(),a.booleanWasTransformed=!1}else a instanceof or&&a.needsTransformForDownstream===!0?(Qt.transformMeshSet(a.booleanMeshSetAddress,ca),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Qt.transformMeshSet(a.booleanMeshSetAddress,JC.multiplyMatrices(ca,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(ca).invert(),a.booleanWasTransformed=!1);Qt.hasOpenEdges(a.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.wasFilteredFromBoolean=!1):a.geometry.userData.wasFilteredFromBoolean=!0}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new QC([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Qt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new M0,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Qt.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(i){this.booleanMeshSetAddress=0,console.error(i)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,ra(this),oa(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as eN}from"three";var L0;(r=>{function n(e){return Te.is(e)&&e instanceof eN}r.is=n})(L0||(L0={}));var da=(n,r)=>class extends Wr(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 Uo=n=>n instanceof bt,ua=n=>n!==null&&n instanceof or;var ps=n=>wc.is(n);import{Group as rN}from"three";import{AxesHelper as tN}from"three";var qr=class extends Ur(tN){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){Hr(this.object,qr.geometryHelper,e,t)}update(){}};var Tn=class extends Wr(rN,qr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};import{Color as yN,Fog as gN,HemisphereLight as xN}from"three";import{ShaderChunk as fs}from"three";var oN=n=>`
2220
2220
 
2221
2221
  // PCSS implementation based on:
2222
2222
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -2590,4 +2590,4 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2590
2590
  }
2591
2591
 
2592
2592
  #endif
2593
- `,rN=ps.lights_fragment_begin,oN=ps.shadowmask_pars_fragment,E0=null,nN=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},L0=(n="medium")=>{if(E0===n)return!1;E0=n;let r=nN(n);ps.shadowmap_pars_fragment=tN(r);let e=rN.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 ]"),ps.lights_fragment_begin=e;let t=oN.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ps.shadowmask_pars_fragment=t,!0};import{DirectionalLight as cN,CameraHelper as D0}from"three";import{DirectionalLightHelper as iN}from"three";var ua=class extends Ur(iN){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,ua.geometryHelper,e,t)}};import{PointLightHelper as aN}from"three";var pa=class extends Ur(aN){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,pa.geometryHelper,e,t)}};import{SpotLightHelper as sN,Vector3 as lN}from"three";var Tc=class extends Ur(sN){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,Tc.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Tc._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)}}},fs=Tc;fs._vector=new lN;function dN(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 fa=class extends ca(cN,ua){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 D0(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 D0&&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&&dN(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()}};import{Scene as gN}from"three";import{SpotLight as uN,CameraHelper as B0,MathUtils as pN,Vector3 as z0,Quaternion as fN}from"three";var R0=new z0,G0=new z0,V0=new fN,ma=class extends ca(uN,fs){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=pN.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new B0(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 B0&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),G0.setFromMatrixPosition(this.matrixWorld),V0.setFromRotationMatrix(this.matrixWorld),R0.copy(this.up).applyQuaternion(V0).negate().multiplyScalar(this.distance),this.target.position.copy(G0).add(R0),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))}};var Ho=class extends hi(gN){constructor(e,t){super();this.data=t;this.bgColor=new it(1,1,1,1);this.fog=null;this.backupFog=new hN(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new mN;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new po(Po,{...Jo.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new yN(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Tt(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.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Ft)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&&L0(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=Tt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Tt(e.aoColor,t))}updateByOp(e,t,o,i){super.updateByOp(e,t,o,i);let a=t;_t(e.path,["fog"])?this.updateFog(a.fog,o.shared):_t(e.path,["ao"])?this.updateAo(a.ao,o.shared):_t(e.path,["ambient"])?this.updateAmbientLight(a.ambient,o.shared):_t(e.path,["shadow"])&&this.updateShadow(a.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Tt(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)}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 fa&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof ma&&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;Te.is(a)&&(a.visible||s?.object.data.visible)&&((Uo(a)||us(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),hs(a,e,t,!0)),o(a))}};return o(this),t}};import{PointLight as xN,Vector3 as _c,Box3 as vN,Box3Helper as j0,Color as bN}from"three";var Pc=class extends ca(xN,pa){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 _c(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new _c(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new vN(a,s),u=new j0(c,new bN(16755200));u.visible=!1,this.gizmos.shadowmap=u,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 j0){let t=this.shadow.camera,o=new _c(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new _c(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 Oc=class extends Ze{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Ya(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ha=class extends Ze{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=Yl;break;case"Ellipse":i=Ti;break;case"Polygon":i=$l;break;case"Star":i=Xl;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?Ya(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};import{Group as SN,Matrix4 as wN,Skeleton as TN}from"three";var fo=class extends Wr(SN,qr){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=li.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let i,a;for(let s of Nr.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]=Tr.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...xt.defaultData,...e,...nr(xt.defaultData,Nr.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 Nr.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&&Nr.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(Te.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Ac(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};k0(e,[this.uuid],t.overrides,this,o,o,0,i,a);for(let s of this.children)if(Te.is(s)){let c=s.data;c.type==="Empty"&&c.animations&&s.traverseEntity(u=>{if(u instanceof Ze&&u.isSkinnedMesh){let l=u.dataPatched;if(l.bones&&l.boneInverses){let d=l.bones.map(m=>e.scene.find(a[m])),p=l.boneInverses.map(m=>new wN().fromArray(m)),f=new TN(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Ac(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)Te.is(e)&&Ac(e)}}function F0(n,r,e,t){return n.component===r&&zc(n.identity,t)?n.overrideData===e?2:1:0}function k0(n,r,e,t,o,i,a,s,c){if(a>50)return!1;if(t.component!==o){if(t.component){let l=t.component.instances.indexOf(t);l>=0&&t.component.instances.splice(l,1)}o.instances.push(t),t.component=o}o instanceof fo&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let l of o.children)if(Te.is(l)){let d=[...r,...typeof l.identity=="string"?[l.identity]:l.identity],p=ii.resolve(e,d,1);if(p!=null&&!(p instanceof Re)){if(!1)debugger;Object.setPrototypeOf(p,Re.prototype),console.error("wrong prototype")}let f=null,m;if(!s){let h=t.children[u];if(f=Te.is(h)?h:null,f!==null){let y=F0(f,l,p,d);m=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=F0(f,l,p,d);if(m=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),t.children.splice(u,0,f),f.parent===t?(g<=u&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let h=p?Tr.apply(l.data,p):l.data;ir.is(h.type)&&(h={...h,type:"Empty"}),f=lr.createEntity(d,h,n),f.overrideData=p,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(u,0,f),f.updateState(f.data,n),m&&f.changeSelectedState(m,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let h=f.identity[f.identity.length-1];c[h]=f.uuid}u+=1,k0(n,r,e,f,l,i,a+1,s,c)}if(!s){let l=u;for(;;){let d=t.children[u];if(Te.is(d))n.pendingDeletes.add(d);else break;u+=1}t.children.splice(l,u-l)}return!0}import{Bone as _N}from"three";var Cc=class extends Wr(_N,qr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};function PN(n,r,e){let t;return r.geometry.type==="TextGeometry"?new na(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new xn(n,r,e):r.geometry.type==="PathGeometry"?t=new ha(n,r,e):r.geometry.type==="VectorGeometry"?t=new Oc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new or(n,r,e):t=new Ze(n,r,e),t)}function Nc(n,r,e){return r.type==="Mesh"?PN(n,r,e):r.type==="Empty"?new Tn(n,r):r.type==="Bone"?new Cc(n,r):r.type==="Page"?new Ho(n,r):r.type==="PointLight"?new Pc(n,r,e):r.type==="SpotLight"?new ma(n,r,e):r.type==="DirectionalLight"?new fa(n,r,e):r.type==="Component"||r.type==="Instance"?new fo(n,r,e):ir.is(r.type)?new po(n,r):(console.error(r),new Tn(n,r))}lr.createEntity=Nc;function ON(n,r,e){let t=Nc(n.identity,r,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,c=n.instances,u=n.overrideData,l=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let p of Object.keys(t))n[p]=t[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=c,n.uuid=l,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}lr.changeEntityProptotype=ON;lr.Cloner=aa;function U0(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as NN,Ray as IN,Raycaster as MN}from"three";function H0(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,ra(n),ta(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof Ft&&n.needsAO&&n.layers.enable(5),e}function W0(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 q0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Ft)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)H0(e,e.material[t])&&(r=!0);else H0(e,e.material)&&(r=!0)}),r}function $0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Ft)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)W0(e,e.material[t])&&(r=!0);else W0(e,e.material)&&(r=!0)}),r}var EN=new MN,LN=new NN,DN=new IN;function hs(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let a=LN.copy(i.matrixWorld).invert(),s=DN.copy(r.ray).applyMatrix4(a),c=n.matrixWorld;s.applyMatrix4(c);let u=EN;u.set(s.origin,s.direction),u.near=r.near,u.far=r.far;let l=u.intersectObject(n,!1);l.length>0&&e.push({...l[0],object:t?i:n})}}var Ic=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 c=r.find(i[s]);c?c.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 FN=new zN;FN.wireframe=!0;var Y0=new RN,Mc=class extends BN{constructor(e,t){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Ic;this.errorPage=new Ho("fdasfa",{...eo.defaultData,name:""});this.invisibleObjects=new Tn("jflkdsafjasdifjaslk",{...gl.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=$0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=q0(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 Ho&&(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)=>cp(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===Po)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}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(),i.resetBBoxNeedsUpdate(),Uo(i)&&da(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty()}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),da(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Uo(o)&&(o.freeBooleanPointer(),i instanceof or&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ha&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Uo(o)&&(o.invalidateUpstreamBooleanData(),da(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof or&&i.invalidateDownstreamBooleanData().recomputeBoolean())}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 Ho&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}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{U0(a,t,o,{scene:this,shared:i}),a instanceof Ze&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,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=>{da(i)&&i.recomputeBoolean(),i instanceof po&&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){Te.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Te.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,c){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(l=>{l.data=vo(l.data,d=>{let p=d.events.data(c.id),f=l.goUp(s);if(f){let m=[...gs(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=Je.zoom(p,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(c=>{c.data.type==="Transition"?this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,a,s):c.data.type==="Animation"&&this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof fo&&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=vo(s.data,c=>{s.isInstanceRoot||(c.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of Sl.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 fo&&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),Ac(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof fo&&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)Te.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 c=s.cloner;if(Te.is(s)&&!s.raycastLock&&(s.visible||c?.object.data.visible))if(t===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let l=u[0];l.object=s,l.point.applyMatrix4(l.object.matrixWorld);let d=s.matrixWorld.clone().invert();l.point.applyMatrix4(d),o.push(l)}}else(Uo(s)||us(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),hs(s,e,o)),i(s)}};return i(this),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;Te.is(a)&&(a.visible||s?.object.data.visible)&&((Uo(a)||us(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),hs(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Te.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Te.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Te.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof Ze&&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();da(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)ui.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Te.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 c={scene:this,shared:s},u=Nc(e,t,c);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(t,c),u instanceof Ze&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&u.traverseEntity(l=>{if(l instanceof Ze&&l.isSkinnedMesh){let d=l.dataPatched;if(d.bones&&d.boneInverses){let p=d.bones.map(h=>this.find(h)),f=d.boneInverses.map(h=>new GN().fromArray(h)),m=new jN(p,f);l.bind(m,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),u}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:c}=e[i],u=this.find(s),l=c?u.recursiveBBox:u.singleBBox;t.push(...l.vertices)}let o=new VN;return o.setFromPoints(t),o.getCenter(Y0),Y0}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 bt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof jt&&e(t.material[o]);else t.material instanceof jt&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof po&&i.setViewplaneSize(e,t,o)})}};import{DRACOLoader as kN}from"three/examples/jsm/loaders/DRACOLoader.js";var Wo;function UN(){return Wo||(Wo=new kN,Wo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wo.decoderPending}async function HN(n){if(Wo){let r={attributeIDs:Wo.defaultAttributeIDs,attributeTypes:Wo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Wo.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 X0(n,r){let[e,t]=Wc(il.deserialize(new Uint8Array(n)));_l(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 UN();for(let i of o){let a=await HN(We(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:c,array:u,itemSize:l})=>{s[c]={array:u,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}import{Mesh as lte}from"three";import{mergeBufferGeometries as ute}from"three/examples/jsm/utils/BufferGeometryUtils.js";function K0(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}import{Color as Z0,ShaderLib as WN}from"three";function Q0(n){let r=new Set;return n.traverse(e=>{if(e instanceof Ft)if(He(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(qN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new Z0,specularColor:new Z0});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},WN.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let c=s.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,c.aspectRatio.value=Rg(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else $N(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function qN(n){return n.getLayersOfType("transmission").length>0}function $N(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 J0(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function ex(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}import{mergeBufferGeometries as YN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function tx(n){let r=[];return n.traverse(e=>{e instanceof aa&&r.push(e)}),r.forEach(e=>{let t=e.object,a=[...e.children.map(s=>{s.updateMatrix();let c;if(s.geometry!==void 0)try{c=s.geometry.clone().applyMatrix4(s.matrix)}catch(u){console.error(u)}return c!==void 0&&s.matrix.determinant()<0&&K0(c),c}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof bt&&a.unshift(t.geometry),a.length){let s=YN(a);t instanceof bt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Jg})}),n}function rx(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function ox(n){Object.values(n.shared.materials).forEach(r=>{ip(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?ip(e.material):"materials"in e&&e.materials.forEach(t=>{ip(t)})})}function ip(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 lx=ya(ix(),1);function ax(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var sx="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",ap=class extends KN{load(r,e,t,o=console.error){let i=new XN(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(sx+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(sx),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 X0(r,ox);e.version&&(0,lx.default)(e.version,"0.9.456")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([s0(e)&&fg(),x0(e)&&Zg()].filter(Boolean));let t=new gn(e.shared);Object.values(t.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Mc(e.scene,t),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=tx(o),o=Q0(o),o=J0(o),o=ex(o),o=rx(o),o=ax(o),o}};export{ap as default};
2593
+ `,nN=fs.lights_fragment_begin,iN=fs.shadowmask_pars_fragment,D0=null,aN=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},B0=(n="medium")=>{if(D0===n)return!1;D0=n;let r=aN(n);fs.shadowmap_pars_fragment=oN(r);let e=nN.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 ]"),fs.lights_fragment_begin=e;let t=iN.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),fs.shadowmask_pars_fragment=t,!0};import{DirectionalLight as uN,CameraHelper as R0}from"three";import{DirectionalLightHelper as sN}from"three";var pa=class extends Ur(sN){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,pa.geometryHelper,e,t)}};import{PointLightHelper as lN}from"three";var fa=class extends Ur(lN){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,fa.geometryHelper,e,t)}};import{SpotLightHelper as cN,Vector3 as dN}from"three";var _c=class extends Ur(cN){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,_c.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=_c._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)}}},ms=_c;ms._vector=new dN;function pN(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 ma=class extends da(uN,pa){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 R0(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 R0&&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&&pN(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()}};import{Scene as vN}from"three";import{SpotLight as fN,CameraHelper as G0,MathUtils as mN,Vector3 as F0,Quaternion as hN}from"three";var V0=new F0,z0=new F0,j0=new hN,ha=class extends da(fN,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=mN.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new G0(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 G0&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),z0.setFromMatrixPosition(this.matrixWorld),j0.setFromRotationMatrix(this.matrixWorld),V0.copy(this.up).applyQuaternion(j0).negate().multiplyScalar(this.distance),this.target.position.copy(z0).add(V0),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))}};var Ho=class extends yi(vN){constructor(e,t){super();this.data=t;this.bgColor=new it(1,1,1,1);this.fog=null;this.backupFog=new gN(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new yN;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new po(Po,{...Jo.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new xN(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=Tt(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.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Ft)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&&B0(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=Tt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=Tt(e.aoColor,t))}updateByOp(e,t,o,i){super.updateByOp(e,t,o,i);let a=t;_t(e.path,["fog"])?this.updateFog(a.fog,o.shared):_t(e.path,["ao"])?this.updateAo(a.ao,o.shared):_t(e.path,["ambient"])?this.updateAmbientLight(a.ambient,o.shared):_t(e.path,["shadow"])&&this.updateShadow(a.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(Tt(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)}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 ma&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof ha&&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;Te.is(a)&&(a.visible||s?.object.data.visible)&&((Uo(a)||ps(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),ys(a,e,t,!0)),o(a))}};return o(this),t}};import{PointLight as bN,Vector3 as Pc,Box3 as SN,Box3Helper as k0,Color as wN}from"three";var Oc=class extends da(bN,fa){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 Pc(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new Pc(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new SN(a,s),u=new k0(c,new wN(16755200));u.visible=!1,this.gizmos.shadowmap=u,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 k0){let t=this.shadow.camera,o=new Pc(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new Pc(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 Ac=class extends Ze{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Xa(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ya=class extends Ze{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=Xl;break;case"Ellipse":i=_i;break;case"Polygon":i=Yl;break;case"Star":i=Kl;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?Xa(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};import{Group as TN,Matrix4 as _N,Skeleton as PN}from"three";var fo=class extends Wr(TN,qr){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=li.getComponentData({scene:t.scene.data,shared:t.shared.data},e.component);if(o){let i,a;for(let s of Nr.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]=Tr.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...xt.defaultData,...e,...nr(xt.defaultData,Nr.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 Nr.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&&Nr.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(Te.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),Cc(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};H0(e,[this.uuid],t.overrides,this,o,o,0,i,a);for(let s of this.children)if(Te.is(s)){let c=s.data;c.type==="Empty"&&c.animations&&s.traverseEntity(u=>{if(u instanceof Ze&&u.isSkinnedMesh){let l=u.dataPatched;if(l.bones&&l.boneInverses){let d=l.bones.map(m=>e.scene.find(a[m])),p=l.boneInverses.map(m=>new _N().fromArray(m)),f=new PN(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function Cc(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)Te.is(e)&&Cc(e)}}function U0(n,r,e,t){return n.component===r&&jc(n.identity,t)?n.overrideData===e?2:1:0}function H0(n,r,e,t,o,i,a,s,c){if(a>50)return!1;if(t.component!==o){if(t.component){let l=t.component.instances.indexOf(t);l>=0&&t.component.instances.splice(l,1)}o.instances.push(t),t.component=o}o instanceof fo&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let l of o.children)if(Te.is(l)){let d=[...r,...typeof l.identity=="string"?[l.identity]:l.identity],p=ii.resolve(e,d,1);if(p!=null&&!(p instanceof Re)){if(!1)debugger;Object.setPrototypeOf(p,Re.prototype),console.error("wrong prototype")}let f=null,m;if(!s){let h=t.children[u];if(f=Te.is(h)?h:null,f!==null){let y=U0(f,l,p,d);m=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(d)??null,f!==null)){let y=U0(f,l,p,d);if(m=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),t.children.splice(u,0,f),f.parent===t?(g<=u&&console.error("not possible"),void 0):(f.parent=t,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),n.pendingDeletes.delete(f),void 0)}}}if(f===null){let h=p?Tr.apply(l.data,p):l.data;ir.is(h.type)&&(h={...h,type:"Empty"}),f=lr.createEntity(d,h,n),f.overrideData=p,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(u,0,f),f.updateState(f.data,n),m&&f.changeSelectedState(m,n),n.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let h=f.identity[f.identity.length-1];c[h]=f.uuid}u+=1,H0(n,r,e,f,l,i,a+1,s,c)}if(!s){let l=u;for(;;){let d=t.children[u];if(Te.is(d))n.pendingDeletes.add(d);else break;u+=1}t.children.splice(l,u-l)}return!0}import{Bone as ON}from"three";var Nc=class extends Wr(ON,qr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};function AN(n,r,e){let t;return r.geometry.type==="TextGeometry"?new ia(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new xn(n,r,e):r.geometry.type==="PathGeometry"?t=new ya(n,r,e):r.geometry.type==="VectorGeometry"?t=new Ac(n,r,e):r.geometry.type==="BooleanGeometry"?t=new or(n,r,e):t=new Ze(n,r,e),t)}function Ic(n,r,e){return r.type==="Mesh"?AN(n,r,e):r.type==="Empty"?new Tn(n,r):r.type==="Bone"?new Nc(n,r):r.type==="Page"?new Ho(n,r):r.type==="PointLight"?new Oc(n,r,e):r.type==="SpotLight"?new ha(n,r,e):r.type==="DirectionalLight"?new ma(n,r,e):r.type==="Component"||r.type==="Instance"?new fo(n,r,e):ir.is(r.type)?new po(n,r):(console.error(r),new Tn(n,r))}lr.createEntity=Ic;function CN(n,r,e){let t=Ic(n.identity,r,e),o=n.children,i=n.attachedPaths,a=n.parent,s=n.component,c=n.instances,u=n.overrideData,l=n.uuid,d=n.stateSelection;n.dispose();for(let p of Object.keys(n))delete n[p];Object.setPrototypeOf(n,Object.getPrototypeOf(t));for(let p of Object.keys(t))n[p]=t[p];n.children=[...n.children,...o],n.attachedPaths=i,n.parent=a,n.component=s,n.instances=c,n.uuid=l,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}lr.changeEntityProptotype=CN;lr.Cloner=sa;function W0(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as MN,Ray as EN,Raycaster as LN}from"three";function q0(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,oa(n),ra(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof Ft&&n.needsAO&&n.layers.enable(5),e}function $0(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 Y0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Ft)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)q0(e,e.material[t])&&(r=!0);else q0(e,e.material)&&(r=!0)}),r}function X0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Ft)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)$0(e,e.material[t])&&(r=!0);else $0(e,e.material)&&(r=!0)}),r}var DN=new LN,BN=new MN,RN=new EN;function ys(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let a=BN.copy(i.matrixWorld).invert(),s=RN.copy(r.ray).applyMatrix4(a),c=n.matrixWorld;s.applyMatrix4(c);let u=DN;u.set(s.origin,s.direction),u.near=r.near,u.far=r.far;let l=u.intersectObject(n,!1);l.length>0&&e.push({...l[0],object:t?i:n})}}var Mc=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 c=r.find(i[s]);c?c.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 UN=new FN;UN.wireframe=!0;var K0=new VN,Ec=class extends GN{constructor(e,t){super();this.data=e;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Mc;this.errorPage=new Ho("fdasfa",{...eo.defaultData,name:""});this.invisibleObjects=new Tn("jflkdsafjasdifjaslk",{...xl.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=X0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Y0(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 Ho&&(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)=>dp(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===Po)return this.activePage.personalCamera}if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}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(),i.resetBBoxNeedsUpdate(),Uo(i)&&ua(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty()}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),ua(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Uo(o)&&(o.freeBooleanPointer(),i instanceof or&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ya&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid)}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),Uo(o)&&(o.invalidateUpstreamBooleanData(),ua(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof or&&i.invalidateDownstreamBooleanData().recomputeBoolean())}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 Ho&&(t.visible=t.uuid===e,t.visible&&(this.activePage=t,this.activePage.onActive(this)))}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{W0(a,t,o,{scene:this,shared:i}),a instanceof Ze&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,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=>{ua(i)&&i.recomputeBoolean(),i instanceof po&&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){Te.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Te.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,a,s,c){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(l=>{l.data=vo(l.data,d=>{let p=d.events.data(c.id),f=l.goUp(s);if(f){let m=[...xs(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=Je.zoom(p,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,a,s){e.forEach(c=>{c.data.type==="Transition"?this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,a,s):c.data.type==="Animation"&&this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof fo&&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=vo(s.data,c=>{s.isInstanceRoot||(c.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of wl.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 fo&&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),Cc(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof fo&&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)Te.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 c=s.cloner;if(Te.is(s)&&!s.raycastLock&&(s.visible||c?.object.data.visible))if(t===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let l=u[0];l.object=s,l.point.applyMatrix4(l.object.matrixWorld);let d=s.matrixWorld.clone().invert();l.point.applyMatrix4(d),o.push(l)}}else(Uo(s)||ps(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),ys(s,e,o)),i(s)}};return i(this),o}raycastWithClones(e){let t=[],o=i=>{for(let a of i.children){let s=a.cloner;Te.is(a)&&(a.visible||s?.object.data.visible)&&((Uo(a)||ps(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),ys(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Te.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Te.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Te.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof Ze&&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();ua(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)pi.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Te.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 c={scene:this,shared:s},u=Ic(e,t,c);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(t,c),u instanceof Ze&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&u.traverseEntity(l=>{if(l instanceof Ze&&l.isSkinnedMesh){let d=l.dataPatched;if(d.bones&&d.boneInverses){let p=d.bones.map(h=>this.find(h)),f=d.boneInverses.map(h=>new zN().fromArray(h)),m=new kN(p,f);l.bind(m,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),u}getCenter(e){let t=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:c}=e[i],u=this.find(s),l=c?u.recursiveBBox:u.singleBBox;t.push(...l.vertices)}let o=new jN;return o.setFromPoints(t),o.getCenter(K0),K0}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 bt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof jt&&e(t.material[o]);else t.material instanceof jt&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof po&&i.setViewplaneSize(e,t,o)})}};import{DRACOLoader as HN}from"three/examples/jsm/loaders/DRACOLoader.js";var Wo;function WN(){return Wo||(Wo=new HN,Wo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Wo.decoderPending}async function qN(n){if(Wo){let r={attributeIDs:Wo.defaultAttributeIDs,attributeTypes:Wo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Wo.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 Z0(n,r){let[e,t]=qc(al.deserialize(new Uint8Array(n)));Pl(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 WN();for(let i of o){let a=await qN(We(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:c,array:u,itemSize:l})=>{s[c]={array:u,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}import{Mesh as dte}from"three";import{mergeBufferGeometries as fte}from"three/examples/jsm/utils/BufferGeometryUtils.js";function Q0(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}import{Color as J0,ShaderLib as $N}from"three";function ex(n){let r=new Set;return n.traverse(e=>{if(e instanceof Ft)if(He(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(YN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new J0,specularColor:new J0});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},$N.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let c=s.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,c.aspectRatio.value=Vg(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else XN(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function YN(n){return n.getLayersOfType("transmission").length>0}function XN(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 tx(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function rx(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}import{mergeBufferGeometries as KN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function ox(n){let r=[];return n.traverse(e=>{e instanceof sa&&r.push(e)}),r.forEach(e=>{let t=e.object,a=[...e.children.map(s=>{s.updateMatrix();let c;if(s.geometry!==void 0)try{c=s.geometry.clone().applyMatrix4(s.matrix)}catch(u){console.error(u)}return c!==void 0&&s.matrix.determinant()<0&&Q0(c),c}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof bt&&a.unshift(t.geometry),a.length){let s=KN(a);t instanceof bt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:t0})}),n}function nx(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function ix(n){Object.values(n.shared.materials).forEach(r=>{ap(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?ap(e.material):"materials"in e&&e.materials.forEach(t=>{ap(t)})})}function ap(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 dx=ga(sx(),1);function lx(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var cx="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",sp=class extends QN{load(r,e,t,o=console.error){let i=new ZN(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(cx+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(cx),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 Z0(r,ix);e.version&&(0,dx.default)(e.version,"0.9.457")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([c0(e)&&hg(),b0(e)&&Jg()].filter(Boolean));let t=new gn(e.shared);Object.values(t.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Ec(e.scene,t),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=ox(o),o=ex(o),o=tx(o),o=rx(o),o=nx(o),o=lx(o),o}};export{sp as default};