@splinetool/loader 0.9.440 → 0.9.441

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,16 +1,16 @@
1
- var J0=Object.create;var wc=Object.defineProperty;var ex=Object.getOwnPropertyDescriptor;var tx=Object.getOwnPropertyNames;var rx=Object.getPrototypeOf,ox=Object.prototype.hasOwnProperty;var vn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),nx=(n,r)=>{for(var e in r)wc(n,e,{get:r[e],enumerable:!0})},ix=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of tx(r))!ox.call(n,o)&&o!==e&&wc(n,o,{get:()=>r[o],enumerable:!(t=ex(r,o))||t.enumerable});return n};var ss=(n,r,e)=>(e=n!=null?J0(rx(n)):{},ix(r||!n||!n.__esModule?wc(e,"default",{value:n,enumerable:!0}):e,n));var Ah=vn((ou,Oh)=>{(function(n,r){typeof ou=="object"?Oh.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(ou,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,s=1;e.length==0&&(e=[+new Date]);var a=r();t=a(" "),o=a(" "),i=a(" ");for(var c=0;c<e.length;c++)t-=a(e[c]),t<0&&(t+=1),o-=a(e[c]),o<0&&(o+=1),i-=a(e[c]),i<0&&(i+=1);a=null;var d=function(){var l=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=l-(s=l|0)};return d.next=d,d.uint32=function(){return d()*4294967296},d.fract53=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.version="Alea 0.9",d.args=e,d.exportState=function(){return[t,o,i,s]},d.importState=function(l){t=+l[0]||0,o=+l[1]||0,i=+l[2]||0,s=+l[3]||0},d}(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 s=.02519603282416938*e;e=s>>>0,s-=e,s*=e,e=s>>>0,s-=e,e+=s*4294967296}return(e>>>0)*23283064365386963e-26};return t.version="Mash 0.9",t}})});var Eh=vn((xl,Mh)=>{(function(n,r){typeof xl=="object"&&typeof Mh<"u"?r(xl):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(xl,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 s,a,c,d,l,u,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=[],_=[],P=e==="f"?S:x,v=h=p=0;v<S;v++)b[v]=new Array(P).fill(0);for(v=0;v<x;v++)_[v]=new Array(x).fill(0);var N,T=new Array(x).fill(0);for(v=0;v<S;v++)for(s=0;s<x;s++)b[v][s]=r[v][s];for(v=0;v<x;v++){for(w[v]=p,m=0,c=v+1,s=v;s<S;s++)m+=Math.pow(b[s][v],2);if(m<i)p=0;else for(f=(u=b[v][v])*(p=u<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v]=u-p,s=c;s<x;s++){for(m=0,a=v;a<S;a++)m+=b[a][v]*b[a][s];for(u=m/f,a=v;a<S;a++)b[a][s]=b[a][s]+u*b[a][v]}for(T[v]=p,m=0,s=c;s<x;s++)m+=Math.pow(b[v][s],2);if(m<i)p=0;else{for(f=(u=b[v][v+1])*(p=u<0?Math.sqrt(m):-Math.sqrt(m))-m,b[v][v+1]=u-p,s=c;s<x;s++)w[s]=b[v][s]/f;for(s=c;s<S;s++){for(m=0,a=c;a<x;a++)m+=b[s][a]*b[v][a];for(a=c;a<x;a++)b[s][a]=b[s][a]+m*w[a]}}h<(y=Math.abs(T[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,s=c;s<x;s++)_[s][v]=b[v][s]/f;for(s=c;s<x;s++){for(m=0,a=c;a<x;a++)m+=b[v][a]*_[a][s];for(a=c;a<x;a++)_[a][s]=_[a][s]+m*_[a][v]}}for(s=c;s<x;s++)_[v][s]=0,_[s][v]=0;_[v][v]=1,p=w[v],c=v}if(e){if(e==="f")for(v=x;v<S;v++){for(s=x;s<S;s++)b[v][s]=0;b[v][v]=1}for(v=x-1;0<=v;v--){for(c=v+1,p=T[v],s=c;s<P;s++)b[v][s]=0;if(p!==0){for(f=b[v][v]*p,s=c;s<P;s++){for(m=0,a=c;a<S;a++)m+=b[a][v]*b[a][s];for(u=m/f,a=v;a<S;a++)b[a][s]=b[a][s]+u*b[a][v]}for(s=v;s<S;s++)b[s][v]=b[s][v]/p}else for(s=v;s<S;s++)b[s][v]=0;b[v][v]=b[v][v]+1}}for(o*=h,a=x-1;0<=a;a--)for(var C=0;C<50;C++){for(N=!1,c=a;0<=c;c--){if(Math.abs(w[c])<=o){N=!0;break}if(Math.abs(T[c-1])<=o)break}if(!N){for(l=0,d=c-(m=1),v=c;v<a+1&&(u=m*w[v],w[v]=l*w[v],!(Math.abs(u)<=o));v++)if(p=T[v],T[v]=Math.sqrt(u*u+p*p),l=p/(f=T[v]),m=-u/f,e)for(s=0;s<S;s++)y=b[s][d],g=b[s][v],b[s][d]=y*l+g*m,b[s][v]=-y*m+g*l}if(g=T[a],c===a){if(g<0&&(T[a]=-g,t))for(s=0;s<x;s++)_[s][a]=-_[s][a];break}for(h=T[c],u=(((y=T[a-1])-g)*(y+g)+((p=w[a-1])-(f=w[a]))*(p+f))/(2*f*y),p=Math.sqrt(u*u+1),u=((h-g)*(h+g)+f*(y/(u<0?u-p:u+p)-f))/h,v=c+(m=l=1);v<a+1;v++){if(p=w[v],y=T[v],f=m*p,p*=l,g=Math.sqrt(u*u+f*f),u=h*(l=u/(w[v-1]=g))+p*(m=f/g),p=-h*m+p*l,f=y*m,y*=l,t)for(s=0;s<x;s++)h=_[s][v-1],g=_[s][v],_[s][v-1]=h*l+g*m,_[s][v]=-h*m+g*l;if(g=Math.sqrt(u*u+f*f),u=(l=u/(T[v-1]=g))*p+(m=f/g)*y,h=-m*p+l*y,e)for(s=0;s<S;s++)y=b[s][v-1],g=b[s][v],b[s][v-1]=y*l+g*m,b[s][v]=-y*m+g*l}w[c]=0,w[a]=u,T[a]=h}for(v=0;v<x;v++)T[v]<o&&(T[v]=0);return{u:b,q:T,v:_}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var cy=vn((Iu,Mu)=>{(function(n,r){typeof Iu=="object"&&typeof Mu<"u"?Mu.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(Iu,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,s=o.compare,a=i[t];t>0;){var c=t-1>>1,d=i[c];if(s(a,d)>=0)break;i[t]=d,t=c}i[t]=a},n.prototype._down=function(t){for(var o=this,i=o.data,s=o.compare,a=this.length>>1,c=i[t];t<a;){var d=(t<<1)+1,l=i[d],u=d+1;if(u<this.length&&s(i[u],l)<0&&(d=u,l=i[u]),s(l,c)>=0)break;i[t]=l,t=d}i[t]=c};function r(e,t){return e<t?-1:e>t?1:0}return n})});var dy=vn((DF,Eu)=>{"use strict";var Cl=cy();Cl.default&&(Cl=Cl.default);Eu.exports=uy;Eu.exports.default=uy;function uy(n,r,e){r=r||1;for(var t,o,i,s,a=0;a<n[0].length;a++){var c=n[0][a];(!a||c[0]<t)&&(t=c[0]),(!a||c[1]<o)&&(o=c[1]),(!a||c[0]>i)&&(i=c[0]),(!a||c[1]>s)&&(s=c[1])}var d=i-t,l=s-o,u=Math.min(d,l),p=u/2;if(u===0){var f=[t,o];return f.distance=0,f}for(var m=new Cl(void 0,dT),h=t;h<i;h+=u)for(var y=o;y<s;y+=u)m.push(new Mo(h+p,y+p,p,n));var g=fT(n),x=new Mo(t+d/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 Mo(w.x-p,w.y-p,p,n)),m.push(new Mo(w.x+p,w.y-p,p,n)),m.push(new Mo(w.x-p,w.y+p,p,n)),m.push(new Mo(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 dT(n,r){return r.max-n.max}function Mo(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=pT(n,r,t),this.max=this.d+this.h*Math.SQRT2}function pT(n,r,e){for(var t=!1,o=1/0,i=0;i<e.length;i++)for(var s=e[i],a=0,c=s.length,d=c-1;a<c;d=a++){var l=s[a],u=s[d];l[1]>r!=u[1]>r&&n<(u[0]-l[0])*(r-l[1])/(u[1]-l[1])+l[0]&&(t=!t),o=Math.min(o,mT(n,r,l,u))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function fT(n){for(var r=0,e=0,t=0,o=n[0],i=0,s=o.length,a=s-1;i<s;a=i++){var c=o[i],d=o[a],l=c[0]*d[1]-d[0]*c[1];e+=(c[0]+d[0])*l,t+=(c[1]+d[1])*l,r+=l*3}return r===0?new Mo(o[0][0],o[0][1],0,n):new Mo(e/r,t/r,0,n)}function mT(n,r,e,t){var o=e[0],i=e[1],s=t[0]-o,a=t[1]-i;if(s!==0||a!==0){var c=((n-o)*s+(r-i)*a)/(s*s+a*a);c>1?(o=t[0],i=t[1]):c>0&&(o+=s*c,i+=a*c)}return s=n-o,a=r-i,s*s+a*a}});var Ag=vn(ec=>{(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 u=this||r;if(l=parseFloat(l),u.ctx||d(),typeof l<"u"&&l>=0&&l<=1){if(u._volume=l,u._muted)return u;u.usingWebAudio&&u.masterGain.gain.setValueAtTime(l,r.ctx.currentTime);for(var p=0;p<u._howls.length;p++)if(!u._howls[p]._webAudio)for(var f=u._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=u._howls[p]._soundById(f[m]);h&&h._node&&(h._node.volume=h._volume*l)}return u}return u._volume},mute:function(l){var u=this||r;u.ctx||d(),u._muted=l,u.usingWebAudio&&u.masterGain.gain.setValueAtTime(l?0:u._volume,r.ctx.currentTime);for(var p=0;p<u._howls.length;p++)if(!u._howls[p]._webAudio)for(var f=u._howls[p]._getSoundIds(),m=0;m<f.length;m++){var h=u._howls[p]._soundById(f[m]);h&&h._node&&(h._node.muted=l?!0:h._muted)}return u},stop:function(){for(var l=this||r,u=0;u<l._howls.length;u++)l._howls[u].stop();return l},unload:function(){for(var l=this||r,u=l._howls.length-1;u>=0;u--)l._howls[u].unload();return l.usingWebAudio&&l.ctx&&typeof l.ctx.close<"u"&&(l.ctx.close(),l.ctx=null,d()),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 u=new Audio;typeof u.oncanplaythrough>"u"&&(l._canPlayEvent="canplay")}catch{l.noAudio=!0}else l.noAudio=!0;try{var u=new Audio;u.muted&&(l.noAudio=!0)}catch{}return l.noAudio||l._setupCodecs(),l},_setupCodecs:function(){var l=this||r,u=null;try{u=typeof Audio<"u"?new Audio:null}catch{return l}if(!u||typeof u.canPlayType!="function")return l;var p=u.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||u.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!p,opus:!!u.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!u.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!u.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(u.canPlayType('audio/wav; codecs="1"')||u.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!u.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!u.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(u.canPlayType("audio/x-m4a;")||u.canPlayType("audio/m4a;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(u.canPlayType("audio/x-m4b;")||u.canPlayType("audio/m4b;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(u.canPlayType("audio/x-mp4;")||u.canPlayType("audio/mp4;")||u.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!x&&u.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!x&&u.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!u.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(u.canPlayType("audio/x-flac;")||u.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 u=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",u,!0),document.removeEventListener("touchend",u,!0),document.removeEventListener("click",u,!0),document.removeEventListener("keydown",u,!0);for(var S=0;S<l._howls.length;S++)l._howls[S]._emit("unlock")}};return document.addEventListener("touchstart",u,!0),document.addEventListener("touchend",u,!0),document.addEventListener("click",u,!0),document.addEventListener("keydown",u,!0),l}},_obtainHtml5Audio:function(){var l=this||r;if(l._html5AudioPool.length)return l._html5AudioPool.pop();var u=new Audio().play();return u&&typeof Promise<"u"&&(u instanceof Promise||typeof u.then=="function")&&u.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(l){var u=this||r;return l._unlocked&&u._html5AudioPool.push(l),u},_autoSuspend:function(){var l=this;if(!(!l.autoSuspend||!l.ctx||typeof l.ctx.suspend>"u"||!r.usingWebAudio)){for(var u=0;u<l._howls.length;u++)if(l._howls[u]._webAudio){for(var p=0;p<l._howls[u]._sounds.length;p++)if(!l._howls[u]._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 u=0;u<l._howls.length;u++)l._howls[u]._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 u=this;if(!l.src||l.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}u.init(l)};e.prototype={init:function(l){var u=this;return r.ctx||d(),u._autoplay=l.autoplay||!1,u._format=typeof l.format!="string"?l.format:[l.format],u._html5=l.html5||!1,u._muted=l.mute||!1,u._loop=l.loop||!1,u._pool=l.pool||5,u._preload=typeof l.preload=="boolean"||l.preload==="metadata"?l.preload:!0,u._rate=l.rate||1,u._sprite=l.sprite||{},u._src=typeof l.src!="string"?l.src:[l.src],u._volume=l.volume!==void 0?l.volume:1,u._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},u._duration=0,u._state="unloaded",u._sounds=[],u._endTimers={},u._queue=[],u._playLock=!1,u._onend=l.onend?[{fn:l.onend}]:[],u._onfade=l.onfade?[{fn:l.onfade}]:[],u._onload=l.onload?[{fn:l.onload}]:[],u._onloaderror=l.onloaderror?[{fn:l.onloaderror}]:[],u._onplayerror=l.onplayerror?[{fn:l.onplayerror}]:[],u._onpause=l.onpause?[{fn:l.onpause}]:[],u._onplay=l.onplay?[{fn:l.onplay}]:[],u._onstop=l.onstop?[{fn:l.onstop}]:[],u._onmute=l.onmute?[{fn:l.onmute}]:[],u._onvolume=l.onvolume?[{fn:l.onvolume}]:[],u._onrate=l.onrate?[{fn:l.onrate}]:[],u._onseek=l.onseek?[{fn:l.onseek}]:[],u._onunlock=l.onunlock?[{fn:l.onunlock}]:[],u._onresume=[],u._webAudio=r.usingWebAudio&&!u._html5,typeof r.ctx<"u"&&r.ctx&&r.autoUnlock&&r._unlockAudio(),r._howls.push(u),u._autoplay&&u._queue.push({event:"play",action:function(){u.play()}}),u._preload&&u._preload!=="none"&&u.load(),u},load:function(){var l=this,u=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)){u=l._src[p];break}}if(!u){l._emit("loaderror",null,"No codec support for selected audio sources.");return}return l._src=u,l._state="loading",window.location.protocol==="https:"&&u.slice(0,5)==="http:"&&(l._html5=!0,l._webAudio=!1),new t(l),l._webAudio&&i(l),l},play:function(l,u){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 u||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,_=(p._sprite[l][0]+p._sprite[l][1])/1e3;y._sprite=l,y._ended=!1;var P=function(){y._paused=!1,y._seek=x,y._start=b,y._stop=_,y._loop=!!(y._loop||p._sprite[l][2])};if(x>=_){p._ended(y);return}var v=y._node;if(p._webAudio){var N=function(){p._playLock=!1,P(),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)),u||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 T=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,P(),A.then(function(){p._playLock=!1,v._unlocked=!0,u?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})):u||(p._playLock=!1,P(),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)T();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",T(),v.removeEventListener(r._canPlayEvent,O,!1)};v.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(l){var u=this;if(u._state!=="loaded"||u._playLock)return u._queue.push({event:"pause",action:function(){u.pause(l)}}),u;for(var p=u._getSoundIds(l),f=0;f<p.length;f++){u._clearTimer(p[f]);var m=u._soundById(p[f]);if(m&&!m._paused&&(m._seek=u.seek(p[f]),m._rateSeek=0,m._paused=!0,u._stopFade(p[f]),m._node))if(u._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),u._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||u._emit("pause",m?m._id:null)}return u},stop:function(l,u){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))),u||p._emit("stop",h._id))}return p},mute:function(l,u){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(l,u)}}),p;if(typeof u>"u")if(typeof l=="boolean")p._muted=l;else return p._muted;for(var f=p._getSoundIds(u),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,u=arguments,p,f;if(u.length===0)return l._volume;if(u.length===1||u.length===2&&typeof u[1]>"u"){var m=l._getSoundIds(),h=m.indexOf(u[0]);h>=0?f=parseInt(u[0],10):p=parseFloat(u[0])}else u.length>=2&&(p=parseFloat(u[0]),f=parseInt(u[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,u)}}),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,u[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,u,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(l,u,p,f)}}),m;l=Math.min(Math.max(0,parseFloat(l)),1),u=Math.min(Math.max(0,parseFloat(u)),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(u,S)}m._startFadeInterval(g,l,u,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(l,u,p,f,m,h){var y=this,g=u,x=p-u,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 _=(Date.now()-b)/f;b=Date.now(),g+=x*_,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<u&&g<=p||p>u&&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 u=this,p=u._soundById(l);return p&&p._interval&&(u._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,u.volume(p._fadeTo,l),p._fadeTo=null,u._emit("fade",l)),u},loop:function(){var l=this,u=arguments,p,f,m;if(u.length===0)return l._loop;if(u.length===1)if(typeof u[0]=="boolean")p=u[0],l._loop=p;else return m=l._soundById(parseInt(u[0],10)),m?m._loop:!1;else u.length===2&&(p=u[0],f=parseInt(u[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,u=arguments,p,f;if(u.length===0)f=l._sounds[0]._id;else if(u.length===1){var m=l._getSoundIds(),h=m.indexOf(u[0]);h>=0?f=parseInt(u[0],10):p=parseFloat(u[0])}else u.length===2&&(p=parseFloat(u[0]),f=parseInt(u[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,u)}}),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,u=arguments,p,f;if(u.length===0)l._sounds.length&&(f=l._sounds[0]._id);else if(u.length===1){var m=l._getSoundIds(),h=m.indexOf(u[0]);h>=0?f=parseInt(u[0],10):l._sounds.length&&(f=l._sounds[0]._id,p=parseFloat(u[0]))}else u.length===2&&(p=parseFloat(u[0]),f=parseInt(u[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,u)}}),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 u=this;if(typeof l=="number"){var p=u._soundById(l);return p?!p._paused:!1}for(var f=0;f<u._sounds.length;f++)if(!u._sounds[f]._paused)return!0;return!1},duration:function(l){var u=this,p=u._duration,f=u._soundById(l);return f&&(p=u._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var l=this,u=l._sounds,p=0;p<u.length;p++)u[p]._paused||l.stop(u[p]._id),l._webAudio||(l._clearSound(u[p]._node),u[p]._node.removeEventListener("error",u[p]._errorFn,!1),u[p]._node.removeEventListener(r._canPlayEvent,u[p]._loadFn,!1),u[p]._node.removeEventListener("ended",u[p]._endFn,!1),r._releaseHtml5Audio(u[p]._node)),delete u[p]._node,l._clearTimer(u[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,u,p,f){var m=this,h=m["_on"+l];return typeof u=="function"&&h.push(f?{id:p,fn:u,once:f}:{id:p,fn:u}),m},off:function(l,u,p){var f=this,m=f["_on"+l],h=0;if(typeof u=="number"&&(p=u,u=null),u||p)for(h=0;h<m.length;h++){var y=p===m[h].id;if(u===m[h].fn&&y||!u&&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,u,p){var f=this;return f.on(l,u,p,1),f},_emit:function(l,u,p){for(var f=this,m=f["_on"+l],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===u||l==="load")&&(setTimeout(function(y){y.call(this,u,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 u=this;if(u._queue.length>0){var p=u._queue[0];p.event===l&&(u._queue.shift(),u._loadQueue()),l||p.action()}return u},_ended:function(l){var u=this,p=l._sprite;if(!u._webAudio&&l._node&&!l._node.paused&&!l._node.ended&&l._node.currentTime<l._stop)return setTimeout(u._ended.bind(u,l),100),u;var f=!!(l._loop||u._sprite[p][2]);if(u._emit("end",l._id),!u._webAudio&&f&&u.stop(l._id,!0).play(l._id),u._webAudio&&f){u._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);u._endTimers[l._id]=setTimeout(u._ended.bind(u,l),m)}return u._webAudio&&!f&&(l._paused=!0,l._ended=!0,l._seek=l._start||0,l._rateSeek=0,u._clearTimer(l._id),u._cleanBuffer(l._node),r._autoSuspend()),!u._webAudio&&!f&&u.stop(l._id,!0),u},_clearTimer:function(l){var u=this;if(u._endTimers[l]){if(typeof u._endTimers[l]!="function")clearTimeout(u._endTimers[l]);else{var p=u._soundById(l);p&&p._node&&p._node.removeEventListener("ended",u._endTimers[l],!1)}delete u._endTimers[l]}return u},_soundById:function(l){for(var u=this,p=0;p<u._sounds.length;p++)if(l===u._sounds[p]._id)return u._sounds[p];return null},_inactiveSound:function(){var l=this;l._drain();for(var u=0;u<l._sounds.length;u++)if(l._sounds[u]._ended)return l._sounds[u].reset();return new t(l)},_drain:function(){var l=this,u=l._pool,p=0,f=0;if(!(l._sounds.length<u)){for(f=0;f<l._sounds.length;f++)l._sounds[f]._ended&&p++;for(f=l._sounds.length-1;f>=0;f--){if(p<=u)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 u=this;if(typeof l>"u"){for(var p=[],f=0;f<u._sounds.length;f++)p.push(u._sounds[f]._id);return p}else return[l]},_refreshBuffer:function(l){var u=this;return l._node.bufferSource=r.ctx.createBufferSource(),l._node.bufferSource.buffer=o[u._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),u},_cleanBuffer:function(l){var u=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,u},_clearSound:function(l){var u=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);u||(l.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(l){this._parent=l,this.init()};t.prototype={init:function(){var l=this,u=l._parent;return l._muted=u._muted,l._loop=u._loop,l._volume=u._volume,l._rate=u._rate,l._seek=0,l._paused=!0,l._ended=!0,l._sprite="__default",l._id=++r._counter,u._sounds.push(l),l.create(),l},create:function(){var l=this,u=l._parent,p=r._muted||l._muted||l._parent._muted?0:l._volume;return u._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=u._src,l._node.preload=u._preload===!0?"auto":u._preload,l._node.volume=p*r.volume(),l._node.load()),l},reset:function(){var l=this,u=l._parent;return l._muted=u._muted,l._loop=u._loop,l._volume=u._volume,l._rate=u._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,u=l._parent;u._duration=Math.ceil(l._node.duration*10)/10,Object.keys(u._sprite).length===0&&(u._sprite={__default:[0,u._duration*1e3]}),u._state!=="loaded"&&(u._state="loaded",u._emit("load"),u._loadQueue()),l._node.removeEventListener(r._canPlayEvent,l._loadFn,!1)},_endListener:function(){var l=this,u=l._parent;u._duration===1/0&&(u._duration=Math.ceil(l._node.duration*10)/10,u._sprite.__default[1]===1/0&&(u._sprite.__default[1]=u._duration*1e3),u._ended(l)),l._node.removeEventListener("ended",l._endFn,!1)}};var o={},i=function(l){var u=l._src;if(o[u]){l._duration=o[u].duration,c(l);return}if(/^data:[^;]+;base64,/.test(u)){for(var p=atob(u.split(",")[1]),f=new Uint8Array(p.length),m=0;m<p.length;++m)f[m]=p.charCodeAt(m);a(f.buffer,l)}else{var h=new XMLHttpRequest;h.open(l._xhr.method,u,!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}a(h.response,l)},h.onerror=function(){l._webAudio&&(l._html5=!0,l._webAudio=!1,l._sounds=[],delete o[u],l.load())},s(h)}},s=function(l){try{l.send()}catch{l.onerror()}},a=function(l,u){var p=function(){u._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&u._sounds.length>0?(o[u._src]=m,c(u,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,u){u&&!l._duration&&(l._duration=u.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())},d=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),u=r._navigator&&r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),p=u?parseInt(u[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 ec<"u"&&(ec.Howler=r,ec.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,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;var c=a._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,s=typeof s!="number"?c[5]:s,typeof r=="number")a._orientation=[r,e,t,o,i,s],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return a},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),s=0;s<i.length;s++){var a=t._soundById(i[s]);if(a)if(typeof r=="number")a._stereo=r,a._pos=[r,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",(!a._panner||!a._panner.pan)&&n(a,o),o==="spatial"?typeof a._panner.positionX<"u"?(a._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(r,0,0):a._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",a._id);else return a._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 s=i._getSoundIds(o),a=0;a<s.length;a++){var c=i._soundById(s[a]);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 s=i._getSoundIds(o),a=0;a<s.length;a++){var c=i._soundById(s[a]);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 s=r._getSoundIds(o),a=0;a<s.length;a++)if(i=r._soundById(s[a]),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 d=i._panner;d?(d.coneInnerAngle=c.coneInnerAngle,d.coneOuterAngle=c.coneOuterAngle,d.coneOuterGain=c.coneOuterGain,d.distanceModel=c.distanceModel,d.maxDistance=c.maxDistance,d.refDistance=c.refDistance,d.rolloffFactor=c.rolloffFactor,d.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 k0=vn((lee,F0)=>{F0.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var s=Number(t[i]),a=Number(o[i]);if(s>a)return 1;if(a>s)return-1;if(!isNaN(s)&&isNaN(a))return 1;if(isNaN(s)&&!isNaN(a))return-1}return 0}});import{FileLoader as yN,Loader as gN}from"three";function Kd(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function or(n,r){return Object.setPrototypeOf(n,r),n}function ca(n){return Array.isArray(n)?n:[n]}function Zd(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 sx=typeof global=="object"&&global&&global.Object===Object&&global,ua=sx;var ax=typeof self=="object"&&self&&self.Object===Object&&self,lx=ua||ax||Function("return this")(),Ke=lx;var cx=Ke.Symbol,it=cx;var Qd=Object.prototype,ux=Qd.hasOwnProperty,dx=Qd.toString,as=it?it.toStringTag:void 0;function px(n){var r=ux.call(n,as),e=n[as];try{n[as]=void 0;var t=!0}catch{}var o=dx.call(n);return t&&(r?n[as]=e:delete n[as]),o}var Jd=px;var fx=Object.prototype,mx=fx.toString;function hx(n){return mx.call(n)}var ep=hx;var yx="[object Null]",gx="[object Undefined]",tp=it?it.toStringTag:void 0;function xx(n){return n==null?n===void 0?gx:yx:tp&&tp in Object(n)?Jd(n):ep(n)}var kt=xx;function vx(n){return n!=null&&typeof n=="object"}var mt=vx;var bx="[object Symbol]";function Sx(n){return typeof n=="symbol"||mt(n)&&kt(n)==bx}var bn=Sx;function wx(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 da=wx;var _x=Array.isArray,He=_x;var Px=1/0,rp=it?it.prototype:void 0,op=rp?rp.toString:void 0;function np(n){if(typeof n=="string")return n;if(He(n))return da(n,np)+"";if(bn(n))return op?op.call(n):"";var r=n+"";return r=="0"&&1/n==-Px?"-0":r}var ip=np;function Tx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Ut=Tx;function Ox(n){return n}var sp=Ox;var Ax="[object AsyncFunction]",Cx="[object Function]",Nx="[object GeneratorFunction]",Ix="[object Proxy]";function Mx(n){if(!Ut(n))return!1;var r=kt(n);return r==Cx||r==Nx||r==Ax||r==Ix}var pa=Mx;var Ex=Ke["__core-js_shared__"],fa=Ex;var ap=function(){var n=/[^.]+$/.exec(fa&&fa.keys&&fa.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Lx(n){return!!ap&&ap in n}var lp=Lx;var Dx=Function.prototype,Bx=Dx.toString;function Rx(n){if(n!=null){try{return Bx.call(n)}catch{}try{return n+""}catch{}}return""}var $r=Rx;var Gx=/[\\^$.*+?()[\]{}|]/g,Vx=/^\[object .+?Constructor\]$/,zx=Function.prototype,jx=Object.prototype,Fx=zx.toString,kx=jx.hasOwnProperty,Ux=RegExp("^"+Fx.call(kx).replace(Gx,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hx(n){if(!Ut(n)||lp(n))return!1;var r=pa(n)?Ux:Vx;return r.test($r(n))}var cp=Hx;function Wx(n,r){return n?.[r]}var up=Wx;function qx(n,r){var e=up(n,r);return cp(e)?e:void 0}var Dt=qx;var $x=Dt(Ke,"WeakMap"),ma=$x;var dp=Object.create,Yx=function(){function n(){}return function(r){if(!Ut(r))return{};if(dp)return dp(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),pp=Yx;function Xx(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 fp=Xx;function Kx(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var mp=Kx;var Zx=800,Qx=16,Jx=Date.now;function ev(n){var r=0,e=0;return function(){var t=Jx(),o=Qx-(t-e);if(e=t,o>0){if(++r>=Zx)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var hp=ev;function tv(n){return function(){return n}}var yp=tv;var rv=function(){try{var n=Dt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Sn=rv;var ov=Sn?function(n,r){return Sn(n,"toString",{configurable:!0,enumerable:!1,value:yp(r),writable:!0})}:sp,gp=ov;var nv=hp(gp),xp=nv;function iv(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var vp=iv;var sv=9007199254740991,av=/^(?:0|[1-9]\d*)$/;function lv(n,r){var e=typeof n;return r=r??sv,!!r&&(e=="number"||e!="symbol"&&av.test(n))&&n>-1&&n%1==0&&n<r}var wn=lv;function cv(n,r,e){r=="__proto__"&&Sn?Sn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var ha=cv;function uv(n,r){return n===r||n!==n&&r!==r}var _n=uv;var dv=Object.prototype,pv=dv.hasOwnProperty;function fv(n,r,e){var t=n[r];(!(pv.call(n,r)&&_n(t,e))||e===void 0&&!(r in n))&&ha(n,r,e)}var Pn=fv;function mv(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var a=r[i],c=t?t(e[a],n[a],a,e,n):void 0;c===void 0&&(c=n[a]),o?ha(e,a,c):Pn(e,a,c)}return e}var br=mv;var bp=Math.max;function hv(n,r,e){return r=bp(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=bp(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var a=Array(r+1);++o<r;)a[o]=t[o];return a[r]=e(s),fp(n,this,a)}}var Sp=hv;var yv=9007199254740991;function gv(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=yv}var Tn=gv;function xv(n){return n!=null&&Tn(n.length)&&!pa(n)}var ya=xv;var vv=Object.prototype;function bv(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||vv;return n===e}var On=bv;function Sv(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var wp=Sv;var wv="[object Arguments]";function _v(n){return mt(n)&&kt(n)==wv}var _c=_v;var _p=Object.prototype,Pv=_p.hasOwnProperty,Tv=_p.propertyIsEnumerable,Ov=_c(function(){return arguments}())?_c:function(n){return mt(n)&&Pv.call(n,"callee")&&!Tv.call(n,"callee")},An=Ov;function Av(){return!1}var Pp=Av;var Ap=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Tp=Ap&&typeof module=="object"&&module&&!module.nodeType&&module,Cv=Tp&&Tp.exports===Ap,Op=Cv?Ke.Buffer:void 0,Nv=Op?Op.isBuffer:void 0,Iv=Nv||Pp,Fo=Iv;var Mv="[object Arguments]",Ev="[object Array]",Lv="[object Boolean]",Dv="[object Date]",Bv="[object Error]",Rv="[object Function]",Gv="[object Map]",Vv="[object Number]",zv="[object Object]",jv="[object RegExp]",Fv="[object Set]",kv="[object String]",Uv="[object WeakMap]",Hv="[object ArrayBuffer]",Wv="[object DataView]",qv="[object Float32Array]",$v="[object Float64Array]",Yv="[object Int8Array]",Xv="[object Int16Array]",Kv="[object Int32Array]",Zv="[object Uint8Array]",Qv="[object Uint8ClampedArray]",Jv="[object Uint16Array]",eb="[object Uint32Array]",ze={};ze[qv]=ze[$v]=ze[Yv]=ze[Xv]=ze[Kv]=ze[Zv]=ze[Qv]=ze[Jv]=ze[eb]=!0;ze[Mv]=ze[Ev]=ze[Hv]=ze[Lv]=ze[Wv]=ze[Dv]=ze[Bv]=ze[Rv]=ze[Gv]=ze[Vv]=ze[zv]=ze[jv]=ze[Fv]=ze[kv]=ze[Uv]=!1;function tb(n){return mt(n)&&Tn(n.length)&&!!ze[kt(n)]}var Cp=tb;function rb(n){return function(r){return n(r)}}var Cn=rb;var Np=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ls=Np&&typeof module=="object"&&module&&!module.nodeType&&module,ob=ls&&ls.exports===Np,Pc=ob&&ua.process,nb=function(){try{var n=ls&&ls.require&&ls.require("util").types;return n||Pc&&Pc.binding&&Pc.binding("util")}catch{}}(),Yr=nb;var Ip=Yr&&Yr.isTypedArray,ib=Ip?Cn(Ip):Cp,ga=ib;var sb=Object.prototype,ab=sb.hasOwnProperty;function lb(n,r){var e=He(n),t=!e&&An(n),o=!e&&!t&&Fo(n),i=!e&&!t&&!o&&ga(n),s=e||t||o||i,a=s?wp(n.length,String):[],c=a.length;for(var d in n)(r||ab.call(n,d))&&!(s&&(d=="length"||o&&(d=="offset"||d=="parent")||i&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||wn(d,c)))&&a.push(d);return a}var xa=lb;function cb(n,r){return function(e){return n(r(e))}}var va=cb;var ub=va(Object.keys,Object),Mp=ub;var db=Object.prototype,pb=db.hasOwnProperty;function fb(n){if(!On(n))return Mp(n);var r=[];for(var e in Object(n))pb.call(n,e)&&e!="constructor"&&r.push(e);return r}var Ep=fb;function mb(n){return ya(n)?xa(n):Ep(n)}var Nn=mb;function hb(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var Lp=hb;var yb=Object.prototype,gb=yb.hasOwnProperty;function xb(n){if(!Ut(n))return Lp(n);var r=On(n),e=[];for(var t in n)t=="constructor"&&(r||!gb.call(n,t))||e.push(t);return e}var Dp=xb;function vb(n){return ya(n)?xa(n,!0):Dp(n)}var In=vb;var bb=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Sb=/^\w*$/;function wb(n,r){if(He(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||bn(n)?!0:Sb.test(n)||!bb.test(n)||r!=null&&n in Object(r)}var Bp=wb;var _b=Dt(Object,"create"),Xr=_b;function Pb(){this.__data__=Xr?Xr(null):{},this.size=0}var Rp=Pb;function Tb(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Gp=Tb;var Ob="__lodash_hash_undefined__",Ab=Object.prototype,Cb=Ab.hasOwnProperty;function Nb(n){var r=this.__data__;if(Xr){var e=r[n];return e===Ob?void 0:e}return Cb.call(r,n)?r[n]:void 0}var Vp=Nb;var Ib=Object.prototype,Mb=Ib.hasOwnProperty;function Eb(n){var r=this.__data__;return Xr?r[n]!==void 0:Mb.call(r,n)}var zp=Eb;var Lb="__lodash_hash_undefined__";function Db(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Xr&&r===void 0?Lb:r,this}var jp=Db;function Mn(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])}}Mn.prototype.clear=Rp;Mn.prototype.delete=Gp;Mn.prototype.get=Vp;Mn.prototype.has=zp;Mn.prototype.set=jp;var Tc=Mn;function Bb(){this.__data__=[],this.size=0}var Fp=Bb;function Rb(n,r){for(var e=n.length;e--;)if(_n(n[e][0],r))return e;return-1}var po=Rb;var Gb=Array.prototype,Vb=Gb.splice;function zb(n){var r=this.__data__,e=po(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Vb.call(r,e,1),--this.size,!0}var kp=zb;function jb(n){var r=this.__data__,e=po(r,n);return e<0?void 0:r[e][1]}var Up=jb;function Fb(n){return po(this.__data__,n)>-1}var Hp=Fb;function kb(n,r){var e=this.__data__,t=po(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var Wp=kb;function En(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])}}En.prototype.clear=Fp;En.prototype.delete=kp;En.prototype.get=Up;En.prototype.has=Hp;En.prototype.set=Wp;var fo=En;var Ub=Dt(Ke,"Map"),mo=Ub;function Hb(){this.size=0,this.__data__={hash:new Tc,map:new(mo||fo),string:new Tc}}var qp=Hb;function Wb(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var $p=Wb;function qb(n,r){var e=n.__data__;return $p(r)?e[typeof r=="string"?"string":"hash"]:e.map}var ho=qb;function $b(n){var r=ho(this,n).delete(n);return this.size-=r?1:0,r}var Yp=$b;function Yb(n){return ho(this,n).get(n)}var Xp=Yb;function Xb(n){return ho(this,n).has(n)}var Kp=Xb;function Kb(n,r){var e=ho(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var Zp=Kb;function Ln(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])}}Ln.prototype.clear=qp;Ln.prototype.delete=Yp;Ln.prototype.get=Xp;Ln.prototype.has=Kp;Ln.prototype.set=Zp;var ko=Ln;var Zb="Expected a function";function Oc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(Zb);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 s=n.apply(this,t);return e.cache=i.set(o,s)||i,s};return e.cache=new(Oc.Cache||ko),e}Oc.Cache=ko;var Qp=Oc;var Qb=500;function Jb(n){var r=Qp(n,function(t){return e.size===Qb&&e.clear(),t}),e=r.cache;return r}var Jp=Jb;var eS=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tS=/\\(\\)?/g,rS=Jp(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(eS,function(e,t,o,i){r.push(o?i.replace(tS,"$1"):t||e)}),r}),ef=rS;function oS(n){return n==null?"":ip(n)}var tf=oS;function nS(n,r){return He(n)?n:Bp(n,r)?[n]:ef(tf(n))}var Xt=nS;var iS=1/0;function sS(n){if(typeof n=="string"||bn(n))return n;var r=n+"";return r=="0"&&1/n==-iS?"-0":r}var yo=sS;function aS(n,r){r=Xt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[yo(r[e++])];return e&&e==t?n:void 0}var ba=aS;function lS(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var Dn=lS;var rf=it?it.isConcatSpreadable:void 0;function cS(n){return He(n)||An(n)||!!(rf&&n&&n[rf])}var of=cS;function nf(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=of),o||(o=[]);++i<s;){var a=n[i];r>0&&e(a)?r>1?nf(a,r-1,e,t,o):Dn(o,a):t||(o[o.length]=a)}return o}var sf=nf;function uS(n){var r=n==null?0:n.length;return r?sf(n,1):[]}var af=uS;function dS(n){return xp(Sp(n,void 0,af),n+"")}var Sa=dS;var pS=va(Object.getPrototypeOf,Object),Bn=pS;var fS="[object Object]",mS=Function.prototype,hS=Object.prototype,lf=mS.toString,yS=hS.hasOwnProperty,gS=lf.call(Object);function xS(n){if(!mt(n)||kt(n)!=fS)return!1;var r=Bn(n);if(r===null)return!0;var e=yS.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&lf.call(e)==gS}var cf=xS;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 uf=vS;function bS(){this.__data__=new fo,this.size=0}var df=bS;function SS(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var pf=SS;function wS(n){return this.__data__.get(n)}var ff=wS;function _S(n){return this.__data__.has(n)}var mf=_S;var PS=200;function TS(n,r){var e=this.__data__;if(e instanceof fo){var t=e.__data__;if(!mo||t.length<PS-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new ko(t)}return e.set(n,r),this.size=e.size,this}var hf=TS;function Rn(n){var r=this.__data__=new fo(n);this.size=r.size}Rn.prototype.clear=df;Rn.prototype.delete=pf;Rn.prototype.get=ff;Rn.prototype.has=mf;Rn.prototype.set=hf;var Gn=Rn;function OS(n,r){return n&&br(r,Nn(r),n)}var yf=OS;function AS(n,r){return n&&br(r,In(r),n)}var gf=AS;var Sf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xf=Sf&&typeof module=="object"&&module&&!module.nodeType&&module,CS=xf&&xf.exports===Sf,vf=CS?Ke.Buffer:void 0,bf=vf?vf.allocUnsafe:void 0;function NS(n,r){if(r)return n.slice();var e=n.length,t=bf?bf(e):new n.constructor(e);return n.copy(t),t}var wf=NS;function IS(n,r){for(var e=-1,t=n==null?0:n.length,o=0,i=[];++e<t;){var s=n[e];r(s,e,n)&&(i[o++]=s)}return i}var _f=IS;function MS(){return[]}var wa=MS;var ES=Object.prototype,LS=ES.propertyIsEnumerable,Pf=Object.getOwnPropertySymbols,DS=Pf?function(n){return n==null?[]:(n=Object(n),_f(Pf(n),function(r){return LS.call(n,r)}))}:wa,Vn=DS;function BS(n,r){return br(n,Vn(n),r)}var Tf=BS;var RS=Object.getOwnPropertySymbols,GS=RS?function(n){for(var r=[];n;)Dn(r,Vn(n)),n=Bn(n);return r}:wa,_a=GS;function VS(n,r){return br(n,_a(n),r)}var Of=VS;function zS(n,r,e){var t=r(n);return He(n)?t:Dn(t,e(n))}var Pa=zS;function jS(n){return Pa(n,Nn,Vn)}var cs=jS;function FS(n){return Pa(n,In,_a)}var Ta=FS;var kS=Dt(Ke,"DataView"),Oa=kS;var US=Dt(Ke,"Promise"),Aa=US;var HS=Dt(Ke,"Set"),Ca=HS;var Af="[object Map]",WS="[object Object]",Cf="[object Promise]",Nf="[object Set]",If="[object WeakMap]",Mf="[object DataView]",qS=$r(Oa),$S=$r(mo),YS=$r(Aa),XS=$r(Ca),KS=$r(ma),Uo=kt;(Oa&&Uo(new Oa(new ArrayBuffer(1)))!=Mf||mo&&Uo(new mo)!=Af||Aa&&Uo(Aa.resolve())!=Cf||Ca&&Uo(new Ca)!=Nf||ma&&Uo(new ma)!=If)&&(Uo=function(n){var r=kt(n),e=r==WS?n.constructor:void 0,t=e?$r(e):"";if(t)switch(t){case qS:return Mf;case $S:return Af;case YS:return Cf;case XS:return Nf;case KS:return If}return r});var Kr=Uo;var ZS=Object.prototype,QS=ZS.hasOwnProperty;function JS(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&QS.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Ef=JS;var ew=Ke.Uint8Array,zn=ew;function tw(n){var r=new n.constructor(n.byteLength);return new zn(r).set(new zn(n)),r}var jn=tw;function rw(n,r){var e=r?jn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Lf=rw;var ow=/\w*$/;function nw(n){var r=new n.constructor(n.source,ow.exec(n));return r.lastIndex=n.lastIndex,r}var Df=nw;var Bf=it?it.prototype:void 0,Rf=Bf?Bf.valueOf:void 0;function iw(n){return Rf?Object(Rf.call(n)):{}}var Gf=iw;function sw(n,r){var e=r?jn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Vf=sw;var aw="[object Boolean]",lw="[object Date]",cw="[object Map]",uw="[object Number]",dw="[object RegExp]",pw="[object Set]",fw="[object String]",mw="[object Symbol]",hw="[object ArrayBuffer]",yw="[object DataView]",gw="[object Float32Array]",xw="[object Float64Array]",vw="[object Int8Array]",bw="[object Int16Array]",Sw="[object Int32Array]",ww="[object Uint8Array]",_w="[object Uint8ClampedArray]",Pw="[object Uint16Array]",Tw="[object Uint32Array]";function Ow(n,r,e){var t=n.constructor;switch(r){case hw:return jn(n);case aw:case lw:return new t(+n);case yw:return Lf(n,e);case gw:case xw:case vw:case bw:case Sw:case ww:case _w:case Pw:case Tw:return Vf(n,e);case cw:return new t;case uw:case fw:return new t(n);case dw:return Df(n);case pw:return new t;case mw:return Gf(n)}}var zf=Ow;function Aw(n){return typeof n.constructor=="function"&&!On(n)?pp(Bn(n)):{}}var jf=Aw;var Cw="[object Map]";function Nw(n){return mt(n)&&Kr(n)==Cw}var Ff=Nw;var kf=Yr&&Yr.isMap,Iw=kf?Cn(kf):Ff,Uf=Iw;var Mw="[object Set]";function Ew(n){return mt(n)&&Kr(n)==Mw}var Hf=Ew;var Wf=Yr&&Yr.isSet,Lw=Wf?Cn(Wf):Hf,qf=Lw;var Dw=1,Bw=2,Rw=4,$f="[object Arguments]",Gw="[object Array]",Vw="[object Boolean]",zw="[object Date]",jw="[object Error]",Yf="[object Function]",Fw="[object GeneratorFunction]",kw="[object Map]",Uw="[object Number]",Xf="[object Object]",Hw="[object RegExp]",Ww="[object Set]",qw="[object String]",$w="[object Symbol]",Yw="[object WeakMap]",Xw="[object ArrayBuffer]",Kw="[object DataView]",Zw="[object Float32Array]",Qw="[object Float64Array]",Jw="[object Int8Array]",e1="[object Int16Array]",t1="[object Int32Array]",r1="[object Uint8Array]",o1="[object Uint8ClampedArray]",n1="[object Uint16Array]",i1="[object Uint32Array]",Ge={};Ge[$f]=Ge[Gw]=Ge[Xw]=Ge[Kw]=Ge[Vw]=Ge[zw]=Ge[Zw]=Ge[Qw]=Ge[Jw]=Ge[e1]=Ge[t1]=Ge[kw]=Ge[Uw]=Ge[Xf]=Ge[Hw]=Ge[Ww]=Ge[qw]=Ge[$w]=Ge[r1]=Ge[o1]=Ge[n1]=Ge[i1]=!0;Ge[jw]=Ge[Yf]=Ge[Yw]=!1;function Na(n,r,e,t,o,i){var s,a=r&Dw,c=r&Bw,d=r&Rw;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!Ut(n))return n;var l=He(n);if(l){if(s=Ef(n),!a)return mp(n,s)}else{var u=Kr(n),p=u==Yf||u==Fw;if(Fo(n))return wf(n,a);if(u==Xf||u==$f||p&&!o){if(s=c||p?{}:jf(n),!a)return c?Of(n,gf(s,n)):Tf(n,yf(s,n))}else{if(!Ge[u])return o?n:{};s=zf(n,u,a)}}i||(i=new Gn);var f=i.get(n);if(f)return f;i.set(n,s),qf(n)?n.forEach(function(y){s.add(Na(y,r,e,y,n,i))}):Uf(n)&&n.forEach(function(y,g){s.set(g,Na(y,r,e,g,n,i))});var m=d?c?Ta:cs:c?In:Nn,h=l?void 0:m(n);return vp(h||n,function(y,g){h&&(g=y,y=n[g]),Pn(s,g,Na(y,r,e,g,n,i))}),s}var Ia=Na;var s1=1,a1=4;function l1(n){return Ia(n,s1|a1)}var Zr=l1;var c1="__lodash_hash_undefined__";function u1(n){return this.__data__.set(n,c1),this}var Kf=u1;function d1(n){return this.__data__.has(n)}var Zf=d1;function Ma(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new ko;++r<e;)this.add(n[r])}Ma.prototype.add=Ma.prototype.push=Kf;Ma.prototype.has=Zf;var Qf=Ma;function p1(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 Jf=p1;function f1(n,r){return n.has(r)}var em=f1;var m1=1,h1=2;function y1(n,r,e,t,o,i){var s=e&m1,a=n.length,c=r.length;if(a!=c&&!(s&&c>a))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var u=-1,p=!0,f=e&h1?new Qf:void 0;for(i.set(n,r),i.set(r,n);++u<a;){var m=n[u],h=r[u];if(t)var y=s?t(h,m,u,r,n,i):t(m,h,u,n,r,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Jf(r,function(g,x){if(!em(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 Ea=y1;function g1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var tm=g1;function x1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var rm=x1;var v1=1,b1=2,S1="[object Boolean]",w1="[object Date]",_1="[object Error]",P1="[object Map]",T1="[object Number]",O1="[object RegExp]",A1="[object Set]",C1="[object String]",N1="[object Symbol]",I1="[object ArrayBuffer]",M1="[object DataView]",om=it?it.prototype:void 0,Ac=om?om.valueOf:void 0;function E1(n,r,e,t,o,i,s){switch(e){case M1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case I1:return!(n.byteLength!=r.byteLength||!i(new zn(n),new zn(r)));case S1:case w1:case T1:return _n(+n,+r);case _1:return n.name==r.name&&n.message==r.message;case O1:case C1:return n==r+"";case P1:var a=tm;case A1:var c=t&v1;if(a||(a=rm),n.size!=r.size&&!c)return!1;var d=s.get(n);if(d)return d==r;t|=b1,s.set(n,r);var l=Ea(a(n),a(r),t,o,i,s);return s.delete(n),l;case N1:if(Ac)return Ac.call(n)==Ac.call(r)}return!1}var nm=E1;var L1=1,D1=Object.prototype,B1=D1.hasOwnProperty;function R1(n,r,e,t,o,i){var s=e&L1,a=cs(n),c=a.length,d=cs(r),l=d.length;if(c!=l&&!s)return!1;for(var u=c;u--;){var p=a[u];if(!(s?p in r:B1.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=s;++u<c;){p=a[u];var g=n[p],x=r[p];if(t)var S=s?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 im=R1;var G1=1,sm="[object Arguments]",am="[object Array]",La="[object Object]",V1=Object.prototype,lm=V1.hasOwnProperty;function z1(n,r,e,t,o,i){var s=He(n),a=He(r),c=s?am:Kr(n),d=a?am:Kr(r);c=c==sm?La:c,d=d==sm?La:d;var l=c==La,u=d==La,p=c==d;if(p&&Fo(n)){if(!Fo(r))return!1;s=!0,l=!1}if(p&&!l)return i||(i=new Gn),s||ga(n)?Ea(n,r,e,t,o,i):nm(n,r,c,e,t,o,i);if(!(e&G1)){var f=l&&lm.call(n,"__wrapped__"),m=u&&lm.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Gn),o(h,y,e,t,i)}}return p?(i||(i=new Gn),im(n,r,e,t,o,i)):!1}var cm=z1;function um(n,r,e,t,o){return n===r?!0:n==null||r==null||!mt(n)&&!mt(r)?n!==n&&r!==r:cm(n,r,e,t,um,o)}var dm=um;function j1(n,r){return n!=null&&r in Object(n)}var pm=j1;function F1(n,r,e){r=Xt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=yo(r[t]);if(!(i=n!=null&&e(n,s)))break;n=n[s]}return i||++t!=o?i:(o=n==null?0:n.length,!!o&&Tn(o)&&wn(s,o)&&(He(n)||An(n)))}var fm=F1;function k1(n,r){return n!=null&&fm(n,r,pm)}var mm=k1;function U1(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var hm=U1;function H1(n,r){return r.length<2?n:ba(n,uf(r,0,-1))}var ym=H1;function W1(n,r){return dm(n,r)}var us=W1;function q1(n,r){return r=Xt(r,n),n=ym(n,r),n==null||delete n[yo(hm(r))]}var gm=q1;function $1(n){return cf(n)?void 0:n}var xm=$1;var Y1=1,X1=2,K1=4,Z1=Sa(function(n,r){var e={};if(n==null)return e;var t=!1;r=da(r,function(i){return i=Xt(i,n),t||(t=i.length>1),i}),br(n,Ta(n),e),t&&(e=Ia(e,Y1|X1|K1,xm));for(var o=r.length;o--;)gm(e,r[o]);return e}),Fn=Z1;function Q1(n,r,e,t){if(!Ut(n))return n;r=Xt(r,n);for(var o=-1,i=r.length,s=i-1,a=n;a!=null&&++o<i;){var c=yo(r[o]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var l=a[c];d=t?t(l,c,a):void 0,d===void 0&&(d=Ut(l)?l:wn(r[o+1])?[]:{})}Pn(a,c,d),a=a[c]}return n}var vm=Q1;function J1(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],a=ba(n,s);e(a,s)&&vm(i,Xt(s,n),a)}return i}var bm=J1;function e_(n,r){return bm(n,r,function(e,t){return mm(n,t)})}var Sm=e_;var t_=Sa(function(n,r){return n==null?{}:Sm(n,r)}),nr=t_;var Be=class{modifyById(r,e){let t=this;if(t[r]===void 0)throw new Error("not expected");{let i={...t,[r]:e};return Object.setPrototypeOf(i,Be.prototype),i}}add(r,e){return this.runOp({type:1,id:r,data:e})?.data??this}runOp(r){let e=this;if(r.type===1){let t=e[r.id],o;t===void 0?o={type:2,id:r.id}:o={type:1,id:r.id,data:t};let{id:i,data:s}=r,a={...e,[i]:s};return Object.setPrototypeOf(a,Be.prototype),{data:a,actual:r,reverse:o}}else if(r.type===2){let{id:t}=r,o=e[t];if(o===void 0)return null;{let i={...e};return Object.setPrototypeOf(i,Be.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function ds(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"&&ds(t)}return Object.freeze(n)}function wm(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 kn=class extends Error{};function Da(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Sr(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 s=n+(r-n)*(i+.75+Math.random()*.5)*o;t.push(s)}return t}function Un(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 _m(){return typeof process<"u"}function Pm(n,r){for(let e of n)r(e.id,e.data)!==!0&&Pm(e.children,r)}function Tm(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Tm(e,r)}var Fe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Fe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ds(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&&Tm(o,t)}}traverse(e){Pm(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let i=this.parent(e),s=this.childrenArray(i),a=s.findIndex(l=>l.id===e);if(a<0)throw new Error("not expected");let c=s[a];return s=[...s],s[a]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let a=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let d=i.findIndex(l=>l.id===c);if(d<0)throw new Error;i=[...i],i[d]={...i[d],children:a}}Object.setPrototypeOf(i,Fe.prototype);let s=i;return s.fillCaches(),s}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:s,children:a}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,d=this.childrenArray(c),l={fi:o,id:i,data:s,children:a};return d=[...d,l],d.sort((p,f)=>p.fi-f.fi),e.localIndex=d.indexOf(l),{data:this.modifyArrayBy(c,d),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),s=i.findIndex(d=>d.id===t);e.localIndex=s,i=[...i];let a=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...a,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 kn("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let a=s,c=this.childrenArray(s),d=c.findIndex(f=>f.id===i);c=[...c];let l=c.splice(d,1)[0],u=this.modifyArrayBy(s,c);s=t,c=u.childrenArray(s);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),u=u.modifyArrayBy(s,c),{data:u,actual:e,reverse:{type:9,parent:a,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(s=>s.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(s=>s.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)=>wm(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),s=i;if(i!==void 0){for(;t;)o.splice(0,0,i.fi),t=this.parent(t),t!==null&&(i=this.get(t));return{...s,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 Sr(0,o,o);{let s=i[0].fi;return Sr(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let a=i.find(c=>c.fi>s.fi);if(a===void 0){let c=i[i.length-1].fi;return Sr(c,c+o,o)}else return Sr(s.fi,a.fi,o)}}};var Hn;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],a=!1;if(o)for(let c of Object.keys(o)){let d=parseInt(c);if(isNaN(d))throw new Error("wrong index");i[c]=s[d],s[d]=o[c],a=!0}return a?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},a=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let d=o[c];d===void 0?delete s[c]:s[c]=d,a=!0}return a?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Hn||(Hn={}));var ye=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ye.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ds(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,s=i.findIndex(d=>d.id===e);if(s<0)throw new Error("not expected");let a=i[s];return i=[...i],i[s]={...a,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ye.prototype);let t=e;return _m()||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,s=this,a={fi:t,id:o,data:i};return s=[...s,a],s.sort((d,l)=>d.fi-l.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),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 s=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...s}}}moveOp(e){let{fi:t,id:o}=e,i=this;i=[...i];let s=i.findIndex(l=>l.id===o);if(s===-1)return null;let a=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((l,u)=>l.fi-u.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:a,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 Sr(0,t,t);{let i=o[0].fi;return Sr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(a=>a.fi>i.fi);if(s===void 0){let a=o[o.length-1].fi;return Sr(a,a+t,t)}else return Sr(i.fi,s.fi,t)}}};function Wn(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&&!Wn(t))return null;o+=1}t=t?Da(t):new Re;for(let[c,d]of Object.entries(r.props)){let l=t[c];i[c]=l,d===void 0?delete t[c]:t[c]=d}for(;o>0;){if(Object.keys(t).length===0){let c=e[o-1];c&&(t=Da(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let d=Da(c);d[r.path[o-1]]=t,t=d}else{let d=new Re;d[r.path[o-1]]=t,t=d}}o-=1}let s=Object.setPrototypeOf(t,Re.prototype),a={...r,props:i};return{data:s,actual:r,reverse:a}}},wr;(t=>{function n(o,i){return ps(o,i)??o}t.apply=n;function r(o,i){return Nc(o,i)}t.merge=r;function e(o,i){let s=0,a=i.path,c=o;for(;s<a.length&&c!==void 0;){if(c=Tt.zoomOnce(c,a[s]),c===void 0)return i;if(!Wn(c))return;s+=1}if(c===void 0)return i;if(!!Wn(c))if(i.type===0){let d={...i.props};for(let l of Object.keys(c))delete d[l];return{...i,props:d}}else if(i.type===1||i.type===4||i.type===7){let d=Cc([i],c);return d?(console.log(d),d):i}else return i}t.filterOp=e})(wr||(wr={}));function Cc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=ps(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let a=Cc(o.children,r);return a!==void 0?e=!0:a=o.children,{...o,id:i,data:s,children:a}}else return{...o,id:i,data:s}});if(e)return t}function r_(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=ps(o.data,r[i]);return e=e||s!==void 0,s===void 0&&(s=o.data),{...o,id:i,data:s}});if(e)return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function ps(n,r){if(!Wn(r))return r;if(n instanceof Fe){let e=Cc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ye)return r_(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=ps(o,r[i]);return e=e||s!==void 0,s===void 0&&(s=o),s});return e?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else{if(n instanceof Re)return Nc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=ps(i,r[o]);t=t||s!==void 0,s===void 0&&(s=i),e[o]=s}return t?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Nc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Wn(r))return r;if(!Wn(n))return wr.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=Nc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Om(n,r){let e={cur:[],result:[],len:0};return n=fs(n,r,e)??n,[n,e.result]}function Ba(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Ra(n){n&&(n.len-=1)}function o_(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Am(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,a=r[s];if(a!==void 0&&typeof a=="string"&&(t=!0,s=a,e!==null))throw new Error("not supported");let c=fs(i.data,r,Ba(e,s));Ra(e),t=t||c!==void 0,c===void 0&&(c=i.data);let d=Am(i.children,r,e);return d!==void 0?t=!0:d=i.children,{...i,id:s,data:c,children:d}});if(t)return o}function n_(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,a=r[s];if(a!==void 0&&typeof a=="string"&&(t=!0,s=a,e!==null))throw new Error("not supported");let c=fs(i.data,r,Ba(e,s));return Ra(e),t=t||c!==void 0,c===void 0&&(c=i.data),{...i,id:s,data:c}});if(t)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function fs(n,r,e){if(n instanceof Fe){let t=Am(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ye)return n_(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let a=fs(i,r,Ba(e,s));return Ra(e),t=t||a!==void 0,a===void 0&&(a=i),a});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!Un(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let a=r[i];if(typeof a=="string"){if(e!==null)throw new Error("not supported");o=!0,i=a}let c=fs(s,r,Ba(e,i));Ra(e),o=o||c!==void 0,c===void 0&&(c=s),t[i]=c}else t[i]=s;return o?(Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t):void 0}else if(typeof n=="string"){let t=r[n];if(t!==void 0){if(n.length!==36)throw new Error("for now you should only call this method when the key is a uuid");o_(e)}return t}else return}}var Ga;(r=>{function n(e,t){let o=Tt.zoom(t,e.path);if(typeof o=="object"){let i={};for(let s of Object.keys(e.props))i[s]=o[s];return{...e,props:i}}else return{...e,props:{}}}r.replaceProps=n})(Ga||(Ga={}));var ht;(a=>{function n(c,d){return{...c,path:c.path.slice(d)}}a.drop=n;function r(c,d){return e(c,d)?.data??c}a.applySimple=r;function e(c,d){let l=d.path;for(var u=[];;){let p;if(c instanceof Re&&d.type===0&&(p=c.runOp({...d,path:l.slice(u.length)}),p===null&&(p=void 0)),p===void 0&&u.length===l.length&&(c instanceof Fe||c instanceof ye||c instanceof Be?p=c.runOp(d):p=Hn.runOp(c,d)),p!==void 0)if(p!==null){let h=p.data;for(let y=u.length-1;y>=0;y--){let g=l[y],x=u[y];if(x instanceof Fe){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof ye){if(typeof g=="number")throw new Error("illegal arg");h=x.modifyById(g,h)}else if(x instanceof Be){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[u.length],m;if(c instanceof Fe){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else if(c instanceof ye){if(typeof f=="number")throw new Error("");m=c.get(f)?.data}else c!==null&&(m=c[f]);if(m!==void 0)u.push(c),c=m;else return null}}a.apply=e;function t(c,d){for(let l=0;l<c.length&&l<d.length;l++)if(c[l]!==d[l])return!0;return!1}a.pathDisjoint=t;function o(c,d){if(c.length!==d.length)return!1;for(let l=0;l<c.length;l++)if(c[l]!==d[l])return!1;return!0}a.pathEq=o;function i(c,d){return t(c.path,d.path)}a.commutative=i;function s(c,d){return c.type===0&&d.type===0&&o(c.path,d.path)?Object.keys(c.props).every(l=>d.props[l]!==void 0):!1}a.subsumed=s})(ht||(ht={}));var Ic;(c=>{function n(){return[]}c.empty=n;function r(d,l){let u=[];for(let p of d){let[f,...m]=p.path;f===l&&u.push({...p,path:m})}return u}c.removePrefix=r;function e(d,l){return d.map(u=>({...u,path:[l,...u.path]}))}c.addPrefix=e;function t(d,l){return[...d,...l]}c.concat=t;function o(d,l){return[...d.filter(p=>!l.some(f=>ht.subsumed(p,f))),...l]}c.compress=o;function i(d,l){return d.every(u=>l.every(p=>ht.commutative(u,p)))}c.commutative=i;function s(d,l){for(let u of l){let p=a(d,u);p!==null&&(d=p.data)}return d}c.applyAll=s;function a(d,l){var u=d;let p=[],f=[];for(let m of l)try{if(m.type===3){let h=Tt.zoom(u,[...m.path,m.id]),y=ht.apply(u,{...m,type:2});if(y!==null){u=y.data;let[g,x]=Om(u,{[m.id]:h});u=g;for(let S of x){let w=S[S.length-1];S.splice(S.length-1,1),p.push({type:0,path:S,props:{[w]:h}}),f.push({type:0,path:S,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=ht.apply(u,m);h!==null&&(p.push(h.actual),u=h.data,f.push(h.reverse))}}catch(h){if(h instanceof kn)return null;throw h}return{data:u,actual:p,reverse:f.reverse()}}c.apply=a})(Ic||(Ic={}));var Cm=Symbol(),i_=Symbol(),za=Symbol(),Ho=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Va);){let s=o._path,a=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,a)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[za];t&&t(),delete this._children[r]}}}},Ec=class extends Ho{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,Hn.runOp(this._current,r),r.path)}},Lc=class extends Ho{constructor(r,e,t){super(),this._parent=r,this._path=e,this._current=t}update(r,e){this._current={...this._current,[r]:e},Object.setPrototypeOf(this._current,Be.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Nm={get(n,r){if(r===za)return()=>{n._parent=null};if(r===Cm)return n._current;if(r===i_)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],s=ja(n,r,i);return s!==i?(t===void 0&&(t={},n._children=t),t[r]=s,s):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]}}},s_={...Nm,set(n,r,e){let t={type:0,props:{[r]:Ze(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}},a_={...Nm,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 Ho{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[za]=()=>{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,s=ja(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):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 s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}insertBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(r,o[i],s.id,s.data,s.children)}}moveAfter(r,e,t){let o=this._current.insertAfterHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}moveBefore(r,e,t){let o=this._current.insertBeforeHelper(r,e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(r,o[i],s)}}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)}},$n=class extends Ho{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[za]=()=>{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,s=ja(this,r,i);return s!==i?(t===void 0&&(t={},this._children=t),t[r]=s,s):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 Mc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Tt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Va=class extends Ho{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){Mc(this.ts,e,r),Mc(this.actual,t,r),Mc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ja(n,r,e){return e instanceof Fe?new qn(n,r,e):e instanceof ye?new $n(n,r,e):e instanceof Be?new Proxy(new Lc(n,r,e),a_):e!==null&&typeof e=="object"?Un(e)?e:new Proxy(new Ec(n,r,e),s_):e}function Dc(n){let r=new Va(n);return[ja(r,"",n),r]}function Yn(n,r){let[e,t]=Dc(n);return r(e),t.result()}function Ze(n){return n instanceof qn||n instanceof $n?n._current:n!==null&&typeof n=="object"?n[Cm]:n}var Tt;(o=>{function n(i,s){if(s.length===i.length)for(var a=0;a<i.length;){if(i[a]!==s[a])return!1;a+=1}else return!1;return!0}o.equal=n;function r(i,s,a){let c=t(a,i);if(c!==void 0&&typeof c=="object"&&c!==null){let d={...s};return Object.keys(c).forEach(l=>{delete d[l]}),d}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof Fe||i instanceof qn)&&typeof s=="string")return i.data(s);if((i instanceof ye||i instanceof $n)&&typeof s=="string")return i.data(s);if(typeof s=="number"&&Array.isArray(i))return i[s];if(typeof s=="string"&&typeof i=="object"&&i!==null)return i[s]}o.zoomOnce=e;function t(i,s,a=0){for(;a<s.length&&i!==void 0;)i=e(i,s[a]),a+=1;return i}o.zoom=t})(Tt||(Tt={}));function Im(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 Fa=class{},ms=class extends Fa{constructor(e){super();this.id=e}},hs=class extends Fa{constructor(e){super();this.data=e}};var Rc;try{Rc=new TextDecoder}catch{}var re,xo,I=0;var Vm=[],Gc=Vm,Vc=0,Bt={},Ne,go,Kt=0,_r=0,Ht,Qr,Ot=[],Me,Mm={useRecords:!1,mapsAsObjects:!0},ys=class{},jc=new ys;jc.name="MessagePack 0xC1";var Xn=!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 Um(()=>(Ua(),this?this.unpack(r,e):Pr.prototype.unpack.call(Mm,r,e)));xo=e>-1?e:r.length,I=0,Vc=0,_r=0,go=null,Gc=Vm,Ht=null,re=r;try{Me=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(Bt=this,this.structures)return Ne=this.structures,ka();(!Ne||Ne.length>0)&&(Ne=[])}else Bt=Mm,(!Ne||Ne.length>0)&&(Ne=[]);return ka()}unpackMultiple(r,e){let t,o=0;try{Xn=!0;let i=r.length,s=this?this.unpack(r,i):qa.unpack(r,i);if(e){for(e(s);I<i;)if(o=I,e(ka())===!1)return}else{for(t=[s];I<i;)o=I,t.push(ka());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{Xn=!1,Ua()}}_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 ka(){try{if(!Bt.trusted&&!Xn){let r=Ne.sharedLength||0;r<Ne.length&&(Ne.length=r)}let n=We();if(I==xo)Ne.restoreStructures&&Em(),Ne=null,re=null,Qr&&(Qr=null);else if(I>xo){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!Xn)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ne.restoreStructures&&Em(),Ua(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Em(){for(let n in Ne.restoreStructures)Ne[n]=Ne.restoreStructures[n];Ne.restoreStructures=null}function We(){let n=re[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Ne[n&63]||Bt.getStructures&&zm()[n&63];return r?(r.read||(r.read=Fc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Bt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Fm()]=We();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(We(),We());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=We();return r}else if(n<192){let r=n-160;if(_r>=I)return go.slice(I-Kt,(I+=r)-Kt);if(_r==0&&xo<140){let e=r<16?kc(r):jm(r);if(e!=null)return e}return zc(r)}else{let r;switch(n){case 192:return null;case 193:return Ht?(r=We(),r>0?Ht[1].slice(Ht.position1,Ht.position1+=r):Ht[0].slice(Ht.position0,Ht.position0-=r)):jc;case 194:return!1;case 195:return!0;case 196:return Bc(re[I++]);case 197:return r=Me.getUint16(I),I+=2,Bc(r);case 198:return r=Me.getUint32(I),I+=4,Bc(r);case 199:return Wo(re[I++]);case 200:return r=Me.getUint16(I),I+=2,Wo(r);case 201:return r=Me.getUint32(I),I+=4,Wo(r);case 202:if(r=Me.getFloat32(I),Bt.useFloat32>2){let e=Wa[(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=Me.getFloat64(I),I+=8,r;case 204:return re[I++];case 205:return r=Me.getUint16(I),I+=2,r;case 206:return r=Me.getUint32(I),I+=4,r;case 207:return Bt.int64AsNumber?(r=Me.getUint32(I)*4294967296,r+=Me.getUint32(I+4)):r=Me.getBigUint64(I),I+=8,r;case 208:return Me.getInt8(I++);case 209:return r=Me.getInt16(I),I+=2,r;case 210:return r=Me.getInt32(I),I+=4,r;case 211:return Bt.int64AsNumber?(r=Me.getInt32(I)*4294967296,r+=Me.getUint32(I+4)):r=Me.getBigInt64(I),I+=8,r;case 212:if(r=re[I++],r==114)return Gm(re[I++]&63);{let e=Ot[r];if(e)return e.read?(I++,e.read(We())):e.noBuffer?(I++,e()):e(re.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=re[I],r==114?(I++,Gm(re[I++]&63,re[I++])):Wo(2);case 214:return Wo(4);case 215:return Wo(8);case 216:return Wo(16);case 217:return r=re[I++],_r>=I?go.slice(I-Kt,(I+=r)-Kt):c_(r);case 218:return r=Me.getUint16(I),I+=2,_r>=I?go.slice(I-Kt,(I+=r)-Kt):u_(r);case 219:return r=Me.getUint32(I),I+=4,_r>=I?go.slice(I-Kt,(I+=r)-Kt):d_(r);case 220:return r=Me.getUint16(I),I+=2,Dm(r);case 221:return r=Me.getUint32(I),I+=4,Dm(r);case 222:return r=Me.getUint16(I),I+=2,Bm(r);case 223:return r=Me.getUint32(I),I+=4,Bm(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 l_=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Fc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>l_.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(We);return n.highByte===0&&(n.read=Lm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=We()}return t}return e.count=0,n.highByte===0?Lm(r,e):e}var Lm=(n,r)=>function(){let e=re[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ne[t]||zm()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Fc(o,n)),o.read()};function zm(){let n=Um(()=>(re=null,Bt.getStructures()));return Ne=Bt._mergeStructures(n,Ne)}var zc=Ha,c_=Ha,u_=Ha,d_=Ha;function Ha(n){let r;if(n<16&&(r=kc(n)))return r;if(n>64&&Rc)return Rc.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,s=re[I++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=re[I++]&63,s=re[I++]&63,a=re[I++]&63,c=(o&7)<<18|i<<12|s<<6|a;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+=st.apply(String,t),t.length=0)}return t.length>0&&(r+=st.apply(String,t)),r}function Dm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=We();return r}function Bm(n){if(Bt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Fm()]=We();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(We(),We());return r}}var st=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 st.apply(String,e)}function kc(n){if(n<4)if(n<2){if(n===0)return"";{let r=re[I++];if((r&128)>1){I-=1;return}return st(r)}}else{let r=re[I++],e=re[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return st(r,e);let t=re[I++];if((t&128)>0){I-=3;return}return st(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 st(r,e,t,o);{let i=re[I++];if((i&128)>0){I-=5;return}return st(r,e,t,o,i)}}else if(n<8){let i=re[I++],s=re[I++];if((i&128)>0||(s&128)>0){I-=6;return}if(n<7)return st(r,e,t,o,i,s);let a=re[I++];if((a&128)>0){I-=7;return}return st(r,e,t,o,i,s,a)}else{let i=re[I++],s=re[I++],a=re[I++],c=re[I++];if((i&128)>0||(s&128)>0||(a&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return st(r,e,t,o,i,s,a,c);{let d=re[I++];if((d&128)>0){I-=9;return}return st(r,e,t,o,i,s,a,c,d)}}else if(n<12){let d=re[I++],l=re[I++];if((d&128)>0||(l&128)>0){I-=10;return}if(n<11)return st(r,e,t,o,i,s,a,c,d,l);let u=re[I++];if((u&128)>0){I-=11;return}return st(r,e,t,o,i,s,a,c,d,l,u)}else{let d=re[I++],l=re[I++],u=re[I++],p=re[I++];if((d&128)>0||(l&128)>0||(u&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return st(r,e,t,o,i,s,a,c,d,l,u,p);{let f=re[I++];if((f&128)>0){I-=13;return}return st(r,e,t,o,i,s,a,c,d,l,u,p,f)}}else{let f=re[I++],m=re[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return st(r,e,t,o,i,s,a,c,d,l,u,p,f,m);let h=re[I++];if((h&128)>0){I-=15;return}return st(r,e,t,o,i,s,a,c,d,l,u,p,f,m,h)}}}}}function Bc(n){return Bt.copyBuffers?Uint8Array.prototype.slice.call(re,I,I+=n):re.subarray(I,I+=n)}function Wo(n){let r=re[I++];if(Ot[r])return Ot[r](re.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var Rm=new Array(4096);function Fm(){let n=re[I++];if(n>=160&&n<192){if(n=n-160,_r>=I)return go.slice(I-Kt,(I+=n)-Kt);if(!(_r==0&&xo<180))return zc(n)}else return I--,We();let r=(n<<5^(n>1?Me.getUint16(I):n>0?re[I]:0))&4095,e=Rm[r],t=I,o=I+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Me.getUint32(t),i!=e[s++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=re[t++],i!=e[s++]){t=1879048192;break}if(t===o)return I=t,e.string;o-=3,t=I}for(e=[],Rm[r]=e,e.bytes=n;t<o;)i=Me.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=re[t++],e.push(i);let a=n<16?kc(n):jm(n);return a!=null?e.string=a:e.string=zc(n)}var Gm=(n,r)=>{var e=We();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Ne[n];return o&&o.isShared&&((Ne.restoreStructures||(Ne.restoreStructures=[]))[n]=o),Ne[n]=e,e.read=Fc(e,t),e.read()},km=typeof self=="object"?self:global;Ot[0]=()=>{};Ot[0].noBuffer=!0;Ot[101]=()=>{let n=We();return(km[n[0]]||Error)(n[1])};Ot[105]=n=>{let r=Me.getUint32(I-4);Qr||(Qr=new Map);let e=re[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};Qr.set(r,o);let i=We();return o.used?Object.assign(t,i):(o.target=i,i)};Ot[112]=n=>{let r=Me.getUint32(I-4),e=Qr.get(r);return e.used=!0,e.target};Ot[115]=()=>new Set(We());var Uc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Ot[116]=n=>{let r=n[0],e=Uc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new km[e](Uint8Array.prototype.slice.call(n,1).buffer)};Ot[120]=()=>{let n=We();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,Ht=[We(),We()],Ht.position0=0,Ht.position1=0;let t=I;I=e;try{return We()}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 Um(n){let r=xo,e=I,t=Vc,o=Kt,i=_r,s=go,a=Gc,c=Qr,d=Ht,l=new Uint8Array(re.slice(0,xo)),u=Ne,p=Ne.slice(0,Ne.length),f=Bt,m=Xn,h=n();return xo=r,I=e,Vc=t,Kt=o,_r=i,go=s,Gc=a,Qr=c,Ht=d,re=l,Xn=m,Ne=u,Ne.splice(0,Ne.length,...p),Bt=f,Me=new DataView(re.buffer,re.byteOffset,re.byteLength),h}function Ua(){re=null,Qr=null,Ne=null}function Hm(n){n.unpack?Ot[n.type]=n.unpack:Ot[n.type]=n}var Wa=new Array(147);for(let n=0;n<256;n++)Wa[n]=+("1e"+Math.floor(45.15-n*.30103));var qa=new Pr({useRecords:!1}),p_=qa.unpack,f_=qa.unpackMultiple,m_=qa.unpack,$a={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},h_=new Float32Array(1),RR=new Uint8Array(h_.buffer,0,4);var Ya;try{Ya=new TextEncoder}catch{}var Xa,Wc,Ka=typeof Buffer<"u",Hc=Ka?Buffer.allocUnsafeSlow:Uint8Array,Ym=Ka?Buffer:Uint8Array,Wm=Ka?4294967296:2144337920,G,Ye,E=0,Tr,Or=null,y_=/[\u0080-\uFFFF]/,gs=Symbol("record-id"),qo=class extends Pr{constructor(r){super(r),this.offset=0;let e,t,o,i,s,a,c=0,d=Ym.prototype.utf8Write?function(v,N,T){return G.utf8Write(v,N,T)}:Ya&&Ya.encodeInto?function(v,N){return Ya.encodeInto(v,G.subarray(N)).written}:!1,l=this;r||(r={});let u=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),u&&!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 Hc(8192),Ye=new DataView(G.buffer,0,8192),E=0),Tr=G.length-10,Tr-E<2048?(G=new Hc(G.length),Ye=new DataView(G.buffer,0,G.length),Tr=G.length-10,E=0):E=E+7&2147483640,t=E,a=l.structuredClone?new Map:null,l.bundleStrings?(Or=["",""],G[E++]=214,G[E++]=98,Or.position=E-t,E+=4):Or=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let T=o.sharedLength||0;if(T>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<T;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[gs]=C+64}c=T}u||(o.nextId=T+64)}i&&(i=!1),s=o||[];try{if(b(v),Or){Ye.setUint32(Or.position+t,E-Or.position-t);let T=Or;Or=null,b(T[0]),b(T[1])}if(l.offset=E,a&&a.idsToInsert){E+=a.idsToInsert.length*6,E>Tr&&P(E),l.offset=E;let T=x_(G.subarray(t,E),a.idsToInsert);return a=null,T}return N&Km?(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&&!u){for(let T=0,C=x.length;T<C;T++)x[T][gs]=0;x=[]}if(i&&l.saveStructures){let T=o.sharedLength||f;o.length>T&&(o=o.slice(0,T));let C=G.subarray(t,E);return l.saveStructures(o,c)===!1?(l._mergeStructures(l.getStructures()),l.pack(v)):(c=T,C)}}N&T_&&(E=t)}};let b=v=>{E>Tr&&(G=P(E));var N=typeof v,T;if(N==="string"){let C=v.length;if(Or&&C>=8&&C<4096){let M=y_.test(v);Or[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>Tr&&(G=P(E+A)),C<64||!d){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);T=R-E-O}else T=d(v,E+O,A);T<32?G[E++]=160|T:T<256?(O<2&&G.copyWithin(E+2,E+1,E+1+T),G[E++]=217,G[E++]=T):T<65536?(O<3&&G.copyWithin(E+3,E+2,E+2+T),G[E++]=218,G[E++]=T>>8,G[E++]=T&255):(O<5&&G.copyWithin(E+5,E+3,E+3+T),G[E++]=219,Ye.setUint32(E,T),E+=4),E+=T}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,Ye.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,Ye.setInt16(E,v),E+=2):(G[E++]=210,Ye.setInt32(E,v),E+=4);else{let C;if((C=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){G[E++]=202,Ye.setFloat32(E,v);let O;if(C<4||(O=v*Wa[(G[E]&127)<<1|G[E+1]>>7])>>0===O){E+=4;return}else E--}G[E++]=203,Ye.setFloat64(E,v),E+=8}else if(N==="object")if(!v)G[E++]=192;else{if(a){let O=a.get(v);if(O){if(!O.id){let A=a.idsToInsert||(a.idsToInsert=[]);O.id=A.push(O)}G[E++]=214,G[E++]=112,Ye.setUint32(E,O.id),E+=4;return}else a.set(v,{offset:E-t})}let C=v.constructor;if(C===Object)_(v,!0);else if(C===Array){T=v.length,T<16?G[E++]=144|T:T<65536?(G[E++]=220,G[E++]=T>>8,G[E++]=T&255):(G[E++]=221,Ye.setUint32(E,T),E+=4);for(let O=0;O<T;O++)b(v[O])}else if(C===Map){T=v.size,T<16?G[E++]=128|T:T<65536?(G[E++]=222,G[E++]=T>>8,G[E++]=T&255):(G[E++]=223,Ye.setUint32(E,T),E+=4);for(let[O,A]of v)b(O),b(A)}else{for(let O=0,A=Xa.length;O<A;O++){let M=Wc[O];if(v instanceof M){let L=Xa[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=Ye,Z=E;G=null;let z;try{z=L.pack.call(this,v,V=>(G=X,X=null,E+=V,E>Tr&&P(E),{target:G,targetView:Ye,position:E-V}),b)}finally{X&&(G=X,Ye=R,E=Z,Tr=G.length-10)}z&&(z.length+E>Tr&&P(z.length+E),E=g_(z,G,E,L.type));return}}_(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,Ye.setBigInt64(E,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)G[E++]=207,Ye.setBigUint64(E,v);else if(this.largeBigIntToFloat)G[E++]=203,Ye.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)},_=this.useRecords===!1?this.variableMapSize?v=>{let N=Object.keys(v),T=N.length;T<16?G[E++]=128|T:T<65536?(G[E++]=222,G[E++]=T>>8,G[E++]=T&255):(G[E++]=223,Ye.setUint32(E,T),E+=4);let C;for(let O=0;O<T;O++)b(C=N[O]),b(v[C])}:(v,N)=>{G[E++]=222;let T=E-t;E+=2;let C=0;for(let O in v)(N||v.hasOwnProperty(O))&&(b(O),b(v[O]),C++);G[T+++t]=C>>8,G[T+t]=C&255}:v=>{let N=Object.keys(v),T,C=s.transitions||(s.transitions=Object.create(null)),O=0;for(let M=0,L=N.length;M<L;M++){let X=N[M];T=C[X],T||(T=C[X]=Object.create(null),O++),C=T}let A=C[gs];if(A)A>=96&&h?(G[E++]=((A-=96)&31)+96,G[E++]=A>>5):G[E++]=A;else{A=s.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(A=s.nextOwnId,A<g||(A=y),s.nextOwnId=A+1):(A>=g&&(A=y),s.nextId=A+1);let M=N.highByte=A>=96&&h?A-96>>5:-1;C[gs]=A,s[A-64]=N,A<y?(N.isShared=!0,s.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()[gs]=0),x.push(C),b(N))}for(let M=0,L=N.length;M<L;M++)b(v[N[M]])},P=v=>{let N;if(v>16777216){if(v-t>Wm)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(Wm,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 T=new Hc(N);return Ye=new DataView(T.buffer,0,N),G.copy?G.copy(T,0,t,v):T.set(G.slice(t,v)),E-=t,t=0,Tr=T.length-10,G=T}}useBuffer(r){G=r,Ye=new DataView(G.buffer,G.byteOffset,G.byteLength),E=0}};Wc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ys];Xa=[{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:s}=r(6);o[s++]=214,o[s++]=255,i.setUint32(s,t)}else if(t>0&&t<17179869184){let{target:o,targetView:i,position:s}=r(10);o[s++]=215,o[s++]=255,i.setUint32(s,n.getMilliseconds()*4e6+(t/1e3/4294967296>>0)),i.setUint32(s+4,t)}else if(isNaN(t)){if(this.onInvalidDate)return r(0),e(this.onInvalidDate());let{target:o,targetView:i,position:s}=r(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:i,position:s}=r(15);o[s++]=199,o[s++]=12,o[s++]=255,i.setUint32(s,n.getMilliseconds()*1e6),i.setBigInt64(s+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?qm(n,16,r):$m(Ka?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==Ym&&this.structuredClone?qm(n,Uc.indexOf(e.name),r):$m(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function qm(n,r,e,t){let o=n.byteLength;if(o+1<256){var{target:i,position:s}=e(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=e(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:a}=e(7+o);i[s++]=201,a.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function $m(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 g_(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 x_(n,r){let e,t=r.length*6,o=n.length-t;for(r.sort((i,s)=>i.offset>s.offset?1:-1);e=r.pop();){let i=e.offset,s=e.id;n.copyWithin(i+t,i,o),t-=6;let a=i+t;n[a++]=214,n[a++]=105,n[a++]=s>>24,n[a++]=s>>16&255,n[a++]=s>>8&255,n[a++]=s&255,o=i}return n}function vo(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)");Wc.unshift(n.Class),Xa.unshift(n)}Hm(n)}var Xm=new qo({useRecords:!1}),v_=Xm.pack,b_=Xm.pack;var{NEVER:S_,ALWAYS:w_,DECIMAL_ROUND:__,DECIMAL_FIT:P_}=$a,Km=512,T_=1024;var Zm=new qo({structuredClone:!0});vo({Class:Be.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Be.prototype),n}});vo({Class:ye.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ye.prototype),n}});vo({Class:Fe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Fe.prototype),n}});vo({Class:ms.prototype.constructor,type:4,write(n){return n.id},read(n){return new ms(n)}});vo({Class:hs.prototype.constructor,type:5,write(n){return n.data},read(n){return new hs(n)}});vo({Class:Re.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});function O_(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 qc(n){if(Un(n))return n;if(Array.isArray(n))return n.map(qc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=qc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var Za;(t=>{function n(o){return Zm.pack(o)}t.serialize=n;function r(o){return Zm.unpack(o)}t.deserialize=r;function e(o){return O_(n(qc(o))).toString()}t.checksum=e})(Za||(Za={}));var wo="personal camera",_o="a218fcc3-276b-49b9-b485-49037fd14f5f",oh=2960946,et=5526619;var Qm;(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})(Qm||(Qm={}));var bo;(a=>{function n(c,d){return c[0]===d[0]&&c[1]===d[1]&&c[2]===d[2]}a.isEqual=n;function r(c,d){return[c[0]+d[0],c[1]+d[1],c[2]+d[2]]}a.add=r;function e(c,d){return[c[0]-d[0],c[1]-d[1],c[2]-d[2]]}a.sub=e;function t(c,d){return[c[0]/d[0],c[1]/d[1],c[2]/d[2]]}a.div=t;function o(c,d){return[c[0]*d[0],c[1]*d[1],c[2]*d[2]]}a.mul=o;function i(c,d){return Math.hypot(c[0]-d[0],c[1]-d[1],c[2]-d[2])}a.dist=i;function s(c,d,l){return[c[0]+(d[0]-c[0])*l,c[1]+(d[1]-c[1])*l,c[2]+(d[2]-c[2])*l]}a.lerp=s})(bo||(bo={}));var Jm;(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})(Jm||(Jm={}));var So;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function r(i,s){for(let a=0;a<16;a++)if(i[a]!==s[a])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let a=s.slice(0);for(var c=0,d=s.length;c<d;c+=3){let l=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];a[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/l,a[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/l,a[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/l}return a}o.applyMatrix4=t})(So||(So={}));var at;(l=>{function n(u){return typeof u=="object"&&typeof u.r=="number"&&typeof u.g=="number"&&typeof u.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(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}l.toRgb255a1=o;function i(u){return{r:u.r,g:u.g,b:u.b}}l.clone=i;function s(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}l.fromHex=s;function a(u){return Math.round(u.r*255)*65536+Math.round(u.g*255)*256+Math.round(u.b*255)}l.toHex=a;function c(u,p){return u.r===p.r&&u.g===p.g&&u.b===p.b}l.equals=c;function d(u,p,f){return{r:u.r+(p.r-u.r)*f,g:u.g+(p.g-u.g)*f,b:u.b+(p.b-u.b)*f}}l.lerp=d})(at||(at={}));var At;(a=>{a.white={...at.white,a:1},a.transparent={...at.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}a.from0to1=e;function t(c,d){return{...at.fromHex(c),a:d}}a.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}}a.toRgb255a1=o;function i(c,d){return at.equals(c,d)&&c.a===d.a}a.equals=i;function s(c,d,l){return{r:c.r+(d.r-c.r)*l,g:c.g+(d.g-c.g)*l,b:c.b+(d.b-c.b)*l,a:c.a+(d.a-c.a)*l}}a.lerp=s})(At||(At={}));var Qa;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(Qa||(Qa={}));var eh;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(eh||(eh={}));var th;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(th||(th={}));var rh;(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]))(rh||(rh={}));var ir;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(ir||(ir={}));var Po;(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})(Po||(Po={}));var Ar;(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(A_.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,a=o.radial;C_.forEach(c=>{Object.assign(i.radial,{[c]:a[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,a=o.linear;N_.forEach(c=>{Object.assign(i.linear,{[c]:a[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,a=o.grid;I_.forEach(c=>{Object.assign(i.grid,{[c]:a[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,a=o.toObject;M_.forEach(c=>{Object.assign(i.toObject,{[c]:a[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,a=o.randomnessObject;E_.forEach(c=>{Object.assign(i.randomnessObject,{[c]:a[c]??s[c]})})}return i}e.merge=r})(Ar||(Ar={}));var Ja;(t=>{t.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let r=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let s=[];o.count!==void 0&&s.push({type:0,path:i,props:{count:o.count}});for(let a of r){let c=o[a];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,a],props:c})}return s}t.toOps=e})(Ja||(Ja={}));var A_=["count"],C_=["radius","start","end","position","scale","rotation"],N_=["position","scale","rotation"],I_=["count","size"],M_=["count","position","scale","rotation"],E_=["strength","scale","rotation","position","movement","seed","freqScale"];var el;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(el||(el={}));var tl;(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")}})(tl||(tl={}));var To;(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]})(To||(To={}));var $c;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})($c||($c={}));var Yc;(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})(Yc||(Yc={}));var rl;(r=>r.defaultData={...Yc.defaultData,...$c.defaultData})(rl||(rl={}));var Kn;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Kn||(Kn={}));var nh;(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})(nh||(nh={}));function sh(n){return n.type!=="displace"}var ih;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(ih||(ih={}));var ah=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],lh=["wrapping","image","video","name"],Ct;(o=>{function n(i,s){let{texture:a,...c}=s;if(Object.assign(i,c),a){let d=i.texture;d&&Object.assign(d,a)}}o.patch=n;function r(i,s){return i==="light"&&s?e(s):t(i)}o.defaultData=r;function e(i){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function t(i){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Kn.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...s,type:"color",color:at.fromHex(et)};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...at.fromHex(6710886),a:1},colorB:{...at.fromHex(6710886),a:1},colorC:{...at.fromHex(16777215),a:1},colorD:{...at.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{...s,type:"fresnel",color:At.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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{...s,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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{...s,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{...s,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...at.fromHex(0),a:1},colorB:{...at.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 yt;(c=>{function n(d){return!d.layers.some(u=>u.data.type==="texture"&&u.data.projection!==0||u.data.type==="depth"&&!u.data.isWorldSpace||u.data.type==="noise"||u.data.type==="displace")}c.isMergable=n;function r(d){let l="";return d.layers.forEach(u=>{Object.entries(u.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 ye}}c.defaultEmptyData=e;function t(d="layer1",l="layer2"){return i("phong",d,l)}c.defaultData=t;function o(d,l){return{...d,name:l}}c.withName=o;function i(d,l="layer1",u="layer2"){let p=new ye;return p.push({fi:0,data:Ct.defaultData("light",d),id:l}),p.push({fi:1,data:Ct.defaultData("color"),id:u}),{layers:p}}c.defaultTwoLayerData=i;function s(d,l="phong",u="layer1",p="layer2"){let f=Ct.defaultData("texture");Object.assign(f.texture,{image:d});let m=new ye;return m.push({fi:0,data:f,id:u}),m.push({fi:1,data:Ct.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function a(d,l="phong",u="layer1",p="layer2"){let f=Ct.defaultData("video");Object.assign(f.texture,{video:d});let m=new ye;return m.push({fi:0,data:f,id:u}),m.push({fi:1,data:Ct.defaultData("light",l),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=a})(yt||(yt={}));var Zn;(r=>{function n(){return{points:new ye,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(Zn||(Zn={}));var Qn;(r=>{function n(){return{points:new ye,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(Qn||(Qn={}));var Xc={type:"Ellipse",width:100,height:100,spikes:16,angle:360,innerRadius:0};var ol;(r=>{function n(e,t){let o={...e};return L_.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(ol||(ol={}));var nl={shape:Xc,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},L_=["depth","offset","angle","twist","startScale","endScale"];var xs;(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})(xs||(xs={}));var il;(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,ol.merge(o.extrusion,t.extrusion))),o}r.merge=n})(il||(il={}));var Oo;(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:Qn.defaultData(),extrusion:nl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Zn.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:"",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:Math.PI};throw new Error("not implemented")}r.defaultData=n})(Oo||(Oo={}));var sl;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:at.white,near:.1,far:2e3})(sl||(sl={}));var al;(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}}})(al||(al={}));var Kc;(r=>r.defaultData={softShadowQuality:"low"})(Kc||(Kc={}));var Zc;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Zc||(Zc={}));var Qc;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Qc||(Qc={}));var vs;(r=>r.defaultData={usePhysics:!1,gravity:-10})(vs||(vs={}));var Jc;(r=>r.defaultData={playCamera:wo,gameControlObject:null})(Jc||(Jc={}));var ll;(r=>r.defaultData={backgroundColor:At.fromHexAndA(oh,1),postprocessing:al.defaultData,fog:sl.defaultData,globalPhysics:vs.defaultData,ambient:Zc.defaultData,ao:Qc.defaultData,shadow:Kc.defaultData,publish:Jc.defaultData})(ll||(ll={}));var ch;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(ch||(ch={}));var Jn;(o=>{o.identity={...Qa.identity,hiddenMatrix:So.identity};function r(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=r;function e(i,s){return{position:s?.position||i.position,rotation:s?.rotation||i.rotation,scale:s?.scale||i.scale,hiddenMatrix:s?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function t(i,s){return Kd({position:bo.isEqual(i.position,s.position)?void 0:s.position,rotation:bo.isEqual(i.rotation,s.rotation)?void 0:s.rotation,scale:bo.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:So.isEqual(i.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}o.diff=t})(Jn||(Jn={}));var gt;(r=>r.defaultData={states:new ye,events:new ye,visible:!0,raycastLock:!1,physics:To.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Jn.identity,cloner:null})(gt||(gt={}));var uh;(r=>r.defaultData={type:"Empty",...gt.defaultData})(uh||(uh={}));var dh;(r=>r.defaultData={type:"Component",...gt.defaultData})(dh||(dh={}));var $o;(r=>r.defaultData={type:"Mesh",...gt.defaultData,...rl.defaultData})($o||($o={}));var Yo;(r=>r.defaultData={...gt.defaultData,...Jn.identity,position:[0,0,Po.DefaultTargetOffset],...Po.defaultData})(Yo||(Yo={}));var cl;(e=>{function n(t){return{...gt.defaultData,...tl.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(cl||(cl={}));var ei;(e=>{function n(t,o,i=0){for(;i<o.length;){let s=t?t[o[i]]:void 0;if(o.length===i+1)return s;if(s)t=s.descendants,i+=1;else return}}e.resolveWithDes=n;function r(t,o,i=0){let s=n(t,o,i);if(s){let a=Object.keys(s);if(a.length===1&&a[0]==="descendants")return}return s}e.resolve=r})(ei||(ei={}));var Cr;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,a){return{...gt.defaultData,...a,component:s,overrides:new Re,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let a=Jn.fromObject(s.data);return t(s.id,a)}i.fromComponentData=o})(Cr||(Cr={}));var Jr;(r=>r.defaultData={type:"Page",...gt.defaultData,physics:{...To.defaultData,fusedBody:!1},...ll.defaultData,camera:Yo.defaultData})(Jr||(Jr={}));var ul;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:So.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:To.defaultData,states:new ye,events:new ye,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Po.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",...gt.defaultData,...$o.defaultData,geometry:Oo.defaultData("RectangleGeometry"),material:yt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...gt.defaultData,...$o.defaultData,geometry:Oo.defaultData("BooleanGeometry"),material:yt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...gt.defaultData,...$o.defaultData,geometry:Oo.defaultData("TextGeometry"),material:yt.defaultTwoLayerData("phong","layer1","layer2")}))(ul||(ul={}));var Xo;(o=>{function n(i,s){let a={name:s};return i.type==="Mesh"?(a.geometry={},"material"in i&&(a.material={layers:new Re}),"materials"in i&&(a.materials=i.materials.map(c=>({layers:new Re})))):ir.is(i.type)&&(a.perspective={},a.orthographic={}),a}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let a={...i};return"material"in a&&"material"in s&&s.material&&(a.material=Yn(a.material,c=>{if(typeof c!="string")for(let[d,l]of Object.entries(s.material.layers)){let u=c.layers.data(d);u&&Ct.patch(u,l)}}).data),a.materials&&s.materials&&(a.materials=Yn(a.materials,c=>{for(let d=0;d<a.materials.length;d++){let l=s.materials[d];if(typeof l!="string")for(let[u,p]of Object.entries(l.layers)){let f=c[d]?.layers?.data(u);f&&Ct.patch(f,p)}}}).data),a}function e(i,s){let a,c=[],d={orthographic:0,perspective:0,geometry:0};function l(u,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:[...u,"layers",f,"texture"],props:h,type:0};c.push(g)}if(Object.keys(y).length>0){let g={path:[...u,"layers",f],props:y,type:0};c.push(g)}}}for(let[u,p]of Object.entries(s))if(u!=="name")if(u==="cloner")c.push(...Ja.toOps(p,["cloner"]));else if(u==="pathSnapping")c.push({path:[u],props:{slide:p.slide,offset:p.offset},type:0});else if(u==="material")l(["material"],p);else if(u==="materials")for(let[f,m]of Object.entries(p))l(["materials",f],m);else if(d[u]===0){if(u==="geometry"&&p.extrusion!==void 0){let f={path:[u,"extrusion"],props:p.extrusion,type:0};c.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[u],props:p,type:0};c.push(f)}}else a===void 0&&(a={path:[],props:{},type:0},c.push(a)),a.props[u]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let a={...i};if(Object.assign(a,Jn.merge(a,s)),Object.assign(a,{pathSnapping:Object.assign({},a.pathSnapping,{slide:s.pathSnapping?.slide??a.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??a.pathSnapping?.offset??0})}),ir.is(i.type)){a.orthographic={...a.orthographic},a.perspective={...a.perspective};let c=s;c.orthographic?.zoom!==void 0&&(a.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(a.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(a.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(a.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in s&&Object.assign(a,{geometry:il.merge(a.geometry,s.geometry)}),(s.material||s.materials)&&(a=r(a,s)),a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Ar.merge(a.cloner,s.cloner)});else if(i.type==="Empty")a.cloner&&"cloner"in s&&Object.assign(a,{cloner:Ar.merge(a.cloner,s.cloner)});else if(el.is(i.type)){let c=s;c.intensity!==void 0&&(a.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?a.color=c.color:a.color=at.clone(c.color))}return a}o.patch=t})(Xo||(Xo={}));var ti;(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})(ti||(ti={}));var Nr;(r=>r.defaultData={orbitControls:ti.defaultData,playPage:_o,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})(Nr||(Nr={}));var eu;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(eu||(eu={}));var tu;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(tu||(tu={}));var Ao;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...eu.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:tu.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Ao||(Ao={}));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.traverseFrom(o,(s,a)=>{if(a.type==="Instance"){let c=t.data(a.component);c&&i(s,a,c.events)}else i(s,a,a.events)})}e.traverseModuleInstances=r})(ph||(ph={}));var dl;(a=>{a.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let d=[],l=ul.defaultMeshObject;c.withLight===!0&&d.push({fi:-1,data:cl.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),c.withSquare===!0&&d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:l,children:[]});let u=new Fe;return u.push({fi:1,id:_o,data:{...Jr.defaultData,name:"Scene 1"},children:d}),u}a.defaultData={objects:r(),publish:Nr.defaultData,styles:Ao.defaultData()},a.emptyDataWithoutPage=function(){return{objects:new Fe,publish:Nr.defaultData,styles:Ao.defaultData()}},a.emptyDataWithPage=function(c){return{objects:r(c),publish:Nr.defaultData,styles:Ao.defaultData()}};function i(c){return{...a.defaultData,objects:or(c,Fe.prototype)}}a.withObjs=i;function s(c,d){return i([{id:c,data:d,children:[],fi:0}])}a.withObj=s})(dl||(dl={}));var ri;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(ri||(ri={}));var pl;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},or(o,Be.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ri.emptyImage,name:"AI generated image"}),or(i,Be.prototype)}t.defaultImages=r;function e(){return{materials:new Be,images:new Be,videos:new Be,colors:new Be,audios:new Be,fonts:new Be}}t.emptyData=e})(pl||(pl={}));import{MathUtils as hl}from"three";var fl;(r=>r.list=["idle","move","jump","run"])(fl||(fl={}));var ml;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new ye,move:new ye,jump:new ye,run:new ye},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:At.fromHexAndA(3728051,1)}}))(ml||(ml={}));function fh(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 a=2;a<10;a++)o.push(o[1]),i.push(1);let s={...nr(Ze(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,s)}else if(r.type==="depth"&&r.gradientType===1&&(r.near<0||r.far<0)){let e={...Ze(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function eo(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function to(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach((o,i)=>{o===void 0&&(t.materials[i]=yt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=yt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=yt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&r(o.material)})})}function D_(n){Object.assign(n.scene.publish,{orbitControls:{...ti.defaultData,...Ze(n.scene.publish.orbitControls)}})}function B_(n){Object.assign(n.scene.publish.settings,{video:{...Nr.defaultData.settings.video,...Ze(n.scene.publish.settings.video)}})}function R_(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((ah.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,a]of Object.entries(i))(lh.includes(s)||typeof a=="boolean")&&delete i[s]}}}n.scene.objects.traverse((e,t)=>{t.states.forEach(o=>{let i=o;i.material?r(i.material):i.materials&&i.materials.forEach(s=>{r(s)})})})}function G_(n){n.scene.publish.withBackground=!0}function V_(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function z_(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 j_(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 F_(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=Ze(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Ze(e).booleanExclude!==!0)}})}function k_(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 U_(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 s=i;if(s.material){let a=Ze(s.material).layers;e(a),s.material.layers=a}if(s.materials)for(let a=0;a<s.materials.length;a++){let c=s.materials[a],d=Ze(c).layers;e(d),c.layers=d}})})}function mh(n){n.layers===void 0&&Object.assign(n,yt.defaultTwoLayerData("lambert"))}function ru(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={...Ze(r),colors:e,steps:t};Object.assign(r,o)}})}function H_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function hh(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&ru(t)}):"material"in e&&typeof e.material!="string"&&ru(e.material)}),Object.values(n.shared.materials).forEach(r=>ru(r))}function W_(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 q_(n){n.shared.audios=or({},Be.prototype)}function $_(n){n.shared.videos=or({},Be.prototype)}function Y_(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 X_(n){Object.entries(Ze(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(Ze(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function K_(n){n.scene.publish.settings.web.preload=!1}function yh(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 gh(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 Z_(n){n.shared.fonts=or({},Be.prototype)}function Q_(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 J_(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=yt.defaultTwoLayerData("phong"),s=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:s.r,g:s.g,b:s.b},i.layers[1].data.alpha=o.alpha;let a=Q_(o.font);n.shared.fonts[a]===void 0&&(n.shared.fonts[a]={name:a});let c={name:o.name,...gt.defaultData,...$o.defaultData,flatShading:!1,wireframe:!1,geometry:{...Oo.defaultData("TextGeometry"),width:o.width,height:o.height,font:a,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:Ze(o.states),events:Ze(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},d=Ze(n.scene.objects).parent(e);n.scene.objects.insertAfter(d??null,e,[{id:e+"new",data:c,children:[]}]),r.push(e)}}),r.forEach(e=>{n.scene.objects.delete(e)})}function eP(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 ye,move:new ye,jump:new ye}});else{let i=new ye;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:hl.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,a,c)=>{let d={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},l={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(l,nr(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(l,{control1:{...s.control1},control2:{...s.control2}});let u={repeat:s.repeat?-1:0,delay:s.delay,delayDirection:s.delayDirection,direction:s.cycle&&s.rewind?"pingpong-rewind":s.cycle?"pingpong":"normal"},p={state:s.state,...u,...l},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ye({fi:0,id:hl.generateUUID(),data:d},{fi:1,id:hl.generateUUID(),data:p})};i.push({fi:c,id:a,data:f})}),delete o.targets)}})})}function tP(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new ye,a=[];if(e.events.forEach((c,d,l)=>{if(c.type==="Audio"&&c.trigger===i){let u;a.push(d),c.interaction==="play"?u={...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")&&(u={...nr(c,"interaction","delay","object","playAudio"),type:"Audio"}),u&&s.push({fi:l,id:d,data:u})}}),a.forEach(c=>e.events.delete(c)),s.length){let c=e.events.find(d=>d.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,s):e.events.insertBefore(null,[{id:hl.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function xh(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 vh(n){eo(n,xh),to(n,xh)}function rP(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function oP(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 nP(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=yt.defaultTwoLayerData("phong"))})}function iP(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 sP(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 aP(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 lP(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function cP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function uP(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function dP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=ml.defaultDataThirdPerson.navmesh)})})}function pP(n){n.scene.styles||(n.scene.styles=Ao.defaultData())}function bh(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function fP(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}),to(n,bh),eo(n,bh)}function mP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new ye})})})}function hP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Sh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function wh(n,r){if(r<1&&(to(n,fh),eo(n,fh),n.schema=1),r<2&&(D_(n),n.schema=2),r<3&&(R_(n),n.schema=3),r<4&&(G_(n),n.schema=4),r<5&&(V_(n),n.schema=5),r<6&&(z_(n),n.schema=6),r<7&&(j_(n),n.schema=7),r<8&&(n.schema=8),r<9&&(hh(n),n.schema=9),r<10&&(H_(n),n.schema=10),r<11&&(W_(n),n.schema=11),r<12&&(hh(n),n.schema=12),r<13&&(q_(n),n.schema=13),r<14&&(Y_(n),n.schema=14),r<15&&(X_(n),n.schema=15),r<16&&(K_(n),n.schema=16),r<17&&(to(n,yh),eo(n,yh),n.schema=17),r<18&&(to(n,mh),eo(n,mh),n.schema=18),r<19&&(B_(n),n.schema=19),r<20&&(Z_(n),J_(n),n.schema=20),r<21&&(eP(n),tP(n),n.schema=21),r<22&&(vh(n),n.schema=22),r<23&&(rP(n),n.schema=23),r<24&&(oP(n),n.schema=24),(r<25||n.shared.videos===void 0)&&($_(n),r<25&&(n.schema=25)),r<26&&(F_(n),n.schema=26),r<27&&(k_(n),n.schema=27),r<28&&(vh(n),n.schema=28),r<29&&(U_(n),n.schema=29),r<30&&(nP(n),n.schema=30),r<31&&(iP(n),n.schema=31),r<33&&(sP(n),n.schema=33),r<34&&(aP(n),n.schema=34),r<35&&(lP(n),n.schema=35),r<36&&(cP(n),n.schema=36),r<37&&(uP(n),n.schema=37),r<38&&(to(n,gh),eo(n,gh),n.schema=38),r<39&&(dP(n),n.schema=39),r<40&&(pP(n),n.schema=40),r<41&&(fP(n),n.schema=41),r<42&&(mP(n),n.schema=42),r<43&&(hP(n),n.schema=43),r<99){to(n,Sh),eo(n,Sh),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=wo);let e=Ze(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=_o,t.insertBefore(null,null,[{id:_o,data:{...Jr.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:{...vs.defaultData,...nr(n.scene.environment,"usePhysics","gravity")},camera:Ze(n.scene.ownerCamera)??Jr.defaultData.camera,name:"Scene"},children:[]}]);for(let s of e)s.id!==dl.TRASH_CAN_ID&&t.move(_o,s.fi,s.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((s,a)=>{a.type==="DirectionalLight"?(a.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):a.type==="SpotLight"&&(a.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(a.physics===void 0||a.physics===null)&&a.type!=="Instance"&&(a.physics={},Object.assign(a.physics,To.defaultData)),a.physics!==void 0&&a.physics!==null&&(a.physics.enabled=a.collision??"visibility",delete a.collision)}),n.schema=99}}function _h(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function yP(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 Ph=102;function Th(n){let r=n.schema??0;r!==Ph&&(console.warn("updating from ",r,"to ",Ph),wh(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Nr.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(to(n,_h),eo(n,_h),n.schema=101),r<102&&(yP(n),n.schema=102))}var Ki=ss(Ah());import{Object3D as KA,Vector3 as Yt,Euler as Gd,MathUtils as r0,Matrix4 as gn}from"three";var gP=.5*(Math.sqrt(3)-1),Ss=(3-Math.sqrt(3))/6,xP=1/3,Ir=1/6,Xz=(Math.sqrt(5)-1)/4,Kz=(5-Math.sqrt(5))/20,ws=n=>Math.floor(n)|0,Ch=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]),nu=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 yl(n=Math.random){let r=Ih(n),e=new Float64Array(r).map(o=>Ch[o%12*2]),t=new Float64Array(r).map(o=>Ch[o%12*2+1]);return function(i,s){let a=0,c=0,d=0,l=(i+s)*gP,u=ws(i+l),p=ws(s+l),f=(u+p)*Ss,m=u-f,h=p-f,y=i-m,g=s-h,x,S;y>g?(x=1,S=0):(x=0,S=1);let w=y-x+Ss,b=g-S+Ss,_=y-1+2*Ss,P=g-1+2*Ss,v=u&255,N=p&255,T=.5-y*y-g*g;if(T>=0){let A=v+r[N],M=e[A],L=t[A];T*=T,a=T*T*(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-_*_-P*P;if(O>=0){let A=v+1+r[N+1],M=e[A],L=t[A];O*=O,d=O*O*(M*_+L*P)}return 70*(a+c+d)}}function Nh(n=Math.random){let r=Ih(n),e=new Float64Array(r).map(i=>nu[i%12*3]),t=new Float64Array(r).map(i=>nu[i%12*3+1]),o=new Float64Array(r).map(i=>nu[i%12*3+2]);return function(s,a,c){let d,l,u,p,f=(s+a+c)*xP,m=ws(s+f),h=ws(a+f),y=ws(c+f),g=(m+h+y)*Ir,x=m-g,S=h-g,w=y-g,b=s-x,_=a-S,P=c-w,v,N,T,C,O,A;b>=_?_>=P?(v=1,N=0,T=0,C=1,O=1,A=0):b>=P?(v=1,N=0,T=0,C=1,O=0,A=1):(v=0,N=0,T=1,C=1,O=0,A=1):_<P?(v=0,N=0,T=1,C=0,O=1,A=1):b<P?(v=0,N=1,T=0,C=0,O=1,A=1):(v=0,N=1,T=0,C=1,O=1,A=0);let M=b-v+Ir,L=_-N+Ir,X=P-T+Ir,R=b-C+2*Ir,Z=_-O+2*Ir,z=P-A+2*Ir,V=b-1+3*Ir,W=_-1+3*Ir,$=P-1+3*Ir,Y=m&255,q=h&255,k=y&255,U=.6-b*b-_*_-P*P;if(U<0)d=0;else{let D=Y+r[q+r[k]];U*=U,d=U*U*(e[D]*b+t[D]*_+o[D]*P)}let B=.6-M*M-L*L-X*X;if(B<0)l=0;else{let D=Y+v+r[q+N+r[k+T]];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)u=0;else{let D=Y+C+r[q+O+r[k+A]];F*=F,u=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*(d+l+u+p)}}function Ih(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 vP}from"three";var sr=new vP,gl=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 s=Math.ceil((t+o)/2);if(s===0||e[s-1]<=r&&e[s]>r){i=s;break}else r<e[s]?o=s-1:t=s+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 PP}from"three";var Lh=ss(Eh());import{Object3D as bP,Matrix4 as Mr}from"three";var SP=new Mr,wP=new Mr,_P=new Mr,oi;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(oi||(oi={}));var ni=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Mr;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Mr;this.matrixWorldRigid=new Mr;this.shearScale=new Mr;this.shearScaleInv=new Mr}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof bP&&(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 s of this.children)s.updateWorldMatrix(!1,!0)}traverseChildren(t,o=0){for(let i of this.children)oi.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)oi.is(s)&&s.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:s,q:a}=(0,Lh.SVD)(o),c=SP.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),d=wP.set(s[0][0],s[0][1],s[0][2],0,s[1][0],s[1][1],s[1][2],0,s[2][0],s[2][1],s[2][2],0,0,0,0,1),l=_P.copy(d).transpose();this.shearScale.makeScale(a[0],a[1],a[2]).multiply(l).premultiply(d),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,l).copyPosition(this.matrixWorld),a.every(u=>Math.abs(a[0]-u)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Mr().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Mr?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,s,a,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var iu=class extends ni(PP){},TP=n=>n.type==="Mesh",ro=class extends iu{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 ro(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 TP(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 SO,BufferGeometry as wO,MeshBasicMaterial as _O}from"three";import{Matrix4 as vO,Mesh as bO}from"three";import{Matrix4 as bl,Vector3 as MP,Euler as EP}from"three";import{Box3 as OP,Line3 as AP,Matrix4 as su,Vector3 as Wt}from"three";var Ko=new Wt,Zo=new Wt,ii=new su,Bh=[new Wt(-1,1,1),new Wt(-1,-1,1),new Wt(1,-1,1),new Wt(1,1,1),new Wt(-1,1,-1),new Wt(-1,-1,-1),new Wt(1,-1,-1),new Wt(1,1,-1)],CP=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],NP=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Dh=(n,r,e)=>{n.updateEntityBoxSize(Ko,Zo),ii.copy(r).multiply(n.matrixWorld),Zo.x===0&&Zo.y===0&&Zo.z===0?e.push(new Wt(Ko.x,Ko.y,Ko.z).applyMatrix4(ii)):Bh.forEach(t=>{e.push(t.clone().multiply(Zo).add(Ko).applyMatrix4(ii))})},_s=class extends OP{constructor(){super(...arguments);this.matrix=new su;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 su().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,t)}expandByObjectSize(e,t,o=!1){let i=[];return o===!0?e.traverseEntity(s=>{if(s.visible||s.cloner&&s.data.visible){if(!("geometry"in s)){i.push(new Wt);return}Dh(s,t,i)}}):Dh(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(ii.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Zo).multiplyScalar(.5),this.getCenter(Ko),ii.copy(this.matrix).setPosition(Ko),this.vertices=Bh.map(e=>e.clone().multiply(Zo).applyMatrix4(ii))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=CP.map(([e,t])=>new AP(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Wt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=NP.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var ar={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as IP,CubicBezierCurve3 as au,Vector3 as lr}from"three";var cu=class extends IP{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),s=o[o.length-1]/o.length;for(let a=0,c=this.curves;a<c.length;a++){let d=c[a],l=a===0?o[a]:o[a]-o[a-1],u=Math.ceil(r*l/s),p=d.getPoints(u);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 uu=.001;function du(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=uu}function lu(n,r){let e=new lr(...n.position),t=new lr(...n.controlNext.position),o=new lr(...r.controlPrevious.position),i=new lr(...r.position);return du(e,t,i)&&du(e,o,i)}function vl(n){let r=n.points.map(l=>new lr(...l.data.position)),e=[n.points[0]],t=new lr(...e[0].data.position);for(let l=0;l<n.points.length-1;l++)du(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),s=e.length,a=[];for(let l=0;l<s;l++){let u=e[l].data,p=new lr(...u.position),f=new lr(...u.controlPrevious.position),m=new lr(...u.controlNext.position),h={position:p,baseRoundness:u.roundness,controlPrevious:f,controlNext:m};if(u.roundness===0||!n.isClosed&&(l===0||l===s-1)){a[l]={...h,removedLength:0};continue}let y=o&&l==0?s-1:l-1,g=o&&l==s-1?0:l+1,x=e[y].data,S=e[g].data,w=new lr(...x.position),b=new lr(...S.position),_=w.clone().sub(p).normalize(),P=b.clone().sub(p).normalize();Object.assign(h,{prevDir:_,nextDir:P});let v=lu(x,u),N=lu(u,S);if(!v||!N)a[l]={...h,removedLength:0};else{let T=_.clone().add(P).normalize(),C=T.clone().cross(_).length()/_.dot(T);a[l]={...h,tan:C,removedLength:u.roundness/C}}}for(let l=0;l<i;l++){let u=l,p=o&&l===s-1?0:l+1,f=a[u],m=a[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 u=l,p=o&&l===s-1?0:l+1,f=a[u],m=a[p],h=null;if(!lu(e[u].data,e[p].data))f.position.distanceTo(m.position)>uu&&(h=new au(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)>uu&&(h=new au(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*l+1]=h}for(let l=0;l<s;l++){let u=a[l];if(u.removedLength===0){c[2*l]=null;continue}let p=u.position,f=u.prevDir.clone().multiplyScalar(u.removedLength).add(p),m=u.nextDir.clone().multiplyScalar(u.removedLength).add(p),h=u.tan*u.removedLength,y=u.prevDir.clone().add(u.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),_=u.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),P=_.clone().lerp(w,2),v=f.clone().lerp(_,4/3),N=m.clone().lerp(P,4/3);c[2*l]=new au(f,v,N,m)}let d=new cu;return c.forEach(l=>{l&&d.add(l)}),d}var Te;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Te||(Te={}));var si=n=>Te.is(n),LP={type:"completeState",isfromEntity:!0},ai=n=>class extends ni(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.instances=[];this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new _s;this._recursiveBBox=new _s;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 s of this.data.states)Xo.toOps(this.data,s.data).forEach(c=>{let d=Ga.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(d,this.data,o)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Xo.patch(this.data,s),Xo.toOps(this.data,s).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched),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=>{si(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)si(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Te.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)si(s)&&s.isConcreteEntity&&s.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)si(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)si(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=>si(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,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Fn(o,t)}updateTransformState(t){let o=!1;return t.position&&(this.position.fromArray(t.position),o=!0),t.rotation&&(this.rotation.fromArray(t.rotation),o=!0),t.scale&&(o=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(o=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??So.identity)),o&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),o}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 Fn(o,t)}updateByObjUpdateOp(t,o){t!==void 0&&this.updateByOp({type:0,props:t,path:[]},{...this.data,...t},o,!1)}updateByOp(t,o,i,s){let a=this.data;this.data=o;let c=t,d=_t(t.path,["states","*"]);if(d!==null){if(t.type===0){let[l]=d;if(this?.stateSelection===l){let u={...t.props};if(delete u.name,Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Tt.zoom(p,t.path.slice(2));if(f)for(let m in t.props)t.props[m]===void 0&&m in f&&(u[m]=f[m])}}c={...t,props:u,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 u=Tt.removeOverridden(t.path,t.props,l);c={...t,props:u}}}if(this.updateByPatchedOpBase(c,Xo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),_t(t.path,["overrides"])){let l=[],u=[...t.path];for(l.push(u[1]),u.splice(0,2);u.length>0&&u[0]==="descendants";)l.push(u[1]),u.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(wr.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...l]);if(p){let f=Tt.zoom(p.component.data,u);if(t={...t,path:u},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=ei.resolve(o.overrides,l),p.updateByOp(t,ht.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let l;if(t.path.length===0&&t.type===0){let u;for(let p of Cr.rootOverrideProps)p in t.props&&(u===void 0&&(u={}),u[p]=t.props[p]);u&&(l={...t,props:u})}else for(let u of Cr.rootOverrideProps)if(_t(t.path,[u])){l=t;break}l!==void 0&&this.instances.forEach(u=>{if(u.isInstanceRoot){let p=wr.filterOp(u.overrideData,l);p&&u.updateByOp(p,ht.applySimple(u.data,p),i,!0)}}),this.instances.forEach(u=>{if(!u.isInstanceRoot){let p=wr.filterOp(u.overrideData,t);if(p){let f;a===u.data&&t===p?f=o:f=ht.applySimple(u.data,p),u.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)&&ar.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){ar.changeEntityProptotype(this,o,i);for(let s of this.children)Te.is(s)&&s.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 s=ht.drop(t,1);s.path.length===0&&s.type===0&&s.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,s=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset,a=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 d=c.data;if(d.geometry.path.points.length<=1)return;let l=vl(d.geometry.path),u=(i+s)%1;i+s===1&&u===0&&(u=1);let p=l.getPointAt(u),f=this.parent?this.parent?.matrixWorld:new bl;c.updateMatrixWorld();let m=new bl().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:d.rotation};if(a==="tangential"){let y=new bl().extractRotation(c.matrixWorld),g=l.getTangentAt(u).applyMatrix4(y).add(p),x=new bl().lookAt(p,g,new MP(0,1,0)),S=new EP().setFromRotationMatrix(x);h={...h,rotation:[S.x,S.y,S.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(LP)})}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)}get attachedSurfaceCloners(){return this.children.filter(t=>t instanceof ar.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 ar.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{ConeGeometry as RP}from"three";import{BufferGeometry as DP,CylinderGeometry as BP,Float32BufferAttribute as pu,Vector2 as cr,Vector3 as Sl}from"three";var Gh=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),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:s,thetaStart:a,thetaLength:c,radiusTop:d,radiusBottom:l,cornerRadius:u,cornerSegments:p,hollow:f}=n.parameters,m;return u||f?m=new Ps(d,l,t,o,i,s,a,c*Math.PI/180,u,u,p,f):m=new BP(d,l,t,o,i,s,a,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function Co(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Rh(n){return new cr(n.y,-n.x)}var Ps=class extends DP{constructor(r,e,t,o,i,s,a,c,d,l,u,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,s=s!==void 0?s:!1,a=a!==void 0?a:0,c=c!==void 0?c:Math.PI*2,s&&(d=0,l=0);let m=[],h=[],y=[],g=[],x=0,S=t/2,w=new Sl,b=new Sl;f&&r==0&&(r=d),f&&e==0&&(e=l);let _=new cr(r,S),P=new cr(e,-S),v=null,N=null,T=null,C=null,O=_.clone().sub(P),A=0,M=0,L=0;p>0&&(A=Math.min(r,e)*(1-p),M=r-A,L=e-A);let X=_.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(d=Math.min(d,(r-M)/$,O.length()/W),l=Math.min(l,(e-L)/Y,O.length()/W),d>0){let j=d/z;v=_.clone().sub(new cr(j,d)),p&&(T=v.clone(),T.x-=A-W*d),_.sub(O.clone().setLength(j))}if(l>0){let j=l/V;N=P.clone().sub(new cr(j,-l)),P.add(O.clone().setLength(j)),p&&(C=N.clone(),C.x-=A-W*l,X.sub(O.clone().setLength(j)))}O=_.clone().sub(P);let q=O.length()<.5,k=[];for(let j=0;j<=o;j++){let D=[],oe=j/o,ee=oe*c+a,K=new cr(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)):s||B(D,K,e,L,-1);let te=Rh(O).normalize();if(Co(te,K,w),!q)for(let Q=0;Q<=i;Q++){let ae=Q/i,ne=O.clone().multiplyScalar(ae).add(P);Co(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(T&&v?(U(D,oe,K,R,d,v,1,!1),U(D,oe,K,Z,d,T,1,!0)):v?(U(D,oe,K,R,d,v,1,!1),B(D,K,v.x,0,1)):s||B(D,K,r,M,1),p&&!q){let Q=Rh(O).multiplyScalar(-1).normalize();Co(Q,K,w);for(let ae=0;ae<=i;ae++){let ne=ae/i,ie=O.clone().multiplyScalar(-ne).add(X);Co(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&&!s&&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(s&&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],ae=h[K*3+2];m.push(oe,ee,te),(Q!=0||ae!=0)&&m.push(ee,K,te)}c<Math.PI*2&&(F(-1,k[0],a),F(1,k[k.length-1],a+c)),this.setIndex(m),this.setAttribute("position",new pu(h,3)),this.setAttribute("normal",new pu(y,3)),this.setAttribute("uv",new pu(g,2));function U(j,D,oe,ee,K,te,Q,ae){for(let ne=0;ne<u+1;ne++){let ie=ne/u,ce=Q<0?ie:1-ie;ae&&(ce-=1),ce*=ee;let le=new cr(Math.sin(ce),Math.cos(ce)*Q),ue=le.clone().multiplyScalar(K).add(te);Co(ue,oe,b),h.push(b.x,b.y,b.z),Co(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 Sl,Q=new cr,ae=[oe,ee];K<0&&ae.reverse();for(let ne of ae)Q.set(ne,S*K),Co(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 cr(Math.sin(oe),Math.cos(oe)),K=new cr(-Math.cos(oe),Math.sin(oe)),te=new Sl,Q=j<0?(ie,ce,le)=>m.push(ie,ce,le):(ie,ce,le)=>m.push(ie,le,ce),ae=new cr((r+e+M+L)/4,0);Co(ae,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 Vh=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{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:s,thetaStart:a,thetaLength:c,cornerRadiusTop:d,cornerRadiusBottom:l,cornerSegments:u}=n.parameters,p;return d>0||l>0||c<360?p=new Ps(0,r/2,t,o,i,s,a,c*Math.PI/180,d,l,u,0,!0):p=new RP(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as GP,BufferGeometry as VP,Float32BufferAttribute as fu,Vector3 as Ts}from"three";var zh=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:s,cornerRadius:a,cornerSegments:c}=n.parameters,d;return a==0?d=new GP(r,e,t,o,i,s):d=new hu(r,e,t,o,i,s,a,c),Object.assign(d,{userData:{...n,type:"CubeGeometry"}})}},mu=Math.PI/2,hu=class extends VP{constructor(r=1,e=1,t=1,o=1,i=1,s=1,a=0,c=4){super(),this.type="BoxGeometry";let d=this;o=Math.floor(o),i=Math.floor(i),s=Math.floor(s),c=Math.floor(c),a=Math.min(a,r/2,e/2,t/2);let l=[],u=[],p=[],f=[],m=0,h=0;y("z","y","x",-1,-1,t,e,r,s,i,0),y("z","y","x",1,-1,t,e,-r,s,i,1),y("x","z","y",1,1,r,t,e,o,s,2),y("x","z","y",1,-1,r,t,-e,o,s,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),a>0&&(g("z","y","x",-1,-1,1,t,e,r,s,0),g("z","y","x",1,-1,-1,t,e,r,s,1),g("z","y","x",-1,1,-1,t,e,r,s,1),g("z","y","x",1,1,1,t,e,r,s,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 fu(u,3)),this.setAttribute("normal",new fu(p,3)),this.setAttribute("uv",new fu(f,2));function y(S,w,b,_,P,v,N,T,C,O,A){let M=(v-2*a)/C,L=(N-2*a)/O,X=v/2-a,R=N/2-a,Z=T/2,z=C+1,V=O+1,W=0,$=0,Y=new Ts;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*_,Y[w]=k*P,Y[b]=Z,u.push(Y.x,Y.y,Y.z),Y[S]=0,Y[w]=0,Y[b]=T>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}d.addGroup(h,$,A),h+=$,m+=W}function g(S,w,b,_,P,v,N,T,C,O,A){let M=(N-2*a)/O,L=N/2-a,X=T/2-a,R=C/2,Z=O+1,z=0,V=0,W=new Ts,$=new Ts;for(let Y=0;Y<c+1;Y++){let q=Y/c*mu,k=Math.sin(q)*a,U=(1-Math.cos(q))*a,B=Math.sin(q),F=Math.cos(q);W[w]=(X+k)*P,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*_,u.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}d.addGroup(h,V,A),h+=V,m+=z}function x(S,w,b){let _=new Ts,P=new Ts(r/2,e/2,t/2);P.subScalar(a);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=mu*(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);_.x=M*Z,_.y=L,_.z=M*z;let V=P.clone().addScaledVector(_,a);u.push(S*V.x,w*V.y,b*V.z),p.push(S*_.x,w*_.y,b*_.z),f.push(0,0),O.push(m++),X+=mu/C}v.push(O)}let T=v.length-1;for(let C=0;C<T;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 zP,Float32BufferAttribute as yu,Triangle as jP,Vector3 as oo,Vector2 as gu}from"three";var No=class extends zP{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],c=[],d=[];l(),u(),this.setAttribute("position",new yu(a,3)),this.setAttribute("normal",new yu(d,3)),this.setAttribute("uv",new yu(c,2));return;function l(){i=Math.min(1-1e-5,i),i==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[t],m=new oo,h=m.clone(),y=new jP,g=i*o,x=o-g,S=s+1,w=new oo,b=(z,V)=>w.subVectors(z,V).normalize(),_=(z,V)=>Array(z).fill(void 0).map(V),P=_(r.length/3,(z,V)=>new oo().fromArray(r,V*3).setLength(o)),v=[],N=1e6;for(let z=0;z<P.length;z++){let V=P[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(P[$]),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 T=[];{let z=0,V=0,W,$,Y=f==3;for(let q=0;q<=s;q++){W=q*(q+1)/2,$=(q+1)*(q+2)/2;for(let k=0;k<s-q;k++)[z,V]=[W+k+q+2,$+k+q+3],T.push(W,$,...Y?[V,W]:[z,$],V,z),[W,$]=[z,V];T.push(W,$,W+s+2)}}let C=m.clone(),O=m.clone(),A=m.clone(),M=m.clone(),L=m.clone(),X=[],R=_(P.length,()=>_(f,()=>m.clone()));for(let z=0;z<P.length;z++){m.copy(P[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(P,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 oo;s==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;s==0?O.copy(q):O.copy(C).setLength(x+te),$.push(te);let Q=[O,D,oe];for(let ae=0;ae<2;ae++){let ne=Q[ae],ie=Q[ae+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][ae]*ce/S;m.copy(M).applyAxisAngle(A,le).add(C),W.push(m.clone()),ae&&(b(m,C),F.push([ce==0?ne:m.clone(),w.clone()]))}ae&&(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=T.map(ee=>D[ee]);a.push(...oe.map(ee=>[ee.x,ee.y,ee.z]).flat()),d.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=>{a.push(D[0].x,D[0].y,D[0].z),d.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=>{a.push(U.x,U.y,U.z),d.push(w.x,w.y,w.z)})}}function u(){let p=new oo;for(let P=0;P<a.length;P+=3){p.x=a[P+0],p.y=a[P+1],p.z=a[P+2];let v=b(p)/2/Math.PI+.5,N=_(p)/Math.PI+.5;c.push(v,1-N)}let f=new oo,m=new oo,h=new oo,y=new oo,g=new gu,x=new gu,S=new gu,w=(P,v,N,T)=>{T<0&&P.x===1&&(c[v]=P.x-1),N.x===0&&N.z===0&&(c[v]=T/2/Math.PI+.5)};for(let P=0,v=0;P<a.length;P+=9,v+=6){f.set(a[P+0],a[P+1],a[P+2]),m.set(a[P+3],a[P+4],a[P+5]),h.set(a[P+6],a[P+7],a[P+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 P=0;P<c.length;P+=6){let v=c[P+0],N=c[P+2],T=c[P+4],C=Math.max(v,N,T),O=Math.min(v,N,T);C>.9&&O<.1&&(v<.2&&(c[P+0]+=1),N<.2&&(c[P+2]+=1),T<.2&&(c[P+4]+=1))}function b(P){return Math.atan2(P.z,-P.x)}function _(P){return Math.atan2(-P.y,Math.sqrt(P.x*P.x+P.z*P.z))}}}static fromJSON(r){return new No(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as FP}from"three";var jh=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:s}=n.parameters,a=o===0&&i!==0?new Os(r*.5,i,s):new FP(r*.5,o);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"DodecahedronGeometry"}})}},Os=class extends No{constructor(r=1,e=.2,t=4){let o=(1+Math.sqrt(5))/2,i=1/o,s=[-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],a=[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(s,a,c,r,e,t),this.type=c}static fromJSON(r){return new Os(r.radius,r.corner,r.cornerSides)}};import{Plane as QP,Shape as ty,Vector2 as no,Vector3 as JP,MathUtils as Pu,LineCurve as Tu,QuadraticBezierCurve as ry,CubicBezierCurve as Tl}from"three";import{CubicBezierCurve as wl,EllipseCurve as kP,LineCurve as _l,LineCurve3 as UP,MathUtils as HP,QuadraticBezierCurve as vu,SplineCurve as WP,Vector2 as Pt,Vector3 as Uh}from"three";var As=1e-12,li=class{constructor(r){this.position=new Pt;this.startPosition=new Pt;this.uuid=HP.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 li(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ci=class extends li{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ci(this.parent).copy(this)}},ur=class extends li{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ci(this),new ci(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 s=this.controls[o];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new 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&&(Fh(o,e),Fh(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 Fh(n,r=new Pt){let e=n.length();return r.set(-n.y/e,n.x/e)}var bu=n=>n,ui=new Pt,Pl=new Pt,qP=new Pt,$P=new Pt,YP=new Pt,XP=new Pt,Hh=new Uh,Wh=new Uh;function qh(n){let r=new Pt;r.addVectors(n.v0,ui.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Pt;return e.addVectors(n.v2,Pl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new wl(n.v0,r,e,n.v2)}function Cs(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function KP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function ZP(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Su(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 $h(n,r,e){return kh(n,r)&&kh(r,e)&&xu(n.position,r.position,e.position)}function xu(n,r,e){return ui.copy(r).sub(n).cross(Pl.copy(e).sub(n))===0}function Yh(n,r,e,t,o){let i=Math.sqrt(Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)),s=(n.y+r.y)/2,a=(n.x+r.x)/2,c=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-r.y)/i,d=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(r.x-n.x)/i;return t.set(a+c,s+d),o.set(a-c,s-d),[t,o]}function Xh(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function Kh(n,r,e,t,o,i){let s=r.x-n.x,a=r.y-n.y,c=e.x-n.x,d=e.y-n.y,l=Math.sqrt((s+c)*(s+c)+(a+d)*(a+d)),u;return Su(r,n,e)>Math.PI&&(l*=-1),Cs(d,a)?u=(a+d)*(t/l-.5)*8/3/(s-c):u=(s+c)*(t/l-.5)*8/3/(d-a),o.set(r.x-u*a,r.y+u*s),i.set(e.x+u*d,e.y-u*c),[o,i]}function wu(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function kh(n,r){return xu(n.position,n.controls[1].position,r.position)&&xu(n.position,r.controls[0].position,r.position)}function Zh(n,r,e,t,o=.5){let i=ui.subVectors(r,n).multiplyScalar(o).add(n),s=Pl.subVectors(e,r).multiplyScalar(o).add(r),a=qP.subVectors(t,e).multiplyScalar(o).add(e),c=i,d=$P.subVectors(s,i).multiplyScalar(o).add(i),l=YP.subVectors(a,s).multiplyScalar(o).add(s),u=a,p=XP.subVectors(l,d).multiplyScalar(o).add(d);return[n.x,n.y,c.x,c.y,d.x,d.y,p.x,p.y,l.x,l.y,u.x,u.y,t.x,t.y]}function Qh(n,r,e=12,t=!0){let o=Wh.set(0,0,0),i,s=0,a=[];for(let c=0;c<r.length;c++){let d=bu(r[c]),l=ui,u=Io(d,e);a.push(u);for(let p=0;p<=u;p++)if(d instanceof wl||d instanceof vu||d instanceof _l){if(d.getPoint(p/u,l),o.set(l.x,l.y,0),i!==void 0&&ZP(i,o))continue;i===void 0&&(i=Hh),i.copy(o),n.setXYZ(s,o.x,o.y,o.z),s++}}return t&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function Jh(n,r,e,t=12,o=!0){let i=Wh.set(0,0,0),s=0,a=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let d,l=bu(r[c]),u=ui,p=Io(l,t);a.push(p);for(let f=0;f<=p;f++)if(l instanceof wl||l instanceof vu||l instanceof _l){if(l.getPoint(f/p,u),i.set(u.x,u.y,0),d?.equals(i))continue;d===void 0?d=Hh:(n.setXYZ(s,d.x,d.y,d.z),s++,n.setXYZ(s,i.x,i.y,i.z),s++),d.copy(i)}}return o&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),a}function _u(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],a=0;if(e&&s.roundedCurveCorner!==void 0){let c=Io(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),a+=c}s.curveAfter!==void 0&&(a+=Io(s.curveAfter,r)),t.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=Io(n[0].roundedCurveCorner,r)*.5),t}function Io(n,r=12){return n&&n instanceof kP?r*2:n&&(n instanceof _l||n instanceof UP)?1:n&&n instanceof WP?r*n.points.length:r}function ey(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let a=bu(r[s]),c=Io(a,e),d=ui;for(let l=0;l<=c;l++)if(a instanceof wl||a instanceof vu||a instanceof _l){if(a.getPoint(l/c,d),o!==void 0&&KP(o,d,As))continue;o===void 0&&(o=Pl),o.copy(d),n.push(d.x,d.y),i++}}return Cs(n[0],n[n.length-2],As)&&Cs(n[1],n[n.length-1],As)&&(n.pop(),n.pop()),t&&i>1&&!(Cs(n[i-1],n[1],As)&&Cs(n[i-2],n[0],As))&&(n.push(n[0],n[1]),i++),n}var Ou=new no,eT=new no,tT=new no,rT=new no,oT=new no,nT=new no,Ae=class extends ty{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new QP(new JP(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=Pu.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Ae;return i.isClosed=e.isClosed,i.points=e.points.map(s=>ur.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>Ae.createFromState(s)),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 s=0,a=this.shapeHoles.length;s<a;s++){let c=this.shapeHoles[s],d=c.points.length,l=c.getPointIndexById(e);if(l<0)i+=d;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 s=this.shapeHoles[o],a=e-t;if(a<=s.points.length-1)return s.points[a];t+=s.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 s=this.shapeHoles[o],a=s.points.indexOf(e);if(a>=0)return t+a;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=Ou.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let a=this.points[i];a.position.multiply(o),a.controls[0].position.multiply(o),a.controls[1].position.multiply(o)}for(let i=0,s=this.shapeHoles.length;i<s;i++)this.shapeHoles[i].applyScale(e,t);this._update()}createPoint(e,t=0,o=Pu.generateUUID()){let i;e instanceof no?i=e:i=new no(e,t);let s=new ur(o,i);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,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 s=this.shapeHoles[t].getPointByUuid(e);if(s)return s}}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 Qh(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=_u(this.points,e,!1),this.roundedCurveDivisions=_u(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return Jh(e,this.curves,t,o,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),ey(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,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=Io(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=i.reduce((c,d)=>c+d,0));for(let c=0,d=i.length;c<d;c++){let l=i[c];if(a<o+l)return[c,(a-o+1)/l];o+=l}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,c=a[e];if(wu(i,s)){let u=i.position.distanceTo(s.position);return i.position.distanceTo(Ou.set(o.x,o.y))/u}let d=0;for(let u=0;u<e;u++)d+=a[u];return(t-d)/c}dispose(){}_applyCurveForPoint(e,t){wu(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 s=this.points[t-1];this._applyCurveForPoint(i,s)}}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 s=this.points[o],a=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],d=s.roundness,l=a&&c&&$h(a,s,c);if(!s.controlsMoved()&&d>0&&!l){let u=s.curveBefore,p=s.curveAfter;if(u===void 0||p===void 0)continue;let f=s.roundedCurveBefore,m=s.roundedCurveAfter,h=u.getLength(),y=p.getLength(),g=Math.min(d,h*.499),x=Math.min(d,y*.499),S=Math.min(g,x),w=1-S/h,b=S/y,_=u.getPointAt(w,Ou),P=p.getPointAt(b,eT);this._subSplitCurve(u,f,w,_,void 0),this._subSplitCurve(p,m,b,void 0,P);let v;if(this.useCubicForRoundedCorners){let N=Su(_,s.position,P)/2,T=Math.tan(N)*_.distanceTo(s.position),[C,O]=Yh(_,P,T,tT,rT),A=Xh(C,O,s.position),[M,L]=Kh(A,_,P,T,oT,nT);v=new Tl(_.clone(),M.clone(),L.clone(),P.clone())}else v=new ry(_.clone(),s.position.clone(),P.clone());s.roundedCurveCorner=v,this.roundedCurves.splice(o+t,0,v),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Tu)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let a=e,c=t,d=a.getUtoTmapping(o,0),l=Zh(a.v0,a.v1,a.v2,a.v3,d);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])),s!==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 Ae(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,s=e.points[i+0],a=e.points[i+1],c=e.points[i+2],d=e.points[i+3],l=e.points[i+4],u=e.points[i+5],p=e.points[i+6],f=new ur(Pu.generateUUID(),new no(s,a));f.controls[0].position.set(c,d),f.controls[1].position.set(l,u),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Ae;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Tl&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],a,c;for(a=0,c=i.length;a<c;a++)i[a]instanceof ry&&(i[a]=qh(i[a]));for(a=0,c=i.length;a<c;a++){let u=i[a],p=a>0?i[a-1]:null,f;u instanceof Tl?(f=this.createPoint(u.v0),f.controls[1].position.copy(u.v1)):u instanceof Tu&&(f=this.createPoint(u.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let d=i[i.length-1],l=!1;return d instanceof Tl?d.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(d.v2),l=!0):d instanceof Tu&&d.v2.equals(s[0].position)&&(l=!0),this.isClosed=l,s};return this.points=o(e.curves),e instanceof ty&&(this.shapeHoles=e.holes.map(i=>{let s=new Ae;return s.fromShape(i),s})),this.update(),this}updatePoint(e,t){let o=this.getPointByUuid(e);o&&(t.position!==void 0&&o.position.fromArray(t.position),t.roundness!==void 0&&(o.roundness=t.roundness),t.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,t){let i=this.getPointByUuid(e)?.controls[0];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}updateNextControl(e,t){let i=this.getPointByUuid(e)?.controls[1];i&&(t.position&&i.position.fromArray(t.position),this.needsUpdate=!0)}};var Cu=Math.PI*2;function Au({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function iT(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),s=Math.sin(n+r);return[{x:t-o*e,y:o+t*e},{x:i+s*e,y:s-i*e},{x:i,y:s}]}function oy(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 sT(n,r,e,t,o,i,s,a,c,d){let l=Math.pow(o,2),u=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(a,2),m=l*u-l*f-u*p;m<0&&(m=0),m/=l*f+u*p,m=Math.sqrt(m)*(c===d?-1:1);let h=m*o/i*a,y=m*-i/o*s,g=h+(n+e)/2,x=y+(r+t)/2,S=(s-h)/o,w=(a-y)/i,b=(-s-h)/o,_=(-a-y)/i,P=oy(1,0,S,w),v=oy(S,w,b,_);return!d&&v>0&&(v-=Cu),d&&v<0&&(v+=Cu),{centerx:g,centery:x,ang1:P,ang2:v}}function ny({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:a}){let c=[];if(o===0||i===0)return[];let d=(n-e)/2,l=(r-t)/2;if(d===0&&l===0)return[];o=Math.abs(o),i=Math.abs(i);let u=Math.pow(d,2)/Math.pow(o,2)+Math.pow(l,2)/Math.pow(i,2);u>1&&(o*=Math.sqrt(u),i*=Math.sqrt(u));let p=sT(n,r,e,t,o,i,d,l,s,a),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(Cu/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(iT(f,m)),f+=m;return c.map(S=>{let{x:w,y:b}=Au(S[0],o,i,h,y),{x:_,y:P}=Au(S[1],o,i,h,y),{x:v,y:N}=Au(S[2],o,i,h,y);return{x1:w,y1:b,x2:_,y2:P,x:v,y:N}})}import{BufferAttribute as Il,BufferGeometry as yT}from"three";var we;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(we||(we={}));var 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 fe(n,r){if(!n)throw r||"Assertion Failed!"}var de=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){fe(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){fe(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){fe(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){fe(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 s,a,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)?(s=n.edgeEval(r,t,e),a=n.edgeEval(t,e,o),s+a<0&&(s=-s,a=-a),i.s=n.interpolate(s,t.s,a,e.s)):(s=n.edgeSign(r,t,e),a=-n.edgeSign(r,o,e),s+a<0&&(s=-s,a=-a),i.s=n.interpolate(s,t.s,a,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)?(s=n.transEval(r,t,e),a=n.transEval(t,e,o),s+a<0&&(s=-s,a=-a),i.t=n.interpolate(s,t.t,a,e.t)):(s=n.transSign(r,t,e),a=-n.transSign(r,o,e),s+a<0&&(s=-s,a=-a),i.t=n.interpolate(s,t.t,a,o.t)):i.t=(t.t+e.t)/2},n}(),Ns=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}(),Ol=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}(),di=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}(),iy=function(){function n(){var r=new di,e=new Ns,t=new Ol(0),o=new Ol(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 Ol(0),t=new Ol(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;fe(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 s=e;do s.Org=o,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;fe(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 s=e;do s.Lface=o,s=s.Lnext;while(s!==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,s=r.next;s.prev=i,i.next=s},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,s=r.next;s.prev=i,i.next=s},n.prototype.makeEdge=function(){var r=new di,e=new di,t=new Ns,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 di;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new Ns;this.makeFace_(s,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 Ns;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 di;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 s=new Ns;this.makeFace_(s,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,s,a;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);s=r.prev,a=r.next,a.prev=s,s.next=a},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,s,a,c;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(t=e.anEdge,s=t.Org;o=t.Lnext,i=t.Sym,i&&i.Lface&&i.Lface.inside&&(a=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),a+c-2<=r&&de.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&de.vertCCW(i.Lprev.Org,i.Org,t.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),t=null,i=null)),!(t&&t.Lnext.Org===s);)t=o;return!0},n.prototype.check=function(){var r=this.fHead,e=this.vHead,t=this.eHead,o,i,s,a,c,d;for(i=r,i=r;(o=i.next)!==r;i=o){fe(o.prev===i),c=o.anEdge;do fe(c.Sym!==c),fe(c.Sym.Sym===c),fe(c.Lnext.Onext.Sym===c),fe(c.Onext.Sym.Lnext===c),fe(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(fe(o.prev===i&&o.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){fe(s.prev===a),c=s.anEdge;do fe(c.Sym!==c),fe(c.Sym.Sym===c),fe(c.Lnext.Onext.Sym===c),fe(c.Onext.Sym.Lnext===c),fe(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(fe(s.prev===a&&s.anEdge===null),d=t,d=t;(c=d.next)!==t;d=c)fe(c.Sym.next===d.Sym),fe(c.Sym!==c),fe(c.Sym.Sym===c),fe(c.Org!==null),fe(c.Dst!==null),fe(c.Lnext.Onext.Sym===c),fe(c.Onext.Sym.Lnext===c);fe(c.Sym.next===d.Sym&&c.Sym===this.eHeadSym&&c.Sym.Sym===c&&c.Org===null&&c.Dst===null&&c.Lface===null&&c.Rface===null)},n}(),sy=function(){function n(){this.handle=null}return n}(),ay=function(){function n(){this.key=null,this.node=0}return n}(),aT=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 sy,this.handles[t]=new ay;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,s;for(o=e[r].handle;;){if(s=r<<1,s<this.size&&this.leq(t[e[s+1].handle].key,t[e[s].handle].key)&&++s,fe(s<=this.max),i=e[s].handle,s>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=s}},n.prototype.floatUp_=function(r){var e=this.nodes,t=this.handles,o,i,s;for(o=e[r].handle;;){if(s=r>>1,i=e[s].handle,s===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=s}},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 sy;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new ay}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;fe(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}(),Nu=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}(),ly=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),lT=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new ly,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 ly;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}(),cT=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,s=t.eUp;if(i.Dst===o)return s.Dst===o?de.vertLeq(i.Org,s.Org)?de.edgeSign(s.Dst,i.Org,s.Org)<=0:de.edgeSign(i.Dst,s.Org,i.Org)>=0:de.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return de.edgeSign(i.Dst,o,i.Org)>=0;var a=de.edgeEval(i.Dst,o,i.Org),c=de.edgeEval(s.Dst,o,s.Org);return a>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&fe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){fe(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 Nu;return o.eUp=t,o.nodeUp=r.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,t.activeRegion=o,o},n.isWindingInside=function(r,e){switch(r.windingRule){case we.ODD:return(e&1)!==0;case we.NONZERO:return e!==0;case we.POSITIVE:return e>0;case we.NEGATIVE:return e<0;case we.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(r,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(r,e.windingNumber)},n.finishRegion=function(r,e){var t=e.eUp,o=t.Lface;o.inside=e.inside,o.anEdge=t,n.deleteRegion(r,e)},n.finishLeftRegions=function(r,e,t){for(var o,i=null,s=e,a=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=a.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(a.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}a.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(a,o)),n.finishRegion(r,s),a=i.eUp,s=i}return a},n.addRightEdges=function(r,e,t,o,i,s){var a,c,d,l,u=!0;d=t;do fe(de.vertLeq(d.Org,d.Dst)),n.addRegionBelow(r,e,d.Sym),d=d.Onext;while(d!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),c=e,l=i;a=n.regionBelow(c),d=a.eUp.Sym,d.Org===l.Org;)d.Onext!==l&&(r.mesh.splice(d.Oprev,d),r.mesh.splice(l.Oprev,d)),a.windingNumber=c.windingNumber-d.winding,a.inside=n.isWindingInside(r,a.windingNumber),c.dirty=!0,!u&&n.checkForRightSplice(r,c)&&(n.addWinding(d,l),n.deleteRegion(r,c),r.mesh.delete(l)),u=!1,c=a,l=d;c.dirty=!0,fe(c.windingNumber-d.winding===a.windingNumber),s&&n.walkDirtyRegions(r,c)},n.spliceMergeVertices=function(r,e,t){r.mesh.splice(e,t)},n.vertexWeights=function(r,e,t){var o=de.vertL1dist(e,r),i=de.vertL1dist(t,r),s=.5*i/(o+i),a=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+a*t.coords[0],r.coords[1]+=s*e.coords[1]+a*t.coords[1],r.coords[2]+=s*e.coords[2]+a*t.coords[2]},n.getIntersectData=function(r,e,t,o,i,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,t,o),n.vertexWeights(e,i,s)},n.checkForRightSplice=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp;if(de.vertLeq(o.Org,i.Org)){if(de.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;de.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(de.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,s;if(fe(!de.vertEq(o.Dst,i.Dst)),de.vertLeq(o.Dst,i.Dst)){if(de.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=r.mesh.splitEdge(o),r.mesh.splice(i.Sym,s),s.Lface.inside=e.inside}else{if(de.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=t.dirty=!0,s=r.mesh.splitEdge(i),r.mesh.splice(o.Lnext,i.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(r,e){var t=n.regionBelow(e),o=e.eUp,i=t.eUp,s=o.Org,a=i.Org,c=o.Dst,d=i.Dst,l,u,p=new di,f,m;if(fe(!de.vertEq(d,c)),fe(de.edgeSign(c,r.event,s)<=0),fe(de.edgeSign(d,r.event,a)>=0),fe(s!==r.event&&a!==r.event),fe(!e.fixUpperEdge&&!t.fixUpperEdge),s===a||(l=Math.min(s.t,c.t),u=Math.max(a.t,d.t),l>u))return!1;if(de.vertLeq(s,a)){if(de.edgeSign(d,s,a)>0)return!1}else if(de.edgeSign(c,a,s)<0)return!1;return n.debugEvent(r),de.intersect(c,s,d,a,p),fe(Math.min(s.t,c.t)<=p.t),fe(p.t<=Math.max(a.t,d.t)),fe(Math.min(d.s,c.s)<=p.s),fe(p.s<=Math.max(a.s,s.s)),de.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=de.vertLeq(s,a)?s:a,de.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),de.vertEq(p,s)||de.vertEq(p,a)?(n.checkForRightSplice(r,e),!1):!de.vertEq(c,r.event)&&de.edgeSign(c,r.event,p)>=0||!de.vertEq(d,r.event)&&de.edgeSign(d,r.event,p)<=0?d===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):(de.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),de.edgeSign(d,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,s,c,a,d),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,s=n.regionBelow(e),a=e.eUp,c=s.eUp,d=!1;if(a.Dst!==c.Dst&&n.checkForIntersect(r,e),de.vertEq(a.Org,r.event)&&(r.mesh.splice(i.Oprev,a),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),d=!0),de.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,s,null),d=!0),d){n.addRightEdges(r,e,t.Onext,i,i,!0);return}de.vertLeq(c.Org,a.Org)?o=c.Oprev:o=a,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,s,a,c;if(o=e.eUp,de.vertEq(o.Org,t)){fe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!de.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}fe(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=a=s.Onext,c.fixUpperEdge&&(fe(i!==s),n.deleteRegion(r,c),r.mesh.delete(s),s=i.Oprev),r.mesh.splice(t.anEdge,s),de.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,s.Onext,a,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,a,c,d=new Nu;if(d.eUp=e.anEdge.Sym,t=r.dict.search(d).key,o=n.regionBelow(t),!!o){if(s=t.eUp,a=o.eUp,de.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=de.vertLeq(a.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var l=r.mesh.connect(a.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);fe(o!==null);var i=n.regionBelow(o),s=i.eUp,a=n.finishLeftRegions(r,i,null);a.Onext===s?n.connectRightVertex(r,o,a):n.addRightEdges(r,o,a.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new Nu,s=r.mesh.makeEdge();s.Org.s=t,s.Org.t=o,s.Dst.s=e,s.Dst.t=o,r.event=s.Dst,i.eUp=s,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 lT(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,s=r.bmin[1]-t,a=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,a)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(fe(e.fixUpperEdge),fe(++t===1)),fe(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,de.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 aT(i,de.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,fe(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||!de.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}(),uT=function(){function n(){this.mesh=new iy,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=we.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]},n.prototype.normalize_=function(r){var e=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),r[0]/=e,r[1]/=e,r[2]/=e},n.prototype.longAxis_=function(r){var e=0;return Math.abs(r[1])>Math.abs(r[0])&&(e=1),Math.abs(r[2])>Math.abs(r[e])&&(e=2),e},n.prototype.computeNormal_=function(r){var e,t,o,i,s,a,c=[0,0,0],d=[0,0,0],l=[0,0,0],u=[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],d[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<d[g]&&(d[g]=i,m[g]=e),i>c[g]&&(c[g]=i,f[g]=e);var x=0;if(c[1]-d[1]>c[0]-d[0]&&(x=1),c[2]-d[2]>c[x]-d[x]&&(x=2),d[x]>=c[x]){r[0]=0,r[1]=0,r[2]=1;return}for(a=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)u[0]=e.coords[0]-o.coords[0],u[1]=e.coords[1]-o.coords[1],u[2]=e.coords[2]-o.coords[2],p[0]=l[1]*u[2]-l[2]*u[1],p[1]=l[2]*u[0]-l[0]*u[2],p[2]=l[0]*u[1]-l[1]*u[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>a&&(a=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);a<=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,s=r.next;s!==r;s=s.next)if(o=s.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.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 s=this.longAxis_(e);t[s]=0,t[(s+1)%3]=1,t[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=e[s]>0?1:-1;for(var a=r.next;a!==r;a=a.next)a.s=this.dot_(a.coords,t),a.t=this.dot_(a.coords,o);i&&this.checkOrientation_();for(var c=!0,d=r.next;d!==r;d=d.next)c?(this.bmin[0]=this.bmax[0]=d.s,this.bmin[1]=this.bmax[1]=d.t,c=!1):(d.s<this.bmin[0]&&(this.bmin[0]=d.s),d.s>this.bmax[0]&&(this.bmax[0]=d.s),d.t<this.bmin[1]&&(this.bmin[1]=d.t),d.t>this.bmax[1]&&(this.bmax[1]=d.t))},n.prototype.addWinding_=function(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(;de.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;de.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(de.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(de.edgeGoesLeft(o.Lnext)||de.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&&(de.edgeGoesRight(t.Lprev)||de.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,s=0,a=0,c;t>3&&r.mergeConvexFaces(t);for(var d=r.vHead.next;d!==r.vHead;d=d.next)d.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 d=i.Org;d.n===-1&&(d.n=a,a++),c++,i=i.Lnext}while(i!==l.anEdge);if(c>t)throw"Face vertex greater that support polygon";l.n=s,++s}this.elementCount=s,e===ke.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var d=r.vHead.next;d!==r.vHead;d=d.next)if(d.n!==-1){var u=d.n*o;this.vertices[u+0]=d.coords[0],this.vertices[u+1]=d.coords[1],o>2&&(this.vertices[u+2]=d.coords[2]),this.vertexIndices[d.n]=d.idx}for(var p=0,l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){i=l.anEdge,c=0;do{var d=i.Org;this.elements[p++]=d.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,s=0;this.vertexCount=0,this.elementCount=0;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){o=t=a.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,d=0,l=0;i=0;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){s=0,o=t=a.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[d++]=this.vertexIdCallback?this.vertexIdCallback(t):t.Org.idx,s++,t=t.Lnext;while(t!==o);this.elements[l++]=i,this.elements[l++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new iy),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,s){if(r===void 0&&(r=we.ODD),e===void 0&&(e=ke.POLYGONS),s===void 0&&(s=!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_(),cT.computeInterior(this,s);var a=this.mesh;return e===ke.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===ke.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,e,t,o),!0},n}();function dr(n){var r=n.windingRule,e=r===void 0?we.ODD:r,t=n.elementType,o=t===void 0?ke.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,a=n.vertexSize,c=a===void 0?2:a,d=n.normal,l=d===void 0?[0,0,1]:d,u=n.contours,p=u===void 0?[]:u,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 uT;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,s,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 PF=we.ODD,TF=we.NONZERO,OF=we.POSITIVE,AF=we.NEGATIVE,CF=we.ABS_GEQ_TWO,NF=ke.POLYGONS,IF=ke.CONNECTED_POLYGONS,MF=ke.BOUNDARY_CONTOURS;import{BufferAttribute as Nl,BufferGeometry as hT}from"three";var Al=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*Al.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*Al.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let d=new Float32Array(o,s*i,2*r);e?(a.set(this.positions.subarray(0,this.size*3)),c.set(this.normals.subarray(0,this.size*3)),d.set(this.uvs.subarray(0,this.size*2))):(a.set(this.positions),c.set(this.normals),d.set(this.uvs)),this.buffer=o,this.positions=a,this.normals=c,this.uvs=d,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)}},Is=Al;Is.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var py=ss(dy()),Ms={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Du={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Bu={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},Lu=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Eo=class extends hT{constructor(e,t,o=0,i=12,s=3,a=we.ODD,c=!1){super();this.forPathBevel=c;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._curveSegments=i,this._bevelSegmentsInput=s;let d=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}),u=[],p=[];for(let C=0;C<d.length;C+=2)p.push([d[C],d[C+1]]);u.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]]);u.push(A)}let f=u[0].length?(0,py.default)(u).distance:o;o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,t/2),this._bevelSegments=Math.floor(s));let m;try{m=dr({windingRule:a,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[d]})}catch{m=Ms}let h;try{h=dr({windingRule:we.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{h=Du}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 Is(this._computeBufferEstimatedSize(m));let b=[],_=[];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 ae=j-oe,ne=D-ee,ie=Math.sqrt(ae*ae+ne*ne);ae/=ie,ne/=ie,R.normals[U*2+0]=-ne,R.normals[U*2+1]=ae,R.concave[U]=K*ne-te*ae>0;let ce=m.vertexIndices[Z];if(Array.isArray(ce))R.continuous[U]=!1;else{let[le,ue]=this._shape.getCurveIndexFromVertexId(ce-1,!0);if(ue>0&&ue<1)R.continuous[U]=!0;else{let me=ue===1?le+1:le-1;me=(me+W)%W;let _e=ue===1?0:1,Ve=this._shape.roundedCurves[le].getTangent(ue),Pe=this._shape.roundedCurves[me].getTangent(_e);R.continuous[U]=Ve.dot(Pe)>.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 ae=Q*2,ne=(Q-1+L)%L*2,ie=m.vertices[R.start*2+ae+0],ce=m.vertices[R.start*2+ae+1],le=-R.normals[ne+0]*F,ue=-R.normals[ne+1]*F,me=-R.normals[ae+0]*F,_e=-R.normals[ae+1]*F;if(R.concave[Q]||!R.concave[Q]&&O){let Ve=Math.atan2(ue,le),Pe=Math.atan2(_e,me);Pe>Ve&&(Pe-=Math.PI*2);let De=Pe-Ve;if(R.continuous[Q]||O){let Et=Ve+De/2,ve=Math.cos(Et)*F,Je=Math.sin(Et)*F;j[2*K+0]=ie+ve*(O?-1:1),j[2*K+1]=ce+Je*(O?-1:1),ee[K]=Q,K++}else{let Et=Math.max(1,Math.floor(i/4*Math.abs(De)/Math.PI));for(let ve=0;ve<=Et;ve++){let Je=Ve+De*(ve/Et),nt=Math.cos(Je)*F,xn=Math.sin(Je)*F;j[2*K+0]=ie+nt,j[2*K+1]=ce+xn,ee[K]=Q,K++}}}else j[2*K+0]=ie+le,j[2*K+1]=ce+ue,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+me,j[2*K+1]=ce+_e,ee[K]=Q,oe[Q]=K,K++}let te=dr({windingRule:we.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 ae=Q.Lprev.idx;return[ae?ae[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[ae,ne]=te.vertexIndices[Q];if(ae===ne)continue;let ie=ne;ne<ae&&(ie+=L);for(let ce=ae;ce<ie;ce++){let le=ce%L,ue=(ce+1)%L;if(!R.continuous[le]||!R.continuous[ue]){te.vertexIndices[Q]=[ae,le],te.vertexIndices.splice(Q+1,0,[ue,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=Lu(ee,L);for(;!B.boundary.vertexIndices.filter(K).length||!F.boundary.vertexIndices.filter(K).length;)ee++,K=Lu(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 ae=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,ue=ce,me,_e,Ve=!1;do{ne=(ee||oe)/oe,K=Lu(ee,L);let Pe=q(B,te,K),De=q(F,Q,K),Et=Ve;if(Ve=!1,Pe&&!De){for(let ve=0;ve<Pe;ve++)me=this._buildBevelVert(R,B,(te+ve)%j,ve/(Pe-1),ne),b.push(le.topN,me.topP,ue.topN),c===!1&&b.push(me.bottomP,le.bottomN,ue.bottomN),le=me;Ve=!0}else if(!Pe&&De)for(let ve=0;ve<De;ve++)_e=this._buildBevelVert(R,F,(Q+ve)%D,ve/(De-1),ne),b.push(ue.topN,le.topP,_e.topP),c===!1&&b.push(le.bottomP,ue.bottomN,_e.bottomP),ue=_e;else if(Pe&&De)if(me=this._buildBevelVert(R,B,te,0,ne),_e=this._buildBevelVert(R,F,Q,0,ne),Et?(b.push(le.topN,_e.topP,ue.topN),b.push(le.topN,me.topP,_e.topP),c===!1&&(b.push(_e.bottomP,le.bottomN,ue.bottomN),b.push(_e.bottomP,me.bottomP,le.bottomN))):(b.push(ue.topN,le.topN,me.topP),b.push(ue.topN,me.topP,_e.topP),c===!1&&(b.push(me.bottomP,le.bottomN,ue.bottomN),b.push(me.bottomP,ue.bottomN,_e.bottomP))),le=me,ue=_e,Pe===De)for(let ve=1;ve<Pe;ve++)me=this._buildBevelVert(R,B,(te+ve)%j,ve/(Pe-1),ne),_e=this._buildBevelVert(R,F,(Q+ve)%D,ve/(De-1),ne),b.push(le.topN,me.topP,ue.topN),b.push(ue.topN,me.topP,_e.topP),c===!1&&(b.push(me.bottomP,le.bottomN,ue.bottomN),b.push(me.bottomP,ue.bottomN,_e.bottomP)),le=me,ue=_e;else if(Pe>De){let ve=Pe/De,Je=0;for(let nt=1;nt<Pe;nt++)me=this._buildBevelVert(R,B,(te+nt)%j,nt/(Pe-1),ne),b.push(le.topN,me.topP,ue.topN),c===!1&&b.push(me.bottomP,le.bottomN,ue.bottomN),le=me,nt>(Je+1)*ve&&(Je++,_e=this._buildBevelVert(R,F,(Q+Je)%D,Je/(De-1),ne),b.push(ue.topN,me.topP,_e.topP),c===!1&&b.push(me.bottomP,ue.bottomN,_e.bottomP),ue=_e)}else{let ve=De/Pe,Je=0;for(let nt=1;nt<De;nt++)_e=this._buildBevelVert(R,F,(Q+nt)%D,nt/(De-1),ne),b.push(ue.topN,me.topP,_e.topP),c===!1&&b.push(me.bottomP,ue.bottomN,_e.bottomP),ue=_e,nt>(Je+1)*ve&&(Je++,me=this._buildBevelVert(R,B,(te+Je)%j,Je/(Pe-1),ne),b.push(le.topN,me.topP,ue.topN),c===!1&&b.push(me.bottomP,le.bottomN,ue.bottomN),le=me)}te=(te+Pe)%j,Q=(Q+De)%D,ee=(ee+1)%oe}while(ee!==ae)}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)}_.push(U)}if(!O){let U=$[$.length-1],B;try{B=dr({windingRule:$.length>1?we.POSITIVE:we.ODD,elementType:ke.POLYGONS,vertexSize:2,strict:!0,contours:[U.insetPoints,..._]})}catch{B=Bu}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 P=new Nl(Uint32Array.from(b),1),v=new Nl(this._buffer.positions,3),N=new Nl(this._buffer.normals,3),T=new Nl(this._buffer.uvs,2);v.needsUpdate=!0,N.needsUpdate=!0,T.needsUpdate=!0,P.needsUpdate=!0,this.setAttribute("position",v),this.setAttribute("normal",N),this.setAttribute("uv",T),this.setIndex(P)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,a=i.boundary.vertexCount;s<a;s++){let c=this._buildBevelVert(t,i,s),d=this._buildBevelVert(t,i,(s+1)%a);o.push(d.topP,c.topN,c.bottomN),o.push(d.topP,c.bottomN,d.bottomP)}}_buildSurfaceVert(e,t,o){let i=t.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=e.vertices[t*2+0],a=e.vertices[t*2+1],c=(s-this._minX)/this._width,d=(a-this._minY)/this._height;this.forPathBevel&&(d=1);let l=this._buffer.get(this.forPathBevel?1:2),u=l*3,p=l*2,f={top:l+0,bottom:l+1};return this._buffer.positions[u+0]=s,this._buffer.positions[u+1]=a,this._buffer.positions[u+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[u+0]=0,this._buffer.normals[u+1]=0,this._buffer.normals[u+2]=1,this._buffer.uvs[p+0]=c,this._buffer.uvs[p+1]=d,this.forPathBevel===!1&&(this._buffer.positions[u+3]=s,this._buffer.positions[u+4]=a,this._buffer.positions[u+5]=o,this._buffer.normals[u+3]=0,this._buffer.normals[u+4]=0,this._buffer.normals[u+5]=-1,this._buffer.uvs[p+2]=c,this._buffer.uvs[p+3]=d),this.vertexCache[i]=f,f}_buildBevelVert(e,t,o,i=1,s){let a=`${t.bevelI}:${o}`;if(a in this.vertexCache&&s!==0&&s!==1&&(!s||s===this.vertexCache[a].pathBevelUCoord))return this.vertexCache[a];let[c,d]=t.boundary.vertexIndices[o],l,u,p,f;c!==d?(u=c,l=d,f=!1,p=e.continuous[u]&&e.continuous[l]):(l=c,u=(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=u*2,S=t.boundary.vertices[y+0],w=t.boundary.vertices[y+1],b=(1-h)*this._bevel,_=(S-this._minX)/this._width,P=(w-this._minY)/this._height;this.forPathBevel&&(s!==void 0&&(_=s),P=1);let v=e.normals[g+0],N=e.normals[g+1],T=e.normals[x+0],C=e.normals[x+1];if(f){let X=T-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:s};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]=_,this._buffer.uvs[M+1]=P,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]=P,this._buffer.uvs[M+3]=_),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]=T*m,this._buffer.normals[A+1]=C*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=_,this._buffer.uvs[M+1]=P,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]=T*m,this._buffer.normals[A+4]=C*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=P,this._buffer.uvs[M+3]=_)),this.vertexCache[a]=L,L}clone(){let e=new Eo(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zr(this.userData),e}};var pi=class extends yT{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=we.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:we.ODD,elementType:ke.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,c=!0,d=!0,l,u;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),u!==void 0&&x!==u&&(d=!1),l=g,u=x,!c&&!d)break}if(!c&&!d)try{a=dr({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{a=Ms}let p=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Il(new Float32Array(p*3),3),this._normalAttribute=new Il(new Float32Array(p*3),3),this._uvAttribute=new Il(new Float32Array(p*2),2),this._indexAttribute=new Il(new Uint32Array(f*3),1),a){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,b=p;w<b;w++){let _=w*2,P=a.vertices[_+0],v=a.vertices[_+1];P<m&&(m=P),P>h&&(h=P),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 _=w*2,P=a.vertices[_+0],v=a.vertices[_+1],N=(P-m)/x,T=(v-y)/S;this._positionAttribute.setXYZ(w,P,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,N,T)}for(let w=0,b=f;w<b;w++){let _=w*3,P=a.elements[_+0],v=a.elements[_+1],N=a.elements[_+2];this._indexAttribute.setX(_+0,P),this._indexAttribute.setX(_+1,v),this._indexAttribute.setX(_+2,N)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let e=new pi(this._shape,this._curveSegments);return e.userData=Zr(this.userData),e}};var fi=class extends Eo{constructor(e,t,o=0,i=12,s=3,a=we.ODD){super(e,t,o,i,s,a);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,a=i.boundary.vertexCount;s<a;s++){let c=this._buildBevelVert(t,i,s),d=this._buildBevelVert(t,i,(s+1)%a);o.push(d.topP,c.topN,c.bottomN),o.push(d.topP,c.bottomN,d.bottomP)}}clone(){let e=new fi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zr(this.userData),e}};var Rt=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=Object.assign({},r?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:we.ODD},n.parameters),t=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),s=n.shape??r?.shape,a=s?.roundness??e.roundness;s!==void 0&&(s instanceof Ae?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new Ae(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new Ae(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:a}),shape:c}}static build(n){let{depth:r,extrudeBevelSize:e,extrudeBevelSegments:t,subdivisions:o,roundness:i,windingRule:s}=n.parameters;n.shape.roundness=i;let a;return r<=0?a=new pi(n.shape,o,{windingRule:s}):a=new fi(n.shape,r,e,o,t,s),Object.assign(a,{userData:{...n,type:"VectorGeometry"}})}};import{MathUtils as my,Vector2 as hy}from"three";var yy=Math.PI*2,hi=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{shape:n.shape&&n.shape instanceof Ae?n.shape:new Ae,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:s,extrudeBevelSize:a,extrudeBevelSegments:c}=n.parameters,d=n.shape,l=r*.5,u=e*.5,p=gT(d,l,u,o*Math.PI/180,t,i);d.isClosed=!0,d.update();let f=Rt.create({shape:d,parameters:{subdivisions:p,depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function gT(n,r,e,t,o,i){if(t>=yy)return o>30||o%4===0?(vT(n,r,e,i),Math.round(o/4)):fy(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},a=t+Math.PI*.5,c={x:Math.cos(a)*r,y:Math.sin(a)*e},d=ny({px:s.x,py:s.y,cx:c.x,cy:c.y,rx:r,ry:e,largeArcFlag:t>Math.PI,sweepFlag:!0});return o>30||o%d.length===0?xT(n,s.x,s.y,d,o,r,e,i):fy(n,t,o,r,e,i)}function xT(n,r,e,t,o,i,s,a){let c=Math.round(o/t.length);n.addPoint(mi(r,e));for(let d=0,l=t.length;d<l;d++){let u=t[d],p=n.points[d],f=mi(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),f.controls[0].position.set(u.x2,u.y2),n.addPoint(f)}return a>0?gy(n,i,s,a):n.addPoint(mi(0,0)),c}function fy(n,r,e,t,o,i){let s=-r/e;for(let a=0;a<=e;a++){let c=s*a,d=Math.sin(c)*t,l=Math.cos(c)*o;n.addPoint(mi(d,l))}return r<yy?i>0?gy(n,t,o,i):n.addPoint(mi(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&xy(n,t,o,i)),1}function vT(n,r,e,t=0,o=0,i=0){let s=.5522847498,a=r*s,c=e*s;n.addPoint(Ml(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(Ml(o,i+e,o-a,i+e,o+a,i+e)),n.addPoint(Ml(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(Ml(o,i-e,o+a,i-e,o-a,i-e)),t>0&&xy(n,r,e,t)}function mi(n,r){return new ur(my.generateUUID(),new hy(n,r))}function Ml(n,r,e,t,o,i){let s=mi(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function gy(n,r,e,t){vy(n,r,e,t).forEach(i=>n.addPoint(i))}function xy(n,r,e,t){let o=vy(n,r,e,t),i=new Ae;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function vy(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new hy(o/r,i/e),a=n.points.map(c=>{let d=c.clone();return d.uuid=my.generateUUID(),d}).reverse();return a.forEach(c=>{c.position.multiply(s);let d=c.controls[0].position.clone().multiply(s),l=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(l),c.controls[1].position.copy(d)}),a}import{BufferGeometry as bT,Float32BufferAttribute as Ru,Uint32BufferAttribute as ST,Vector3 as by}from"three";var Sy=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),s=Math.abs(Math.min(t,i))/2;return{parameters:Object.assign(e,{width:t,height:o,depth:i,radius:s,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:s,pathRadius:a,pathType:c,pathSegments:d,cornerRadius:l,cornerSegments:u}=n.parameters,p=new Es(!1,r,e,t,o,i,s,a,c,d,l,u);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Gu=new ST([0,0,0],1),Es=class extends bT{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,a=1,c=1,d=1,l=1,u=1,p=1){if(super(),s===0)return;let f=r&&s===1;f&&(p=0),u>100&&(u=100),u===0&&(p=0);let m=()=>new by,h=new by,y=m(),g=m(),x=m(),S,w,b,_,P,v,N,T,C=m(),O=m(),A=m(),M=m(),L=m(),X=m(),R=m(),Z=m(),z=t-2*c+.001,V=z/s,W=Math.ceil(a*s),$=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-u/100)*c,c-F),D=c-j,oe=0,ee=2,K=p*ee+ee,te=k*K/ee,Q=te+k*$,ae=k*($+K),[ne,ie,ce]=[3,3,2].map($e=>Array(ae*$e).fill(0)),le=[],ue=i-c;function me($e,Ft){let vr=Math.PI/2;v=Ft*Y,T=2*Math.PI*(v%V)/V+vr,v+=q,N=Math.sin(T)*ue,P=Math.cos(T)*ue,r?$e.set(P,N,v):$e.set(P,v,N)}me(h,-1e-10),me(y,0),C.copy(h),me(h,1);let _e=h.distanceTo(y),Ve=f?0:D+j,Pe=_e*W+2*Ve,De=j,Et=Pe-Ve;for(let $e=0;$e<=W;$e++){me(g,$e),Z.subVectors(g,C).normalize(),C.copy(g),X.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(Z,X).normalize();let Ft=$e===0,vr=$e===W,q0=Ft?3*Math.PI/2:B,$0=Ft?De:Et,Y0=Ft?k:Q,X0=Ft?0:ae-k,K0=Z.clone().multiplyScalar(Ft?-D:D).add(g),Z0=Z.clone().multiplyScalar(Ft?-1:1).normalize();for(let qr=0;qr<k;qr++){let Xd=qr*U;if(O.addVectors(h.copy(X).multiplyScalar(c*Math.cos(Xd)),y.copy(R).multiplyScalar(c*Math.sin(Xd))),A.copy(O).normalize(),Ft||vr){f||(oe=X0+qr,[0,1,2].forEach(Lt=>{ne[oe*3+Lt]=K0.getComponent(Lt),ie[oe*3+Lt]=Z0.getComponent(Lt)}),ce[oe*2]=+vr,ce[oe*2+1]=qr/l),y.copy(A).multiplyScalar(j),x.addVectors(g,y);for(let Lt=0;Lt<p;Lt++){let Sc=Lt*B+q0;M.addVectors(h.copy(Z).multiplyScalar(D*Math.sin(Sc)),y.copy(A).multiplyScalar(D*Math.cos(Sc))),L.copy(M).normalize(),y.addVectors(x,M),M.normalize(),oe=Y0+Lt*k+qr,[0,1,2].forEach(la=>{ne[oe*3+la]=y.getComponent(la),ie[oe*3+la]=L.getComponent(la)});let Q0=+Ft+Math.sin(Sc);ce[oe*2]=($0+D*Q0)/Pe,ce[oe*2+1]=qr/l}}y.addVectors(g,O),oe=te+$e*k+qr,[0,1,2].forEach(Lt=>{ne[oe*3+Lt]=y.getComponent(Lt),ie[oe*3+Lt]=A.getComponent(Lt)}),ce[oe*2]=(Ve+$e*_e)/Pe,ce[oe*2+1]=qr/l}}let ve=$+2*p+ee,Je=1,[nt,xn]=[+f,ve-1];for(let $e=nt;$e<=xn-1;$e++){let Ft=f&&$e===xn-1;for(let vr=0;vr<k-1;vr++)S=$e*k+vr,w=S+1,b=(Ft?vr:S)+k,_=(Ft?vr+1:w)+k,$e===0?le.push(w,_,b):$e===ve-2?le.push(S,w,b):le.push(S,w,b,w,_,b)}this.setIndex(le),this.setAttribute("position",new Ru(ne,3)),this.setAttribute("normal",new Ru(ie,3)),this.setAttribute("uv",new Ru(ce,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,s,a,c,d=6*(e-1)*r.radialSegments,l=e,u=l===e;for(let p=0;p<r.radialSegments;p++)i=l*t+p,s=i+1,a=(u?p:i)+t,c=(u?p+1:s)+t,o[d++]=i,o[d++]=s,o[d++]=a,o[d++]=s,o[d++]=c,o[d++]=a;return o.length=d,Gu.array=o,Gu.count=o.length,Gu}};import{IcosahedronGeometry as wT}from"three";var wy=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:s}=n.parameters,a=o===0&&i!==0?new Ls(r*.5,i,s):new wT(r*.5,o);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"IcosahedronGeometry"}})}},Ls=class extends No{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],s=[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],a="IcosahedronGeometry";super(i,s,a,r,e,t),this.type=a}static fromJSON(r){return new Ls(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as _T,Shape as PT}from"three";var _y=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 PT;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 _T(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as My,BufferGeometryLoader as RT,Vector3 as GT,BoxGeometry as Ey}from"three";import{BufferGeometry as ET,Vector2 as Fu,Vector3 as Iy}from"three";import{Box3 as TT,BufferAttribute as Ds,BufferGeometry as Py,Color as ju,EventDispatcher as OT,Float32BufferAttribute as yi,Matrix3 as Ty,Matrix4 as Ny,MathUtils as AT,Object3D as CT,Sphere as NT,Vector2 as qt,Vector3 as xt,Vector4 as IT}from"three";var Er=new Ny,Vu=new CT,El=new xt,Lo=class extends OT{constructor(){super(),this.uuid=AT.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 Ty().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 s=0,a=i.vertexNormals.length;s<a;s++)i.vertexNormals[s].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(r){return Er.makeRotationX(r),this.applyMatrix4(Er),this}rotateY(r){return Er.makeRotationY(r),this.applyMatrix4(Er),this}rotateZ(r){return Er.makeRotationZ(r),this.applyMatrix4(Er),this}translate(r,e,t){return Er.makeTranslation(r,e,t),this.applyMatrix4(Er),this}scale(r,e,t){return Er.makeScale(r,e,t),this.applyMatrix4(Er),this}lookAt(r){return Vu.lookAt(r),Vu.updateMatrix(),this.applyMatrix4(Vu.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,s=o.normal,a=o.color,c=o.uv,d=o.uv2;d!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new xt().fromBufferAttribute(i,p)),a!==void 0&&e.colors.push(new ju().fromBufferAttribute(a,p));function l(p,f,m,h){let y=a===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new xt().fromBufferAttribute(s,p),new xt().fromBufferAttribute(s,f),new xt().fromBufferAttribute(s,m)],x=new gi(p,f,m,g,y,h);e.faces.push(x),c!==void 0&&e.faceVertexUvs[0].push([new qt().fromBufferAttribute(c,p),new qt().fromBufferAttribute(c,f),new qt().fromBufferAttribute(c,m)]),d!==void 0&&e.faceVertexUvs[1].push([new qt().fromBufferAttribute(d,p),new qt().fromBufferAttribute(d,f),new qt().fromBufferAttribute(d,m)])}let u=r.groups;if(u.length>0)for(let p=0;p<u.length;p++){let f=u[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(El).negate(),this.translate(El.x,El.y,El.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new Ny;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 xt,e=new xt;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],a=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,a),e.subVectors(s,a),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 xt;if(r){let t=new xt,o=new xt;for(let i=0,s=this.faces.length;i<s;i++){let a=this.faces[i],c=this.vertices[a.a],d=this.vertices[a.b],l=this.vertices[a.c];t.subVectors(l,d),o.subVectors(c,d),t.cross(o),e[a.a].add(t),e[a.b].add(t),e[a.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],s=i.vertexNormals;s.length===3?(s[0].copy(e[i.a]),s[1].copy(e[i.b]),s[2].copy(e[i.c])):(s[0]=e[i.a].clone(),s[1]=e[i.b].clone(),s[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,s=o.vertexNormals.length;i<s;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let r=new Lo;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,s=this.morphNormals[e].vertexNormals;for(let a=0,c=this.faces.length;a<c;a++){let d=new xt,l={a:new xt,b:new xt,c:new xt};i.push(d),s.push(l)}}let o=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals(),r.computeVertexNormals();for(let i=0,s=this.faces.length;i<s;i++){let a=this.faces[i],c=o.faceNormals[i],d=o.vertexNormals[i];c.copy(a.normal),d.a.copy(a.vertexNormals[0]),d.b.copy(a.vertexNormals[1]),d.c.copy(a.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 TT),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new NT),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,s=this.vertices,a=r.vertices,c=this.faces,d=r.faces,l=this.colors,u=r.colors;e!==void 0&&(o=new Ty().getNormalMatrix(e));for(let p=0,f=a.length;p<f;p++){let h=a[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=u.length;p<f;p++)l.push(u[p].clone());for(let p=0,f=d.length;p<f;p++){let m=d[p],h,y,g=m.vertexNormals,x=m.vertexColors,S=new gi(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,d=this.vertices.length;c<d;c++){let l=this.vertices[c],u=Math.round(l.x*i)+"_"+Math.round(l.y*i)+"_"+Math.round(l.z*i);e[u]===void 0?(e[u]=c,t.push(this.vertices[c]),o[c]=t.length-1):o[c]=o[e[u]]}let s=[];for(let c=0,d=this.faces.length;c<d;c++){let l=this.faces[c];l.a=o[l.a],l.b=o[l.b],l.c=o[l.c];let u=[l.a,l.b,l.c];for(let p=0;p<3;p++)if(u[p]===u[(p+1)%3]){s.push(c);break}}for(let c=s.length-1;c>=0;c--){let d=s[c];this.faces.splice(d,1);for(let l=0,u=this.faceVertexUvs.length;l<u;l++)this.faceVertexUvs[l].splice(d,1)}let a=this.vertices.length-t.length;return this.vertices=t,a}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new xt(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,d){return c.materialIndex-d.materialIndex}r.sort(t);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],s,a;o&&o.length===e&&(s=[]),i&&i.length===e&&(a=[]);for(let c=0;c<e;c++){let d=r[c]._id;s&&s.push(o[d]),a&&a.push(i[d])}s&&(this.faceVertexUvs[0]=s),a&&(this.faceVertexUvs[1]=a)}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={},s=[],a={},c=[],d={};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,_=h.vertexColors.length>0,P=0;if(P=l(P,0,0),P=l(P,1,y),P=l(P,2,g),P=l(P,3,x),P=l(P,4,S),P=l(P,5,w),P=l(P,6,b),P=l(P,7,_),t.push(P),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(u(h.normal)),w){let v=h.vertexNormals;t.push(u(v[0]),u(v[1]),u(v[2]))}if(b&&t.push(p(h.color)),_){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 u(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 a[h]!==void 0||(a[h]=s.length,s.push(m.getHex())),a[h]}function f(m){let h=m.x.toString()+m.y.toString();return d[h]!==void 0||(d[h]=c.length/2,c.push(m.x,m.y)),d[h]}return r.data={},r.data.vertices=e,r.data.normals=o,s.length>0&&(r.data.colors=s),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new Lo().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 s=r.morphNormals;for(let p=0,f=s.length;p<f;p++){let m={};if(s[p].vertexNormals!==void 0){m.vertexNormals=[];for(let h=0,y=s[p].vertexNormals.length;h<y;h++){let g=s[p].vertexNormals[h],x={};x.a=g.a.clone(),x.b=g.b.clone(),x.c=g.c.clone(),m.vertexNormals.push(x)}}if(s[p].faceNormals!==void 0){m.faceNormals=[];for(let h=0,y=s[p].faceNormals.length;h<y;h++)m.faceNormals.push(s[p].faceNormals[h].clone())}this.morphNormals.push(m)}let a=r.skinWeights;for(let p=0,f=a.length;p<f;p++)this.skinWeights.push(a[p].clone());let c=r.skinIndices;for(let p=0,f=c.length;p<f;p++)this.skinIndices.push(c[p].clone());let d=r.lineDistances;for(let p=0,f=d.length;p<f;p++)this.lineDistances.push(d[p]);let l=r.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=r.boundingSphere;return u!==null&&(this.boundingSphere=u.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 zu().fromGeometry(this),e=new Py,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Ll.call(new Ds(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Ll.call(new Ds(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",Oy.call(new Ds(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Ay.call(new Ds(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Ay.call(new Ds(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let a=0,c=s.length;a<c;a++){let d=s[a],l=new yi(d.data.length*3,3);l.name=d.name,i.push(Ll.call(l,d.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new yi(r.skinIndices.length*4,4);e.setAttribute("skinIndex",Cy.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new yi(r.skinWeights.length*4,4);e.setAttribute("skinWeight",Cy.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 Py,t=r.geometry;if(r.isPoints||r.isLine){let o=new yi(t.vertices.length*3,3),i=new yi(t.colors.length*3,3);if(e.setAttribute("position",Ll.call(o,t.vertices)),e.setAttribute("color",Oy.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new yi(t.lineDistances.length,1);e.setAttribute("lineDistance",MT.call(s,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}};Lo.prototype.isGeometry=!0;var zu=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,s=r.faces;for(o=0;o<s.length;o++){let a=s[o];a.materialIndex!==i&&(i=a.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,s=o[1]&&o[1].length>0,a=r.morphTargets,c=a.length,d;if(c>0){d=[];for(let g=0;g<c;g++)d[g]={name:a[g].name,data:[]};this.morphTargets.position=d}let l=r.morphNormals,u=l.length,p;if(u>0){p=[];for(let g=0;g<u;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 qt,new qt,new qt))}if(s===!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 qt,new qt,new qt))}for(let b=0;b<c;b++){let _=a[b].vertices;d[b].data.push(_[x.a],_[x.b],_[x.c])}for(let b=0;b<u;b++){let _=l[b].vertexNormals[g];p[b].data.push(_.a,_.b,_.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}},gi=class{constructor(r,e,t,o,i,s=0){this.a=r,this.b=e,this.c=t,this.normal=o&&o.isVector3?o:new xt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new ju,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=s}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 MT(n){return this.array.set(n),this}function Oy(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 ju),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function Ay(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 qt),r[e++]=i.x,r[e++]=i.y}return this}function Ll(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 xt),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function Cy(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 IT),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var LT=["a","b","c"];function DT(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function ku(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Uu(n,r,e,t,o,i){let s=Math.min(n,r),a=Math.max(n,r),c=s+"_"+a,d;if(t.has(c))d=t.get(c);else{let l=e[s],u=e[a];d={a:l,b:u,newEdge:null,faces:[]},t.set(c,d)}d.faces.push(o),i[n].edges.push(d),i[r].edges.push(d)}function BT(n,r,e,t){let o,i,s;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=r.length;o<i;o++)s=r[o],Uu(s.a,s.b,n,t,s,e),Uu(s.b,s.c,n,t,s,e),Uu(s.c,s.a,n,t,s,e)}function Dl(n,r,e,t,o){n.push(new gi(r,e,t,void 0,void 0,o))}function xi(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Bl(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Rl=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof ET?r=new Lo().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 Iy,t,o,i,s,a,c=r.vertices,d=r.faces,l=r.faceVertexUvs[0],u=l!==void 0&&l.length>0,p=[],f=new Map;BT(c,d,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 Iy,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),s=0;s<b;s++){for(x=y.faces[s],a=0;a<3&&(h=c[DT(x,LT[a])],!(h!==y.a&&h!==y.b));a++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let _,P,v,N,T,C,O,A=[];for(o=0,i=c.length;o<i;o++){for(C=c[o],T=p[o].edges,t=T.length,t==3?_=3/16:t>3&&(_=3/(8*t)),P=1-t*Number(_),v=_,t<=2&&(t==2?(P=3/4,v=1/8):t==1||t==0),O=C.clone().multiplyScalar(P),e.set(0,0,0),s=0;s<t;s++)N=T[s],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 Fu,U=new Fu,B=new Fu;for(o=0,i=d.length;o<i;o++)x=d[o],X=Number(ku(x.a,x.b,f).newEdge)+L,R=Number(ku(x.b,x.c,f).newEdge)+L,Z=Number(ku(x.c,x.a,f).newEdge)+L,Dl(z,X,R,Z,x.materialIndex),Dl(z,x.a,X,Z,x.materialIndex),Dl(z,x.b,R,X,x.materialIndex),Dl(z,x.c,Z,R,x.materialIndex),u&&(W=l[o],$=W[0],Y=W[1],q=W[2],k.set(xi($.x,Y.x),xi($.y,Y.y)),U.set(xi(Y.x,q.x),xi(Y.y,q.y)),B.set(xi($.x,q.x),xi($.y,q.y)),Bl(V,k,U,B),Bl(V,$,k,B),Bl(V,Y,U,k),Bl(V,q,B,U));r.vertices=M,r.faces=z,u&&(r.faceVertexUvs[0]=V)}};var tt=new GT,Ly=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new My().copy(new Ey(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(tt),t={width:tt.x,height:tt.y,depth:tt.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 My().copy(new Ey(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(tt)):tt.set(s.width,s.height,s.depth),(r!==tt.x||e!==tt.y||t!==tt.z)&&i.scale(tt.x===0?1:r/tt.x,tt.y===0?1:e/tt.y,tt.z===0?1:t/tt.z);let a=i.originalGeometry;try{o>0?(a===void 0||s?.subdivisions!==o)&&(a===void 0&&(a=i),i=new Rl(o).modify(a).toBufferGeometry()):(a!==void 0&&(i=a),a=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{a!==void 0&&(i=a),a=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return a!==void 0&&Object.assign(i,{originalGeometry:a}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new RT(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(tt);let s=100/tt.x;Object.assign(i.parameters,{width:100,height:tt.y*s,depth:tt.z*s}),r(this.build(i))})}};var Gl=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 Ae?n.shape:new Ae,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:s,extrudeBevelSegments:a}=n.parameters,c=n.shape,d=r*.5,l=e*.5,u=0,p=0,f=2*Math.PI/t;for(let h=0;h<t;h++){let y=f*h,g=u+Math.sin(y)*d,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=Rt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as VT,Float32BufferAttribute as Hu,Vector2 as Lr,Vector3 as lt}from"three";var Dy=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:s,cornerRadius:a,cornerSegments:c}=n.parameters,d=new qu(r*.5,e,o,i,s,a,c);return d.scale(1,1,t/r),Object.assign(d,{userData:{...n,type:"PyramidGeometry"}})}};function Bs(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Wu(n,r,e,t,o,i){let s=r.clone().sub(n),a=e.clone().sub(n),c=s.angleTo(a);if(s.normalize(),a.normalize(),t===o){let d=s.add(a).normalize();i.copy(n).addScaledVector(d,t/Math.sin(c/2))}else{let d=s.angleTo(a);i.copy(n),i.addScaledVector(s,o/Math.sin(d)),i.addScaledVector(a,t/Math.sin(d))}}function zT(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var qu=class extends VT{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,a=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),a=Math.floor(a);let c=[],d=[],l=[],u=[],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 lt(0,-f,0),w=new lt(0,f,0),b=new Lr(r,-f),_=new Lr(h,-f),P=new Lr(0,w.y).sub(_),v=new Lr(0,w.y).sub(b),N=new Lr(P.y,-P.x).normalize(),T=new Lr(v.y,-v.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-P.angle())/2)-1e-8;s=Math.min(s,O);let A;{let V=new lt(N.x,N.y,0),W=new lt(Math.cos(y)*V.x,V.y,Math.sin(y)*V.x);A=V.angleTo(W)}let M=s/Math.tan((Math.PI-P.angle())/2),L=s/Math.tan((Math.PI-A)/2),X=new lt;if(!i){d.push(S.x,S.y,S.z),l.push(0,-1,0),u.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 Lr(Math.sin(k),Math.cos(k));Bs($,U,X),d.push(X.x,X.y,X.z),l.push(0,-1,0),u.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 lt,W=new lt,$=new lt,Y=new lt,q=new lt,k=new lt;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 Lr(Math.sin(B),Math.cos(B)),oe=new Lr(Math.sin(F),Math.cos(F)),ee=new Lr(Math.sin(j),Math.cos(j));Bs(b,D,W),Bs(b,ee,$),Bs(N,oe,V),Wu(w,W,$,L,L,Y),d.push(Y.x,Y.y,Y.z),Wu(W,w,$,L,M,q),d.push(q.x,q.y,q.z),Wu($,W,w,M,L,k),d.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),u.push(0,0),u.push(0,0),u.push(0,0);let K=p++,te=p++,Q=p++;if(c.push(K,te,Q),s>0){{let ie=W.clone().add($).multiplyScalar(.5),ce=w.clone().sub(ie).normalize(),ue=S.clone().sub(ie).normalize().add(ce).normalize().multiplyScalar(-1),me=k.clone().sub(q);Z(ie,me,ue,P.angle())}let ae,ne;{let ie=new lt;Bs(T,ee,ie);let ce=k.clone().add(Y).multiplyScalar(.5);ce=zT(ce,$,w);let le=k.clone().sub(Y);[ae,ne]=Z(ce,le,ie,A,Y.y)}{let ie=ae,ce=ie.clone().setY(0).normalize(),le=new lt(0,-1,0),ue=ce.clone().cross(le);z(ie,ce,le,ue)}R.concat(ne);{let ie=P.angle(),ce=Math.PI-ie,le=w.clone();le.y-=s/Math.sin(ie-Math.PI/2);let ue=new lt,me=[];for(let Ve=0;Ve<a;Ve++){let Pe=[],De=Math.PI/2-ce*Ve/a,Et=Math.cos(De),ve=Math.sin(De),Je=F;for(let nt=0;nt<=Ve;nt++){let xn=Math.cos(Je),$e=Math.sin(Je);V.x=Et*$e,V.y=ve,V.z=Et*xn,ue.copy(le).addScaledVector(V,s),d.push(ue.x,ue.y,ue.z),l.push(V.x,V.y,V.z),u.push(0,0),Pe.push(p++),Je+=Math.PI*2/Ve/t}me.push(Pe)}ne.reverse(),me.push(ne);let _e=me.length-1;for(let Ve=0;Ve<_e;Ve++){let Pe=me[Ve],De=me[Ve+1],Et=Pe.length-1;c.push(De[1],Pe[0],De[0]);for(let ve=1;ve<=Et;ve++)c.push(Pe[ve],Pe[ve-1],De[ve]),c.push(De[ve+1],Pe[ve],De[ve])}}}}}this.setIndex(c),this.setAttribute("position",new Hu(d,3)),this.setAttribute("normal",new Hu(l,3)),this.setAttribute("uv",new Hu(u,2));function Z(V,W,$,Y,q){let k=-Y/2,U=(Math.PI-Y)/2,B=W.clone().normalize().cross($);V.addScaledVector($,-s/Math.sin(U));let F=new lt,j=new lt,D=1,oe=p,ee=[];for(let K=0;K<=a;K++){let te=k+K/a*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 ae=Q/D-.5;if(F.copy(V),F.addScaledVector(W,ae),F.addScaledVector(j,s),q!=null){let ne=Math.max(0,F.y-q);F.addScaledVector(W,-ne/W.y)}d.push(F.x,F.y,F.z),l.push(j.x,j.y,j.z),u.push(0,0),Q===0&&ee.push(p),p++}}for(let K=0;K<a;K++)for(let te=0;te<D;te++){let Q=oe+te+(D+1)*K,ae=Q+(D+1),ne=ae+1,ie=Q+1;c.push(Q,ae,ie),c.push(ae,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 lt,F=new lt;for(let D=0;D<=a;D++){let oe=[],ee=D/a;for(let K=0;K<=D;K++){let Q=((D?K/D:0)-.5)*x,ae=Math.cos(Q),ne=Math.sin(Q),ie=Math.atan(Math.tan(k)*ae),ce=(q+ie)*ee,le=Math.cos(ce),ue=Math.sin(ce);B.set(0,0,0),B.addScaledVector(W,ue*ae),B.addScaledVector($,le),B.addScaledVector(Y,ue*ne),F.copy(V).addScaledVector(B,s),d.push(F.x,F.y,F.z),l.push(B.x,B.y,B.z),u.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 Vl=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 Ae?n.shape:new Ae,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:s,extrudeBevelSize:a,extrudeBevelSegments:c}=n.parameters,d={x:e*.5,y:t*.5},l={x:-d.x,y:-d.y},u={x:d.x,y:d.y};function p(w,b,_){return b>e&&_>t?Math.min(w*e/b,w*t/_):b>e?w*e/b:_>t?w*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=u.x,y=u.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=Rt.create({shape:r,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:c}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};import{SphereGeometry as jT}from"three";var By=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:Math.PI},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=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:s,phiLength:a,thetaStart:c,thetaLength:d}=n.parameters,l=new jT(.5*r,o,i,s,a,c,d);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as FT}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,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 FT(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as kT,Float32BufferAttribute as $u,Vector3 as UT}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,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:s}=n.parameters,a=new Yu(r,e,t,o,i,s);return Object.assign(a,{userData:{...n,type:"BackdropGeometry"}})}},Yu=class extends kT{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let a=[],c=[],d=[],l=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-l,o),o*=Math.PI/180;let u=[],p=Math.PI/2,f=(F=0,j=0,D=0)=>new UT(F,j,D),m=f(),h=f(),[y,g,x]=[e/2,r/2,t/2],S=-g,w=+g,[b,_,P]=[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));P.y=Math.sin(o)*e-y;let T=Math.cos(o)*e-x,C=b.z-l;o<=p?(P.z=Math.min(T,C),P.z==C&&(P.y-=(T-C)/Math.tan(p-o))):_.z=Math.min(_.z-T-x,b.z-l),m.subVectors(b,_),h.subVectors(P,_);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(_);m.set(0,v(o,!0),N(o,!0)),u.push([P,m.clone()]);let X=(Math.PI-o)/s;for(let F=0;F<=s;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)),u.push([m.clone(),h.clone()])}u.push([b,f(0,1,0)]);let R=Math.sin(X/2)*A*2,Z=u.length-1,z=u[0][0].distanceTo(u[1][0]),V=u[Z-1][0].distanceTo(u[Z][0]),W=z+R*s+V;u[0].push(1);for(let F=0;F<=s;F++)u[F+1].push(1-(z+F*R)/W);u[Z].push(0);let[$,Y,q]=u[0],k,U,B;for(let F=1;F<u.length;F++)[k,U,B]=u[F],a.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),d.push(0,q,0,B,1,q,1,q,0,B,1,B),[$,Y,q]=[k,U,B];this.setAttribute("position",new $u(a,3)),this.setAttribute("normal",new $u(c,3)),this.setAttribute("uv",new $u(d,2))}};var zl=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 Ae?n.shape:new Ae,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:s,depth:a,extrudeBevelSize:c,extrudeBevelSegments:d}=n.parameters,l=n.shape,u=r*.5,p=e*.5,f=0,m=0,h=s*Math.PI/360/o,y=Math.PI/2*3*-1,g=u*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,_=f+Math.sin(b)*u,P=m+Math.cos(b)*p;l.addPoint(l.createPoint(_,P))}}else for(let w=0;w<o;w++){let b=f+Math.cos(y)*u,_=m+Math.sin(y)*p;l.addPoint(l.createPoint(b,_)),y+=h,b=f+Math.cos(y)*g,_=m+Math.sin(y)*x,w<=o,l.addPoint(l.createPoint(b,_)),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=Rt.create({shape:l,parameters:{roundness:i,depth:a,extrudeBevelSize:c,extrudeBevelSegments:d}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as HT}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,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 HT(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var zy=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:Math.PI*2,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:s,cornerRadius:a,cornerSegments:c}=n.parameters,d=WT(r,e,t,r*.5,s,i,0,0,o,a,c);return d.scale(1,e/r,1),Object.assign(d,{userData:{...n,type:"TorusGeometry"}})}};function WT(n,r,e,t,o,i,s,a,c,d,l){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(d=0),new Es(!0,n,r,e,t,o,i,s,a,c,d,l)}import{TorusKnotGeometry as qT}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,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:s}=n.parameters,a=r*.5;a!==e&&(a-=e);let c=new qT(a,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var Fy=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 Ae?n.shape:new Ae,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:s,isRect:a}=n.parameters,c=n.shape,d=r*.5,l=e*.5;a?(c.addPoint(c.createPoint(-d,l)),c.addPoint(c.createPoint(d,-l)),c.addPoint(c.createPoint(-d,-l))):(c.addPoint(c.createPoint(0,l)),c.addPoint(c.createPoint(d,-l)),c.addPoint(c.createPoint(-d,-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 u=Rt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(u,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as Uy,Vector3 as ct,Matrix3 as $T,Matrix4 as Qo,BufferGeometry as Hy,BufferAttribute as vi,MathUtils as Xu}from"three";function ky(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var YT=new Qo,XT=new Qo;function KT(n,r,e){let t=[new ct,new ct,new ct],o=[new ct,new ct,new ct];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,s)=>{let a=o[s],c=Xu.lerp(i.length(),a.length(),e);i.lerp(a,e).setLength(c)}),new Qo().makeBasis(t[0],t[1],t[2])}var Wy=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),s=r?.shapeData??hi.create({parameters:Xc}).userData.shape;return{path:n.path??Qn.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...nl,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new Ku(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Hy,{userData:{...n,type:"PathGeometry"}})}},Ku=class extends Hy{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)||!ky(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,s=this.inputs.path.isClosed?e.length:e.length-1,a=Math.floor(i*s),c=this.inputs.path.isClosed?Math.ceil((o+i)*s):Math.ceil(Math.min(1,o+i)*s),d=Math.min(Math.max(2,c-a+1),s+2),l=[],u=[];for(let z=0;z<d;z++){let V=this.inputs.path.isClosed?(z+a)%e.length:Math.min(z+a,e.length-1);l.push(e[V].clone()),u.push(t[V].clone())}let p=(z,V,W)=>{l[z]=l[z].clone().lerp(l[V],W),u[z]=KT(u[z],u[V],W)},f=0,m=i*s%1;(!this.inputs.path.isClosed||o<=1)&&(m||i===0)&&(f=m,p(0,1,f));let h=0,y=(i+o)*s%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]),u[z].copy(u[0])}this._applyPathModifiers(u,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:_,vertices:P}=this._computeShapePoints(w),v=0,N;S==="round"&&(N=new Eo(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=N.getAttribute("position").count);let T=0,C=0;_.sort((z,V)=>z.start-V.start),_.forEach(z=>{z.verticesStart=T,z.verticesCount=z.continuous.reduce((V,W,$)=>V+($===0||!W?2:1),0),C+=z.verticesCount,T=C});let O=C*d,A,M=0;if(this._isOpenEnded()&&S==="flat"){try{A=dr({windingRule:we.ODD,elementType:ke.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:b})}catch{A=Bu}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(_.forEach(z=>{this._extrudeRegion(z,P,u,l,R,Z,this._isGeometryClosed()&&!this._isOpenEnded())}),A&&(this._closeEnd(A,O,Z,R,u[0],l[0],!1),this._closeEnd(A,O+M,Z,R,u[u.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 vi(R.positions,3)),this.setAttribute("normal",new vi(R.normals,3)),this.setAttribute("uv",new vi(R.uvs,2)),this.setIndex(Z);let W=YT;W.copy(u[u.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(W,X,L),W.copy(u[0]).setPosition(l[0]).multiply(XT.makeScale(1,1,-1)),this.applyMatrix4OnRange(W,X-v,X),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new vi(R.positions,3)),this.setAttribute("normal",new vi(R.normals,3)),this.setAttribute("uv",new vi(R.uvs,2)),this.setIndex(Z)}_extractPathPoints(){let t=vl(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(t.length<2)return[];let o=[t[0]];return t.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),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,s=new ct,a=new ct,c=new ct,d=new ct,l=new ct(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(x).normalize(),b=S.clone().sub(g).normalize(),_=w.clone().add(b).normalize();c.copy(_),y===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let P=l.clone().cross(_).normalize(),v=_.clone().cross(P).normalize();l.copy(v),d.copy(P),y===0&&(s.copy(v),a.copy(_));let N=new Qo().makeBasis(P,v,_);t.push(N)}let u=i?a:c,p=i?s:new ct(0,1,0),f=u.clone().cross(d).normalize(),m=Math.acos(p.dot(f));if(isNaN(m))return t;let h=p.clone().cross(f);u.dot(h)>0&&(m*=-1);for(let y=1;y<t.length;y++){let g=new Qo().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:s,twist:a,startScale:c,endScale:d}=this.inputs.parameters.extrusion,l=new Qo,u=new Qo;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(Xu.lerp(s,s+a,m));let h=Xu.lerp(c,d,m);u.makeScale(h,h,h),p.multiply(l).multiply(u)}),e}_computeShapePoints(e=12,t=we.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),s=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}),a;try{a=dr({windingRule:t,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{a=Ms}let c;try{c=dr({windingRule:we.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{c=Du}if(!a)throw new Error("error generating geometry");let d=a.elementCount;if(c){a.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?a.vertexCount:0;a.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=a.vertexCount;a.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];a.vertices.push(y)}}let l=1/0,u=-1/0,p=1/0,f=-1/0;for(let h=0,y=a.vertexCount;h<y;h++){let g=h*2,x=a.vertices[g+0],S=a.vertices[g+1];x<l&&(l=x),x>u&&(u=x),S<p&&(p=S),S>f&&(f=S)}let m=[];for(let h=a.elementCount-1;h>=0;h--){let y=h>=d,g=h*2,x=a.elements[g+0],S=a.elements[g+1],w=x+S,b={start:x,count:S,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(b);let _=x,P=w-1,v=x+1,N=o.roundedCurves.length;do{let T=_-x,C=a.vertices[P*2+0],O=a.vertices[P*2+1],A=a.vertices[_*2+0],M=a.vertices[_*2+1],L=a.vertices[v*2+0],X=a.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[T*2+0]=-W,b.normals[T*2+1]=V;let Y=a.vertexIndices[_];if(Array.isArray(Y))b.continuous[T]=!1;else{let[q,k]=o.getCurveIndexFromVertexId(Y-1,!0);if(k>0&&k<1)b.continuous[T]=!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[T]=F.dot(j)>.95}}y&&(b.normals[T*2+0]*=-1,b.normals[T*2+1]*=-1),[P,_,v]=[_,v,v+1],v>=w&&(v-=S)}while(v!==x+1)}return{regions:[i,...s],infos:m,vertices:a.vertices}}_insertVertex(e,t,o,i,s){let a=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[a+0]=s.x,e.uvs[a+1]=s.y}_extrudeRegion(e,t,o,i,s,a,c){let d=new ct,l=new ct,u=new ct,p=new ct,f=new Uy;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(d.set(t[w+0],t[w+1],0),u.copy(d).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(d).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(s,x,u,p,f),x++,!e.continuous[S]||S===0){if(S===0)p.set(e.normals[S*2+0],e.normals[S*2+1],0),f.set(0,y/(o.length-1));else{let b=S===e.count-1?e.start*2:w+2;l.set(t[b+0],t[b+1],0),p.copy(l).sub(d),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(s,x,u,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,_=y+w,P=g+w,v=g+x;e.isHole?a.push(b,P,_,b,v,P):a.push(b,_,P,b,P,v),x++}}}_closeEnd(e,t,o,i,s,a,c){let d=e.vertexCount,l=new ct(0,0,c?-1:1).applyMatrix4(s),u=new ct,p=new Uy;for(let m=0;m<d;m++){let h=2*m;u.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(s).add(a),this._insertVertex(i,t+m,u,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,s=new $T().getNormalMatrix(e).elements,a,c,d,l,u=this.attributes.position,p=this.attributes.normal;if(!u||!p)return;let f=u.array,m=p.array,h=u.itemSize;for(let y=t*h,g=o*h;y<g;y+=h){if(y===t)debugger;a=f[y+0],c=f[y+1],d=f[y+2],l=1/(i[3]*a+i[7]*c+i[11]*d+i[15]),f[y+0]=(i[0]*a+i[4]*c+i[8]*d+i[12])*l,f[y+1]=(i[1]*a+i[5]*c+i[9]*d+i[13])*l,f[y+2]=(i[2]*a+i[6]*c+i[10]*d+i[14])*l,a=m[y+0],c=m[y+1],d=m[y+2],m[y+0]=s[0]*a+s[3]*c+s[6]*d,m[y+1]=s[1]*a+s[4]*c+s[7]*d,m[y+2]=s[2]*a+s[5]*c+s[8]*d}u.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,t){let o=this.index;if(o){for(let i=e;i<t;i+=3){let s=o.getX(i),a=o.getX(i+1),c=o.getX(i+2);o.setXYZ(i,c,a,s)}o.needsUpdate=!0}}};import{BufferAttribute as qy,BufferGeometry as Zu}from"three";import{mergeBufferGeometries as ZT}from"three/examples/jsm/utils/BufferGeometryUtils.js";function $y(){let n=new Zu;return n.setAttribute("position",new qy(new Float32Array([]),3)),n.setIndex(new qy(new Uint16Array([]),1)),n}var QT=$y().attributes,JT=12,eO=1,bi=class extends Zu{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,QT),this.userData={parameters:e,type:"TextGeometry"};let o=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:s,extrudeBevelSize:a,extrudeBevelSegments:c,text:d,textTransform:l}=e,u=l===2?d.toUpperCase():l===3?d.toLowerCase():d,p=tO(e,t,u),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,x=f.map(b=>new Ae().fromShape(b));this.vectorShapes=x;let S=x.map(b=>Rt.create({shape:b,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:a,windingRule:s<=0?we.NONZERO:we.ODD,subdivisions:this.isLowResolution&&s>0?eO:JT}})),w=S.length?ZT(S):$y();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([b,_])=>{this.setAttribute(b,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=or(new Zu,bi.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 tO(n,r,e){e=e??n.text;let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
1
+ var ax=Object.create;var Nc=Object.defineProperty;var sx=Object.getOwnPropertyDescriptor;var lx=Object.getOwnPropertyNames;var cx=Object.getPrototypeOf,dx=Object.prototype.hasOwnProperty;var Tn=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),ux=(n,r)=>{for(var e in r)Nc(n,e,{get:r[e],enumerable:!0})},px=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of lx(r))!dx.call(n,o)&&o!==e&&Nc(n,o,{get:()=>r[o],enumerable:!(t=sx(r,o))||t.enumerable});return n};var ma=(n,r,e)=>(e=n!=null?ax(cx(n)):{},px(r||!n||!n.__esModule?Nc(e,"default",{value:n,enumerable:!0}):e,n));var Dh=Tn((dd,Eh)=>{(function(n,r){typeof dd=="object"?Eh.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(dd,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 zh=Tn((Tl,Vh)=>{(function(n,r){typeof Tl=="object"&&typeof Vh<"u"?r(Tl):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Tl,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=[],_=[],P=e==="f"?S:x,v=h=p=0;v<S;v++)b[v]=new Array(P).fill(0);for(v=0;v<x;v++)_[v]=new Array(x).fill(0);var N,T=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(T[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(T[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++)_[a][v]=b[v][a]/f;for(a=c;a<x;a++){for(m=0,s=c;s<x;s++)m+=b[v][s]*_[s][a];for(s=c;s<x;s++)_[s][a]=_[s][a]+m*_[s][v]}}for(a=c;a<x;a++)_[v][a]=0,_[a][v]=0;_[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=T[v],a=c;a<P;a++)b[v][a]=0;if(p!==0){for(f=b[v][v]*p,a=c;a<P;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(T[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=T[v],T[v]=Math.sqrt(d*d+p*p),l=p/(f=T[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=T[s],c===s){if(g<0&&(T[s]=-g,t))for(a=0;a<x;a++)_[a][s]=-_[a][s];break}for(h=T[c],d=(((y=T[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=T[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=_[a][v-1],g=_[a][v],_[a][v-1]=h*l+g*m,_[a][v]=-h*m+g*l;if(g=Math.sqrt(d*d+f*f),d=(l=d/(T[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,T[s]=h}for(v=0;v<x;v++)T[v]<o&&(T[v]=0);return{u:b,q:T,v:_}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var yy=Tn((Gd,Vd)=>{(function(n,r){typeof Gd=="object"&&typeof Vd<"u"?Vd.exports=r():typeof define=="function"&&define.amd?define(r):(n=n||self,n.TinyQueue=r())})(Gd,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 xy=Tn((dk,zd)=>{"use strict";var Bl=yy();Bl.default&&(Bl=Bl.default);zd.exports=gy;zd.exports.default=gy;function gy(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 Bl(void 0,xT),h=t;h<i;h+=d)for(var y=o;y<a;y+=d)m.push(new Bo(h+p,y+p,p,n));var g=bT(n),x=new Bo(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 Bo(w.x-p,w.y-p,p,n)),m.push(new Bo(w.x+p,w.y-p,p,n)),m.push(new Bo(w.x-p,w.y+p,p,n)),m.push(new Bo(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 xT(n,r){return r.max-n.max}function Bo(n,r,e,t){this.x=n,this.y=r,this.h=e,this.d=vT(n,r,t),this.max=this.d+this.h*Math.SQRT2}function vT(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,ST(n,r,l,d))}return o===0?0:(t?1:-1)*Math.sqrt(o)}function bT(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 Bo(o[0][0],o[0][1],0,n):new Bo(e/r,t/r,0,n)}function ST(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 Dg=Tn(sc=>{(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,_=(p._sprite[l][0]+p._sprite[l][1])/1e3;y._sprite=l,y._ended=!1;var P=function(){y._paused=!1,y._seek=x,y._start=b,y._stop=_,y._loop=!!(y._loop||p._sprite[l][2])};if(x>=_){p._ended(y);return}var v=y._node;if(p._webAudio){var N=function(){p._playLock=!1,P(),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 T=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,P(),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(),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)T();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",T(),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 _=(Date.now()-b)/f;b=Date.now(),g+=x*_,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 sc<"u"&&(sc.Howler=r,sc.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 X0=Tn((jee,Y0)=>{Y0.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 _N,Loader as PN}from"three";function op(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function or(n,r){return Object.setPrototypeOf(n,r),n}function ys(n){return Array.isArray(n)?n:[n]}function np(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 fx=typeof global=="object"&&global&&global.Object===Object&&global,gs=fx;var mx=typeof self=="object"&&self&&self.Object===Object&&self,hx=gs||mx||Function("return this")(),Ze=hx;var yx=Ze.Symbol,at=yx;var ip=Object.prototype,gx=ip.hasOwnProperty,xx=ip.toString,ha=at?at.toStringTag:void 0;function vx(n){var r=gx.call(n,ha),e=n[ha];try{n[ha]=void 0;var t=!0}catch{}var o=xx.call(n);return t&&(r?n[ha]=e:delete n[ha]),o}var ap=vx;var bx=Object.prototype,Sx=bx.toString;function wx(n){return Sx.call(n)}var sp=wx;var _x="[object Null]",Px="[object Undefined]",lp=at?at.toStringTag:void 0;function Tx(n){return n==null?n===void 0?Px:_x:lp&&lp in Object(n)?ap(n):sp(n)}var kt=Tx;function Ox(n){return n!=null&&typeof n=="object"}var ht=Ox;var Ax="[object Symbol]";function Cx(n){return typeof n=="symbol"||ht(n)&&kt(n)==Ax}var On=Cx;function Nx(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 xs=Nx;var Ix=Array.isArray,He=Ix;var Mx=1/0,cp=at?at.prototype:void 0,dp=cp?cp.toString:void 0;function up(n){if(typeof n=="string")return n;if(He(n))return xs(n,up)+"";if(On(n))return dp?dp.call(n):"";var r=n+"";return r=="0"&&1/n==-Mx?"-0":r}var pp=up;function Lx(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Ut=Lx;function Ex(n){return n}var fp=Ex;var Dx="[object AsyncFunction]",Bx="[object Function]",Rx="[object GeneratorFunction]",Gx="[object Proxy]";function Vx(n){if(!Ut(n))return!1;var r=kt(n);return r==Bx||r==Rx||r==Dx||r==Gx}var vs=Vx;var zx=Ze["__core-js_shared__"],bs=zx;var mp=function(){var n=/[^.]+$/.exec(bs&&bs.keys&&bs.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function jx(n){return!!mp&&mp in n}var hp=jx;var Fx=Function.prototype,kx=Fx.toString;function Ux(n){if(n!=null){try{return kx.call(n)}catch{}try{return n+""}catch{}}return""}var Yr=Ux;var Hx=/[\\^$.*+?()[\]{}|]/g,Wx=/^\[object .+?Constructor\]$/,qx=Function.prototype,$x=Object.prototype,Yx=qx.toString,Xx=$x.hasOwnProperty,Kx=RegExp("^"+Yx.call(Xx).replace(Hx,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Zx(n){if(!Ut(n)||hp(n))return!1;var r=vs(n)?Kx:Wx;return r.test(Yr(n))}var yp=Zx;function Qx(n,r){return n?.[r]}var gp=Qx;function Jx(n,r){var e=gp(n,r);return yp(e)?e:void 0}var Dt=Jx;var ev=Dt(Ze,"WeakMap"),Ss=ev;var xp=Object.create,tv=function(){function n(){}return function(r){if(!Ut(r))return{};if(xp)return xp(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),vp=tv;function rv(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 bp=rv;function ov(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Sp=ov;var nv=800,iv=16,av=Date.now;function sv(n){var r=0,e=0;return function(){var t=av(),o=iv-(t-e);if(e=t,o>0){if(++r>=nv)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var wp=sv;function lv(n){return function(){return n}}var _p=lv;var cv=function(){try{var n=Dt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),An=cv;var dv=An?function(n,r){return An(n,"toString",{configurable:!0,enumerable:!1,value:_p(r),writable:!0})}:fp,Pp=dv;var uv=wp(Pp),Tp=uv;function pv(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var Op=pv;var fv=9007199254740991,mv=/^(?:0|[1-9]\d*)$/;function hv(n,r){var e=typeof n;return r=r??fv,!!r&&(e=="number"||e!="symbol"&&mv.test(n))&&n>-1&&n%1==0&&n<r}var Cn=hv;function yv(n,r,e){r=="__proto__"&&An?An(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var ws=yv;function gv(n,r){return n===r||n!==n&&r!==r}var Nn=gv;var xv=Object.prototype,vv=xv.hasOwnProperty;function bv(n,r,e){var t=n[r];(!(vv.call(n,r)&&Nn(t,e))||e===void 0&&!(r in n))&&ws(n,r,e)}var In=bv;function Sv(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?ws(e,s,c):In(e,s,c)}return e}var Sr=Sv;var Ap=Math.max;function wv(n,r,e){return r=Ap(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Ap(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),bp(n,this,s)}}var Cp=wv;var _v=9007199254740991;function Pv(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=_v}var Mn=Pv;function Tv(n){return n!=null&&Mn(n.length)&&!vs(n)}var _s=Tv;var Ov=Object.prototype;function Av(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||Ov;return n===e}var Ln=Av;function Cv(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Np=Cv;var Nv="[object Arguments]";function Iv(n){return ht(n)&&kt(n)==Nv}var Ic=Iv;var Ip=Object.prototype,Mv=Ip.hasOwnProperty,Lv=Ip.propertyIsEnumerable,Ev=Ic(function(){return arguments}())?Ic:function(n){return ht(n)&&Mv.call(n,"callee")&&!Lv.call(n,"callee")},En=Ev;function Dv(){return!1}var Mp=Dv;var Dp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Lp=Dp&&typeof module=="object"&&module&&!module.nodeType&&module,Bv=Lp&&Lp.exports===Dp,Ep=Bv?Ze.Buffer:void 0,Rv=Ep?Ep.isBuffer:void 0,Gv=Rv||Mp,Wo=Gv;var Vv="[object Arguments]",zv="[object Array]",jv="[object Boolean]",Fv="[object Date]",kv="[object Error]",Uv="[object Function]",Hv="[object Map]",Wv="[object Number]",qv="[object Object]",$v="[object RegExp]",Yv="[object Set]",Xv="[object String]",Kv="[object WeakMap]",Zv="[object ArrayBuffer]",Qv="[object DataView]",Jv="[object Float32Array]",eb="[object Float64Array]",tb="[object Int8Array]",rb="[object Int16Array]",ob="[object Int32Array]",nb="[object Uint8Array]",ib="[object Uint8ClampedArray]",ab="[object Uint16Array]",sb="[object Uint32Array]",ze={};ze[Jv]=ze[eb]=ze[tb]=ze[rb]=ze[ob]=ze[nb]=ze[ib]=ze[ab]=ze[sb]=!0;ze[Vv]=ze[zv]=ze[Zv]=ze[jv]=ze[Qv]=ze[Fv]=ze[kv]=ze[Uv]=ze[Hv]=ze[Wv]=ze[qv]=ze[$v]=ze[Yv]=ze[Xv]=ze[Kv]=!1;function lb(n){return ht(n)&&Mn(n.length)&&!!ze[kt(n)]}var Bp=lb;function cb(n){return function(r){return n(r)}}var Dn=cb;var Rp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ya=Rp&&typeof module=="object"&&module&&!module.nodeType&&module,db=ya&&ya.exports===Rp,Mc=db&&gs.process,ub=function(){try{var n=ya&&ya.require&&ya.require("util").types;return n||Mc&&Mc.binding&&Mc.binding("util")}catch{}}(),Xr=ub;var Gp=Xr&&Xr.isTypedArray,pb=Gp?Dn(Gp):Bp,Ps=pb;var fb=Object.prototype,mb=fb.hasOwnProperty;function hb(n,r){var e=He(n),t=!e&&En(n),o=!e&&!t&&Wo(n),i=!e&&!t&&!o&&Ps(n),a=e||t||o||i,s=a?Np(n.length,String):[],c=s.length;for(var u in n)(r||mb.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 Ts=hb;function yb(n,r){return function(e){return n(r(e))}}var Os=yb;var gb=Os(Object.keys,Object),Vp=gb;var xb=Object.prototype,vb=xb.hasOwnProperty;function bb(n){if(!Ln(n))return Vp(n);var r=[];for(var e in Object(n))vb.call(n,e)&&e!="constructor"&&r.push(e);return r}var zp=bb;function Sb(n){return _s(n)?Ts(n):zp(n)}var Bn=Sb;function wb(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var jp=wb;var _b=Object.prototype,Pb=_b.hasOwnProperty;function Tb(n){if(!Ut(n))return jp(n);var r=Ln(n),e=[];for(var t in n)t=="constructor"&&(r||!Pb.call(n,t))||e.push(t);return e}var Fp=Tb;function Ob(n){return _s(n)?Ts(n,!0):Fp(n)}var Rn=Ob;var Ab=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Cb=/^\w*$/;function Nb(n,r){if(He(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||On(n)?!0:Cb.test(n)||!Ab.test(n)||r!=null&&n in Object(r)}var kp=Nb;var Ib=Dt(Object,"create"),Kr=Ib;function Mb(){this.__data__=Kr?Kr(null):{},this.size=0}var Up=Mb;function Lb(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var Hp=Lb;var Eb="__lodash_hash_undefined__",Db=Object.prototype,Bb=Db.hasOwnProperty;function Rb(n){var r=this.__data__;if(Kr){var e=r[n];return e===Eb?void 0:e}return Bb.call(r,n)?r[n]:void 0}var Wp=Rb;var Gb=Object.prototype,Vb=Gb.hasOwnProperty;function zb(n){var r=this.__data__;return Kr?r[n]!==void 0:Vb.call(r,n)}var qp=zb;var jb="__lodash_hash_undefined__";function Fb(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Kr&&r===void 0?jb:r,this}var $p=Fb;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=Up;Gn.prototype.delete=Hp;Gn.prototype.get=Wp;Gn.prototype.has=qp;Gn.prototype.set=$p;var Lc=Gn;function kb(){this.__data__=[],this.size=0}var Yp=kb;function Ub(n,r){for(var e=n.length;e--;)if(Nn(n[e][0],r))return e;return-1}var fo=Ub;var Hb=Array.prototype,Wb=Hb.splice;function qb(n){var r=this.__data__,e=fo(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Wb.call(r,e,1),--this.size,!0}var Xp=qb;function $b(n){var r=this.__data__,e=fo(r,n);return e<0?void 0:r[e][1]}var Kp=$b;function Yb(n){return fo(this.__data__,n)>-1}var Zp=Yb;function Xb(n,r){var e=this.__data__,t=fo(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var Qp=Xb;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=Yp;Vn.prototype.delete=Xp;Vn.prototype.get=Kp;Vn.prototype.has=Zp;Vn.prototype.set=Qp;var mo=Vn;var Kb=Dt(Ze,"Map"),ho=Kb;function Zb(){this.size=0,this.__data__={hash:new Lc,map:new(ho||mo),string:new Lc}}var Jp=Zb;function Qb(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var ef=Qb;function Jb(n,r){var e=n.__data__;return ef(r)?e[typeof r=="string"?"string":"hash"]:e.map}var yo=Jb;function eS(n){var r=yo(this,n).delete(n);return this.size-=r?1:0,r}var tf=eS;function tS(n){return yo(this,n).get(n)}var rf=tS;function rS(n){return yo(this,n).has(n)}var of=rS;function oS(n,r){var e=yo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var nf=oS;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=Jp;zn.prototype.delete=tf;zn.prototype.get=rf;zn.prototype.has=of;zn.prototype.set=nf;var qo=zn;var nS="Expected a function";function Ec(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(nS);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(Ec.Cache||qo),e}Ec.Cache=qo;var af=Ec;var iS=500;function aS(n){var r=af(n,function(t){return e.size===iS&&e.clear(),t}),e=r.cache;return r}var sf=aS;var sS=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,lS=/\\(\\)?/g,cS=sf(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(sS,function(e,t,o,i){r.push(o?i.replace(lS,"$1"):t||e)}),r}),lf=cS;function dS(n){return n==null?"":pp(n)}var cf=dS;function uS(n,r){return He(n)?n:kp(n,r)?[n]:lf(cf(n))}var Xt=uS;var pS=1/0;function fS(n){if(typeof n=="string"||On(n))return n;var r=n+"";return r=="0"&&1/n==-pS?"-0":r}var go=fS;function mS(n,r){r=Xt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[go(r[e++])];return e&&e==t?n:void 0}var As=mS;function hS(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var jn=hS;var df=at?at.isConcatSpreadable:void 0;function yS(n){return He(n)||En(n)||!!(df&&n&&n[df])}var uf=yS;function pf(n,r,e,t,o){var i=-1,a=n.length;for(e||(e=uf),o||(o=[]);++i<a;){var s=n[i];r>0&&e(s)?r>1?pf(s,r-1,e,t,o):jn(o,s):t||(o[o.length]=s)}return o}var ff=pf;function gS(n){var r=n==null?0:n.length;return r?ff(n,1):[]}var mf=gS;function xS(n){return Tp(Cp(n,void 0,mf),n+"")}var Cs=xS;var vS=Os(Object.getPrototypeOf,Object),Fn=vS;var bS="[object Object]",SS=Function.prototype,wS=Object.prototype,hf=SS.toString,_S=wS.hasOwnProperty,PS=hf.call(Object);function TS(n){if(!ht(n)||kt(n)!=bS)return!1;var r=Fn(n);if(r===null)return!0;var e=_S.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&hf.call(e)==PS}var yf=TS;function OS(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 gf=OS;function AS(){this.__data__=new mo,this.size=0}var xf=AS;function CS(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var vf=CS;function NS(n){return this.__data__.get(n)}var bf=NS;function IS(n){return this.__data__.has(n)}var Sf=IS;var MS=200;function LS(n,r){var e=this.__data__;if(e instanceof mo){var t=e.__data__;if(!ho||t.length<MS-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new qo(t)}return e.set(n,r),this.size=e.size,this}var wf=LS;function kn(n){var r=this.__data__=new mo(n);this.size=r.size}kn.prototype.clear=xf;kn.prototype.delete=vf;kn.prototype.get=bf;kn.prototype.has=Sf;kn.prototype.set=wf;var Un=kn;function ES(n,r){return n&&Sr(r,Bn(r),n)}var _f=ES;function DS(n,r){return n&&Sr(r,Rn(r),n)}var Pf=DS;var Cf=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Tf=Cf&&typeof module=="object"&&module&&!module.nodeType&&module,BS=Tf&&Tf.exports===Cf,Of=BS?Ze.Buffer:void 0,Af=Of?Of.allocUnsafe:void 0;function RS(n,r){if(r)return n.slice();var e=n.length,t=Af?Af(e):new n.constructor(e);return n.copy(t),t}var Nf=RS;function GS(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 If=GS;function VS(){return[]}var Ns=VS;var zS=Object.prototype,jS=zS.propertyIsEnumerable,Mf=Object.getOwnPropertySymbols,FS=Mf?function(n){return n==null?[]:(n=Object(n),If(Mf(n),function(r){return jS.call(n,r)}))}:Ns,Hn=FS;function kS(n,r){return Sr(n,Hn(n),r)}var Lf=kS;var US=Object.getOwnPropertySymbols,HS=US?function(n){for(var r=[];n;)jn(r,Hn(n)),n=Fn(n);return r}:Ns,Is=HS;function WS(n,r){return Sr(n,Is(n),r)}var Ef=WS;function qS(n,r,e){var t=r(n);return He(n)?t:jn(t,e(n))}var Ms=qS;function $S(n){return Ms(n,Bn,Hn)}var ga=$S;function YS(n){return Ms(n,Rn,Is)}var Ls=YS;var XS=Dt(Ze,"DataView"),Es=XS;var KS=Dt(Ze,"Promise"),Ds=KS;var ZS=Dt(Ze,"Set"),Bs=ZS;var Df="[object Map]",QS="[object Object]",Bf="[object Promise]",Rf="[object Set]",Gf="[object WeakMap]",Vf="[object DataView]",JS=Yr(Es),ew=Yr(ho),tw=Yr(Ds),rw=Yr(Bs),ow=Yr(Ss),$o=kt;(Es&&$o(new Es(new ArrayBuffer(1)))!=Vf||ho&&$o(new ho)!=Df||Ds&&$o(Ds.resolve())!=Bf||Bs&&$o(new Bs)!=Rf||Ss&&$o(new Ss)!=Gf)&&($o=function(n){var r=kt(n),e=r==QS?n.constructor:void 0,t=e?Yr(e):"";if(t)switch(t){case JS:return Vf;case ew:return Df;case tw:return Bf;case rw:return Rf;case ow:return Gf}return r});var Zr=$o;var nw=Object.prototype,iw=nw.hasOwnProperty;function aw(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&iw.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var zf=aw;var sw=Ze.Uint8Array,Wn=sw;function lw(n){var r=new n.constructor(n.byteLength);return new Wn(r).set(new Wn(n)),r}var qn=lw;function cw(n,r){var e=r?qn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var jf=cw;var dw=/\w*$/;function uw(n){var r=new n.constructor(n.source,dw.exec(n));return r.lastIndex=n.lastIndex,r}var Ff=uw;var kf=at?at.prototype:void 0,Uf=kf?kf.valueOf:void 0;function pw(n){return Uf?Object(Uf.call(n)):{}}var Hf=pw;function fw(n,r){var e=r?qn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var Wf=fw;var mw="[object Boolean]",hw="[object Date]",yw="[object Map]",gw="[object Number]",xw="[object RegExp]",vw="[object Set]",bw="[object String]",Sw="[object Symbol]",ww="[object ArrayBuffer]",_w="[object DataView]",Pw="[object Float32Array]",Tw="[object Float64Array]",Ow="[object Int8Array]",Aw="[object Int16Array]",Cw="[object Int32Array]",Nw="[object Uint8Array]",Iw="[object Uint8ClampedArray]",Mw="[object Uint16Array]",Lw="[object Uint32Array]";function Ew(n,r,e){var t=n.constructor;switch(r){case ww:return qn(n);case mw:case hw:return new t(+n);case _w:return jf(n,e);case Pw:case Tw:case Ow:case Aw:case Cw:case Nw:case Iw:case Mw:case Lw:return Wf(n,e);case yw:return new t;case gw:case bw:return new t(n);case xw:return Ff(n);case vw:return new t;case Sw:return Hf(n)}}var qf=Ew;function Dw(n){return typeof n.constructor=="function"&&!Ln(n)?vp(Fn(n)):{}}var $f=Dw;var Bw="[object Map]";function Rw(n){return ht(n)&&Zr(n)==Bw}var Yf=Rw;var Xf=Xr&&Xr.isMap,Gw=Xf?Dn(Xf):Yf,Kf=Gw;var Vw="[object Set]";function zw(n){return ht(n)&&Zr(n)==Vw}var Zf=zw;var Qf=Xr&&Xr.isSet,jw=Qf?Dn(Qf):Zf,Jf=jw;var Fw=1,kw=2,Uw=4,em="[object Arguments]",Hw="[object Array]",Ww="[object Boolean]",qw="[object Date]",$w="[object Error]",tm="[object Function]",Yw="[object GeneratorFunction]",Xw="[object Map]",Kw="[object Number]",rm="[object Object]",Zw="[object RegExp]",Qw="[object Set]",Jw="[object String]",e1="[object Symbol]",t1="[object WeakMap]",r1="[object ArrayBuffer]",o1="[object DataView]",n1="[object Float32Array]",i1="[object Float64Array]",a1="[object Int8Array]",s1="[object Int16Array]",l1="[object Int32Array]",c1="[object Uint8Array]",d1="[object Uint8ClampedArray]",u1="[object Uint16Array]",p1="[object Uint32Array]",Ge={};Ge[em]=Ge[Hw]=Ge[r1]=Ge[o1]=Ge[Ww]=Ge[qw]=Ge[n1]=Ge[i1]=Ge[a1]=Ge[s1]=Ge[l1]=Ge[Xw]=Ge[Kw]=Ge[rm]=Ge[Zw]=Ge[Qw]=Ge[Jw]=Ge[e1]=Ge[c1]=Ge[d1]=Ge[u1]=Ge[p1]=!0;Ge[$w]=Ge[tm]=Ge[t1]=!1;function Rs(n,r,e,t,o,i){var a,s=r&Fw,c=r&kw,u=r&Uw;if(e&&(a=o?e(n,t,o,i):e(n)),a!==void 0)return a;if(!Ut(n))return n;var l=He(n);if(l){if(a=zf(n),!s)return Sp(n,a)}else{var d=Zr(n),p=d==tm||d==Yw;if(Wo(n))return Nf(n,s);if(d==rm||d==em||p&&!o){if(a=c||p?{}:$f(n),!s)return c?Ef(n,Pf(a,n)):Lf(n,_f(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),Jf(n)?n.forEach(function(y){a.add(Rs(y,r,e,y,n,i))}):Kf(n)&&n.forEach(function(y,g){a.set(g,Rs(y,r,e,g,n,i))});var m=u?c?Ls:ga:c?Rn:Bn,h=l?void 0:m(n);return Op(h||n,function(y,g){h&&(g=y,y=n[g]),In(a,g,Rs(y,r,e,g,n,i))}),a}var Gs=Rs;var f1=1,m1=4;function h1(n){return Gs(n,f1|m1)}var Qr=h1;var y1="__lodash_hash_undefined__";function g1(n){return this.__data__.set(n,y1),this}var om=g1;function x1(n){return this.__data__.has(n)}var nm=x1;function Vs(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new qo;++r<e;)this.add(n[r])}Vs.prototype.add=Vs.prototype.push=om;Vs.prototype.has=nm;var im=Vs;function v1(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 am=v1;function b1(n,r){return n.has(r)}var sm=b1;var S1=1,w1=2;function _1(n,r,e,t,o,i){var a=e&S1,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&w1?new im: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(!am(r,function(g,x){if(!sm(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 zs=_1;function P1(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var lm=P1;function T1(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var cm=T1;var O1=1,A1=2,C1="[object Boolean]",N1="[object Date]",I1="[object Error]",M1="[object Map]",L1="[object Number]",E1="[object RegExp]",D1="[object Set]",B1="[object String]",R1="[object Symbol]",G1="[object ArrayBuffer]",V1="[object DataView]",dm=at?at.prototype:void 0,Dc=dm?dm.valueOf:void 0;function z1(n,r,e,t,o,i,a){switch(e){case V1:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case G1:return!(n.byteLength!=r.byteLength||!i(new Wn(n),new Wn(r)));case C1:case N1:case L1:return Nn(+n,+r);case I1:return n.name==r.name&&n.message==r.message;case E1:case B1:return n==r+"";case M1:var s=lm;case D1:var c=t&O1;if(s||(s=cm),n.size!=r.size&&!c)return!1;var u=a.get(n);if(u)return u==r;t|=A1,a.set(n,r);var l=zs(s(n),s(r),t,o,i,a);return a.delete(n),l;case R1:if(Dc)return Dc.call(n)==Dc.call(r)}return!1}var um=z1;var j1=1,F1=Object.prototype,k1=F1.hasOwnProperty;function U1(n,r,e,t,o,i){var a=e&j1,s=ga(n),c=s.length,u=ga(r),l=u.length;if(c!=l&&!a)return!1;for(var d=c;d--;){var p=s[d];if(!(a?p in r:k1.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 pm=U1;var H1=1,fm="[object Arguments]",mm="[object Array]",js="[object Object]",W1=Object.prototype,hm=W1.hasOwnProperty;function q1(n,r,e,t,o,i){var a=He(n),s=He(r),c=a?mm:Zr(n),u=s?mm:Zr(r);c=c==fm?js:c,u=u==fm?js:u;var l=c==js,d=u==js,p=c==u;if(p&&Wo(n)){if(!Wo(r))return!1;a=!0,l=!1}if(p&&!l)return i||(i=new Un),a||Ps(n)?zs(n,r,e,t,o,i):um(n,r,c,e,t,o,i);if(!(e&H1)){var f=l&&hm.call(n,"__wrapped__"),m=d&&hm.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),pm(n,r,e,t,o,i)):!1}var ym=q1;function gm(n,r,e,t,o){return n===r?!0:n==null||r==null||!ht(n)&&!ht(r)?n!==n&&r!==r:ym(n,r,e,t,gm,o)}var xm=gm;function $1(n,r){return n!=null&&r in Object(n)}var vm=$1;function Y1(n,r,e){r=Xt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var a=go(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)||En(n)))}var bm=Y1;function X1(n,r){return n!=null&&bm(n,r,vm)}var Sm=X1;function K1(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var wm=K1;function Z1(n,r){return r.length<2?n:As(n,gf(r,0,-1))}var _m=Z1;function Q1(n,r){return xm(n,r)}var xa=Q1;function J1(n,r){return r=Xt(r,n),n=_m(n,r),n==null||delete n[go(wm(r))]}var Pm=J1;function e_(n){return yf(n)?void 0:n}var Tm=e_;var t_=1,r_=2,o_=4,n_=Cs(function(n,r){var e={};if(n==null)return e;var t=!1;r=xs(r,function(i){return i=Xt(i,n),t||(t=i.length>1),i}),Sr(n,Ls(n),e),t&&(e=Gs(e,t_|r_|o_,Tm));for(var o=r.length;o--;)Pm(e,r[o]);return e}),$n=n_;function i_(n,r,e,t){if(!Ut(n))return n;r=Xt(r,n);for(var o=-1,i=r.length,a=i-1,s=n;s!=null&&++o<i;){var c=go(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=Ut(l)?l:Cn(r[o+1])?[]:{})}In(s,c,u),s=s[c]}return n}var Om=i_;function a_(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var a=r[t],s=As(n,a);e(s,a)&&Om(i,Xt(a,n),s)}return i}var Am=a_;function s_(n,r){return Am(n,r,function(e,t){return Sm(n,t)})}var Cm=s_;var l_=Cs(function(n,r){return n==null?{}:Cm(n,r)}),nr=l_;var he=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,he.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,he.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,he.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function va(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"&&va(t)}return Object.freeze(n)}function Nm(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 Fs(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 Im(){return typeof process<"u"}function Mm(n,r){for(let e of n)r(e.id,e.data)!==!0&&Mm(e.children,r)}function Lm(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Lm(e,r)}var Fe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Fe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)va(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&&Lm(o,t)}}traverse(e){Mm(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)=>Nm(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 ge=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ge.prototype)}deepFreeze(){let e=0;for(;e<this.length;)va(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,ge.prototype);let t=e;return Im()||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?Fs(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=Fs(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=Fs(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}}},_r;(t=>{function n(o,i){return ba(o,i)??o}t.apply=n;function r(o,i){return Rc(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=Tt.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=Bc([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(_r||(_r={}));function Bc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=ba(o.data,r[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Bc(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 c_(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,a=ba(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 ba(n,r){if(!Zn(r))return r;if(n instanceof Fe){let e=Bc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ge)return c_(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let a=ba(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 Rc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let a=ba(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 Rc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Zn(r))return r;if(!Zn(n))return _r.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=Rc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Em(n,r){let e={cur:[],result:[],len:0};return n=Sa(n,r,e)??n,[n,e.result]}function ks(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Us(n){n&&(n.len-=1)}function d_(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Dm(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=Sa(i.data,r,ks(e,a));Us(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=Dm(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 u_(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=Sa(i.data,r,ks(e,a));return Us(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 Sa(n,r,e){if(n instanceof Fe){let t=Dm(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ge)return u_(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,a)=>{let s=Sa(i,r,ks(e,a));return Us(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=Sa(a,r,ks(e,i));Us(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&&d_(e),t}else return}}var Hs;(r=>{function n(e,t){let o=Tt.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})(Hs||(Hs={}));var Qe;(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 ge||c instanceof he?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 ge){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 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 ge){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})(Qe||(Qe={}));var wa;(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=>Qe.subsumed(p,f))),...l]}c.compress=o;function i(u,l){return u.every(d=>l.every(p=>Qe.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=Tt.zoom(d,[...m.path,m.id]),y=Qe.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,x]=Em(d,{[m.id]:h});d=g;for(let S of x){let w=S[S.length-1];S.splice(S.length-1,1),p.push({type:0,path:S,props:{[w]:h}}),f.push({type:0,path:S,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=Qe.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})(wa||(wa={}));var Bm=Symbol(),p_=Symbol(),qs=Symbol(),Yo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Ws);){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[qs];t&&t(),delete this._children[r]}}}},Vc=class extends Yo{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)}},zc=class extends Yo{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,he.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Rm={get(n,r){if(r===qs)return()=>{n._parent=null};if(r===Bm)return n._current;if(r===p_)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=$s(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]}}},f_={...Rm,set(n,r,e){let t={type:0,props:{[r]:Je(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}},m_={...Rm,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 Yo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[qs]=()=>{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=$s(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 Yo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[qs]=()=>{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=$s(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 Gc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Tt.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Ws=class extends Yo{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){Gc(this.ts,e,r),Gc(this.actual,t,r),Gc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function $s(n,r,e){return e instanceof Fe?new Qn(n,r,e):e instanceof ge?new Jn(n,r,e):e instanceof he?new Proxy(new zc(n,r,e),m_):e!==null&&typeof e=="object"?Xn(e)?e:new Proxy(new Vc(n,r,e),f_):e}function jc(n){let r=new Ws(n);return[$s(r,"",n),r]}function xo(n,r){let[e,t]=jc(n);return r(e),t.result()}function Je(n){return n instanceof Qn||n instanceof Jn?n._current:n!==null&&typeof n=="object"?n[Bm]:n}var Tt;(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 ge||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})(Tt||(Tt={}));function Gm(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 Ys=class{},_a=class extends Ys{constructor(e){super();this.id=e}},Pa=class extends Ys{constructor(e){super();this.data=e}};var kc;try{kc=new TextDecoder}catch{}var re,bo,I=0;var Wm=[],Uc=Wm,Hc=0,Bt={},Ie,vo,Kt=0,Pr=0,Ht,Jr,Ot=[],Le,Vm={useRecords:!1,mapsAsObjects:!0},Ta=class{},qc=new Ta;qc.name="MessagePack 0xC1";var ei=!1,Tr=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 Km(()=>(Ks(),this?this.unpack(r,e):Tr.prototype.unpack.call(Vm,r,e)));bo=e>-1?e:r.length,I=0,Hc=0,Pr=0,vo=null,Uc=Wm,Ht=null,re=r;try{Le=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 Tr){if(Bt=this,this.structures)return Ie=this.structures,Xs();(!Ie||Ie.length>0)&&(Ie=[])}else Bt=Vm,(!Ie||Ie.length>0)&&(Ie=[]);return Xs()}unpackMultiple(r,e){let t,o=0;try{ei=!0;let i=r.length,a=this?this.unpack(r,i):Js.unpack(r,i);if(e){for(e(a);I<i;)if(o=I,e(Xs())===!1)return}else{for(t=[a];I<i;)o=I,t.push(Xs());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{ei=!1,Ks()}}_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 Xs(){try{if(!Bt.trusted&&!ei){let r=Ie.sharedLength||0;r<Ie.length&&(Ie.length=r)}let n=We();if(I==bo)Ie.restoreStructures&&zm(),Ie=null,re=null,Jr&&(Jr=null);else if(I>bo){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&&zm(),Ks(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function zm(){for(let n in Ie.restoreStructures)Ie[n]=Ie.restoreStructures[n];Ie.restoreStructures=null}function We(){let n=re[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Ie[n&63]||Bt.getStructures&&qm()[n&63];return r?(r.read||(r.read=$c(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Bt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Ym()]=We();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(We(),We());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=We();return r}else if(n<192){let r=n-160;if(Pr>=I)return vo.slice(I-Kt,(I+=r)-Kt);if(Pr==0&&bo<140){let e=r<16?Yc(r):$m(r);if(e!=null)return e}return Wc(r)}else{let r;switch(n){case 192:return null;case 193:return Ht?(r=We(),r>0?Ht[1].slice(Ht.position1,Ht.position1+=r):Ht[0].slice(Ht.position0,Ht.position0-=r)):qc;case 194:return!1;case 195:return!0;case 196:return Fc(re[I++]);case 197:return r=Le.getUint16(I),I+=2,Fc(r);case 198:return r=Le.getUint32(I),I+=4,Fc(r);case 199:return Xo(re[I++]);case 200:return r=Le.getUint16(I),I+=2,Xo(r);case 201:return r=Le.getUint32(I),I+=4,Xo(r);case 202:if(r=Le.getFloat32(I),Bt.useFloat32>2){let e=Qs[(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=Le.getFloat64(I),I+=8,r;case 204:return re[I++];case 205:return r=Le.getUint16(I),I+=2,r;case 206:return r=Le.getUint32(I),I+=4,r;case 207:return Bt.int64AsNumber?(r=Le.getUint32(I)*4294967296,r+=Le.getUint32(I+4)):r=Le.getBigUint64(I),I+=8,r;case 208:return Le.getInt8(I++);case 209:return r=Le.getInt16(I),I+=2,r;case 210:return r=Le.getInt32(I),I+=4,r;case 211:return Bt.int64AsNumber?(r=Le.getInt32(I)*4294967296,r+=Le.getUint32(I+4)):r=Le.getBigInt64(I),I+=8,r;case 212:if(r=re[I++],r==114)return Hm(re[I++]&63);{let e=Ot[r];if(e)return e.read?(I++,e.read(We())):e.noBuffer?(I++,e()):e(re.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=re[I],r==114?(I++,Hm(re[I++]&63,re[I++])):Xo(2);case 214:return Xo(4);case 215:return Xo(8);case 216:return Xo(16);case 217:return r=re[I++],Pr>=I?vo.slice(I-Kt,(I+=r)-Kt):y_(r);case 218:return r=Le.getUint16(I),I+=2,Pr>=I?vo.slice(I-Kt,(I+=r)-Kt):g_(r);case 219:return r=Le.getUint32(I),I+=4,Pr>=I?vo.slice(I-Kt,(I+=r)-Kt):x_(r);case 220:return r=Le.getUint16(I),I+=2,Fm(r);case 221:return r=Le.getUint32(I),I+=4,Fm(r);case 222:return r=Le.getUint16(I),I+=2,km(r);case 223:return r=Le.getUint32(I),I+=4,km(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 h_=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function $c(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>h_.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(We);return n.highByte===0&&(n.read=jm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let a=n[o];t[a]=We()}return t}return e.count=0,n.highByte===0?jm(r,e):e}var jm=(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=$c(o,n)),o.read()};function qm(){let n=Km(()=>(re=null,Bt.getStructures()));return Ie=Bt._mergeStructures(n,Ie)}var Wc=Zs,y_=Zs,g_=Zs,x_=Zs;function Zs(n){let r;if(n<16&&(r=Yc(n)))return r;if(n>64&&kc)return kc.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+=st.apply(String,t),t.length=0)}return t.length>0&&(r+=st.apply(String,t)),r}function Fm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=We();return r}function km(n){if(Bt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[Ym()]=We();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(We(),We());return r}}var st=String.fromCharCode;function $m(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 st.apply(String,e)}function Yc(n){if(n<4)if(n<2){if(n===0)return"";{let r=re[I++];if((r&128)>1){I-=1;return}return st(r)}}else{let r=re[I++],e=re[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return st(r,e);let t=re[I++];if((t&128)>0){I-=3;return}return st(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 st(r,e,t,o);{let i=re[I++];if((i&128)>0){I-=5;return}return st(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 st(r,e,t,o,i,a);let s=re[I++];if((s&128)>0){I-=7;return}return st(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 st(r,e,t,o,i,a,s,c);{let u=re[I++];if((u&128)>0){I-=9;return}return st(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 st(r,e,t,o,i,a,s,c,u,l);let d=re[I++];if((d&128)>0){I-=11;return}return st(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 st(r,e,t,o,i,a,s,c,u,l,d,p);{let f=re[I++];if((f&128)>0){I-=13;return}return st(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 st(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 st(r,e,t,o,i,a,s,c,u,l,d,p,f,m,h)}}}}}function Fc(n){return Bt.copyBuffers?Uint8Array.prototype.slice.call(re,I,I+=n):re.subarray(I,I+=n)}function Xo(n){let r=re[I++];if(Ot[r])return Ot[r](re.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var Um=new Array(4096);function Ym(){let n=re[I++];if(n>=160&&n<192){if(n=n-160,Pr>=I)return vo.slice(I-Kt,(I+=n)-Kt);if(!(Pr==0&&bo<180))return Wc(n)}else return I--,We();let r=(n<<5^(n>1?Le.getUint16(I):n>0?re[I]:0))&4095,e=Um[r],t=I,o=I+n-3,i,a=0;if(e&&e.bytes==n){for(;t<o;){if(i=Le.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=[],Um[r]=e,e.bytes=n;t<o;)i=Le.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=re[t++],e.push(i);let s=n<16?Yc(n):$m(n);return s!=null?e.string=s:e.string=Wc(n)}var Hm=(n,r)=>{var e=We();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=$c(e,t),e.read()},Xm=typeof self=="object"?self:global;Ot[0]=()=>{};Ot[0].noBuffer=!0;Ot[101]=()=>{let n=We();return(Xm[n[0]]||Error)(n[1])};Ot[105]=n=>{let r=Le.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=We();return o.used?Object.assign(t,i):(o.target=i,i)};Ot[112]=n=>{let r=Le.getUint32(I-4),e=Jr.get(r);return e.used=!0,e.target};Ot[115]=()=>new Set(We());var Xc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Ot[116]=n=>{let r=n[0],e=Xc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new Xm[e](Uint8Array.prototype.slice.call(n,1).buffer)};Ot[120]=()=>{let n=We();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,Ht=[We(),We()],Ht.position0=0,Ht.position1=0;let t=I;I=e;try{return We()}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 Km(n){let r=bo,e=I,t=Hc,o=Kt,i=Pr,a=vo,s=Uc,c=Jr,u=Ht,l=new Uint8Array(re.slice(0,bo)),d=Ie,p=Ie.slice(0,Ie.length),f=Bt,m=ei,h=n();return bo=r,I=e,Hc=t,Kt=o,Pr=i,vo=a,Uc=s,Jr=c,Ht=u,re=l,ei=m,Ie=d,Ie.splice(0,Ie.length,...p),Bt=f,Le=new DataView(re.buffer,re.byteOffset,re.byteLength),h}function Ks(){re=null,Jr=null,Ie=null}function Zm(n){n.unpack?Ot[n.type]=n.unpack:Ot[n.type]=n}var Qs=new Array(147);for(let n=0;n<256;n++)Qs[n]=+("1e"+Math.floor(45.15-n*.30103));var Js=new Tr({useRecords:!1}),v_=Js.unpack,b_=Js.unpackMultiple,S_=Js.unpack,el={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},w_=new Float32Array(1),UR=new Uint8Array(w_.buffer,0,4);var tl;try{tl=new TextEncoder}catch{}var rl,Zc,ol=typeof Buffer<"u",Kc=ol?Buffer.allocUnsafeSlow:Uint8Array,th=ol?Buffer:Uint8Array,Qm=ol?4294967296:2144337920,G,Ye,L=0,Or,Ar=null,__=/[\u0080-\uFFFF]/,Oa=Symbol("record-id"),Ko=class extends Tr{constructor(r){super(r),this.offset=0;let e,t,o,i,a,s,c=0,u=th.prototype.utf8Write?function(v,N,T){return G.utf8Write(v,N,T)}:tl&&tl.encodeInto?function(v,N){return tl.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 Kc(8192),Ye=new DataView(G.buffer,0,8192),L=0),Or=G.length-10,Or-L<2048?(G=new Kc(G.length),Ye=new DataView(G.buffer,0,G.length),Or=G.length-10,L=0):L=L+7&2147483640,t=L,s=l.structuredClone?new Map:null,l.bundleStrings?(Ar=["",""],G[L++]=214,G[L++]=98,Ar.position=L-t,L+=4):Ar=null,o=l.structures,o){o.uninitialized&&(o=l._mergeStructures(l.getStructures()));let T=o.sharedLength||0;if(T>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<T;C++){let O=o[C];if(!O)continue;let A,M=o.transitions;for(let E=0,X=O.length;E<X;E++){let R=O[E];A=M[R],A||(A=M[R]=Object.create(null)),M=A}M[Oa]=C+64}c=T}d||(o.nextId=T+64)}i&&(i=!1),a=o||[];try{if(b(v),Ar){Ye.setUint32(Ar.position+t,L-Ar.position-t);let T=Ar;Ar=null,b(T[0]),b(T[1])}if(l.offset=L,s&&s.idsToInsert){L+=s.idsToInsert.length*6,L>Or&&P(L),l.offset=L;let T=T_(G.subarray(t,L),s.idsToInsert);return s=null,T}return N&oh?(G.start=t,G.end=L,G):G.subarray(t,L)}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 T=0,C=x.length;T<C;T++)x[T][Oa]=0;x=[]}if(i&&l.saveStructures){let T=o.sharedLength||f;o.length>T&&(o=o.slice(0,T));let C=G.subarray(t,L);return l.saveStructures(o,c)===!1?(l._mergeStructures(l.getStructures()),l.pack(v)):(c=T,C)}}N&L_&&(L=t)}};let b=v=>{L>Or&&(G=P(L));var N=typeof v,T;if(N==="string"){let C=v.length;if(Ar&&C>=8&&C<4096){let M=__.test(v);Ar[M?0:1]+=v,G[L++]=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(L+A>Or&&(G=P(L+A)),C<64||!u){let M,E,X,R=L+O;for(M=0;M<C;M++)E=v.charCodeAt(M),E<128?G[R++]=E:E<2048?(G[R++]=E>>6|192,G[R++]=E&63|128):(E&64512)===55296&&((X=v.charCodeAt(M+1))&64512)===56320?(E=65536+((E&1023)<<10)+(X&1023),M++,G[R++]=E>>18|240,G[R++]=E>>12&63|128,G[R++]=E>>6&63|128,G[R++]=E&63|128):(G[R++]=E>>12|224,G[R++]=E>>6&63|128,G[R++]=E&63|128);T=R-L-O}else T=u(v,L+O,A);T<32?G[L++]=160|T:T<256?(O<2&&G.copyWithin(L+2,L+1,L+1+T),G[L++]=217,G[L++]=T):T<65536?(O<3&&G.copyWithin(L+3,L+2,L+2+T),G[L++]=218,G[L++]=T>>8,G[L++]=T&255):(O<5&&G.copyWithin(L+5,L+3,L+3+T),G[L++]=219,Ye.setUint32(L,T),L+=4),L+=T}else if(N==="number")if(v>>>0===v)v<64?G[L++]=v:v<256?(G[L++]=204,G[L++]=v):v<65536?(G[L++]=205,G[L++]=v>>8,G[L++]=v&255):(G[L++]=206,Ye.setUint32(L,v),L+=4);else if(v>>0===v)v>=-32?G[L++]=256+v:v>=-128?(G[L++]=208,G[L++]=v+256):v>=-32768?(G[L++]=209,Ye.setInt16(L,v),L+=2):(G[L++]=210,Ye.setInt32(L,v),L+=4);else{let C;if((C=this.useFloat32)>0&&v<4294967296&&v>=-2147483648){G[L++]=202,Ye.setFloat32(L,v);let O;if(C<4||(O=v*Qs[(G[L]&127)<<1|G[L+1]>>7])>>0===O){L+=4;return}else L--}G[L++]=203,Ye.setFloat64(L,v),L+=8}else if(N==="object")if(!v)G[L++]=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[L++]=214,G[L++]=112,Ye.setUint32(L,O.id),L+=4;return}else s.set(v,{offset:L-t})}let C=v.constructor;if(C===Object)_(v,!0);else if(C===Array){T=v.length,T<16?G[L++]=144|T:T<65536?(G[L++]=220,G[L++]=T>>8,G[L++]=T&255):(G[L++]=221,Ye.setUint32(L,T),L+=4);for(let O=0;O<T;O++)b(v[O])}else if(C===Map){T=v.size,T<16?G[L++]=128|T:T<65536?(G[L++]=222,G[L++]=T>>8,G[L++]=T&255):(G[L++]=223,Ye.setUint32(L,T),L+=4);for(let[O,A]of v)b(O),b(A)}else{for(let O=0,A=rl.length;O<A;O++){let M=Zc[O];if(v instanceof M){let E=rl[O];if(E.write){E.type&&(G[L++]=212,G[L++]=E.type,G[L++]=0),b(E.write.call(this,v));return}let X=G,R=Ye,Z=L;G=null;let z;try{z=E.pack.call(this,v,V=>(G=X,X=null,L+=V,L>Or&&P(L),{target:G,targetView:Ye,position:L-V}),b)}finally{X&&(G=X,Ye=R,L=Z,Or=G.length-10)}z&&(z.length+L>Or&&P(z.length+L),L=P_(z,G,L,E.type));return}}_(v,!v.hasOwnProperty)}}else if(N==="boolean")G[L++]=v?195:194;else if(N==="bigint"){if(v<BigInt(1)<<BigInt(63)&&v>=-(BigInt(1)<<BigInt(63)))G[L++]=211,Ye.setBigInt64(L,v);else if(v<BigInt(1)<<BigInt(64)&&v>0)G[L++]=207,Ye.setBigUint64(L,v);else if(this.largeBigIntToFloat)G[L++]=203,Ye.setFloat64(L,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");L+=8}else if(N==="undefined")this.encodeUndefinedAsNil?G[L++]=192:(G[L++]=212,G[L++]=0,G[L++]=0);else if(N==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},_=this.useRecords===!1?this.variableMapSize?v=>{let N=Object.keys(v),T=N.length;T<16?G[L++]=128|T:T<65536?(G[L++]=222,G[L++]=T>>8,G[L++]=T&255):(G[L++]=223,Ye.setUint32(L,T),L+=4);let C;for(let O=0;O<T;O++)b(C=N[O]),b(v[C])}:(v,N)=>{G[L++]=222;let T=L-t;L+=2;let C=0;for(let O in v)(N||v.hasOwnProperty(O))&&(b(O),b(v[O]),C++);G[T+++t]=C>>8,G[T+t]=C&255}:v=>{let N=Object.keys(v),T,C=a.transitions||(a.transitions=Object.create(null)),O=0;for(let M=0,E=N.length;M<E;M++){let X=N[M];T=C[X],T||(T=C[X]=Object.create(null),O++),C=T}let A=C[Oa];if(A)A>=96&&h?(G[L++]=((A-=96)&31)+96,G[L++]=A>>5):G[L++]=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[Oa]=A,a[A-64]=N,A<y?(N.isShared=!0,a.sharedLength=A-63,i=!0,M>=0?(G[L++]=(A&31)+96,G[L++]=M):G[L++]=A):(M>=0?(G[L++]=213,G[L++]=114,G[L++]=(A&31)+96,G[L++]=M):(G[L++]=212,G[L++]=114,G[L++]=A),O&&(S+=w*O),x.length>=m&&(x.shift()[Oa]=0),x.push(C),b(N))}for(let M=0,E=N.length;M<E;M++)b(v[N[M]])},P=v=>{let N;if(v>16777216){if(v-t>Qm)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(Qm,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 T=new Kc(N);return Ye=new DataView(T.buffer,0,N),G.copy?G.copy(T,0,t,v):T.set(G.slice(t,v)),L-=t,t=0,Or=T.length-10,G=T}}useBuffer(r){G=r,Ye=new DataView(G.buffer,G.byteOffset,G.byteLength),L=0}};Zc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ta];rl=[{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?Jm(n,16,r):eh(ol?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==th&&this.structuredClone?Jm(n,Xc.indexOf(e.name),r):eh(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function Jm(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 eh(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 P_(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 T_(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 So(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)");Zc.unshift(n.Class),rl.unshift(n)}Zm(n)}var rh=new Ko({useRecords:!1}),O_=rh.pack,A_=rh.pack;var{NEVER:C_,ALWAYS:N_,DECIMAL_ROUND:I_,DECIMAL_FIT:M_}=el,oh=512,L_=1024;var nh=new Ko({structuredClone:!0});So({Class:he.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,he.prototype),n}});So({Class:ge.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ge.prototype),n}});So({Class:Fe.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Fe.prototype),n}});So({Class:_a.prototype.constructor,type:4,write(n){return n.id},read(n){return new _a(n)}});So({Class:Pa.prototype.constructor,type:5,write(n){return n.data},read(n){return new Pa(n)}});So({Class:Re.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});function E_(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 Qc(n){if(Xn(n))return n;if(Array.isArray(n))return n.map(Qc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=Qc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var nl;(t=>{function n(o){return nh.pack(o)}t.serialize=n;function r(o){return nh.unpack(o)}t.deserialize=r;function e(o){return E_(n(Qc(o))).toString()}t.checksum=e})(nl||(nl={}));var Po="personal camera",To="a218fcc3-276b-49b9-b485-49037fd14f5f",dh=2960946,tt=5526619;var ih;(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})(ih||(ih={}));var wo;(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})(wo||(wo={}));var ah;(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})(ah||(ah={}));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 lt;(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})(lt||(lt={}));var At;(s=>{s.white={...lt.white,a:1},s.transparent={...lt.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{...lt.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 lt.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 il;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(il||(il={}));var sh;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(sh||(sh={}));var lh;(r=>r.defaultData={control1:[.5,0],control2:[.5,1]})(lh||(lh={}));var ch;(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]))(ch||(ch={}));var ir;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(ir||(ir={}));var Oo;(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})(Oo||(Oo={}));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(D_.forEach(a=>{Object.assign(i,{[a]:o[a]??t[a]})}),i.radial={...t.radial},o.radial){let a=t.radial,s=o.radial;B_.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;R_.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;G_.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;V_.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;z_.forEach(c=>{Object.assign(i.randomnessObject,{[c]:s[c]??a[c]})})}return i}e.merge=r})(Cr||(Cr={}));var al;(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})(al||(al={}));var D_=["count"],B_=["radius","start","end","position","scale","rotation"],R_=["position","scale","rotation"],G_=["count","size"],V_=["count","position","scale","rotation"],z_=["strength","scale","rotation","position","movement","seed","freqScale"];var sl;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(sl||(sl={}));var ll;(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")}})(ll||(ll={}));var Ao;(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]})(Ao||(Ao={}));var Jc;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(Jc||(Jc={}));var ed;(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})(ed||(ed={}));var cl;(r=>r.defaultData={...ed.defaultData,...Jc.defaultData})(cl||(cl={}));var uh;(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})(uh||(uh={}));var ti;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(ti||(ti={}));var ph;(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})(ph||(ph={}));function mh(n){return n.type!=="displace"}var fh;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(fh||(fh={}));var hh=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],yh=["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:lt.fromHex(tt)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...lt.fromHex(6710886),a:1},colorB:{...lt.fromHex(6710886),a:1},colorC:{...lt.fromHex(16777215),a:1},colorD:{...lt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color: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:{...lt.fromHex(0),a:1},colorB:{...lt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Ct||(Ct={}));var yt;(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 ge}}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 ge;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 ge;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 ge;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})(yt||(yt={}));var ri;(r=>{function n(){return{points:new ge,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(ri||(ri={}));var oi;(r=>{function n(){return{points:new ge,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(oi||(oi={}));var td={type:"Ellipse",width:100,height:100,spikes:16,angle:360,innerRadius:0};var dl;(r=>{function n(e,t){let o={...e};return j_.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(dl||(dl={}));var ul={shape:td,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},j_=["depth","offset","angle","twist","startScale","endScale"];var Aa;(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})(Aa||(Aa={}));var pl;(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,dl.merge(o.extrusion,t.extrusion))),o}r.merge=n})(pl||(pl={}));var Co;(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:ul};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:"",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:Math.PI};throw new Error("not implemented")}r.defaultData=n})(Co||(Co={}));var fl;(r=>r.defaultData={enabled:!1,useBackgroundColor:!1,color:lt.white,near:.1,far:2e3})(fl||(fl={}));var ml;(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}}})(ml||(ml={}));var rd;(r=>r.defaultData={softShadowQuality:"low"})(rd||(rd={}));var od;(r=>r.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(od||(od={}));var nd;(r=>r.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(nd||(nd={}));var Ca;(r=>r.defaultData={usePhysics:!1,gravity:-10})(Ca||(Ca={}));var id;(r=>r.defaultData={playCamera:Po,gameControlObject:null})(id||(id={}));var hl;(r=>r.defaultData={backgroundColor:At.fromHexAndA(dh,1),postprocessing:ml.defaultData,fog:fl.defaultData,globalPhysics:Ca.defaultData,ambient:od.defaultData,ao:nd.defaultData,shadow:rd.defaultData,publish:id.defaultData})(hl||(hl={}));var gh;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(gh||(gh={}));var ni;(o=>{o.identity={...il.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 op({position:wo.isEqual(i.position,a.position)?void 0:a.position,rotation:wo.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:wo.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 gt;(r=>r.defaultData={states:new ge,events:new ge,visible:!0,raycastLock:!1,physics:Ao.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ni.identity,cloner:null})(gt||(gt={}));var yl;(r=>r.defaultData={type:"Empty",...gt.defaultData})(yl||(yl={}));var xh;(r=>r.defaultData={type:"Component",...gt.defaultData})(xh||(xh={}));var Zo;(r=>r.defaultData={type:"Mesh",...gt.defaultData,...cl.defaultData})(Zo||(Zo={}));var Qo;(r=>r.defaultData={...gt.defaultData,...ni.identity,position:[0,0,Oo.DefaultTargetOffset],...Oo.defaultData})(Qo||(Qo={}));var gl;(e=>{function n(t){return{...gt.defaultData,...ll.defaultData(t)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(gl||(gl={}));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{...gt.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",...gt.defaultData,physics:{...Ao.defaultData,fusedBody:!1},...hl.defaultData,camera:Qo.defaultData})(eo||(eo={}));var xl;(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:Ao.defaultData,states:new ge,events:new ge,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Oo.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",...gt.defaultData,...Zo.defaultData,geometry:Co.defaultData("RectangleGeometry"),material:yt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...gt.defaultData,...Zo.defaultData,geometry:Co.defaultData("BooleanGeometry"),material:yt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...gt.defaultData,...Zo.defaultData,geometry:Co.defaultData("TextGeometry"),material:yt.defaultTwoLayerData("phong","layer1","layer2")}))(xl||(xl={}));var Jo;(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=xo(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=xo(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(...al.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:pl.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(sl.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=lt.clone(c.color))}return s}o.patch=t})(Jo||(Jo={}));var ai;(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})(ai||(ai={}));var Ir;(r=>r.defaultData={orbitControls:ai.defaultData,playPage:To,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 ad;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(ad||(ad={}));var sd;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(sd||(sd={}));var No;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...ad.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:sd.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(No||(No={}));var vh;(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=si.getComponentData(t,s.component)?.data;c&&i(a,s,c.events)}else i(a,s,s.events)})}e.traverseModuleInstances=r})(vh||(vh={}));var Io;(s=>{s.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function r(c={withLight:!0,withSquare:!0}){let u=[],l=xl.defaultMeshObject;c.withLight===!0&&u.push({fi:-1,data:gl.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:To,data:{...eo.defaultData,name:"Scene 1"},children:u}),d}s.defaultData={objects:r(),publish:Ir.defaultData,styles:No.defaultData()},s.emptyDataWithoutPage=function(){return{objects:new Fe,publish:Ir.defaultData,styles:No.defaultData()}},s.emptyDataWithPage=function(c){return{objects:r(c),publish:Ir.defaultData,styles:No.defaultData()}};function i(c){return{...s.defaultData,objects:or(c,Fe.prototype)}}s.withObjs=i;function a(c,u){return i([{id:c,data:u,children:[],fi:0}])}s.withObj=a})(Io||(Io={}));var li;(r=>r.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(li||(li={}));var ci;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(ci||(ci={}));var ld;(r=>r.all=["images","videos","colors","audios","fonts","materials"])(ld||(ld={}));var bh;(r=>r.all=[...ld.all,"components"])(bh||(bh={}));var Sh;(r=>{function n(){return{images:new he,videos:new he,colors:new he,audios:new he,fonts:new he,materials:new he,components:new he}}r.defaultData=n})(Sh||(Sh={}));var en;(r=>{function n(){return{images:new he,videos:new he,colors:new he,audios:new he,fonts:new he,materials:new he,components:new he}}r.defaultData=n})(en||(en={}));var ar;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},or(o,he.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...ci.emptyImage,name:"AI generated image"}),or(i,he.prototype)}t.defaultImages=r;function e(){return{catelogs:new he,materials:new he,images:new he,videos:new he,colors:new he,audios:new he,fonts:new he,lib:en.defaultData()}}t.emptyData=e})(ar||(ar={}));import{MathUtils as Sl}from"three";var vl;(r=>r.list=["idle","move","jump","run"])(vl||(vl={}));var bl;(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 ge,move:new ge,jump:new ge,run:new ge},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)}}))(bl||(bl={}));function wh(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(Je(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={...Je(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]=yt.defaultData(),o=t.materials[i]),typeof o!="string"&&r(o)}):"material"in t?typeof t.material!="string"&&(t.material===void 0&&(t.material=yt.defaultData()),r(t.material)):t.type==="Mesh"&&(t.material===void 0&&(t.material=yt.defaultData()),r(t.material)),"overrides"in t&&Object.values(t.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&r(o.material)})})}function F_(n){Object.assign(n.scene.publish,{orbitControls:{...ai.defaultData,...Je(n.scene.publish.orbitControls)}})}function k_(n){Object.assign(n.scene.publish.settings,{video:{...Ir.defaultData.settings.video,...Je(n.scene.publish.settings.video)}})}function U_(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((hh.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[a,s]of Object.entries(i))(yh.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 H_(n){n.scene.publish.withBackground=!0}function W_(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function q_(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 $_(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 Y_(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=Je(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=Je(e).booleanExclude!==!0)}})}function X_(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 K_(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=Je(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=Je(c).layers;e(u),c.layers=u}})})}function _h(n){n.layers===void 0&&Object.assign(n,yt.defaultTwoLayerData("lambert"))}function cd(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={...Je(r),colors:e,steps:t};Object.assign(r,o)}})}function Z_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Ph(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&cd(t)}):"material"in e&&typeof e.material!="string"&&cd(e.material)}),Object.values(n.shared.materials).forEach(r=>cd(r))}function Q_(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 J_(n){n.shared.audios=or({},he.prototype)}function eP(n){n.shared.videos=or({},he.prototype)}function tP(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 rP(n){Object.entries(Je(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(Je(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function oP(n){n.scene.publish.settings.web.preload=!1}function Th(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 Oh(n){n.layers&&n.layers.forEach(r=>{mh(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 nP(n){n.shared.fonts=or({},he.prototype)}function iP(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 aP(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=yt.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=iP(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let c={name:o.name,...gt.defaultData,...Zo.defaultData,flatShading:!1,wireframe:!1,geometry:{...Co.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:Je(o.states),events:Je(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=Je(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 sP(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 ge,move:new ge,jump:new ge}});else{let i=new ge;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:Sl.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 ge({fi:0,id:Sl.generateUUID(),data:u},{fi:1,id:Sl.generateUUID(),data:p})};i.push({fi:c,id:s,data:f})}),delete o.targets)}})})}function lP(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let a=new ge,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:Sl.generateUUID(),data:{type:o,actions:a}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Ah(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 Ch(n){to(n,Ah),ro(n,Ah)}function cP(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function dP(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 uP(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=yt.defaultTwoLayerData("phong"))})}function pP(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 fP(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 mP(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 hP(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function yP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function gP(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function xP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=bl.defaultDataThirdPerson.navmesh)})})}function vP(n){n.scene.styles||(n.scene.styles=No.defaultData())}function Nh(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function bP(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,Nh),to(n,Nh)}function SP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&Object.assign(t.gameActions,{run:new ge})})})}function wP(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.keyAssignments=[...t.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Ih(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.bumpMapIntensity===void 0&&(r.bumpMapIntensity=5)})}function Mh(n,r){if(r<1&&(ro(n,wh),to(n,wh),n.schema=1),r<2&&(F_(n),n.schema=2),r<3&&(U_(n),n.schema=3),r<4&&(H_(n),n.schema=4),r<5&&(W_(n),n.schema=5),r<6&&(q_(n),n.schema=6),r<7&&($_(n),n.schema=7),r<8&&(n.schema=8),r<9&&(Ph(n),n.schema=9),r<10&&(Z_(n),n.schema=10),r<11&&(Q_(n),n.schema=11),r<12&&(Ph(n),n.schema=12),r<13&&(J_(n),n.schema=13),r<14&&(tP(n),n.schema=14),r<15&&(rP(n),n.schema=15),r<16&&(oP(n),n.schema=16),r<17&&(ro(n,Th),to(n,Th),n.schema=17),r<18&&(ro(n,_h),to(n,_h),n.schema=18),r<19&&(k_(n),n.schema=19),r<20&&(nP(n),aP(n),n.schema=20),r<21&&(sP(n),lP(n),n.schema=21),r<22&&(Ch(n),n.schema=22),r<23&&(cP(n),n.schema=23),r<24&&(dP(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(eP(n),r<25&&(n.schema=25)),r<26&&(Y_(n),n.schema=26),r<27&&(X_(n),n.schema=27),r<28&&(Ch(n),n.schema=28),r<29&&(K_(n),n.schema=29),r<30&&(uP(n),n.schema=30),r<31&&(pP(n),n.schema=31),r<33&&(fP(n),n.schema=33),r<34&&(mP(n),n.schema=34),r<35&&(hP(n),n.schema=35),r<36&&(yP(n),n.schema=36),r<37&&(gP(n),n.schema=37),r<38&&(ro(n,Oh),to(n,Oh),n.schema=38),r<39&&(xP(n),n.schema=39),r<40&&(vP(n),n.schema=40),r<41&&(bP(n),n.schema=41),r<42&&(SP(n),n.schema=42),r<43&&(wP(n),n.schema=43),r<99){ro(n,Ih),to(n,Ih),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=Po);let e=Je(n.scene.objects),t=n.scene.objects;n.scene.publish.playPage=To,t.insertBefore(null,null,[{id:To,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:{...Ca.defaultData,...nr(n.scene.environment,"usePhysics","gravity")},camera:Je(n.scene.ownerCamera)??eo.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==Io.TRASH_CAN_ID&&t.move(To,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,Ao.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function Lh(n){n.layers&&n.layers.forEach(r=>{r.type==="light"&&r.alphaOverride===void 0&&(r.alphaOverride=1)})}function _P(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 Mo=104;function wl(n){let r=n.schema??0;r!==Mo&&(console.warn("updating from ",r,"to ",Mo),Mh(n,r),r<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Ir.defaultData.joystickSizeAndXYOffset),n.schema=100),r<101&&(ro(n,Lh),to(n,Lh),n.schema=101),r<102&&(_P(n),n.schema=102),r<104&&(n.shared.catelogs=new he,n.shared.lib=en.defaultData(),n.schema=104))}var si;(s=>{s.defaultData={schema:Mo,scene:Io.defaultData,frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",li.defaultData),shared:{...ar.emptyData(),colors:ar.defaultColors()}},s.emptyDataForImports=function(c){let u=Io.emptyDataWithPage(c);return{schema:Mo,scene:u,frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",li.defaultData),shared:{...ar.emptyData(),colors:ar.defaultColors(),images:ar.defaultImages(c)}}},s.emptyData=function(){return{schema:Mo,scene:Io.emptyDataWithPage(),frames:new he().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",li.defaultData),shared:ar.emptyData()}},s.collabHelper={...wa,updateSchema(c){return(c.schema??0)<Mo?xo(c,wl):(c.schema??0)-Mo}};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:en.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})(si||(si={}));var oa=ma(Dh());import{Object3D as oC,Vector3 as Yt,Euler as Hu,MathUtils as c0,Matrix4 as wn}from"three";var PP=.5*(Math.sqrt(3)-1),Ia=(3-Math.sqrt(3))/6,TP=1/3,Mr=1/6,Tj=(Math.sqrt(5)-1)/4,Oj=(5-Math.sqrt(5))/20,Ma=n=>Math.floor(n)|0,Bh=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]),ud=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 _l(n=Math.random){let r=Gh(n),e=new Float64Array(r).map(o=>Bh[o%12*2]),t=new Float64Array(r).map(o=>Bh[o%12*2+1]);return function(i,a){let s=0,c=0,u=0,l=(i+a)*PP,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,_=y-1+2*Ia,P=g-1+2*Ia,v=d&255,N=p&255,T=.5-y*y-g*g;if(T>=0){let A=v+r[N],M=e[A],E=t[A];T*=T,s=T*T*(M*y+E*g)}let C=.5-w*w-b*b;if(C>=0){let A=v+x+r[N+S],M=e[A],E=t[A];C*=C,c=C*C*(M*w+E*b)}let O=.5-_*_-P*P;if(O>=0){let A=v+1+r[N+1],M=e[A],E=t[A];O*=O,u=O*O*(M*_+E*P)}return 70*(s+c+u)}}function Rh(n=Math.random){let r=Gh(n),e=new Float64Array(r).map(i=>ud[i%12*3]),t=new Float64Array(r).map(i=>ud[i%12*3+1]),o=new Float64Array(r).map(i=>ud[i%12*3+2]);return function(a,s,c){let u,l,d,p,f=(a+s+c)*TP,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,_=s-S,P=c-w,v,N,T,C,O,A;b>=_?_>=P?(v=1,N=0,T=0,C=1,O=1,A=0):b>=P?(v=1,N=0,T=0,C=1,O=0,A=1):(v=0,N=0,T=1,C=1,O=0,A=1):_<P?(v=0,N=0,T=1,C=0,O=1,A=1):b<P?(v=0,N=1,T=0,C=0,O=1,A=1):(v=0,N=1,T=0,C=1,O=1,A=0);let M=b-v+Mr,E=_-N+Mr,X=P-T+Mr,R=b-C+2*Mr,Z=_-O+2*Mr,z=P-A+2*Mr,V=b-1+3*Mr,W=_-1+3*Mr,$=P-1+3*Mr,Y=m&255,q=h&255,k=y&255,U=.6-b*b-_*_-P*P;if(U<0)u=0;else{let D=Y+r[q+r[k]];U*=U,u=U*U*(e[D]*b+t[D]*_+o[D]*P)}let B=.6-M*M-E*E-X*X;if(B<0)l=0;else{let D=Y+v+r[q+N+r[k+T]];B*=B,l=B*B*(e[D]*M+t[D]*E+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 Gh(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 OP}from"three";var sr=new OP,Pl=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 MP}from"three";var jh=ma(zh());import{Object3D as AP,Matrix4 as Lr}from"three";var CP=new Lr,NP=new Lr,IP=new Lr,di;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(di||(di={}));var ui=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Lr;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Lr;this.matrixWorldRigid=new Lr;this.shearScale=new Lr;this.shearScaleInv=new Lr}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof AP&&(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)di.is(i)&&i.traverseObject(t,o+1)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let a of this.children)di.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,jh.SVD)(o),c=CP.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=NP.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=IP.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 Lr().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Lr?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 pd=class extends ui(MP){},LP=n=>n.type==="Mesh",oo=class extends pd{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 oo(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 LP(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 CO,BufferGeometry as NO,MeshBasicMaterial as IO}from"three";import{Matrix4 as OO,Mesh as AO}from"three";import{Matrix4 as Al,Vector3 as VP,Euler as zP}from"three";import{Box3 as EP,Line3 as DP,Matrix4 as fd,Vector3 as Wt}from"three";var tn=new Wt,rn=new Wt,pi=new fd,kh=[new Wt(-1,1,1),new Wt(-1,-1,1),new Wt(1,-1,1),new Wt(1,1,1),new Wt(-1,1,-1),new Wt(-1,-1,-1),new Wt(1,-1,-1),new Wt(1,1,-1)],BP=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],RP=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],Fh=(n,r,e)=>{n.updateEntityBoxSize(tn,rn),pi.copy(r).multiply(n.matrixWorld),rn.x===0&&rn.y===0&&rn.z===0?e.push(new Wt(tn.x,tn.y,tn.z).applyMatrix4(pi)):kh.forEach(t=>{e.push(t.clone().multiply(rn).add(tn).applyMatrix4(pi))})},La=class extends EP{constructor(){super(...arguments);this.matrix=new fd;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 fd().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 Wt);return}Fh(a,t,i)}}):Fh(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(pi.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(rn).multiplyScalar(.5),this.getCenter(tn),pi.copy(this.matrix).setPosition(tn),this.vertices=kh.map(e=>e.clone().multiply(rn).applyMatrix4(pi))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=BP.map(([e,t])=>new DP(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Wt))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=RP.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var lr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as GP,CubicBezierCurve3 as md,Vector3 as cr}from"three";var yd=class extends GP{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 gd=.001;function xd(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=gd}function hd(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 xd(e,t,i)&&xd(e,o,i)}function Ol(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++)xd(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),_=w.clone().sub(p).normalize(),P=b.clone().sub(p).normalize();Object.assign(h,{prevDir:_,nextDir:P});let v=hd(x,d),N=hd(d,S);if(!v||!N)s[l]={...h,removedLength:0};else{let T=_.clone().add(P).normalize(),C=T.clone().cross(_).length()/_.dot(T);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(!hd(e[d].data,e[p].data))f.position.distanceTo(m.position)>gd&&(h=new md(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)>gd&&(h=new md(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),_=d.prevDir.clone().multiplyScalar(b*p.distanceTo(f)).add(p),P=_.clone().lerp(w,2),v=f.clone().lerp(_,4/3),N=m.clone().lerp(P,4/3);c[2*l]=new md(f,v,N,m)}let u=new yd;return c.forEach(l=>{l&&u.add(l)}),u}var Oe;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Oe||(Oe={}));var fi=n=>Oe.is(n),jP={type:"completeState",isfromEntity:!0},mi=n=>class extends ui(n){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;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(Oe.is(o))return o}entityChildrenCount(){let t=this.children.length;for(;t--;)if(Oe.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(Oe.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)Jo.toOps(this.data,a.data).forEach(c=>{let u=Hs.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=Jo.patch(this.data,a),Jo.toOps(this.data,a).forEach(c=>{this.updateByPatchedOp(c,this.dataPatched,o)}))}i&&this.updateTransformState(this.dataPatched),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=>{fi(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(Oe.is(o[i]))return o[i];if(Oe.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Oe.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)fi(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Oe.is(o)&&t(o)})}traverseConcreteEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)fi(a)&&a.isConcreteEntity&&a.traverseEntity(t,o+1)}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let a of this.children)fi(a)&&a.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)fi(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=>fi(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,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return $n(o,t)}updateTransformState(t){let o=!1;return t.position&&(this.position.fromArray(t.position),o=!0),t.rotation&&(this.rotation.fromArray(t.rotation),o=!0),t.scale&&(o=!0,this.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&(o=!0,this.hiddenMatrix.fromArray(t.hiddenMatrix??_o.identity)),o&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(i=>{i.invalidateClonerTransform(this)})),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),o}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let t of this.children)Oe.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Oe.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=Tt.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=Tt.removeOverridden(t.path,t.props,l);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,Jo.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(_r.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...l]);if(p){let f=Tt.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,Qe.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=_r.filterOp(d.overrideData,l);p&&d.updateByOp(p,Qe.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=_r.filterOp(d.overrideData,t);if(p){let f;s===d.data&&t===p?f=o:f=Qe.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)Oe.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=Qe.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=Ol(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 Al;c.updateMatrixWorld();let m=new Al().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new Al().extractRotation(c.matrixWorld),g=l.getTangentAt(d).applyMatrix4(y).add(p),x=new Al().lookAt(p,g,new VP(0,1,0)),S=new zP().setFromRotationMatrix(x);h={...h,rotation:[S.x,S.y,S.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(jP)})}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)}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{ConeGeometry as UP}from"three";import{BufferGeometry as FP,CylinderGeometry as kP,Float32BufferAttribute as vd,Vector2 as dr,Vector3 as Cl}from"three";var Hh=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),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 d||f?m=new Ea(u,l,t,o,i,a,s,c*Math.PI/180,d,d,p,f):m=new kP(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 Uh(n){return new dr(n.y,-n.x)}var Ea=class extends FP{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 Cl,b=new Cl;f&&r==0&&(r=u),f&&e==0&&(e=l);let _=new dr(r,S),P=new dr(e,-S),v=null,N=null,T=null,C=null,O=_.clone().sub(P),A=0,M=0,E=0;p>0&&(A=Math.min(r,e)*(1-p),M=r-A,E=e-A);let X=_.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-E)/Y,O.length()/W),u>0){let j=u/z;v=_.clone().sub(new dr(j,u)),p&&(T=v.clone(),T.x-=A-W*u),_.sub(O.clone().setLength(j))}if(l>0){let j=l/V;N=P.clone().sub(new dr(j,-l)),P.add(O.clone().setLength(j)),p&&(C=N.clone(),C.x-=A-W*l,X.sub(O.clone().setLength(j)))}O=_.clone().sub(P);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,E,-1);let te=Uh(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(P);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(T&&v?(U(D,oe,K,R,u,v,1,!1),U(D,oe,K,Z,u,T,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=Uh(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 vd(h,3)),this.setAttribute("normal",new vd(y,3)),this.setAttribute("uv",new vd(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 Cl,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 Cl,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+E)/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 Wh=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{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 u>0||l>0||c<360?p=new Ea(0,r/2,t,o,i,a,s,c*Math.PI/180,u,l,d,0,!0):p=new UP(r/2,t,o,i,a),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as HP,BufferGeometry as WP,Float32BufferAttribute as bd,Vector3 as Da}from"three";var qh=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 HP(r,e,t,o,i,a):u=new wd(r,e,t,o,i,a,s,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Sd=Math.PI/2,wd=class extends WP{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 bd(d,3)),this.setAttribute("normal",new bd(p,3)),this.setAttribute("uv",new bd(f,2));function y(S,w,b,_,P,v,N,T,C,O,A){let M=(v-2*s)/C,E=(N-2*s)/O,X=v/2-s,R=N/2-s,Z=T/2,z=C+1,V=O+1,W=0,$=0,Y=new Da;for(let q=0;q<V;q++){let k=q*E-R;for(let U=0;U<z;U++){let B=U*M-X;Y[S]=B*_,Y[w]=k*P,Y[b]=Z,d.push(Y.x,Y.y,Y.z),Y[S]=0,Y[w]=0,Y[b]=T>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,_,P,v,N,T,C,O,A){let M=(N-2*s)/O,E=N/2-s,X=T/2-s,R=C/2,Z=O+1,z=0,V=0,W=new Da,$=new Da;for(let Y=0;Y<c+1;Y++){let q=Y/c*Sd,k=Math.sin(q)*s,U=(1-Math.cos(q))*s,B=Math.sin(q),F=Math.cos(q);W[w]=(X+k)*P,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-E;W[S]=D*_,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 _=new Da,P=new Da(r/2,e/2,t/2);P.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=Sd*(1-C/c),M=Math.cos(A),E=Math.sin(A),X=0;for(let R=0;R<=C;R++){let Z=Math.cos(X),z=Math.sin(X);_.x=M*Z,_.y=E,_.z=M*z;let V=P.clone().addScaledVector(_,s);d.push(S*V.x,w*V.y,b*V.z),p.push(S*_.x,w*_.y,b*_.z),f.push(0,0),O.push(m++),X+=Sd/C}v.push(O)}let T=v.length-1;for(let C=0;C<T;C++){let O=v[C],A=v[C+1],M=O.length-1;N(O[0],A[1],A[0]);for(let E=1;E<=M;E++)N(O[E-1],O[E],A[E]),N(O[E],A[E+1],A[E])}}}};import{BufferGeometry as qP,Float32BufferAttribute as _d,Triangle as $P,Vector3 as no,Vector2 as Pd}from"three";var Eo=class extends qP{constructor(r=[],e=[],t="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],c=[],u=[];l(),d(),this.setAttribute("position",new _d(s,3)),this.setAttribute("normal",new _d(u,3)),this.setAttribute("uv",new _d(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 no,h=m.clone(),y=new $P,g=i*o,x=o-g,S=a+1,w=new no,b=(z,V)=>w.subVectors(z,V).normalize(),_=(z,V)=>Array(z).fill(void 0).map(V),P=_(r.length/3,(z,V)=>new no().fromArray(r,V*3).setLength(o)),v=[],N=1e6;for(let z=0;z<P.length;z++){let V=P[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(P[$]),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 T=[];{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],T.push(W,$,...Y?[V,W]:[z,$],V,z),[W,$]=[z,V];T.push(W,$,W+a+2)}}let C=m.clone(),O=m.clone(),A=m.clone(),M=m.clone(),E=m.clone(),X=[],R=_(P.length,()=>_(f,()=>m.clone()));for(let z=0;z<P.length;z++){m.copy(P[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(P,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 no;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),E.subVectors(ie,C),A.crossVectors(M,E).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],E=W[j+ee],D.push(M);for(let K=1,te=ee-U+1;K<=te;K++)m.lerpVectors(M,E,K/(te+1)),m.sub(C).setLength($[B]).add(C),D.push(m.clone());D.push(E)}for(let ee=0;ee<S;ee++)D.push(W[ee+S+F]);D.push(W[j+S]);let oe=T.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 no;for(let P=0;P<s.length;P+=3){p.x=s[P+0],p.y=s[P+1],p.z=s[P+2];let v=b(p)/2/Math.PI+.5,N=_(p)/Math.PI+.5;c.push(v,1-N)}let f=new no,m=new no,h=new no,y=new no,g=new Pd,x=new Pd,S=new Pd,w=(P,v,N,T)=>{T<0&&P.x===1&&(c[v]=P.x-1),N.x===0&&N.z===0&&(c[v]=T/2/Math.PI+.5)};for(let P=0,v=0;P<s.length;P+=9,v+=6){f.set(s[P+0],s[P+1],s[P+2]),m.set(s[P+3],s[P+4],s[P+5]),h.set(s[P+6],s[P+7],s[P+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 P=0;P<c.length;P+=6){let v=c[P+0],N=c[P+2],T=c[P+4],C=Math.max(v,N,T),O=Math.min(v,N,T);C>.9&&O<.1&&(v<.2&&(c[P+0]+=1),N<.2&&(c[P+2]+=1),T<.2&&(c[P+4]+=1))}function b(P){return Math.atan2(P.z,-P.x)}function _(P){return Math.atan2(-P.y,Math.sqrt(P.x*P.x+P.z*P.z))}}}static fromJSON(r){return new Eo(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};import{DodecahedronGeometry as YP}from"three";var $h=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 Ba(r*.5,i,a):new YP(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},Ba=class extends Eo{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 Ba(r.radius,r.corner,r.cornerSides)}};import{Plane as iT,Shape as ly,Vector2 as io,Vector3 as aT,MathUtils as Md,LineCurve as Ld,QuadraticBezierCurve as cy,CubicBezierCurve as Ll}from"three";import{CubicBezierCurve as Nl,EllipseCurve as XP,LineCurve as Il,LineCurve3 as KP,MathUtils as ZP,QuadraticBezierCurve as Od,SplineCurve as QP,Vector2 as Pt,Vector3 as Kh}from"three";var Ra=1e-12,hi=class{constructor(r){this.position=new Pt;this.startPosition=new Pt;this.uuid=ZP.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 hi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},yi=class extends hi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new yi(this.parent).copy(this)}},ur=class extends hi{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new yi(this),new yi(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&&(Yh(o,e),Yh(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 Yh(n,r=new Pt){let e=n.length();return r.set(-n.y/e,n.x/e)}var Ad=n=>n,gi=new Pt,Ml=new Pt,JP=new Pt,eT=new Pt,tT=new Pt,rT=new Pt,Zh=new Kh,Qh=new Kh;function Jh(n){let r=new Pt;r.addVectors(n.v0,gi.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Pt;return e.addVectors(n.v2,Ml.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Nl(n.v0,r,e,n.v2)}function Ga(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function oT(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function nT(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function Cd(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 ey(n,r,e){return Xh(n,r)&&Xh(r,e)&&Td(n.position,r.position,e.position)}function Td(n,r,e){return gi.copy(r).sub(n).cross(Ml.copy(e).sub(n))===0}function ty(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 ry(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function oy(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 Cd(r,n,e)>Math.PI&&(l*=-1),Ga(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 Nd(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function Xh(n,r){return Td(n.position,n.controls[1].position,r.position)&&Td(n.position,r.controls[0].position,r.position)}function ny(n,r,e,t,o=.5){let i=gi.subVectors(r,n).multiplyScalar(o).add(n),a=Ml.subVectors(e,r).multiplyScalar(o).add(r),s=JP.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=eT.subVectors(a,i).multiplyScalar(o).add(i),l=tT.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=rT.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 iy(n,r,e=12,t=!0){let o=Qh.set(0,0,0),i,a=0,s=[];for(let c=0;c<r.length;c++){let u=Ad(r[c]),l=gi,d=Do(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof Nl||u instanceof Od||u instanceof Il){if(u.getPoint(p/d,l),o.set(l.x,l.y,0),i!==void 0&&nT(i,o))continue;i===void 0&&(i=Zh),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 ay(n,r,e,t=12,o=!0){let i=Qh.set(0,0,0),a=0,s=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,l=Ad(r[c]),d=gi,p=Do(l,t);s.push(p);for(let f=0;f<=p;f++)if(l instanceof Nl||l instanceof Od||l instanceof Il){if(l.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=Zh:(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 Id(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=Do(a.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),s+=c}a.curveAfter!==void 0&&(s+=Do(a.curveAfter,r)),t.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=Do(n[0].roundedCurveCorner,r)*.5),t}function Do(n,r=12){return n&&n instanceof XP?r*2:n&&(n instanceof Il||n instanceof KP)?1:n&&n instanceof QP?r*n.points.length:r}function sy(n,r,e=12,t=!0){let o,i=0;for(let a=0;a<r.length;a++){let s=Ad(r[a]),c=Do(s,e),u=gi;for(let l=0;l<=c;l++)if(s instanceof Nl||s instanceof Od||s instanceof Il){if(s.getPoint(l/c,u),o!==void 0&&oT(o,u,Ra))continue;o===void 0&&(o=Ml),o.copy(u),n.push(u.x,u.y),i++}}return Ga(n[0],n[n.length-2],Ra)&&Ga(n[1],n[n.length-1],Ra)&&(n.pop(),n.pop()),t&&i>1&&!(Ga(n[i-1],n[1],Ra)&&Ga(n[i-2],n[0],Ra))&&(n.push(n[0],n[1]),i++),n}var Ed=new io,sT=new io,lT=new io,cT=new io,dT=new io,uT=new io,Ce=class extends ly{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new iT(new aT(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=Md.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=Ed.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=Md.generateUUID()){let i;e instanceof io?i=e:i=new io(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 iy(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Id(this.points,e,!1),this.roundedCurveDivisions=Id(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return ay(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),sy(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=Do(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(Nd(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(Ed.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){Nd(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&&ey(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,_=d.getPointAt(w,Ed),P=p.getPointAt(b,sT);this._subSplitCurve(d,f,w,_,void 0),this._subSplitCurve(p,m,b,void 0,P);let v;if(this.useCubicForRoundedCorners){let N=Cd(_,a.position,P)/2,T=Math.tan(N)*_.distanceTo(a.position),[C,O]=ty(_,P,T,lT,cT),A=ry(C,O,a.position),[M,E]=oy(A,_,P,T,dT,uT);v=new Ll(_.clone(),M.clone(),E.clone(),P.clone())}else v=new cy(_.clone(),a.position.clone(),P.clone());a.roundedCurveCorner=v,this.roundedCurves.splice(o+t,0,v),t++}}}}_subSplitCurve(e,t,o,i,a){if(e instanceof Ld)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=ny(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(Md.generateUUID(),new io(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 Ll&&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 cy&&(i[s]=Jh(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 Ll?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ld&&(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 Ll?u.v3.equals(a[0].position)&&(a[0].controls[0].position.copy(u.v2),l=!0):u instanceof Ld&&u.v2.equals(a[0].position)&&(l=!0),this.isClosed=l,a};return this.points=o(e.curves),e instanceof ly&&(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 Bd=Math.PI*2;function Dd({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function pT(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 dy(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 fT(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,_=(-s-y)/i,P=dy(1,0,S,w),v=dy(S,w,b,_);return!u&&v>0&&(v-=Bd),u&&v<0&&(v+=Bd),{centerx:g,centery:x,ang1:P,ang2:v}}function uy({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=fT(n,r,e,t,o,i,u,l,a,s),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(Bd/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(pT(f,m)),f+=m;return c.map(S=>{let{x:w,y:b}=Dd(S[0],o,i,h,y),{x:_,y:P}=Dd(S[1],o,i,h,y),{x:v,y:N}=Dd(S[2],o,i,h,y);return{x1:w,y1:b,x2:_,y2:P,x:v,y:N}})}import{BufferAttribute as Gl,BufferGeometry as _T}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 fe(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){fe(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){fe(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){fe(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){fe(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}(),Va=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}(),El=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}(),xi=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}(),py=function(){function n(){var r=new xi,e=new Va,t=new El(0),o=new El(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 El(0),t=new El(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;fe(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;fe(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 xi,e=new xi,t=new Va,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 xi;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var a=new Va;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 Va;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 xi;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 Va;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){fe(o.prev===i),c=o.anEdge;do fe(c.Sym!==c),fe(c.Sym.Sym===c),fe(c.Lnext.Onext.Sym===c),fe(c.Onext.Sym.Lnext===c),fe(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(fe(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){fe(a.prev===s),c=a.anEdge;do fe(c.Sym!==c),fe(c.Sym.Sym===c),fe(c.Lnext.Onext.Sym===c),fe(c.Onext.Sym.Lnext===c),fe(c.Org===a),c=c.Onext;while(c!==a.anEdge)}for(fe(a.prev===s&&a.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)fe(c.Sym.next===u.Sym),fe(c.Sym!==c),fe(c.Sym.Sym===c),fe(c.Org!==null),fe(c.Dst!==null),fe(c.Lnext.Onext.Sym===c),fe(c.Onext.Sym.Lnext===c);fe(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}(),fy=function(){function n(){this.handle=null}return n}(),my=function(){function n(){this.key=null,this.node=0}return n}(),mT=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 fy,this.handles[t]=new my;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,fe(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 fy;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new my}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;fe(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}(),Rd=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}(),hy=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),hT=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new hy,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 hy;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}(),yT=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&&fe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){fe(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 Rd;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 fe(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,fe(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(fe(!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 xi,f,m;if(fe(!ue.vertEq(u,c)),fe(ue.edgeSign(c,r.event,a)<=0),fe(ue.edgeSign(u,r.event,s)>=0),fe(a!==r.event&&s!==r.event),fe(!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),fe(Math.min(a.t,c.t)<=p.t),fe(p.t<=Math.max(s.t,u.t)),fe(Math.min(u.s,c.s)<=p.s),fe(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)){fe(!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}fe(!1),e=n.topRightRegion(e),c=n.regionBelow(e),a=c.eUp.Sym,i=s=a.Onext,c.fixUpperEdge&&(fe(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 Rd;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);fe(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 Rd,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 hT(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||(fe(e.fixUpperEdge),fe(++t===1)),fe(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 mT(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,fe(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}(),gT=function(){function n(){this.mesh=new py,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 py),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_(),yT.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 gT;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 ek=_e.ODD,tk=_e.NONZERO,rk=_e.POSITIVE,ok=_e.NEGATIVE,nk=_e.ABS_GEQ_TWO,ik=ke.POLYGONS,ak=ke.CONNECTED_POLYGONS,sk=ke.BOUNDARY_CONTOURS;import{BufferAttribute as Rl,BufferGeometry as wT}from"three";var Dl=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*Dl.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*Dl.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)}},za=Dl;za.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var vy=ma(xy()),ja={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Fd={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},kd={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},jd=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),Ro=class extends wT{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 E=O[M-1],X=O[M-0];A.push(E,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,vy.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=ja}let h;try{h=pr({windingRule:_e.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]})}catch{h=Fd}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],E=m.vertices[A+1];M<g&&(g=M),M>x&&(x=M),E<S&&(S=E),E>w&&(w=E)}this._minX=g,this._minY=S,this._width=x-g,this._height=w-S,this._buffer=new za(this._computeBufferEstimatedSize(m));let b=[],_=[];for(let C=m.elementCount-1;C>=0;C--){let O=C>=y,A=C*2,M=m.elements[A+0],E=m.elements[A+1],X=M+E,R={start:M,count:E,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 me=de===1?le+1:le-1;me=(me+W)%W;let Pe=de===1?0:1,Ve=this._shape.roundedCurves[le].getTangent(de),Te=this._shape.roundedCurves[me].getTangent(Pe);R.continuous[U]=Ve.dot(Te)>.95}}O&&(R.normals[U*2+0]*=-1,R.normals[U*2+1]*=-1),[z,Z,V]=[Z,V,V+1],V>=X&&(V-=E)}while(V!==M+1);let $=[];$.push({bevelI:0,angle:0,size:0,boundary:{vertices:m.vertices.slice(M*2,X*2),vertexCount:E,vertexIndices:new Array(E).fill(!0).map((U,B)=>[B,B]),elements:[0,E],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<E;Q++){let se=Q*2,ne=(Q-1+E)%E*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,me=-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),Te=Math.atan2(Pe,me);Te>Ve&&(Te-=Math.PI*2);let Be=Te-Ve;if(R.continuous[Q]||O){let Lt=Ve+Be/2,be=Math.cos(Lt)*F,et=Math.sin(Lt)*F;j[2*K+0]=ie+be*(O?-1:1),j[2*K+1]=ce+et*(O?-1:1),ee[K]=Q,K++}else{let Lt=Math.max(1,Math.floor(i/4*Math.abs(Be)/Math.PI));for(let be=0;be<=Lt;be++){let et=Ve+Be*(be/Lt),it=Math.cos(et)*F,Pn=Math.sin(et)*F;j[2*K+0]=ie+it,j[2*K+1]=ce+Pn,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+me,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+=E);for(let ce=se;ce<ie;ce++){let le=ce%E,de=(ce+1)%E;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=jd(ee,E);for(;!B.boundary.vertexIndices.filter(K).length||!F.boundary.vertexIndices.filter(K).length;)ee++,K=jd(ee,E);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)%E;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,me,Pe,Ve=!1;do{ne=(ee||oe)/oe,K=jd(ee,E);let Te=q(B,te,K),Be=q(F,Q,K),Lt=Ve;if(Ve=!1,Te&&!Be){for(let be=0;be<Te;be++)me=this._buildBevelVert(R,B,(te+be)%j,be/(Te-1),ne),b.push(le.topN,me.topP,de.topN),c===!1&&b.push(me.bottomP,le.bottomN,de.bottomN),le=me;Ve=!0}else if(!Te&&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(Te&&Be)if(me=this._buildBevelVert(R,B,te,0,ne),Pe=this._buildBevelVert(R,F,Q,0,ne),Lt?(b.push(le.topN,Pe.topP,de.topN),b.push(le.topN,me.topP,Pe.topP),c===!1&&(b.push(Pe.bottomP,le.bottomN,de.bottomN),b.push(Pe.bottomP,me.bottomP,le.bottomN))):(b.push(de.topN,le.topN,me.topP),b.push(de.topN,me.topP,Pe.topP),c===!1&&(b.push(me.bottomP,le.bottomN,de.bottomN),b.push(me.bottomP,de.bottomN,Pe.bottomP))),le=me,de=Pe,Te===Be)for(let be=1;be<Te;be++)me=this._buildBevelVert(R,B,(te+be)%j,be/(Te-1),ne),Pe=this._buildBevelVert(R,F,(Q+be)%D,be/(Be-1),ne),b.push(le.topN,me.topP,de.topN),b.push(de.topN,me.topP,Pe.topP),c===!1&&(b.push(me.bottomP,le.bottomN,de.bottomN),b.push(me.bottomP,de.bottomN,Pe.bottomP)),le=me,de=Pe;else if(Te>Be){let be=Te/Be,et=0;for(let it=1;it<Te;it++)me=this._buildBevelVert(R,B,(te+it)%j,it/(Te-1),ne),b.push(le.topN,me.topP,de.topN),c===!1&&b.push(me.bottomP,le.bottomN,de.bottomN),le=me,it>(et+1)*be&&(et++,Pe=this._buildBevelVert(R,F,(Q+et)%D,et/(Be-1),ne),b.push(de.topN,me.topP,Pe.topP),c===!1&&b.push(me.bottomP,de.bottomN,Pe.bottomP),de=Pe)}else{let be=Be/Te,et=0;for(let it=1;it<Be;it++)Pe=this._buildBevelVert(R,F,(Q+it)%D,it/(Be-1),ne),b.push(de.topN,me.topP,Pe.topP),c===!1&&b.push(me.bottomP,de.bottomN,Pe.bottomP),de=Pe,it>(et+1)*be&&(et++,me=this._buildBevelVert(R,B,(te+et)%j,et/(Te-1),ne),b.push(le.topN,me.topP,de.topN),c===!1&&b.push(me.bottomP,le.bottomN,de.bottomN),le=me)}te=(te+Te)%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)}_.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,..._]})}catch{B=kd}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 P=new Rl(Uint32Array.from(b),1),v=new Rl(this._buffer.positions,3),N=new Rl(this._buffer.normals,3),T=new Rl(this._buffer.uvs,2);v.needsUpdate=!0,N.needsUpdate=!0,T.needsUpdate=!0,P.needsUpdate=!0,this.setAttribute("position",v),this.setAttribute("normal",N),this.setAttribute("uv",T),this.setIndex(P)}_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,_=(S-this._minX)/this._width,P=(w-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(_=a),P=1);let v=e.normals[g+0],N=e.normals[g+1],T=e.normals[x+0],C=e.normals[x+1];if(f){let X=T-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,E={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]=_,this._buffer.uvs[M+1]=P,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]=P,this._buffer.uvs[M+3]=_),p||(this.forPathBevel?(O+=1,A+=3,M+=2):(O+=2,A+=6,M+=4),E.topP=O+0,E.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]=T*m,this._buffer.normals[A+1]=C*m,this._buffer.normals[A+2]=h,this._buffer.uvs[M+0]=_,this._buffer.uvs[M+1]=P,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]=T*m,this._buffer.normals[A+4]=C*m,this._buffer.normals[A+5]=-h,this._buffer.uvs[M+2]=P,this._buffer.uvs[M+3]=_)),this.vertexCache[s]=E,E}clone(){let e=new Ro(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Qr(this.userData),e}};var vi=class extends _T{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=ja}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Gl(new Float32Array(p*3),3),this._normalAttribute=new Gl(new Float32Array(p*3),3),this._uvAttribute=new Gl(new Float32Array(p*2),2),this._indexAttribute=new Gl(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 _=w*2,P=s.vertices[_+0],v=s.vertices[_+1];P<m&&(m=P),P>h&&(h=P),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 _=w*2,P=s.vertices[_+0],v=s.vertices[_+1],N=(P-m)/x,T=(v-y)/S;this._positionAttribute.setXYZ(w,P,v,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,N,T)}for(let w=0,b=f;w<b;w++){let _=w*3,P=s.elements[_+0],v=s.elements[_+1],N=s.elements[_+2];this._indexAttribute.setX(_+0,P),this._indexAttribute.setX(_+1,v),this._indexAttribute.setX(_+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 vi(this._shape,this._curveSegments);return e.userData=Qr(this.userData),e}};var bi=class extends Ro{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 bi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Qr(this.userData),e}};var Rt=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 vi(n.shape,o,{windingRule:a}):s=new bi(n.shape,r,e,o,t,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{MathUtils as Sy,Vector2 as wy}from"three";var _y=Math.PI*2,wi=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{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=PT(u,l,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=Rt.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function PT(n,r,e,t,o,i){if(t>=_y)return o>30||o%4===0?(OT(n,r,e,i),Math.round(o/4)):by(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=uy({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?TT(n,a.x,a.y,u,o,r,e,i):by(n,t,o,r,e,i)}function TT(n,r,e,t,o,i,a,s){let c=Math.round(o/t.length);n.addPoint(Si(r,e));for(let u=0,l=t.length;u<l;u++){let d=t[u],p=n.points[u],f=Si(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?Py(n,i,a,s):n.addPoint(Si(0,0)),c}function by(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(Si(u,l))}return r<_y?i>0?Py(n,t,o,i):n.addPoint(Si(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Ty(n,t,o,i)),1}function OT(n,r,e,t=0,o=0,i=0){let a=.5522847498,s=r*a,c=e*a;n.addPoint(Vl(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(Vl(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(Vl(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(Vl(o,i-e,o+s,i-e,o-s,i-e)),t>0&&Ty(n,r,e,t)}function Si(n,r){return new ur(Sy.generateUUID(),new wy(n,r))}function Vl(n,r,e,t,o,i){let a=Si(n,r);return a.controls[0].position.set(e,t),a.controls[1].position.set(o,i),a}function Py(n,r,e,t){Oy(n,r,e,t).forEach(i=>n.addPoint(i))}function Ty(n,r,e,t){let o=Oy(n,r,e,t),i=new Ce;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Oy(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),a=new wy(o/r,i/e),s=n.points.map(c=>{let u=c.clone();return u.uuid=Sy.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 AT,Float32BufferAttribute as Ud,Uint32BufferAttribute as CT,Vector3 as Ay}from"three";var Cy=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 Fa(!1,r,e,t,o,i,a,s,c,u,l,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},Hd=new CT([0,0,0],1),Fa=class extends AT{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 Ay,h=new Ay,y=m(),g=m(),x=m(),S,w,b,_,P,v,N,T,C=m(),O=m(),A=m(),M=m(),E=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=k*($+K),[ne,ie,ce]=[3,3,2].map($e=>Array(se*$e).fill(0)),le=[],de=i-c;function me($e,Ft){let br=Math.PI/2;v=Ft*Y,T=2*Math.PI*(v%V)/V+br,v+=q,N=Math.sin(T)*de,P=Math.cos(T)*de,r?$e.set(P,N,v):$e.set(P,v,N)}me(h,-1e-10),me(y,0),C.copy(h),me(h,1);let Pe=h.distanceTo(y),Ve=f?0:D+j,Te=Pe*W+2*Ve,Be=j,Lt=Te-Ve;for(let $e=0;$e<=W;$e++){me(g,$e),Z.subVectors(g,C).normalize(),C.copy(g),X.copy(g).setComponent(+r+1,0).normalize(),R.crossVectors(Z,X).normalize();let Ft=$e===0,br=$e===W,J0=Ft?3*Math.PI/2:B,ex=Ft?Be:Lt,tx=Ft?k:Q,rx=Ft?0:se-k,ox=Z.clone().multiplyScalar(Ft?-D:D).add(g),nx=Z.clone().multiplyScalar(Ft?-1:1).normalize();for(let $r=0;$r<k;$r++){let rp=$r*U;if(O.addVectors(h.copy(X).multiplyScalar(c*Math.cos(rp)),y.copy(R).multiplyScalar(c*Math.sin(rp))),A.copy(O).normalize(),Ft||br){f||(oe=rx+$r,[0,1,2].forEach(Et=>{ne[oe*3+Et]=ox.getComponent(Et),ie[oe*3+Et]=nx.getComponent(Et)}),ce[oe*2]=+br,ce[oe*2+1]=$r/l),y.copy(A).multiplyScalar(j),x.addVectors(g,y);for(let Et=0;Et<p;Et++){let Cc=Et*B+J0;M.addVectors(h.copy(Z).multiplyScalar(D*Math.sin(Cc)),y.copy(A).multiplyScalar(D*Math.cos(Cc))),E.copy(M).normalize(),y.addVectors(x,M),M.normalize(),oe=tx+Et*k+$r,[0,1,2].forEach(hs=>{ne[oe*3+hs]=y.getComponent(hs),ie[oe*3+hs]=E.getComponent(hs)});let ix=+Ft+Math.sin(Cc);ce[oe*2]=(ex+D*ix)/Te,ce[oe*2+1]=$r/l}}y.addVectors(g,O),oe=te+$e*k+$r,[0,1,2].forEach(Et=>{ne[oe*3+Et]=y.getComponent(Et),ie[oe*3+Et]=A.getComponent(Et)}),ce[oe*2]=(Ve+$e*Pe)/Te,ce[oe*2+1]=$r/l}}let be=$+2*p+ee,et=1,[it,Pn]=[+f,be-1];for(let $e=it;$e<=Pn-1;$e++){let Ft=f&&$e===Pn-1;for(let br=0;br<k-1;br++)S=$e*k+br,w=S+1,b=(Ft?br:S)+k,_=(Ft?br+1:w)+k,$e===0?le.push(w,_,b):$e===be-2?le.push(S,w,b):le.push(S,w,b,w,_,b)}this.setIndex(le),this.setAttribute("position",new Ud(ne,3)),this.setAttribute("normal",new Ud(ie,3)),this.setAttribute("uv",new Ud(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,Hd.array=o,Hd.count=o.length,Hd}};import{IcosahedronGeometry as NT}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,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 ka(r*.5,i,a):new NT(r*.5,o);return s.scale(1,e/r,t/r),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},ka=class extends Eo{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 ka(r.radius,r.corner,r.cornerSides)}};import{LatheGeometry as IT,Shape as MT}from"three";var Iy=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 MT;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 IT(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as Vy,BufferGeometryLoader as UT,Vector3 as HT,BoxGeometry as zy}from"three";import{BufferGeometry as zT,Vector2 as Yd,Vector3 as Gy}from"three";import{Box3 as LT,BufferAttribute as Ua,BufferGeometry as My,Color as $d,EventDispatcher as ET,Float32BufferAttribute as _i,Matrix3 as Ly,Matrix4 as Ry,MathUtils as DT,Object3D as BT,Sphere as RT,Vector2 as qt,Vector3 as xt,Vector4 as GT}from"three";var Er=new Ry,Wd=new BT,zl=new xt,Go=class extends ET{constructor(){super(),this.uuid=DT.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 Ly().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 Er.makeRotationX(r),this.applyMatrix4(Er),this}rotateY(r){return Er.makeRotationY(r),this.applyMatrix4(Er),this}rotateZ(r){return Er.makeRotationZ(r),this.applyMatrix4(Er),this}translate(r,e,t){return Er.makeTranslation(r,e,t),this.applyMatrix4(Er),this}scale(r,e,t){return Er.makeScale(r,e,t),this.applyMatrix4(Er),this}lookAt(r){return Wd.lookAt(r),Wd.updateMatrix(),this.applyMatrix4(Wd.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 xt().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new $d().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 xt().fromBufferAttribute(a,p),new xt().fromBufferAttribute(a,f),new xt().fromBufferAttribute(a,m)],x=new Pi(p,f,m,g,y,h);e.faces.push(x),c!==void 0&&e.faceVertexUvs[0].push([new qt().fromBufferAttribute(c,p),new qt().fromBufferAttribute(c,f),new qt().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new qt().fromBufferAttribute(u,p),new qt().fromBufferAttribute(u,f),new qt().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(zl).negate(),this.translate(zl.x,zl.y,zl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new Ry;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 xt,e=new xt;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 xt;if(r){let t=new xt,o=new xt;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 Go;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 xt,l={a:new xt,b:new xt,c:new xt};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 LT),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new RT),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 Ly().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 xt(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,_=h.vertexColors.length>0,P=0;if(P=l(P,0,0),P=l(P,1,y),P=l(P,2,g),P=l(P,3,x),P=l(P,4,S),P=l(P,5,w),P=l(P,6,b),P=l(P,7,_),t.push(P),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)),_){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 Go().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 My,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",jl.call(new Ua(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",jl.call(new Ua(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",Ey.call(new Ua(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Dy.call(new Ua(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Dy.call(new Ua(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(jl.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",By.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new _i(r.skinWeights.length*4,4);e.setAttribute("skinWeight",By.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 My,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",jl.call(o,t.vertices)),e.setAttribute("color",Ey.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let a=new _i(t.lineDistances.length,1);e.setAttribute("lineDistance",VT.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}};Go.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 qt,new qt,new qt))}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 qt,new qt,new qt))}for(let b=0;b<c;b++){let _=s[b].vertices;u[b].data.push(_[x.a],_[x.b],_[x.c])}for(let b=0;b<d;b++){let _=l[b].vertexNormals[g];p[b].data.push(_.a,_.b,_.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 xt,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new $d,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 VT(n){return this.array.set(n),this}function Ey(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 $d),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function Dy(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 qt),r[e++]=i.x,r[e++]=i.y}return this}function jl(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 xt),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function By(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 GT),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var jT=["a","b","c"];function FT(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function Xd(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function Kd(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 kT(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],Kd(a.a,a.b,n,t,a,e),Kd(a.b,a.c,n,t,a,e),Kd(a.c,a.a,n,t,a,e)}function Fl(n,r,e,t,o){n.push(new Pi(r,e,t,void 0,void 0,o))}function Ti(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function kl(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Ul=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof zT?r=new Go().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 Gy,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;kT(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 Gy,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[FT(x,jT[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 _,P,v,N,T,C,O,A=[];for(o=0,i=c.length;o<i;o++){for(C=c[o],T=p[o].edges,t=T.length,t==3?_=3/16:t>3&&(_=3/(8*t)),P=1-t*Number(_),v=_,t<=2&&(t==2?(P=3/4,v=1/8):t==1||t==0),O=C.clone().multiplyScalar(P),e.set(0,0,0),a=0;a<t;a++)N=T[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),E=A.length,X,R,Z,z=[],V=[],W,$,Y,q,k=new Yd,U=new Yd,B=new Yd;for(o=0,i=u.length;o<i;o++)x=u[o],X=Number(Xd(x.a,x.b,f).newEdge)+E,R=Number(Xd(x.b,x.c,f).newEdge)+E,Z=Number(Xd(x.c,x.a,f).newEdge)+E,Fl(z,X,R,Z,x.materialIndex),Fl(z,x.a,X,Z,x.materialIndex),Fl(z,x.b,R,X,x.materialIndex),Fl(z,x.c,Z,R,x.materialIndex),d&&(W=l[o],$=W[0],Y=W[1],q=W[2],k.set(Ti($.x,Y.x),Ti($.y,Y.y)),U.set(Ti(Y.x,q.x),Ti(Y.y,q.y)),B.set(Ti($.x,q.x),Ti($.y,q.y)),kl(V,k,U,B),kl(V,$,k,B),kl(V,Y,U,k),kl(V,q,B,U));r.vertices=M,r.faces=z,d&&(r.faceVertexUvs[0]=V)}};var rt=new HT,jy=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Vy().copy(new zy(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(rt),t={width:rt.x,height:rt.y,depth:rt.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 Vy().copy(new zy(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(rt)):rt.set(a.width,a.height,a.depth),(r!==rt.x||e!==rt.y||t!==rt.z)&&i.scale(rt.x===0?1:r/rt.x,rt.y===0?1:e/rt.y,rt.z===0?1:t/rt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Ul(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 UT(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(rt);let a=100/rt.x;Object.assign(i.parameters,{width:100,height:rt.y*a,depth:rt.z*a}),r(this.build(i))})}};var Hl=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=Rt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as WT,Float32BufferAttribute as Zd,Vector2 as Dr,Vector3 as ct}from"three";var Fy=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 Jd(r*.5,e,o,i,a,s,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function Ha(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function Qd(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 qT(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var Jd=class extends WT{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 ct(0,-f,0),w=new ct(0,f,0),b=new Dr(r,-f),_=new Dr(h,-f),P=new Dr(0,w.y).sub(_),v=new Dr(0,w.y).sub(b),N=new Dr(P.y,-P.x).normalize(),T=new Dr(v.y,-v.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-P.angle())/2)-1e-8;a=Math.min(a,O);let A;{let V=new ct(N.x,N.y,0),W=new ct(Math.cos(y)*V.x,V.y,Math.sin(y)*V.x);A=V.angleTo(W)}let M=a/Math.tan((Math.PI-P.angle())/2),E=a/Math.tan((Math.PI-A)/2),X=new ct;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));Ha($,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 ct,W=new ct,$=new ct,Y=new ct,q=new ct,k=new ct;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));Ha(b,D,W),Ha(b,ee,$),Ha(N,oe,V),Qd(w,W,$,E,E,Y),u.push(Y.x,Y.y,Y.z),Qd(W,w,$,E,M,q),u.push(q.x,q.y,q.z),Qd($,W,w,M,E,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),me=k.clone().sub(q);Z(ie,me,de,P.angle())}let se,ne;{let ie=new ct;Ha(T,ee,ie);let ce=k.clone().add(Y).multiplyScalar(.5);ce=qT(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 ct(0,-1,0),de=ce.clone().cross(le);z(ie,ce,le,de)}R.concat(ne);{let ie=P.angle(),ce=Math.PI-ie,le=w.clone();le.y-=a/Math.sin(ie-Math.PI/2);let de=new ct,me=[];for(let Ve=0;Ve<s;Ve++){let Te=[],Be=Math.PI/2-ce*Ve/s,Lt=Math.cos(Be),be=Math.sin(Be),et=F;for(let it=0;it<=Ve;it++){let Pn=Math.cos(et),$e=Math.sin(et);V.x=Lt*$e,V.y=be,V.z=Lt*Pn,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),Te.push(p++),et+=Math.PI*2/Ve/t}me.push(Te)}ne.reverse(),me.push(ne);let Pe=me.length-1;for(let Ve=0;Ve<Pe;Ve++){let Te=me[Ve],Be=me[Ve+1],Lt=Te.length-1;c.push(Be[1],Te[0],Be[0]);for(let be=1;be<=Lt;be++)c.push(Te[be],Te[be-1],Be[be]),c.push(Be[be+1],Te[be],Be[be])}}}}}this.setIndex(c),this.setAttribute("position",new Zd(u,3)),this.setAttribute("normal",new Zd(l,3)),this.setAttribute("uv",new Zd(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 ct,j=new ct,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 ct,F=new ct;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 Wl=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,_){return b>e&&_>t?Math.min(w*e/b,w*t/_):b>e?w*e/b:_>t?w*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=Rt.create({shape:r,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:c}});return Object.assign(S,{userData:{...n,type:"RectangleGeometry"}})}};import{SphereGeometry as $T}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,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},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=100,height:e=r,depth:t=r,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:c,thetaLength:u}=n.parameters,l=new $T(.5*r,o,i,a,s,c,u);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as YT}from"three";var Uy=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 YT(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as XT,Float32BufferAttribute as eu,Vector3 as KT}from"three";var Hy=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 tu(r,e,t,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},tu=class extends XT{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 KT(F,j,D),m=f(),h=f(),[y,g,x]=[e/2,r/2,t/2],S=-g,w=+g,[b,_,P]=[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));P.y=Math.sin(o)*e-y;let T=Math.cos(o)*e-x,C=b.z-l;o<=p?(P.z=Math.min(T,C),P.z==C&&(P.y-=(T-C)/Math.tan(p-o))):_.z=Math.min(_.z-T-x,b.z-l),m.subVectors(b,_),h.subVectors(P,_);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),M=O/Math.cos(o/2),E=m.clone().normalize().add(h.normalize()).setLength(M).add(_);m.set(0,v(o,!0),N(o,!0)),d.push([P,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(E),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 eu(s,3)),this.setAttribute("normal",new eu(c,3)),this.setAttribute("uv",new eu(u,2))}};var ql=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,_=f+Math.sin(b)*d,P=m+Math.cos(b)*p;l.addPoint(l.createPoint(_,P))}}else for(let w=0;w<o;w++){let b=f+Math.cos(y)*d,_=m+Math.sin(y)*p;l.addPoint(l.createPoint(b,_)),y+=h,b=f+Math.cos(y)*g,_=m+Math.sin(y)*x,w<=o,l.addPoint(l.createPoint(b,_)),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=Rt.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(S,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as ZT}from"three";var Wy=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 ZT(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};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:32,tubularSegments:64,arc:Math.PI*2,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=QT(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 QT(n,r,e,t,o,i,a,s,c,u,l){return[r,e]=[e,r],a=r/2,o/=2*Math.PI,o==1&&(u=0),new Fa(!0,n,r,e,t,o,i,a,s,c,u,l)}import{TorusKnotGeometry as JT}from"three";var $y=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 JT(s,e,t,o,i,a);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var Yy=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=Rt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as Ky,Vector3 as dt,Matrix3 as eO,Matrix4 as on,BufferGeometry as Zy,BufferAttribute as Oi,MathUtils as ru}from"three";function Xy(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}var tO=new on,rO=new on;function oO(n,r,e){let t=[new dt,new dt,new dt],o=[new dt,new dt,new dt];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=ru.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(c)}),new on().makeBasis(t[0],t[1],t[2])}var Qy=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??wi.create({parameters:td}).userData.shape;return{path:n.path??oi.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...ul,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new ou(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new Zy,{userData:{...n,type:"PathGeometry"}})}},ou=class extends Zy{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)||!Xy(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]=oO(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:_,vertices:P}=this._computeShapePoints(w),v=0,N;S==="round"&&(N=new Ro(this.inputs.shapeData,2*g,g,w,x,void 0,!0),v=N.getAttribute("position").count);let T=0,C=0;_.sort((z,V)=>z.start-V.start),_.forEach(z=>{z.verticesStart=T,z.verticesCount=z.continuous.reduce((V,W,$)=>V+($===0||!W?2:1),0),C+=z.verticesCount,T=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=kd}M=A.vertexCount}let E=O+2*M+v*2,X=O+2*M,R={positions:new Float32Array(E*3),normals:new Float32Array(E*3),uvs:new Float32Array(E*2)},Z=[];if(_.forEach(z=>{this._extrudeRegion(z,P,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 Oi(R.positions,3)),this.setAttribute("normal",new Oi(R.normals,3)),this.setAttribute("uv",new Oi(R.uvs,2)),this.setIndex(Z);let W=tO;W.copy(d[d.length-1]).setPosition(l[l.length-1]),this.applyMatrix4OnRange(W,X,E),W.copy(d[0]).setPosition(l[0]).multiply(rO.makeScale(1,1,-1)),this.applyMatrix4OnRange(W,X-v,X),this.reverseIndicesOnRange(z,V)}else this.setAttribute("position",new Oi(R.positions,3)),this.setAttribute("normal",new Oi(R.normals,3)),this.setAttribute("uv",new Oi(R.uvs,2)),this.setIndex(Z)}_extractPathPoints(){let t=Ol(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 dt,s=new dt,c=new dt,u=new dt,l=new dt(0,1,0);for(let y=0;y<o;y++){let g=e[y],x;y===0?x=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):x=e[y-1];let S;y===o-1?S=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):S=e[y+1];let w=g.clone().sub(x).normalize(),b=S.clone().sub(g).normalize(),_=w.clone().add(b).normalize();c.copy(_),y===0&&(_.equals(l)||_.clone().negate().equals(l))&&l.set(0,0,1);let P=l.clone().cross(_).normalize(),v=_.clone().cross(P).normalize();l.copy(v),u.copy(P),y===0&&(a.copy(v),s.copy(_));let N=new on().makeBasis(P,v,_);t.push(N)}let d=i?s:c,p=i?a:new dt(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(ru.lerp(a,a+s,m));let h=ru.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=ja}let c;try{c=pr({windingRule:_e.ODD,elementType:ke.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{c=Fd}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 _=x,P=w-1,v=x+1,N=o.roundedCurves.length;do{let T=_-x,C=s.vertices[P*2+0],O=s.vertices[P*2+1],A=s.vertices[_*2+0],M=s.vertices[_*2+1],E=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-E,W=M-X,$=Math.sqrt(V*V+W*W);V/=$,W/=$,b.normals[T*2+0]=-W,b.normals[T*2+1]=V;let Y=s.vertexIndices[_];if(Array.isArray(Y))b.continuous[T]=!1;else{let[q,k]=o.getCurveIndexFromVertexId(Y-1,!0);if(k>0&&k<1)b.continuous[T]=!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[T]=F.dot(j)>.95}}y&&(b.normals[T*2+0]*=-1,b.normals[T*2+1]*=-1),[P,_,v]=[_,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 dt,l=new dt,d=new dt,p=new dt,f=new Ky;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,_=y+w,P=g+w,v=g+x;e.isHole?s.push(b,P,_,b,v,P):s.push(b,_,P,b,P,v),x++}}}_closeEnd(e,t,o,i,a,s,c){let u=e.vertexCount,l=new dt(0,0,c?-1:1).applyMatrix4(a),d=new dt,p=new Ky;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 eO().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 Jy,BufferGeometry as nu}from"three";import{mergeBufferGeometries as nO}from"three/examples/jsm/utils/BufferGeometryUtils.js";function eg(){let n=new nu;return n.setAttribute("position",new Jy(new Float32Array([]),3)),n.setIndex(new Jy(new Uint16Array([]),1)),n}var iO=eg().attributes,aO=12,sO=1,Ai=class extends nu{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,iO),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=l===2?u.toUpperCase():l===3?u.toLowerCase():u,p=lO(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,x=f.map(b=>new Ce().fromShape(b));this.vectorShapes=x;let S=x.map(b=>Rt.create({shape:b,parameters:{depth:a,extrudeBevelSegments:c,extrudeBevelSize:s,windingRule:a<=0?_e.NONZERO:_e.ODD,subdivisions:this.isLowResolution&&a>0?sO:aO}})),w=S.length?nO(S):eg();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([b,_])=>{this.setAttribute(b,_)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=or(new nu,Ai.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 lO(n,r,e){e=e??n.text;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 Ju,BufferAttribute as Zy,Uint32BufferAttribute as ed,Float32BufferAttribute as td,Matrix4 as iO,Vector3 as Gs,Sphere as sO,Box3 as aO,BoxGeometry as lO}from"three";var Xy,Si=new Promise(n=>{Xy=n}),Yy=!1;var jl;function Ky(){if(Yy)return;if(jl)return jl;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.440/build",o=import("./process.js"),[i,s]=await Promise.all([o,fetch(`${e}/process.wasm`).then(d=>d.arrayBuffer())]),a=i.default,c=await a({wasmBinary:s});Xy(c),Yy=!0}return jl=n(),jl}import{BufferGeometryLoader as rO}from"three";function en(n,r,e){let t={parameters:n,type:n.type};if(n.type==="PathGeometry")t.path=n.path;else if(n.type==="VectorGeometry"){let i=Ae.createFromState(n.shape,n.width,n.height);t.shape=i}else if(n.type==="NonParametricGeometry")n.data.groups&&n.data.groups.forEach(i=>i.materialIndex=Math.max(i.materialIndex??0,0)),t.geometry=new rO().parse(n);else{if(n.type==="SubdivGeometry")return new Xe(n,e);if(n.type==="TextGeometry")return new bi(n,r)}let o;try{o=Qu(t)}catch(i){console.error(i)}if(!o){let i=Ae.createFromState(Zn.defaultData(),100,100);t.shape=i,o=Qu(t)}return o}import{Matrix4 as oO}from"three";var nO=new oO;function Rs(n,r,e,t){let o=n.position.array,i=n.normal.array,s=nO.makeScale(r,e,t).invert().elements,a,c,d;for(var l=0,u=o.length;l<u;l+=3)o[l]*=r,o[l+1]*=e,o[l+2]*=t,a=i[l],c=i[l+1],d=i[l+2],i[l]=s[0]*a+s[4]*c+s[8]*d,i[l+1]=s[1]*a+s[5]*c+s[9]*d,i[l+2]=s[2]*a+s[6]*c+s[10]*d;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Fl=new aO,wi=new Gs,pe;Si.then(n=>{pe=n});var Qy=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Jy=new Uint32Array([0,1,2,3]),eg=new Uint8Array([4]),Xe=class extends Ju{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=bo.div(t,o);this.subdividedGeometry&&Rs(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Rs(this.originalGeometry.attributes,...i),this.data=e;let s=this.userData.parameters;this.userData.parameters={width:s.width*i[0],height:s.height*i[1],depth:s.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(wi.fromArray(i));let a=wi.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=a/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=Xe.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lO(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&&(Xe.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new sO,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Fl.setFromBufferAttribute(t),Fl.getCenter(o),e.boundingSphere.radius=o.distanceTo(Fl.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Fl.getSize(wi);let i={width:wi.x,height:wi.y,depth:wi.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,a,c,d=e?.phongAngle??35;o===!1&&(d=-1),t&&(pe.free_bvh(t),pe.free_subdivision_surface(t));try{s=Xe.allocate(e,i)}catch(l){console.error(l,e),s=Xe.allocate({positionWASM:Qy,indexWASM:Jy,verticesPerFaceWASM:eg},i)}if(pe.set_destination_refinement_level(s,0),a=Xe.buildLevel(s,!0,d),e.subdivisions>0)try{pe.set_destination_refinement_level(s,e.subdivisions),c=Xe.buildLevel(s,!1,d)}catch{try{pe.set_destination_refinement_level(s,e.subdivisions-1),c=Xe.buildLevel(s,!1,d)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:a,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:en(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let a,c,d,l;({positions:a,triIndices:l}=id(i.getAttribute("position"),s));let u;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;u=[p,f]}return{indices:c,verticesPerFace:d}=sd(a,l,i,u),{positions:a,indices:c,verticesPerFace:d}}static allocate(e,t){let o,i,s,a=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=Qy,i=Jy,s=eg);let d=o.length,l=i.length,u=s.length,p=o.length+a.length+c.length,f=i.length+s.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(a,o.length),x.set(c,o.length+a.length),S.set(i,0),S.set(s,i.length);let w;e?.scaleBaked?.some(_=>_!==1)&&(w=new iO().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let b=w?pe.alloc_subdivision_surface2(g,d,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,u,w.elements):pe.alloc_subdivision_surface(g,d,g+h,l,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,u);return pe._free(g),b}static buildLevel(e,t,o,i,s){let a=s?pe.get_mesh_data2(e,t?pe.Level.CONTROL:pe.Level.REFINED,o,s.elements):pe.get_mesh_data(e,t?pe.Level.CONTROL:pe.Level.REFINED,o),c=8,d=pe.HEAPU32.subarray(a>>2,(a>>2)+c),l=d.subarray(4,4+4),u=0,p=pe.HEAPU32[d[u]>>2],f=pe.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let m=pe.HEAPU32[d[u]>>2],h=pe.HEAPF32.subarray(m>>2,(m>>2)+l[u]);u++;let y=pe.HEAPU32[d[u]>>2],g=pe.HEAPU32.subarray(y>>2,(y>>2)+l[u]);u++;let x=pe.HEAPU32[d[u]>>2],S=pe.HEAPU32.subarray(x>>2,(x>>2)+l[u]);if(u++,i===void 0){let w=new Ju;if(w.setIndex(new ed(S,1)),w.setAttribute("position",new td(f,3)),w.setAttribute("normal",new td(h,3)),t){w.setAttribute("faceMap",new ed(g,1));let b=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new Zy(b,4))}return pe.free_mesh_data(a),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(a)}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),s=4,a=pe.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+2),d=0,l=pe.HEAPU32[a[d]>>2],u=pe.HEAPF32.subarray(l>>2,(l>>2)+c[d]);d++;let p=pe.HEAPU32[a[d]>>2],f=pe.HEAPU32.subarray(p>>2,(p>>2)+c[d]);if(t===void 0){let m=new Ju;m.setAttribute("position",new td(u,3));let h=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)h[y++]=o.r,h[y++]=o.g,h[y++]=o.b;return m.setAttribute("color",new Zy(h,3)),m.setIndex(new ed(f,1)),pe.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(u),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 s=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),a=6,c=pe.HEAPU32.subarray(s>>2,(s>>2)+a),d=c.subarray(3,3+3),l=0,u=pe.HEAPU32[c[l]>>2],p=new Float32Array(pe.HEAPF32.subarray(u>>2,(u>>2)+d[l]));l++;let f=pe.HEAPU32[c[l]>>2],m=new Uint32Array(pe.HEAPU32.subarray(f>>2,(f>>2)+d[l]));l++;let h=pe.HEAPU32[c[l]>>2],y=new Uint8Array(pe.HEAPU32.subarray(h>>2,(h>>2)+d[l]));return pe.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var tg=["getX","getY","getZ"];function id(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],a=1e4;for(let d=0;d<t;d++){let l=r?r.getX(d):d,u="";for(let p=0;p<3;p++)u+=`${~~(n[tg[p]](l)*a)},`;if(u in e)i.push(e[u]);else{for(let p=0;p<3;p++)s.push(n[tg[p]](l));e[u]=o,i.push(o),o++}}let c=[];for(let d=0;d<i.length;d+=3)i[d]===i[d+1]||i[d]===i[d+2]||i[d+1]===i[d+2]||c.push(i[d],i[d+1],i[d+2]);return{positions:s,triIndices:c}}var kl=new Gs,rd=new Gs,od=new Gs,nd=new Gs;function sd(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([]),d=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&d<=24&&d%4===0&&e.userData.parameters.angle>=360){let p=c.length/2/d;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 u=0;if(l<0)for(let p=0;p<c.length;p+=2)n.push(c[p],c[p+1],0),o.push(u++);else for(let p=c.length-2;p>=0;p-=2)n.push(c[p],c[p+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}let s=new Float32Array([e.userData.parameters.depth])[0],a=0;for(;a<r.length;){if(e.useNgonForTopBottomFaceDuringBake){let c=0;if((n[r[a]*3+2]===s||n[r[a]*3+2]===0)&&c++,(n[r[a+1]*3+2]===s||n[r[a+1]*3+2]===0)&&c++,(n[r[a+2]*3+2]===s||n[r[a+2]*3+2]===0)&&c++,c===3)break}if(r[a+1]===r[a+3]&&r[a+2]===r[a+5]||r[a+0]===r[a+3]&&r[a+2]===r[a+4]){kl.set(n[r[a]*3],n[r[a]*3+1],n[r[a]*3+2]),rd.set(n[r[a+1]*3],n[r[a+1]*3+1],n[r[a+1]*3+2]),od.set(n[r[a+4]*3],n[r[a+4]*3+1],n[r[a+4]*3+2]),nd.set(n[r[a+5]*3],n[r[a+5]*3+1],n[r[a+5]*3+2]),rd.sub(kl).normalize(),od.sub(kl).normalize(),nd.sub(kl).normalize();let c=rd.cross(od).dot(nd);Math.abs(c)>.005||t&&t.some((d,l)=>l%2===1?!1:a>=t[l]&&a<t[l+1])?(o.push(r[a],r[a+1],r[a+2]),i.push(3),a+=3):(o.push(r[a],r[a+1],r[a+4],r[a+5]),i.push(4),a+=6)}else o.push(r[a],r[a+1],r[a+2]),i.push(3),a+=3}if(e.useNgonForTopBottomFaceDuringBake){let c=[],d=[],l=0;for(let u=0,p=0;u<n.length;u+=3,p++)n[u+2]===0&&(c.push(p),l++),n[u+2]===s&&d.push(p);if(e.userData.parameters.extrudeBevelSize===0){let u=d[0];d[0]=d[1],d[1]=u}c.reverse(),o.push(...c,...d),i.push(l,l)}return{indices:o,verticesPerFace:i}}var Zt={};nx(Zt,{calcBoolean:()=>fO,calcBooleanTopological:()=>pO,freeMeshSet:()=>gO,getMeshSet:()=>mO,hasOpenEdges:()=>hO,transformMeshSet:()=>yO});var cO,rg=new Promise(n=>{cO=n});import{Float32BufferAttribute as og,Sphere as uO}from"three";var be,_i;rg.then(n=>be=n);function dO(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:s}=id(n.getAttribute("position"),o),a;if(r&&e){let{indices:c,verticesPerFace:d}=sd(i,s,n);a=d.length,t=[];for(let l=0,u=0;l<a;l++){t.push(d[l]);for(let p=0;p<d[l];p++)t.push(c[u++])}}else{let c=s.length;t=Array(c+c/3),a=0;for(let d=0,l=0;l<t.length;)t[l++]=3,a++,t[l++]=s[d++],t[l++]=s[d++],t[l++]=s[d++]}return{positions:i,faceIndices:t,nFaces:a}}function ng(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=be._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(be.HEAPU32.buffer,i,r):new Float32Array(be.HEAPF32.buffer,i,r)).set(n,0),i}function ig(n){switch(n){case 0:return be.OP.UNION;case 1:return be.OP.INTERSECTION;case 2:return be.OP.A_MINUS_B;case 3:return be.OP.B_MINUS_A;case 4:return be.OP.SYMMETRIC_DIFFERENCE;case 5:return be.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function pO(n,r){_i===void 0&&(_i=be.init_csg());let e=ng(n),t=be.csg_calc_topological(_i,e,n.length,ig(r));be._free(e);let o=6,i=be.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),a=0,c=be.HEAPU32[i[a]>>2],d=new Float32Array(be.HEAPF32.subarray(c>>2,(c>>2)+s[a]));a++;let l=be.HEAPU32[i[a]>>2],u=new Uint32Array(be.HEAPU32.subarray(l>>2,(l>>2)+s[a]));a++;let p=be.HEAPU32[i[a]>>2],f=new Uint8Array(be.HEAPU32.subarray(p>>2,(p>>2)+s[a]));return be.free_mesh_data(t),{positions:d,indices:u,verticesPerFace:f}}function fO(n,r,e,t){_i===void 0&&(_i=be.init_csg());let o=ng(n),i=be.csg_calc(_i,o,n.length,t,ig(r));be._free(o);let s=5,a=be.HEAPU32.subarray(i>>2,(i>>2)+s),c=a.subarray(2,2+3),d=0,l=be.HEAPU32[a[d]>>2],u=be.HEAPF32.subarray(l>>2,(l>>2)+c[d]);d++;let p=be.HEAPU32[a[d]>>2],f=be.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let m=c[d];e.setAttribute("position",new og(u,3)),e.setAttribute("normal",new og(f,3));let h=be.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},be.free_mesh_data(i),m}function mO(n,r,e){if(be===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}=dO(n,r,e));let s=t.length,a=o.length,c=t.length,d=o.length,l=c*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,u=c*Float32Array.BYTES_PER_ELEMENT,p=d*Uint32Array.BYTES_PER_ELEMENT,f=be._malloc(l),m=new Float32Array(be.HEAPF32.buffer,f,c),h=new Uint32Array(be.HEAPU32.buffer,f+u,d);return m.set(t,0),h.set(o,0),be.get_csg_mesh(f,s,f+u,a,i)}function hO(n){return be.has_open_edges(n)}function yO(n,r){be.transform_csg_mesh(n,r.elements)}function gO(n){be.free_csg_mesh(n)}var xO={ConeGeometry:Vh,CubeGeometry:zh,CylinderGeometry:Gh,DodecahedronGeometry:jh,EllipseGeometry:hi,HelixGeometry:Sy,IcosahedronGeometry:wy,LatheGeometry:_y,NonParametricGeometry:Ly,PolygonGeometry:Gl,PyramidGeometry:Dy,RectangleGeometry:Vl,SphereGeometry:By,PlaneGeometry:Ry,BackdropGeometry:Gy,StarGeometry:zl,TextFrameGeometry:Vy,TorusGeometry:zy,TorusKnotGeometry:jy,TriangleGeometry:Fy,PathGeometry:Wy,VectorGeometry:Rt},Qu=n=>xO[n.type].create(n);function Vs(n){return n!==null&&"booleanOp"in n}var Pi=class extends ai(bO){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new vO}updateVisible(){super.updateVisible(),this.visible=!Vs(this.parent)&&this.visible,Vs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Zt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Vs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Pi&&(e.freeBooleanPointer(),Vs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Vs(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var Ul=new SO;function zs(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,a=1/0,c=-1/0,d=-1/0,l=-1/0;for(let u=r;u<e;u++){let p=n.getX(u),f=n.getY(u),m=n.getZ(u);p<i&&(i=p),f<s&&(s=f),m<a&&(a=m),p>c&&(c=p),f>d&&(d=f),m>l&&(l=m)}Ul.min.set(i,s,a),Ul.max.set(c,d,l),Ul.getCenter(t),Ul.getSize(o).multiplyScalar(.5)}var PO=new wO,TO=new _O,vt=class extends Pi{constructor(r,e){super(PO,TO),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?zs(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 RA,Matrix4 as GA,Sphere as Ug,Vector3 as VA}from"three";import{BufferAttribute as LA,Float32BufferAttribute as kg,MathUtils as Ld,Vector3 as Dd}from"three";import{ShaderMaterial as vA}from"three";import{CubeReflectionMapping as GO,CubeRefractionMapping as VO,CubeUVReflectionMapping as zO,LinearEncoding as fg,sRGBEncoding as jO}from"three";var js=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 OO}from"three";var ut=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=OO.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,s){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 ut&&(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 ad=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}},rt=new ad;import{Vector2 as sg}from"three";import{MathUtils as AO}from"three";var se=class extends ut{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 s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=AO.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let a=e.getNodeData(o),c=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return a.name=a.name||super.build(e,t,o),a.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||a.deps===1))return super.build(e,t,o);o=this.getUUID(!1);let d=this.getTemp(e,o);if(d)return e.format(d,c,t);{d=super.generate(e,t,o,a.output,i);let l=this.generate(e,c,o);return e.addNodeCode(d+" = "+l+";"),e.format(d,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,s){return this.getShared(e,t)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),s,this.getLabel()).name}};var Ee=class extends se{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,s,a){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,s,a):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,a,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,a,this.getLabel())),e.format(c.fragment.name,i,t))}};var Ue=class extends Ee{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof sg?e:new sg(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,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};import{Vector3 as ag}from"three";var bt=class extends Ee{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof ag?e:new ag(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,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};import{Color as CO}from"three";var ot=class extends CO{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,s=o[1],a=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.a=s==="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(a))return this.a=s==="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 Gt=class extends Ee{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof ot?e:new ot(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var NO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,lg=/[a-z_0-9]+/gi,H=class extends se{constructor(e,t,o,i,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,t,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,s){let a,c=0,d=this.src;if(this.includes)for(let u=0;u<this.includes.length;u++)e.include(this.includes[u],this);for(let u in this.extensions)e.extensions[u]=!0;let l=[];for(;a=lg.exec(this.src);)l.push(a);for(let u=0;u<l.length;u++){let p=l[u],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&rt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=rt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||rt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}h=y.build(e)}f!==h&&d[p.index+c-1]!=="."&&(d=d.substring(0,p.index+c)+h+d.substring(p.index+f.length+c),c+=h.length-f.length),this.getIncludeByName(h)===void 0&&rt.contains(h)&&e.include(rt.get(h))}return t==="source"?d:this.isMethod?(this.isInterface||e.include(this,void 0,d),this.name):e.format("( "+d+" )",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 s=NO.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(lg);if(a){let c=0;for(;c<a.length;){let d=a[c++],l;d==="in"||d==="out"||d==="inout"?l=a[c++]:(l=d,d="");let u=a[c++];this.inputs.push({name:u,type:l,qualifier:d})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var IO=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ld=class extends se{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ld.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,o,i,s){this.src=e||"";let a,c,d="",l=IO.exec(e);this.useDefine=s??this.src.charAt(0)==="#",l&&l.length>1?(c=l[1],a=l[2],d=l[3]):(a=this.src,c="f"),this.name=a,this.type=c,this.value=d}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,s){return e.format(this.name,this.getType(e),t)}},Oe=ld;Oe.PI="PI",Oe.PI2="PI2",Oe.RECIPROCAL_PI="RECIPROCAL_PI",Oe.RECIPROCAL_PI2="RECIPROCAL_PI2",Oe.LOG2="LOG2",Oe.EPSILON="EPSILON";var MO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
- )*?)}`,"gim"),EO=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Ti=class extends se{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,o,i,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=MO.exec(e);if(t){let o=t[2],i;for(;i=EO.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Oi=class extends se{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)}};rt.addKeyword("uv",function(){return new Oi});rt.addKeyword("uv2",function(){return new Oi(1)});import{LinearEncoding as LO,sRGBEncoding as DO}from"three";var tn=class extends se{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??tn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case LO:return["Linear"];case DO:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=tn.Nodes[this.method],a=e.include(s);if(a===tn.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(a+"( "+o+", "+c+" )",i,t)}else return e.format(a+"( "+o+" )",i,t)}fromEncoding(e){let t=tn.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=tn.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Nt=tn;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 au,BufferAttribute as ng,Uint32BufferAttribute as su,Float32BufferAttribute as lu,Matrix4 as pO,Vector3 as qa,Sphere as fO,Box3 as mO,BoxGeometry as hO}from"three";var rg,Ci=new Promise(n=>{rg=n}),tg=!1;var $l;function og(){if(tg)return;if($l)return $l;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.441/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});rg(c),tg=!0}return $l=n(),$l}import{BufferGeometryLoader as cO}from"three";function an(n,r,e){let t={parameters:n,type:n.type};if(n.type==="PathGeometry")t.path=n.path;else if(n.type==="VectorGeometry"){let i=Ce.createFromState(n.shape,n.width,n.height);t.shape=i}else if(n.type==="NonParametricGeometry")n.data.groups&&n.data.groups.forEach(i=>i.materialIndex=Math.max(i.materialIndex??0,0)),t.geometry=new cO().parse(n);else{if(n.type==="SubdivGeometry")return new Xe(n,e);if(n.type==="TextGeometry")return new Ai(n,r)}let o;try{o=iu(t)}catch(i){console.error(i)}if(!o){let i=Ce.createFromState(ri.defaultData(),100,100);t.shape=i,o=iu(t)}return o}import{Matrix4 as dO}from"three";var uO=new dO;function Wa(n,r,e,t){let o=n.position.array,i=n.normal.array,a=uO.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 Yl=new mO,Ni=new qa,pe;Ci.then(n=>{pe=n});var ig=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ag=new Uint32Array([0,1,2,3]),sg=new Uint8Array([4]),Xe=class extends au{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=wo.div(t,o);this.subdividedGeometry&&Wa(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Wa(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(Ni.fromArray(i));let s=Ni.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}=Xe.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new hO(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&&(Xe.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new fO,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Yl.setFromBufferAttribute(t),Yl.getCenter(o),e.boundingSphere.radius=o.distanceTo(Yl.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Yl.getSize(Ni);let i={width:Ni.x,height:Ni.y,depth:Ni.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=Xe.allocate(e,i)}catch(l){console.error(l,e),a=Xe.allocate({positionWASM:ig,indexWASM:ag,verticesPerFaceWASM:sg},i)}if(pe.set_destination_refinement_level(a,0),s=Xe.buildLevel(a,!0,u),e.subdivisions>0)try{pe.set_destination_refinement_level(a,e.subdivisions),c=Xe.buildLevel(a,!1,u)}catch{try{pe.set_destination_refinement_level(a,e.subdivisions-1),c=Xe.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}=pu(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}=fu(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=ig,i=ag,a=sg);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(_=>_!==1)&&(w=new pO().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 au;if(w.setIndex(new su(S,1)),w.setAttribute("position",new lu(f,3)),w.setAttribute("normal",new lu(h,3)),t){w.setAttribute("faceMap",new su(g,1));let b=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new ng(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 au;m.setAttribute("position",new lu(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 ng(h,3)),m.setIndex(new su(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 lg=["getX","getY","getZ"];function pu(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[lg[p]](l)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[lg[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 Xl=new qa,cu=new qa,du=new qa,uu=new qa;function fu(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]){Xl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),cu.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),du.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),uu.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),cu.sub(Xl).normalize(),du.sub(Xl).normalize(),uu.sub(Xl).normalize();let c=cu.cross(du).dot(uu);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 Zt={};ux(Zt,{calcBoolean:()=>bO,calcBooleanTopological:()=>vO,freeMeshSet:()=>PO,getMeshSet:()=>SO,hasOpenEdges:()=>wO,transformMeshSet:()=>_O});var yO,cg=new Promise(n=>{yO=n});import{Float32BufferAttribute as dg,Sphere as gO}from"three";var Se,Ii;cg.then(n=>Se=n);function xO(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}=pu(n.getAttribute("position"),o),s;if(r&&e){let{indices:c,verticesPerFace:u}=fu(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 ug(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 pg(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 vO(n,r){Ii===void 0&&(Ii=Se.init_csg());let e=ug(n),t=Se.csg_calc_topological(Ii,e,n.length,pg(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 bO(n,r,e,t){Ii===void 0&&(Ii=Se.init_csg());let o=ug(n),i=Se.csg_calc(Ii,o,n.length,t,pg(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 dg(d,3)),e.setAttribute("normal",new dg(f,3));let h=Se.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new gO),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 SO(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}=xO(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 wO(n){return Se.has_open_edges(n)}function _O(n,r){Se.transform_csg_mesh(n,r.elements)}function PO(n){Se.free_csg_mesh(n)}var TO={ConeGeometry:Wh,CubeGeometry:qh,CylinderGeometry:Hh,DodecahedronGeometry:$h,EllipseGeometry:wi,HelixGeometry:Cy,IcosahedronGeometry:Ny,LatheGeometry:Iy,NonParametricGeometry:jy,PolygonGeometry:Hl,PyramidGeometry:Fy,RectangleGeometry:Wl,SphereGeometry:ky,PlaneGeometry:Uy,BackdropGeometry:Hy,StarGeometry:ql,TextFrameGeometry:Wy,TorusGeometry:qy,TorusKnotGeometry:$y,TriangleGeometry:Yy,PathGeometry:Qy,VectorGeometry:Rt},iu=n=>TO[n.type].create(n);function $a(n){return n!==null&&"booleanOp"in n}var Mi=class extends mi(AO){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new OO}updateVisible(){super.updateVisible(),this.visible=!$a(this.parent)&&this.visible,$a(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Zt.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),$a(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Mi&&(e.freeBooleanPointer(),$a(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&$a(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var Kl=new CO;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)}Kl.min.set(i,a,s),Kl.max.set(c,u,l),Kl.getCenter(t),Kl.getSize(o).multiplyScalar(.5)}var MO=new NO,LO=new IO,vt=class extends Mi{constructor(r,e){super(MO,LO),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 UA,Matrix4 as HA,Sphere as Kg,Vector3 as WA}from"three";import{BufferAttribute as jA,Float32BufferAttribute as Xg,MathUtils as ju,Vector3 as Fu}from"three";import{ShaderMaterial as OA}from"three";import{CubeReflectionMapping as HO,CubeRefractionMapping as WO,CubeUVReflectionMapping as qO,LinearEncoding as bg,sRGBEncoding as $O}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 EO}from"three";var ut=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=EO.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 ut&&(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 mu=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}},ot=new mu;import{Vector2 as fg}from"three";import{MathUtils as DO}from"three";var ae=class extends ut{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=DO.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 Ee=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 Ee{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof fg?e:new fg(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 mg}from"three";var bt=class extends Ee{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof mg?e:new mg(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 BO}from"three";var nt=class extends BO{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 Gt=class extends Ee{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof nt?e:new nt(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 RO=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,hg=/[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=hg.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&&ot.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=ot.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||ot.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&&ot.contains(h)&&e.include(ot.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=RO.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(hg);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 GO=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,hu=class extends ae{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||hu.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=GO.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=hu;Ae.PI="PI",Ae.PI2="PI2",Ae.RECIPROCAL_PI="RECIPROCAL_PI",Ae.RECIPROCAL_PI2="RECIPROCAL_PI2",Ae.LOG2="LOG2",Ae.EPSILON="EPSILON";var VO=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
+ )*?)}`,"gim"),zO=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Li=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=VO.exec(e);if(t){let o=t[2],i;for(;i=zO.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Ei=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)}};ot.addKeyword("uv",function(){return new Ei});ot.addKeyword("uv2",function(){return new Ei(1)});import{LinearEncoding as jO,sRGBEncoding as FO}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 jO:return["Linear"];case FO: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 Ce=class extends H{constructor(e="",t,o,i,s){super(e,s,i,o,t);this.nodeType="Expression"}};import{Texture as BO}from"three";var It=class extends Ee{constructor(e=new BO,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Oi,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"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,c;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?c=a+"( "+o+", "+i+", "+s+" )":c=a+"( "+o+", "+i+" )";let d={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(d),this.colorSpace=this.colorSpace??new Nt(new Ce("",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 Ee{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,s,a){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var Fs=class extends se{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,s){i=this.getType(e);let a=this.value,c=a.build(e,t)+"( ",d=[];if(a.inputs){for(let l=0;l<a.inputs.length;l++){let u=a.inputs[l],p=this.inputs[l]||this.inputs[u.name];d.push(p.build(e,e.getTypeByFormat(u.type)))}c+=d.join(", ")+" )"}return e.format(c,i,t)}};var cd=class extends se{constructor(e,t,o=cd.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),s=this.b.build(e,o);return e.format("( "+i+" "+this.op+" "+s+" )",o,t)}},dt=cd;dt.ADD="+",dt.SUB="-",dt.MUL="*",dt.DIV="/";var Le=class extends se{constructor(e,t=Le.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 Le.MIX:case Le.CLAMP:case Le.REFRACT:case Le.SMOOTHSTEP:case Le.FACEFORWARD:return 3;case Le.MIN:case Le.MAX:case Le.MOD:case Le.STEP:case Le.REFLECT:case Le.DISTANCE:case Le.DOT:case Le.CROSS:case Le.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 Le.LENGTH:case Le.DISTANCE:case Le.DOT:return"f";case Le.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let o,i,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,c=this.b?e.getTypeLength(this.b.getType(e)):0,d=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),u=this.getType(e);switch(this.type=u,this.method){case Le.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case Le.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case Le.CROSS:o=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case Le.STEP:o=this.a.build(e,a===1?"f":l),i=this.b.build(e,l);break;case Le.MIN:case Le.MAX:case Le.MOD:o=this.a.build(e,l),i=this.b.build(e,c===1?"f":l);break;case Le.REFRACT:o=this.a.build(e,l),i=this.b.build(e,l),s=this.c.build(e,"f");break;case Le.MIX:o=this.a.build(e,l),i=this.b.build(e,l),s=this.c.build(e,d===1?"f":l);break;default:o=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(s=this.c.build(e,l));break}let p=[];p.push(o),i&&p.push(i),s&&p.push(s);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(", ")+" )",u,t)}},he=Le;he.RAD="radians",he.DEG="degrees",he.EXP="exp",he.EXP2="exp2",he.LOG="log",he.LOG2="log2",he.SQRT="sqrt",he.INV_SQRT="inversesqrt",he.FLOOR="floor",he.CEIL="ceil",he.NORMALIZE="normalize",he.FRACT="fract",he.SATURATE="saturate",he.SIN="sin",he.COS="cos",he.TAN="tan",he.ASIN="asin",he.ACOS="acos",he.ARCTAN="atan",he.ABS="abs",he.SIGN="sign",he.LENGTH="length",he.NEGATE="negate",he.INVERT="invert",he.MIN="min",he.MAX="max",he.MOD="mod",he.STEP="step",he.REFLECT="reflect",he.DISTANCE="distance",he.DOT="dot",he.CROSS="cross",he.POW="pow",he.MIX="mix",he.CLAMP="clamp",he.REFRACT="refract",he.SMOOTHSTEP="smoothstep",he.FACEFORWARD="faceforward";var Ai=class extends se{constructor(e,t,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=o}bilinearCubeUV(e,t,o,i){let s=new Fs(Ai.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new Nt(new Ce("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Nt(new Ce("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Nt(new Ce("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Nt(new Ce("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new Ce(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ce(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ce(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ce(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new Ce("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=s,c}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,s=new Fs(Ai.Nodes.roughnessToMip,[i]),a=new he(s,Ai.Nodes.m0,Ai.Nodes.cubeUV_maxMipLevel,he.CLAMP),c=new he(a,he.FLOOR),d=new he(a,he.FRACT),l=this.bilinearCubeUV(e,this.value,o,c),u=this.bilinearCubeUV(e,this.value,o,new dt(c,new J(1).setReadonly(!0),dt.ADD)),p=new he(l,u,d,he.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)}},Ci=Ai;Ci.Nodes=function(){let e=new Ti(`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 kO}from"three";var It=class extends Ee{constructor(e=new kO,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new Ei,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 Ee{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 yu=class extends ae{constructor(e,t,o=yu.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)}},pt=yu;pt.ADD="+",pt.SUB="-",pt.MUL="*",pt.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)}},ye=De;ye.RAD="radians",ye.DEG="degrees",ye.EXP="exp",ye.EXP2="exp2",ye.LOG="log",ye.LOG2="log2",ye.SQRT="sqrt",ye.INV_SQRT="inversesqrt",ye.FLOOR="floor",ye.CEIL="ceil",ye.NORMALIZE="normalize",ye.FRACT="fract",ye.SATURATE="saturate",ye.SIN="sin",ye.COS="cos",ye.TAN="tan",ye.ASIN="asin",ye.ACOS="acos",ye.ARCTAN="atan",ye.ABS="abs",ye.SIGN="sign",ye.LENGTH="length",ye.NEGATE="negate",ye.INVERT="invert",ye.MIN="min",ye.MAX="max",ye.MOD="mod",ye.STEP="step",ye.REFLECT="reflect",ye.DISTANCE="distance",ye.DOT="dot",ye.CROSS="cross",ye.POW="pow",ye.MIX="mix",ye.CLAMP="clamp",ye.REFRACT="refract",ye.SMOOTHSTEP="smoothstep",ye.FACEFORWARD="faceforward";var Di=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(Di.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(Di.Nodes.roughnessToMip,[i]),s=new ye(a,Di.Nodes.m0,Di.Nodes.cubeUV_maxMipLevel,ye.CLAMP),c=new ye(s,ye.FLOOR),u=new ye(s,ye.FRACT),l=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new pt(c,new J(1).setReadonly(!0),pt.ADD)),p=new ye(l,d,u,ye.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)}},Bi=Di;Bi.Nodes=function(){let e=new Li(`struct TextureCubeUVData {
8
8
  vec4 tl;
9
9
  vec4 tr;
10
10
  vec4 br;
11
11
  vec4 bl;
12
12
  vec2 f;
13
- }`),t=new Oe("float cubeUV_maxMipLevel 8.0",!0),o=new Oe("float cubeUV_minMipLevel 4.0",!0),i=new Oe("float cubeUV_maxTileSize 256.0",!0),s=new Oe("float cubeUV_minTileSize 16.0",!0),a=new H(`float getFace(vec3 direction) {
13
+ }`),t=new Ae("float cubeUV_maxMipLevel 8.0",!0),o=new Ae("float cubeUV_minMipLevel 4.0",!0),i=new Ae("float cubeUV_maxTileSize 256.0",!0),a=new Ae("float cubeUV_minTileSize 16.0",!0),s=new H(`float getFace(vec3 direction) {
14
14
  vec3 absDirection = abs(direction);
15
15
  float face = -1.0;
16
16
  if (absDirection.x > absDirection.z) {
@@ -25,7 +25,7 @@ var J0=Object.create;var wc=Object.defineProperty;var ex=Object.getOwnPropertyDe
25
25
  face = direction.y > 0.0 ? 1.0 : 4.0;
26
26
  }
27
27
  return face;
28
- }`);a.useKeywords=!1;let c=new H(`vec2 getUV(vec3 direction, float face) {
28
+ }`);s.useKeywords=!1;let c=new H(`vec2 getUV(vec3 direction, float face) {
29
29
  vec2 uv;
30
30
  if (face == 0.0) {
31
31
  uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
@@ -41,7 +41,7 @@ var J0=Object.create;var wc=Object.defineProperty;var ex=Object.getOwnPropertyDe
41
41
  uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
42
42
  }
43
43
  return 0.5 * (uv + 1.0);
44
- }`);c.useKeywords=!1;let d=new H(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
44
+ }`);c.useKeywords=!1;let u=new H(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
45
45
  float face = getFace(direction);
46
46
  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
47
47
  mipInt = max(mipInt, cubeUV_minMipLevel);
@@ -69,7 +69,7 @@ var J0=Object.create;var wc=Object.defineProperty;var ex=Object.getOwnPropertyDe
69
69
  uv.x -= texelSize;
70
70
  vec4 bl = texture2D(envMap, uv);
71
71
  return TextureCubeUVData( tl, tr, br, bl, f );
72
- }`,[e,a,c,t,o,i,s]);d.useKeywords=!1;let l=new Oe("float r0 1.0",!0),u=new Oe("float v0 0.339",!0),p=new Oe("float m0 -2.0",!0),f=new Oe("float r1 0.8",!0),m=new Oe("float v1 0.276",!0),h=new Oe("float m1 -1.0",!0),y=new Oe("float r4 0.4",!0),g=new Oe("float v4 0.046",!0),x=new Oe("float m4 2.0",!0),S=new Oe("float r5 0.305",!0),w=new Oe("float v5 0.016",!0),b=new Oe("float m5 3.0",!0),_=new Oe("float r6 0.21",!0),P=new Oe("float v6 0.0038",!0),v=new Oe("float m6 4.0",!0),N=[l,u,p,f,m,h,y,g,x,S,w,b,_,P,v],T=new H(`float roughnessToMip(float roughness) {
72
+ }`,[e,s,c,t,o,i,a]);u.useKeywords=!1;let l=new Ae("float r0 1.0",!0),d=new Ae("float v0 0.339",!0),p=new Ae("float m0 -2.0",!0),f=new Ae("float r1 0.8",!0),m=new Ae("float v1 0.276",!0),h=new Ae("float m1 -1.0",!0),y=new Ae("float r4 0.4",!0),g=new Ae("float v4 0.046",!0),x=new Ae("float m4 2.0",!0),S=new Ae("float r5 0.305",!0),w=new Ae("float v5 0.016",!0),b=new Ae("float m5 3.0",!0),_=new Ae("float r6 0.21",!0),P=new Ae("float v6 0.0038",!0),v=new Ae("float m6 4.0",!0),N=[l,d,p,f,m,h,y,g,x,S,w,b,_,P,v],T=new H(`float roughnessToMip(float roughness) {
73
73
  float mip = 0.0;
74
74
  if (roughness >= r1) {
75
75
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -83,7 +83,7 @@ var J0=Object.create;var wc=Object.defineProperty;var ex=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:d,roughnessToMip:T,m0:p,cubeUV_maxMipLevel:t}}();var rn=class extends se{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??rn.VIEW}getShared(){return this.scope===rn.WORLD}build(e,t,o,i){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,o,i):super.build(e,t,o)}generate(e,t,o,i,s){let a;switch(this.scope){case rn.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case rn.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case rn.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),t)}},pt=rn;pt.LOCAL="local",pt.WORLD="world",pt.VIEW="view",pt.NORMAL="normal";rt.addKeyword("viewNormal",function(){return new pt(pt.VIEW)});rt.addKeyword("localNormal",function(){return new pt(pt.NORMAL)});rt.addKeyword("worldNormal",function(){return new pt(pt.WORLD)});var Dr=class extends se{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Dr.LOCAL}getType(){switch(this.scope){case Dr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Dr.LOCAL:case Dr.WORLD:return!1}return!0}generate(e,t,o,i,s){let a;switch(this.scope){case Dr.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case Dr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case Dr.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Dr.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),t)}},Vt=Dr;Vt.LOCAL="local",Vt.WORLD="world",Vt.VIEW="view",Vt.PROJECTION="projection";rt.addKeyword("position",function(){return new Vt});rt.addKeyword("worldPosition",function(){return new Vt(Vt.WORLD)});rt.addKeyword("viewPosition",function(){return new Vt(Vt.VIEW)});var pr=class extends se{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??pr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case pr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case pr.VECTOR:{let s=new pt(pt.VIEW),a=e.context.roughness,c=s.build(e,"v3"),d=new Vt(Vt.VIEW).build(e,"v3"),l=a?a.build(e,"f"):void 0,u=`reflect( -normalize( ${d} ), ${c} )`;l&&(u=`normalize( mix( ${u}, ${c}, ${l} * ${l} ) )`);let p=`inverseTransformDirection( ${u}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case pr.CUBE:{let s=new pr(pr.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),i="reflectCubeVec"):i=a;break}case pr.SPHERE:{let a="normalize( ( viewMatrix * vec4( "+new pr(pr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),i="reflectSphereVec"):i=a;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)}},Br=pr;Br.CUBE="cube",Br.SPHERE="sphere",Br.VECTOR="vector";var Hl=class extends se{constructor(e=new It,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Ci(this.value,t??new Br(Br.VECTOR),o),this.irradianceNode=new Ci(this.value,new pt(pt.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 RO}from"three";var Wl=class extends Ee{constructor(e=new RO,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new Br,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"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+o+", "+i+", "+s+" )":a="texCube( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},d=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Nt(new Ce("",d)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,d),e.removeContext(),e.format(a,d,t)}};var cg=`
86
+ }`,N);return{bilinearCubeUV:u,roughnessToMip:T,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)}},ft=ln;ft.LOCAL="local",ft.WORLD="world",ft.VIEW="view",ft.NORMAL="normal";ot.addKeyword("viewNormal",function(){return new ft(ft.VIEW)});ot.addKeyword("localNormal",function(){return new ft(ft.NORMAL)});ot.addKeyword("worldNormal",function(){return new ft(ft.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)}},Vt=Br;Vt.LOCAL="local",Vt.WORLD="world",Vt.VIEW="view",Vt.PROJECTION="projection";ot.addKeyword("position",function(){return new Vt});ot.addKeyword("worldPosition",function(){return new Vt(Vt.WORLD)});ot.addKeyword("viewPosition",function(){return new Vt(Vt.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 ft(ft.VIEW),s=e.context.roughness,c=a.build(e,"v3"),u=new Vt(Vt.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 Zl=class extends ae{constructor(e=new It,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Bi(this.value,t??new Rr(Rr.VECTOR),o),this.irradianceNode=new Bi(this.value,new ft(ft.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 UO}from"three";var Ql=class extends Ee{constructor(e=new UO,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 yg=`
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
- `,ug=`
94
+ `,gg=`
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
- `,dg=`
136
+ `,xg=`
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
- `,pg=`
173
+ `,vg=`
174
174
  vec2 oldPos = vPreviousPosition.xy;
175
175
  oldPos /= vPreviousPosition.w;
176
176
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -185,8 +185,8 @@ 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"],FO=["float","vec2","vec3","vec4"],kO={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},UO={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[]"},ql=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 s="";i=i.sort(r);for(let a=0;a<i.length;a++)i[a].src&&(s+=i[a].src+`
189
- `);return s}}();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",`
188
+ `;var Sg=["x","y","z","w"],YO=["float","vec2","vec3","vec4"],XO={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},KO={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[]"},Jl=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
+ `);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
192
192
  #define SPE_BLENDING_MULTIPLY 1
@@ -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(cg),this.addFragmentParsCode(ug),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(dg),this.addFragmentFinalCode(pg)),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(yg),this.addFragmentParsCode(gg),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(xg),this.addFragmentFinalCode(vg)),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
- `}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",s=""){let a=this.getVars(o),c=a[r];if(!c){let d=a.length;c={name:t||"node"+i+d+(s?"_"+s:""),type:e},a.push(c),a[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
- `)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let s=r[o],a=s.type,c=s.name,d=s.size,l=this.getFormatByType(a);if(l===void 0)throw new Error("Node pars "+l+" not found.");l.includes("[]")?t+=e+" "+l.substring(0,l.length-2)+" "+c+`[${d}];
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
+ `)}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 ut?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,c=a.list.length,d=new js({type:e,size:t.size,name:o||"nodeUA"+c+(s?"_"+s:""),node:t,needsUpdate:i});return a.list.push(d),a[r].push(d),a[r][d.name]=d,this.uniforms[d.name]=d,d}else{let a=this.inputs.uniforms,c=a.list.length,d=new js({type:e,name:o||"nodeU"+c+(s?"_"+s:""),node:t,needsUpdate:i});return a.list.push(d),a[r].push(d),a[r][d.name]=d,this.uniforms[d.name]=d,d}}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"?rt.get(r):r,this.context.include===!1)return r.name;r instanceof H?o=this.includes.functions:r instanceof Oe?o=this.includes.consts:r instanceof Ti&&(o=this.includes.structs);let i=o[this.shader]=o[this.shader]||[];if(r){let s=i[r.name];if(s||(s=i[r.name]={node:r,deps:[]},i.push(s),s.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 a=0;do this.include(r.includes[a++],e);while(a<r.includes.length)}return t&&(s.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 FO[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 GO:case VO:return new Wl(t);case zO:return new Hl(new It(t));default:return new It(t)}else{if(t.isVector2)return new Ue(t);if(t.isVector3)return new bt(t);if(t.isVector4)return new Gt(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 kO[r]||r}getFormatByType(r){return UO[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=fg,e===fg&&this.context.gamma&&(e=jO),e}};import{Vector2 as yr,Vector3 as Vr,Vector4 as Wi}from"three";var Ie=class extends Ee{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof ot?e:new ot(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,s,a){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let c=e.getNodeData(o),d=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let l=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${l};`)}return d?this.generateReadonly(e,t,o,i,s,a):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,a,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,a,this.getLabel())),e.format(c.fragment.name,i,t))}generateReadonly(e,t,o,i,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var Se=class extends Ee{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,s,a){return e.format(this.value.toString(),i,t)}};import{UniformsLib as YO,UniformsUtils as XO}from"three";var qe=class extends Ee{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 fr=class extends Ee{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 HO}from"three";var Do=class extends Ee{};var $l=class extends Do{constructor(e){super("v3");this.image=e;this._value=new HO}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 on=class extends Do{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};import{Matrix3 as WO}from"three";var Ni=class extends Ee{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new WO}generateReadonly(e,t,o,i,s,a){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 qO}from"three";var St=class extends Ee{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new qO}generateReadonly(e,t,o,i,s,a){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 $O}from"three";function hg(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var Yl=class extends Ni{constructor(e,t){super(new $O);this.repeat=e;this.offset=t;hg(this.value,e,t)}updateMatrix(){hg(this.value,this.repeat,this.offset)}};import{Vector4 as yg}from"three";var mr=class extends Ee{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof yg?new Array(e).fill(t):new Array(e).fill(new yg(0))}};var Ii=class extends se{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 ud=class extends se{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(ud.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)}},nn=ud;nn.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 ut?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"?ot.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 Li&&(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 YO[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 HO:case WO:return new Ql(t);case qO:return new Zl(new It(t));default:return new It(t)}else{if(t.isVector2)return new Ue(t);if(t.isVector3)return new bt(t);if(t.isVector4)return new Gt(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 XO[r]||r}getFormatByType(r){return KO[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Sg[r]}getIndexByElement(r){return Sg.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=bg,e===bg&&this.context.gamma&&(e=$O),e}};import{Vector2 as gr,Vector3 as zr,Vector4 as Qi}from"three";var Me=class extends Ee{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof nt?e:new nt(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 Ee{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 tA,UniformsUtils as rA}from"three";var qe=class extends Ee{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 Ee{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 ZO}from"three";var Vo=class extends Ee{};var ec=class extends Vo{constructor(e){super("v3");this.image=e;this._value=new ZO}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 Vo{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};import{Matrix3 as QO}from"three";var Ri=class extends Ee{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new QO}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 JO}from"three";var St=class extends Ee{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new JO}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 eA}from"three";function wg(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var tc=class extends Ri{constructor(e,t){super(new eA);this.repeat=e;this.offset=t;wg(this.value,e,t)}updateMatrix(){wg(this.value,this.repeat,this.offset)}};import{Vector4 as _g}from"three";var hr=class extends Ee{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof _g?new Array(e).fill(t):new Array(e).fill(new _g(0))}};var Gi=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 gu=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(gu.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=gu;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 dd=class extends se{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(dd.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)}},Mi=dd;Mi.Nodes=function(){return{customNormal:new H(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
239
+ }`)}}();var xu=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(xu.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)}},Vi=xu;Vi.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 Ei=class extends se{constructor(e,t,o,i,s,a,c,d,l,u,p,f){super("v3");this.nodeType="CustomTexture";this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=s,this.side=a,this.size=c,this.blending=d,this.mat=l,this.isMask=f,this.alpha=u,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(Ei.Nodes.cylindrical);break;case 2:i=e.include(Ei.Nodes.spherical);break;case 1:let a=["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],d=new H(`
248
+ }`)}}();var zi=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(zi.Nodes.cylindrical);break;case 2:i=e.include(zi.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;
@@ -255,7 +255,7 @@ gVelocity = vec4(velocity, 0.0, 1.0);
255
255
 
256
256
  vec3 col = tmp.rgb;
257
257
  float lalpha = alpha * tmp.a;
258
- ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, mat * ${a}));`}
258
+ ${this.side.value===2?"":`lalpha *= step(0.0, ${this.side.value===1?"-1.0 * ":""}dot(vObjectNormal, mat * ${s}));`}
259
259
 
260
260
  if ( crop > 0.5 ) {
261
261
  if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
@@ -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(d);break;case 4:i=e.include(Ei.Nodes.triplanar);break;default:i=e.include(Ei.Nodes.uv);break}e.addFragmentVariable(this.calpha,"float");let s=[];if(s.push("normal"),s.push(this.texture.generate(e,"t")),s.push(this.textureSize.build(e,"v2")),s.push(this.crop.build(e,"f")),s.push(this.mat.build(e,"mat3")),s.push(this.size.build(e,"v2")),s.push(this.blending.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.mode.build(e,"i")),s.push(this.calpha),this.projection.value===4){let a=`${o}_writeUvs`,c=a+"0",d=a+"1",l=a+"2",u=`${o}_triplanarWeights`;e.addFragmentVariable(c,"vec2"),e.addFragmentVariable(d,"vec2"),e.addFragmentVariable(l,"vec2"),e.addFragmentVariable(u,"vec3"),s.push(c),s.push(d),s.push(l),s.push(u)}else{let a=`${o}_writeUvs`;e.addFragmentVariable(a,"vec2"),s.push(a)}return e.format(i+"("+s.join(",")+")",this.getType(e),t)}},Bo=Ei;Bo.Nodes=function(){let e=new H(`
272
+ }`);i=e.include(u);break;case 4:i=e.include(zi.Nodes.triplanar);break;default:i=e.include(zi.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)}},zo=zi;zo.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 Li=class extends se{constructor(e,t,o,i,s,a,c,d,l,u,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=s,this.isWorldSpace=a,this.origin=c,this.direction=d,this.colors=l,this.steps=u,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 ji=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
- }`,[Li.Nodes.vectorLinearWorldSpaceDepth,Li.Nodes.vectorLinearObjectSpaceDepth,Li.Nodes.vectorSphericalObjectSpaceDepth,Li.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 s=e.include(i),a=[];return a.push(this.near.build(e,"f")),a.push(this.far.build(e,"f")),a.push(this.origin.build(e,"v3")),a.push(this.direction.build(e,"v3")),a.push(this.colors.build(e,"v4[]")),a.push(this.steps.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.calpha),e.format(s+"("+a.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)}},Di=Li;Di.Nodes=function(){let e=new H(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
467
+ }`,[ji.Nodes.vectorLinearWorldSpaceDepth,ji.Nodes.vectorLinearObjectSpaceDepth,ji.Nodes.vectorSphericalObjectSpaceDepth,ji.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)}},Fi=ji;Fi.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 ks=class extends se{constructor(e,t,o,i,s,a,c,d){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=s,this.isMask=d,this.alpha=a,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 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) {
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),s=[];return s.push(this.color.build(e,"c")),s.push(this.bias.build(e,"f")),s.push(this.scale.build(e,"f")),s.push(this.intensity.build(e,"f")),s.push(this.factor.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.mode.build(e,"i")),s.push(this.calpha),e.format(i+"("+s.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 pd=class extends se{constructor(e,t,o,i,s,a,c,d,l){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=s,this.morph=a,this.angle=c,this.isMask=l,this.alpha=d,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(pd.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)}},Bi=pd;Bi.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 vu=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(vu.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)}},ki=vu;ki.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 fd=class extends se{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(fd.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)}},Ri=fd;Ri.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 bu=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(bu.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)}},Ui=bu;Ui.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 Us=(s=>(s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin",s.VORONOI="voronoi",s))(Us||{}),ft=function(){let r=new H(`vec3 random3(vec3 c) {
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||{}),mt=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);
@@ -580,7 +580,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
580
580
  d *= w;
581
581
 
582
582
  return dot(d, vec4(52.0));
583
- }`,[r]);e.keywords.F3=new Oe("float F3 0.3333333"),e.keywords.G3=new Oe("float G3 0.1666667");let t=new H(`float simplex3dFractal(vec3 m) {
583
+ }`,[r]);e.keywords.F3=new Ae("float F3 0.3333333"),e.keywords.G3=new Ae("float G3 0.1666667");let t=new H(`float simplex3dFractal(vec3 m) {
584
584
  mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
585
585
  mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
586
586
  mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
@@ -588,7 +588,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
588
588
  + 0.2666667 * simplex3d(2.0 * m * rot2)
589
589
  + 0.1333333 * simplex3d(4.0 * m * rot3)
590
590
  + 0.0666667 * simplex3d(8.0 * m);
591
- }`,[e]),o=new H("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new H("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new H(`float simplexAshima(vec3 v) {
591
+ }`,[e]),o=new H("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),i=new H("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),a=new H(`float simplexAshima(vec3 v) {
592
592
  const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
593
593
  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
594
594
  vec3 i = floor(v + dot(v, C.yyy) );
@@ -633,7 +633,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
633
633
  m = m * m;
634
634
  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
635
635
  dot(p2,x2), dot(p3,x3) ) );
636
- }`,[o,i]),a=new H("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),c=new H("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),d=new H(`float noise(vec3 p){
636
+ }`,[o,i]),s=new H("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),c=new H("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[s]),u=new H(`float noise(vec3 p){
637
637
  vec3 a = floor(p);
638
638
  vec3 d = p - a;
639
639
  d = d * d * (3.0 - 2.0 * d);
@@ -658,7 +658,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
658
658
  a *= 0.5;
659
659
  }
660
660
  return v;
661
- }`,[d]);l.keywords.NUM_OCTAVES=new Oe(`int NUM_OCTAVES ${5}`);let u=new H("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new H(`float perlin(vec3 P){
661
+ }`,[u]);l.keywords.NUM_OCTAVES=new Ae(`int NUM_OCTAVES ${5}`);let d=new H("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new H(`float perlin(vec3 P){
662
662
  vec3 Pi0 = floor(P);
663
663
  vec3 Pi1 = Pi0 + vec3(1.0);
664
664
  Pi0 = mod(Pi0, 289.0);
@@ -717,7 +717,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
717
717
  vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
718
718
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
719
719
  return 2.2 * n_xyz;
720
- }`,[o,i,u]),f=new H(`float hashwithoutsine13(vec3 p3)
720
+ }`,[o,i,d]),f=new H(`float hashwithoutsine13(vec3 p3)
721
721
  {
722
722
  p3 = fract(p3 * .1031);
723
723
  p3 += dot(p3, p3.yzx + 33.33);
@@ -893,8 +893,8 @@ 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:s,fbm:l,perlin:p,voronoi:S}}();var Gi=class extends se{constructor(e,t,o,i,s,a,c,d,l,u,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=s,this.distortion=a,this.colorA=c,this.colorB=d,this.colorC=l,this.colorD=u,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,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let a=Object.values(Us)[this.noiseType.value],c=a=="voronoi"?`
897
- float v = ${a}(st + move, voronoiStyle, smoothness, seed, quality);
896
+ `,[f,m,h,y,g,x]);return{simplex:e,simplexFractal:t,simplexAshima:a,fbm:l,perlin:p,voronoi:S}}();var Hi=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"?`
897
+ float v = ${s}(st + move, voronoiStyle, smoothness, seed, quality);
898
898
 
899
899
  // Apply clipping to colors
900
900
  v = remap(v, lowCut, highCut, 0.0, 1.0);
@@ -904,18 +904,18 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
904
904
  // Note that the voronoi mode only uses colors "A" and "C" from the UI
905
905
  vec4 color = mix(colorA, colorC, v);
906
906
  `:`
907
- vec3 q = vec3(${a}(st),
908
- ${a}(st + vec3(1.0)),
909
- ${a}(st + vec3(1.0)));
910
- vec3 r = vec3(${a}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
911
- ${a}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
912
- ${a}(st * q));
913
- float f = ${a}(st + r);
907
+ vec3 q = vec3(${s}(st),
908
+ ${s}(st + vec3(1.0)),
909
+ ${s}(st + vec3(1.0)));
910
+ vec3 r = vec3(${s}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
911
+ ${s}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
912
+ ${s}(st * q));
913
+ float f = ${s}(st + r);
914
914
  vec4 color;
915
915
  color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
916
916
  color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
917
917
  color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
918
- `,d=new H(`vec3 ${a}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
918
+ `,u=new H(`vec3 ${s}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, int voronoiStyle, float highCut, float lowCut, float smoothness, float seed, int quality, bool isMask, float mask, float alpha, out float calpha)
919
919
  {
920
920
  // Prevent scale of zero
921
921
  scale = max(abs(scale), 0.001);
@@ -930,22 +930,22 @@ 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
- }`,[ft.simplex,ft.simplexFractal,ft.simplexAshima,ft.fbm,ft.perlin,ft.voronoi]),l=e.include(d),u=[];return u.push(this.scale.build(e,"f")),u.push(this.size.build(e,"v3")),u.push(this.move.build(e,"f")),u.push(this.fA.build(e,"v2")),u.push(this.fB.build(e,"v2")),u.push(this.distortion.build(e,"v2")),u.push(this.colorA.build(e,"v4")),u.push(this.colorB.build(e,"v4")),u.push(this.colorC.build(e,"v4")),u.push(this.colorD.build(e,"v4")),u.push(this.voronoiStyle.build(e,"i")),u.push(this.highCut.build(e,"f")),u.push(this.lowCut.build(e,"f")),u.push(this.smoothness.build(e,"f")),u.push(this.seed.build(e,"f")),u.push(this.quality.build(e,"i")),u.push(this.isMask.build(e,"b")),u.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),u.push(this.alpha.build(e,"f")),u.push(this.calpha),e.format(l+"("+u.join(",")+")",this.getType(e),t)}};Gi.numOctaves=5;var md=class extends se{constructor(e,t,o,i,s,a,c,d,l,u,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=s,this.outlineThreshold=a,this.contourFrequency=c,this.outlineSmoothing=d,this.contourDirection=l,this.positionalLines=u,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"),s=this.resolution.build(e,"v2"),a=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(s,"uniform vec2"),e.addVertexParsVariable(a,"uniform bool"),e.addVertexParsVariable(c,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
933
+ }`,[mt.simplex,mt.simplexFractal,mt.simplexAshima,mt.fbm,mt.perlin,mt.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)}};Hi.numOctaves=5;var Su=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
- if (${a}) {
936
+ if (${s}) {
937
937
  vec4 ${o}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
938
938
  // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
939
939
  // normals face the camera directly. So we hackily fix this by offsetting the normal
940
940
  // by a tiny amount.
941
941
  vec3 ${o}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
942
- ${o}_offset = normalize(${o}_clipNormal.xy) / ${s} * (${i} / 2.0) * ${o}_clipPosition.w * 2.0 * ${c};
942
+ ${o}_offset = normalize(${o}_clipNormal.xy) / ${a} * (${i} / 2.0) * ${o}_clipPosition.w * 2.0 * ${c};
943
943
  ${o}_clipPosition.xy += ${o}_offset;
944
944
  // TODO(MAX): To handle multiple outline layers, we only want to extrude
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(md.Nodes.outline),s=[];return s.push(this.outlineColor.build(e,"c")),s.push(this.contourColor.build(e,"c")),s.push(this.outlineWidth.build(e,"f")),s.push(this.contourWidth.build(e,"f")),s.push(this.contourThreshold.build(e,"f")),s.push(this.outlineThreshold.build(e,"f")),s.push(this.contourFrequency.build(e,"f")),s.push(this.outlineSmoothing.build(e,"f")),s.push(this.contourDirection.build(e,"v3")),s.push(this.positionalLines.build(e,"b")),s.push(this.resolution.build(e,"v2")),s.push(this.normalMap.getTexture(e,"t")),s.push(this.depthMap.getTexture(e,"t")),s.push(this.pixelRatio.build(e,"f")),s.push(this.compensation.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),this.firstTime=!this.firstTime,e.format(i+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Vi=md;Vi.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(Su.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."),""}},Wi=Su;Wi.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];
@@ -1094,12 +1094,12 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1094
1094
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1095
1095
 
1096
1096
  return result;
1097
- }`,[e])}}();var Rr=class extends se{constructor(e,t,o,i,s,a,c,d,l,u,p,f,m,h,y,g,x,S){super("v3");this.nodeType="Pattern";this.style=e,this.projection=t,this.axis=o,this.blending=i,this.offset=s,this.colorA=a,this.colorB=c,this.frequency=d,this.size=l,this.variation=u,this.smoothness=p,this.zigzag=f,this.rotation=m,this.vertical=h,this.horizontal=y,this.sides=g,this.isMask=S,this.alpha=x,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,s=new H(`float hashwithoutsine12(vec2 p)
1097
+ }`,[e])}}();var Gr=class extends ae{constructor(e,t,o,i,a,s,c,u,l,d,p,f,m,h,y,g,x,S){super("v3");this.nodeType="Pattern";this.style=e,this.projection=t,this.axis=o,this.blending=i,this.offset=a,this.colorA=s,this.colorB=c,this.frequency=u,this.size=l,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=m,this.vertical=h,this.horizontal=y,this.sides=g,this.isMask=S,this.alpha=x,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,a=new H(`float hashwithoutsine12(vec2 p)
1098
1098
  {
1099
1099
  vec3 p3 = fract(vec3(p.xyx) * .1031);
1100
1100
  p3 += dot(p3, p3.yzx + 33.33);
1101
1101
  return fract((p3.x + p3.y) * p3.z);
1102
- }`),a=new H(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
1102
+ }`),s=new H(`vec2 rotate_uv(in vec2 uv, float a, bool repeat)
1103
1103
  {
1104
1104
  const float mid = 0.5;
1105
1105
  float radians = a * (PI / 180.0);
@@ -1156,7 +1156,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1156
1156
  custom_uv = rotate_uv(custom_uv, rotation, true);
1157
1157
 
1158
1158
  float draw = ${p};
1159
- `}let d=new H(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
1159
+ `}let u=new H(`vec3 ${i}_pattern(vec3 normal, float blending, int style, vec2 offset, vec4 colorA, vec4 colorB, vec2 frequency, float size, float variation, float smoothness, float zigzag, float rotation, vec2 vertical, vec2 horizontal, int sides, bool isMask, float mask, float alpha, out float calpha) {
1160
1160
  const float TWO_PI = PI * 2.0;
1161
1161
  float smoothness_remapped = pow(smoothness, 5.0);
1162
1162
 
@@ -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
- }`,[a,s,Rr.DrawFunctions.circle,Rr.DrawFunctions.ring,Rr.DrawFunctions.polygon,Rr.DrawFunctions.cross,Rr.DrawFunctions.diamond,Rr.DrawFunctions.checkerboard,Rr.DrawFunctions.line,Rr.DrawFunctions.wave]),l=e.include(d),u=[];return u.push("normal"),u.push(this.blending.build(e,"f")),u.push(this.style.build(e,"i")),u.push(this.offset.build(e,"v2")),u.push(this.colorA.build(e,"v4")),u.push(this.colorB.build(e,"v4")),u.push(this.frequency.build(e,"v2")),u.push(this.size.build(e,"f")),u.push(this.variation.build(e,"f")),u.push(this.smoothness.build(e,"f")),u.push(this.zigzag.build(e,"f")),u.push(this.rotation.build(e,"f")),u.push(this.vertical.build(e,"v2")),u.push(this.horizontal.build(e,"v2")),u.push(this.sides.build(e,"i")),u.push(this.isMask.build(e,"b")),u.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),u.push(this.alpha.build(e,"f")),u.push(this.calpha),e.format(l+"("+u.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)}},zi=Rr;zi.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)}},qi=Gr;qi.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);
@@ -1229,7 +1229,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1229
1229
  float outer = smoothstep(-smoothness, smoothness, d - size);
1230
1230
  float inner = smoothstep(-smoothness, smoothness, d - size * inner_width);
1231
1231
  return outer + (1.0 - inner);
1232
- }`,[t]),s=new H(`float sdf_ngon(in vec2 p, in float r, in int n) {
1232
+ }`,[t]),a=new H(`float sdf_ngon(in vec2 p, in float r, in int n) {
1233
1233
  float an = (PI * 2.0) / float(n);
1234
1234
  float he = r * tan(0.5 * an);
1235
1235
 
@@ -1246,7 +1246,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1246
1246
  float polygon(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation, in int sides) {
1247
1247
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1248
1248
  return smoothstep(-smoothness, smoothness, sdf_ngon(f, size, sides));
1249
- }`,[t]),a=new H(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
1249
+ }`,[t]),s=new H(`float sdf_cross(in vec2 p, in vec2 b, float r ) {
1250
1250
  p = abs(p);
1251
1251
  p = (p.y > p.x) ? p.yx : p.xy;
1252
1252
  vec2 q = p - b;
@@ -1273,7 +1273,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1273
1273
  float diamond(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1274
1274
  vec2 f = tile_and_center(uv, frequency, variation, zigzag, rotation);
1275
1275
  return smoothstep(-smoothness, smoothness, sdf_diamond(f, vec2(size)));
1276
- }`,[t]),d=new H(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1276
+ }`,[t]),u=new H(`float checkerboard(in vec2 uv, in vec2 frequency, in float size, in float variation, in float smoothness, in float zigzag, in float rotation) {
1277
1277
  uv *= frequency;
1278
1278
  vec2 i = floor(uv);
1279
1279
 
@@ -1296,7 +1296,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1296
1296
  s + smoothness,
1297
1297
  abs(f.y)
1298
1298
  );
1299
- }`,[t]),u=new H(`// Uses bisection
1299
+ }`,[t]),d=new H(`// Uses bisection
1300
1300
  float udf_cos(in vec2 p, in float a, in float b, in float c, in float d) {
1301
1301
  // Convert all data to a primitive cosine wave
1302
1302
  p = c * (p - vec2(d, a));
@@ -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:s,cross:a,diamond:c,checkerboard:d,line:l,wave:u}}();var hd=class extends se{constructor(e,t,o,i,s,a,c,d){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=s,this.offset=a,this.isMask=d,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(hd.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)}},ji=hd;ji.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 wu=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(wu.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)}},$i=wu;$i.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)),
@@ -1358,7 +1358,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1358
1358
  float noise = simplex3d(st + r);
1359
1359
 
1360
1360
  return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
1361
- }`,[ft.simplex]);return{rainbow:new H(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
1361
+ }`,[mt.simplex]);return{rainbow:new H(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
1362
1362
  vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
1363
1363
 
1364
1364
  float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 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 yd=class extends se{constructor(e,t,o,i,s,a,c,d,l,u){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=s,this.noiseStrength=a,this.noiseScale=c,this.shadowColor=d,this.offset=l,this.alpha=u,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(yd.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)}},Fi=yd;Fi.Nodes=function(){let e=new H(`float rand(float n) {
1371
+ }`,[e])}}();var _u=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(_u.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)}},Yi=_u;Yi.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);
@@ -1396,7 +1396,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1396
1396
  dot(x,vec3(113.5, 271.9, 124.6)));
1397
1397
 
1398
1398
  return fract(sin(x)*43758.5453123);
1399
- }`),s=new H(`vec3 voronoiNoise(in vec3 x)
1399
+ }`),a=new H(`vec3 voronoiNoise(in vec3 x)
1400
1400
  {
1401
1401
  vec3 p = floor(x);
1402
1402
  vec3 f = fract(x);
@@ -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
- }`,[ft.simplex,e,o,s])}}();import{Vector2 as xg}from"three";var gg=function(){return{textureBicubic:new H(`float w0( float a ) {
1607
+ }`,[mt.simplex,e,o,a])}}();import{Vector2 as Tg}from"three";var Pg=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 vg(n,r){return n>=r?new xg(r/n,1):new xg(1,n/r)}var gd=class extends se{constructor(e,t,o,i,s,a,c,d){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=a,this.aspectRatio=c,this.alpha=d,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,xe.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(gd.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)}},ki=gd;ki.Nodes=function(){let e=new H(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1671
+ }`)}}();function Og(n,r){return n>=r?new Tg(r/n,1):new Tg(1,n/r)}var Pu=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(Pu.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)}},Xi=Pu;Xi.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
- }`,[gg.textureBicubic,o,e]),s=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
+ }`,[Pg.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,20 +1759,20 @@ 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
- }`,[s])}}();var xd=(e=>(e.NOISE="noise",e.MAP="map",e))(xd||{}),vd=class extends se{constructor(e,t,o,i,s,a,c,d,l,u,p){super("v3");this.displacementTypeIndex=new Se(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(xd)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Ni(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=u,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=s,this.seed=a,this.highCut=c,this.lowCut=d,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(xd)[this.displacementTypeIndex.value]){case"map":{o=e.include(vd.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 a=Object.values(Us)[this.noiseFunctionIndex.value],c=new H(`vec3 orthogonal(vec3 v) {
1762
+ }`,[a])}}();var Tu=(e=>(e.NOISE="noise",e.MAP="map",e))(Tu||{}),Ou=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(Tu)[this.displacementTypeIndex.value]==="map"&&(this.mat=new Ri(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(Tu)[this.displacementTypeIndex.value]){case"map":{o=e.include(Ou.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) {
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
- }`),d=a=="voronoi"?`
1765
- float v = ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
1764
+ }`),u=s=="voronoi"?`
1765
+ float v = ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
1766
1766
  v = remap(v, lowCut, highCut, 0.0, 1.0);
1767
1767
  v = smax(v, 0.0, smoothness * 0.25);
1768
1768
  v = smin(v, 1.0, smoothness * 0.25);
1769
1769
 
1770
1770
  return p + n * v * intensity;
1771
1771
  `:`
1772
- return p + n * ${a}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
1772
+ return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
1773
1773
  `,l=new H(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality) {
1774
- ${d}
1775
- }`,[ft.simplex,ft.simplexFractal,ft.simplexAshima,ft.fbm,ft.perlin,ft.voronoi]),u=new H(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
1774
+ ${u}
1775
+ }`,[mt.simplex,mt.simplexFractal,mt.simplexAshima,mt.fbm,mt.perlin,mt.voronoi]),d=new H(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, int voronoiStyle, float smoothness, float seed, float highCut, float lowCut, int quality, float intensity, out vec3 displaced_normal) {
1776
1776
  vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1777
1777
  vec3 tangent1 = orthogonal(normal);
1778
1778
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -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(u),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)}},Ui=vd;Ui.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)}},Ki=Ou;Ki.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 xe={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 qe,pixelRatioNode:new J(1),resolution:new Ue,penumbraSize:new fr(5,.5),frameIndex:new Se(0),transmissionLod:new Se(2)};for(let n of Object.values(xe))n.isRenderGlobal=!0;var an=class extends ut{constructor(){super("basic");this.nodeType="Basic";this.color=new Ie(et),this.shadingAlpha=new J(1),this.shadingBlend=new Se(0),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St}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:xe.frameIndex}),e.mergeUniform({resolution:xe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(XO.merge([YO.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 qe,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 ut{constructor(){super("basic");this.nodeType="Basic";this.color=new Me(tt),this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St}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(rA.merge([tA.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>
@@ -1828,9 +1828,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1828
1828
  #include <begin_vertex>
1829
1829
  #endif /* !USE_LAYER_DISPLACE */
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
- `)}else{this.color===void 0&&(this.color=new Ie(et)),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,s=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,a=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
- `));let c=["#include <normal_fragment_begin>",o.code];i&&c.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),a?c.push(a.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`):c.push(`vec3 finalColor = ${o.result};`);let d="1.0";this.mask&&(this.mask.analyze(e),d=`luminance(${this.mask.flow(e,"v3").result})`),i?c.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${d} );`):c.push("gl_FragColor = vec4("+o.result+", 1.0 );"),s&&c.push(`gl_FragColor.a *= ${s.result};`),c.push("#include <fog_fragment>","#include <dithering_fragment>"),t=c.join(`
1833
- `)}return t}};import{UniformsLib as bg,UniformsUtils as KO}from"three";var Hs=class extends ut{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ie(et),this.emissive=new Ie(0),this.emissiveIntensity=new J(1),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new Se(0),this.occlusion=new qe(!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:xe.frameIndex}),e.mergeUniform({resolution:xe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(KO.merge([bg.fog,bg.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(`
1831
+ `)}else{this.color===void 0&&(this.color=new Me(tt)),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
+ `));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 Ag,UniformsUtils as oA}from"three";var Ja=class extends ut{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Me(tt),this.emissive=new Me(0),this.emissiveIntensity=new J(1),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new qe(!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(oA.merge([Ag.fog,Ag.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>
@@ -1923,23 +1923,23 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1923
1923
  #pragma unroll_loop_end
1924
1924
  #endif
1925
1925
  `," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
1926
- `)}else{e.mergeUniform({penumbraSize:xe.penumbraSize}),e.mergeUniform({frameIndex:xe.frameIndex}),e.mergeUniform({aoMap:xe.aoRenderTarget}),e.mergeUniform({aoEnabled:xe.aoEnabled}),this.color===void 0&&(this.color=new Ie(et)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),a=this.occlusion.flow(e,"b",{slot:"occlusion"}),c=this.shadingAlpha.flow(e,"f"),d=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1926
+ `)}else{e.mergeUniform({penumbraSize:ve.penumbraSize}),e.mergeUniform({frameIndex:ve.frameIndex}),e.mergeUniform({aoMap:ve.aoRenderTarget}),e.mergeUniform({aoEnabled:ve.aoEnabled}),this.color===void 0&&(this.color=new Me(tt)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.emissive.flow(e,"c",{slot:"emissive"}),a=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.occlusion.flow(e,"b",{slot:"occlusion"}),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1927
1927
  `));let f=["#include <normal_fragment_begin>",`
1928
1928
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1929
1929
  vec3 viewdx = dFdx(vViewPosition);
1930
1930
  vec3 viewdy = dFdy(vViewPosition);
1931
1931
  vec3 faceNormal = normalize(cross(viewdx, viewdy));
1932
1932
  bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
1933
- `,"#include <clipping_planes_fragment>"];f.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),u&&f.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),f.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&f.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+s.result+";"),f.push("vec3 ao = aoEnabled && "+a.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let m="1.0";this.mask&&(this.mask.analyze(e),m=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
1933
+ `,"#include <clipping_planes_fragment>"];f.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),d&&f.push(d.code,"#ifdef ALPHATEST","if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),f.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),i&&f.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+a.result+";"),f.push("vec3 ao = aoEnabled && "+s.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let m="1.0";this.mask&&(this.mask.analyze(e),m=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
1934
1934
  if (outgoingLight != diffuseColor) {
1935
1935
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1936
1936
  accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${m} * lightAccu;
1937
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${m}, ${d.result} );
1937
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${m}, ${u.result} );
1938
1938
 
1939
1939
  outgoingLight *= ao;
1940
1940
  }
1941
- `),l&&f.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),u?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.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 Sg,UniformsUtils as ZO}from"three";var io=function(){let n=new H(`vec2 dHdxy(sampler2D bumpMap, vec2 bumpMapUv, float bumpScale) {
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 Cg,UniformsUtils as nA}from"three";var ao=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 Ws=class extends ut{constructor(){super("phong");this.nodeType="Phong";this.color=new Ie(et),this.specular=new Ie(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new Se(0),this.occlusion=new qe(!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:xe.frameIndex}),e.mergeUniform({resolution:xe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(ZO.merge([Sg.fog,Sg.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 es=class extends ut{constructor(){super("phong");this.nodeType="Phong";this.color=new Me(tt),this.specular=new Me(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new qe(!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(nA.merge([Cg.fog,Cg.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>
@@ -1991,7 +1991,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1991
1991
  #include <begin_vertex>
1992
1992
  #endif
1993
1993
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
1994
- `)}else{e.mergeUniform({penumbraSize:xe.penumbraSize}),e.mergeUniform({frameIndex:xe.frameIndex}),e.mergeUniform({aoMap:xe.aoRenderTarget}),e.mergeUniform({aoEnabled:xe.aoEnabled}),this.color===void 0&&(this.color=new Ie(et)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),s=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),d=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,u=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=u!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1994
+ `)}else{e.mergeUniform({penumbraSize:ve.penumbraSize}),e.mergeUniform({frameIndex:ve.frameIndex}),e.mergeUniform({aoMap:ve.aoRenderTarget}),e.mergeUniform({aoEnabled:ve.aoEnabled}),this.color===void 0&&(this.color=new Me(tt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e);let o=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let i=this.color.flow(e,"c",{slot:"color"}),a=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
1995
1995
  `));let f=["#include <normal_fragment_begin>",`
1996
1996
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1997
1997
  vec3 viewdx = dFdx(vViewPosition);
@@ -2000,7 +2000,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2000
2000
  if (dot(normal, faceNormal) < 0.0) {
2001
2001
  normal *= -1.0;
2002
2002
  }
2003
- `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(io.dHdxy),e.include(io.perturbNormalArb);let h=this.bumpMap.texture.flow(e,"t"),y=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",x="";this.bumpMap.projection.value===4?x=`
2003
+ `," BlinnPhongMaterial material;"];if(this.bumpMap){e.include(ao.dHdxy),e.include(ao.perturbNormalArb);let h=this.bumpMap.texture.flow(e,"t"),y=this.bumpMap.flow(e,"v3"),g=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",x="";this.bumpMap.projection.value===4?x=`
2004
2004
  vec3 bumpNormal = vec3(0.0);
2005
2005
  {
2006
2006
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2029,16 +2029,16 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2029
2029
  `,f.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
2030
2030
  ${y.result};
2031
2031
  ${x}
2032
- `)}f.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",s.code," vec3 specular = "+s.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),u&&f.push(u.code,"#ifdef ALPHATEST","if ( "+u.result+" <= ALPHATEST ) discard;","#endif"),f.push("material.diffuseColor = diffuseColor;"),f.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),f.push("vec3 ao = aoEnabled && "+o.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let m="1.0";this.mask&&(this.mask.analyze(e),m=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
2032
+ `)}f.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",a.code," vec3 specular = "+a.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),d&&f.push(d.code,"#ifdef ALPHATEST","if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),f.push("material.diffuseColor = diffuseColor;"),f.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),f.push("vec3 ao = aoEnabled && "+o.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let m="1.0";this.mask&&(this.mask.analyze(e),m=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
2033
2033
  if (outgoingLight != diffuseColor) {
2034
2034
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
2035
2035
  accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${m} * lightAccu;
2036
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${m}, ${d.result} );
2036
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${m}, ${u.result} );
2037
2037
 
2038
2038
  outgoingLight *= ao;
2039
2039
  }
2040
- `),l&&f.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),u?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.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 bd,UniformsUtils as QO}from"three";var qs=class extends ut{constructor(){super("standard");this.nodeType="Standard";this.color=new Ie(et),this.roughness=new J(.3),this.metalness=new J(0),this.reflectivity=new J(.5),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new Se(0),this.occlusion=new qe(!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:xe.frameIndex}),e.mergeUniform({resolution:xe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(QO.merge([bd.fog,bd.lights])),bd.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(`
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 Au,UniformsUtils as iA}from"three";var ts=class extends ut{constructor(){super("standard");this.nodeType="Standard";this.color=new Me(tt),this.roughness=new J(.3),this.metalness=new J(0),this.reflectivity=new J(.5),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new we(0),this.occlusion=new qe(!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(iA.merge([Au.fog,Au.lights])),Au.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>
@@ -2056,7 +2056,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2056
2056
  #include <begin_vertex>
2057
2057
  #endif /* !USE_LAYER_DISPLACE */
2058
2058
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
2059
- `)}else{e.mergeUniform({penumbraSize:xe.penumbraSize}),e.mergeUniform({frameIndex:xe.frameIndex}),e.mergeUniform({aoMap:xe.aoRenderTarget}),e.mergeUniform({aoEnabled:xe.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new Ie(et)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let s=this.color.flow(e,"c",{slot:"color",context:o}),a=this.roughness.flow(e,"f"),c=this.metalness.flow(e,"f"),d=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,m=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
2059
+ `)}else{e.mergeUniform({penumbraSize:ve.penumbraSize}),e.mergeUniform({frameIndex:ve.frameIndex}),e.mergeUniform({aoMap:ve.aoRenderTarget}),e.mergeUniform({aoEnabled:ve.aoEnabled});let o={gamma:!0};this.color===void 0&&(this.color=new Me(tt)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e);let i=this.occlusion.flow(e,"b",{slot:"occlusion"});this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let a=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),c=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),d=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,p=this.alpha?this.alpha.flow(e,"f"):void 0,f=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,m=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=p!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
2060
2060
  `));let h=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
2061
2061
  // NOTE: gl_FrontFacing alternative using face normal estimation.
2062
2062
  vec3 viewdx = dFdx(vViewPosition);
@@ -2065,7 +2065,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2065
2065
  if (dot(normal, faceNormal) < 0.0) {
2066
2066
  normal *= -1.0;
2067
2067
  }
2068
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(io.dHdxy),e.include(io.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),x=this.bumpMap.flow(e,"v3"),S=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",w="";this.bumpMap.projection.value===4?w=`
2068
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];if(this.bumpMap){e.include(ao.dHdxy),e.include(ao.perturbNormalArb);let g=this.bumpMap.texture.flow(e,"t"),x=this.bumpMap.flow(e,"v3"),S=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",w="";this.bumpMap.projection.value===4?w=`
2069
2069
  vec3 bumpNormal = vec3(0.0);
2070
2070
  {
2071
2071
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2094,7 +2094,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2094
2094
  `,h.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
2095
2095
  ${x.result};
2096
2096
  ${w}
2097
- `)}if(h.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",c.code," float metalnessFactor = "+c.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),x=this.roughnessMap.flow(e,"v3"),S="";this.roughnessMap.projection.value===4?S=`
2097
+ `)}if(h.push(a.code," vec3 diffuseColor = "+a.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",c.code," float metalnessFactor = "+c.result+";"),this.roughnessMap){let g=this.roughnessMap.texture.flow(e,"t"),x=this.roughnessMap.flow(e,"v3"),S="";this.roughnessMap.projection.value===4?S=`
2098
2098
  float roughnessChange = 1.0;
2099
2099
  {
2100
2100
  vec2 uv0 = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2108,28 +2108,28 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2108
2108
 
2109
2109
  roughnessChange = (r0 * weights.z + r1 * weights.x + r2 * weights.y);
2110
2110
  }
2111
- float roughnessFactor = roughnessChange * ${a.result};
2111
+ float roughnessFactor = roughnessChange * ${s.result};
2112
2112
  `:S=`
2113
2113
  vec2 roughnessMapCachedUv = g${this.roughnessMap.uuid.toString().replace(/-/g,"")}_writeUvs;
2114
2114
 
2115
2115
  vec4 vals = texture(${g.result}, roughnessMapCachedUv);
2116
- float roughnessFactor = luminance(vals.rgb) * ${a.result};
2116
+ float roughnessFactor = luminance(vals.rgb) * ${s.result};
2117
2117
  `,h.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
2118
2118
  ${x.result};
2119
2119
 
2120
2120
  const float roughnessScale = 1.0;
2121
2121
 
2122
2122
  ${S}
2123
- `)}else h.push(a.code," float roughnessFactor = "+a.result+";");p&&h.push(p.code,"#ifdef ALPHATEST"," if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),h.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),h.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),m?h.push(m.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+m.result+" ) ), diffuseColor, metalnessFactor );"):h.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),h.push("#include <lights_fragment_begin>"),h.push("#include <lights_fragment_end>"),h.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let y="1.0";this.mask&&(this.mask.analyze(e),y=`luminance(${this.mask.flow(e,"v3").result})`),h.push(`
2123
+ `)}else h.push(s.code," float roughnessFactor = "+s.result+";");p&&h.push(p.code,"#ifdef ALPHATEST"," if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),h.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),h.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),m?h.push(m.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+m.result+" ) ), diffuseColor, metalnessFactor );"):h.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),h.push("#include <lights_fragment_begin>"),h.push("#include <lights_fragment_end>"),h.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let y="1.0";this.mask&&(this.mask.analyze(e),y=`luminance(${this.mask.flow(e,"v3").result})`),h.push(`
2124
2124
  if (outgoingLight != diffuseColor) {
2125
2125
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
2126
- accumAlpha += ( 1.0 - accumAlpha ) * ${d.result} * ${y} * lightAccu;
2127
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${d.result} * ${y}, ${l.result} );
2126
+ accumAlpha += ( 1.0 - accumAlpha ) * ${u.result} * ${y} * lightAccu;
2127
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${u.result} * ${y}, ${l.result} );
2128
2128
 
2129
2129
  outgoingLight *= ao;
2130
2130
  }
2131
- `),u&&h.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),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 wg,UniformsUtils as JO}from"three";var $s=class extends ut{constructor(){super("toon");this.nodeType="Toon";this.color=new Ie(et),this.specular=new Ie(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,this.shadingAlpha=new J(1),this.shadingBlend=new Se(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:xe.frameIndex}),e.mergeUniform({resolution:xe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(JO.merge([wg.fog,wg.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(`
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 Ng,UniformsUtils as aA}from"three";var rs=class extends ut{constructor(){super("toon");this.nodeType="Toon";this.color=new Me(tt),this.specular=new Me(1118481),this.shininess=new J(30),this.previousModelViewMatrix=new St,this.previouseProjectionMatrix=new St,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(aA.merge([Ng.fog,Ng.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>
@@ -2147,7 +2147,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2147
2147
  #include <begin_vertex>
2148
2148
  #endif
2149
2149
  `];o&&i.push(o.code,o.result?"displaced_position = "+o.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
2150
- `)}else{e.mergeUniform({penumbraSize:xe.penumbraSize}),e.mergeUniform({frameIndex:xe.frameIndex}),e.mergeUniform({aoMap:xe.aoRenderTarget}),e.mergeUniform({aoEnabled:xe.aoEnabled}),this.color===void 0&&(this.color=new Ie(et)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),d=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,u=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=l!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
2150
+ `)}else{e.mergeUniform({penumbraSize:ve.penumbraSize}),e.mergeUniform({frameIndex:ve.frameIndex}),e.mergeUniform({aoMap:ve.aoRenderTarget}),e.mergeUniform({aoEnabled:ve.aoEnabled}),this.color===void 0&&(this.color=new Me(tt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let o=this.color.flow(e,"c",{slot:"color"}),i=this.specular.flow(e,"c"),a=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,l=this.alpha?this.alpha.flow(e,"f"):void 0,d=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0;e.requires.transparent=l!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"uniform sampler2D aoMap;","uniform bool aoEnabled;","varying vec3 vWPosition;","#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
2151
2151
  varying vec3 vViewPosition;
2152
2152
  struct ToonMaterial {
2153
2153
  vec3 diffuseColor;
@@ -2176,7 +2176,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2176
2176
  if (dot(normal, faceNormal) < 0.0) {
2177
2177
  normal *= -1.0;
2178
2178
  }
2179
- `," ToonMaterial material;"];if(this.bumpMap){e.include(io.dHdxy),e.include(io.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),h=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=`
2179
+ `," ToonMaterial material;"];if(this.bumpMap){e.include(ao.dHdxy),e.include(ao.perturbNormalArb);let m=this.bumpMap.texture.flow(e,"t"),h=this.bumpMap.flow(e,"v3"),y=this.bumpMapIntensity?this.bumpMapIntensity.flow(e,"f").result:"1.0",g="";this.bumpMap.projection.value===4?g=`
2180
2180
  vec3 bumpNormal = vec3(0.0);
2181
2181
  {
2182
2182
  vec2 uv0 = g${this.bumpMap.uuid.toString().replace(/-/g,"")}_writeUvs0;
@@ -2205,18 +2205,18 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2205
2205
  `,p.push(`// Call the Texture Layer's function once here so that it writes out its procedural UV coordinates
2206
2206
  ${h.result};
2207
2207
  ${g}
2208
- `)}p.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),l&&p.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),p.push("material.diffuseColor = diffuseColor;"),p.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),p.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
2208
+ `)}p.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",a.code," float shininess = max( 0.0001, "+a.result+" );"," float specularStrength = 1.0;"),l&&p.push(l.code,"#ifdef ALPHATEST","if ( "+l.result+" <= ALPHATEST ) discard;","#endif"),p.push("material.diffuseColor = diffuseColor;"),p.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),p.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
2209
2209
  if (outgoingLight != diffuseColor) {
2210
2210
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
2211
- accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * ${f} * lightAccu;
2212
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${f}, ${c.result} );
2211
+ accumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * ${f} * lightAccu;
2212
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${c.result} );
2213
2213
  }
2214
- `),d&&p.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),l?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u&&p.push(`gl_FragColor.a *= ${u.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
2215
- `)}return t}};import{VideoTexture as eA,Texture as tA}from"three";var Xl=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 wd=class extends Xl{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Sd;function _g(n){return typeof n=="string"?n:(Sd||(Sd=new wd),Sd.load(n))}var Kl=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")}},Zl=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 Hi=class extends Kl{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 s of i){let a=this[s];a&&(a.image=this.img,a.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(s=>{o.onloadend=a=>{i=a.target?.result,s(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=_g(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new eA(this.img,void 0,e,e):o=new tA(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 Qt=class extends Hi{};import{Vector2 as so,Vector3 as Gr,Vector4 as Ql}from"three";function wt(n,r){return r.color(n)}function Pg(n,r){switch(n.type){case"fresnel":return nA(n,r);case"gradient":return iA(n);case"depth":return sA(n);case"normal":return aA(n);case"noise":return lA(n,r);case"rainbow":return cA(n);case"toon":return uA(n,r);case"outline":return dA(n,r);case"transmission":return pA(n,r);case"color":return oA(n,r);case"pattern":return fA(n,r)}}function rA(n){return{type:n.type}}function hr(n){let{alpha:r,mode:e,isMask:t}=n;return{...rA(n),alpha:r,mode:e,isMask:t}}function oA(n,r){return{...hr(n),color:wt(n.color,r)}}function nA(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s,isMask:a}=n;return{...hr(n),color:wt(s,r),bias:e,scale:t,intensity:o,factor:i}}function iA(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:a}=n;return{...hr(n),gradientType:r,smooth:e,colors:t.map(c=>new Ql(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new so(...s),morph:new so(...a),angle:i}}function sA(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:a,colors:c,steps:d,smooth:l}=n;return{...hr(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Gr(...s),direction:a?new Gr(...a):new Gr(1,0,0),colors:c.map(u=>u!==void 0?new Ql(u[0],u[1],u[2],u[3]):new Ql(0,0,0,0)),steps:d.slice(0,c.length),smooth:l}}function aA(n){let{cnormal:r}=n;return{...hr(n),cnormal:new Gr(r[0],r[1],r[2])}}function lA(n,r){return{...hr(n),scale:n.scale,move:n.move,fA:new so(...n.fA),fB:new so(...n.fB),size:new Gr(...n.size),distortion:new so(...n.distortion),colorA:wt(n.colorA,r),colorB:wt(n.colorB,r),colorC:wt(n.colorC,r),colorD:wt(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 cA(n){return{...hr(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Gr(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Gr(...n.offset)}}function uA(n,r){return{...hr(n),positioning:n.positioning,colors:n.colors.map(e=>new Ql(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Gr(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:wt(n.shadowColor,r),offset:new Gr(...n.offset)}}function dA(n,r){return{...hr(n),outlineColor:wt(n.outlineColor,r),contourColor:wt(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Gr(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function pA(n,r){return{...hr(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function fA(n,r){return{...hr(n),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new so(...n.offset),colorA:wt(n.colorA,r),colorB:wt(n.colorB,r),frequency:new so(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new so(...n.vertical),horizontal:new so(...n.horizontal),sides:n.sides}}var Ro=class extends ot{};import{Vector4 as mA}from"three";var _d={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Pd={depth:["colors"]};function hA(n,r,e){if(r==="isMask")return!0;let t=_d[n.type],o=Pd[n.type];if(o!==void 0){let i=n.color;if(o.includes(r)){let s=i[r]?.value?.length;if(s!==void 0&&s!==e.length)return!0}}return t!==void 0?t.includes(r):!1}function Td(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 s=i.image,a=r.image(s),c=t;c.image instanceof Qt||c.image.deref(),c.image=a}if("video"in i){let s=i.video,a=r.video(s),c=t;c.image instanceof Qt||c.image.deref(),c.image=a}if("wrapping"in i){let s=t;s.wrap=i.wrapping}if("repeat"in i||"offset"in i){let s="mat",a=e.uniforms[`f${e.id}_${s}`];"repeat"in i&&(a.repeat=i.repeat),"offset"in i&&(a.offset=i.offset),a.updateMatrix()}return o}function Tg(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||s===void 0)continue;if(Od(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let a=e.uniforms[`f${e.id}_${i}`];if(!!a&&!(a instanceof Do))switch(o=o||hA(e,i,s),a.constructor){case Ie:if(typeof s=="string"){let c=r.getColor(s);c&&(a.value=c);break}else{let c=s;a.value instanceof Ro?a.value=new ot(c.r,c.g,c.b,c.a):a.setRGBA(c);break}case Gt:if(typeof s=="string"){let c=r.getColor(s);c&&(a.value=c);break}else{let c=s;a.value instanceof Ro?a.value=new ot(c.r,c.g,c.b,c.a):a.value.setRGBA(c.r,c.g,c.b,c.a);break}case Ue:{let c=s;a.value.setX(c[0]),a.value.setY(c[1]);break}case bt:{let c=s;a.value.setX(c[0]),a.value.setY(c[1]),a.value.setZ(c[2]);break}case It:{Td(s,r,e);break}case mr:{a.value=s.map(c=>new mA(...c));break}default:{a.value=s;break}}}return o}var zr=class{constructor(r,e,t,o){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let i in o)this.uniforms[`f${this.id}_${i}`]=o[i];for(let i in t)Od(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return $t.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),s=new on(i,t.texture.wrapping),a=new $l(i),c=new Yl(t.texture.repeat,t.texture.offset),d=new J(t.crop?1:0),l=new Se(t.projection??0),u=new Se(["x","y","z"].indexOf(t.axis)??0),p=new Se(t.side??0),f=new Ue(t.size?new yr(t.size[0],t.size[1]):new yr(100,100)),m=new J(t.blending??0),h=new J(t.alpha??1),y=new Se(t.mode??0),g=new qe(t.isMask??!1),x=new Bo(s,a,d,l,u,p,f,m,c,h,y,g),S=new Ce(x.calpha,"f");return new je(r,e,t,{texture:s,textureSize:a,crop:d,projection:l,axis:u,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},x,y,S,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new on(i,t.texture.wrapping),a=new J(t.alpha??1),c=new Se(t.mode??0),d=new qe(t.isMask??!1),l=new Ri(s,a,c,d),u=new Ce(l.calpha,"f");return new je(r,e,t,{texture:s,alpha:a,mode:c,isMask:d},l,c,u,d)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new bt(new Vr(...t.offset)),s=new J(t.scale??10),a=new J(t.intensity??8),c=new J(t.movement??1),d=new Se(t.noiseType??0),l=new Se(t.voronoiStyle??0),u=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 Se(t.quality??1),y=new Ui(a,c,i,l,u,p,f,m,h,s,d);return new Ys(r,e,t,{offset:i,scale:s,intensity:a,movement:c,noiseType:d,voronoiStyle:l,smoothness:u,seed:p,highCut:f,lowCut:m,quality:h},y)}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):Tg(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Td(o.props,t.shared,this):!0;return!1}dispose(){if(yA(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof Qt||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 zr{constructor(e,t,o,i,s,a,c,d){super(e,t,o,i);this.params=i;this.color=s;this.mode=a;this.alpha=c;this.isMask=d}},Ys=class extends zr{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},$t=class extends zr{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,a=new J(o.alpha),c=new Se(o.mode),d=new J(o.bumpMapIntensity),l=new J(o.alphaOverride),u;if(!o.visible)s=new an,u={};else if(o.category==="lambert"){s=new Hs;let p=new Ie(i.color(o.emissive)??0),f=new qe(o.occlusion??!0);u={emissive:p,occlusion:f},s.emissive=p,s.occlusion=f}else if(o.category==="toon"){s=new $s;let p=new J(o.shininess??30),f=new Ie(i.color(o.specular)??1118481);u={shininess:p,specular:f},s.shininess=p,s.specular=f}else if(o.category==="physical"){s=new qs;let p=new J(o.roughness??.3),f=new J(o.metalness??0),m=new J(o.reflectivity??.5),h=new qe(o.occlusion??!0);u={roughness:p,metalness:f,reflectivity:m,occlusion:h},s.roughness=p,s.metalness=f,s.reflectivity=m,s.occlusion=h}else{s=new Ws;let p=new J(o.shininess??30),f=new Ie(o.specular!==void 0?i.color(o.specular)??1118481:1118481),m=new qe(o.occlusion??!0);u={shininess:p,specular:f,occlusion:m},s.shininess=p,s.specular=f,s.occlusion=m}return s.alpha=new J(1),s.shadingAlpha=a,s.shadingBlend=c,s.bumpMapIntensity=d,s.alphaOverride=l,u.alpha=s.shadingAlpha,u.mode=s.shadingBlend,u.bumpMapIntensity=s.bumpMapIntensity,u.alphaOverride=s.alphaOverride,new $t(e,t,o,s,u)}get category(){return this.node.category}};function yA(n){let r=n instanceof zr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function Jt(n){return{alpha:new J(n.alpha??1),mode:new Se(n.mode??0),isMask:new qe(n.isMask??!1)}}function gA(n,r,e,t){switch(n.type){case"color":{let o=new Ie(t.color??et),i=Jt(t),s=new nn(o,i.alpha),a=new Ce(s.calpha,"f");return new je(r,e,n,{color:o,...i},s,i.mode,a,i.isMask)}case"fresnel":{let o=new Ie(t.color??16777215),i=new J(t.bias??.1),s=new J(t.scale??1),a=new J(t.intensity??2),c=new J(t.factor??1),d=Jt(t),l=new ks(o,i,s,a,c,d.alpha,d.mode,d.isMask),u=new Ce(l.calpha,"f");return new je(r,e,n,{color:o,bias:i,scale:s,intensity:a,factor:c,...d},l,d.mode,u,d.isMask)}case"rainbow":{let o=new J(t.filmThickness??30),i=new J(t.movement??0),s=new bt(t.wavelengths??new Vr(0,0,0)),a=new J(t.noiseStrength??0),c=new J(t.noiseScale??1),d=new bt(t.offset??new Vr(0,0,0)),l=Jt(t),u=new ji(o,i,s,a,c,d,l.alpha,l.isMask),p=new Ce(u.calpha,"f");return new je(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:a,noiseScale:c,offset:d,...l},u,l.mode,p,l.isMask)}case"transmission":{let o=new J(t.thickness??10),i=new J(t.ior??1.5),s=new J(t.roughness??.5),a=xe.transmissionSize,c=xe.transmissionRenderTarget,d=xe.transmissionRenderTargetDepth,l=window.innerWidth,u=window.innerHeight,p=l>=u?new Ue(u/l,1):new Ue(1,l/u),f=Jt(t),m=new ki(o,i,s,a,c,d,p,f.alpha),h=new Ce(m.calpha,"f");return new je(r,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:p,...f},m,f.mode,h,f.isMask)}case"toon":{let o=new Se(t.positioning??0),i;t.colors?i=new mr(t.colors.length,t.colors):(i=new mr(10,new Wi(0,0,0,1)),i.value[1]=new Wi(1,1,1,1));let s;t.steps?s=new fr(t.steps.length,t.steps):(s=new fr(10,1),s.value[0]=0);let a=new bt(t.source??new Vr(0,0,0)),c=new qe(t.isWorldSpace??!0),d=new J(t.noiseStrength??0),l=new J(t.noiseScale??1),u=new Gt(t.shadowColor),p=new bt(t.offset??new Vr(0,0,0)),f=Jt(t),m=new Fi(o,i,s,a,c,d,l,u,p,f.alpha),h=new Ce(m.calpha,"f");return new je(r,e,n,{positioning:o,colors:i,steps:s,source:a,isWorldSpace:c,noiseStrength:d,noiseScale:l,shadowColor:u,offset:p,...f},m,f.mode,h,f.isMask)}case"outline":{let o=new Ie(t.outlineColor??16777215),i=new Ie(t.contourColor??16777215),s=new J(t.outlineWidth??.1),a=new J(t.contourWidth??.1),c=new J(t.outlineThreshold??.1),d=new J(t.contourThreshold??.1),l=new J(t.outlineSmoothing??.1),u=new J(t.contourFrequency??.1),p=new bt(t.contourDirection??new Vr(0,1,0)),f=new qe(t.positionalLines??!1),m=new qe(t.compensation??!0),h=xe.normalRenderTarget,y=xe.normalRenderTargetDepth,g=xe.pixelRatioNode,x=xe.resolution,S=Jt(t),w=new Vi(o,i,s,a,c,d,l,u,p,f,m,x,h,y,g,S.alpha),b=new Ce(w.calpha,"f");return new je(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:a,outlineThreshold:c,contourThreshold:d,outlineSmoothing:l,contourFrequency:u,contourDirection:p,positionalLines:f,compensation:m,...S},w,S.mode,b,S.isMask)}case"depth":{let o=new Se(t.gradientType??0),i=new qe(t.smooth??!1),s=new J(t.near??50),a=new J(t.far??200),c=new J(t.isVector??1),d=new J(t.isWorldSpace??0),l=new bt(t.origin??new Vr),u=new bt(t.direction??new Vr),p;t.colors?p=new mr(t.colors.length,t.colors):(p=new mr(2,new Wi(0,0,0,1)),p.value[1]=new Wi(1,1,1,1));let f;t.steps?f=new fr(t.steps.length,t.steps):(f=new fr(2,1),f.value[0]=0);let m=Jt(t),h=new Di(o,i,s,a,c,d,l,u,p,f,m.alpha,m.isMask),y=new Ce(h.calpha,"f");return new je(r,e,n,{gradientType:o,smooth:i,near:s,far:a,isVector:c,isWorldSpace:d,origin:l,direction:u,colors:p,steps:f,...m},h,m.mode,y,m.isMask)}case"noise":{let o=new J(t.scale??1),i=new bt(t.size??new Vr(100,100,100)),s=new J(t.move??1),a=new Ue(t.fA??new yr(1.7,9.2)),c=new Ue(t.fB??new yr(8.3,2.8)),d=new Ue(t.distortion??new yr(1,1)),l=new Gt(t.colorA),u=new Gt(t.colorB),p=new Gt(t.colorC),f=new Gt(t.colorD),m=new Se(t.noiseType??0),h=new Se(t.voronoiStyle??0),y=new J(t.highCut??1),g=new J(t.lowCut??0),x=new J(t.smoothness??.5),S=new J(t.seed??.5),w=new Se(t.quality??1),b=Jt(t),_=new Gi(o,i,s,a,c,d,l,u,p,f,b.alpha,m,b.isMask,h,y,g,x,S,w),P=new Ce(_.calpha,"f");return new je(r,e,n,{scale:o,size:i,move:s,fA:a,fB:c,distortion:d,colorA:l,colorB:u,colorC:p,colorD:f,noiseType:m,...b,voronoiStyle:h,highCut:y,lowCut:g,smoothness:x,seed:S,quality:w},_,b.mode,P,b.isMask)}case"normal":{let o=new bt(t.cnormal??new Vr(1,1,1)),i=Jt(t),s=new Mi(o,i.alpha),a=new Ce(s.calpha,"f");return new je(r,e,n,{cnormal:o,...i},s,i.mode,a,i.isMask)}case"gradient":{let o=new Se(t.gradientType??0),i=new qe(t.smooth??!1),s;t.colors?s=new mr(t.colors.length,t.colors):(s=new mr(10,new Wi(0,0,0,1)),s.value[1]=new Wi(1,1,1,1));let a;t.steps?a=new fr(t.steps.length,t.steps):(a=new fr(10,1),a.value[0]=0);let c=new Ue(t.offset??new yr(0,0)),d=new Ue(t.morph??new yr(0,0)),l=new J(t.angle??0),u=Jt(t),p=new Bi(o,i,s,a,c,d,l,u.alpha,u.isMask),f=new Ce(p.calpha,"f");return new je(r,e,n,{gradientType:o,smooth:i,colors:s,steps:a,offset:c,morph:d,angle:l,...u},p,u.mode,f,u.isMask)}case"pattern":{let o=new Se(t.style??0),i=new Se(t.projection??0),s=new Se(["x","y","z"].indexOf(t.axis)??0),a=new J(t.blending??0),c=new Ue(t.offset??new yr(0,0)),d=new Gt(t.colorA),l=new Gt(t.colorB),u=new Ue(t.frequency??new yr(10,10)),p=new J(t.size??.5),f=new J(t.variation??0),m=new J(t.smoothness??.5),h=new J(t.zigzag??0),y=new J(t.rotation??0),g=new Ue(t.vertical??new yr(0,1)),x=new Ue(t.horizontal??new yr(0,1)),S=new Se(t.sides??6),w=Jt(t),b=new zi(o,i,s,a,c,d,l,u,p,f,m,h,y,g,x,S,w.alpha,w.isMask),_=new Ce(b.calpha,"f");return new je(r,e,n,{style:o,projection:i,axis:s,blending:a,offset:c,colorA:d,colorB:l,frequency:u,size:p,variation:f,smoothness:m,zigzag:h,rotation:y,vertical:g,horizontal:x,sides:S,...w},b,w.mode,_,w.isMask)}default:{let o=new Ie(1,0,0,1),i=Jt(t),s=new nn(o,i.alpha),a=new Ce(s.calpha,"f");return new je(r,e,n,{color:o,...i},s,i.mode,a,i.isMask)}}}function xA(n,r,e,t){let o=Pg(e,t);return gA(e,n,r,o)}function Od(n,r,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let t=r.uniforms[`f${r.id}_intensity`];return t?(t.value=e.intensity*(e.visible?1:0),t):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let t=r.uniforms[`f${r.id}_alpha`];if(!t)return;if(t.value=e.alpha*(e.visible?1:0),e.type==="outline"&&n==="visible"){let o=r.uniforms[`f${r.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return t}}function Og(n,r){let e=0,t=n.layers.find(o=>o.data.type==="light");if(t&&t.data.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(i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let s of o.data.colors)if(s[3]<1){i=s[3];break}}else if(i===1&&o.data.type==="noise"){let s=r.color(o.data.colorA).a,a=r.color(o.data.colorB).a,c=r.color(o.data.colorC).a,d=r.color(o.data.colorD).a,l=Math.min(s,Math.min(a,Math.min(c,d)));l<1&&(i=l)}e+=(1-e)*i}}return e<1}var zt=class extends vA{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}},Jl=class extends zt{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()}},ln=class extends zt{constructor(e,t){super();this.data=e;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 s=this.flavors[i];return s===void 0&&(s=new Jl(e,t,o,this),this.flavors[i]=s,s.flatShading=e,s.side=t,s.updateAfterBuild()),s}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??yt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>zr.create(this.layerIdGen++,i.id,i.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Og(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof $t),this.lightLayer===void 0&&(this.lightLayer=new $t(0,"",{...Ct.defaultData("light","phong"),visible:!1},new an,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(s=>s instanceof $t);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 s=0;s<this.layers.length;++s){let a=this.layers[s];a instanceof je&&a.color instanceof Bo&&(a.uuid===o&&(e.node.bumpMap=a.color),a.uuid===i&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=Og(t,o.shared),e.path[0]==="layers"){this.data=t;let i=o.shared,s=e.path[1];if(s===void 0){if(this.layers.reverse(),e.type===4){let a=zr.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,a),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 a=this.layers.findIndex(d=>d.uuid===e.id),c=this.layers[a];this.layers.splice(a,1),this.layers.splice(e.localIndex,0,c),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(c=>c.uuid===s);if(a){let c=t.layers.data(s);if(a.updateByOp({...e,path:e.path.slice(2)},c,o)){let l=zr.create(this.layerIdGen++,s,c,i);this.layers.splice(this.layers.findIndex(u=>u.uuid===s),1,l),this.onUpdate()}}}}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 $t&&(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 $t?i.node.mask=new dt(t.color,t.alpha,dt.MUL):i instanceof je&&(i.isMask.value||(i.color.mask=new dt(t.color,t.alpha,dt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof je),t=this.layers.findIndex(o=>o instanceof $t);if(e!==-1&&e<t){let o=this.layers[e].color;for(let i=e+1;i<t;++i){let s=this.layers[i];if(s instanceof je){if(s.isMask.value)continue;o=new Ii(o,s.color,s.alpha,s.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ce("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof $t);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 Ii(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 Ys);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new dt(t,e[o].position,dt.ADD),t=new dt(t,new J(.5).setReadonly(!0),dt.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,s,a)=>Math.min(Math.max(i,s),a);for(let i of this.layers)if(i.type==="displace"){let s=o(i.uniforms[`f${i.id}_intensity`].value,e,t);i.uniforms[`f${i.id}_intensity`].value=s}}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=(_d[t.type]??[]).map(d=>t[d]),i=(Pd[t.type]??[]).map(d=>t[d]?.length??0),s=[...o,...i],a="isMask"in t&&t.isMask,c=`"${t.type}-${t.visible}-${a}"`;s.length?e+=`[${c}, "${s.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 ql;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 on&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(zt.prototype,{properties:{get:function(){return this.fragment.properties}}});var cn=class extends ln{};var Ig=ss(Ag());var Cg=new Map;function Ng(n){if(typeof n=="string")return n;let r=Cg.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},Cg.set(n,r)),r.url}var un=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:Ng(r),format:"wav"},this.sound=new Ig.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 bA,Vector2 as dn,Path as Mg,Shape as SA,ShapeUtils as wA,Color as _A}from"three";var tc=class{constructor(){this.type="ShapePath";this.color=new _A;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Mg,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,s){return this.currentPath?.bezierCurveTo(r,e,t,o,i,s),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,_=x.x,P=h.y,v=y.y,N=g.y,T=x.y,C=(_-b)*(P-N)-(T-N)*(S-b),O=(w-S)*(P-N)-(v-P)*(S-b),A=(T-N)*(w-S)-(_-b)*(v-P),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=+(P+t.t*(v-P)).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=+(P+M*(v-P)).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,_=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(_<-Number.EPSILON){t.loc=e.LEFT;return}if(_>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 P;x!==0?P=w/x:P=b/S,t.loc=e.BETWEEN,t.t=P}function s(h,y){let g=[],x=[];for(let S=1;S<h.length;S++){let w=h[S-1],b=h[S];for(let _=1;_<y.length;_++){let P=y[_-1],v=y[_],N=o(w,b,P,v);N!==null&&g.find(T=>T.t<=N.t+Number.EPSILON&&T.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),x.push(new dn(N.x,N.y)))}}return x}function a(h,y,g){let x=new dn;y.getCenter(x);let S=[];return g.forEach(w=>{w.boundingBox.containsPoint(x)&&s(h,w.points).forEach(_=>{S.push({identifier:w.identifier,isCW:w.isCW,point:_})})}),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 dn;h.boundingBox.getCenter(w);let b=[new dn(g,w.y),new dn(x,w.y)],_=a(b,h.boundingBox,y);_.sort((O,A)=>O.point.x-A.point.x);let P=[],v=[];_.forEach(O=>{O.identifier===h.identifier?P.push(O):v.push(O)});let N=P[0].point.x,T=[],C=0;for(;C<v.length&&v[C].point.x<N;)T.length>0&&T[T.length-1]===v[C].identifier?T.pop():T.push(v[C].identifier),C++;if(T.push(h.identifier),S==="evenodd"){let O=T.length%2===0,A=T[T.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<T.length;L++){let X=T[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 d=0,l=999999999,u=-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 _=y[b];_.y>g&&(g=_.y),_.y<x&&(x=_.y),_.x>S&&(S=_.x),_.x<w&&(w=_.x)}u<=S&&(u=S+1),l>=w&&(l=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:wA.isClockWise(y),identifier:d++,boundingBox:new bA(new dn(w,x),new dn(S,g))})});let f=p.map(h=>c(h,p,l,u,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new SA;g.curves=h.curves,f.filter(S=>S?.isHole&&S.for===h.identifier).forEach(S=>{if(S){let w=p[S.identifier],b=new Mg;b.curves=w.curves,g.holes.push(b)}}),m.push(g)}}),m}};var Lg,Ad=new Promise(n=>{Lg=n}),Eg=!1;var rc;function Dg(){if(Eg)return;if(rc)return rc;async function n(){let e=await import("./opentype.js");Lg(e),Eg=!0}return rc=n(),rc}var Xs=class{async load(r,e,t=()=>{}){let{load:o}=await Ad;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await Ad;try{let o=e(r),i=new t,s=a=>o.charToGlyphIndex(a.char);return i.registerModifier("glyphIndex",null,s),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function PA(n){return await(await fetch(n)).arrayBuffer()}var TA=new Xs;async function Cd(n){let r,e,t=!1;if(n.url?(r=await PA(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 TA.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}import{CubicBezierCurve as OA,LineCurve as AA,QuadraticBezierCurve as CA}from"three";function NA(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var oc=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Cd(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=Cd(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,s=[],a=0,c=t.length===i.length;for(let d=0;d<t.length;d++){let l=t[d].index,u=String.fromCharCode(t[d].unicode),p=i[a];if(NA(l,p)||c)s.push({char:u,index:l,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),a++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)a++,m=e.charAt(a),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===l&&(g=!0),a>e.length&&(g=!0);s.push({char:u,index:l,replacements:h,replacementChars:Array.from(f)}),a++}}return s}generateShapes(r,e){if(!this._isLoaded)return;let t=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,s=r.map(x=>this.getTextWidth(x,e)),a=e.width,c=this.getCharWidth(`
2216
- `,e),d=e.horizontalAlign===1?c:0,l=this.computeSpaceWidthForLine(r,0,e),u=this.getLineInitialOffsetX(s[0],a,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(P){console.warn(P)}u=this.getLineInitialOffsetX(s[x],a,e.horizontalAlign,S,c);let _=[];try{_=this.reverseLigaturesTable(t,S,b)}catch(P){console.warn(P)}l=this.computeSpaceWidthForLine(r,x,e);for(let P=0;P<b.length;P++){let v=b[P],N=v.index===0?`
2217
- `:v.unicode?String.fromCharCode(v.unicode):void 0,T=_[P],C=0,O=0;P===0&&e.horizontalAlign===2&&v.leftSideBearing!==void 0&&(O=-v.leftSideBearing*o),y&&(C=t.getKerningValue(v,y)*o),u+=O+C;let A=0;if(N===`
2218
- `)A=d;else if(N===" ")A=l;else{let M=this.createPath(v,o,u,p,e);M&&(A=M.offsetX-(C+O),f.push(M.path))}if(T.replacements.length===1)h[x].push([u,p]),m[x].push(A);else{let M=T.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=u;for(let Z=0;Z<X.length;Z++){let z=A*X[Z];h[x].push([R,p]),m[x].push(z),R+=z}}u+=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:s,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 s=e*r,a=Math.abs(this.ascender-this.descender)*o,c=r-a,d=-this.ascender*o-c/2;return i===3?-(t-s-d):i===2?-(t*.5-s*.5-d):d}createPath(r,e,t,o,i){let s=r.getPath(t,-o,i.fontSize,{kerning:!1,letterSpacing:i.letterSpacing});if(!s){console.error('THREE.Font: character "'+r+'" does not exists in font family '+this.familyName+".");return}let a=new tc,c=(r.advanceWidth??1)*e;if(r)for(let d of s.commands){let l=a.currentPath?.currentPoint;if(!(l&&d.type!=="Z"&&l.x===d.x&&-l.y===d.y))switch(d.type){case"M":a.moveTo(d.x,-d.y);break;case"L":a.lineTo(d.x,-d.y);break;case"Q":a.quadraticCurveTo(d.x1,-d.y1,d.x,-d.y);break;case"C":a.bezierCurveTo(d.x1,-d.y1,d.x2,-d.y2,d.x,-d.y);break}}return a.subPaths.forEach(d=>{let l=IA(d.curves);l!==void 0&&d.currentPoint.distanceTo(l)>0&&d.lineTo(l.x,l.y)}),{offsetX:c+i.fontSize*i.letterSpacing,path:a}}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 s=this.countSpaces(i.trimEnd());if(t.horizontalAlign===4&&e<r.length-1&&s){let a=t.width,c=this.getTextWidth(i,t);return(a-(c-s*o))/s}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function IA(n){if(n.length){let r=n[0];if(r instanceof AA)return r.v1;if(r instanceof OA||r instanceof CA)return r.v0}}var Nd=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){let t=this.objects.get(r);return t===void 0?(t=this.createObject(r,e),this.objects.set(r,t)):t.isShared=!0,t}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()}},Ks=class extends Nd{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=en(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var Bg={markNeedsUpdateRendererDirty:()=>{}};var Id=class extends Zl{constructor(e){super();this.shared=e}create(e){return new Hi(e,this.shared)}},pn=class{constructor(r,e={}){this.geometryCache=new Ks(!0);this.geometryCache2=new Ks(!1);this.imageHolderCache=new Id(this);this.thisContext={scene:Bg,shared:this};this.deletedMaterial=new cn(yt.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new Qt(ri.emptyImage,this);this.deletedVideo=new Qt(Kn.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};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.data);this.reset(r)}setRequestRender(r){this._requestRender=r}reset(r){for(let[e,t]of Object.entries(r.images))this.addImage(e,t);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,new cn(t,this.thisContext));for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t.data);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t)}addMaterial(r,e){e.uuid=r,this.materials[r]?(this.materials[r].reset(e.data,this.thisContext),e.dispose()):this.materials[r]=e}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 ln(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 Qt(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 Qt(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 Ro(e.r,e.g,e.b,e.a):this.colors[r]=new Ro(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 ot(0,0,0,0))}else return"a"in r?new ot(r.r,r.g,r.b,r.a):new ot(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 un)return e;{let t=new un({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof un&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new oc(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 un&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},Rg=new pn(pl.emptyData());var jt=class extends vt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Im(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,s]of Object.entries(e.props)){let a=o.shared.material(s);this.material[Number(i)]=a}else if(_t(e.path,["material"])&&this.material instanceof zt)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(ht.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 s=t.materials[i];typeof s!="string"&&this.material[i].updateByOp(ht.drop(e,2),s,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&&ca(this.material).forEach(e=>{e instanceof zt&&(e instanceof cn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as MA,Matrix4 as Md,Vector3 as Fg,Vector4 as Ed}from"three";var Gg=new Fg,Vg=new Ed,zg=new Ed,EA=new Fg,jg=new Md,Qe=class extends jt{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 Md().fromArray(t.bindMatrix),this.bindMatrixInverse=new Md)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof MA&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof pn){let e=this.geometryCreateDeleyed,t=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=t.get(this.dataPatched.geometry,e)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return xs.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return xs.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(ht.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=en(l,t,this.data.flatShading)}let s,a,c;i.scaleBaked?[s,a,c]=i.scaleBaked:{width:s,height:a,depth:c}=i;let d=this.localGeometry.userData;d.sxPrev!==void 0&&Rs(this.localGeometry.attributes,s/d.sxPrev,a/d.syPrev,c/d.szPrev),d.sxPrev=s,d.syPrev=a,d.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=en(i,t,this.data.flatShading)}}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&&us(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof Xe&&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 Ed,o=this.geometry.attributes.skinWeight;for(let i=0,s=o.count;i<s;i++){t.fromBufferAttribute(o,i);let a=1/t.manhattanLength();a!==1/0?t.multiplyScalar(a):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;Vg.fromBufferAttribute(i.attributes.skinIndex,e),zg.fromBufferAttribute(i.attributes.skinWeight,e),Gg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let a=zg.getComponent(s);if(a!==0){let c=Vg.getComponent(s);jg.multiplyMatrices(o.bones[c].matrixWorld,o.boneInverses[c]),t.addScaledVector(EA.copy(Gg).applyMatrix4(jg),a)}}return t.applyMatrix4(this.bindMatrixInverse)}};function DA(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 s=0;s<t.length;s+=3){let a=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=new Dd(o[s],o[s+1],o[s+2]);r.has(a)?r.get(a)?.normals.push(c):r.set(a,{normals:[c],result:new Dd})}r.forEach((s,a)=>{for(let c of s.normals)s.result.add(c);s.result.divideScalar(s.normals.length)});for(let s=0;s<t.length;s+=3){let a=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=r.get(a)?.result;c&&(i[s]=c.x,i[s+1]=c.y,i[s+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new kg(i,3))}function BA(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 Dd;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 kg(t,3))}function qi(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof zt)||n.material.getLayersOfType("outline").length===0)return;n instanceof Qe&&n.is2DAndNoDepth?BA(n):DA(n)}function $i(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=[Ld.seededRandom(o),Ld.seededRandom(o+1e4),Ld.seededRandom(o+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];n.geometry.setAttribute("randomColor",new LA(t,3))}var zA;Si.then(n=>{zA=n});var jr=new RA,Zs=new VA;function Hg(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var fn=class extends Qe{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new GA;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:s}=Xe.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=s,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,qi(this),$i(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){Xe.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Xe.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Xe.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Xe.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,vt.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 Ug,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;jr.setFromBufferAttribute(t),jr.getCenter(o),e.boundingSphere.radius=o.distanceTo(jr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),jr.getSize(Zs),this.hasNonUniformScale&&Zs.divide(this.scale);let i={width:Zs.x,height:Zs.y,depth:Zs.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;jr.min.set(e[0],e[2],e[4]),jr.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(jr.min.applyMatrix4(this.shearScaleInv),jr.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Ug);let o=t.boundingSphere.center;jr.getCenter(o),t.boundingSphere.radius=o.distanceTo(jr.max)}freeSubdivPointer(){this.subdivPointer&&(Xe.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 jA,Vector3 as hn}from"three";var Wg=-1,FA=1,qg={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},$g={polygon_center:0,edge:1,vertex:2},Qs=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,ge=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-Wg)*(e-t)/(FA-Wg)+t};function Yg(n){let r=[],e={};for(var t=0,o=n.length;t<o;t++){var i=JSON.stringify(n[t].pos.map(s=>Math.round(s*1e4)/1e4));e[i]||(r.push(n[t]),e[i]=!0)}return r}var kA=new hn,nc=new hn,UA=new hn,HA=new hn;function Yi(n,r){let e=UA.fromArray(n),t=HA.fromArray(r);nc.copy(t).sub(e);let o=nc.length();return nc.normalize().multiplyScalar(o*.5),kA.copy(e).add(nc).toArray()}var er=new jA,ic=new hn,sc=new hn,mn=new hn;function Xg(n){let r=[];for(let e=0;e<=n.index.count;e++)if(ic.fromArray(n.index.array,e*3),er.setFromAttributeAndIndices(n.attributes.position,ic.x,ic.y,ic.z),er.getNormal(sc),er.getMidpoint(mn),!(isNaN(mn.x)||isNaN(mn.y)||isNaN(mn.z))){let{a:t,b:o,c:i}=er,s=t.toArray(),a=o.toArray(),c=i.toArray(),d=t.distanceTo(o),l=o.distanceTo(i),u=i.distanceTo(t),p=Yi(s,a),f=Yi(a,c),m=Yi(c,s),h=[d,l,u],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,x=[],S=er.getMidpoint(mn).toArray();y===d&&!g&&(x=[f,m,m],S=p),y===l&&!g&&(x=[p,m,m],S=f),y===u&&!g&&(x=[p,f,f],S=m),g&&(x=[p,f,m]),r.push({vertices:[s,a,c],faceCenters:x,midpoint:S,norm:er.getNormal(sc).toArray()})}return r}function Kg(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){er.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),er.getNormal(sc),er.getMidpoint(mn);let o=er.a.toArray(),i=er.b.toArray(),s=er.c.toArray();r.push({vertices:[o,i,s],faceCenters:[Yi(o,i),Yi(i,s),Yi(s,o)],midpoint:mn.toArray(),norm:sc.toArray()})}return r}var WA=4,qA=.5,Bd=n=>.5*(1-Math.cos(n*Math.PI)),Rd=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),s=Math.floor(t),a=r-o,c=e-i,d=t-s,l,u,p=0,f=.5,m,h,y;for(let g=0;g<WA;g++){let x=o+(i<<4)+(s<<8);l=Bd(a),u=Bd(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+=u*(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+=u*(y-h),m+=Bd(d)*(h-m),p+=m*f,f*=qA,o<<=1,a*=2,i<<=1,c*=2,s<<=1,d*=2,a>=1&&(o++,a--),c>=1&&(i++,c--),d>=1&&(s++,d--)}return p}noiseSeed(r){let e=(()=>{let s,a;return{setSeed(c){a=s=(c??Math.random()*4294967296)>>>0},getSeed(){return s},rand(){return a=(1664525*a+1013904223)%4294967296,a/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Zg=Rd;import{Vector3 as $A,Matrix4 as YA,Ray as XA}from"three";var Qg=new $A,Jg=new YA,e0=new XA;function t0(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var Xi=class extends Qe{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)&&(Jg.copy(o).invert(),e0.copy(e.ray).applyMatrix4(Jg),e0.intersectBox(this.singleBBox,Qg))){let i=Qg.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var Mt=1e-4,Fr,i0,s0,a0,o0=new Yt,n0=new Yt;Si.then(n=>{Fr=n,i0=[Fr.get_face_center,Fr.get_edge_midpoint,Fr.get_vertex_position],s0=[Fr.get_face_normal,Fr.get_edge_normal,Fr.get_vertex_normal],a0=[Fr.face_count,Fr.edge_count,Fr.vertex_count]});var ZA=new gn,QA=new gn,Go=new Yt,yn=new Yt,Js=new Yt,Vd=new Yt,JA=new Yt,eC=new Yt;var ao=new Zg,Zi=class extends ni(KA){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 ro&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof ro&&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,s=this.children.length;i<s;++i)this.remove(this.children[0]);let o=this.children;if(o.length===t)return;if(o.length<t)for(let i=0,s=t-o.length;i<s;++i){let a=new ro(this.object);a.expand(),this.add(a)}else for(let i=0,s=o.length-t;i<s;++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 s=new ro(this.object);s.expand(),this.add(s)}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*r0.DEG2RAD,i=t.end*r0.DEG2RAD,s=o-i,a=new Gd(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Yt(0,0,1);break;case"y":c=new Yt(0,1,0);break;default:case"x":c=new Yt(1,0,0);break}let d=e.randomnessObject??Ar.defaultData([1,1,1]).randomnessObject,l=d.noiseType==="perlin";ao.noiseSeed(d.seed);let u=yl((0,Ki.default)(d.seed)),p=Qs(d.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(d.freqScale/10)+d.movement,y=l?ao.noise(h):u(h,h),g=f+1;m.scale.x=t.scale[0]+p(g,ge(y,d.scale[0]))||Mt,m.scale.y=t.scale[1]+p(g,ge(y,d.scale[1]))||Mt,m.scale.z=t.scale[2]+p(g,ge(y,d.scale[2]))||Mt,m.position.setScalar(0);let x=s/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,ge(y,d.position[0])),m.position.y+=t.position[1]+p(g,ge(y,d.position[1])),m.position.z+=t.position[2]+p(g,ge(y,d.position[2]));let S=p(g,ge(y,d.rotation[0])),w=p(g,ge(y,d.rotation[1])),b=p(g,ge(y,d.rotation[2]));t.alignment===!0?(m.rotation.x+=a.x+S,m.rotation.y+=a.y+w,m.rotation.z+=a.z+b):m.rotation.set(a.x+S,a.y+w,a.z+b)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Gd(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Ar.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";ao.noiseSeed(i.seed);let a=yl((0,Ki.default)(i.seed)),c=Qs(i.strength,this.parameters.randomness);for(let[d,l]of this.children.entries()){let u=d*(i.freqScale/10)+i.movement,p=s?ao.noise(u):a(u,u),f=d+1,m=c(f,ge(p,i.rotation[0])),h=c(f,ge(p,i.rotation[1])),y=c(f,ge(p,i.rotation[2]));l.scale.x=1+(t.scale[0]-1)*d+c(f,ge(p,i.scale[0]))||Mt,l.scale.y=1+(t.scale[1]-1)*d+c(f,ge(p,i.scale[1]))||Mt,l.scale.z=1+(t.scale[2]-1)*d+c(f,ge(p,i.scale[2]))||Mt,l.rotation.x=o.x*d+m,l.rotation.y=o.y*d+h,l.rotation.z=o.z*d+y,l.position.x=t.position[0]*d+c(f,ge(p,i.position[0])),l.position.y=t.position[1]*d+c(f,ge(p,i.position[1])),l.position.z=t.position[2]*d+c(f,ge(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Ar.defaultData([1,1,1]).randomnessObject,s=Qs(i.strength,this.parameters.randomness),a=i.noiseType==="perlin";ao.noiseSeed(i.seed);let c=Nh((0,Ki.default)(i.seed));if(o.useCenter===!0){let d={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 Yt(o.size[0]*(o.count[0]-d.x)*.5,o.size[1]*(o.count[1]-d.y)*.5,o.size[2]*(o.count[2]-d.z)*.5);for(let u=0;u<o.count[0];u++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let m=[(u+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=a?ao.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,ge(h,i.scale[0]))||Mt,y.scale.y=1+s(t,ge(h,i.scale[1]))||Mt,y.scale.z=1+s(t,ge(h,i.scale[2]))||Mt;let g=s(t,ge(h,i.rotation[0])),x=s(t,ge(h,i.rotation[1])),S=s(t,ge(h,i.rotation[2]));y.rotation.set(g,x,S),y.position.x=o.size[0]*u-l.x+s(t,ge(h,i.position[0])),y.position.y=o.size[1]*p-l.y+s(t,ge(h,i.position[1])),y.position.z=o.size[2]*f-l.z+s(t,ge(h,i.position[2]))}}else for(let d=0;d<o.count[0];d++)for(let l=0;l<o.count[1];l++)for(let u=0;u<o.count[2];u++){let p=[(d+1)*(i.freqScale/10)+i.movement,(l+1)*(i.freqScale/10)+i.movement,(u+1)*(i.freqScale/10)+i.movement],f=a?ao.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,ge(f,i.scale[0]))||Mt,m.scale.y=1+s(t,ge(f,i.scale[1]))||Mt,m.scale.z=1+s(t,ge(f,i.scale[2]))||Mt;let h=s(t,ge(f,i.rotation[0])),y=s(t,ge(f,i.rotation[1])),g=s(t,ge(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*d+s(t,ge(f,i.position[0])),m.position.y=-o.size[1]*l+s(t,ge(f,i.position[1])),m.position.z=-o.size[2]*u+s(t,ge(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Gd(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Ar.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";ao.noiseSeed(i.seed);let a=yl((0,Ki.default)(i.seed)),c=Qs(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 Xi)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 d=this.getSubdivData(),l=[],u=g=>{let x=g.length,S=g.map(_=>_[0]).reduce((_,P)=>_+P,0),w=g.map(_=>_[1]).reduce((_,P)=>_+P,0),b=g.map(_=>_[2]).reduce((_,P)=>_+P,0);return[S/x,w/x,b/x]},p=g=>Math.round(g*1e6)/1e6;d.forEach(g=>{let x=d.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:u(x.map(S=>S.norm))}):l.push(g)});let f=Yg(l);if(d.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new gl(this.objectForSample).build(),h=qg[t.axis],y=this.children;m.setRandomGenerator((0,Ki.default)(this.object.uuid+t.seed));for(let[g,x]of y.entries()){let S=g*(i.freqScale/10)+i.movement,w=s?ao.noise(S):a(S,S),b=g+1,_=c(b,ge(w,i.rotation[0])),P=c(b,ge(w,i.rotation[1])),v=c(b,ge(w,i.rotation[2]));t.spreadType==="random"?m.sample(Js,Vd):(f.length&&(Js.fromArray(f[g].pos),Vd.fromArray(f[g].norm)),this.objectForSample instanceof fn&&Js.applyMatrix4(ZA.copy(this.objectForSample.matrixWorld).invert())),Js.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(Js),Go.fromArray(h);let N=t.align==="normal"?Vd:this.object.getWorldDirection(eC),T=yn.fromArray(t.position);yn.x+=yn.x+c(b,ge(w,i.position[0])),yn.y+=yn.y+c(b,ge(w,i.position[1])),yn.z+=yn.z+c(b,ge(w,i.position[2]));let C=Math.acos(N.dot(Go)),O=JA.crossVectors(Go,N).normalize(),A=QA.makeRotationAxis(O,C),M=N.clone().cross(this.object.up).normalize(),L=M.clone().cross(N).normalize(),X=new gn().makeBasis(M,N,L),R=new Yt(Go.y,Go.z,Go.x).normalize(),Z=R.clone().cross(Go).normalize(),z=new gn().makeBasis(R,Go,Z).invert(),V=new gn().multiplyMatrices(X,z);x.rotation.setFromRotationMatrix(V),T.applyMatrix4(A),x.position.add(T),x.rotation.x=x.rotation.x+o.x+_,x.rotation.y=x.rotation.y+o.y+P,x.rotation.z=x.rotation.z+o.z+v,x.scale.setScalar(1),x.scale.x=x.scale.x+t.scale[0]+c(b,ge(w,i.scale[0]))||Mt,x.scale.y=x.scale.y+t.scale[1]+c(b,ge(w,i.scale[1]))||Mt,x.scale.z=x.scale.z+t.scale[2]+c(b,ge(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 fn){let t=this.objectForSample,o=$g[e],i=a0[o],s=i0[o],a=s0[o],c=[],d=i(t.subdivPointerNew);for(let l=0;l<=d-1;l++){let u=s(t.subdivPointerNew,l),p=a(t.subdivPointerNew,l);o0.fromArray(u).applyMatrix4(t.matrixWorld),n0.fromArray(p),c.push({pos:o0.toArray(),norm:n0.toArray()})}return c}else return(this.objectForSample.geometry.index?Xg(this.objectForSample.geometry):Kg(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=Zr(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 vt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new gn,this.hiddenMatrix=new gn,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};import{Scene as rN,Vector3 as oN,Matrix4 as nN,Box3 as iN,MeshBasicMaterial as sN,Skeleton as aN}from"three";import{Camera as pC,OrthographicCamera as fC,PerspectiveCamera as mC,Vector3 as xr,Object3D as d0,Quaternion as hC,Matrix4 as yC}from"three";import{Camera as sC,LineSegments as aC,BufferGeometry as lC,LineBasicMaterial as cC,Color as jd,Vector3 as uC,Float32BufferAttribute as c0}from"three";import{BoxGeometry as tC}from"three";var kr=n=>{var r;return r=class extends n{},r.geometryHelper=new tC(30,30,30),r};import{Ray as rC,Sphere as oC,Matrix4 as nC,Vector3 as lo}from"three";var ac=new rC,zd=new oC,l0=new nC,Ur=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),zd.copy(i.boundingSphere),zd.applyMatrix4(s),e.ray.intersectsSphere(zd)===!1||(l0.copy(s).invert(),ac.copy(e.ray).applyMatrix4(l0),i.boundingBox!==null&&ac.intersectsBox(i.boundingBox)===!1))return;let a,c,d,l,u=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),x=Math.min(u.count,f.start+f.count);for(m=g,h=x;m<h;m+=3)if(c=u.getX(m),d=u.getX(m+1),l=u.getX(m+2),a=y(n,e,ac,p,c,d,l),a){a.faceIndex=Math.floor(m/3),t.push(a);return}}else{let x=i.attributes.position,S=new lo,w=new lo,b=new lo,_=new lo,P=2,N=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=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+=P){if(S.fromBufferAttribute(x,A),w.fromBufferAttribute(x,A+1),ac.distanceSqToSegment(S,w,_,b)>T)continue;_.applyMatrix4(n.matrixWorld);let X=e.ray.origin.distanceTo(_);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,_,P){let v=new lo,N=new lo,T=new lo,C=new lo,O=new lo;if(v.fromBufferAttribute(w,b),N.fromBufferAttribute(w,_),T.fromBufferAttribute(w,P),S.intersectTriangle(v,N,T,!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 lc=new uC,tr=new sC,Fd=class extends aC{constructor(e){let t=new lC,o=new cC({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],a={},c=new jd(15711266),d=new jd(15711266),l=new jd(2857471);u("n1","n2",c),u("n2","n4",c),u("n4","n3",c),u("n3","n1",c),u("f1","f2",c),u("f2","f4",c),u("f4","f3",c),u("f3","f1",c),u("n1","f1",c),u("n2","f2",c),u("n3","f3",c),u("n4","f4",c),u("p","n1",d),u("p","n2",d),u("p","n3",d),u("p","n4",d),u("u1","u2",l),u("u2","u3",l),u("u3","u1",l);function u(f,m,h){p(f,h),p(m,h)}function p(f,m){i.push(0,0,0),s.push(m.r,m.g,m.b),a[f]===void 0&&(a[f]=[]),a[f].push(i.length/3-1)}t.setAttribute("position",new c0(i,3)),t.setAttribute("color",new c0(s,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=a,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;tr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,a=o?.8:1e-4;gr("n1",t,e,tr,-i,-s,a),gr("n2",t,e,tr,i,-s,a),gr("n3",t,e,tr,-i,s,a),gr("n4",t,e,tr,i,s,a);let c=a;gr("f1",t,e,tr,-i,-s,c),gr("f2",t,e,tr,i,-s,c),gr("f3",t,e,tr,-i,s,c),gr("f4",t,e,tr,i,s,c);let d=c,l=.5;gr("u1",t,e,tr,i*.7*l,s*1.1,d),gr("u2",t,e,tr,-i*.7*l,s*1.1,d),gr("u3",t,e,tr,0,s*(1.1+.9*l),d),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function gr(n,r,e,t,o,i,s){lc.set(o,i,s).unproject(t);let a=r[n];if(a!==void 0){let c=e.getAttribute("position");for(let d=0,l=a.length;d<l;d++)c.setXYZ(a[d],lc.x,lc.y,lc.z)}}var cc=class extends kr(Fd){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){Ur(this.object,this.geometry,e,t,!0)}};import{Box3Helper as u0,BoxGeometry as dC}from"three";var uc;(r=>r.is=e=>"objectHelper"in e)(uc||(uc={}));var Hr=(n,r)=>class extends ai(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 u0&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof dC?(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 u0&&(i.visible=!1)}}};var dc=790,Qi=new xr,kd=new xr,Ud=new hC,Hd=new xr,ea=new xr,Wd=new xr,co=class extends Hr(pC,cc){constructor(e="",t={...Yo.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Po.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new yC,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new fC(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new mC(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 xr(e,t,o)),super.lookAt(e),this.getWorldPosition(Qi),this.targetOffset=Qi.distanceTo(e)}getTarget(e=new xr){return this.getWorldDirection(kd),this.getWorldPosition(Qi),kd.multiplyScalar(this.targetOffset),e.copy(Qi).add(kd),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Qi),Qi.distanceTo(e)}updateUp(){this.getWorldQuaternion(Ud),Hd.set(0,0,1).applyQuaternion(Ud),ea.copy(d0.DEFAULT_UP),this.isUpVectorFlipped&&ea.negate(),ea.applyQuaternion(Ud),Wd.copy(d0.DEFAULT_UP).projectOnPlane(Hd),this.angleOffsetFromUp=Wd.angleTo(ea),this.angleOffsetFromUp*=Wd.cross(ea).dot(Hd)>=0?1:-1}updateTransformState(e){let t=super.updateTransformState(e);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),t}getViewFrontToObject(e){let t=e.getWorldPosition(new xr),i=e.getWorldDirection(new xr).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToTarget(e){let o=this.getWorldDirection(new xr).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let t=new xr,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,s=e>t?1:this.aspect;this.left=-dc*.5*i,this.right=dc*.5*i,this.top=dc*.5*(1/s),this.bottom=-dc*.5*(1/s)}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,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,s,a):this.orthoCamera.setViewOffset(e,t,o,i,s,a)}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 Fn(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 p0,Matrix4 as f0,Float32BufferAttribute as gC}from"three";var Ji=new f0,xC=new f0;var rr=class extends jt{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new p0;this.onAfterRender=(e,t,o,i,s,a)=>{super.onAfterRender(e,t,o,i,s,a),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 s=this.children[i];s instanceof rr&&s.dataPatched.visible===!0&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof vt&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(Ji.multiplyMatrices(s.hiddenMatrix,s.matrix),s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=Zt.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;Zt.transformMeshSet(s.booleanMeshSetAddress,Ji),s.booleanMatrixInvOld.copy(Ji).invert(),s.booleanWasTransformed=!1}else s instanceof rr&&s.needsTransformForDownstream===!0?(Zt.transformMeshSet(s.booleanMeshSetAddress,Ji),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(Zt.transformMeshSet(s.booleanMeshSetAddress,xC.multiplyMatrices(Ji,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(Ji).invert(),s.booleanWasTransformed=!1);Zt.hasOpenEdges(s.booleanMeshSetAddress)===!1||i===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(s.booleanMeshSetAddress),s.geometry.userData.wasFilteredFromBoolean=!1):s.geometry.userData.wasFilteredFromBoolean=!0}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new gC([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Zt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new p0,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Zt.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,qi(this),$i(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as vC}from"three";var m0;(r=>{function n(e){return Te.is(e)&&e instanceof vC}r.is=n})(m0||(m0={}));var es=(n,r)=>class extends Hr(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 Vo=n=>n instanceof vt,ta=n=>n!==null&&n instanceof rr;var ra=n=>uc.is(n);import{Group as SC}from"three";import{AxesHelper as bC}from"three";var Wr=class extends kr(bC){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){Ur(this.object,Wr.geometryHelper,e,t)}update(){}};var oa=class extends Hr(SC,Wr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};import{Color as BC,Fog as RC,HemisphereLight as GC}from"three";import{ShaderChunk as na}from"three";var wC=n=>`
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 sA,Texture as lA}from"three";var rc=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 Nu=class extends rc{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Cu;function Ig(n){return typeof n=="string"?n:(Cu||(Cu=new Nu),Cu.load(n))}var oc=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")}},nc=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 Zi=class extends oc{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=Ig(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new sA(this.img,void 0,e,e):o=new lA(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 Qt=class extends Zi{};import{Vector2 as so,Vector3 as Vr,Vector4 as ic}from"three";function wt(n,r){return r.color(n)}function Mg(n,r){switch(n.type){case"fresnel":return uA(n,r);case"gradient":return pA(n);case"depth":return fA(n);case"normal":return mA(n);case"noise":return hA(n,r);case"rainbow":return yA(n);case"toon":return gA(n,r);case"outline":return xA(n,r);case"transmission":return vA(n,r);case"color":return dA(n,r);case"pattern":return bA(n,r)}}function cA(n){return{type:n.type}}function yr(n){let{alpha:r,mode:e,isMask:t}=n;return{...cA(n),alpha:r,mode:e,isMask:t}}function dA(n,r){return{...yr(n),color:wt(n.color,r)}}function uA(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:a,isMask:s}=n;return{...yr(n),color:wt(a,r),bias:e,scale:t,intensity:o,factor:i}}function pA(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:a,morph:s}=n;return{...yr(n),gradientType:r,smooth:e,colors:t.map(c=>new ic(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new so(...a),morph:new so(...s),angle:i}}function fA(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:a,direction:s,colors:c,steps:u,smooth:l}=n;return{...yr(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Vr(...a),direction:s?new Vr(...s):new Vr(1,0,0),colors:c.map(d=>d!==void 0?new ic(d[0],d[1],d[2],d[3]):new ic(0,0,0,0)),steps:u.slice(0,c.length),smooth:l}}function mA(n){let{cnormal:r}=n;return{...yr(n),cnormal:new Vr(r[0],r[1],r[2])}}function hA(n,r){return{...yr(n),scale:n.scale,move:n.move,fA:new so(...n.fA),fB:new so(...n.fB),size:new Vr(...n.size),distortion:new so(...n.distortion),colorA:wt(n.colorA,r),colorB:wt(n.colorB,r),colorC:wt(n.colorC,r),colorD:wt(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 yA(n){return{...yr(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Vr(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Vr(...n.offset)}}function gA(n,r){return{...yr(n),positioning:n.positioning,colors:n.colors.map(e=>new ic(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:wt(n.shadowColor,r),offset:new Vr(...n.offset)}}function xA(n,r){return{...yr(n),outlineColor:wt(n.outlineColor,r),contourColor:wt(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 vA(n,r){return{...yr(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function bA(n,r){return{...yr(n),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new so(...n.offset),colorA:wt(n.colorA,r),colorB:wt(n.colorB,r),frequency:new so(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new so(...n.vertical),horizontal:new so(...n.horizontal),sides:n.sides}}var jo=class extends nt{};import{Vector4 as SA}from"three";var Iu={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Mu={depth:["colors"]};function wA(n,r,e){if(r==="isMask")return!0;let t=Iu[n.type],o=Mu[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 Lu(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 Qt||c.image.deref(),c.image=s}if("video"in i){let a=i.video,s=r.video(a),c=t;c.image instanceof Qt||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 Lg(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(Eu(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof Vo))switch(o=o||wA(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 jo?s.value=new nt(c.r,c.g,c.b,c.a):s.setRGBA(c);break}case Gt:if(typeof a=="string"){let c=r.getColor(a);c&&(s.value=c);break}else{let c=a;s.value instanceof jo?s.value=new nt(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 bt:{let c=a;s.value.setX(c[0]),s.value.setY(c[1]),s.value.setZ(c[2]);break}case It:{Lu(a,r,e);break}case hr:{s.value=a.map(c=>new SA(...c));break}default:{s.value=a;break}}}return o}var jr=class{constructor(r,e,t,o){this.id=r;this.uuid=e;this.data=t;this.uniforms={};for(let i in o)this.uniforms[`f${this.id}_${i}`]=o[i];for(let i in t)Eu(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return $t.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 ec(i),c=new tc(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(t.alpha??1),y=new we(t.mode??0),g=new qe(t.isMask??!1),x=new zo(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)}else if(t.type==="matcap"){let i=o.image(t.texture.image),a=new cn(i,t.texture.wrapping),s=new J(t.alpha??1),c=new we(t.mode??0),u=new qe(t.isMask??!1),l=new Ui(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)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new bt(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 Ki(s,c,i,l,d,p,f,m,h,a,u);return new os(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)}else throw new Error;else return TA(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):Lg(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Lu(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 Qt||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){super(e,t,o,i);this.params=i;this.color=a;this.mode=s;this.alpha=c;this.isMask=u}},os=class extends jr{constructor(e,t,o,i,a){super(e,t,o,i);this.position=a}},$t=class extends jr{constructor(e,t,o,i,a){super(e,t,o,a);this.node=i}static createLigherLayer(e,t,o,i){let a,s=new J(o.alpha),c=new we(o.mode),u=new J(o.bumpMapIntensity),l=new J(o.alphaOverride),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 qe(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 qe(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 qe(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 $t(e,t,o,a,d)}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 Jt(n){return{alpha:new J(n.alpha??1),mode:new we(n.mode??0),isMask:new qe(n.isMask??!1)}}function PA(n,r,e,t){switch(n.type){case"color":{let o=new Me(t.color??tt),i=Jt(t),a=new dn(o,i.alpha),s=new Ne(a.calpha,"f");return new je(r,e,n,{color:o,...i},a,i.mode,s,i.isMask)}case"fresnel":{let o=new Me(t.color??16777215),i=new J(t.bias??.1),a=new J(t.scale??1),s=new J(t.intensity??2),c=new J(t.factor??1),u=Jt(t),l=new Za(o,i,a,s,c,u.alpha,u.mode,u.isMask),d=new Ne(l.calpha,"f");return new je(r,e,n,{color:o,bias:i,scale:a,intensity:s,factor:c,...u},l,u.mode,d,u.isMask)}case"rainbow":{let o=new J(t.filmThickness??30),i=new J(t.movement??0),a=new bt(t.wavelengths??new zr(0,0,0)),s=new J(t.noiseStrength??0),c=new J(t.noiseScale??1),u=new bt(t.offset??new zr(0,0,0)),l=Jt(t),d=new $i(o,i,a,s,c,u,l.alpha,l.isMask),p=new Ne(d.calpha,"f");return new je(r,e,n,{filmThickness:o,movement:i,wavelengths:a,noiseStrength:s,noiseScale:c,offset:u,...l},d,l.mode,p,l.isMask)}case"transmission":{let o=new J(t.thickness??10),i=new J(t.ior??1.5),a=new J(t.roughness??.5),s=ve.transmissionSize,c=ve.transmissionRenderTarget,u=ve.transmissionRenderTargetDepth,l=window.innerWidth,d=window.innerHeight,p=l>=d?new Ue(d/l,1):new Ue(1,l/d),f=Jt(t),m=new Xi(o,i,a,s,c,u,p,f.alpha),h=new Ne(m.calpha,"f");return new je(r,e,n,{thickness:o,ior:i,roughness:a,aspectRatio:p,...f},m,f.mode,h,f.isMask)}case"toon":{let o=new we(t.positioning??0),i;t.colors?i=new hr(t.colors.length,t.colors):(i=new hr(10,new Qi(0,0,0,1)),i.value[1]=new Qi(1,1,1,1));let a;t.steps?a=new mr(t.steps.length,t.steps):(a=new mr(10,1),a.value[0]=0);let s=new bt(t.source??new zr(0,0,0)),c=new qe(t.isWorldSpace??!0),u=new J(t.noiseStrength??0),l=new J(t.noiseScale??1),d=new Gt(t.shadowColor),p=new bt(t.offset??new zr(0,0,0)),f=Jt(t),m=new Yi(o,i,a,s,c,u,l,d,p,f.alpha),h=new Ne(m.calpha,"f");return new je(r,e,n,{positioning:o,colors:i,steps:a,source:s,isWorldSpace:c,noiseStrength:u,noiseScale:l,shadowColor:d,offset:p,...f},m,f.mode,h,f.isMask)}case"outline":{let o=new Me(t.outlineColor??16777215),i=new Me(t.contourColor??16777215),a=new J(t.outlineWidth??.1),s=new J(t.contourWidth??.1),c=new J(t.outlineThreshold??.1),u=new J(t.contourThreshold??.1),l=new J(t.outlineSmoothing??.1),d=new J(t.contourFrequency??.1),p=new bt(t.contourDirection??new zr(0,1,0)),f=new qe(t.positionalLines??!1),m=new qe(t.compensation??!0),h=ve.normalRenderTarget,y=ve.normalRenderTargetDepth,g=ve.pixelRatioNode,x=ve.resolution,S=Jt(t),w=new Wi(o,i,a,s,c,u,l,d,p,f,m,x,h,y,g,S.alpha),b=new Ne(w.calpha,"f");return new je(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:a,contourWidth:s,outlineThreshold:c,contourThreshold:u,outlineSmoothing:l,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,...S},w,S.mode,b,S.isMask)}case"depth":{let o=new we(t.gradientType??0),i=new qe(t.smooth??!1),a=new J(t.near??50),s=new J(t.far??200),c=new J(t.isVector??1),u=new J(t.isWorldSpace??0),l=new bt(t.origin??new zr),d=new bt(t.direction??new zr),p;t.colors?p=new hr(t.colors.length,t.colors):(p=new hr(2,new Qi(0,0,0,1)),p.value[1]=new Qi(1,1,1,1));let f;t.steps?f=new mr(t.steps.length,t.steps):(f=new mr(2,1),f.value[0]=0);let m=Jt(t),h=new Fi(o,i,a,s,c,u,l,d,p,f,m.alpha,m.isMask),y=new Ne(h.calpha,"f");return new je(r,e,n,{gradientType:o,smooth:i,near:a,far:s,isVector:c,isWorldSpace:u,origin:l,direction:d,colors:p,steps:f,...m},h,m.mode,y,m.isMask)}case"noise":{let o=new J(t.scale??1),i=new bt(t.size??new zr(100,100,100)),a=new J(t.move??1),s=new Ue(t.fA??new gr(1.7,9.2)),c=new Ue(t.fB??new gr(8.3,2.8)),u=new Ue(t.distortion??new gr(1,1)),l=new Gt(t.colorA),d=new Gt(t.colorB),p=new Gt(t.colorC),f=new Gt(t.colorD),m=new we(t.noiseType??0),h=new we(t.voronoiStyle??0),y=new J(t.highCut??1),g=new J(t.lowCut??0),x=new J(t.smoothness??.5),S=new J(t.seed??.5),w=new we(t.quality??1),b=Jt(t),_=new Hi(o,i,a,s,c,u,l,d,p,f,b.alpha,m,b.isMask,h,y,g,x,S,w),P=new Ne(_.calpha,"f");return new je(r,e,n,{scale:o,size:i,move:a,fA:s,fB:c,distortion:u,colorA:l,colorB:d,colorC:p,colorD:f,noiseType:m,...b,voronoiStyle:h,highCut:y,lowCut:g,smoothness:x,seed:S,quality:w},_,b.mode,P,b.isMask)}case"normal":{let o=new bt(t.cnormal??new zr(1,1,1)),i=Jt(t),a=new Vi(o,i.alpha),s=new Ne(a.calpha,"f");return new je(r,e,n,{cnormal:o,...i},a,i.mode,s,i.isMask)}case"gradient":{let o=new we(t.gradientType??0),i=new qe(t.smooth??!1),a;t.colors?a=new hr(t.colors.length,t.colors):(a=new hr(10,new Qi(0,0,0,1)),a.value[1]=new Qi(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 Ue(t.offset??new gr(0,0)),u=new Ue(t.morph??new gr(0,0)),l=new J(t.angle??0),d=Jt(t),p=new ki(o,i,a,s,c,u,l,d.alpha,d.isMask),f=new Ne(p.calpha,"f");return new je(r,e,n,{gradientType:o,smooth:i,colors:a,steps:s,offset:c,morph:u,angle:l,...d},p,d.mode,f,d.isMask)}case"pattern":{let o=new we(t.style??0),i=new we(t.projection??0),a=new we(["x","y","z"].indexOf(t.axis)??0),s=new J(t.blending??0),c=new Ue(t.offset??new gr(0,0)),u=new Gt(t.colorA),l=new Gt(t.colorB),d=new Ue(t.frequency??new gr(10,10)),p=new J(t.size??.5),f=new J(t.variation??0),m=new J(t.smoothness??.5),h=new J(t.zigzag??0),y=new J(t.rotation??0),g=new Ue(t.vertical??new gr(0,1)),x=new Ue(t.horizontal??new gr(0,1)),S=new we(t.sides??6),w=Jt(t),b=new qi(o,i,a,s,c,u,l,d,p,f,m,h,y,g,x,S,w.alpha,w.isMask),_=new Ne(b.calpha,"f");return new je(r,e,n,{style:o,projection:i,axis:a,blending:s,offset:c,colorA:u,colorB:l,frequency:d,size:p,variation:f,smoothness:m,zigzag:h,rotation:y,vertical:g,horizontal:x,sides:S,...w},b,w.mode,_,w.isMask)}default:{let o=new Me(1,0,0,1),i=Jt(t),a=new dn(o,i.alpha),s=new Ne(a.calpha,"f");return new je(r,e,n,{color:o,...i},a,i.mode,s,i.isMask)}}}function TA(n,r,e,t){let o=Mg(e,t);return PA(e,n,r,o)}function Eu(n,r,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let t=r.uniforms[`f${r.id}_intensity`];return t?(t.value=e.intensity*(e.visible?1:0),t):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let t=r.uniforms[`f${r.id}_alpha`];if(!t)return;if(t.value=e.alpha*(e.visible?1:0),e.type==="outline"&&n==="visible"){let o=r.uniforms[`f${r.id}_compensation`];o&&(o.value=e.compensation&&e.visible)}return t}}function Eg(n,r){let e=0,t=n.layers.find(o=>o.data.type==="light");if(t&&t.data.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(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 zt=class extends OA{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}},ac=class extends zt{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 zt{constructor(e,t){super();this.data=e;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 ac(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??yt.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(),this.transparent=Eg(e,t.shared)}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(e=>e instanceof $t),this.lightLayer===void 0&&(this.lightLayer=new $t(0,"",{...Ct.defaultData("light","phong"),visible:!1},new pn,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof $t);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 zo&&(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=Eg(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()}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()}}}}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 $t&&(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 $t?i.node.mask=new pt(t.color,t.alpha,pt.MUL):i instanceof je&&(i.isMask.value||(i.color.mask=new pt(t.color,t.alpha,pt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof je),t=this.layers.findIndex(o=>o instanceof $t);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 Gi(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 $t);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 Gi(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 os);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new pt(t,e[o].position,pt.ADD),t=new pt(t,new J(.5).setReadonly(!0),pt.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=(Iu[t.type]??[]).map(u=>t[u]),i=(Mu[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 Jl;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(zt.prototype,{properties:{get:function(){return this.fragment.properties}}});var mn=class extends fn{};var Gg=ma(Dg());var Bg=new Map;function Rg(n){if(typeof n=="string")return n;let r=Bg.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},Bg.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:Rg(r),format:"wav"},this.sound=new Gg.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 AA,Vector2 as yn,Path as Vg,Shape as CA,ShapeUtils as NA,Color as IA}from"three";var lc=class{constructor(){this.type="ShapePath";this.color=new IA;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new Vg,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,_=x.x,P=h.y,v=y.y,N=g.y,T=x.y,C=(_-b)*(P-N)-(T-N)*(S-b),O=(w-S)*(P-N)-(v-P)*(S-b),A=(T-N)*(w-S)-(_-b)*(v-P),M=C/A,E=O/A;if(A===0&&C!==0||M<=0||M>=1||E<0||E>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=+(P+t.t*(v-P)).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=+(P+M*(v-P)).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,_=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(_<-Number.EPSILON){t.loc=e.LEFT;return}if(_>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 P;x!==0?P=w/x:P=b/S,t.loc=e.BETWEEN,t.t=P}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 _=1;_<y.length;_++){let P=y[_-1],v=y[_],N=o(w,b,P,v);N!==null&&g.find(T=>T.t<=N.t+Number.EPSILON&&T.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(_=>{S.push({identifier:w.identifier,isCW:w.isCW,point:_})})}),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)],_=s(b,h.boundingBox,y);_.sort((O,A)=>O.point.x-A.point.x);let P=[],v=[];_.forEach(O=>{O.identifier===h.identifier?P.push(O):v.push(O)});let N=P[0].point.x,T=[],C=0;for(;C<v.length&&v[C].point.x<N;)T.length>0&&T[T.length-1]===v[C].identifier?T.pop():T.push(v[C].identifier),C++;if(T.push(h.identifier),S==="evenodd"){let O=T.length%2===0,A=T[T.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(S==="nonzero"){let O=!0,A=null,M=null;for(let E=0;E<T.length;E++){let X=T[E];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 _=y[b];_.y>g&&(g=_.y),_.y<x&&(x=_.y),_.x>S&&(S=_.x),_.x<w&&(w=_.x)}d<=S&&(d=S+1),l>=w&&(l=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:NA.isClockWise(y),identifier:u++,boundingBox:new AA(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 CA;g.curves=h.curves,f.filter(S=>S?.isHole&&S.for===h.identifier).forEach(S=>{if(S){let w=p[S.identifier],b=new Vg;b.curves=w.curves,g.holes.push(b)}}),m.push(g)}}),m}};var jg,Du=new Promise(n=>{jg=n}),zg=!1;var cc;function Fg(){if(zg)return;if(cc)return cc;async function n(){let e=await import("./opentype.js");jg(e),zg=!0}return cc=n(),cc}var ns=class{async load(r,e,t=()=>{}){let{load:o}=await Du;o(r,(i,a)=>{i||!a?t(i??"Something went wrong"):e(a)})}async parse(r){let{parse:e,Bidi:t}=await Du;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 MA(n){return await(await fetch(n)).arrayBuffer()}var LA=new ns;async function Bu(n){let r,e,t=!1;if(n.url?(r=await MA(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 LA.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}import{CubicBezierCurve as EA,LineCurve as DA,QuadraticBezierCurve as BA}from"three";function RA(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var dc=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Bu(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=Bu(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(RA(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
+ `,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(P){console.warn(P)}d=this.getLineInitialOffsetX(a[x],s,e.horizontalAlign,S,c);let _=[];try{_=this.reverseLigaturesTable(t,S,b)}catch(P){console.warn(P)}l=this.computeSpaceWidthForLine(r,x,e);for(let P=0;P<b.length;P++){let v=b[P],N=v.index===0?`
2217
+ `:v.unicode?String.fromCharCode(v.unicode):void 0,T=_[P],C=0,O=0;P===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
+ `)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(T.replacements.length===1)h[x].push([d,p]),m[x].push(A);else{let M=T.replacements.map(Z=>(t.glyphs.get(Z).advanceWidth??0)*o),E=M.reduce((Z,z)=>Z+=z,0),X=M.map(Z=>Z/E),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 lc,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=GA(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 GA(n){if(n.length){let r=n[0];if(r instanceof DA)return r.v1;if(r instanceof EA||r instanceof BA)return r.v0}}var Ru=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){let t=this.objects.get(r);return t===void 0?(t=this.createObject(r,e),this.objects.set(r,t)):t.isShared=!0,t}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()}},is=class extends Ru{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=an(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var kg={markNeedsUpdateRendererDirty:()=>{}};var Gu=class extends nc{constructor(e){super();this.shared=e}create(e){return new Zi(e,this.shared)}},gn=class{constructor(r,e={}){this.data=r;this.geometryCache=new is(!0);this.geometryCache2=new is(!1);this.imageHolderCache=new Gu(this);this.thisContext={scene:kg,shared:this};this.deletedMaterial=new mn(yt.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new Qt(ci.emptyImage,this);this.deletedVideo=new Qt(ti.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};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}reset(r){this.resetLib(r.lib);for(let[e,t]of Object.entries(r.images))this.addImage(e,t);for(let[e,t]of Object.entries(r.videos))this.addVideo(e,t);for(let[e,t]of Object.entries(r.colors))this.addColor(e,t);for(let[e,t]of Object.entries(r.materials))this.addMaterial(e,t);for(let[e,t]of Object.entries(r.audios))this.addAudio(e,t);for(let[e,t]of Object.entries(r.fonts))this.addFont(e,t)}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);t.uuid=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 Qt(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 Qt(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 jo(e.r,e.g,e.b,e.a):this.colors[r]=new jo(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 nt(0,0,0,0))}else return"a"in r?new nt(r.r,r.g,r.b,r.a):new nt(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 dc(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()}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)}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]==="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(Qe.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]==="lib"&&this.updateLibByOp(Qe.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)}}},Ug=new gn(ar.emptyData());var jt=class extends vt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Gm(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 zt)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(Qe.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(Qe.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&&ys(this.material).forEach(e=>{e instanceof zt&&(e instanceof mn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};import{BufferGeometry as VA,Matrix4 as Vu,Vector3 as Yg,Vector4 as zu}from"three";var Hg=new Yg,Wg=new zu,qg=new zu,zA=new Yg,$g=new Vu,Ke=class extends jt{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 Vu().fromArray(t.bindMatrix),this.bindMatrixInverse=new Vu)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof VA&&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)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return Aa.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return Aa.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(Qe.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)}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&&Wa(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)}}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&&xa(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof Xe&&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 zu,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;Wg.fromBufferAttribute(i.attributes.skinIndex,e),qg.fromBufferAttribute(i.attributes.skinWeight,e),Hg.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){let s=qg.getComponent(a);if(s!==0){let c=Wg.getComponent(a);$g.multiplyMatrices(o.bones[c].matrixWorld,o.boneInverses[c]),t.addScaledVector(zA.copy(Hg).applyMatrix4($g),s)}}return t.applyMatrix4(this.bindMatrixInverse)}};function FA(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 Fu(o[a],o[a+1],o[a+2]);r.has(s)?r.get(s)?.normals.push(c):r.set(s,{normals:[c],result:new Fu})}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 Xg(i,3))}function kA(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 Fu;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 Xg(t,3))}function Ji(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof zt)||n.material.getLayersOfType("outline").length===0)return;n instanceof Ke&&n.is2DAndNoDepth?kA(n):FA(n)}function ea(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=[ju.seededRandom(o),ju.seededRandom(o+1e4),ju.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)t[a]=i[a%3];n.geometry.setAttribute("randomColor",new jA(t,3))}var qA;Ci.then(n=>{qA=n});var Fr=new UA,as=new WA;function Zg(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 Ke{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new HA;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}=Xe.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,Ji(this),ea(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){Xe.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&Xe.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Xe.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Xe.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,vt.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 Kg,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(as),this.hasNonUniformScale&&as.divide(this.scale);let i={width:as.x,height:as.y,depth:as.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 Kg);let o=t.boundingSphere.center;Fr.getCenter(o),t.boundingSphere.radius=o.distanceTo(Fr.max)}freeSubdivPointer(){this.subdivPointer&&(Xe.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 $A,Vector3 as bn}from"three";var Qg=-1,YA=1,Jg={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},e0={polygon_center:0,edge:1,vertex:2},ss=(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-Qg)*(e-t)/(YA-Qg)+t};function t0(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 XA=new bn,uc=new bn,KA=new bn,ZA=new bn;function ta(n,r){let e=KA.fromArray(n),t=ZA.fromArray(r);uc.copy(t).sub(e);let o=uc.length();return uc.normalize().multiplyScalar(o*.5),XA.copy(e).add(uc).toArray()}var er=new $A,pc=new bn,fc=new bn,vn=new bn;function r0(n){let r=[];for(let e=0;e<=n.index.count;e++)if(pc.fromArray(n.index.array,e*3),er.setFromAttributeAndIndices(n.attributes.position,pc.x,pc.y,pc.z),er.getNormal(fc),er.getMidpoint(vn),!(isNaN(vn.x)||isNaN(vn.y)||isNaN(vn.z))){let{a:t,b:o,c:i}=er,a=t.toArray(),s=o.toArray(),c=i.toArray(),u=t.distanceTo(o),l=o.distanceTo(i),d=i.distanceTo(t),p=ta(a,s),f=ta(s,c),m=ta(c,a),h=[u,l,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,x=[],S=er.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:er.getNormal(fc).toArray()})}return r}function o0(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){er.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),er.getNormal(fc),er.getMidpoint(vn);let o=er.a.toArray(),i=er.b.toArray(),a=er.c.toArray();r.push({vertices:[o,i,a],faceCenters:[ta(o,i),ta(i,a),ta(a,o)],midpoint:vn.toArray(),norm:fc.toArray()})}return r}var QA=4,JA=.5,ku=n=>.5*(1-Math.cos(n*Math.PI)),Uu=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<QA;g++){let x=o+(i<<4)+(a<<8);l=ku(s),d=ku(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+=ku(u)*(h-m),p+=m*f,f*=JA,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()}},n0=Uu;import{Vector3 as eC,Matrix4 as tC,Ray as rC}from"three";var i0=new eC,a0=new tC,s0=new rC;function l0(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var ra=class extends Ke{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)&&(a0.copy(o).invert(),s0.copy(e.ray).applyMatrix4(a0),s0.intersectBox(this.singleBBox,i0))){let i=i0.applyMatrix4(o),a=e.ray.origin.distanceTo(i);t.push({distance:a,point:i.clone(),object:this})}}};var Mt=1e-4,kr,p0,f0,m0,d0=new Yt,u0=new Yt;Ci.then(n=>{kr=n,p0=[kr.get_face_center,kr.get_edge_midpoint,kr.get_vertex_position],f0=[kr.get_face_normal,kr.get_edge_normal,kr.get_vertex_normal],m0=[kr.face_count,kr.edge_count,kr.vertex_count]});var nC=new wn,iC=new wn,Fo=new Yt,Sn=new Yt,ls=new Yt,Wu=new Yt,aC=new Yt,sC=new Yt;var lo=new n0,na=class extends ui(oC){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 oo&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof oo&&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 oo(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 oo(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*c0.DEG2RAD,i=t.end*c0.DEG2RAD,a=o-i,s=new Hu(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Yt(0,0,1);break;case"y":c=new Yt(0,1,0);break;default:case"x":c=new Yt(1,0,0);break}let u=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,l=u.noiseType==="perlin";lo.noiseSeed(u.seed);let d=_l((0,oa.default)(u.seed)),p=ss(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=l?lo.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 Hu(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";lo.noiseSeed(i.seed);let s=_l((0,oa.default)(i.seed)),c=ss(i.strength,this.parameters.randomness);for(let[u,l]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=a?lo.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=ss(i.strength,this.parameters.randomness),s=i.noiseType==="perlin";lo.noiseSeed(i.seed);let c=Rh((0,oa.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 Yt(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?lo.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?lo.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 Hu(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Cr.defaultData([1,1,1]).randomnessObject,a=i.noiseType==="perlin";lo.noiseSeed(i.seed);let s=_l((0,oa.default)(i.seed)),c=ss(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 ra)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(_=>_[0]).reduce((_,P)=>_+P,0),w=g.map(_=>_[1]).reduce((_,P)=>_+P,0),b=g.map(_=>_[2]).reduce((_,P)=>_+P,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=t0(l);if(u.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new Pl(this.objectForSample).build(),h=Jg[t.axis],y=this.children;m.setRandomGenerator((0,oa.default)(this.object.uuid+t.seed));for(let[g,x]of y.entries()){let S=g*(i.freqScale/10)+i.movement,w=a?lo.noise(S):s(S,S),b=g+1,_=c(b,xe(w,i.rotation[0])),P=c(b,xe(w,i.rotation[1])),v=c(b,xe(w,i.rotation[2]));t.spreadType==="random"?m.sample(ls,Wu):(f.length&&(ls.fromArray(f[g].pos),Wu.fromArray(f[g].norm)),this.objectForSample instanceof xn&&ls.applyMatrix4(nC.copy(this.objectForSample.matrixWorld).invert())),ls.applyMatrix4(this.object.hiddenMatrix.clone().invert()),x.position.copy(ls),Fo.fromArray(h);let N=t.align==="normal"?Wu:this.object.getWorldDirection(sC),T=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(Fo)),O=aC.crossVectors(Fo,N).normalize(),A=iC.makeRotationAxis(O,C),M=N.clone().cross(this.object.up).normalize(),E=M.clone().cross(N).normalize(),X=new wn().makeBasis(M,N,E),R=new Yt(Fo.y,Fo.z,Fo.x).normalize(),Z=R.clone().cross(Fo).normalize(),z=new wn().makeBasis(R,Fo,Z).invert(),V=new wn().multiplyMatrices(X,z);x.rotation.setFromRotationMatrix(V),T.applyMatrix4(A),x.position.add(T),x.rotation.x=x.rotation.x+o.x+_,x.rotation.y=x.rotation.y+o.y+P,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=e0[e],i=m0[o],a=p0[o],s=f0[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);d0.fromArray(d).applyMatrix4(t.matrixWorld),u0.fromArray(p),c.push({pos:d0.toArray(),norm:u0.toArray()})}return c}else return(this.objectForSample.geometry.index?r0(this.objectForSample.geometry):o0(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 vt?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 cN,Vector3 as dN,Matrix4 as uN,Box3 as pN,MeshBasicMaterial as fN,Skeleton as mN}from"three";import{Camera as vC,OrthographicCamera as bC,PerspectiveCamera as SC,Vector3 as vr,Object3D as x0,Quaternion as wC,Matrix4 as _C}from"three";import{Camera as fC,LineSegments as mC,BufferGeometry as hC,LineBasicMaterial as yC,Color as $u,Vector3 as gC,Float32BufferAttribute as y0}from"three";import{BoxGeometry as lC}from"three";var Ur=n=>{var r;return r=class extends n{},r.geometryHelper=new lC(30,30,30),r};import{Ray as cC,Sphere as dC,Matrix4 as uC,Vector3 as co}from"three";var mc=new cC,qu=new dC,h0=new uC,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||(h0.copy(a).invert(),mc.copy(e.ray).applyMatrix4(h0),i.boundingBox!==null&&mc.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,mc,p,c,u,l),s){s.faceIndex=Math.floor(m/3),t.push(s);return}}else{let x=i.attributes.position,S=new co,w=new co,b=new co,_=new co,P=2,N=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=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+=P){if(S.fromBufferAttribute(x,A),w.fromBufferAttribute(x,A+1),mc.distanceSqToSegment(S,w,_,b)>T)continue;_.applyMatrix4(n.matrixWorld);let X=e.ray.origin.distanceTo(_);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,_,P){let v=new co,N=new co,T=new co,C=new co,O=new co;if(v.fromBufferAttribute(w,b),N.fromBufferAttribute(w,_),T.fromBufferAttribute(w,P),S.intersectTriangle(v,N,T,!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 hc=new gC,tr=new fC,Yu=class extends mC{constructor(e){let t=new hC,o=new yC({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],a=[],s={},c=new $u(15711266),u=new $u(15711266),l=new $u(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 y0(i,3)),t.setAttribute("color",new y0(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;tr.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,tr,-i,-a,s),xr("n2",t,e,tr,i,-a,s),xr("n3",t,e,tr,-i,a,s),xr("n4",t,e,tr,i,a,s);let c=s;xr("f1",t,e,tr,-i,-a,c),xr("f2",t,e,tr,i,-a,c),xr("f3",t,e,tr,-i,a,c),xr("f4",t,e,tr,i,a,c);let u=c,l=.5;xr("u1",t,e,tr,i*.7*l,a*1.1,u),xr("u2",t,e,tr,-i*.7*l,a*1.1,u),xr("u3",t,e,tr,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){hc.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],hc.x,hc.y,hc.z)}}var yc=class extends Ur(Yu){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 g0,BoxGeometry as xC}from"three";var gc;(r=>r.is=e=>"objectHelper"in e)(gc||(gc={}));var Wr=(n,r)=>class extends mi(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 g0&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof xC?(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 g0&&(i.visible=!1)}}};var xc=790,ia=new vr,Xu=new vr,Ku=new wC,Zu=new vr,cs=new vr,Qu=new vr,uo=class extends Wr(vC,yc){constructor(e="",t={...Qo.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Oo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new _C,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;this.orthoCamera=new bC(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4),this.perspCamera=new SC(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(ia),this.targetOffset=ia.distanceTo(e)}getTarget(e=new vr){return this.getWorldDirection(Xu),this.getWorldPosition(ia),Xu.multiplyScalar(this.targetOffset),e.copy(ia).add(Xu),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(ia),ia.distanceTo(e)}updateUp(){this.getWorldQuaternion(Ku),Zu.set(0,0,1).applyQuaternion(Ku),cs.copy(x0.DEFAULT_UP),this.isUpVectorFlipped&&cs.negate(),cs.applyQuaternion(Ku),Qu.copy(x0.DEFAULT_UP).projectOnPlane(Zu),this.angleOffsetFromUp=Qu.angleTo(cs),this.angleOffsetFromUp*=Qu.cross(cs).dot(Zu)>=0?1:-1}updateTransformState(e){let t=super.updateTransformState(e);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),t}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=-xc*.5*i,this.right=xc*.5*i,this.top=xc*.5*(1/a),this.bottom=-xc*.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 v0,Matrix4 as b0,Float32BufferAttribute as PC}from"three";var aa=new b0,TC=new b0;var rr=class extends jt{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new v0;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 rr&&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 vt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0){if(aa.multiplyMatrices(a.hiddenMatrix,a.matrix),a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Zt.getMeshSet(a.geometry,e===!0,t)),a.booleanMeshSetAddress===-1)return;Zt.transformMeshSet(a.booleanMeshSetAddress,aa),a.booleanMatrixInvOld.copy(aa).invert(),a.booleanWasTransformed=!1}else a instanceof rr&&a.needsTransformForDownstream===!0?(Zt.transformMeshSet(a.booleanMeshSetAddress,aa),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Zt.transformMeshSet(a.booleanMeshSetAddress,TC.multiplyMatrices(aa,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(aa).invert(),a.booleanWasTransformed=!1);Zt.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 PC([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Zt.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new v0,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Zt.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,Ji(this),ea(this)}dispose(){super.dispose(),this.geometry.dispose()}};import{Light as OC}from"three";var S0;(r=>{function n(e){return Oe.is(e)&&e instanceof OC}r.is=n})(S0||(S0={}));var sa=(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 ko=n=>n instanceof vt,la=n=>n!==null&&n instanceof rr;var ds=n=>gc.is(n);import{Group as CC}from"three";import{AxesHelper as AC}from"three";var qr=class extends Ur(AC){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 _n=class extends Wr(CC,qr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};import{Color as kC,Fog as UC,HemisphereLight as HC}from"three";import{ShaderChunk as us}from"three";var NC=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
- `,_C=na.lights_fragment_begin,PC=na.shadowmask_pars_fragment,h0=null,TC=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},y0=(n="medium")=>{if(h0===n)return!1;h0=n;let r=TC(n);na.shadowmap_pars_fragment=wC(r);let e=_C.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 ]"),na.lights_fragment_begin=e;let t=PC.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),na.shadowmask_pars_fragment=t,!0};import{DirectionalLight as IC,CameraHelper as g0}from"three";import{DirectionalLightHelper as OC}from"three";var ts=class extends kr(OC){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Ur(this.object,ts.geometryHelper,e,t)}};import{PointLightHelper as AC}from"three";var rs=class extends kr(AC){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Ur(this.object,rs.geometryHelper,e,t)}};import{SpotLightHelper as CC,Vector3 as NC}from"three";var pc=class extends kr(CC){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Ur(this.object,pc.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=pc._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 s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},ia=pc;ia._vector=new NC;function MC(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 os=class extends es(IC,ts){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 s=new g0(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s}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),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&&MC(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 VC}from"three";import{SpotLight as EC,CameraHelper as x0,MathUtils as LC,Vector3 as w0,Quaternion as DC}from"three";var v0=new w0,b0=new w0,S0=new DC,ns=class extends es(EC,ia){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=LC.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new x0(this.shadow.camera);s.visible=!1,this.gizmos.shadowmap=s,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let r in this.gizmos){let e=this.gizmos[r];e instanceof x0&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),b0.setFromMatrixPosition(this.matrixWorld),S0.setFromRotationMatrix(this.matrixWorld),v0.copy(this.up).applyQuaternion(S0).negate().multiplyScalar(this.distance),this.target.position.copy(b0).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 zo=class extends ai(VC){constructor(e,t){super();this.data=t;this.bgColor=new ot(1,1,1,1);this.fog=null;this.backupFog=new RC(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new BC;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new co(wo,{...Yo.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new GC(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=wt(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 jt)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&&y0(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=wt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=wt(e.aoColor,t))}updateByOp(e,t,o,i){super.updateByOp(e,t,o,i);let s=t;_t(e.path,["fog"])?this.updateFog(s.fog,o.shared):_t(e.path,["ao"])?this.updateAo(s.ao,o.shared):_t(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):_t(e.path,["shadow"])&&this.updateShadow(s.shadow)}updateState(e,t){this.updateState_Entity(e,t),e.backgroundColor!==void 0&&this.setBackgroundColor(wt(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 os&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof ns&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+t]=o.data.penumbraSize,t+=1)})}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Te.is(s)&&(s.visible||a?.object.data.visible)&&((Vo(s)||ra(s)&&this.scene.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),aa(s,e,t,!0)),o(s))}};return o(this),t}};import{PointLight as zC,Vector3 as fc,Box3 as jC,Box3Helper as _0,Color as FC}from"three";var mc=class extends es(zC,rs){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 s=new fc(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),a=new fc(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new jC(s,a),d=new _0(c,new FC(16755200));d.visible=!1,this.gizmos.shadowmap=d,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 _0){let t=this.shadow.camera,o=new fc(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new fc(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 hc=class extends Qe{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?zs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var is=class extends Qe{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,t;if(e.type==="Custom"){let i=e.shapeId;if(i!==this._shapeId&&this.detachShape(),i){this._shapeId=i;let s=this._context.scene.find(i);s?.data&&(s.attachedPaths.add(this),t=s.geometry.userData?.shape),t||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let i;switch(e.type){case"Rectangle":i=Vl;break;case"Ellipse":i=hi;break;case"Polygon":i=Gl;break;case"Star":i=zl;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){return super.updateTransformState(e)}updateGeometryInteractions(e,t){super.updateGeometryInteractions(e,t),this.updateShape()}updateEntityBoxSize(e,t){let o=this.geometry.getAttribute("position");o!==void 0?zs(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 kC,Matrix4 as UC,Skeleton as HC}from"three";var uo=class extends Hr(kC,Wr){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=t.scene.data.objects.get(e.component);if(o){let i,s;for(let a of Cr.rootOverrideProps)e[a]===void 0?(i===void 0&&(i={...e}),i[a]=o.data[a]):(s===void 0&&(s={}),s[a]=e[a],i===void 0&&(i={...e}),i[a]=wr.apply(o.data[a],e[a]));return this.overrideData=s,i}else return{...gt.defaultData,...e,...nr(gt.defaultData,Cr.rootOverrideProps)}}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i){if(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component)for(let a of Cr.rootOverrideProps)a in e.props&&e.props[a]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[a]=this.component.data[a]);else if(e.type===0&&e.path.length>0&&Cr.rootOverrideProps.includes(e.path[0])){let a=e.path[0];s===void 0&&(s={...e,path:[],props:{[a]:t[a]}})}}super.updateByOp(s??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 s=0;for(let a of this.children)if(Te.is(a))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),yc(a),s+=1;else break;this.children.splice(0,s)}i=!0}if(o){let s={};T0(e,[this.uuid],t.overrides,this,o,o,0,i,s);for(let a of this.children)if(Te.is(a)){let c=a.data;c.type==="Empty"&&c.animations&&a.traverseEntity(d=>{if(d instanceof Qe&&d.isSkinnedMesh){let l=d.dataPatched;if(l.bones&&l.boneInverses){let u=l.bones.map(m=>e.scene.find(s[m])),p=l.boneInverses.map(m=>new UC().fromArray(m)),f=new HC(u,p);d.bind(f,d.bindMatrix)}}else d.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function yc(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)&&yc(e)}}function P0(n,r,e,t){return n.component===r&&us(n.identity,t)?n.overrideData===e?2:1:0}function T0(n,r,e,t,o,i,s,a,c){if(s>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 uo&&o.isInstanceRoot&&o.expandInstanceChildren(n);let d=0;for(let l of o.children)if(Te.is(l)){let u=[...r,...typeof l.identity=="string"?[l.identity]:l.identity],p=ei.resolve(e,u,1);if(p!=null&&!(p instanceof Re)){if(Object.setPrototypeOf(p,Re.prototype),!1)debugger;console.error("wrong prototype")}let f=null,m;if(!a){let h=t.children[d];if(f=Te.is(h)?h:null,f!==null){let y=P0(f,l,p,u);m=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=n.scene.findInstance(u)??null,f!==null)){let y=P0(f,l,p,u);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(d,0,f),f.parent===t?(g<=d&&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?wr.apply(l.data,p):l.data;ir.is(h.type)&&(h={...h,type:"Empty"}),f=ar.createEntity(u,h,n),f.overrideData=p,t.add(f),t.children.splice(t.children.length-1,1),t.children.splice(d,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}d+=1,T0(n,r,e,f,l,i,s+1,a,c)}if(!a){let l=d;for(;;){let u=t.children[d];if(Te.is(u))n.pendingDeletes.add(u);else break;d+=1}t.children.splice(l,d-l)}return!0}import{Bone as WC}from"three";var gc=class extends Hr(WC,Wr){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(r,e){this.updateState_Entity(r,e)}};function qC(n,r,e){let t;return r.geometry.type==="TextGeometry"?new Xi(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new fn(n,r,e):r.geometry.type==="PathGeometry"?t=new is(n,r,e):r.geometry.type==="VectorGeometry"?t=new hc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new rr(n,r,e):t=new Qe(n,r,e),t)}function xc(n,r,e){return r.type==="Mesh"?qC(n,r,e):r.type==="Empty"?new oa(n,r):r.type==="Bone"?new gc(n,r):r.type==="Page"?new zo(n,r):r.type==="PointLight"?new mc(n,r,e):r.type==="SpotLight"?new ns(n,r,e):r.type==="DirectionalLight"?new os(n,r,e):r.type==="Component"||r.type==="Instance"?new uo(n,r,e):ir.is(r.type)?new co(n,r):(console.error(r),new oa(n,r))}ar.createEntity=xc;function $C(n,r,e){let t=xc(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,a=n.component,c=n.instances,d=n.overrideData,l=n.uuid,u=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=s,n.component=a,n.instances=c,n.uuid=l,n.overrideData=d,n.updateState(n.data,e),u&&n.changeSelectedState(u,e),n.resetBBoxNeedsUpdate()}ar.changeEntityProptotype=$C;ar.Cloner=Zi;function O0(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as KC,Ray as ZC,Raycaster as QC}from"three";function A0(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,$i(n),qi(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof jt&&n.needsAO&&n.layers.enable(5),e}function C0(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 N0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof jt)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)A0(e,e.material[t])&&(r=!0);else A0(e,e.material)&&(r=!0)}),r}function I0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof jt)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)C0(e,e.material[t])&&(r=!0);else C0(e,e.material)&&(r=!0)}),r}var JC=new QC,eN=new KC,tN=new ZC;function aa(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=eN.copy(i.matrixWorld).invert(),a=tN.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;a.applyMatrix4(c);let d=JC;d.set(a.origin,a.direction),d.near=r.near,d.far=r.far;let l=d.intersectObject(n,!1);l.length>0&&e.push({...l[0],object:t?i:n})}}var vc=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],s=t;for(;this._constraints.has(s);)s=this._constraints.get(s),e.has(s)||i.push(s);for(let a=i.length-2;a>=0;a--)if(!e.has(i[a])){let c=r.find(i[a]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[a]}`),e.add(i[a])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var lN=new sN;lN.wireframe=!0;var M0=new oN,bc=class extends rN{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 vc;this.errorPage=new zo("fdasfa",{...Jr.defaultData,name:""});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=I0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=N0(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 zo&&(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 s=i;i=i.parent;let a=i.children.indexOf(s);o.splice(0,0,a)}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)=>Zd(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===wo)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}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(),Vo(i)&&ta(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),ta(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Vo(o)&&(o.freeBooleanPointer(),i instanceof rr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof is&&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 s=e.parent===null?this:this.find(e.parent);if(s===void 0)throw new Error("unexpected");s.add(o),this.markNeedsRecomputeInstancesForAncessors(s),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let a=e.localIndex;s.children.splice(a,0,s.children.pop()),Vo(o)&&(o.invalidateUpstreamBooleanData(),ta(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof rr&&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 zo&&(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:a}=t.props;t={...t,props:a},this.markNeedsRecomputeInstances()}t.path[0]==="pathSnapping"&&t.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,t.props.pathId)}let s=this.find(e);if(s)try{O0(s,t,o,{scene:this,shared:i}),s instanceof Qe&&s.updateGeometryGroupsIfNeeded()}catch(a){console.error(a)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}init(e,t){this.createChildrenObjects(e.objects,this,t),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(t,!0),this.traverseEntity(o=>{ta(o)&&o.recomputeBoolean(),o instanceof co&&o.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,s,a,c){if(e){let d=i.find(e);d&&d!==i&&s.forInstancesRec(l=>{l.data=Yn(l.data,u=>{let p=u.events.data(c.id),f=l.goUp(a);if(f){let m=[...ca(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=Tt.zoom(p,t);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,t,o,i,s,a){e.forEach(c=>{c.data.type==="Transition"?this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a):c.data.type==="Animation"&&this.relativeizeInner(c.data.object,[...t,c.id],"object",o,i,s,a)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof uo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{if(i.data.type==="GameControl"){let s=!1;if(t.forInstancesRec(a=>{a.data=Yn(a.data,c=>{a.isInstanceRoot||(c.events.delete(i.id),s=!0)}).data}),s===!1)for(let a of fl.list)this.rewriteActions(i.data.gameActions[a],["gameActions",a],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(s=>{if(s instanceof uo&&s.isInstanceRoot)return s.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),t||s.resetBBoxNeedsUpdate(),o&&s.traverseEntity(a=>{o.addClip(a)}),!0});for(let s of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),yc(s)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof uo&&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=s=>{for(let a of s.children){let c=a.cloner;if(Te.is(a)&&!a.raycastLock&&(a.visible||c?.object.data.visible))if(t===!0&&a.isInstanceRoot){let d=[];if(e.intersectObject(a,!0,d),d.length){let l=d[0];l.object=a,l.point.applyMatrix4(l.object.matrixWorld);let u=a.matrixWorld.clone().invert();l.point.applyMatrix4(u),o.push(l)}}else(Vo(a)||ra(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,o),aa(a,e,o)),i(a)}};return i(this),o}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let a=s.cloner;Te.is(s)&&(s.visible||a?.object.data.visible)&&((Vo(s)||ra(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),aa(s,e,t,!0)),o(s))}};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)}traverseObject(e){for(let t of this.children)oi.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 s of e)this.createObject(s.id,s.data,s.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,s,a){let c={scene:this,shared:a},d=xc(e,t,c);return d&&(this.entityByUuid[e]=d,i.add(d),i.children.splice(s,0,i.children.pop()),o.length>0&&(d.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,d,a)),d.updateState(t,c),d instanceof Qe&&d.updateGeometryGroupsIfNeeded(),d.updateVisible(),d.cloner&&this.toExpandCloner.add(d),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),t.type==="Empty"&&t.animations&&d.traverseEntity(l=>{if(l instanceof Qe&&l.isSkinnedMesh){let u=l.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(h=>this.find(h)),f=u.boneInverses.map(h=>new nN().fromArray(h)),m=new aN(p,f);l.bind(m,l.bindMatrix)}}else l.matrixAutoUpdate=!0}),d}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:a,recursive:c}=e[i],d=this.find(a),l=c?d.recursiveBBox:d.singleBBox;t.push(...l.vertices)}let o=new iN;return o.setFromPoints(t),o.getCenter(M0),M0}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 vt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof zt&&e(t.material[o]);else t.material instanceof zt&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof co&&i.setViewplaneSize(e,t,o)})}};import{DRACOLoader as cN}from"three/examples/jsm/loaders/DRACOLoader.js";var jo;function uN(){return jo||(jo=new cN,jo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),jo.decoderPending}async function dN(n){if(jo){let r={attributeIDs:jo.defaultAttributeIDs,attributeTypes:jo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await jo.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 E0(n,r){let[e,t]=Dc(Za.deserialize(new Uint8Array(n)));Th(e);let o=[];e.scene.objects.traverse((i,s)=>{s.type==="Mesh"&&s.geometry.type==="NonParametricGeometry"&&s.geometry.data.draco!==void 0&&o.push(s)}),o.length&&await uN();for(let i of o){let s=await dN(Ze(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};s.attributes.forEach(({name:c,array:d,itemSize:l})=>{a[c]={array:d,itemSize:l,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=a,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}import{Mesh as zJ}from"three";import{mergeBufferGeometries as kJ}from"three/examples/jsm/utils/BufferGeometryUtils.js";function L0(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 D0,ShaderLib as pN}from"three";function B0(n){let r=new Set;return n.traverse(e=>{if(e instanceof jt)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(fN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new D0,specularColor:new D0});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},pN.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(a=>{if(i.uniforms.transmissionSamplerMap.value){let c=a.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 mN(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function fN(n){return n.getLayersOfType("transmission").length>0}function mN(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 R0(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function G0(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 s=t;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}import{mergeBufferGeometries as hN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function V0(n){let r=[];return n.traverse(e=>{e instanceof Zi&&r.push(e)}),r.forEach(e=>{let t=e.object,s=[...e.children.map(a=>{a.updateMatrix();let c;if(a.geometry!==void 0)try{c=a.geometry.clone().applyMatrix4(a.matrix)}catch(d){console.error(d)}return c!==void 0&&a.matrix.determinant()<0&&L0(c),c}).filter(a=>a!==void 0)];if(!e.parameters.hideBase&&t instanceof vt&&s.unshift(t.geometry),s.length){let a=hN(s);t instanceof vt&&(t.geometry=a)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Rg})}),n}function z0(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function j0(n){Object.values(n.shared.materials).forEach(r=>{$d(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?$d(e.material):"materials"in e&&e.materials.forEach(t=>{$d(t)})})}function $d(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 W0=ss(k0(),1);function U0(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var H0="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Yd=class extends gN{load(r,e,t,o=console.error){let i=new yN(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(H0+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(H0),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){o(a)}},t,o)}async parse(r){let e=await E0(r,j0);e.version&&(0,W0.default)(e.version,"0.9.440")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([Hg(e)&&Ky(),t0(e)&&Dg()].filter(Boolean));let t=new pn(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new bc(e.scene,t),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=V0(o),o=B0(o),o=R0(o),o=G0(o),o=z0(o),o=U0(o),o}};export{Yd as default};
2593
+ `,IC=us.lights_fragment_begin,MC=us.shadowmask_pars_fragment,w0=null,LC=n=>{switch(n){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},_0=(n="medium")=>{if(w0===n)return!1;w0=n;let r=LC(n);us.shadowmap_pars_fragment=NC(r);let e=IC.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 ]"),us.lights_fragment_begin=e;let t=MC.slice();return t=t.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),us.shadowmask_pars_fragment=t,!0};import{DirectionalLight as GC,CameraHelper as P0}from"three";import{DirectionalLightHelper as EC}from"three";var ca=class extends Ur(EC){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,ca.geometryHelper,e,t)}};import{PointLightHelper as DC}from"three";var da=class extends Ur(DC){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,da.geometryHelper,e,t)}};import{SpotLightHelper as BC,Vector3 as RC}from"three";var vc=class extends Ur(BC){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Hr(this.object,vc.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=vc._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)}}},ps=vc;ps._vector=new RC;function VC(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 ua=class extends sa(GC,ca){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 P0(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 P0&&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&&VC(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 WC}from"three";import{SpotLight as zC,CameraHelper as T0,MathUtils as jC,Vector3 as N0,Quaternion as FC}from"three";var O0=new N0,A0=new N0,C0=new FC,pa=class extends sa(zC,ps){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=jC.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let a=new T0(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 T0&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),A0.setFromMatrixPosition(this.matrixWorld),C0.setFromRotationMatrix(this.matrixWorld),O0.copy(this.up).applyQuaternion(C0).negate().multiplyScalar(this.distance),this.target.position.copy(A0).add(O0),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 Uo=class extends mi(WC){constructor(e,t){super();this.data=t;this.bgColor=new nt(1,1,1,1);this.fog=null;this.backupFog=new UC(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new kC;this.penumbraSizeArrayCache=null;this.super_Entity(e,t),this.personalCamera=new uo(Po,{...Qo.defaultData,...t.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new HC(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=wt(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 jt)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&&_0(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=wt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,t){e.aoColor!==void 0&&(this.aoColor=wt(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(wt(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 ua&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize,e+=1),o instanceof pa&&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;Oe.is(a)&&(a.visible||s?.object.data.visible)&&((ko(a)||ds(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),ms(a,e,t,!0)),o(a))}};return o(this),t}};import{PointLight as qC,Vector3 as bc,Box3 as $C,Box3Helper as I0,Color as YC}from"three";var Sc=class extends sa(qC,da){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 bc(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new bc(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new $C(a,s),u=new I0(c,new YC(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 I0){let t=this.shadow.camera,o=new bc(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new bc(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 wc=class extends Ke{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 fa=class extends Ke{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,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=Wl;break;case"Ellipse":i=wi;break;case"Polygon":i=Hl;break;case"Star":i=ql;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){return super.updateTransformState(e)}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 XC,Matrix4 as KC,Skeleton as ZC}from"three";var po=class extends Wr(XC,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=si.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]=_r.apply(o.data[s],e[s]));return this.overrideData=a,i}else return{...gt.defaultData,...e,...nr(gt.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(Oe.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),_c(s),a+=1;else break;this.children.splice(0,a)}i=!0}if(o){let a={};L0(e,[this.uuid],t.overrides,this,o,o,0,i,a);for(let s of this.children)if(Oe.is(s)){let c=s.data;c.type==="Empty"&&c.animations&&s.traverseEntity(u=>{if(u instanceof Ke&&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 KC().fromArray(m)),f=new ZC(d,p);u.bind(f,u.bindMatrix)}}else u.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function _c(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)Oe.is(e)&&_c(e)}}function M0(n,r,e,t){return n.component===r&&xa(n.identity,t)?n.overrideData===e?2:1:0}function L0(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 po&&o.isInstanceRoot&&o.expandInstanceChildren(n);let u=0;for(let l of o.children)if(Oe.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=Oe.is(h)?h:null,f!==null){let y=M0(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=M0(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?_r.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,L0(n,r,e,f,l,i,a+1,s,c)}if(!s){let l=u;for(;;){let d=t.children[u];if(Oe.is(d))n.pendingDeletes.add(d);else break;u+=1}t.children.splice(l,u-l)}return!0}import{Bone as QC}from"three";var Pc=class extends Wr(QC,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 JC(n,r,e){let t;return r.geometry.type==="TextGeometry"?new ra(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new xn(n,r,e):r.geometry.type==="PathGeometry"?t=new fa(n,r,e):r.geometry.type==="VectorGeometry"?t=new wc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new rr(n,r,e):t=new Ke(n,r,e),t)}function Tc(n,r,e){return r.type==="Mesh"?JC(n,r,e):r.type==="Empty"?new _n(n,r):r.type==="Bone"?new Pc(n,r):r.type==="Page"?new Uo(n,r):r.type==="PointLight"?new Sc(n,r,e):r.type==="SpotLight"?new pa(n,r,e):r.type==="DirectionalLight"?new ua(n,r,e):r.type==="Component"||r.type==="Instance"?new po(n,r,e):ir.is(r.type)?new uo(n,r):(console.error(r),new _n(n,r))}lr.createEntity=Tc;function eN(n,r,e){let t=Tc(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=eN;lr.Cloner=na;function E0(n,r,e,t){n.updateByOp(r,e,t,!1)}import{Matrix4 as oN,Ray as nN,Raycaster as iN}from"three";function D0(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,ea(n),Ji(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof jt&&n.needsAO&&n.layers.enable(5),e}function B0(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 R0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof jt)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)D0(e,e.material[t])&&(r=!0);else D0(e,e.material)&&(r=!0)}),r}function G0(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof jt)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)B0(e,e.material[t])&&(r=!0);else B0(e,e.material)&&(r=!0)}),r}var aN=new iN,sN=new oN,lN=new nN;function ms(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let a=sN.copy(i.matrixWorld).invert(),s=lN.copy(r.ray).applyMatrix4(a),c=n.matrixWorld;s.applyMatrix4(c);let u=aN;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 Oc=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 hN=new fN;hN.wireframe=!0;var V0=new dN,Ac=class extends cN{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 Oc;this.errorPage=new Uo("fdasfa",{...eo.defaultData,name:""});this.invisibleObjects=new _n("jflkdsafjasdifjaslk",{...yl.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=G0(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=R0(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 Uo&&(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)=>np(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(),ko(i)&&la(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),la(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),ko(o)&&(o.freeBooleanPointer(),i instanceof rr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof fa&&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()),ko(o)&&(o.invalidateUpstreamBooleanData(),la(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof rr&&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 Uo&&(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{E0(a,t,o,{scene:this,shared:i}),a instanceof Ke&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}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=>{la(i)&&i.recomputeBoolean(),i instanceof uo&&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){Oe.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Oe.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=xo(l.data,d=>{let p=d.events.data(c.id),f=l.goUp(s);if(f){let m=[...ys(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid,g=Tt.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 po&&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=xo(s.data,c=>{s.isInstanceRoot||(c.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of vl.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 po&&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),_c(a)}recomputeInstances(e,t){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof po&&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)Oe.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(Oe.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(ko(s)||ds(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),ms(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;Oe.is(a)&&(a.visible||s?.object.data.visible)&&((ko(a)||ds(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,t),ms(a,e,t,!0)),o(a))}};return o(this),t}forEachEntity(e){for(let t of this.children)Oe.is(t)&&e(t)}traverseConcreteEntity(e){for(let t of this.children)Oe.is(t)&&t.isConcreteEntity&&t.traverseEntity(e)}traverseEntity(e){for(let t of this.children)Oe.is(t)&&t.traverseEntity(e)}updateFont(e,t){this.traverseEntity(o=>{if(o instanceof Ke&&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();la(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let t of this.children)di.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Oe.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=Tc(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 Ke&&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 Ke&&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 uN().fromArray(h)),m=new mN(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 pN;return o.setFromPoints(t),o.getCenter(V0),V0}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 vt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof zt&&e(t.material[o]);else t.material instanceof zt&&e(t.material)})}updateViewPlaneSize(e,t,o=!1){this.traverseConcreteEntity(i=>{i instanceof uo&&i.setViewplaneSize(e,t,o)})}};import{DRACOLoader as yN}from"three/examples/jsm/loaders/DRACOLoader.js";var Ho;function gN(){return Ho||(Ho=new yN,Ho.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Ho.decoderPending}async function xN(n){if(Ho){let r={attributeIDs:Ho.defaultAttributeIDs,attributeTypes:Ho.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Ho.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]=jc(nl.deserialize(new Uint8Array(n)));wl(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 gN();for(let i of o){let a=await xN(Je(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 gee}from"three";import{mergeBufferGeometries as bee}from"three/examples/jsm/utils/BufferGeometryUtils.js";function j0(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 F0,ShaderLib as vN}from"three";function k0(n){let r=new Set;return n.traverse(e=>{if(e instanceof jt)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(bN(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new F0,specularColor:new F0});let o=0;e.onBeforeCompile=(i,a)=>{t&&t(i,a),i.uniforms=Object.assign({},vN.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=Og(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else SN(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function bN(n){return n.getLayersOfType("transmission").length>0}function SN(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 U0(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function H0(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 wN}from"three/examples/jsm/utils/BufferGeometryUtils.js";function W0(n){let r=[];return n.traverse(e=>{e instanceof na&&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&&j0(c),c}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&t instanceof vt&&a.unshift(t.geometry),a.length){let s=wN(a);t instanceof vt&&(t.geometry=s)}e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:Ug})}),n}function q0(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function $0(n){Object.values(n.shared.materials).forEach(r=>{ep(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?ep(e.material):"materials"in e&&e.materials.forEach(t=>{ep(t)})})}function ep(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 Q0=ma(X0(),1);function K0(n){return n.traverseMaterial(r=>{r.needsJitter=!1}),n}var Z0="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",tp=class extends PN{load(r,e,t,o=console.error){let i=new _N(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(Z0+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(Z0),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,$0);e.version&&(0,Q0.default)(e.version,"0.9.441")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([Zg(e)&&og(),l0(e)&&Fg()].filter(Boolean));let t=new gn(e.shared);Object.values(t.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Ac(e.scene,t),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=W0(o),o=k0(o),o=U0(o),o=H0(o),o=q0(o),o=K0(o),o}};export{tp as default};