@splinetool/loader 0.9.357 → 0.9.360

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- "use strict";var $g=Object.create;var pa=Object.defineProperty;var Xg=Object.getOwnPropertyDescriptor;var Yg=Object.getOwnPropertyNames;var Kg=Object.getPrototypeOf,Zg=Object.prototype.hasOwnProperty;var fa=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),yu=(n,r)=>{for(var e in r)pa(n,e,{get:r[e],enumerable:!0})},gu=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Yg(r))!Zg.call(n,o)&&o!==e&&pa(n,o,{get:()=>r[o],enumerable:!(t=Xg(r,o))||t.enumerable});return n};var ln=(n,r,e)=>(e=n!=null?$g(Kg(n)):{},gu(r||!n||!n.__esModule?pa(e,"default",{value:n,enumerable:!0}):e,n)),Qg=n=>gu(pa({},"__esModule",{value:!0}),n);var qm=fa((Wc,Hm)=>{(function(n,r){typeof Wc=="object"?Hm.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Wc,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 l=r();t=l(" "),o=l(" "),i=l(" ");for(var c=0;c<e.length;c++)t-=l(e[c]),t<0&&(t+=1),o-=l(e[c]),o<0&&(o+=1),i-=l(e[c]),i<0&&(i+=1);l=null;var u=function(){var a=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=a-(s=a|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,s]},u.importState=function(a){t=+a[0]||0,o=+a[1]||0,i=+a[2]||0,s=+a[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 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 Zm=fa((gl,Km)=>{(function(n,r){typeof gl=="object"&&typeof Km<"u"?r(gl):typeof define=="function"&&define.amd?define(["exports"],r):r((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(gl,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,l,c,u,a,d,p,f,m,h,y,g,v=r[0].length,b=r.length;if(b<v)throw new TypeError("Invalid matrix: m < n");for(var w=[],S=[],T=[],_=e==="f"?b:v,x=h=p=0;x<b;x++)S[x]=new Array(_).fill(0);for(x=0;x<v;x++)T[x]=new Array(v).fill(0);var C,P=new Array(v).fill(0);for(x=0;x<b;x++)for(s=0;s<v;s++)S[x][s]=r[x][s];for(x=0;x<v;x++){for(w[x]=p,m=0,c=x+1,s=x;s<b;s++)m+=Math.pow(S[s][x],2);if(m<i)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x]=d-p,s=c;s<v;s++){for(m=0,l=x;l<b;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<b;l++)S[l][s]=S[l][s]+d*S[l][x]}for(P[x]=p,m=0,s=c;s<v;s++)m+=Math.pow(S[x][s],2);if(m<i)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x+1]=d-p,s=c;s<v;s++)w[s]=S[x][s]/f;for(s=c;s<b;s++){for(m=0,l=c;l<v;l++)m+=S[s][l]*S[x][l];for(l=c;l<v;l++)S[s][l]=S[s][l]+m*w[l]}}h<(y=Math.abs(P[x])+Math.abs(w[x]))&&(h=y)}if(t)for(x=v-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,s=c;s<v;s++)T[s][x]=S[x][s]/f;for(s=c;s<v;s++){for(m=0,l=c;l<v;l++)m+=S[x][l]*T[l][s];for(l=c;l<v;l++)T[l][s]=T[l][s]+m*T[l][x]}}for(s=c;s<v;s++)T[x][s]=0,T[s][x]=0;T[x][x]=1,p=w[x],c=x}if(e){if(e==="f")for(x=v;x<b;x++){for(s=v;s<b;s++)S[x][s]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(c=x+1,p=P[x],s=c;s<_;s++)S[x][s]=0;if(p!==0){for(f=S[x][x]*p,s=c;s<_;s++){for(m=0,l=c;l<b;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<b;l++)S[l][s]=S[l][s]+d*S[l][x]}for(s=x;s<b;s++)S[s][x]=S[s][x]/p}else for(s=x;s<b;s++)S[s][x]=0;S[x][x]=S[x][x]+1}}for(o*=h,l=v-1;0<=l;l--)for(var N=0;N<50;N++){for(C=!1,c=l;0<=c;c--){if(Math.abs(w[c])<=o){C=!0;break}if(Math.abs(P[c-1])<=o)break}if(!C){for(a=0,u=c-(m=1),x=c;x<l+1&&(d=m*w[x],w[x]=a*w[x],!(Math.abs(d)<=o));x++)if(p=P[x],P[x]=Math.sqrt(d*d+p*p),a=p/(f=P[x]),m=-d/f,e)for(s=0;s<b;s++)y=S[s][u],g=S[s][x],S[s][u]=y*a+g*m,S[s][x]=-y*m+g*a}if(g=P[l],c===l){if(g<0&&(P[l]=-g,t))for(s=0;s<v;s++)T[s][l]=-T[s][l];break}for(h=P[c],d=(((y=P[l-1])-g)*(y+g)+((p=w[l-1])-(f=w[l]))*(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,x=c+(m=a=1);x<l+1;x++){if(p=w[x],y=P[x],f=m*p,p*=a,g=Math.sqrt(d*d+f*f),d=h*(a=d/(w[x-1]=g))+p*(m=f/g),p=-h*m+p*a,f=y*m,y*=a,t)for(s=0;s<v;s++)h=T[s][x-1],g=T[s][x],T[s][x-1]=h*a+g*m,T[s][x]=-h*m+g*a;if(g=Math.sqrt(d*d+f*f),d=(a=d/(P[x-1]=g))*p+(m=f/g)*y,h=-m*p+a*y,e)for(s=0;s<b;s++)y=S[s][x-1],g=S[s][x],S[s][x-1]=y*a+g*m,S[s][x]=-y*m+g*a}w[c]=0,w[l]=d,P[l]=h}for(x=0;x<v;x++)P[x]<o&&(P[x]=0);return{u:S,q:P,v:T}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var Ey=fa(Xl=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var a=this||r;return a._counter=1e3,a._html5AudioPool=[],a.html5PoolSize=10,a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator=typeof window<"u"&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.autoUnlock=!0,a._setup(),a},volume:function(a){var d=this||r;if(a=parseFloat(a),d.ctx||u(),typeof a<"u"&&a>=0&&a<=1){if(d._volume=a,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a,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*a)}return d}return d._volume},mute:function(a){var d=this||r;d.ctx||u(),d._muted=a,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a?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=a?!0:h._muted)}return d},stop:function(){for(var a=this||r,d=0;d<a._howls.length;d++)a._howls[d].stop();return a},unload:function(){for(var a=this||r,d=a._howls.length-1;d>=0;d--)a._howls[d].unload();return a.usingWebAudio&&a.ctx&&typeof a.ctx.close<"u"&&(a.ctx.close(),a.ctx=null,u()),a},codecs:function(a){return(this||r)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||r;if(a.state=a.ctx&&a.ctx.state||"suspended",a._autoSuspend(),!a.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(a._canPlayEvent="canplay")}catch{a.noAudio=!0}else a.noAudio=!0;try{var d=new Audio;d.muted&&(a.noAudio=!0)}catch{}return a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return a}if(!d||typeof d.canPlayType!="function")return a;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=a._navigator?a._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\/(.*?) /),v=y&&g&&parseInt(g[1],10)<15;return a._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:!!(!v&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&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$/,"")},a},_unlockAudio:function(){var a=this||r;if(!(a._audioUnlocked||!a.ctx)){a._audioUnlocked=!1,a.autoUnlock=!1,!a._mobileUnloaded&&a.ctx.sampleRate!==44100&&(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var d=function(p){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,a._releaseHtml5Audio(f)}catch{a.noAudio=!0;break}for(var m=0;m<a._howls.length;m++)if(!a._howls[m]._webAudio)for(var h=a._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=a._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}a._autoResume();var v=a.ctx.createBufferSource();v.buffer=a._scratchBuffer,v.connect(a.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof a.ctx.resume=="function"&&a.ctx.resume(),v.onended=function(){v.disconnect(0),a._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var b=0;b<a._howls.length;b++)a._howls[b]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),a}},_obtainHtml5Audio:function(){var a=this||r;if(a._html5AudioPool.length)return a._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(a){var d=this||r;return a._unlocked&&d._html5AudioPool.push(a),d},_autoSuspend:function(){var a=this;if(!(!a.autoSuspend||!a.ctx||typeof a.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<a._howls.length;d++)if(a._howls[d]._webAudio){for(var p=0;p<a._howls[d]._sounds.length;p++)if(!a._howls[d]._sounds[p]._paused)return a}return a._suspendTimer&&clearTimeout(a._suspendTimer),a._suspendTimer=setTimeout(function(){if(!!a.autoSuspend){a._suspendTimer=null,a.state="suspending";var f=function(){a.state="suspended",a._resumeAfterSuspend&&(delete a._resumeAfterSuspend,a._autoResume())};a.ctx.suspend().then(f,f)}},3e4),a}},_autoResume:function(){var a=this;if(!(!a.ctx||typeof a.ctx.resume>"u"||!r.usingWebAudio))return a.state==="running"&&a.ctx.state!=="interrupted"&&a._suspendTimer?(clearTimeout(a._suspendTimer),a._suspendTimer=null):a.state==="suspended"||a.state==="running"&&a.ctx.state==="interrupted"?(a.ctx.resume().then(function(){a.state="running";for(var d=0;d<a._howls.length;d++)a._howls[d]._emit("resume")}),a._suspendTimer&&(clearTimeout(a._suspendTimer),a._suspendTimer=null)):a.state==="suspending"&&(a._resumeAfterSuspend=!0),a}};var r=new n,e=function(a){var d=this;if(!a.src||a.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(a)};e.prototype={init:function(a){var d=this;return r.ctx||u(),d._autoplay=a.autoplay||!1,d._format=typeof a.format!="string"?a.format:[a.format],d._html5=a.html5||!1,d._muted=a.mute||!1,d._loop=a.loop||!1,d._pool=a.pool||5,d._preload=typeof a.preload=="boolean"||a.preload==="metadata"?a.preload:!0,d._rate=a.rate||1,d._sprite=a.sprite||{},d._src=typeof a.src!="string"?a.src:[a.src],d._volume=a.volume!==void 0?a.volume:1,d._xhr={method:a.xhr&&a.xhr.method?a.xhr.method:"GET",headers:a.xhr&&a.xhr.headers?a.xhr.headers:null,withCredentials:a.xhr&&a.xhr.withCredentials?a.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=a.onend?[{fn:a.onend}]:[],d._onfade=a.onfade?[{fn:a.onfade}]:[],d._onload=a.onload?[{fn:a.onload}]:[],d._onloaderror=a.onloaderror?[{fn:a.onloaderror}]:[],d._onplayerror=a.onplayerror?[{fn:a.onplayerror}]:[],d._onpause=a.onpause?[{fn:a.onpause}]:[],d._onplay=a.onplay?[{fn:a.onplay}]:[],d._onstop=a.onstop?[{fn:a.onstop}]:[],d._onmute=a.onmute?[{fn:a.onmute}]:[],d._onvolume=a.onvolume?[{fn:a.onvolume}]:[],d._onrate=a.onrate?[{fn:a.onrate}]:[],d._onseek=a.onseek?[{fn:a.onseek}]:[],d._onunlock=a.onunlock?[{fn:a.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 a=this,d=null;if(r.noAudio){a._emit("loaderror",null,"No audio support.");return}typeof a._src=="string"&&(a._src=[a._src]);for(var p=0;p<a._src.length;p++){var f,m;if(a._format&&a._format[p])f=a._format[p];else{if(m=a._src[p],typeof m!="string"){a._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=a._src[p];break}}if(!d){a._emit("loaderror",null,"No codec support for selected audio sources.");return}return a._src=d,a._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(a._html5=!0,a._webAudio=!1),new t(a),a._webAudio&&i(a),a},play:function(a,d){var p=this,f=null;if(typeof a=="number")f=a,a=null;else{if(typeof a=="string"&&p._state==="loaded"&&!p._sprite[a])return null;if(typeof a>"u"&&(a="__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?a=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!a&&(a=y._sprite||"__default"),p._state!=="loaded"){y._sprite=a,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 v=Math.max(0,y._seek>0?y._seek:p._sprite[a][0]/1e3),b=Math.max(0,(p._sprite[a][0]+p._sprite[a][1])/1e3-v),w=b*1e3/Math.abs(y._rate),S=p._sprite[a][0]/1e3,T=(p._sprite[a][0]+p._sprite[a][1])/1e3;y._sprite=a,y._ended=!1;var _=function(){y._paused=!1,y._seek=v,y._start=S,y._stop=T,y._loop=!!(y._loop||p._sprite[a][2])};if(v>=T){p._ended(y);return}var x=y._node;if(p._webAudio){var C=function(){p._playLock=!1,_(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(A,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,v,86400):x.bufferSource.noteGrainOn(0,v,b):y._loop?x.bufferSource.start(0,v,86400):x.bufferSource.start(0,v,b),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"?C():(p._playLock=!0,p.once("resume",C),p._clearTimer(y._id))}else{var P=function(){x.currentTime=v,x.muted=y._muted||p._muted||r._muted||x.muted,x.volume=y._volume*r.volume(),x.playbackRate=y._rate;try{var A=x.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,_(),A.then(function(){p._playLock=!1,x._unlocked=!0,d?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):d||(p._playLock=!1,_(),p._emit("play",y._id)),x.playbackRate=y._rate,x.paused){p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}a!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),x.removeEventListener("ended",p._endTimers[y._id],!1)},x.addEventListener("ended",p._endTimers[y._id],!1))}catch(R){p._emit("playerror",y._id,R)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var N=window&&window.ejecta||!x.readyState&&r._navigator.isCocoonJS;if(x.readyState>=3||N)P();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",P(),x.removeEventListener(r._canPlayEvent,O,!1)};x.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(a){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(a)}}),d;for(var p=d._getSoundIds(a),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(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(a)}}),p;for(var f=p._getSoundIds(a),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(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(a,d)}}),p;if(typeof d>"u")if(typeof a=="boolean")p._muted=a;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=a,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(a?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:a),p._emit("mute",h._id))}return p},volume:function(){var a=this,d=arguments,p,f;if(d.length===0)return a._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=a._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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"volume",action:function(){a.volume.apply(a,d)}}),a;typeof f>"u"&&(a._volume=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)y=a._soundById(f[g]),y&&(y._volume=p,d[2]||a._stopFade(f[g]),a._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),a._emit("volume",y._id))}else return y=f?a._soundById(f):a._sounds[0],y?y._volume:0;return a},fade:function(a,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(a,d,p,f)}}),m;a=Math.min(Math.max(0,parseFloat(a)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(a,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 v=r.ctx.currentTime,b=v+p/1e3;g._volume=a,g._node.gain.setValueAtTime(a,v),g._node.gain.linearRampToValueAtTime(d,b)}m._startFadeInterval(g,a,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(a,d,p,f,m,h){var y=this,g=d,v=p-d,b=Math.abs(v/.01),w=Math.max(4,b>0?f/b:f),S=Date.now();a._fadeTo=p,a._interval=setInterval(function(){var T=(Date.now()-S)/f;S=Date.now(),g+=v*T,g=Math.round(g*100)/100,v<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?a._volume=g:y.volume(g,a._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(a._interval),a._interval=null,a._fadeTo=null,y.volume(p,a._id),y._emit("fade",a._id))},w)},_stopFade:function(a){var d=this,p=d._soundById(a);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,a),p._fadeTo=null,d._emit("fade",a)),d},loop:function(){var a=this,d=arguments,p,f,m;if(d.length===0)return a._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],a._loop=p;else return m=a._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=a._getSoundIds(f),y=0;y<h.length;y++)m=a._soundById(h[y]),m&&(m._loop=p,a._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,a.playing(h[y])&&(a.pause(h[y],!0),a.play(h[y],!0)))));return a},rate:function(){var a=this,d=arguments,p,f;if(d.length===0)f=a._sounds[0]._id;else if(d.length===1){var m=a._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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"rate",action:function(){a.rate.apply(a,d)}}),a;typeof f>"u"&&(a._rate=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=a._soundById(f[g]),y){a.playing(f[g])&&(y._rateSeek=a.seek(f[g]),y._playStart=a._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,a._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var v=a.seek(f[g]),b=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,w=b*1e3/Math.abs(y._rate);(a._endTimers[f[g]]||!y._paused)&&(a._clearTimer(f[g]),a._endTimers[f[g]]=setTimeout(a._ended.bind(a,y),w)),a._emit("rate",y._id)}}else return y=a._soundById(f),y?y._rate:a._rate;return a},seek:function(){var a=this,d=arguments,p,f;if(d.length===0)a._sounds.length&&(f=a._sounds[0]._id);else if(d.length===1){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):a._sounds.length&&(f=a._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"&&(a._state!=="loaded"||a._playLock))return a._queue.push({event:"seek",action:function(){a.seek.apply(a,d)}}),a;var y=a._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=a.playing(f);g&&a.pause(f,!0),y._seek=p,y._ended=!1,a._clearTimer(f),!a._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var v=function(){g&&a.play(f,!0),a._emit("seek",f)};if(g&&!a._webAudio){var b=function(){a._playLock?setTimeout(b,0):v()};setTimeout(b,0)}else v()}else if(a._webAudio){var w=a.playing(f)?r.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+w*Math.abs(y._rate))}else return y._node.currentTime;return a},playing:function(a){var d=this;if(typeof a=="number"){var p=d._soundById(a);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(a){var d=this,p=d._duration,f=d._soundById(a);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var a=this,d=a._sounds,p=0;p<d.length;p++)d[p]._paused||a.stop(d[p]._id),a._webAudio||(a._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,a._clearTimer(d[p]._id);var f=r._howls.indexOf(a);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===a._src||a._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[a._src],r.noAudio=!1,a._state="unloaded",a._sounds=[],a=null,null},on:function(a,d,p,f){var m=this,h=m["_on"+a];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(a,d,p){var f=this,m=f["_on"+a],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(a)f["_on"+a]=[];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(a,d,p){var f=this;return f.on(a,d,p,1),f},_emit:function(a,d,p){for(var f=this,m=f["_on"+a],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||a==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(a,m[h].fn,m[h].id));return f._loadQueue(a),f},_loadQueue:function(a){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===a&&(d._queue.shift(),d._loadQueue()),a||p.action()}return d},_ended:function(a){var d=this,p=a._sprite;if(!d._webAudio&&a._node&&!a._node.paused&&!a._node.ended&&a._node.currentTime<a._stop)return setTimeout(d._ended.bind(d,a),100),d;var f=!!(a._loop||d._sprite[p][2]);if(d._emit("end",a._id),!d._webAudio&&f&&d.stop(a._id,!0).play(a._id),d._webAudio&&f){d._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=r.ctx.currentTime;var m=(a._stop-a._start)*1e3/Math.abs(a._rate);d._endTimers[a._id]=setTimeout(d._ended.bind(d,a),m)}return d._webAudio&&!f&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,d._clearTimer(a._id),d._cleanBuffer(a._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(a._id,!0),d},_clearTimer:function(a){var d=this;if(d._endTimers[a]){if(typeof d._endTimers[a]!="function")clearTimeout(d._endTimers[a]);else{var p=d._soundById(a);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[a],!1)}delete d._endTimers[a]}return d},_soundById:function(a){for(var d=this,p=0;p<d._sounds.length;p++)if(a===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var a=this;a._drain();for(var d=0;d<a._sounds.length;d++)if(a._sounds[d]._ended)return a._sounds[d].reset();return new t(a)},_drain:function(){var a=this,d=a._pool,p=0,f=0;if(!(a._sounds.length<d)){for(f=0;f<a._sounds.length;f++)a._sounds[f]._ended&&p++;for(f=a._sounds.length-1;f>=0;f--){if(p<=d)return;a._sounds[f]._ended&&(a._webAudio&&a._sounds[f]._node&&a._sounds[f]._node.disconnect(0),a._sounds.splice(f,1),p--)}}},_getSoundIds:function(a){var d=this;if(typeof a>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[a]},_refreshBuffer:function(a){var d=this;return a._node.bufferSource=r.ctx.createBufferSource(),a._node.bufferSource.buffer=o[d._src],a._panner?a._node.bufferSource.connect(a._panner):a._node.bufferSource.connect(a._node),a._node.bufferSource.loop=a._loop,a._loop&&(a._node.bufferSource.loopStart=a._start||0,a._node.bufferSource.loopEnd=a._stop||0),a._node.bufferSource.playbackRate.setValueAtTime(a._rate,r.ctx.currentTime),d},_cleanBuffer:function(a){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&a.bufferSource&&(a.bufferSource.onended=null,a.bufferSource.disconnect(0),p))try{a.bufferSource.buffer=r._scratchBuffer}catch{}return a.bufferSource=null,d},_clearSound:function(a){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(a.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(a){this._parent=a,this.init()};t.prototype={init:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,d._sounds.push(a),a.create(),a},create:function(){var a=this,d=a._parent,p=r._muted||a._muted||a._parent._muted?0:a._volume;return d._webAudio?(a._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),a._node.gain.setValueAtTime(p,r.ctx.currentTime),a._node.paused=!0,a._node.connect(r.masterGain)):r.noAudio||(a._node=r._obtainHtml5Audio(),a._errorFn=a._errorListener.bind(a),a._node.addEventListener("error",a._errorFn,!1),a._loadFn=a._loadListener.bind(a),a._node.addEventListener(r._canPlayEvent,a._loadFn,!1),a._endFn=a._endListener.bind(a),a._node.addEventListener("ended",a._endFn,!1),a._node.src=d._src,a._node.preload=d._preload===!0?"auto":d._preload,a._node.volume=p*r.volume(),a._node.load()),a},reset:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._rateSeek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,a},_errorListener:function(){var a=this;a._parent._emit("loaderror",a._id,a._node.error?a._node.error.code:0),a._node.removeEventListener("error",a._errorFn,!1)},_loadListener:function(){var a=this,d=a._parent;d._duration=Math.ceil(a._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()),a._node.removeEventListener(r._canPlayEvent,a._loadFn,!1)},_endListener:function(){var a=this,d=a._parent;d._duration===1/0&&(d._duration=Math.ceil(a._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(a)),a._node.removeEventListener("ended",a._endFn,!1)}};var o={},i=function(a){var d=a._src;if(o[d]){a._duration=o[d].duration,c(a);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);l(f.buffer,a)}else{var h=new XMLHttpRequest;h.open(a._xhr.method,d,!0),h.withCredentials=a._xhr.withCredentials,h.responseType="arraybuffer",a._xhr.headers&&Object.keys(a._xhr.headers).forEach(function(y){h.setRequestHeader(y,a._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){a._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}l(h.response,a)},h.onerror=function(){a._webAudio&&(a._html5=!0,a._webAudio=!1,a._sounds=[],delete o[d],a.load())},s(h)}},s=function(a){try{a.send()}catch{a.onerror()}},l=function(a,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(a).then(f).catch(p):r.ctx.decodeAudioData(a,f,p)},c=function(a,d){d&&!a._duration&&(a._duration=d.duration),Object.keys(a._sprite).length===0&&(a._sprite={__default:[0,a._duration*1e3]}),a._state!=="loaded"&&(a._state="loaded",a._emit("load"),a._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 a=/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(a&&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 Xl<"u"&&(Xl.Howler=r,Xl.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 l=this;if(!l.ctx||!l.ctx.listener)return l;var c=l._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")l._orientation=[r,e,t,o,i,s],typeof l.ctx.listener.forwardX<"u"?(l.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),l.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),l.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),l.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),l.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),l.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):l.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return l},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 l=t._soundById(i[s]);if(l)if(typeof r=="number")l._stereo=r,l._pos=[r,0,0],l._node&&(l._pannerAttr.panningModel="equalpower",(!l._panner||!l._panner.pan)&&n(l,o),o==="spatial"?typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):l._panner.setPosition(r,0,0):l._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",l._id);else return l._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),l=0;l<s.length;l++){var c=i._soundById(s[l]);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),l=0;l<s.length;l++){var c=i._soundById(s[l]);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),l=0;l<s.length;l++)if(i=r._soundById(s[l]),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 Rg=fa((B$,Gg)=>{Gg.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var s=Number(t[i]),l=Number(o[i]);if(s>l)return 1;if(l>s)return-1;if(!isNaN(s)&&isNaN(l))return 1;if(isNaN(s)&&!isNaN(l))return-1}return 0}});var iP={};yu(iP,{default:()=>fc});module.exports=Qg(iP);var mc=require("three");function xu(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Yr(n,r){return Object.setPrototypeOf(n,r),n}function ma(n){return Array.isArray(n)?n:[n]}function vu(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 Jg=typeof global=="object"&&global&&global.Object===Object&&global,ha=Jg;var e0=typeof self=="object"&&self&&self.Object===Object&&self,t0=ha||e0||Function("return this")(),ot=t0;var r0=ot.Symbol,dt=r0;var bu=Object.prototype,o0=bu.hasOwnProperty,n0=bu.toString,ts=dt?dt.toStringTag:void 0;function i0(n){var r=o0.call(n,ts),e=n[ts];try{n[ts]=void 0;var t=!0}catch{}var o=n0.call(n);return t&&(r?n[ts]=e:delete n[ts]),o}var Su=i0;var s0=Object.prototype,a0=s0.toString;function l0(n){return a0.call(n)}var wu=l0;var c0="[object Null]",d0="[object Undefined]",_u=dt?dt.toStringTag:void 0;function u0(n){return n==null?n===void 0?d0:c0:_u&&_u in Object(n)?Su(n):wu(n)}var Wt=u0;function p0(n){return n!=null&&typeof n=="object"}var xt=p0;var f0="[object Symbol]";function m0(n){return typeof n=="symbol"||xt(n)&&Wt(n)==f0}var cn=m0;function h0(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 ya=h0;var y0=Array.isArray,Xe=y0;var g0=1/0,Tu=dt?dt.prototype:void 0,Pu=Tu?Tu.toString:void 0;function Ou(n){if(typeof n=="string")return n;if(Xe(n))return ya(n,Ou)+"";if(cn(n))return Pu?Pu.call(n):"";var r=n+"";return r=="0"&&1/n==-g0?"-0":r}var Au=Ou;function x0(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var $t=x0;function v0(n){return n}var Nu=v0;var b0="[object AsyncFunction]",S0="[object Function]",w0="[object GeneratorFunction]",_0="[object Proxy]";function T0(n){if(!$t(n))return!1;var r=Wt(n);return r==S0||r==w0||r==b0||r==_0}var ga=T0;var P0=ot["__core-js_shared__"],xa=P0;var Cu=function(){var n=/[^.]+$/.exec(xa&&xa.keys&&xa.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function O0(n){return!!Cu&&Cu in n}var Iu=O0;var A0=Function.prototype,N0=A0.toString;function C0(n){if(n!=null){try{return N0.call(n)}catch{}try{return n+""}catch{}}return""}var Kr=C0;var I0=/[\\^$.*+?()[\]{}|]/g,M0=/^\[object .+?Constructor\]$/,E0=Function.prototype,L0=Object.prototype,B0=E0.toString,D0=L0.hasOwnProperty,G0=RegExp("^"+B0.call(D0).replace(I0,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function R0(n){if(!$t(n)||Iu(n))return!1;var r=ga(n)?G0:M0;return r.test(Kr(n))}var Mu=R0;function V0(n,r){return n?.[r]}var Eu=V0;function z0(n,r){var e=Eu(n,r);return Mu(e)?e:void 0}var Bt=z0;var j0=Bt(ot,"WeakMap"),va=j0;var Lu=Object.create,F0=function(){function n(){}return function(r){if(!$t(r))return{};if(Lu)return Lu(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Bu=F0;function k0(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 Du=k0;function U0(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Gu=U0;var H0=800,q0=16,W0=Date.now;function $0(n){var r=0,e=0;return function(){var t=W0(),o=q0-(t-e);if(e=t,o>0){if(++r>=H0)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Ru=$0;function X0(n){return function(){return n}}var Vu=X0;var Y0=function(){try{var n=Bt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),dn=Y0;var K0=dn?function(n,r){return dn(n,"toString",{configurable:!0,enumerable:!1,value:Vu(r),writable:!0})}:Nu,zu=K0;var Z0=Ru(zu),ju=Z0;function Q0(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var Fu=Q0;var J0=9007199254740991,ex=/^(?:0|[1-9]\d*)$/;function tx(n,r){var e=typeof n;return r=r??J0,!!r&&(e=="number"||e!="symbol"&&ex.test(n))&&n>-1&&n%1==0&&n<r}var un=tx;function rx(n,r,e){r=="__proto__"&&dn?dn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var ba=rx;function ox(n,r){return n===r||n!==n&&r!==r}var pn=ox;var nx=Object.prototype,ix=nx.hasOwnProperty;function sx(n,r,e){var t=n[r];(!(ix.call(n,r)&&pn(t,e))||e===void 0&&!(r in n))&&ba(n,r,e)}var fn=sx;function ax(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var l=r[i],c=t?t(e[l],n[l],l,e,n):void 0;c===void 0&&(c=n[l]),o?ba(e,l,c):fn(e,l,c)}return e}var Nr=ax;var ku=Math.max;function lx(n,r,e){return r=ku(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=ku(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var l=Array(r+1);++o<r;)l[o]=t[o];return l[r]=e(s),Du(n,this,l)}}var Uu=lx;var cx=9007199254740991;function dx(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=cx}var mn=dx;function ux(n){return n!=null&&mn(n.length)&&!ga(n)}var Sa=ux;var px=Object.prototype;function fx(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||px;return n===e}var hn=fx;function mx(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var Hu=mx;var hx="[object Arguments]";function yx(n){return xt(n)&&Wt(n)==hx}var yc=yx;var qu=Object.prototype,gx=qu.hasOwnProperty,xx=qu.propertyIsEnumerable,vx=yc(function(){return arguments}())?yc:function(n){return xt(n)&&gx.call(n,"callee")&&!xx.call(n,"callee")},yn=vx;function bx(){return!1}var Wu=bx;var Yu=typeof exports=="object"&&exports&&!exports.nodeType&&exports,$u=Yu&&typeof module=="object"&&module&&!module.nodeType&&module,Sx=$u&&$u.exports===Yu,Xu=Sx?ot.Buffer:void 0,wx=Xu?Xu.isBuffer:void 0,_x=wx||Wu,Bo=_x;var Tx="[object Arguments]",Px="[object Array]",Ox="[object Boolean]",Ax="[object Date]",Nx="[object Error]",Cx="[object Function]",Ix="[object Map]",Mx="[object Number]",Ex="[object Object]",Lx="[object RegExp]",Bx="[object Set]",Dx="[object String]",Gx="[object WeakMap]",Rx="[object ArrayBuffer]",Vx="[object DataView]",zx="[object Float32Array]",jx="[object Float64Array]",Fx="[object Int8Array]",kx="[object Int16Array]",Ux="[object Int32Array]",Hx="[object Uint8Array]",qx="[object Uint8ClampedArray]",Wx="[object Uint16Array]",$x="[object Uint32Array]",Fe={};Fe[zx]=Fe[jx]=Fe[Fx]=Fe[kx]=Fe[Ux]=Fe[Hx]=Fe[qx]=Fe[Wx]=Fe[$x]=!0;Fe[Tx]=Fe[Px]=Fe[Rx]=Fe[Ox]=Fe[Vx]=Fe[Ax]=Fe[Nx]=Fe[Cx]=Fe[Ix]=Fe[Mx]=Fe[Ex]=Fe[Lx]=Fe[Bx]=Fe[Dx]=Fe[Gx]=!1;function Xx(n){return xt(n)&&mn(n.length)&&!!Fe[Wt(n)]}var Ku=Xx;function Yx(n){return function(r){return n(r)}}var gn=Yx;var Zu=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rs=Zu&&typeof module=="object"&&module&&!module.nodeType&&module,Kx=rs&&rs.exports===Zu,gc=Kx&&ha.process,Zx=function(){try{var n=rs&&rs.require&&rs.require("util").types;return n||gc&&gc.binding&&gc.binding("util")}catch{}}(),Zr=Zx;var Qu=Zr&&Zr.isTypedArray,Qx=Qu?gn(Qu):Ku,wa=Qx;var Jx=Object.prototype,ev=Jx.hasOwnProperty;function tv(n,r){var e=Xe(n),t=!e&&yn(n),o=!e&&!t&&Bo(n),i=!e&&!t&&!o&&wa(n),s=e||t||o||i,l=s?Hu(n.length,String):[],c=l.length;for(var u in n)(r||ev.call(n,u))&&!(s&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||un(u,c)))&&l.push(u);return l}var _a=tv;function rv(n,r){return function(e){return n(r(e))}}var Ta=rv;var ov=Ta(Object.keys,Object),Ju=ov;var nv=Object.prototype,iv=nv.hasOwnProperty;function sv(n){if(!hn(n))return Ju(n);var r=[];for(var e in Object(n))iv.call(n,e)&&e!="constructor"&&r.push(e);return r}var ep=sv;function av(n){return Sa(n)?_a(n):ep(n)}var xn=av;function lv(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var tp=lv;var cv=Object.prototype,dv=cv.hasOwnProperty;function uv(n){if(!$t(n))return tp(n);var r=hn(n),e=[];for(var t in n)t=="constructor"&&(r||!dv.call(n,t))||e.push(t);return e}var rp=uv;function pv(n){return Sa(n)?_a(n,!0):rp(n)}var vn=pv;var fv=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,mv=/^\w*$/;function hv(n,r){if(Xe(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||cn(n)?!0:mv.test(n)||!fv.test(n)||r!=null&&n in Object(r)}var op=hv;var yv=Bt(Object,"create"),Qr=yv;function gv(){this.__data__=Qr?Qr(null):{},this.size=0}var np=gv;function xv(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var ip=xv;var vv="__lodash_hash_undefined__",bv=Object.prototype,Sv=bv.hasOwnProperty;function wv(n){var r=this.__data__;if(Qr){var e=r[n];return e===vv?void 0:e}return Sv.call(r,n)?r[n]:void 0}var sp=wv;var _v=Object.prototype,Tv=_v.hasOwnProperty;function Pv(n){var r=this.__data__;return Qr?r[n]!==void 0:Tv.call(r,n)}var ap=Pv;var Ov="__lodash_hash_undefined__";function Av(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Qr&&r===void 0?Ov:r,this}var lp=Av;function bn(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])}}bn.prototype.clear=np;bn.prototype.delete=ip;bn.prototype.get=sp;bn.prototype.has=ap;bn.prototype.set=lp;var xc=bn;function Nv(){this.__data__=[],this.size=0}var cp=Nv;function Cv(n,r){for(var e=n.length;e--;)if(pn(n[e][0],r))return e;return-1}var co=Cv;var Iv=Array.prototype,Mv=Iv.splice;function Ev(n){var r=this.__data__,e=co(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Mv.call(r,e,1),--this.size,!0}var dp=Ev;function Lv(n){var r=this.__data__,e=co(r,n);return e<0?void 0:r[e][1]}var up=Lv;function Bv(n){return co(this.__data__,n)>-1}var pp=Bv;function Dv(n,r){var e=this.__data__,t=co(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var fp=Dv;function Sn(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])}}Sn.prototype.clear=cp;Sn.prototype.delete=dp;Sn.prototype.get=up;Sn.prototype.has=pp;Sn.prototype.set=fp;var uo=Sn;var Gv=Bt(ot,"Map"),po=Gv;function Rv(){this.size=0,this.__data__={hash:new xc,map:new(po||uo),string:new xc}}var mp=Rv;function Vv(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var hp=Vv;function zv(n,r){var e=n.__data__;return hp(r)?e[typeof r=="string"?"string":"hash"]:e.map}var fo=zv;function jv(n){var r=fo(this,n).delete(n);return this.size-=r?1:0,r}var yp=jv;function Fv(n){return fo(this,n).get(n)}var gp=Fv;function kv(n){return fo(this,n).has(n)}var xp=kv;function Uv(n,r){var e=fo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var vp=Uv;function wn(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])}}wn.prototype.clear=mp;wn.prototype.delete=yp;wn.prototype.get=gp;wn.prototype.has=xp;wn.prototype.set=vp;var Do=wn;var Hv="Expected a function";function vc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(Hv);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(vc.Cache||Do),e}vc.Cache=Do;var bp=vc;var qv=500;function Wv(n){var r=bp(n,function(t){return e.size===qv&&e.clear(),t}),e=r.cache;return r}var Sp=Wv;var $v=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Xv=/\\(\\)?/g,Yv=Sp(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace($v,function(e,t,o,i){r.push(o?i.replace(Xv,"$1"):t||e)}),r}),wp=Yv;function Kv(n){return n==null?"":Au(n)}var _p=Kv;function Zv(n,r){return Xe(n)?n:op(n,r)?[n]:wp(_p(n))}var Jt=Zv;var Qv=1/0;function Jv(n){if(typeof n=="string"||cn(n))return n;var r=n+"";return r=="0"&&1/n==-Qv?"-0":r}var mo=Jv;function eb(n,r){r=Jt(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[mo(r[e++])];return e&&e==t?n:void 0}var Pa=eb;function tb(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var _n=tb;var Tp=dt?dt.isConcatSpreadable:void 0;function rb(n){return Xe(n)||yn(n)||!!(Tp&&n&&n[Tp])}var Pp=rb;function Op(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=Pp),o||(o=[]);++i<s;){var l=n[i];r>0&&e(l)?r>1?Op(l,r-1,e,t,o):_n(o,l):t||(o[o.length]=l)}return o}var Ap=Op;function ob(n){var r=n==null?0:n.length;return r?Ap(n,1):[]}var Np=ob;function nb(n){return ju(Uu(n,void 0,Np),n+"")}var Oa=nb;var ib=Ta(Object.getPrototypeOf,Object),Tn=ib;var sb="[object Object]",ab=Function.prototype,lb=Object.prototype,Cp=ab.toString,cb=lb.hasOwnProperty,db=Cp.call(Object);function ub(n){if(!xt(n)||Wt(n)!=sb)return!1;var r=Tn(n);if(r===null)return!0;var e=cb.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Cp.call(e)==db}var Ip=ub;function pb(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 Mp=pb;function fb(){this.__data__=new uo,this.size=0}var Ep=fb;function mb(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Lp=mb;function hb(n){return this.__data__.get(n)}var Bp=hb;function yb(n){return this.__data__.has(n)}var Dp=yb;var gb=200;function xb(n,r){var e=this.__data__;if(e instanceof uo){var t=e.__data__;if(!po||t.length<gb-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new Do(t)}return e.set(n,r),this.size=e.size,this}var Gp=xb;function Pn(n){var r=this.__data__=new uo(n);this.size=r.size}Pn.prototype.clear=Ep;Pn.prototype.delete=Lp;Pn.prototype.get=Bp;Pn.prototype.has=Dp;Pn.prototype.set=Gp;var On=Pn;function vb(n,r){return n&&Nr(r,xn(r),n)}var Rp=vb;function bb(n,r){return n&&Nr(r,vn(r),n)}var Vp=bb;var kp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,zp=kp&&typeof module=="object"&&module&&!module.nodeType&&module,Sb=zp&&zp.exports===kp,jp=Sb?ot.Buffer:void 0,Fp=jp?jp.allocUnsafe:void 0;function wb(n,r){if(r)return n.slice();var e=n.length,t=Fp?Fp(e):new n.constructor(e);return n.copy(t),t}var Up=wb;function _b(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 Hp=_b;function Tb(){return[]}var Aa=Tb;var Pb=Object.prototype,Ob=Pb.propertyIsEnumerable,qp=Object.getOwnPropertySymbols,Ab=qp?function(n){return n==null?[]:(n=Object(n),Hp(qp(n),function(r){return Ob.call(n,r)}))}:Aa,An=Ab;function Nb(n,r){return Nr(n,An(n),r)}var Wp=Nb;var Cb=Object.getOwnPropertySymbols,Ib=Cb?function(n){for(var r=[];n;)_n(r,An(n)),n=Tn(n);return r}:Aa,Na=Ib;function Mb(n,r){return Nr(n,Na(n),r)}var $p=Mb;function Eb(n,r,e){var t=r(n);return Xe(n)?t:_n(t,e(n))}var Ca=Eb;function Lb(n){return Ca(n,xn,An)}var os=Lb;function Bb(n){return Ca(n,vn,Na)}var Ia=Bb;var Db=Bt(ot,"DataView"),Ma=Db;var Gb=Bt(ot,"Promise"),Ea=Gb;var Rb=Bt(ot,"Set"),La=Rb;var Xp="[object Map]",Vb="[object Object]",Yp="[object Promise]",Kp="[object Set]",Zp="[object WeakMap]",Qp="[object DataView]",zb=Kr(Ma),jb=Kr(po),Fb=Kr(Ea),kb=Kr(La),Ub=Kr(va),Go=Wt;(Ma&&Go(new Ma(new ArrayBuffer(1)))!=Qp||po&&Go(new po)!=Xp||Ea&&Go(Ea.resolve())!=Yp||La&&Go(new La)!=Kp||va&&Go(new va)!=Zp)&&(Go=function(n){var r=Wt(n),e=r==Vb?n.constructor:void 0,t=e?Kr(e):"";if(t)switch(t){case zb:return Qp;case jb:return Xp;case Fb:return Yp;case kb:return Kp;case Ub:return Zp}return r});var Jr=Go;var Hb=Object.prototype,qb=Hb.hasOwnProperty;function Wb(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&qb.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Jp=Wb;var $b=ot.Uint8Array,Nn=$b;function Xb(n){var r=new n.constructor(n.byteLength);return new Nn(r).set(new Nn(n)),r}var Cn=Xb;function Yb(n,r){var e=r?Cn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var ef=Yb;var Kb=/\w*$/;function Zb(n){var r=new n.constructor(n.source,Kb.exec(n));return r.lastIndex=n.lastIndex,r}var tf=Zb;var rf=dt?dt.prototype:void 0,of=rf?rf.valueOf:void 0;function Qb(n){return of?Object(of.call(n)):{}}var nf=Qb;function Jb(n,r){var e=r?Cn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var sf=Jb;var e1="[object Boolean]",t1="[object Date]",r1="[object Map]",o1="[object Number]",n1="[object RegExp]",i1="[object Set]",s1="[object String]",a1="[object Symbol]",l1="[object ArrayBuffer]",c1="[object DataView]",d1="[object Float32Array]",u1="[object Float64Array]",p1="[object Int8Array]",f1="[object Int16Array]",m1="[object Int32Array]",h1="[object Uint8Array]",y1="[object Uint8ClampedArray]",g1="[object Uint16Array]",x1="[object Uint32Array]";function v1(n,r,e){var t=n.constructor;switch(r){case l1:return Cn(n);case e1:case t1:return new t(+n);case c1:return ef(n,e);case d1:case u1:case p1:case f1:case m1:case h1:case y1:case g1:case x1:return sf(n,e);case r1:return new t;case o1:case s1:return new t(n);case n1:return tf(n);case i1:return new t;case a1:return nf(n)}}var af=v1;function b1(n){return typeof n.constructor=="function"&&!hn(n)?Bu(Tn(n)):{}}var lf=b1;var S1="[object Map]";function w1(n){return xt(n)&&Jr(n)==S1}var cf=w1;var df=Zr&&Zr.isMap,_1=df?gn(df):cf,uf=_1;var T1="[object Set]";function P1(n){return xt(n)&&Jr(n)==T1}var pf=P1;var ff=Zr&&Zr.isSet,O1=ff?gn(ff):pf,mf=O1;var A1=1,N1=2,C1=4,hf="[object Arguments]",I1="[object Array]",M1="[object Boolean]",E1="[object Date]",L1="[object Error]",yf="[object Function]",B1="[object GeneratorFunction]",D1="[object Map]",G1="[object Number]",gf="[object Object]",R1="[object RegExp]",V1="[object Set]",z1="[object String]",j1="[object Symbol]",F1="[object WeakMap]",k1="[object ArrayBuffer]",U1="[object DataView]",H1="[object Float32Array]",q1="[object Float64Array]",W1="[object Int8Array]",$1="[object Int16Array]",X1="[object Int32Array]",Y1="[object Uint8Array]",K1="[object Uint8ClampedArray]",Z1="[object Uint16Array]",Q1="[object Uint32Array]",ze={};ze[hf]=ze[I1]=ze[k1]=ze[U1]=ze[M1]=ze[E1]=ze[H1]=ze[q1]=ze[W1]=ze[$1]=ze[X1]=ze[D1]=ze[G1]=ze[gf]=ze[R1]=ze[V1]=ze[z1]=ze[j1]=ze[Y1]=ze[K1]=ze[Z1]=ze[Q1]=!0;ze[L1]=ze[yf]=ze[F1]=!1;function Ba(n,r,e,t,o,i){var s,l=r&A1,c=r&N1,u=r&C1;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!$t(n))return n;var a=Xe(n);if(a){if(s=Jp(n),!l)return Gu(n,s)}else{var d=Jr(n),p=d==yf||d==B1;if(Bo(n))return Up(n,l);if(d==gf||d==hf||p&&!o){if(s=c||p?{}:lf(n),!l)return c?$p(n,Vp(s,n)):Wp(n,Rp(s,n))}else{if(!ze[d])return o?n:{};s=af(n,d,l)}}i||(i=new On);var f=i.get(n);if(f)return f;i.set(n,s),mf(n)?n.forEach(function(y){s.add(Ba(y,r,e,y,n,i))}):uf(n)&&n.forEach(function(y,g){s.set(g,Ba(y,r,e,g,n,i))});var m=u?c?Ia:os:c?vn:xn,h=a?void 0:m(n);return Fu(h||n,function(y,g){h&&(g=y,y=n[g]),fn(s,g,Ba(y,r,e,g,n,i))}),s}var Da=Ba;var J1=1,eS=4;function tS(n){return Da(n,J1|eS)}var eo=tS;var rS="__lodash_hash_undefined__";function oS(n){return this.__data__.set(n,rS),this}var xf=oS;function nS(n){return this.__data__.has(n)}var vf=nS;function Ga(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Do;++r<e;)this.add(n[r])}Ga.prototype.add=Ga.prototype.push=xf;Ga.prototype.has=vf;var bf=Ga;function iS(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 Sf=iS;function sS(n,r){return n.has(r)}var wf=sS;var aS=1,lS=2;function cS(n,r,e,t,o,i){var s=e&aS,l=n.length,c=r.length;if(l!=c&&!(s&&c>l))return!1;var u=i.get(n),a=i.get(r);if(u&&a)return u==r&&a==n;var d=-1,p=!0,f=e&lS?new bf:void 0;for(i.set(n,r),i.set(r,n);++d<l;){var m=n[d],h=r[d];if(t)var y=s?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(!Sf(r,function(g,v){if(!wf(f,v)&&(m===g||o(m,g,e,t,i)))return f.push(v)})){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 Ra=cS;function dS(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var _f=dS;function uS(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Tf=uS;var pS=1,fS=2,mS="[object Boolean]",hS="[object Date]",yS="[object Error]",gS="[object Map]",xS="[object Number]",vS="[object RegExp]",bS="[object Set]",SS="[object String]",wS="[object Symbol]",_S="[object ArrayBuffer]",TS="[object DataView]",Pf=dt?dt.prototype:void 0,bc=Pf?Pf.valueOf:void 0;function PS(n,r,e,t,o,i,s){switch(e){case TS:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case _S:return!(n.byteLength!=r.byteLength||!i(new Nn(n),new Nn(r)));case mS:case hS:case xS:return pn(+n,+r);case yS:return n.name==r.name&&n.message==r.message;case vS:case SS:return n==r+"";case gS:var l=_f;case bS:var c=t&pS;if(l||(l=Tf),n.size!=r.size&&!c)return!1;var u=s.get(n);if(u)return u==r;t|=fS,s.set(n,r);var a=Ra(l(n),l(r),t,o,i,s);return s.delete(n),a;case wS:if(bc)return bc.call(n)==bc.call(r)}return!1}var Of=PS;var OS=1,AS=Object.prototype,NS=AS.hasOwnProperty;function CS(n,r,e,t,o,i){var s=e&OS,l=os(n),c=l.length,u=os(r),a=u.length;if(c!=a&&!s)return!1;for(var d=c;d--;){var p=l[d];if(!(s?p in r:NS.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;++d<c;){p=l[d];var g=n[p],v=r[p];if(t)var b=s?t(v,g,p,r,n,i):t(g,v,p,n,r,i);if(!(b===void 0?g===v||o(g,v,e,t,i):b)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,S=r.constructor;w!=S&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(h=!1)}return i.delete(n),i.delete(r),h}var Af=CS;var IS=1,Nf="[object Arguments]",Cf="[object Array]",Va="[object Object]",MS=Object.prototype,If=MS.hasOwnProperty;function ES(n,r,e,t,o,i){var s=Xe(n),l=Xe(r),c=s?Cf:Jr(n),u=l?Cf:Jr(r);c=c==Nf?Va:c,u=u==Nf?Va:u;var a=c==Va,d=u==Va,p=c==u;if(p&&Bo(n)){if(!Bo(r))return!1;s=!0,a=!1}if(p&&!a)return i||(i=new On),s||wa(n)?Ra(n,r,e,t,o,i):Of(n,r,c,e,t,o,i);if(!(e&IS)){var f=a&&If.call(n,"__wrapped__"),m=d&&If.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new On),o(h,y,e,t,i)}}return p?(i||(i=new On),Af(n,r,e,t,o,i)):!1}var Mf=ES;function Ef(n,r,e,t,o){return n===r?!0:n==null||r==null||!xt(n)&&!xt(r)?n!==n&&r!==r:Mf(n,r,e,t,Ef,o)}var Lf=Ef;function LS(n,r){return n!=null&&r in Object(n)}var Bf=LS;function BS(n,r,e){r=Jt(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=mo(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&&mn(o)&&un(s,o)&&(Xe(n)||yn(n)))}var Df=BS;function DS(n,r){return n!=null&&Df(n,r,Bf)}var Gf=DS;function GS(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Rf=GS;function RS(n,r){return r.length<2?n:Pa(n,Mp(r,0,-1))}var Vf=RS;function VS(n,r){return Lf(n,r)}var ns=VS;function zS(n,r){return r=Jt(r,n),n=Vf(n,r),n==null||delete n[mo(Rf(r))]}var zf=zS;function jS(n){return Ip(n)?void 0:n}var jf=jS;var FS=1,kS=2,US=4,HS=Oa(function(n,r){var e={};if(n==null)return e;var t=!1;r=ya(r,function(i){return i=Jt(i,n),t||(t=i.length>1),i}),Nr(n,Ia(n),e),t&&(e=Da(e,FS|kS|US,jf));for(var o=r.length;o--;)zf(e,r[o]);return e}),In=HS;function qS(n,r,e,t){if(!$t(n))return n;r=Jt(r,n);for(var o=-1,i=r.length,s=i-1,l=n;l!=null&&++o<i;){var c=mo(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var a=l[c];u=t?t(a,c,l):void 0,u===void 0&&(u=$t(a)?a:un(r[o+1])?[]:{})}fn(l,c,u),l=l[c]}return n}var Ff=qS;function WS(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],l=Pa(n,s);e(l,s)&&Ff(i,Jt(s,n),l)}return i}var kf=WS;function $S(n,r){return kf(n,r,function(e,t){return Gf(n,t)})}var Uf=$S;var XS=Oa(function(n,r){return n==null?{}:Uf(n,r)}),Mn=XS;var Re=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,Re.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,l={...e,[i]:s};return Object.setPrototypeOf(l,Re.prototype),{data:l,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,Re.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function is(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"&&is(t)}return Object.freeze(n)}function Hf(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 En=class extends Error{};function za(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Cr(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 Ln(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 qf(){return typeof process<"u"}function Wf(n,r){for(let e of n)r(e.id,e.data)!==!0&&Wf(e.children,r)}function $f(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)$f(e,r)}var nt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,nt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)is(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}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&&$f(o,t)}}traverse(e){Wf(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),l=s.findIndex(a=>a.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let l=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(a=>a.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:l}}Object.setPrototypeOf(i,nt.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:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,u=this.childrenArray(c),a={fi:o,id:i,data:s,children:l};return u=[...u,a],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(a),{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),s=i.findIndex(u=>u.id===t);e.localIndex=s,i=[...i];let l=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...l,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 En("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let l=s,c=this.childrenArray(s),u=c.findIndex(f=>f.id===i);c=[...c];let a=c.splice(u,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let p=a.fi;return a={...a,fi:o},c=[...c,a],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(a),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:9,parent:l,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)=>Hf(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 Cr(0,o,o);{let s=i[0].fi;return Cr(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=i.find(c=>c.fi>s.fi);if(l===void 0){let c=i[i.length-1].fi;return Cr(c,c+o,o)}else return Cr(s.fi,l.fi,o)}}};var Bn;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],l=!1;if(o)for(let c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=s[u],s[u]=o[c],l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},l=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let u=o[c];u===void 0?delete s[c]:s[c]=u,l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Bn||(Bn={}));var ye=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ye.prototype)}deepFreeze(){let e=0;for(;e<this.length;)is(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(u=>u.id===e);if(s<0)throw new Error("not expected");let l=i[s];return i=[...i],i[s]={...l,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ye.prototype);let t=e;return qf()||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,l={fi:t,id:o,data:i};return s=[...s,l],s.sort((u,a)=>u.fi-a.fi),e.localIndex=s.indexOf(l),{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(a=>a.id===o);if(s===-1)return null;let l=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((a,d)=>a.fi-d.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:l,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 Cr(0,t,t);{let i=o[0].fi;return Cr(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(l=>l.fi>i.fi);if(s===void 0){let l=o[o.length-1].fi;return Cr(l,l+t,t)}else return Cr(i.fi,s.fi,t)}}};function Dn(n){return n&&typeof n=="object"&&n instanceof Ue}var Ue=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&&!Dn(t))return null;o+=1}t=t?za(t):new Ue;for(let[c,u]of Object.entries(r.props)){let a=t[c];i[c]=a,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=za(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=za(c);u[r.path[o-1]]=t,t=u}else{let u=new Ue;u[r.path[o-1]]=t,t=u}}o-=1}let s=Object.setPrototypeOf(t,Ue.prototype),l={...r,props:i};return{data:s,actual:r,reverse:l}}},to;(t=>{function n(o,i){return ss(o,i)??o}t.apply=n;function r(o,i){return wc(o,i)}t.merge=r;function e(o,i){let s=0,l=i.path,c=o;for(;s<l.length&&c!==void 0;){if(c=At.zoomOnce(c,l[s]),c===void 0)return i;if(!Dn(c))return;s+=1}if(c===void 0)return i;if(!!Dn(c))if(i.type===0){let u={...i.props};for(let a of Object.keys(c))delete u[a];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Sc([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(to||(to={}));function Sc(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=ss(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let l=Sc(o.children,r);return l!==void 0?e=!0:l=o.children,{...o,id:i,data:s,children:l}}else return{...o,id:i,data:s}});if(e)return t}function YS(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=ss(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 ss(n,r){if(!Dn(r))return r;if(n instanceof nt){let e=Sc(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ye)return YS(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=ss(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 Ue)return wc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=ss(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 wc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Dn(r))return r;if(!Dn(n))return to.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 Ue;for(let o of e){let i=wc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Xf(n,r){let e={cur:[],result:[],len:0};return n=as(n,r,e)??n,[n,e.result]}function ja(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function Fa(n){n&&(n.len-=1)}function KS(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Yf(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=as(i.data,r,ja(e,s));Fa(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=Yf(i.children,r,e);return u!==void 0?t=!0:u=i.children,{...i,id:s,data:c,children:u}});if(t)return o}function ZS(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=as(i.data,r,ja(e,s));return Fa(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 as(n,r,e){if(n instanceof nt){let t=Yf(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ye)return ZS(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let l=as(i,r,ja(e,s));return Fa(e),t=t||l!==void 0,l===void 0&&(l=i),l});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!Ln(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let l=r[i];if(typeof l=="string"){if(e!==null)throw new Error("not supported");o=!0,i=l}let c=as(s,r,ja(e,i));Fa(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");KS(e)}return t}else return}}var ka;(r=>{function n(e,t){let o=At.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})(ka||(ka={}));var vt;(l=>{function n(c,u){return{...c,path:c.path.slice(u)}}l.drop=n;function r(c,u){return e(c,u)?.data??c}l.applySimple=r;function e(c,u){let a=u.path;for(var d=[];;){let p;if(c instanceof Ue&&u.type===0&&(p=c.runOp({...u,path:a.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===a.length&&(c instanceof nt||c instanceof ye||c instanceof Re?p=c.runOp(u):p=Bn.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=a[y],v=d[y];if(v instanceof nt){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof ye){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof Re){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof Ue){let b={...v,[g]:h};h=Object.setPrototypeOf(b,Ue.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let b=h;h=[...v],h[g]=b}else h={...v,[g]:h};else return null}return{data:h,actual:{...p.actual,path:a},reverse:{...p.reverse,path:a}}}else return null;let f=a[d.length],m;if(c instanceof nt){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)d.push(c),c=m;else return null}}l.apply=e;function t(c,u){for(let a=0;a<c.length&&a<u.length;a++)if(c[a]!==u[a])return!0;return!1}l.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let a=0;a<c.length;a++)if(c[a]!==u[a])return!1;return!0}l.pathEq=o;function i(c,u){return t(c.path,u.path)}l.commutative=i;function s(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(a=>u.props[a]!==void 0):!1}l.subsumed=s})(vt||(vt={}));var _c;(c=>{function n(){return[]}c.empty=n;function r(u,a){let d=[];for(let p of u){let[f,...m]=p.path;f===a&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,a){return u.map(d=>({...d,path:[a,...d.path]}))}c.addPrefix=e;function t(u,a){return[...u,...a]}c.concat=t;function o(u,a){return[...u.filter(p=>!a.some(f=>vt.subsumed(p,f))),...a]}c.compress=o;function i(u,a){return u.every(d=>a.every(p=>vt.commutative(d,p)))}c.commutative=i;function s(u,a){for(let d of a){let p=l(u,d);p!==null&&(u=p.data)}return u}c.applyAll=s;function l(u,a){var d=u;let p=[],f=[];for(let m of a)try{if(m.type===3){let h=At.zoom(d,[...m.path,m.id]),y=vt.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,v]=Xf(d,{[m.id]:h});d=g;for(let b of v){let w=b[b.length-1];b.splice(b.length-1,1),p.push({type:0,path:b,props:{[w]:h}}),f.push({type:0,path:b,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=vt.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof En)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=l})(_c||(_c={}));var Kf=Symbol(),QS=Symbol(),Ha=Symbol(),Ro=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Ua);){let s=o._path,l=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,l)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[Ha];t&&t(),delete this._children[r]}}}},Pc=class extends Ro{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,Bn.runOp(this._current,r),r.path)}},Oc=class extends Ro{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,Re.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Zf={get(n,r){if(r===Ha)return()=>{n._parent=null};if(r===Kf)return n._current;if(r===QS)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=qa(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]}}},JS={...Zf,set(n,r,e){let t={type:0,props:{[r]:ut(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}},ew={...Zf,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}},Gn=class extends Ro{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ha]=()=>{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=qa(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)}},Rn=class extends Ro{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[Ha]=()=>{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=qa(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 Tc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&At.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Ua=class extends Ro{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){Tc(this.ts,e,r),Tc(this.actual,t,r),Tc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function qa(n,r,e){return e instanceof nt?new Gn(n,r,e):e instanceof ye?new Rn(n,r,e):e instanceof Re?new Proxy(new Oc(n,r,e),ew):e!==null&&typeof e=="object"?Ln(e)?e:new Proxy(new Pc(n,r,e),JS):e}function Ac(n){let r=new Ua(n);return[qa(r,"",n),r]}function Vn(n,r){let[e,t]=Ac(n);return r(e),t.result()}function ut(n){return n instanceof Gn||n instanceof Rn?n._current:n!==null&&typeof n=="object"?n[Kf]:n}var At;(o=>{function n(i,s){if(s.length===i.length)for(var l=0;l<i.length;){if(i[l]!==s[l])return!1;l+=1}else return!1;return!0}o.equal=n;function r(i,s,l){let c=t(l,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...s};return Object.keys(c).forEach(a=>{delete u[a]}),u}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof nt||i instanceof Gn)&&typeof s=="string")return i.data(s);if((i instanceof ye||i instanceof Rn)&&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,l=0){for(;l<s.length&&i!==void 0;)i=e(i,s[l]),l+=1;return i}o.zoom=t})(At||(At={}));function Qf(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 dr(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 Wa=class{},ls=class extends Wa{constructor(e){super();this.id=e}},cs=class extends Wa{constructor(e){super();this.data=e}};var Cc;try{Cc=new TextDecoder}catch{}var ne,yo,I=0;var sm=[],Ic=sm,Mc=0,Dt={},Ne,ho,er=0,Ir=0,Xt,ro,Nt=[],Ee,Jf={useRecords:!1,mapsAsObjects:!0},ds=class{},Lc=new ds;Lc.name="MessagePack 0xC1";var zn=!1,Mr=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(ne)return um(()=>(Xa(),this?this.unpack(r,e):Mr.prototype.unpack.call(Jf,r,e)));yo=e>-1?e:r.length,I=0,Mc=0,Ir=0,ho=null,Ic=sm,Xt=null,ne=r;try{Ee=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw ne=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 Mr){if(Dt=this,this.structures)return Ne=this.structures,$a();(!Ne||Ne.length>0)&&(Ne=[])}else Dt=Jf,(!Ne||Ne.length>0)&&(Ne=[]);return $a()}unpackMultiple(r,e){let t,o=0;try{zn=!0;let i=r.length,s=this?this.unpack(r,i):Za.unpack(r,i);if(e){for(e(s);I<i;)if(o=I,e($a())===!1)return}else{for(t=[s];I<i;)o=I,t.push($a());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{zn=!1,Xa()}}_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 $a(){try{if(!Dt.trusted&&!zn){let r=Ne.sharedLength||0;r<Ne.length&&(Ne.length=r)}let n=Ye();if(I==yo)Ne.restoreStructures&&em(),Ne=null,ne=null,ro&&(ro=null);else if(I>yo){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!zn)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ne.restoreStructures&&em(),Xa(),(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 Ye(){let n=ne[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Ne[n&63]||Dt.getStructures&&am()[n&63];return r?(r.read||(r.read=Bc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Dt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[cm()]=Ye();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Ye(),Ye());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=Ye();return r}else if(n<192){let r=n-160;if(Ir>=I)return ho.slice(I-er,(I+=r)-er);if(Ir==0&&yo<140){let e=r<16?Dc(r):lm(r);if(e!=null)return e}return Ec(r)}else{let r;switch(n){case 192:return null;case 193:return Xt?(r=Ye(),r>0?Xt[1].slice(Xt.position1,Xt.position1+=r):Xt[0].slice(Xt.position0,Xt.position0-=r)):Lc;case 194:return!1;case 195:return!0;case 196:return Nc(ne[I++]);case 197:return r=Ee.getUint16(I),I+=2,Nc(r);case 198:return r=Ee.getUint32(I),I+=4,Nc(r);case 199:return Vo(ne[I++]);case 200:return r=Ee.getUint16(I),I+=2,Vo(r);case 201:return r=Ee.getUint32(I),I+=4,Vo(r);case 202:if(r=Ee.getFloat32(I),Dt.useFloat32>2){let e=Ka[(ne[I]&127)<<1|ne[I+1]>>7];return I+=4,(e*r+(r>0?.5:-.5)>>0)/e}return I+=4,r;case 203:return r=Ee.getFloat64(I),I+=8,r;case 204:return ne[I++];case 205:return r=Ee.getUint16(I),I+=2,r;case 206:return r=Ee.getUint32(I),I+=4,r;case 207:return Dt.int64AsNumber?(r=Ee.getUint32(I)*4294967296,r+=Ee.getUint32(I+4)):r=Ee.getBigUint64(I),I+=8,r;case 208:return Ee.getInt8(I++);case 209:return r=Ee.getInt16(I),I+=2,r;case 210:return r=Ee.getInt32(I),I+=4,r;case 211:return Dt.int64AsNumber?(r=Ee.getInt32(I)*4294967296,r+=Ee.getUint32(I+4)):r=Ee.getBigInt64(I),I+=8,r;case 212:if(r=ne[I++],r==114)return im(ne[I++]&63);{let e=Nt[r];if(e)return e.read?(I++,e.read(Ye())):e.noBuffer?(I++,e()):e(ne.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=ne[I],r==114?(I++,im(ne[I++]&63,ne[I++])):Vo(2);case 214:return Vo(4);case 215:return Vo(8);case 216:return Vo(16);case 217:return r=ne[I++],Ir>=I?ho.slice(I-er,(I+=r)-er):rw(r);case 218:return r=Ee.getUint16(I),I+=2,Ir>=I?ho.slice(I-er,(I+=r)-er):ow(r);case 219:return r=Ee.getUint32(I),I+=4,Ir>=I?ho.slice(I-er,(I+=r)-er):nw(r);case 220:return r=Ee.getUint16(I),I+=2,rm(r);case 221:return r=Ee.getUint32(I),I+=4,rm(r);case 222:return r=Ee.getUint16(I),I+=2,om(r);case 223:return r=Ee.getUint32(I),I+=4,om(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 tw=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Bc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>tw.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(Ye);return n.highByte===0&&(n.read=tm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=Ye()}return t}return e.count=0,n.highByte===0?tm(r,e):e}var tm=(n,r)=>function(){let e=ne[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ne[t]||am()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Bc(o,n)),o.read()};function am(){let n=um(()=>(ne=null,Dt.getStructures()));return Ne=Dt._mergeStructures(n,Ne)}var Ec=Ya,rw=Ya,ow=Ya,nw=Ya;function Ya(n){let r;if(n<16&&(r=Dc(n)))return r;if(n>64&&Cc)return Cc.decode(ne.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=ne[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=ne[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=ne[I++]&63,s=ne[I++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=ne[I++]&63,s=ne[I++]&63,l=ne[I++]&63,c=(o&7)<<18|i<<12|s<<6|l;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+=pt.apply(String,t),t.length=0)}return t.length>0&&(r+=pt.apply(String,t)),r}function rm(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=Ye();return r}function om(n){if(Dt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[cm()]=Ye();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Ye(),Ye());return r}}var pt=String.fromCharCode;function lm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=ne[I++];if((o&128)>0){I=r;return}e[t]=o}return pt.apply(String,e)}function Dc(n){if(n<4)if(n<2){if(n===0)return"";{let r=ne[I++];if((r&128)>1){I-=1;return}return pt(r)}}else{let r=ne[I++],e=ne[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return pt(r,e);let t=ne[I++];if((t&128)>0){I-=3;return}return pt(r,e,t)}else{let r=ne[I++],e=ne[I++],t=ne[I++],o=ne[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return pt(r,e,t,o);{let i=ne[I++];if((i&128)>0){I-=5;return}return pt(r,e,t,o,i)}}else if(n<8){let i=ne[I++],s=ne[I++];if((i&128)>0||(s&128)>0){I-=6;return}if(n<7)return pt(r,e,t,o,i,s);let l=ne[I++];if((l&128)>0){I-=7;return}return pt(r,e,t,o,i,s,l)}else{let i=ne[I++],s=ne[I++],l=ne[I++],c=ne[I++];if((i&128)>0||(s&128)>0||(l&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return pt(r,e,t,o,i,s,l,c);{let u=ne[I++];if((u&128)>0){I-=9;return}return pt(r,e,t,o,i,s,l,c,u)}}else if(n<12){let u=ne[I++],a=ne[I++];if((u&128)>0||(a&128)>0){I-=10;return}if(n<11)return pt(r,e,t,o,i,s,l,c,u,a);let d=ne[I++];if((d&128)>0){I-=11;return}return pt(r,e,t,o,i,s,l,c,u,a,d)}else{let u=ne[I++],a=ne[I++],d=ne[I++],p=ne[I++];if((u&128)>0||(a&128)>0||(d&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return pt(r,e,t,o,i,s,l,c,u,a,d,p);{let f=ne[I++];if((f&128)>0){I-=13;return}return pt(r,e,t,o,i,s,l,c,u,a,d,p,f)}}else{let f=ne[I++],m=ne[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return pt(r,e,t,o,i,s,l,c,u,a,d,p,f,m);let h=ne[I++];if((h&128)>0){I-=15;return}return pt(r,e,t,o,i,s,l,c,u,a,d,p,f,m,h)}}}}}function Nc(n){return Dt.copyBuffers?Uint8Array.prototype.slice.call(ne,I,I+=n):ne.subarray(I,I+=n)}function Vo(n){let r=ne[I++];if(Nt[r])return Nt[r](ne.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var nm=new Array(4096);function cm(){let n=ne[I++];if(n>=160&&n<192){if(n=n-160,Ir>=I)return ho.slice(I-er,(I+=n)-er);if(!(Ir==0&&yo<180))return Ec(n)}else return I--,Ye();let r=(n<<5^(n>1?Ee.getUint16(I):n>0?ne[I]:0))&4095,e=nm[r],t=I,o=I+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Ee.getUint32(t),i!=e[s++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=ne[t++],i!=e[s++]){t=1879048192;break}if(t===o)return I=t,e.string;o-=3,t=I}for(e=[],nm[r]=e,e.bytes=n;t<o;)i=Ee.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=ne[t++],e.push(i);let l=n<16?Dc(n):lm(n);return l!=null?e.string=l:e.string=Ec(n)}var im=(n,r)=>{var e=Ye();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=Bc(e,t),e.read()},dm=typeof self=="object"?self:global;Nt[0]=()=>{};Nt[0].noBuffer=!0;Nt[101]=()=>{let n=Ye();return(dm[n[0]]||Error)(n[1])};Nt[105]=n=>{let r=Ee.getUint32(I-4);ro||(ro=new Map);let e=ne[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};ro.set(r,o);let i=Ye();return o.used?Object.assign(t,i):(o.target=i,i)};Nt[112]=n=>{let r=Ee.getUint32(I-4),e=ro.get(r);return e.used=!0,e.target};Nt[115]=()=>new Set(Ye());var Gc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Nt[116]=n=>{let r=n[0],e=Gc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new dm[e](Uint8Array.prototype.slice.call(n,1).buffer)};Nt[120]=()=>{let n=Ye();return new RegExp(n[0],n[1])};Nt[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,Xt=[Ye(),Ye()],Xt.position0=0,Xt.position1=0;let t=I;I=e;try{return Ye()}finally{I=t}};Nt[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=yo,e=I,t=Mc,o=er,i=Ir,s=ho,l=Ic,c=ro,u=Xt,a=new Uint8Array(ne.slice(0,yo)),d=Ne,p=Ne.slice(0,Ne.length),f=Dt,m=zn,h=n();return yo=r,I=e,Mc=t,er=o,Ir=i,ho=s,Ic=l,ro=c,Xt=u,ne=a,zn=m,Ne=d,Ne.splice(0,Ne.length,...p),Dt=f,Ee=new DataView(ne.buffer,ne.byteOffset,ne.byteLength),h}function Xa(){ne=null,ro=null,Ne=null}function pm(n){n.unpack?Nt[n.type]=n.unpack:Nt[n.type]=n}var Ka=new Array(147);for(let n=0;n<256;n++)Ka[n]=+("1e"+Math.floor(45.15-n*.30103));var Za=new Mr({useRecords:!1}),iw=Za.unpack,sw=Za.unpackMultiple,aw=Za.unpack,Qa={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},lw=new Float32Array(1),TE=new Uint8Array(lw.buffer,0,4);var Ja;try{Ja=new TextEncoder}catch{}var el,Vc,tl=typeof Buffer<"u",Rc=tl?Buffer.allocUnsafeSlow:Uint8Array,ym=tl?Buffer:Uint8Array,fm=tl?4294967296:2144337920,z,et,E=0,Er,Lr=null,cw=/[\u0080-\uFFFF]/,us=Symbol("record-id"),zo=class extends Mr{constructor(r){super(r),this.offset=0;let e,t,o,i,s,l,c=0,u=ym.prototype.utf8Write?function(x,C,P){return z.utf8Write(x,C,P)}:Ja&&Ja.encodeInto?function(x,C){return Ja.encodeInto(x,z.subarray(C)).written}:!1,a=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 v=[],b=0,w=0;this.pack=this.encode=function(x,C){if(z||(z=new Rc(8192),et=new DataView(z.buffer,0,8192),E=0),Er=z.length-10,Er-E<2048?(z=new Rc(z.length),et=new DataView(z.buffer,0,z.length),Er=z.length-10,E=0):E=E+7&2147483640,t=E,l=a.structuredClone?new Map:null,a.bundleStrings?(Lr=["",""],z[E++]=214,z[E++]=98,Lr.position=E-t,E+=4):Lr=null,o=a.structures,o){o.uninitialized&&(o=a._mergeStructures(a.getStructures()));let P=o.sharedLength||0;if(P>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let N=0;N<P;N++){let O=o[N];if(!O)continue;let A,R=o.transitions;for(let k=0,$=O.length;k<$;k++){let te=O[k];A=R[te],A||(A=R[te]=Object.create(null)),R=A}R[us]=N+64}c=P}d||(o.nextId=P+64)}i&&(i=!1),s=o||[];try{if(S(x),Lr){et.setUint32(Lr.position+t,E-Lr.position-t);let P=Lr;Lr=null,S(P[0]),S(P[1])}if(a.offset=E,l&&l.idsToInsert){E+=l.idsToInsert.length*6,E>Er&&_(E),a.offset=E;let P=uw(z.subarray(t,E),l.idsToInsert);return l=null,P}return C&xm?(z.start=t,z.end=E,z):z.subarray(t,E)}finally{if(o){if(w<10&&w++,b>1e4)o.transitions=null,w=0,b=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let P=0,N=v.length;P<N;P++)v[P][us]=0;v=[]}if(i&&a.saveStructures){let P=o.sharedLength||f;o.length>P&&(o=o.slice(0,P));let N=z.subarray(t,E);return a.saveStructures(o,c)===!1?(a._mergeStructures(a.getStructures()),a.pack(x)):(c=P,N)}}C&xw&&(E=t)}};let S=x=>{E>Er&&(z=_(E));var C=typeof x,P;if(C==="string"){let N=x.length;if(Lr&&N>=8&&N<4096){let R=cw.test(x);Lr[R?0:1]+=x,z[E++]=193,S(R?-N:N);return}let O;N<32?O=1:N<256?O=2:N<65536?O=3:O=5;let A=N*3;if(E+A>Er&&(z=_(E+A)),N<64||!u){let R,k,$,te=E+O;for(R=0;R<N;R++)k=x.charCodeAt(R),k<128?z[te++]=k:k<2048?(z[te++]=k>>6|192,z[te++]=k&63|128):(k&64512)===55296&&(($=x.charCodeAt(R+1))&64512)===56320?(k=65536+((k&1023)<<10)+($&1023),R++,z[te++]=k>>18|240,z[te++]=k>>12&63|128,z[te++]=k>>6&63|128,z[te++]=k&63|128):(z[te++]=k>>12|224,z[te++]=k>>6&63|128,z[te++]=k&63|128);P=te-E-O}else P=u(x,E+O,A);P<32?z[E++]=160|P:P<256?(O<2&&z.copyWithin(E+2,E+1,E+1+P),z[E++]=217,z[E++]=P):P<65536?(O<3&&z.copyWithin(E+3,E+2,E+2+P),z[E++]=218,z[E++]=P>>8,z[E++]=P&255):(O<5&&z.copyWithin(E+5,E+3,E+3+P),z[E++]=219,et.setUint32(E,P),E+=4),E+=P}else if(C==="number")if(x>>>0===x)x<64?z[E++]=x:x<256?(z[E++]=204,z[E++]=x):x<65536?(z[E++]=205,z[E++]=x>>8,z[E++]=x&255):(z[E++]=206,et.setUint32(E,x),E+=4);else if(x>>0===x)x>=-32?z[E++]=256+x:x>=-128?(z[E++]=208,z[E++]=x+256):x>=-32768?(z[E++]=209,et.setInt16(E,x),E+=2):(z[E++]=210,et.setInt32(E,x),E+=4);else{let N;if((N=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){z[E++]=202,et.setFloat32(E,x);let O;if(N<4||(O=x*Ka[(z[E]&127)<<1|z[E+1]>>7])>>0===O){E+=4;return}else E--}z[E++]=203,et.setFloat64(E,x),E+=8}else if(C==="object")if(!x)z[E++]=192;else{if(l){let O=l.get(x);if(O){if(!O.id){let A=l.idsToInsert||(l.idsToInsert=[]);O.id=A.push(O)}z[E++]=214,z[E++]=112,et.setUint32(E,O.id),E+=4;return}else l.set(x,{offset:E-t})}let N=x.constructor;if(N===Object)T(x,!0);else if(N===Array){P=x.length,P<16?z[E++]=144|P:P<65536?(z[E++]=220,z[E++]=P>>8,z[E++]=P&255):(z[E++]=221,et.setUint32(E,P),E+=4);for(let O=0;O<P;O++)S(x[O])}else if(N===Map){P=x.size,P<16?z[E++]=128|P:P<65536?(z[E++]=222,z[E++]=P>>8,z[E++]=P&255):(z[E++]=223,et.setUint32(E,P),E+=4);for(let[O,A]of x)S(O),S(A)}else{for(let O=0,A=el.length;O<A;O++){let R=Vc[O];if(x instanceof R){let k=el[O];if(k.write){k.type&&(z[E++]=212,z[E++]=k.type,z[E++]=0),S(k.write.call(this,x));return}let $=z,te=et,X=E;z=null;let W;try{W=k.pack.call(this,x,H=>(z=$,$=null,E+=H,E>Er&&_(E),{target:z,targetView:et,position:E-H}),S)}finally{$&&(z=$,et=te,E=X,Er=z.length-10)}W&&(W.length+E>Er&&_(W.length+E),E=dw(W,z,E,k.type));return}}T(x,!x.hasOwnProperty)}}else if(C==="boolean")z[E++]=x?195:194;else if(C==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))z[E++]=211,et.setBigInt64(E,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)z[E++]=207,et.setBigUint64(E,x);else if(this.largeBigIntToFloat)z[E++]=203,et.setFloat64(E,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");E+=8}else if(C==="undefined")this.encodeUndefinedAsNil?z[E++]=192:(z[E++]=212,z[E++]=0,z[E++]=0);else if(C==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+C)},T=this.useRecords===!1?this.variableMapSize?x=>{let C=Object.keys(x),P=C.length;P<16?z[E++]=128|P:P<65536?(z[E++]=222,z[E++]=P>>8,z[E++]=P&255):(z[E++]=223,et.setUint32(E,P),E+=4);let N;for(let O=0;O<P;O++)S(N=C[O]),S(x[N])}:(x,C)=>{z[E++]=222;let P=E-t;E+=2;let N=0;for(let O in x)(C||x.hasOwnProperty(O))&&(S(O),S(x[O]),N++);z[P+++t]=N>>8,z[P+t]=N&255}:x=>{let C=Object.keys(x),P,N=s.transitions||(s.transitions=Object.create(null)),O=0;for(let R=0,k=C.length;R<k;R++){let $=C[R];P=N[$],P||(P=N[$]=Object.create(null),O++),N=P}let A=N[us];if(A)A>=96&&h?(z[E++]=((A-=96)&31)+96,z[E++]=A>>5):z[E++]=A;else{A=s.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(C)?(A=s.nextOwnId,A<g||(A=y),s.nextOwnId=A+1):(A>=g&&(A=y),s.nextId=A+1);let R=C.highByte=A>=96&&h?A-96>>5:-1;N[us]=A,s[A-64]=C,A<y?(C.isShared=!0,s.sharedLength=A-63,i=!0,R>=0?(z[E++]=(A&31)+96,z[E++]=R):z[E++]=A):(R>=0?(z[E++]=213,z[E++]=114,z[E++]=(A&31)+96,z[E++]=R):(z[E++]=212,z[E++]=114,z[E++]=A),O&&(b+=w*O),v.length>=m&&(v.shift()[us]=0),v.push(N),S(C))}for(let R=0,k=C.length;R<k;R++)S(x[C[R]])},_=x=>{let C;if(x>16777216){if(x-t>fm)throw new Error("Packed buffer would be larger than maximum buffer size");C=Math.min(fm,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else C=(Math.max(x-t<<2,z.length-1)>>12)+1<<12;let P=new Rc(C);return et=new DataView(P.buffer,0,C),z.copy?z.copy(P,0,t,x):P.set(z.slice(t,x)),E-=t,t=0,Er=P.length-10,z=P}}useBuffer(r){z=r,et=new DataView(z.buffer,z.byteOffset,z.byteLength),E=0}};Vc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,ds];el=[{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?mm(n,16,r):hm(tl?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==ym&&this.structuredClone?mm(n,Gc.indexOf(e.name),r):hm(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function mm(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:l}=e(7+o);i[s++]=201,l.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function hm(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 dw(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 uw(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 l=i+t;n[l++]=214,n[l++]=105,n[l++]=s>>24,n[l++]=s>>16&255,n[l++]=s>>8&255,n[l++]=s&255,o=i}return n}function go(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)");Vc.unshift(n.Class),el.unshift(n)}pm(n)}var gm=new zo({useRecords:!1}),pw=gm.pack,fw=gm.pack;var{NEVER:mw,ALWAYS:hw,DECIMAL_ROUND:yw,DECIMAL_FIT:gw}=Qa,xm=512,xw=1024;var vm=new zo({structuredClone:!0});go({Class:Re.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Re.prototype),n}});go({Class:ye.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ye.prototype),n}});go({Class:nt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,nt.prototype),n}});go({Class:ls.prototype.constructor,type:4,write(n){return n.id},read(n){return new ls(n)}});go({Class:cs.prototype.constructor,type:5,write(n){return n.data},read(n){return new cs(n)}});go({Class:Ue.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,Ue.prototype),n}});function vw(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 zc(n){if(Ln(n))return n;if(Array.isArray(n))return n.map(zc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=zc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var rl;(t=>{function n(o){return vm.pack(o)}t.serialize=n;function r(o){return vm.unpack(o)}t.deserialize=r;function e(o){return vw(n(zc(o))).toString()}t.checksum=e})(rl||(rl={}));var bm;(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})(bm||(bm={}));var xo;(l=>{function n(c,u){return c[0]===u[0]&&c[1]===u[1]&&c[2]===u[2]}l.isEqual=n;function r(c,u){return[c[0]+u[0],c[1]+u[1],c[2]+u[2]]}l.add=r;function e(c,u){return[c[0]-u[0],c[1]-u[1],c[2]-u[2]]}l.sub=e;function t(c,u){return[c[0]/u[0],c[1]/u[1],c[2]/u[2]]}l.div=t;function o(c,u){return[c[0]*u[0],c[1]*u[1],c[2]*u[2]]}l.mul=o;function i(c,u){return Math.hypot(c[0]-u[0],c[1]-u[1],c[2]-u[2])}l.dist=i;function s(c,u,a){return[c[0]+(u[0]-c[0])*a,c[1]+(u[1]-c[1])*a,c[2]+(u[2]-c[2])*a]}l.lerp=s})(xo||(xo={}));var Sm;(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})(Sm||(Sm={}));var vo;(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 l=0;l<16;l++)if(i[l]!==s[l])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let l=s.slice(0);for(var c=0,u=s.length;c<u;c+=3){let a=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];l[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/a,l[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/a,l[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/a}return l}o.applyMatrix4=t})(vo||(vo={}));var Pt;(a=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}a.isRGB=n,a.white={r:1,g:1,b:1},a.red={r:1,g:0,b:0},a.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}}a.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}a.clone=i;function s(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}a.fromHex=s;function l(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}a.toHex=l;function c(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}a.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}}a.lerp=u})(Pt||(Pt={}));var Yt;(l=>{l.white={...Pt.white,a:1},l.transparent={...Pt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,u){return{...Pt.fromHex(c),a:u}}l.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}}l.toRgb255a1=o;function i(c,u){return Pt.equals(c,u)&&c.a===u.a}l.equals=i;function s(c,u,a){return{r:c.r+(u.r-c.r)*a,g:c.g+(u.g-c.g)*a,b:c.b+(u.b-c.b)*a,a:c.a+(u.a-c.a)*a}}l.lerp=s})(Yt||(Yt={}));var ol;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ol||(ol={}));var wm;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(wm||(wm={}));var _m;(r=>r.defaultData={control1:[.5,.05],control2:[.1,.3]})(_m||(_m={}));var ur;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(ur||(ur={}));var jo;(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,autoZoom:!1,autoZoomFrustumSize:790},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=t})(jo||(jo={}));var Br;(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(bw.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,l=o.radial;Sw.forEach(c=>{Object.assign(i.radial,{[c]:l[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,l=o.linear;ww.forEach(c=>{Object.assign(i.linear,{[c]:l[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,l=o.grid;_w.forEach(c=>{Object.assign(i.grid,{[c]:l[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,l=o.toObject;Tw.forEach(c=>{Object.assign(i.toObject,{[c]:l[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,l=o.randomnessObject;Pw.forEach(c=>{Object.assign(i.randomnessObject,{[c]:l[c]??s[c]})})}return i}e.merge=r})(Br||(Br={}));var nl;(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 l of r){let c=o[l];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,l],props:c})}return s}t.toOps=e})(nl||(nl={}));var bw=["count"],Sw=["radius","start","end","position","scale","rotation"],ww=["position","scale","rotation"],_w=["count","size"],Tw=["count","position","scale","rotation"],Pw=["strength","scale","rotation","position","movement","seed","freqScale"];var il;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function r(t){return e.all.includes(t)}e.is=r})(il||(il={}));var sl;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:Yt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(t==="SpotLight")return{type:t,color:Yt.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:Yt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(sl||(sl={}));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 Fc;(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})(Fc||(Fc={}));var al;(r=>r.defaultData={...Fc.defaultData,...jc.defaultData})(al||(al={}));var jn;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(jn||(jn={}));var Tm;(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})(Tm||(Tm={}));function Om(n){return n.type!=="displace"}var Pm;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(Pm||(Pm={}));var Am=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Nm=["wrapping","image","video"],Ct;(o=>{function n(i,s){let{texture:l,...c}=s;if(Object.assign(i,c),l){let u=i.texture;u&&Object.assign(u,l)}}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};switch(i){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",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};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1}}}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:jn.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!1};case"color":return{...s,type:"color",color:Pt.fromHex(5526619)};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:{...Pt.fromHex(6710886),a:1},colorB:{...Pt.fromHex(6710886),a:1},colorC:{...Pt.fromHex(16777215),a:1},colorD:{...Pt.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:Yt.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:Yt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Yt.fromHexAndA(0,1),contourColor:Yt.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:{...Pt.fromHex(0),a:1},colorB:{...Pt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Ct||(Ct={}));var Gt;(c=>{function n(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=n;function r(u){let a="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{a+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>a+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?a+=`${m.toFixed(4)}`:a+=`${m}`}):a+=`${f}`})}),a}c.getHash=r;function e(){return{layers:new ye}}c.defaultEmptyData=e;function t(u="layer1",a="layer2"){return i("phong",u,a)}c.defaultData=t;function o(u,a){return{...u,name:a}}c.withName=o;function i(u,a="layer1",d="layer2"){let p=new ye;return p.push({fi:0,data:Ct.defaultData("light",u),id:a}),p.push({fi:1,data:Ct.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function s(u,a="phong",d="layer1",p="layer2"){let f=Ct.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ye;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ct.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,a="phong",d="layer1",p="layer2"){let f=Ct.defaultData("video");Object.assign(f.texture,{video:u});let m=new ye;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Ct.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Gt||(Gt={}));var Fn;(r=>{function n(){return{points:new ye,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(Fn||(Fn={}));var kn;(r=>{function n(){return{points:new ye,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(kn||(kn={}));var kc={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var ll;(r=>{function n(e,t){let o={...e};return Ow.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(ll||(ll={}));var cl={shape:kc,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},Ow=["depth","offset","angle","twist","startScale","endScale"];var ps;(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})(ps||(ps={}));var dl;(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,ll.merge(o.extrusion,t.extrusion))),o}r.merge=n})(dl||(dl={}));var bo;(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:kn.defaultData(),extrusion:cl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Fn.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})(bo||(bo={}));var Cm;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Cm||(Cm={}));var Un;(o=>{o.identity={...ol.identity,hiddenMatrix:vo.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 xu({position:xo.isEqual(i.position,s.position)?void 0:s.position,rotation:xo.isEqual(i.rotation,s.rotation)?void 0:s.rotation,scale:xo.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:vo.isEqual(i.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}o.diff=t})(Un||(Un={}));var Im;(r=>r.defaultData={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]})(Im||(Im={}));var Kt;(r=>r.defaultData={states:new ye,events:new ye,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Un.identity,cloner:null})(Kt||(Kt={}));var Mm;(r=>r.defaultData={type:"Empty",...Kt.defaultData})(Mm||(Mm={}));var Em;(r=>r.defaultData={type:"Component",...Kt.defaultData})(Em||(Em={}));var Fo;(r=>r.defaultData={type:"Mesh",...Kt.defaultData,...al.defaultData})(Fo||(Fo={}));var Hn;(r=>r.defaultData={...Kt.defaultData,...Un.identity,...jo.defaultData})(Hn||(Hn={}));var Lm;(r=>{function n(e){return{...Kt.defaultData,...sl.defaultData(e)}}r.defaultData=n})(Lm||(Lm={}));var qn;(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 l=Object.keys(s);if(l.length===1&&l[0]==="descendants")return}return s}e.resolve=r})(qn||(qn={}));var So;(i=>{i.rootOverrideProps=["physics"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,l){return{...Kt.defaultData,...l,component:s,overrides:new Ue,physics:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let l=Un.fromObject(s.data);return t(s.id,l)}i.fromComponentData=o})(So||(So={}));var Bm;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:vo.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new ye,events:new ye,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...jo.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",...Kt.defaultData,...Fo.defaultData,geometry:bo.defaultData("RectangleGeometry"),material:Gt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Kt.defaultData,...Fo.defaultData,geometry:bo.defaultData("BooleanGeometry"),material:Gt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Kt.defaultData,...Fo.defaultData,geometry:bo.defaultData("TextGeometry"),material:Gt.defaultTwoLayerData("phong","layer1","layer2")}))(Bm||(Bm={}));var ko;(o=>{function n(i,s){let l={name:s};return i.type==="Mesh"?(l.geometry={},"material"in i&&(l.material={layers:new Ue}),"materials"in i&&(l.materials=i.materials.map(c=>({layers:new Ue})))):ur.is(i.type)&&(l.perspective={},l.orthographic={}),l}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let l={...i};return"material"in l&&"material"in s&&s.material&&(l.material=Vn(l.material,c=>{if(typeof c!="string")for(let[u,a]of Object.entries(s.material.layers)){let d=c.layers.data(u);d&&Ct.patch(d,a)}}).data),l.materials&&s.materials&&(l.materials=Vn(l.materials,c=>{for(let u=0;u<l.materials.length;u++){let a=s.materials[u];if(typeof a!="string")for(let[d,p]of Object.entries(a.layers)){let f=c[u]?.layers?.data(d);f&&Ct.patch(f,p)}}}).data),l}function e(i,s){let l,c=[],u={orthographic:0,perspective:0,geometry:0};function a(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(s))if(d!=="name")if(d==="cloner")c.push(...nl.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")a(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))a(["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 l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[d]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let l={...i};if(Object.assign(l,Un.merge(l,s)),Object.assign(l,{pathSnapping:Object.assign({},l.pathSnapping,{slide:s.pathSnapping?.slide??l.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??l.pathSnapping?.offset??0})}),ur.is(i.type)){l.orthographic={...l.orthographic},l.perspective={...l.perspective};let c=s;c.orthographic?.zoom!==void 0&&(l.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(l.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(l.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(l.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in s&&Object.assign(l,{geometry:dl.merge(l.geometry,s.geometry)}),(s.material||s.materials)&&(l=r(l,s)),l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Br.merge(l.cloner,s.cloner)});else if(i.type==="Empty")l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Br.merge(l.cloner,s.cloner)});else if(il.is(i.type)){let c=s;c.intensity!==void 0&&(l.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?l.color=c.color:l.color=Pt.clone(c.color))}return l}o.patch=t})(ko||(ko={}));var Wn;(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,autoZoom:!1})(Wn||(Wn={}));var ul;(r=>r.defaultData={orbitControls:Wn.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",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,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"]}),gameControlObject:null,hdTransmission:!1})(ul||(ul={}));var Uc;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Uc||(Uc={}));var Hc;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Hc||(Hc={}));var pl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Uc.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Hc.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(pl||(pl={}));var $n;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})($n||($n={}));var fl;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Yr(o,Re.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...$n.emptyImage,name:"AI generated image"}),Yr(i,Re.prototype)}t.defaultImages=r;function e(){return{materials:new Re,images:new Re,videos:new Re,colors:new Re,audios:new Re,fonts:new Re,penumbraSize:[2,2,2]}}t.emptyData=e})(fl||(fl={}));var ys=require("three");var ml;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,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"]],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},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Yt.fromHexAndA(3728051,1)}}))(ml||(ml={}));function Dm(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 l=2;l<10;l++)o.push(o[1]),i.push(1);let s={...Mn(ut(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={...ut(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function ms(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function hs(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(o=>{typeof o!="string"&&r(o)}):"material"in t&&typeof t.material!="string"&&r(t.material)})}function Aw(n){Object.assign(n.scene.publish,{orbitControls:{...Wn.defaultData,...ut(n.scene.publish.orbitControls)}})}function Nw(n){Object.assign(n.scene.publish.settings,{video:{...ul.defaultData.settings.video,...ut(n.scene.publish.settings.video)}})}function Cw(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((Am.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,l]of Object.entries(i))(Nm.includes(s)||typeof l=="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 Iw(n){n.scene.publish.withBackground=!0}function Mw(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function Ew(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 Lw(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 Bw(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=ut(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ut(e).booleanExclude!==!0)}})}function Dw(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 Gw(n){function r(t){Object.setPrototypeOf(t,Ue.prototype),t.texture&&Object.setPrototypeOf(t.texture,Ue.prototype)}function e(t){Object.setPrototypeOf(t,Ue.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 l=ut(s.material).layers;e(l),s.material.layers=l}if(s.materials)for(let l=0;l<s.materials.length;l++){let c=s.materials[l],u=ut(c).layers;e(u),c.layers=u}})})}function Gm(n){n.layers===void 0&&Object.assign(n,Gt.defaultTwoLayerData("lambert"))}function qc(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={...ut(r),colors:e,steps:t};Object.assign(r,o)}})}function Rw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Rm(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&qc(t)}):"material"in e&&typeof e.material!="string"&&qc(e.material)}),Object.values(n.shared.materials).forEach(r=>qc(r))}function Vw(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 zw(n){n.shared.audios=Yr({},Re.prototype)}function jw(n){n.shared.videos=Yr({},Re.prototype)}function Fw(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 kw(n){Object.entries(ut(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(ut(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function Uw(n){n.scene.publish.settings.web.preload=!1}function Vm(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 zm(n){n.layers&&n.layers.forEach(r=>{Om(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 Hw(n){n.shared.fonts=Yr({},Re.prototype)}function qw(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 Ww(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=Gt.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 l=qw(o.font);n.shared.fonts[l]===void 0&&(n.shared.fonts[l]={name:l});let c={name:o.name,...Kt.defaultData,...Fo.defaultData,flatShading:!1,wireframe:!1,geometry:{...bo.defaultData("TextGeometry"),width:o.width,height:o.height,font:l,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:ut(o.states),events:ut(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=ut(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 $w(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:ys.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,l,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},a={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(a,Mn(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(a,{control1:{...s.control1},control2:{...s.control2}});let d={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,...d,...a},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ye({fi:0,id:ys.MathUtils.generateUUID(),data:u},{fi:1,id:ys.MathUtils.generateUUID(),data:p})};i.push({fi:c,id:l,data:f})}),delete o.targets)}})})}function Xw(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new ye,l=[];if(e.events.forEach((c,u,a)=>{if(c.type==="Audio"&&c.trigger===i){let d;l.push(u),c.interaction==="play"?d={...Mn(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={...Mn(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&s.push({fi:a,id:u,data:d})}}),l.forEach(c=>e.events.delete(c)),s.length){let c=e.events.find(u=>u.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,s):e.events.insertBefore(null,[{id:ys.MathUtils.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function jm(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 Fm(n){ms(n,jm),hs(n,jm)}function Yw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function Kw(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 Zw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Gt.defaultTwoLayerData("phong"))})}function Qw(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 Jw(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 e_(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 t_(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function r_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function o_(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function n_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=ml.defaultDataThirdPerson.navmesh)})})}function i_(n){n.scene.styles||(n.scene.styles=pl.defaultData())}var km=40;function Um(n){let r=n.schema??0;r!==km&&(console.warn("updating from ",r,"to ",km),r<1&&(hs(n,Dm),ms(n,Dm),n.schema=1),r<2&&(Aw(n),n.schema=2),r<3&&(Cw(n),n.schema=3),r<4&&(Iw(n),n.schema=4),r<5&&(Mw(n),n.schema=5),r<6&&(Ew(n),n.schema=6),r<7&&(Lw(n),n.schema=7),r<8&&(n.schema=8),r<9&&(Rm(n),n.schema=9),r<10&&(Rw(n),n.schema=10),r<11&&(Vw(n),n.schema=11),r<12&&(Rm(n),n.schema=12),r<13&&(zw(n),n.schema=13),r<14&&(Fw(n),n.schema=14),r<15&&(kw(n),n.schema=15),r<16&&(Uw(n),n.schema=16),r<17&&(hs(n,Vm),ms(n,Vm),n.schema=17),r<18&&(hs(n,Gm),ms(n,Gm),n.schema=18),r<19&&(Nw(n),n.schema=19),r<20&&(Hw(n),Ww(n),n.schema=20),r<21&&($w(n),Xw(n),n.schema=21),r<22&&(Fm(n),n.schema=22),r<23&&(Yw(n),n.schema=23),r<24&&(Kw(n),n.schema=24),(r<25||n.shared.videos===void 0)&&(jw(n),r<25&&(n.schema=25)),r<26&&(Bw(n),n.schema=26),r<27&&(Dw(n),n.schema=27),r<28&&(Fm(n),n.schema=28),r<29&&(Gw(n),n.schema=29),r<30&&(Zw(n),n.schema=30),r<31&&(Qw(n),n.schema=31),r<33&&(Jw(n),n.schema=33),r<34&&(e_(n),n.schema=34),r<35&&(t_(n),n.schema=35),r<36&&(r_(n),n.schema=36),r<37&&(o_(n),n.schema=37),r<38&&(hs(n,zm),ms(n,zm),n.schema=38),r<39&&(n_(n),n.schema=39),r<40&&(i_(n),n.schema=40))}var Me=require("three"),Hi=ln(qm());var s_=.5*(Math.sqrt(3)-1),xs=(3-Math.sqrt(3))/6,a_=1/3,Dr=1/6,WB=(Math.sqrt(5)-1)/4,$B=(5-Math.sqrt(5))/20,vs=n=>Math.floor(n)|0,Wm=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]),$c=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 hl(n=Math.random){let r=Xm(n),e=new Float64Array(r).map(o=>Wm[o%12*2]),t=new Float64Array(r).map(o=>Wm[o%12*2+1]);return function(i,s){let l=0,c=0,u=0,a=(i+s)*s_,d=vs(i+a),p=vs(s+a),f=(d+p)*xs,m=d-f,h=p-f,y=i-m,g=s-h,v,b;y>g?(v=1,b=0):(v=0,b=1);let w=y-v+xs,S=g-b+xs,T=y-1+2*xs,_=g-1+2*xs,x=d&255,C=p&255,P=.5-y*y-g*g;if(P>=0){let A=x+r[C],R=e[A],k=t[A];P*=P,l=P*P*(R*y+k*g)}let N=.5-w*w-S*S;if(N>=0){let A=x+v+r[C+b],R=e[A],k=t[A];N*=N,c=N*N*(R*w+k*S)}let O=.5-T*T-_*_;if(O>=0){let A=x+1+r[C+1],R=e[A],k=t[A];O*=O,u=O*O*(R*T+k*_)}return 70*(l+c+u)}}function $m(n=Math.random){let r=Xm(n),e=new Float64Array(r).map(i=>$c[i%12*3]),t=new Float64Array(r).map(i=>$c[i%12*3+1]),o=new Float64Array(r).map(i=>$c[i%12*3+2]);return function(s,l,c){let u,a,d,p,f=(s+l+c)*a_,m=vs(s+f),h=vs(l+f),y=vs(c+f),g=(m+h+y)*Dr,v=m-g,b=h-g,w=y-g,S=s-v,T=l-b,_=c-w,x,C,P,N,O,A;S>=T?T>=_?(x=1,C=0,P=0,N=1,O=1,A=0):S>=_?(x=1,C=0,P=0,N=1,O=0,A=1):(x=0,C=0,P=1,N=1,O=0,A=1):T<_?(x=0,C=0,P=1,N=0,O=1,A=1):S<_?(x=0,C=1,P=0,N=0,O=1,A=1):(x=0,C=1,P=0,N=1,O=1,A=0);let R=S-x+Dr,k=T-C+Dr,$=_-P+Dr,te=S-N+2*Dr,X=T-O+2*Dr,W=_-A+2*Dr,H=S-1+3*Dr,V=T-1+3*Dr,G=_-1+3*Dr,B=m&255,L=h&255,D=y&255,Y=.6-S*S-T*T-_*_;if(Y<0)u=0;else{let M=B+r[L+r[D]];Y*=Y,u=Y*Y*(e[M]*S+t[M]*T+o[M]*_)}let q=.6-R*R-k*k-$*$;if(q<0)a=0;else{let M=B+x+r[L+C+r[D+P]];q*=q,a=q*q*(e[M]*R+t[M]*k+o[M]*$)}let j=.6-te*te-X*X-W*W;if(j<0)d=0;else{let M=B+N+r[L+O+r[D+A]];j*=j,d=j*j*(e[M]*te+t[M]*X+o[M]*W)}let F=.6-H*H-V*V-G*G;if(F<0)p=0;else{let M=B+1+r[L+1+r[D+1]];F*=F,p=F*F*(e[M]*H+t[M]*V+o[M]*G)}return 32*(u+a+d+p)}}function Xm(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Ym=require("three"),fr=new Ym.Triangle,yl=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;fr.a.fromBufferAttribute(r,o),fr.b.fromBufferAttribute(r,o+1),fr.c.fromBufferAttribute(r,o+2),i*=fr.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),fr.a.fromBufferAttribute(this.positionAttribute,r*3),fr.b.fromBufferAttribute(this.positionAttribute,r*3+1),fr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(fr.a,o).addScaledVector(fr.b,i).addScaledVector(fr.c,1-(o+i)),fr.getNormal(t),this}};var Jm=require("three");var tr=require("three"),Qm=ln(Zm()),l_=new tr.Matrix4,c_=new tr.Matrix4,d_=new tr.Matrix4,bs;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(bs||(bs={}));var Xn=n=>class extends n{constructor(){super(...arguments);this.hiddenMatrix=new tr.Matrix4;this.matrixWorldRigid=new tr.Matrix4;this.shearScale=new tr.Matrix4;this.shearScaleInv=new tr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof tr.Object3D&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)bs.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:l}=(0,Qm.SVD)(o),c=l_.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=c_.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),a=d_.copy(u).transpose();this.shearScale.makeScale(l[0],l[1],l[2]).multiply(a).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,a).copyPosition(this.matrixWorld),l.every(d=>Math.abs(l[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new tr.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof tr.Matrix4?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}};var Xc=class extends Xn(Jm.Object3D){},u_=n=>n.type==="Mesh",oo=class extends Xc{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 u_(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var mi=require("three");var Dl=require("three");var no=require("three");var Ke=require("three"),Uo=new Ke.Vector3,Ho=new Ke.Vector3,Yn=new Ke.Matrix4,th=[new Ke.Vector3(-1,1,1),new Ke.Vector3(-1,-1,1),new Ke.Vector3(1,-1,1),new Ke.Vector3(1,1,1),new Ke.Vector3(-1,1,-1),new Ke.Vector3(-1,-1,-1),new Ke.Vector3(1,-1,-1),new Ke.Vector3(1,1,-1)],p_=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],f_=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],eh=(n,r,e)=>{n.updateEntityBoxSize(Uo,Ho),Yn.copy(r).multiply(n.matrixWorld),Ho.x===0&&Ho.y===0&&Ho.z===0?e.push(new Ke.Vector3(Uo.x,Uo.y,Uo.z).applyMatrix4(Yn)):th.forEach(t=>{e.push(t.clone().multiply(Ho).add(Uo).applyMatrix4(Yn))})},Ss=class extends Ke.Box3{constructor(){super(...arguments);this.matrix=new Ke.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Ke.Matrix4().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 Ke.Vector3);return}eh(s,t,i)}}):eh(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(Yn.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Ho).multiplyScalar(.5),this.getCenter(Uo),Yn.copy(this.matrix).setPosition(Uo),this.vertices=th.map(e=>e.clone().multiply(Ho).applyMatrix4(Yn))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=p_.map(([e,t])=>new Ke.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ke.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=f_.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var mr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var ft=require("three"),Kc=class extends ft.CurvePath{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),s=o[o.length-1]/o.length;for(let l=0,c=this.curves;l<c.length;l++){let u=c[l],a=l===0?o[l]:o[l]-o[l-1],d=Math.ceil(r*a/s),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 Zc=.001;function Qc(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Zc}function Yc(n,r){let e=new ft.Vector3(...n.position),t=new ft.Vector3(...n.controlNext.position),o=new ft.Vector3(...r.controlPrevious.position),i=new ft.Vector3(...r.position);return Qc(e,t,i)&&Qc(e,o,i)}function xl(n){let r=n.points.map(a=>new ft.Vector3(...a.data.position)),e=[n.points[0]],t=new ft.Vector3(...e[0].data.position);for(let a=0;a<n.points.length-1;a++)Qc(t,r[a],r[a+1])||(e.push(n.points[a]),t=r[a]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),s=e.length,l=[];for(let a=0;a<s;a++){let d=e[a].data,p=new ft.Vector3(...d.position),f=new ft.Vector3(...d.controlPrevious.position),m=new ft.Vector3(...d.controlNext.position),h={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!n.isClosed&&(a===0||a===s-1)){l[a]={...h,removedLength:0};continue}let y=o&&a==0?s-1:a-1,g=o&&a==s-1?0:a+1,v=e[y].data,b=e[g].data,w=new ft.Vector3(...v.position),S=new ft.Vector3(...b.position),T=w.clone().sub(p).normalize(),_=S.clone().sub(p).normalize();Object.assign(h,{prevDir:T,nextDir:_});let x=Yc(v,d),C=Yc(d,b);if(!x||!C)l[a]={...h,removedLength:0};else{let P=T.clone().add(_).normalize(),N=P.clone().cross(T).length()/T.dot(P);l[a]={...h,tan:N,removedLength:d.roundness/N}}}for(let a=0;a<i;a++){let d=a,p=o&&a===s-1?0:a+1,f=l[d],m=l[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 a=0;a<i;a++){let d=a,p=o&&a===s-1?0:a+1,f=l[d],m=l[p],h=null;if(!Yc(e[d].data,e[p].data))f.position.distanceTo(m.position)>Zc&&(h=new ft.CubicBezierCurve3(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)>Zc&&(h=new ft.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*a+1]=h}for(let a=0;a<s;a++){let d=l[a];if(d.removedLength===0){c[2*a]=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),v=f.distanceTo(m)/2,b=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(v,2))).add(g),w=y.clone().multiplyScalar(-h).add(b),S=p.distanceTo(w)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),_=T.clone().lerp(w,2),x=f.clone().lerp(T,4/3),C=m.clone().lerp(_,4/3);c[2*a]=new ft.CubicBezierCurve3(f,x,C,m)}let u=new Kc;return c.forEach(a=>{a&&u.add(a)}),u}var De;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(De||(De={}));var ws=n=>De.is(n),m_={type:"completeState",isfromEntity:!0},vl=n=>class extends Xn(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 Ss;this._recursiveBBox=new Ss;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(De.is(o))return o}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(De.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)ko.toOps(this.data,s.data).forEach(c=>{let u=ka.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=ko.patch(this.data,s),ko.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=>{ws(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(De.is(o[i]))return o[i];if(De.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&De.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)ws(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{De.is(o)&&t(o)})}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)ws(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)ws(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=>ws(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 In(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??vo.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)De.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{De.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return In(o,t)}updateByOp(t,o,i,s){let l=this.data;this.data=o;let c=t,u=dr(t.path,["states","*"]);if(u!==null){if(t.type===0){let[a]=u;if(this?.stateSelection===a){let d={...t.props};if(Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=At.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 a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:p,...f}=a;a=f}if(t.props.material!==void 0&&"material"in a){let{material:p,...f}=a;a=f}let d=At.removeOverridden(t.path,t.props,a);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,ko.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),dr(t.path,["overrides"])){let a=[],d=[...t.path];for(a.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)a.push(d[1]),d.splice(0,2);if(a[a.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){a[a.length-1]=p;let f=i.scene.findInstance([this.uuid,...a]);f&&(f.overrideData=t.props[p],f.updateState(to.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...a]);if(p){let f=At.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=qn.resolve(o.overrides,a),p.updateByOp(t,vt.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let a;if(t.path.length===0&&t.type===0){let d;for(let p of So.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(a={...t,props:d})}else for(let d of So.rootOverrideProps)if(dr(t.path,[d])){a=t;break}a!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=to.filterOp(d.overrideData,a);p&&d.updateByOp(p,vt.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=to.filterOp(d.overrideData,t);if(p){let f;l===d.data&&t===p?f=o:f=vt.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&&!ur.is(t.props.type)&&mr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){mr.changeEntityProptotype(this,o,i);for(let s of this.children)De.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),dr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),dr(t.path,["cloner"])!==null){let s=vt.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,l=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,a=xl(u.geometry.path),d=(i+s)%1;i+s===1&&d===0&&(d=1);let p=a.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new no.Matrix4;c.updateMatrixWorld();let m=new no.Matrix4().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(l==="tangential"){let y=new no.Matrix4().extractRotation(c.matrixWorld),g=a.getTangentAt(d).applyMatrix4(y).add(p),v=new no.Matrix4().lookAt(p,g,new no.Vector3(0,1,0)),b=new no.Euler().setFromRotationMatrix(v);h={...h,rotation:[b.x,b.y,b.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(m_)})}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()),"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 mr.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 mr.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)}};var nh=require("three");var ke=require("three"),oh=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:l,thetaLength:c,radiusTop:u,radiusBottom:a,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return d||f?m=new _s(u,a,t,o,i,s,l,c*Math.PI/180,d,d,p,f):m=new ke.CylinderGeometry(u,a,t,o,i,s,l,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function wo(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function rh(n){return new ke.Vector2(n.y,-n.x)}var _s=class extends ke.BufferGeometry{constructor(r,e,t,o,i,s,l,c,u,a,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,s=s!==void 0?s:!1,l=l!==void 0?l:0,c=c!==void 0?c:Math.PI*2,s&&(u=0,a=0);let m=[],h=[],y=[],g=[],v=0,b=t/2,w=new ke.Vector3,S=new ke.Vector3;f&&r==0&&(r=u),f&&e==0&&(e=a);let T=new ke.Vector2(r,b),_=new ke.Vector2(e,-b),x=null,C=null,P=null,N=null,O=T.clone().sub(_),A=0,R=0,k=0;p>0&&(A=Math.min(r,e)*(1-p),R=r-A,k=e-A);let $=T.clone();$.x-=A;let te=Math.PI-O.angle(),X=O.angle(),W=Math.tan(X/2),H=Math.tan(te/2),V=W+H,G=p?V:H,B=p?V:W;if(u=Math.min(u,(r-R)/G,O.length()/V),a=Math.min(a,(e-k)/B,O.length()/V),u>0){let F=u/W;x=T.clone().sub(new ke.Vector2(F,u)),p&&(P=x.clone(),P.x-=A-V*u),T.sub(O.clone().setLength(F))}if(a>0){let F=a/H;C=_.clone().sub(new ke.Vector2(F,-a)),_.add(O.clone().setLength(F)),p&&(N=C.clone(),N.x-=A-V*a,$.sub(O.clone().setLength(F)))}O=T.clone().sub(_);let L=O.length()<.5,D=[];for(let F=0;F<=o;F++){let M=[],Q=F/o,re=Q*c+l,oe=new ke.Vector2(Math.sin(re),Math.cos(re));N&&C?(Y(M,Q,oe,te,a,N,-1,!0),Y(M,Q,oe,X,a,C,-1,!1)):C?(q(M,oe,C.x,0,-1),Y(M,Q,oe,X,a,C,-1,!1)):s||q(M,oe,e,k,-1);let K=rh(O).normalize();if(wo(K,oe,w),!L)for(let ee=0;ee<=i;ee++){let J=ee/i,se=O.clone().multiplyScalar(J).add(_);wo(se,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(v++)}if(P&&x?(Y(M,Q,oe,te,u,x,1,!1),Y(M,Q,oe,X,u,P,1,!0)):x?(Y(M,Q,oe,te,u,x,1,!1),q(M,oe,x.x,0,1)):s||q(M,oe,r,R,1),p&&!L){let ee=rh(O).multiplyScalar(-1).normalize();wo(ee,oe,w);for(let J=0;J<=i;J++){let se=J/i,de=O.clone().multiplyScalar(-se).add($);wo(de,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(v++)}}p&&!s&&M.push(M[0]),D.push(M)}for(let F=0;F<D.length-1;F++)for(let M=0;M<D[0].length-1;M++){if(s&&p&&M==i)continue;let Q=D[F][M],re=D[F+1][M],oe=D[F+1][M+1],K=D[F][M+1],ee=h[oe*3+0],J=h[oe*3+2];m.push(Q,re,K),(ee!=0||J!=0)&&m.push(re,oe,K)}c<Math.PI*2&&(j(-1,D[0],l),j(1,D[D.length-1],l+c)),this.setIndex(m),this.setAttribute("position",new ke.Float32BufferAttribute(h,3)),this.setAttribute("normal",new ke.Float32BufferAttribute(y,3)),this.setAttribute("uv",new ke.Float32BufferAttribute(g,2));function Y(F,M,Q,re,oe,K,ee,J){for(let se=0;se<d+1;se++){let de=se/d,ae=ee<0?de:1-de;J&&(ae-=1),ae*=re;let me=new ke.Vector2(Math.sin(ae),Math.cos(ae)*ee),$e=me.clone().multiplyScalar(oe).add(K);wo($e,Q,S),h.push(S.x,S.y,S.z),wo(me,Q,w),y.push(w.x,w.y,w.z),g.push(M,.5+S.y/t),F.push(v++)}}function q(F,M,Q,re,oe){let K=new ke.Vector3,ee=new ke.Vector2,J=[Q,re];oe<0&&J.reverse();for(let se of J)ee.set(se,b*oe),wo(ee,M,K),h.push(K.x,K.y,K.z),y.push(0,oe,0),g.push(.5,.5),F.push(v++)}function j(F,M,Q){let re=new ke.Vector2(Math.sin(Q),Math.cos(Q)),oe=new ke.Vector2(-Math.cos(Q),Math.sin(Q)),K=new ke.Vector3,ee=F<0?(de,ae,me)=>m.push(de,ae,me):(de,ae,me)=>m.push(de,me,ae),J=new ke.Vector2((r+e+R+k)/4,0);wo(J,re,K),h.push(K.x,K.y,K.z),y.push(oe.x,0,oe.y),g.push(.5,.5);let se=v++;for(let de of M){let ae=h.slice(de*3,de*3+3);h.push(...ae),y.push(oe.x,0,oe.y);let me=g.slice(de*2,de*2+2);g.push(...me),v++}for(let de=se+1;de<v-1;de++)ee(se,de,de+1);ee(se,v-1,se+1)}}};var ih=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:l,thetaLength:c,cornerRadiusTop:u,cornerRadiusBottom:a,cornerSegments:d}=n.parameters,p;return u>0||a>0||c<360?p=new _s(0,r/2,t,o,i,s,l,c*Math.PI/180,u,a,d,0,!0):p=new nh.ConeGeometry(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var Rt=require("three"),sh=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:l,cornerSegments:c}=n.parameters,u;return l==0?u=new Rt.BoxGeometry(r,e,t,o,i,s):u=new ed(r,e,t,o,i,s,l,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},Jc=Math.PI/2,ed=class extends Rt.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,s=1,l=0,c=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),s=Math.floor(s),c=Math.floor(c),l=Math.min(l,r/2,e/2,t/2);let a=[],d=[],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),l>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),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(a),this.setAttribute("position",new Rt.Float32BufferAttribute(d,3)),this.setAttribute("normal",new Rt.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Rt.Float32BufferAttribute(f,2));function y(b,w,S,T,_,x,C,P,N,O,A){let R=(x-2*l)/N,k=(C-2*l)/O,$=x/2-l,te=C/2-l,X=P/2,W=N+1,H=O+1,V=0,G=0,B=new Rt.Vector3;for(let L=0;L<H;L++){let D=L*k-te;for(let Y=0;Y<W;Y++){let q=Y*R-$;B[b]=q*T,B[w]=D*_,B[S]=X,d.push(B.x,B.y,B.z),B[b]=0,B[w]=0,B[S]=P>0?1:-1,p.push(B.x,B.y,B.z),f.push(Y/N),f.push(1-L/O),V+=1}}for(let L=0;L<O;L++)for(let D=0;D<N;D++){let Y=m+D+W*L,q=m+D+W*(L+1),j=m+(D+1)+W*(L+1),F=m+(D+1)+W*L;a.push(Y,q,F),a.push(q,j,F),G+=6}u.addGroup(h,G,A),h+=G,m+=V}function g(b,w,S,T,_,x,C,P,N,O,A){let R=(C-2*l)/O,k=C/2-l,$=P/2-l,te=N/2,X=O+1,W=0,H=0,V=new Rt.Vector3,G=new Rt.Vector3;for(let B=0;B<c+1;B++){let L=B/c*Jc,D=Math.sin(L)*l,Y=(1-Math.cos(L))*l,q=Math.sin(L),j=Math.cos(L);V[w]=($+D)*_,V[S]=(te-Y)*x,G[b]=0,G[w]=q*Math.sign(V[w]),G[S]=j*Math.sign(V[S]);for(let F=0;F<X;F++){let M=F*R-k;V[b]=M*T,d.push(V.x,V.y,V.z),p.push(G.x,G.y,G.z),f.push(F/O),f.push(0),W+=1}}for(let B=0;B<c;B++)for(let L=0;L<O;L++){let D=m+L+X*B,Y=m+L+X*(B+1),q=m+(L+1)+X*(B+1),j=m+(L+1)+X*B;a.push(D,Y,j),a.push(Y,q,j),H+=6}u.addGroup(h,H,A),h+=H,m+=W}function v(b,w,S){let T=new Rt.Vector3,_=new Rt.Vector3(r/2,e/2,t/2);_.subScalar(l);let x=[],C=b*w*S>0?(N,O,A)=>a.push(N,O,A):(N,O,A)=>a.push(N,A,O);for(let N=0;N<=c;N++){let O=[],A=Jc*(1-N/c),R=Math.cos(A),k=Math.sin(A),$=0;for(let te=0;te<=N;te++){let X=Math.cos($),W=Math.sin($);T.x=R*X,T.y=k,T.z=R*W;let H=_.clone().addScaledVector(T,l);d.push(b*H.x,w*H.y,S*H.z),p.push(b*T.x,w*T.y,S*T.z),f.push(0,0),O.push(m++),$+=Jc/N}x.push(O)}let P=x.length-1;for(let N=0;N<P;N++){let O=x[N],A=x[N+1],R=O.length-1;C(O[0],A[1],A[0]);for(let k=1;k<=R;k++)C(O[k-1],O[k],A[k]),C(O[k],A[k+1],A[k])}}}};var Ze=require("three"),_o=class extends Ze.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let l=[],c=[],u=[];a(),d(),this.setAttribute("position",new Ze.Float32BufferAttribute(l,3)),this.setAttribute("normal",new Ze.Float32BufferAttribute(u,3)),this.setAttribute("uv",new Ze.Float32BufferAttribute(c,2));return;function a(){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 Ze.Vector3,h=m.clone(),y=new Ze.Triangle,g=i*o,v=o-g,b=s+1,w=new Ze.Vector3,S=(W,H)=>w.subVectors(W,H).normalize(),T=(W,H)=>Array(W).fill(void 0).map(H),_=T(r.length/3,(W,H)=>new Ze.Vector3().fromArray(r,H*3).setLength(o)),x=[],C=1e6;for(let W=0;W<_.length;W++){let H=_[W],V=[],G,B,L,D=1e10,Y=-1;for(;(Y=e.indexOf(W,Y+1))!=-1;){let M=Y-Y%3;G=e[M+(Y+1)%3],B=e[M+(Y+2)%3],L=H.distanceToSquared(_[G]),D=Math.min(D,L),V.push([G,B,L])}D+=1e-6;let q=[],j=0,F=V.length;for(let M=0;M<F;M++){[G,B,L]=V[j];let Q=x[G]?.includes(W)==!0;L<=D&&q.push(G+ +Q*C),j=V.findIndex(re=>re[0]==B)}x.push(q)}let P=[];{let W=0,H=0,V,G,B=f==3;for(let L=0;L<=s;L++){V=L*(L+1)/2,G=(L+1)*(L+2)/2;for(let D=0;D<s-L;D++)[W,H]=[V+D+L+2,G+D+L+3],P.push(V,G,...B?[H,V]:[W,G],H,W),[V,G]=[W,H];P.push(V,G,V+s+2)}}let N=m.clone(),O=m.clone(),A=m.clone(),R=m.clone(),k=m.clone(),$=[],te=T(_.length,()=>T(f,()=>m.clone()));for(let W=0;W<_.length;W++){m.copy(_[W]).normalize(),N.copy(m).multiplyScalar(v);let H=x[W];for(let q=0;q<H.length;q++){let j=H[q],F=H[(q+1)%f];y.setFromPointsAndIndices(_,W,j%C,F%C),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(N,te[W][q])}let V=[],G=[],B=[],L=new Ze.Vector3;s==0&&[...te[W]].reduce((q,j)=>q.add(j),L).multiplyScalar(1/f);for(let q=0;q<f;q++){let j=[],F=(q-1+f)%f,M=te[W][F],Q=te[W][q];m.copy(M).sub(N),h.copy(Q).sub(N);let re=N.angleTo(m),oe=m.angleTo(h),K=Math.cos(re)*g;s==0?O.copy(L):O.copy(N).setLength(v+K),G.push(K);let ee=[O,M,Q];for(let J=0;J<2;J++){let se=ee[J],de=ee[J+1];R.subVectors(se,N),k.subVectors(de,N),A.crossVectors(R,k).normalize();for(let ae=0;ae<b;ae++){let me=[re,oe][J]*ae/b;m.copy(R).applyAxisAngle(A,me).add(N),V.push(m.clone()),J&&(S(m,N),j.push([ae==0?se:m.clone(),w.clone()]))}J&&(S(de,N),j.push([de,w.clone()]))}B.push(j)}$.push(B);let D=2*b,Y=2;for(let q=0;q<f;q++){let j=D*q,F=D*((q+1)%f),M=[V[j]];for(let re=1;re<b;re++){R=V[j+re],k=V[F+re],M.push(R);for(let oe=1,K=re-Y+1;oe<=K;oe++)m.lerpVectors(R,k,oe/(K+1)),m.sub(N).setLength(G[q]).add(N),M.push(m.clone());M.push(k)}for(let re=0;re<b;re++)M.push(V[re+b+j]);M.push(V[F+b]);let Q=P.map(re=>M[re]);l.push(...Q.map(re=>[re.x,re.y,re.z]).flat()),u.push(...Q.map(re=>(S(re,N),[w.x,w.y,w.z])).flat())}}let X=[];for(let W=0;W<x.length;W++)for(let H=0;H<f;H++){let V=x[W][H];if(V<C){let G=x[V].findIndex(D=>D%C==W),B=$[W][H],L=$[V][G];for(let D=0;D<b;D++){let Y=B[D],q=L[b-D],j=B[D+1],F=L[b-(D+1)];[Y,q,j,j,q,F].forEach(M=>{l.push(M[0].x,M[0].y,M[0].z),u.push(M[1].x,M[1].y,M[1].z)})}X.push(B[0][0],L[b][0],B[b][0],L[0][0])}}for(;X.length;){let W,H,V,G;[W,H]=X.splice(0,2);let B=[W];for(;W!=H;)B.push(H),V=X.indexOf(H),G=V%2,H=X.splice(V-G,2)[1-G];w.subVectors(B[0],B[1]).cross(m.subVectors(B[0],B[2])).normalize();let L=w.dot(B[0])<0;L&&w.negate();for(let D=1;D<=B.length-2;D++)[B[D+ +L],B[D+1-+L],B[0]].forEach(Y=>{l.push(Y.x,Y.y,Y.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new Ze.Vector3;for(let _=0;_<l.length;_+=3){p.x=l[_+0],p.y=l[_+1],p.z=l[_+2];let x=S(p)/2/Math.PI+.5,C=T(p)/Math.PI+.5;c.push(x,1-C)}let f=new Ze.Vector3,m=new Ze.Vector3,h=new Ze.Vector3,y=new Ze.Vector3,g=new Ze.Vector2,v=new Ze.Vector2,b=new Ze.Vector2,w=(_,x,C,P)=>{P<0&&_.x===1&&(c[x]=_.x-1),C.x===0&&C.z===0&&(c[x]=P/2/Math.PI+.5)};for(let _=0,x=0;_<l.length;_+=9,x+=6){f.set(l[_+0],l[_+1],l[_+2]),m.set(l[_+3],l[_+4],l[_+5]),h.set(l[_+6],l[_+7],l[_+8]),g.set(c[x+0],c[x+1]),v.set(c[x+2],c[x+3]),b.set(c[x+4],c[x+5]),y.copy(f).add(m).add(h).divideScalar(3);let C=S(y);w(g,x+0,f,C),w(v,x+2,m,C),w(b,x+4,h,C)}for(let _=0;_<c.length;_+=6){let x=c[_+0],C=c[_+2],P=c[_+4],N=Math.max(x,C,P),O=Math.min(x,C,P);N>.9&&O<.1&&(x<.2&&(c[_+0]+=1),C<.2&&(c[_+2]+=1),P<.2&&(c[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function T(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new _o(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var ah=require("three"),lh=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,l=o===0&&i!==0?new Ts(r*.5,i,s):new ah.DodecahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"DodecahedronGeometry"}})}},Ts=class extends _o{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],l=[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,l,c,r,e,t),this.type=c}static fromJSON(r){return new Ts(r.radius,r.corner,r.cornerSides)}};var Oe=require("three");var ge=require("three"),Ps=1e-12,Kn=class{constructor(r){this.position=new ge.Vector2;this.startPosition=new ge.Vector2;this.uuid=ge.MathUtils.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new Kn(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Zn=class extends Kn{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Zn(this.parent).copy(this)}},hr=class extends Kn{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Zn(this),new Zn(this))}static create(e,t){let o=new hr(e,new ge.Vector2(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let o=0,i=this.controls.length;o<i;o++){let 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 hr(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 ge.Vector2,t=new ge.Vector2){let[o,i]=this.computeTangents();return o&&i&&(ch(o,e),ch(i,t)),[e,t]}computeTangent(e=new ge.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new ge.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function ch(n,r=new ge.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var rd=n=>n,Qn=new ge.Vector2,bl=new ge.Vector2,h_=new ge.Vector2,y_=new ge.Vector2,g_=new ge.Vector2,x_=new ge.Vector2,uh=new ge.Vector3,ph=new ge.Vector3;function fh(n){let r=new ge.Vector2;r.addVectors(n.v0,Qn.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new ge.Vector2;return e.addVectors(n.v2,bl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new ge.CubicBezierCurve(n.v0,r,e,n.v2)}function Os(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function v_(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function b_(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function od(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 mh(n,r,e){return dh(n,r)&&dh(r,e)&&td(n.position,r.position,e.position)}function td(n,r,e){return Qn.copy(r).sub(n).cross(bl.copy(e).sub(n))===0}function hh(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,l=(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(l+c,s+u),o.set(l-c,s-u),[t,o]}function yh(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function gh(n,r,e,t,o,i){let s=r.x-n.x,l=r.y-n.y,c=e.x-n.x,u=e.y-n.y,a=Math.sqrt((s+c)*(s+c)+(l+u)*(l+u)),d;return od(r,n,e)>Math.PI&&(a*=-1),Os(u,l)?d=(l+u)*(t/a-.5)*8/3/(s-c):d=(s+c)*(t/a-.5)*8/3/(u-l),o.set(r.x-d*l,r.y+d*s),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 dh(n,r){return td(n.position,n.controls[1].position,r.position)&&td(n.position,r.controls[0].position,r.position)}function xh(n,r,e,t,o=.5){let i=Qn.subVectors(r,n).multiplyScalar(o).add(n),s=bl.subVectors(e,r).multiplyScalar(o).add(r),l=h_.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=y_.subVectors(s,i).multiplyScalar(o).add(i),a=g_.subVectors(l,s).multiplyScalar(o).add(s),d=l,p=x_.subVectors(a,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,a.x,a.y,d.x,d.y,t.x,t.y]}function vh(n,r,e=12,t=!0){let o=ph.set(0,0,0),i,s=0,l=[];for(let c=0;c<r.length;c++){let u=rd(r[c]),a=Qn,d=To(u,e);l.push(d);for(let p=0;p<=d;p++)if(u instanceof ge.CubicBezierCurve||u instanceof ge.QuadraticBezierCurve||u instanceof ge.LineCurve){if(u.getPoint(p/d,a),o.set(a.x,a.y,0),i!==void 0&&b_(i,o))continue;i===void 0&&(i=uh),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 bh(n,r,e,t=12,o=!0){let i=ph.set(0,0,0),s=0,l=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,a=rd(r[c]),d=Qn,p=To(a,t);l.push(p);for(let f=0;f<=p;f++)if(a instanceof ge.CubicBezierCurve||a instanceof ge.QuadraticBezierCurve||a instanceof ge.LineCurve){if(a.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=uh:(n.setXYZ(s,u.x,u.y,u.z),s++,n.setXYZ(s,i.x,i.y,i.z),s++),u.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++),l}function id(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],l=0;if(e&&s.roundedCurveCorner!==void 0){let c=To(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),l+=c}s.curveAfter!==void 0&&(l+=To(s.curveAfter,r)),t.push(l)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=To(n[0].roundedCurveCorner,r)*.5),t}function To(n,r=12){return n&&n instanceof ge.EllipseCurve?r*2:n&&(n instanceof ge.LineCurve||n instanceof ge.LineCurve3)?1:n&&n instanceof ge.SplineCurve?r*n.points.length:r}function Sh(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let l=rd(r[s]),c=To(l,e),u=Qn;for(let a=0;a<=c;a++)if(l instanceof ge.CubicBezierCurve||l instanceof ge.QuadraticBezierCurve||l instanceof ge.LineCurve){if(l.getPoint(a/c,u),o!==void 0&&v_(o,u,Ps))continue;o===void 0&&(o=bl),o.copy(u),n.push(u.x,u.y),i++}}return Os(n[0],n[n.length-2],Ps)&&Os(n[1],n[n.length-1],Ps)&&(n.pop(),n.pop()),t&&i>1&&!(Os(n[i-1],n[1],Ps)&&Os(n[i-2],n[0],Ps))&&(n.push(n[0],n[1]),i++),n}var sd=new Oe.Vector2,S_=new Oe.Vector2,w_=new Oe.Vector2,__=new Oe.Vector2,T_=new Oe.Vector2,P_=new Oe.Vector2,Pe=class extends Oe.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Oe.Plane(new Oe.Vector3(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=Oe.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Pe;return i.isClosed=e.isClosed,i.points=e.points.map(s=>hr.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>Pe.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,l=this.shapeHoles.length;s<l;s++){let c=this.shapeHoles[s],u=c.points.length,a=c.getPointIndexById(e);if(a<0)i+=u;else return a+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],l=e-t;if(l<=s.points.length-1)return s.points[l];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],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=sd.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let l=this.points[i];l.position.multiply(o),l.controls[0].position.multiply(o),l.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=Oe.MathUtils.generateUUID()){let i;e instanceof Oe.Vector2?i=e:i=new Oe.Vector2(e,t);let s=new hr(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 vh(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,l)=>s+l,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 bh(e,this.curves,t,o,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Sh(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=To(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let a=i[c];if(l<o+a)return[c,(l-o+1)/a];o+=a}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if(nd(i,s)){let d=i.position.distanceTo(s.position);return i.position.distanceTo(sd.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=l[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 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],l=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],u=s.roundness,a=l&&c&&mh(l,s,c);if(!s.controlsMoved()&&u>0&&!a){let d=s.curveBefore,p=s.curveAfter;if(d===void 0||p===void 0)continue;let f=s.roundedCurveBefore,m=s.roundedCurveAfter,h=d.getLength(),y=p.getLength(),g=Math.min(u,h*.499),v=Math.min(u,y*.499),b=Math.min(g,v),w=1-b/h,S=b/y,T=d.getPointAt(w,sd),_=p.getPointAt(S,S_);this._subSplitCurve(d,f,w,T,void 0),this._subSplitCurve(p,m,S,void 0,_);let x;if(this.useCubicForRoundedCorners){let C=od(T,s.position,_)/2,P=Math.tan(C)*T.distanceTo(s.position),[N,O]=hh(T,_,P,w_,__),A=yh(N,O,s.position),[R,k]=gh(A,T,_,P,T_,P_);x=new Oe.CubicBezierCurve(T.clone(),R.clone(),k.clone(),_.clone())}else x=new Oe.QuadraticBezierCurve(T.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Oe.LineCurve)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,u=l.getUtoTmapping(o,0),a=xh(l.v0,l.v1,l.v2,l.v3,u);return i!==void 0&&(c.v0.set(a[0],a[1]),c.v1.set(a[2],a[3]),c.v2.set(a[4],a[5]),c.v3.set(a[6],a[7])),s!==void 0&&(c.v0.set(a[6],a[7]),c.v1.set(a[8],a[9]),c.v2.set(a[10],a[11]),c.v3.set(a[12],a[13])),c}return t}clone(){let e=new Pe(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],l=e.points[i+1],c=e.points[i+2],u=e.points[i+3],a=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new hr(Oe.MathUtils.generateUUID(),new Oe.Vector2(s,l));f.controls[0].position.set(c,u),f.controls[1].position.set(a,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Pe;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Oe.CubicBezierCurve&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],l,c;for(l=0,c=i.length;l<c;l++)i[l]instanceof Oe.QuadraticBezierCurve&&(i[l]=fh(i[l]));for(l=0,c=i.length;l<c;l++){let d=i[l],p=l>0?i[l-1]:null,f;d instanceof Oe.CubicBezierCurve?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Oe.LineCurve&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let u=i[i.length-1],a=!1;return u instanceof Oe.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),a=!0):u instanceof Oe.LineCurve&&u.v2.equals(s[0].position)&&(a=!0),this.isClosed=a,s};return this.points=o(e.curves),e instanceof Oe.Shape&&(this.shapeHoles=e.holes.map(i=>{let s=new Pe;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 ld=Math.PI*2;function ad({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function O_(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 wh(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 A_(n,r,e,t,o,i,s,l,c,u){let a=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(l,2),m=a*d-a*f-d*p;m<0&&(m=0),m/=a*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*l,y=m*-i/o*s,g=h+(n+e)/2,v=y+(r+t)/2,b=(s-h)/o,w=(l-y)/i,S=(-s-h)/o,T=(-l-y)/i,_=wh(1,0,b,w),x=wh(b,w,S,T);return!u&&x>0&&(x-=ld),u&&x<0&&(x+=ld),{centerx:g,centery:v,ang1:_,ang2:x}}function _h({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:l}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,a=(r-t)/2;if(u===0&&a===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(a,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=A_(n,r,e,t,o,i,u,a,s,l),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(ld/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);m/=v;for(let b=0;b<v;b++)c.push(O_(f,m)),f+=m;return c.map(b=>{let{x:w,y:S}=ad(b[0],o,i,h,y),{x:T,y:_}=ad(b[1],o,i,h,y),{x,y:C}=ad(b[2],o,i,h,y);return{x1:w,y1:S,x2:T,y2:_,x,y:C}})}var Wo=require("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 We;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(We||(We={}));function pe(n,r){if(!n)throw r||"Assertion Failed!"}var ce=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var s,l,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),l=n.edgeEval(t,e,o),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,e.s)):(s=n.edgeSign(r,t,e),l=-n.edgeSign(r,o,e),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,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),l=n.transEval(t,e,o),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,e.t)):(s=n.transSign(r,t,e),l=-n.transSign(r,o,e),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,o.t)):i.t=(t.t+e.t)/2},n}(),As=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}(),Sl=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}(),Jn=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}(),Th=function(){function n(){var r=new Jn,e=new As,t=new Sl(0),o=new Sl(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 Sl(0),t=new Sl(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;pe(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;pe(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var 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 Jn,e=new Jn,t=new As,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 Jn;this.makeVertex_(i,e,r.Org),r.Org.anEdge=r}if(!t){var s=new As;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 As;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 Jn;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 As;this.makeFace_(s,o,r.Lface)}return o},n.prototype.zapFace=function(r){var e=r.anEdge,t,o,i,s,l;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,l=r.next,l.prev=s,s.next=l},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,l,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&&(l=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),l+c-2<=r&&ce.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&ce.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,l,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){pe(o.prev===i),c=o.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(pe(o.prev===i&&o.anEdge===null),l=e,l=e;(s=l.next)!==e;l=s){pe(s.prev===l),c=s.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(pe(s.prev===l&&s.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)pe(c.Sym.next===u.Sym),pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Org!==null),pe(c.Dst!==null),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c);pe(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}(),Ph=function(){function n(){this.handle=null}return n}(),Oh=function(){function n(){this.key=null,this.node=0}return n}(),N_=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 Ph,this.handles[t]=new Oh;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,pe(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 Ph;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new Oh}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;pe(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),cd=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}(),Ah=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),C_=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new Ah,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 Ah;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}(),I_=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?ce.vertLeq(i.Org,s.Org)?ce.edgeSign(s.Dst,i.Org,s.Org)<=0:ce.edgeSign(i.Dst,s.Org,i.Org)>=0:ce.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return ce.edgeSign(i.Dst,o,i.Org)>=0;var l=ce.edgeEval(i.Dst,o,i.Org),c=ce.edgeEval(s.Dst,o,s.Org);return l>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&pe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){pe(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new cd;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,s=e,l=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=l.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(l.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}l.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(l,o)),n.finishRegion(r,s),l=i.eUp,s=i}return l},n.addRightEdges=function(r,e,t,o,i,s){var l,c,u,a,d=!0;u=t;do pe(ce.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,a=i;l=n.regionBelow(c),u=l.eUp.Sym,u.Org===a.Org;)u.Onext!==a&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(a.Oprev,u)),l.windingNumber=c.windingNumber-u.winding,l.inside=n.isWindingInside(r,l.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,a),n.deleteRegion(r,c),r.mesh.delete(a)),d=!1,c=l,a=u;c.dirty=!0,pe(c.windingNumber-u.winding===l.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=ce.vertL1dist(e,r),i=ce.vertL1dist(t,r),s=.5*i/(o+i),l=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+l*t.coords[0],r.coords[1]+=s*e.coords[1]+l*t.coords[1],r.coords[2]+=s*e.coords[2]+l*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(ce.vertLeq(o.Org,i.Org)){if(ce.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ce.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(ce.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(pe(!ce.vertEq(o.Dst,i.Dst)),ce.vertLeq(o.Dst,i.Dst)){if(ce.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(ce.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,l=i.Org,c=o.Dst,u=i.Dst,a,d,p=new Jn,f,m;if(pe(!ce.vertEq(u,c)),pe(ce.edgeSign(c,r.event,s)<=0),pe(ce.edgeSign(u,r.event,l)>=0),pe(s!==r.event&&l!==r.event),pe(!e.fixUpperEdge&&!t.fixUpperEdge),s===l||(a=Math.min(s.t,c.t),d=Math.max(l.t,u.t),a>d))return!1;if(ce.vertLeq(s,l)){if(ce.edgeSign(u,s,l)>0)return!1}else if(ce.edgeSign(c,l,s)<0)return!1;return n.debugEvent(r),ce.intersect(c,s,u,l,p),pe(Math.min(s.t,c.t)<=p.t),pe(p.t<=Math.max(l.t,u.t)),pe(Math.min(u.s,c.s)<=p.s),pe(p.s<=Math.max(l.s,s.s)),ce.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=ce.vertLeq(s,l)?s:l,ce.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ce.vertEq(p,s)||ce.vertEq(p,l)?(n.checkForRightSplice(r,e),!1):!ce.vertEq(c,r.event)&&ce.edgeSign(c,r.event,p)>=0||!ce.vertEq(u,r.event)&&ce.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):(ce.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),ce.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,s,c,l,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,s=n.regionBelow(e),l=e.eUp,c=s.eUp,u=!1;if(l.Dst!==c.Dst&&n.checkForIntersect(r,e),ce.vertEq(l.Org,r.event)&&(r.mesh.splice(i.Oprev,l),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),u=!0),ce.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,s,null),u=!0),u){n.addRightEdges(r,e,t.Onext,i,i,!0);return}ce.vertLeq(c.Org,l.Org)?o=c.Oprev:o=l,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,l,c;if(o=e.eUp,ce.vertEq(o.Org,t)){pe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!ce.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}pe(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=l=s.Onext,c.fixUpperEdge&&(pe(i!==s),n.deleteRegion(r,c),r.mesh.delete(s),s=i.Oprev),r.mesh.splice(t.anEdge,s),ce.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,s.Onext,l,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,l,c,u=new cd;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(s=t.eUp,l=o.eUp,ce.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=ce.vertLeq(l.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var a=r.mesh.connect(l.Dnext,e.anEdge);c=a.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);pe(o!==null);var i=n.regionBelow(o),s=i.eUp,l=n.finishLeftRegions(r,i,null);l.Onext===s?n.connectRightVertex(r,o,l):n.addRightEdges(r,o,l.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new cd,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 C_(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,l=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,l)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(pe(e.fixUpperEdge),pe(++t===1)),pe(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,ce.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 N_(i,ce.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,pe(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!ce.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}(),M_=function(){function n(){this.mesh=new Th,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,s,l,c=[0,0,0],u=[0,0,0],a=[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 v=0;if(c[1]-u[1]>c[0]-u[0]&&(v=1),c[2]-u[2]>c[v]-u[v]&&(v=2),u[v]>=c[v]){r[0]=0,r[1]=0,r[2]=1;return}for(l=0,t=m[v],o=f[v],a[0]=t.coords[0]-o.coords[0],a[1]=t.coords[1]-o.coords[1],a[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]=a[1]*d[2]-a[2]*d[1],p[1]=a[2]*d[0]-a[0]*d[2],p[2]=a[0]*d[1]-a[1]*d[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>l&&(l=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);l<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(a)]=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 l=r.next;l!==r;l=l.next)l.s=this.dot_(l.coords,t),l.t=this.dot_(l.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(;ce.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ce.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(ce.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ce.edgeGoesLeft(o.Lnext)||ce.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&&(ce.edgeGoesRight(t.Lprev)||ce.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,l=0,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(a.n=-1,!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=l,l++),c++,i=i.Lnext}while(i!==a.anEdge);if(c>t)throw"Face vertex greater that support polygon";a.n=s,++s}this.elementCount=s,e===We.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=l,this.vertices=[],this.vertices.length=l*o,this.vertexIndices=[],this.vertexIndices.length=l;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,a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==a.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===We.CONNECTED_POLYGONS){i=a.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==a.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 l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){o=t=l.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,a=0;i=0;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){s=0,o=t=l.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,s++,t=t.Lnext;while(t!==o);this.elements[a++]=i,this.elements[a++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new Th),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=_e.ODD),e===void 0&&(e=We.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_(),I_.computeInterior(this,s);var l=this.mesh;return e===We.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),s&&l.check(),e===We.BOUNDARY_CONTOURS?this.outputContours_(l,o):this.outputPolymesh_(l,e,t,o),!0},n}();function yr(n){var r=n.windingRule,e=r===void 0?_e.ODD:r,t=n.elementType,o=t===void 0?We.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,l=n.vertexSize,c=l===void 0?2:l,u=n.normal,a=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 M_;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(c||2,p[v]);return g.tesselate(e,o,s,c,a,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var tG=_e.ODD,rG=_e.NONZERO,oG=_e.POSITIVE,nG=_e.NEGATIVE,iG=_e.ABS_GEQ_TWO,sG=We.POLYGONS,aG=We.CONNECTED_POLYGONS,lG=We.BOUNDARY_CONTOURS;var qo=require("three");var wl=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*wl.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*wl.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,l=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let u=new Float32Array(o,s*i,2*r);l.set(this.positions.slice(0,this.size*3)),c.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=l,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)}},Ns=wl;Ns.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Cs={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},ud={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},pd={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},dd=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),ei=class extends qo.BufferGeometry{constructor(e,t,o=0,i=12,s=3,l=_e.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=o,this._curveSegments=i,this._bevelSegmentsInput=s,o<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(o,t/2-1e-12),this._bevelSegments=Math.floor(s));let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(_=>{let x=_.extractShapePointsToFlatArray([],i),C=[];for(let P=x.length-1;P>=1;P-=2){let N=x[P-1],O=x[P-0];C.push(N,O)}return C}),a;try{a=yr({windingRule:l,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{a=Cs}let d;try{d=yr({windingRule:_e.ODD,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=ud}if(!a)throw new Error("error generating geometry");let p=a.elementCount;if(d){a.elementCount+=d.elementCount;for(let _=0;_<d.elements.length;_++){let x=d.elements[_],C=_%2===0?a.vertexCount:0;a.elements.push(x+C)}for(let _=0;_<d.vertexIndices.length;_++){let x=d.vertexIndices[_],C=a.vertexCount;a.vertexIndices.push(x+C)}for(let _=0;_<d.vertices.length;_++){let x=d.vertices[_];a.vertices.push(x)}}let f=1/0,m=-1/0,h=1/0,y=-1/0;for(let _=0,x=a.vertexCount;_<x;_++){let C=_*2,P=a.vertices[C+0],N=a.vertices[C+1];P<f&&(f=P),P>m&&(m=P),N<h&&(h=N),N>y&&(y=N)}this._minX=f,this._minY=h,this._width=m-f,this._height=y-h,this._buffer=new Ns(this._computeBufferEstimatedSize(a));let g=[],v=[];for(let _=a.elementCount-1;_>=0;_--){let x=_>=p,C=_*2,P=a.elements[C+0],N=a.elements[C+1],O=P+N,A={start:P,count:N,normals:[],continuous:[],concave:[]},R=P,k=O-1,$=P+1,te=this._shape.roundedCurves.length;do{let V=R-P,G=a.vertices[k*2+0],B=a.vertices[k*2+1],L=a.vertices[R*2+0],D=a.vertices[R*2+1],Y=a.vertices[$*2+0],q=a.vertices[$*2+1],j=L-G,F=D-B,M=Math.sqrt(j*j+F*F);j/=M,F/=M;let Q=L-Y,re=D-q,oe=Math.sqrt(Q*Q+re*re);Q/=oe,re/=oe,A.normals[V*2+0]=-re,A.normals[V*2+1]=Q,A.concave[V]=j*re-F*Q>0;let K=a.vertexIndices[R];if(Array.isArray(K))A.continuous[V]=!1;else{let[ee,J]=this._shape.getCurveIndexFromVertexId(K-1,!0);if(J>0&&J<1)A.continuous[V]=!0;else{let se=J===1?ee+1:ee-1;se=(se+te)%te;let de=J===1?0:1,ae=this._shape.roundedCurves[ee].getTangent(J),me=this._shape.roundedCurves[se].getTangent(de);A.continuous[V]=ae.dot(me)>.95}}x&&(A.normals[V*2+0]*=-1,A.normals[V*2+1]*=-1),[k,R,$]=[R,$,$+1],$>=O&&($-=N)}while($!==P+1);let X=[];X.push({bevelI:0,angle:0,size:0,boundary:{vertices:a.vertices.slice(P*2,O*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((V,G)=>[G,G]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:a.vertices.slice(P*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let G=V/this._bevelSegments*Math.PI/2,B=(1-Math.cos(G))*this._bevelSize,L=[],D=[],Y=[],q=[],j=0;for(let M=0;M<N;M++){let Q=M*2,re=(M-1+N)%N*2,oe=a.vertices[A.start*2+Q+0],K=a.vertices[A.start*2+Q+1],ee=-A.normals[re+0]*B,J=-A.normals[re+1]*B,se=-A.normals[Q+0]*B,de=-A.normals[Q+1]*B;if(A.concave[M]||!A.concave[M]&&x){let ae=Math.atan2(J,ee),me=Math.atan2(de,se);me>ae&&(me-=Math.PI*2);let $e=me-ae;if(A.continuous[M]||x){let xe=ae+$e/2,rt=Math.cos(xe)*B,Ce=Math.sin(xe)*B;L[2*j+0]=oe+rt*(x?-1:1),L[2*j+1]=K+Ce*(x?-1:1),q[j]=M,j++}else{let xe=Math.max(1,Math.floor(i/4*Math.abs($e)/Math.PI));for(let rt=0;rt<=xe;rt++){let Ce=ae+$e*(rt/xe),Et=Math.cos(Ce)*B,Qt=Math.sin(Ce)*B;L[2*j+0]=oe+Et,L[2*j+1]=K+Qt,q[j]=M,j++}}}else L[2*j+0]=oe+ee,L[2*j+1]=K+J,q[j]=M,D[M]=j,j++,L[2*j+0]=oe,L[2*j+1]=K,q[j]=M,j++,L[2*j+0]=oe+se,L[2*j+1]=K+de,q[j]=M,Y[M]=j,j++}let F=yr({windingRule:_e.POSITIVE,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[L],edgeCreateCallback:M=>{let re=M.Org.idx,oe=q[re],K=q[(re+1)%q.length];M.idx=[oe,K],M.Sym.idx=[K,oe]},vertexIdCallback:M=>{let Q=M.Lprev.idx;return[Q?Q[1]:0,M.idx?M.idx[0]:0]}});if(!F)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!F.vertexCount)break;for(let M=0;M<F.vertexIndices.length;M++){let[Q,re]=F.vertexIndices[M];if(Q===re)continue;let oe=re;re<Q&&(oe+=N);for(let K=Q;K<oe;K++){let ee=K%N,J=(K+1)%N;if(!A.continuous[ee]||!A.continuous[J]){F.vertexIndices[M]=[Q,ee],F.vertexIndices.splice(M+1,0,[J,re]),F.vertices.splice((M+1)*2,0,F.vertices[M*2],F.vertices[M*2+1]);break}}}X.push({bevelI:V,angle:G,size:B,boundary:F,reverseMap:q,insetPoints:L})}let W=(V,G,B)=>{let L=0,D=V.boundary.vertexIndices.length;for(;L<D&&B(V.boundary.vertexIndices[G]);)G=(G+1)%D,L++;return L},H=g.length;for(let V=1;V<X.length;V++){let G=X[V-1],B=X[V],L=G.boundary.vertexIndices.length,D=B.boundary.vertexIndices.length;if(!L||!D)break;let Y=A.concave.length,q=0,j=dd(q,N);for(;!G.boundary.vertexIndices.filter(j).length||!B.boundary.vertexIndices.filter(j).length;)q++,j=dd(q,N);let F=G.boundary.vertexIndices.findIndex(j),M=B.boundary.vertexIndices.findIndex(j);do F=(F+1)%L;while(j(G.boundary.vertexIndices[F]));do M=(M+1)%D;while(j(B.boundary.vertexIndices[M]));q=(q+1)%N;let Q=q,re=this._buildBevelVert(A,G,(F-1+L)%L),oe=this._buildBevelVert(A,B,(M-1+D)%D),K=re,ee=oe,J,se,de=!1;do{j=dd(q,N);let ae=W(G,F,j),me=W(B,M,j),$e=de;if(de=!1,ae&&!me){for(let xe=0;xe<ae;xe++)J=this._buildBevelVert(A,G,(F+xe)%L,xe/(ae-1)),g.push(K.topN,J.topP,ee.topN),g.push(J.bottomP,K.bottomN,ee.bottomN),K=J;de=!0}else if(!ae&&me)for(let xe=0;xe<me;xe++)se=this._buildBevelVert(A,B,(M+xe)%D,xe/(me-1)),g.push(ee.topN,K.topP,se.topP),g.push(K.bottomP,ee.bottomN,se.bottomP),ee=se;else if(ae&&me)if(J=this._buildBevelVert(A,G,F,0),se=this._buildBevelVert(A,B,M,0),$e?(g.push(K.topN,se.topP,ee.topN),g.push(K.topN,J.topP,se.topP),g.push(se.bottomP,K.bottomN,ee.bottomN),g.push(se.bottomP,J.bottomP,K.bottomN)):(g.push(ee.topN,K.topN,J.topP),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,K.bottomN,ee.bottomN),g.push(J.bottomP,ee.bottomN,se.bottomP)),K=J,ee=se,ae===me)for(let xe=1;xe<ae;xe++)J=this._buildBevelVert(A,G,(F+xe)%L,xe/(ae-1)),se=this._buildBevelVert(A,B,(M+xe)%D,xe/(me-1)),g.push(K.topN,J.topP,ee.topN),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,K.bottomN,ee.bottomN),g.push(J.bottomP,ee.bottomN,se.bottomP),K=J,ee=se;else if(ae>me){let xe=ae/me,rt=0;for(let Ce=1;Ce<ae;Ce++)J=this._buildBevelVert(A,G,(F+Ce)%L,Ce/(ae-1)),g.push(K.topN,J.topP,ee.topN),g.push(J.bottomP,K.bottomN,ee.bottomN),K=J,Ce>(rt+1)*xe&&(rt++,se=this._buildBevelVert(A,B,(M+rt)%D,rt/(me-1)),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,ee.bottomN,se.bottomP),ee=se)}else{let xe=me/ae,rt=0;for(let Ce=1;Ce<me;Ce++)se=this._buildBevelVert(A,B,(M+Ce)%D,Ce/(me-1)),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,ee.bottomN,se.bottomP),ee=se,Ce>(rt+1)*xe&&(rt++,J=this._buildBevelVert(A,G,(F+rt)%L,rt/(ae-1)),g.push(K.topN,J.topP,ee.topN),g.push(J.bottomP,K.bottomN,ee.bottomN),K=J)}F=(F+ae)%L,M=(M+me)%D,q=(q+1)%Y}while(q!==Q)}if(this._buildWall(X,A,g),x){let V=[];for(let G=g.length-1;G>=H+2;G-=3){let B=g[G-2],L=g[G-1],D=g[G-0];V.push(D,L,B)}g.splice(H,g.length-H,...V)}if(x){let V=[];for(let G=X[X.length-1].boundary.vertices.length-1;G>=1;G-=2){let B=X[X.length-1].boundary.vertices[G-1],L=X[X.length-1].boundary.vertices[G-0];V.push(B,L)}v.push(V)}if(!x){let V=X[X.length-1],G;try{G=yr({windingRule:X.length>1?_e.POSITIVE:_e.ODD,elementType:We.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]})}catch{G=pd}if(!G)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:g.length});for(let B=0;B<G.elementCount*3;B+=3){let L=this._buildSurfaceVert(G,G.elements[B+0]),D=this._buildSurfaceVert(G,G.elements[B+1]),Y=this._buildSurfaceVert(G,G.elements[B+2]);g.push(L.top,D.top,Y.top),g.push(Y.bottom,D.bottom,L.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new qo.BufferAttribute(Uint32Array.from(g),1),w=new qo.BufferAttribute(this._buffer.positions,3),S=new qo.BufferAttribute(this._buffer.normals,3),T=new qo.BufferAttribute(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,T.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",T),this.setIndex(b)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,l=i.boundary.vertexCount;s<l;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%l);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}_buildSurfaceVert(e,t){let o=t.toString();if(o in this.vertexCache)return this.vertexCache[o];let i=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(i-this._minX)/this._width,c=(s-this._minY)/this._height,u=this._buffer.get(2),a=u*3,d=u*2,p={top:u+0,bottom:u+1};return this._buffer.positions[a+0]=i,this._buffer.positions[a+1]=s,this._buffer.positions[a+2]=this._depth,this._buffer.normals[a+0]=0,this._buffer.normals[a+1]=0,this._buffer.normals[a+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[a+3]=i,this._buffer.positions[a+4]=s,this._buffer.positions[a+5]=0,this._buffer.normals[a+3]=0,this._buffer.normals[a+4]=0,this._buffer.normals[a+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[o]=p,p}_buildBevelVert(e,t,o,i=1){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,a,d,p;l!==c?(a=l,u=c,p=!1,d=e.continuous[a]&&e.continuous[u]):(u=l,a=(u-1+e.count)%e.count,p=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||p);let f=Math.cos(t.angle),m=Math.sin(t.angle),h=o*2,y=u*2,g=a*2,v=t.boundary.vertices[h+0],b=t.boundary.vertices[h+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,T=(b-this._minY)/this._height,_=e.normals[y+0],x=e.normals[y+1],C=e.normals[g+0],P=e.normals[g+1];if(p){let k=C-_,$=P-x;_=_+k*(1-i),x=x+$*(1-i);let te=Math.sqrt(_*_+x*x);_/=te,x/=te}let N=this._buffer.get(d?2:4),O=N*3,A=N*2,R={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1};return this._buffer.positions[O+0]=v,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=_*f,this._buffer.normals[O+1]=x*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=T,this._buffer.positions[O+3]=v,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=_*f,this._buffer.normals[O+4]=x*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=T,this._buffer.uvs[A+3]=S,d||(N+=2,O+=6,A+=4,R.topP=N+0,R.bottomP=N+1,this._buffer.positions[O+0]=v,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=C*f,this._buffer.normals[O+1]=P*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=T,this._buffer.positions[O+3]=v,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=C*f,this._buffer.normals[O+4]=P*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=T,this._buffer.uvs[A+3]=S),this.vertexCache[s]=R,R}clone(){let e=new ei(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=eo(this.userData),e}};var ti=class extends Wo.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=_e.ODD;this.elementType=We.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:_e.ODD,elementType:We.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)),l,c=!0,u=!0,a,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],v=i[y+1];if(a!==void 0&&g!==a&&(c=!1),d!==void 0&&v!==d&&(u=!1),a=g,d=v,!c&&!u)break}if(!c&&!u)try{l=yr({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{l=Cs}let p=l?.vertexCount??1,f=l?.elementCount??1;if(this._positionAttribute=new Wo.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Wo.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Wo.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Wo.BufferAttribute(new Uint32Array(f*3),1),l){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,S=p;w<S;w++){let T=w*2,_=l.vertices[T+0],x=l.vertices[T+1];_<m&&(m=_),_>h&&(h=_),x<y&&(y=x),x>g&&(g=x)}let v=h-m,b=g-y;for(let w=0,S=p;w<S;w++){let T=w*2,_=l.vertices[T+0],x=l.vertices[T+1],C=(_-m)/v,P=(x-y)/b;this._positionAttribute.setXYZ(w,_,x,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,C,P)}for(let w=0,S=f;w<S;w++){let T=w*3,_=l.elements[T+0],x=l.elements[T+1],C=l.elements[T+2];this._indexAttribute.setX(T+0,_),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,C)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(l?.elementCount??1)*3)}clone(){let e=new ti(this._shape,this._curveSegments);return e.userData=eo(this.userData),e}};var ri=class extends ei{constructor(e,t,o=0,i=12,s=3,l=_e.ODD){super(e,t,o,i,s,l);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,l=i.boundary.vertexCount;s<l;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%l);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}clone(){let e=new ri(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=eo(this.userData),e}};var Vt=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),s=n.shape??r?.shape,l=s?.roundness??e.roundness;s!==void 0&&(s instanceof Pe?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new Pe(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new Pe(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:l}),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 l;return r<=0?l=new ti(n.shape,o,{windingRule:s}):l=new ri(n.shape,r,e,o,t,s),Object.assign(l,{userData:{...n,type:"VectorGeometry"}})}};var ni=require("three"),Ch=Math.PI*2,ii=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 Pe?n.shape:new Pe,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:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,a=r*.5,d=e*.5,p=E_(u,a,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=Vt.create({shape:u,parameters:{subdivisions:p,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function E_(n,r,e,t,o,i){if(t>=Ch)return o>30||o%4===0?(B_(n,r,e,i),Math.round(o/4)):Nh(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},l=t+Math.PI*.5,c={x:Math.cos(l)*r,y:Math.sin(l)*e},u=_h({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%u.length===0?L_(n,s.x,s.y,u,o,r,e,i):Nh(n,t,o,r,e,i)}function L_(n,r,e,t,o,i,s,l){let c=Math.round(o/t.length);n.addPoint(oi(r,e));for(let u=0,a=t.length;u<a;u++){let d=t[u],p=n.points[u],f=oi(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 l>0?Ih(n,i,s,l):n.addPoint(oi(0,0)),c}function Nh(n,r,e,t,o,i){let s=-r/e;for(let l=0;l<=e;l++){let c=s*l,u=Math.sin(c)*t,a=Math.cos(c)*o;n.addPoint(oi(u,a))}return r<Ch?i>0?Ih(n,t,o,i):n.addPoint(oi(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Mh(n,t,o,i)),1}function B_(n,r,e,t=0,o=0,i=0){let s=.5522847498,l=r*s,c=e*s;n.addPoint(_l(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(_l(o,i+e,o-l,i+e,o+l,i+e)),n.addPoint(_l(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(_l(o,i-e,o+l,i-e,o-l,i-e)),t>0&&Mh(n,r,e,t)}function oi(n,r){return new hr(ni.MathUtils.generateUUID(),new ni.Vector2(n,r))}function _l(n,r,e,t,o,i){let s=oi(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function Ih(n,r,e,t){Eh(n,r,e,t).forEach(i=>n.addPoint(i))}function Mh(n,r,e,t){let o=Eh(n,r,e,t),i=new Pe;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function Eh(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new ni.Vector2(o/r,i/e),l=n.points.map(c=>{let u=c.clone();return u.uuid=ni.MathUtils.generateUUID(),u}).reverse();return l.forEach(c=>{c.position.multiply(s);let u=c.controls[0].position.clone().multiply(s),a=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(a),c.controls[1].position.copy(u)}),l}var gr=require("three"),Lh=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:l,pathType:c,pathSegments:u,cornerRadius:a,cornerSegments:d}=n.parameters,p=new Is(!1,r,e,t,o,i,s,l,c,u,a,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},fd=new gr.Uint32BufferAttribute([0,0,0],1),Is=class extends gr.BufferGeometry{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,l=1,c=1,u=1,a=1,d=1,p=1){if(super(),s===0)return;let f=r&&s===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let m=()=>new gr.Vector3,h=new gr.Vector3,y=m(),g=m(),v=m(),b,w,S,T,_,x,C,P,N=m(),O=m(),A=m(),R=m(),k=m(),$=m(),te=m(),X=m(),W=t-2*c+.001,H=W/s,V=Math.ceil(l*s),G=V+1,B=W/V,L=-W/2,D=a+1,Y=2*Math.PI/a,q=Math.PI/2/p,j=.01,F=Math.min((1-d/100)*c,c-j),M=c-F,Q=0,re=2,oe=p*re+re,K=D*oe/re,ee=K+D*G,J=D*(G+oe),[se,de,ae]=[3,3,2].map(Je=>Array(J*Je).fill(0)),me=[],$e=i-c;function xe(Je,qt){let Ar=Math.PI/2;x=qt*B,P=2*Math.PI*(x%H)/H+Ar,x+=L,C=Math.sin(P)*$e,_=Math.cos(P)*$e,r?Je.set(_,C,x):Je.set(_,x,C)}xe(h,-1e-10),xe(y,0),N.copy(h),xe(h,1);let rt=h.distanceTo(y),Ce=f?0:M+F,Et=rt*V+2*Ce,Qt=F,an=Et-Ce;for(let Je=0;Je<=V;Je++){xe(g,Je),X.subVectors(g,N).normalize(),N.copy(g),$.copy(g).setComponent(+r+1,0).normalize(),te.crossVectors(X,$).normalize();let qt=Je===0,Ar=Je===V,jg=qt?3*Math.PI/2:q,Fg=qt?Qt:an,kg=qt?D:ee,Ug=qt?0:J-D,Hg=X.clone().multiplyScalar(qt?-M:M).add(g),qg=X.clone().multiplyScalar(qt?-1:1).normalize();for(let Xr=0;Xr<D;Xr++){let hu=Xr*Y;if(O.addVectors(h.copy($).multiplyScalar(c*Math.cos(hu)),y.copy(te).multiplyScalar(c*Math.sin(hu))),A.copy(O).normalize(),qt||Ar){f||(Q=Ug+Xr,[0,1,2].forEach(Lt=>{se[Q*3+Lt]=Hg.getComponent(Lt),de[Q*3+Lt]=qg.getComponent(Lt)}),ae[Q*2]=+Ar,ae[Q*2+1]=Xr/a),y.copy(A).multiplyScalar(F),v.addVectors(g,y);for(let Lt=0;Lt<p;Lt++){let hc=Lt*q+jg;R.addVectors(h.copy(X).multiplyScalar(M*Math.sin(hc)),y.copy(A).multiplyScalar(M*Math.cos(hc))),k.copy(R).normalize(),y.addVectors(v,R),R.normalize(),Q=kg+Lt*D+Xr,[0,1,2].forEach(ua=>{se[Q*3+ua]=y.getComponent(ua),de[Q*3+ua]=k.getComponent(ua)});let Wg=+qt+Math.sin(hc);ae[Q*2]=(Fg+M*Wg)/Et,ae[Q*2+1]=Xr/a}}y.addVectors(g,O),Q=K+Je*D+Xr,[0,1,2].forEach(Lt=>{se[Q*3+Lt]=y.getComponent(Lt),de[Q*3+Lt]=A.getComponent(Lt)}),ae[Q*2]=(Ce+Je*rt)/Et,ae[Q*2+1]=Xr/a}}let Ht=G+2*p+re,la=1,[ca,da]=[+f,Ht-1];for(let Je=ca;Je<=da-1;Je++){let qt=f&&Je===da-1;for(let Ar=0;Ar<D-1;Ar++)b=Je*D+Ar,w=b+1,S=(qt?Ar:b)+D,T=(qt?Ar+1:w)+D,Je===0?me.push(w,T,S):Je===Ht-2?me.push(b,w,S):me.push(b,w,S,w,T,S)}this.setIndex(me),this.setAttribute("position",new gr.Float32BufferAttribute(se,3)),this.setAttribute("normal",new gr.Float32BufferAttribute(de,3)),this.setAttribute("uv",new gr.Float32BufferAttribute(ae,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,s,l,c,u=6*(e-1)*r.radialSegments,a=e,d=a===e;for(let p=0;p<r.radialSegments;p++)i=a*t+p,s=i+1,l=(d?p:i)+t,c=(d?p+1:s)+t,o[u++]=i,o[u++]=s,o[u++]=l,o[u++]=s,o[u++]=c,o[u++]=l;return o.length=u,fd.array=o,fd.count=o.length,fd}};var Bh=require("three");var Dh=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,l=o===0&&i!==0?new Ms(r*.5,i,s):new Bh.IcosahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"IcosahedronGeometry"}})}},Ms=class extends _o{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],l="IcosahedronGeometry";super(i,s,l,r,e,t),this.type=l}static fromJSON(r){return new Ms(r.radius,r.corner,r.cornerSides)}};var Tl=require("three"),Gh=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 Tl.Shape;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new Tl.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Rr=require("three");var io=require("three");var ie=require("three"),Gr=new ie.Matrix4,md=new ie.Object3D,Pl=new ie.Vector3,Po=class extends ie.EventDispatcher{constructor(){super(),this.uuid=ie.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new ie.Matrix3().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let s=0,l=i.vertexNormals.length;s<l;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 Gr.makeRotationX(r),this.applyMatrix4(Gr),this}rotateY(r){return Gr.makeRotationY(r),this.applyMatrix4(Gr),this}rotateZ(r){return Gr.makeRotationZ(r),this.applyMatrix4(Gr),this}translate(r,e,t){return Gr.makeTranslation(r,e,t),this.applyMatrix4(Gr),this}scale(r,e,t){return Gr.makeScale(r,e,t),this.applyMatrix4(Gr),this}lookAt(r){return md.lookAt(r),md.updateMatrix(),this.applyMatrix4(md.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,l=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 ie.Vector3().fromBufferAttribute(i,p)),l!==void 0&&e.colors.push(new ie.Color().fromBufferAttribute(l,p));function a(p,f,m,h){let y=l===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new ie.Vector3().fromBufferAttribute(s,p),new ie.Vector3().fromBufferAttribute(s,f),new ie.Vector3().fromBufferAttribute(s,m)],v=new si(p,f,m,g,y,h);e.faces.push(v),c!==void 0&&e.faceVertexUvs[0].push([new ie.Vector2().fromBufferAttribute(c,p),new ie.Vector2().fromBufferAttribute(c,f),new ie.Vector2().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new ie.Vector2().fromBufferAttribute(u,p),new ie.Vector2().fromBufferAttribute(u,f),new ie.Vector2().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?a(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):a(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)a(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)a(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(Pl).negate(),this.translate(Pl.x,Pl.y,Pl.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new ie.Matrix4;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new ie.Vector3,e=new ie.Vector3;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],l=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,l),e.subVectors(s,l),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 ie.Vector3;if(r){let t=new ie.Vector3,o=new ie.Vector3;for(let i=0,s=this.faces.length;i<s;i++){let l=this.faces[i],c=this.vertices[l.a],u=this.vertices[l.b],a=this.vertices[l.c];t.subVectors(a,u),o.subVectors(c,u),t.cross(o),e[l.a].add(t),e[l.b].add(t),e[l.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 Po;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 l=0,c=this.faces.length;l<c;l++){let u=new ie.Vector3,a={a:new ie.Vector3,b:new ie.Vector3,c:new ie.Vector3};i.push(u),s.push(a)}}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 l=this.faces[i],c=o.faceNormals[i],u=o.vertexNormals[i];c.copy(l.normal),u.a.copy(l.vertexNormals[0]),u.b.copy(l.vertexNormals[1]),u.c.copy(l.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 ie.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ie.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,s=this.vertices,l=r.vertices,c=this.faces,u=r.faces,a=this.colors,d=r.colors;e!==void 0&&(o=new ie.Matrix3().getNormalMatrix(e));for(let p=0,f=l.length;p<f;p++){let h=l[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=d.length;p<f;p++)a.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,v=m.vertexColors,b=new si(m.a+i,m.b+i,m.c+i);b.normal.copy(m.normal),o!==void 0&&b.normal.applyMatrix3(o).normalize();for(let w=0,S=g.length;w<S;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),b.vertexNormals.push(h);b.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)y=v[w],b.vertexColors.push(y.clone());b.materialIndex=m.materialIndex+t,c.push(b)}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],v=[];for(let b=0,w=g.length;b<w;b++)v.push(g[b].clone());this.faceVertexUvs[p].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let c=0,u=this.vertices.length;c<u;c++){let a=this.vertices[c],d=Math.round(a.x*i)+"_"+Math.round(a.y*i)+"_"+Math.round(a.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 s=[];for(let c=0,u=this.faces.length;c<u;c++){let a=this.faces[c];a.a=o[a.a],a.b=o[a.b],a.c=o[a.c];let d=[a.a,a.b,a.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){s.push(c);break}}for(let c=s.length-1;c>=0;c--){let u=s[c];this.faces.splice(u,1);for(let a=0,d=this.faceVertexUvs.length;a<d;a++)this.faceVertexUvs[a].splice(u,1)}let l=this.vertices.length-t.length;return this.vertices=t,l}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new ie.Vector3(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],s,l;o&&o.length===e&&(s=[]),i&&i.length===e&&(l=[]);for(let c=0;c<e;c++){let u=r[c]._id;s&&s.push(o[u]),l&&l.push(i[u])}s&&(this.faceVertexUvs[0]=s),l&&(this.faceVertexUvs[1]=l)}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=[],l={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,v=this.faceVertexUvs[0][m]!==void 0,b=h.normal.length()>0,w=h.vertexNormals.length>0,S=h.color.r!==1||h.color.g!==1||h.color.b!==1,T=h.vertexColors.length>0,_=0;if(_=a(_,0,0),_=a(_,1,y),_=a(_,2,g),_=a(_,3,v),_=a(_,4,b),_=a(_,5,w),_=a(_,6,S),_=a(_,7,T),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),v){let x=this.faceVertexUvs[0][m];t.push(f(x[0]),f(x[1]),f(x[2]))}if(b&&t.push(d(h.normal)),w){let x=h.vertexNormals;t.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&t.push(p(h.color)),T){let x=h.vertexColors;t.push(p(x[0]),p(x[1]),p(x[2]))}}function a(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 l[h]!==void 0||(l[h]=s.length,s.push(m.getHex())),l[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,s.length>0&&(r.data.colors=s),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new Po().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],v=[];for(let b=0,w=g.length;b<w;b++){let S=g[b];v.push(S.clone())}this.faceVertexUvs[p].push(v)}}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],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),m.vertexNormals.push(v)}}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 l=r.skinWeights;for(let p=0,f=l.length;p<f;p++)this.skinWeights.push(l[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 a=r.boundingBox;a!==null&&(this.boundingBox=a.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 hd().fromGeometry(this),e=new ie.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Ol.call(new ie.BufferAttribute(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Ol.call(new ie.BufferAttribute(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",Rh.call(new ie.BufferAttribute(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",Vh.call(new ie.BufferAttribute(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",Vh.call(new ie.BufferAttribute(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let l=0,c=s.length;l<c;l++){let u=s[l],a=new ie.Float32BufferAttribute(u.data.length*3,3);a.name=u.name,i.push(Ol.call(a,u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ie.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",zh.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new ie.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",zh.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 ie.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new ie.Float32BufferAttribute(t.vertices.length*3,3),i=new ie.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",Ol.call(o,t.vertices)),e.setAttribute("color",Rh.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new ie.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",D_.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}};Po.prototype.isGeometry=!0;var hd=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 l=s[o];l.materialIndex!==i&&(i=l.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,l=r.morphTargets,c=l.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:l[g].name,data:[]};this.morphTargets.position=u}let a=r.morphNormals,d=a.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:a[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 v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let b=v.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ie.Vector2,new ie.Vector2,new ie.Vector2))}if(s===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ie.Vector2,new ie.Vector2,new ie.Vector2))}for(let S=0;S<c;S++){let T=l[S].vertices;u[S].data.push(T[v.a],T[v.b],T[v.c])}for(let S=0;S<d;S++){let T=a[S].vertexNormals[g];p[S].data.push(T.a,T.b,T.c)}h&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},si=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 ie.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new ie.Color,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 D_(n){return this.array.set(n),this}function Rh(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 ie.Color),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function Vh(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 ie.Vector2),r[e++]=i.x,r[e++]=i.y}return this}function Ol(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 ie.Vector3),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function zh(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 ie.Vector4),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var G_=["a","b","c"];function R_(n,r){switch(r){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function yd(n,r,e){let t=Math.min(n,r),o=Math.max(n,r),i=t+"_"+o;return e.get(i)}function gd(n,r,e,t,o,i){let s=Math.min(n,r),l=Math.max(n,r),c=s+"_"+l,u;if(t.has(c))u=t.get(c);else{let a=e[s],d=e[l];u={a,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function V_(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],gd(s.a,s.b,n,t,s,e),gd(s.b,s.c,n,t,s,e),gd(s.c,s.a,n,t,s,e)}function Al(n,r,e,t,o){n.push(new si(r,e,t,void 0,void 0,o))}function ai(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Nl(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Cl=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof io.BufferGeometry?r=new Po().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 io.Vector3,t,o,i,s,l,c=r.vertices,u=r.faces,a=r.faceVertexUvs[0],d=a!==void 0&&a.length>0,p=[],f=new Map;V_(c,u,p,f);let m=[],h,y,g,v,b,w,S;for(let j of Array.from(f.keys())){for(y=f.get(j),g=new io.Vector3,b=3/8,w=1/8,S=y.faces.length,S!=2&&(b=.5,w=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(b),e.set(0,0,0),s=0;s<S;s++){for(v=y.faces[s],l=0;l<3&&(h=c[R_(v,G_[l])],!(h!==y.a&&h!==y.b));l++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let T,_,x,C,P,N,O,A=[];for(o=0,i=c.length;o<i;o++){for(N=c[o],P=p[o].edges,t=P.length,t==3?T=3/16:t>3&&(T=3/(8*t)),_=1-t*Number(T),x=T,t<=2&&(t==2?(_=3/4,x=1/8):t==1||t==0),O=N.clone().multiplyScalar(_),e.set(0,0,0),s=0;s<t;s++)C=P[s],h=C.a!==N?C.a:C.b,e.add(h);e.multiplyScalar(Number(x)),O.add(e),A.push(O)}let R=A.concat(m),k=A.length,$,te,X,W=[],H=[],V,G,B,L,D=new io.Vector2,Y=new io.Vector2,q=new io.Vector2;for(o=0,i=u.length;o<i;o++)v=u[o],$=Number(yd(v.a,v.b,f).newEdge)+k,te=Number(yd(v.b,v.c,f).newEdge)+k,X=Number(yd(v.c,v.a,f).newEdge)+k,Al(W,$,te,X,v.materialIndex),Al(W,v.a,$,X,v.materialIndex),Al(W,v.b,te,$,v.materialIndex),Al(W,v.c,X,te,v.materialIndex),d&&(V=a[o],G=V[0],B=V[1],L=V[2],D.set(ai(G.x,B.x),ai(G.y,B.y)),Y.set(ai(B.x,L.x),ai(B.y,L.y)),q.set(ai(G.x,L.x),ai(G.y,L.y)),Nl(H,D,Y,q),Nl(H,G,D,q),Nl(H,B,Y,D),Nl(H,L,q,Y));r.vertices=R,r.faces=W,d&&(r.faceVertexUvs[0]=H)}};var it=new Rr.Vector3,jh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Rr.BufferGeometry().copy(new Rr.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(it),t={width:it.x,height:it.y,depth:it.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 Rr.BufferGeometry().copy(new Rr.BoxGeometry(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(it)):it.set(s.width,s.height,s.depth),(r!==it.x||e!==it.y||t!==it.z)&&i.scale(it.x===0?1:r/it.x,it.y===0?1:e/it.y,it.z===0?1:t/it.z);let l=i.originalGeometry;try{o>0?(l===void 0||s?.subdivisions!==o)&&(l===void 0&&(l=i),i=new Cl(o).modify(l).toBufferGeometry()):(l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return l!==void 0&&Object.assign(i,{originalGeometry:l}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new Rr.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(it);let s=100/it.x;Object.assign(i.parameters,{width:100,height:it.y*s,depth:it.z*s}),r(this.build(i))})}};var Il=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 Pe?n.shape:new Pe,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:l}=n.parameters,c=n.shape,u=r*.5,a=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,v=p+Math.cos(y)*a;c.addPoint(c.createPoint(g,v))}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=Vt.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var we=require("three"),Fh=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:l,cornerSegments:c}=n.parameters,u=new vd(r*.5,e,o,i,s,l,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function Es(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function xd(n,r,e,t,o,i){let s=r.clone().sub(n),l=e.clone().sub(n),c=s.angleTo(l);if(s.normalize(),l.normalize(),t===o){let u=s.add(l).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=s.angleTo(l);i.copy(n),i.addScaledVector(s,o/Math.sin(u)),i.addScaledVector(l,t/Math.sin(u))}}function z_(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var vd=class extends we.BufferGeometry{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,l=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),l=Math.floor(l);let c=[],u=[],a=[],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,v=Math.PI-g,b=new we.Vector3(0,-f,0),w=new we.Vector3(0,f,0),S=new we.Vector2(r,-f),T=new we.Vector2(h,-f),_=new we.Vector2(0,w.y).sub(T),x=new we.Vector2(0,w.y).sub(S),C=new we.Vector2(_.y,-_.x).normalize(),P=new we.Vector2(x.y,-x.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;s=Math.min(s,O);let A;{let H=new we.Vector3(C.x,C.y,0),V=new we.Vector3(Math.cos(y)*H.x,H.y,Math.sin(y)*H.x);A=H.angleTo(V)}let R=s/Math.tan((Math.PI-_.angle())/2),k=s/Math.tan((Math.PI-A)/2),$=new we.Vector3;if(!i){u.push(b.x,b.y,b.z),a.push(0,-1,0),d.push(0,0);let H=p++,V=[],G=S.clone(),B=R/Math.cos(Math.PI/t);G.x-=B;for(let L=0;L<t;L++){let D=L/t*Math.PI*2+m,Y=new we.Vector2(Math.sin(D),Math.cos(D));Es(G,Y,$),u.push($.x,$.y,$.z),a.push(0,-1,0),d.push(0,0),V.push(p++)}for(let L=0;L<V.length;L++)c.push(V[L],H,V[(L+1)%V.length])}let te=[];{let H=new we.Vector3,V=new we.Vector3,G=new we.Vector3,B=new we.Vector3,L=new we.Vector3,D=new we.Vector3;for(let Y=0;Y<t;Y++){let q=Y/t*Math.PI*2+m,j=(Y+.5)/t*Math.PI*2+m,F=(Y+1)/t*Math.PI*2+m,M=new we.Vector2(Math.sin(q),Math.cos(q)),Q=new we.Vector2(Math.sin(j),Math.cos(j)),re=new we.Vector2(Math.sin(F),Math.cos(F));Es(S,M,V),Es(S,re,G),Es(C,Q,H),xd(w,V,G,k,k,B),u.push(B.x,B.y,B.z),xd(V,w,G,k,R,L),u.push(L.x,L.y,L.z),xd(G,V,w,R,k,D),u.push(D.x,D.y,D.z),a.push(H.x,H.y,H.z),a.push(H.x,H.y,H.z),a.push(H.x,H.y,H.z),d.push(0,0),d.push(0,0),d.push(0,0);let oe=p++,K=p++,ee=p++;if(c.push(oe,K,ee),s>0){{let de=V.clone().add(G).multiplyScalar(.5),ae=w.clone().sub(de).normalize(),$e=b.clone().sub(de).normalize().add(ae).normalize().multiplyScalar(-1),xe=D.clone().sub(L);X(de,xe,$e,_.angle())}let J,se;{let de=new we.Vector3;Es(P,re,de);let ae=D.clone().add(B).multiplyScalar(.5);ae=z_(ae,G,w);let me=D.clone().sub(B);[J,se]=X(ae,me,de,A,B.y)}{let de=J,ae=de.clone().setY(0).normalize(),me=new we.Vector3(0,-1,0),$e=ae.clone().cross(me);W(de,ae,me,$e)}te.concat(se);{let de=_.angle(),ae=Math.PI-de,me=w.clone();me.y-=s/Math.sin(de-Math.PI/2);let $e=new we.Vector3,xe=[];for(let Ce=0;Ce<l;Ce++){let Et=[],Qt=Math.PI/2-ae*Ce/l,an=Math.cos(Qt),Ht=Math.sin(Qt),la=j;for(let ca=0;ca<=Ce;ca++){let da=Math.cos(la),Je=Math.sin(la);H.x=an*Je,H.y=Ht,H.z=an*da,$e.copy(me).addScaledVector(H,s),u.push($e.x,$e.y,$e.z),a.push(H.x,H.y,H.z),d.push(0,0),Et.push(p++),la+=Math.PI*2/Ce/t}xe.push(Et)}se.reverse(),xe.push(se);let rt=xe.length-1;for(let Ce=0;Ce<rt;Ce++){let Et=xe[Ce],Qt=xe[Ce+1],an=Et.length-1;c.push(Qt[1],Et[0],Qt[0]);for(let Ht=1;Ht<=an;Ht++)c.push(Et[Ht],Et[Ht-1],Qt[Ht]),c.push(Qt[Ht+1],Et[Ht],Qt[Ht])}}}}}this.setIndex(c),this.setAttribute("position",new we.Float32BufferAttribute(u,3)),this.setAttribute("normal",new we.Float32BufferAttribute(a,3)),this.setAttribute("uv",new we.Float32BufferAttribute(d,2));function X(H,V,G,B,L){let D=-B/2,Y=(Math.PI-B)/2,q=V.clone().normalize().cross(G);H.addScaledVector(G,-s/Math.sin(Y));let j=new we.Vector3,F=new we.Vector3,M=1,Q=p,re=[];for(let oe=0;oe<=l;oe++){let K=D+oe/l*B;F.set(0,0,0),F.addScaledVector(q,Math.sin(K)),F.addScaledVector(G,Math.cos(K));for(let ee=0;ee<=M;ee++){let J=ee/M-.5;if(j.copy(H),j.addScaledVector(V,J),j.addScaledVector(F,s),L!=null){let se=Math.max(0,j.y-L);j.addScaledVector(V,-se/V.y)}u.push(j.x,j.y,j.z),a.push(F.x,F.y,F.z),d.push(0,0),ee===0&&re.push(p),p++}}for(let oe=0;oe<l;oe++)for(let K=0;K<M;K++){let ee=Q+K+(M+1)*oe,J=ee+(M+1),se=J+1,de=ee+1;c.push(ee,J,de),c.push(J,se,de)}return[H.clone().addScaledVector(V,.5),re]}function W(H,V,G,B){let L=Math.PI/2,D=x.angle()-L,Y=[],q=new we.Vector3,j=new we.Vector3;for(let M=0;M<=l;M++){let Q=[],re=M/l;for(let oe=0;oe<=M;oe++){let ee=((M?oe/M:0)-.5)*v,J=Math.cos(ee),se=Math.sin(ee),de=Math.atan(Math.tan(D)*J),ae=(L+de)*re,me=Math.cos(ae),$e=Math.sin(ae);q.set(0,0,0),q.addScaledVector(V,$e*J),q.addScaledVector(G,me),q.addScaledVector(B,$e*se),j.copy(H).addScaledVector(q,s),u.push(j.x,j.y,j.z),a.push(q.x,q.y,q.z),d.push(0,0),Q.push(p++)}Y.push(Q)}let F=Y.length-1;for(let M=0;M<F;M++){let Q=Y[M],re=Y[M+1],oe=Q.length-1;c.push(Q[0],re[1],re[0]);for(let K=1;K<=oe;K++)c.push(Q[K-1],Q[K],re[K]),c.push(Q[K],re[K+1],re[K])}}}};var Ml=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 Pe?n.shape:new Pe,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:l,extrudeBevelSegments:c}=n.parameters,u={x:e*.5,y:t*.5},a={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(w,S,T){return S>e&&T>t?Math.min(w*e/S,w*t/T):S>e?w*e/S:T>t?w*t/T:w}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let m=a.x,h=d.x,y=d.y,g=a.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 v=!0;for(let w=0,S=r.points.length;w<S;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let b=Vt.create({shape:r,parameters:{depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(b,{userData:{...n,type:"RectangleGeometry"}})}};var kh=require("three"),Uh=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:l,thetaStart:c,thetaLength:u}=n.parameters,a=new kh.SphereGeometry(.5*r,o,i,s,l,c,u);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"SphereGeometry"}})}};var Hh=require("three"),qh=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 Hh.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var Oo=require("three"),Wh=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,l=new bd(r,e,t,o,i,s);return Object.assign(l,{userData:{...n,type:"BackdropGeometry"}})}},bd=class extends Oo.BufferGeometry{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let l=[],c=[],u=[],a=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-a,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(j=0,F=0,M=0)=>new Oo.Vector3(j,F,M),m=f(),h=f(),[y,g,v]=[e/2,r/2,t/2],b=-g,w=+g,[S,T,_]=[f(b,-y,+v),f(b,-y,-v),f(b,+y,-v)],x=(j,F=!1)=>Math.sin(j-Math.PI/(1+ +F)),C=(j,F=!1)=>Math.cos(j-Math.PI/(1+ +F));_.y=Math.sin(o)*e-y;let P=Math.cos(o)*e-v,N=S.z-a;o<=p?(_.z=Math.min(P,N),_.z==N&&(_.y-=(P-N)/Math.tan(p-o))):T.z=Math.min(T.z-P-v,S.z-a),m.subVectors(S,T),h.subVectors(_,T);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),R=O/Math.cos(o/2),k=m.clone().normalize().add(h.normalize()).setLength(R).add(T);m.set(0,x(o,!0),C(o,!0)),d.push([_,m.clone()]);let $=(Math.PI-o)/s;for(let j=0;j<=s;j++){let F=p+o+j*$;m.set(0,Math.sin(F)*A,Math.cos(F)*A),m.add(k),h.set(0,x(F),C(F)),d.push([m.clone(),h.clone()])}d.push([S,f(0,1,0)]);let te=Math.sin($/2)*A*2,X=d.length-1,W=d[0][0].distanceTo(d[1][0]),H=d[X-1][0].distanceTo(d[X][0]),V=W+te*s+H;d[0].push(1);for(let j=0;j<=s;j++)d[j+1].push(1-(W+j*te)/V);d[X].push(0);let[G,B,L]=d[0],D,Y,q;for(let j=1;j<d.length;j++)[D,Y,q]=d[j],l.push(b,G.y,G.z,b,D.y,D.z,w,G.y,G.z,w,G.y,G.z,b,D.y,D.z,w,D.y,D.z),c.push(0,B.y,B.z,0,Y.y,Y.z,0,B.y,B.z,0,B.y,B.z,0,Y.y,Y.z,0,Y.y,Y.z),u.push(0,L,0,q,1,L,1,L,0,q,1,q),[G,B,L]=[D,Y,q];this.setAttribute("position",new Oo.Float32BufferAttribute(l,3)),this.setAttribute("normal",new Oo.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Oo.Float32BufferAttribute(u,2))}};var El=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 Pe?n.shape:new Pe,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:l,extrudeBevelSize:c,extrudeBevelSegments:u}=n.parameters,a=n.shape,d=r*.5,p=e*.5,f=0,m=0,h=s*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*t/100,v=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let w=0;w<o;w++){let S=h*w,T=f+Math.sin(S)*d,_=m+Math.cos(S)*p;a.addPoint(a.createPoint(T,_))}}else for(let w=0;w<o;w++){let S=f+Math.cos(y)*d,T=m+Math.sin(y)*p;a.addPoint(a.createPoint(S,T)),y+=h,S=f+Math.cos(y)*g,T=m+Math.sin(y)*v,w<=o,a.addPoint(a.createPoint(S,T)),y+=h}a.isClosed=!0;for(let w=0,S=a.points.length;w<S;w++)a.points[w].roundness=i;a.roundness=i,a.update();let b=Vt.create({shape:a,parameters:{roundness:i,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...n,type:"StarGeometry"}})}};var $h=require("three"),Xh=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 $h.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var Yh=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:l,cornerSegments:c}=n.parameters,u=j_(r,e,t,r*.5,s,i,0,0,o,l,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function j_(n,r,e,t,o,i,s,l,c,u,a){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(u=0),new Is(!0,n,r,e,t,o,i,s,l,c,u,a)}var Kh=require("three"),Zh=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,l=r*.5;l!==e&&(l-=e);let c=new Kh.TorusKnotGeometry(l,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var Qh=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 Pe?n.shape:new Pe,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:l}=n.parameters,c=n.shape,u=r*.5,a=e*.5;l?(c.addPoint(c.createPoint(-u,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))):(c.addPoint(c.createPoint(0,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))),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=Vt.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};var ve=require("three");function Jh(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}function F_(n,r,e){let t=[new ve.Vector3,new ve.Vector3,new ve.Vector3],o=[new ve.Vector3,new ve.Vector3,new ve.Vector3];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,s)=>{let l=o[s],c=ve.MathUtils.lerp(i.length(),l.length(),e);i.lerp(l,e).setLength(c)}),new ve.Matrix4().makeBasis(t[0],t[1],t[2])}var ey=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??ii.create({parameters:kc}).userData.shape;return{path:n.path??kn.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...cl,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new Sd(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new ve.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},Sd=class extends ve.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!Jh(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,l=Math.floor(i*s),c=this.inputs.path.isClosed?Math.ceil((o+i)*s):Math.ceil(Math.min(1,o+i)*s),u=Math.min(Math.max(2,c-l+1),s+2),a=[],d=[];for(let O=0;O<u;O++){let A=this.inputs.path.isClosed?(O+l)%e.length:Math.min(O+l,e.length-1);a.push(e[A].clone()),d.push(t[A].clone())}let p=(O,A,R)=>{a[O]=a[O].clone().lerp(a[A],R),d[O]=F_(d[O],d[A],R)},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(a.length-1,a.length-2,1-h)),o===0){let O=a.length-1;a[O].copy(a[0]),d[O].copy(d[0])}this._applyPathModifiers(d,f,h);let{regions:g,infos:v,vertices:b}=this._computeShapePoints(5),w=0,S=0;v.sort((O,A)=>O.start-A.start),v.forEach(O=>{O.verticesStart=w,O.verticesCount=O.continuous.reduce((A,R,k)=>A+(k===0||!R?2:1),0),S+=O.verticesCount,w=S});let T=S*u,_,x=0;if(this._isOpenEnded()){try{_=yr({windingRule:_e.ODD,elementType:We.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:g})}catch{_=pd}x=_.vertexCount}let C=T+2*x,P={positions:new Float32Array(C*3),normals:new Float32Array(C*3),uvs:new Float32Array(C*2)},N=[];v.forEach(O=>{this._extrudeRegion(O,b,d,a,P,N,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,T,N,P,d[0],a[0],!1),this._closeEnd(_,T+x,N,P,d[d.length-1],a[a.length-1],!0)),this.setAttribute("position",new ve.BufferAttribute(P.positions,3)),this.setAttribute("normal",new ve.BufferAttribute(P.normals,3)),this.setAttribute("uv",new ve.BufferAttribute(P.uvs,2)),this.setIndex(N)}_extractPathPoints(){let t=xl(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 ve.Vector3,l=new ve.Vector3,c=new ve.Vector3,u=new ve.Vector3,a=new ve.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===o-1?b=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):b=e[y+1];let w=g.clone().sub(v).normalize(),S=b.clone().sub(g).normalize(),T=w.clone().add(S).normalize();c.copy(T),y===0&&(T.equals(a)||T.clone().negate().equals(a))&&a.set(0,0,1);let _=a.clone().cross(T).normalize(),x=T.clone().cross(_).normalize();a.copy(x),u.copy(_),y===0&&(s.copy(x),l.copy(T));let C=new ve.Matrix4().makeBasis(_,x,T);t.push(C)}let d=i?l:c,p=i?s:new ve.Vector3(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 ve.Matrix4().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:s,twist:l,startScale:c,endScale:u}=this.inputs.parameters.extrusion,a=new ve.Matrix4,d=new ve.Matrix4;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));a.makeRotationZ(ve.MathUtils.lerp(s,s+l,m));let h=ve.MathUtils.lerp(c,u,m);d.makeScale(h,h,h),p.multiply(a).multiply(d)}),e}_computeShapePoints(e=12,t=_e.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),s=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],w=y[v-0];g.push(b,w)}return g}),l;try{l=yr({windingRule:t,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{l=Cs}let c;try{c=yr({windingRule:_e.ODD,elementType:We.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{c=ud}if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?l.vertexCount:0;l.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=l.vertexCount;l.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];l.vertices.push(y)}}let a=1/0,d=-1/0,p=1/0,f=-1/0;for(let h=0,y=l.vertexCount;h<y;h++){let g=h*2,v=l.vertices[g+0],b=l.vertices[g+1];v<a&&(a=v),v>d&&(d=v),b<p&&(p=b),b>f&&(f=b)}let m=[];for(let h=l.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,v=l.elements[g+0],b=l.elements[g+1],w=v+b,S={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let T=v,_=w-1,x=v+1,C=o.roundedCurves.length;do{let P=T-v,N=l.vertices[_*2+0],O=l.vertices[_*2+1],A=l.vertices[T*2+0],R=l.vertices[T*2+1],k=l.vertices[x*2+0],$=l.vertices[x*2+1],te=A-N,X=R-O,W=Math.sqrt(te*te+X*X);te/=W,X/=W;let H=A-k,V=R-$,G=Math.sqrt(H*H+V*V);H/=G,V/=G,S.normals[P*2+0]=-V,S.normals[P*2+1]=H;let B=l.vertexIndices[T];if(Array.isArray(B))S.continuous[P]=!1;else{let[L,D]=o.getCurveIndexFromVertexId(B-1,!0);if(D>0&&D<1)S.continuous[P]=!0;else{let Y=D===1?L+1:L-1;Y=(Y+C)%C;let q=D===1?0:1,j=o.roundedCurves[L].getTangent(D),F=o.roundedCurves[Y].getTangent(q);S.continuous[P]=j.dot(F)>.95}}y&&(S.normals[P*2+0]*=-1,S.normals[P*2+1]*=-1),[_,T,x]=[T,x,x+1],x>=w&&(x-=b)}while(x!==v+1)}return{regions:[i,...s],infos:m,vertices:l.vertices}}_insertVertex(e,t,o,i,s){let l=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[l+0]=s.x,e.uvs[l+1]=s.y}_extrudeRegion(e,t,o,i,s,l,c){let u=new ve.Vector3,a=new ve.Vector3,d=new ve.Vector3,p=new ve.Vector3,f=new ve.Vector2;o.forEach((h,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let b=0;b<e.count;b++){let w=(e.start+b)*2;if(u.set(t[w+0],t[w+1],0),d.copy(u).applyMatrix4(h).add(g),e.continuous[b])p.set(e.normals[b*2+0],e.normals[b*2+1],0);else{let S=b==0?(e.start+e.count-1)*2:w-2;a.set(t[S+0],t[S+1],0),p.copy(u).sub(a),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(b===0?1:b/e.count,y/(o.length-1)),this._insertVertex(s,v,d,p,f),v++,!e.continuous[b]||b===0){if(b===0)p.set(e.normals[b*2+0],e.normals[b*2+1],0),f.set(0,y/(o.length-1));else{let S=b===e.count-1?e.start*2:w+2;a.set(t[S+0],t[S+1],0),p.copy(a).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(s,v,d,p,f),v++}}});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),v=0;for(let b=0;b<e.count;b++){(!e.continuous[b]||b===0)&&v++;let w=b===e.count-1?0:v+1,S=y+v,T=y+w,_=g+w,x=g+v;e.isHole?l.push(S,_,T,S,x,_):l.push(S,T,_,S,_,x),v++}}}_closeEnd(e,t,o,i,s,l,c){let u=e.vertexCount,a=new ve.Vector3(0,0,c?-1:1).applyMatrix4(s),d=new ve.Vector3,p=new ve.Vector2;for(let m=0;m<u;m++){let h=2*m;d.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(s).add(l),this._insertVertex(i,t+m,d,a,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,v=f[h+(c?2:1)]+t;o.push(y,g,v)}}};var $o=require("three"),ty=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ry(){let n=new $o.BufferGeometry;return n.setAttribute("position",new $o.BufferAttribute(new Float32Array([]),3)),n.setIndex(new $o.BufferAttribute(new Uint16Array([]),1)),n}var k_=ry().attributes,U_=12,H_=1,li=class extends $o.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,k_),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:l,extrudeBevelSegments:c,text:u,textTransform:a}=e,d=a===2?u.toUpperCase():a===3?u.toLowerCase():u,p=q_(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,v=f.map(S=>new Pe().fromShape(S));this.vectorShapes=v;let b=v.map(S=>Vt.create({shape:S,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?_e.NONZERO:_e.ODD,subdivisions:this.isLowResolution&&s>0?H_:U_}})),w=b.length?(0,ty.mergeBufferGeometries)(b):ry();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,T])=>{this.setAttribute(S,T)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Yr(new $o.BufferGeometry,li.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 q_(n,r,e){e=e??n.text;let t=[""],o="";for(let i of e)o+=i,i===" "||i===`
1
+ "use strict";var e0=Object.create;var fa=Object.defineProperty;var t0=Object.getOwnPropertyDescriptor;var r0=Object.getOwnPropertyNames;var o0=Object.getPrototypeOf,n0=Object.prototype.hasOwnProperty;var ma=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),gu=(n,r)=>{for(var e in r)fa(n,e,{get:r[e],enumerable:!0})},xu=(n,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of r0(r))!n0.call(n,o)&&o!==e&&fa(n,o,{get:()=>r[o],enumerable:!(t=t0(r,o))||t.enumerable});return n};var dn=(n,r,e)=>(e=n!=null?e0(o0(n)):{},xu(r||!n||!n.__esModule?fa(e,"default",{value:n,enumerable:!0}):e,n)),i0=n=>xu(fa({},"__esModule",{value:!0}),n);var $m=ma((Yc,Wm)=>{(function(n,r){typeof Yc=="object"?Wm.exports=r():typeof define=="function"&&define.amd?define(r):n.Alea=r()})(Yc,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 l=r();t=l(" "),o=l(" "),i=l(" ");for(var c=0;c<e.length;c++)t-=l(e[c]),t<0&&(t+=1),o-=l(e[c]),o<0&&(o+=1),i-=l(e[c]),i<0&&(i+=1);l=null;var u=function(){var a=2091639*t+s*23283064365386963e-26;return t=o,o=i,i=a-(s=a|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,s]},u.importState=function(a){t=+a[0]||0,o=+a[1]||0,i=+a[2]||0,s=+a[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 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 Jm=ma((xl,Qm)=>{(function(n,r){typeof xl=="object"&&typeof Qm<"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,l,c,u,a,d,p,f,m,h,y,g,v=r[0].length,b=r.length;if(b<v)throw new TypeError("Invalid matrix: m < n");for(var w=[],S=[],P=[],_=e==="f"?b:v,x=h=p=0;x<b;x++)S[x]=new Array(_).fill(0);for(x=0;x<v;x++)P[x]=new Array(v).fill(0);var C,T=new Array(v).fill(0);for(x=0;x<b;x++)for(s=0;s<v;s++)S[x][s]=r[x][s];for(x=0;x<v;x++){for(w[x]=p,m=0,c=x+1,s=x;s<b;s++)m+=Math.pow(S[s][x],2);if(m<i)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x]=d-p,s=c;s<v;s++){for(m=0,l=x;l<b;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<b;l++)S[l][s]=S[l][s]+d*S[l][x]}for(T[x]=p,m=0,s=c;s<v;s++)m+=Math.pow(S[x][s],2);if(m<i)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x+1]=d-p,s=c;s<v;s++)w[s]=S[x][s]/f;for(s=c;s<b;s++){for(m=0,l=c;l<v;l++)m+=S[s][l]*S[x][l];for(l=c;l<v;l++)S[s][l]=S[s][l]+m*w[l]}}h<(y=Math.abs(T[x])+Math.abs(w[x]))&&(h=y)}if(t)for(x=v-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,s=c;s<v;s++)P[s][x]=S[x][s]/f;for(s=c;s<v;s++){for(m=0,l=c;l<v;l++)m+=S[x][l]*P[l][s];for(l=c;l<v;l++)P[l][s]=P[l][s]+m*P[l][x]}}for(s=c;s<v;s++)P[x][s]=0,P[s][x]=0;P[x][x]=1,p=w[x],c=x}if(e){if(e==="f")for(x=v;x<b;x++){for(s=v;s<b;s++)S[x][s]=0;S[x][x]=1}for(x=v-1;0<=x;x--){for(c=x+1,p=T[x],s=c;s<_;s++)S[x][s]=0;if(p!==0){for(f=S[x][x]*p,s=c;s<_;s++){for(m=0,l=c;l<b;l++)m+=S[l][x]*S[l][s];for(d=m/f,l=x;l<b;l++)S[l][s]=S[l][s]+d*S[l][x]}for(s=x;s<b;s++)S[s][x]=S[s][x]/p}else for(s=x;s<b;s++)S[s][x]=0;S[x][x]=S[x][x]+1}}for(o*=h,l=v-1;0<=l;l--)for(var N=0;N<50;N++){for(C=!1,c=l;0<=c;c--){if(Math.abs(w[c])<=o){C=!0;break}if(Math.abs(T[c-1])<=o)break}if(!C){for(a=0,u=c-(m=1),x=c;x<l+1&&(d=m*w[x],w[x]=a*w[x],!(Math.abs(d)<=o));x++)if(p=T[x],T[x]=Math.sqrt(d*d+p*p),a=p/(f=T[x]),m=-d/f,e)for(s=0;s<b;s++)y=S[s][u],g=S[s][x],S[s][u]=y*a+g*m,S[s][x]=-y*m+g*a}if(g=T[l],c===l){if(g<0&&(T[l]=-g,t))for(s=0;s<v;s++)P[s][l]=-P[s][l];break}for(h=T[c],d=(((y=T[l-1])-g)*(y+g)+((p=w[l-1])-(f=w[l]))*(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,x=c+(m=a=1);x<l+1;x++){if(p=w[x],y=T[x],f=m*p,p*=a,g=Math.sqrt(d*d+f*f),d=h*(a=d/(w[x-1]=g))+p*(m=f/g),p=-h*m+p*a,f=y*m,y*=a,t)for(s=0;s<v;s++)h=P[s][x-1],g=P[s][x],P[s][x-1]=h*a+g*m,P[s][x]=-h*m+g*a;if(g=Math.sqrt(d*d+f*f),d=(a=d/(T[x-1]=g))*p+(m=f/g)*y,h=-m*p+a*y,e)for(s=0;s<b;s++)y=S[s][x-1],g=S[s][x],S[s][x-1]=y*a+g*m,S[s][x]=-y*m+g*a}w[c]=0,w[l]=d,T[l]=h}for(x=0;x<v;x++)T[x]<o&&(T[x]=0);return{u:S,q:T,v:P}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});var zy=ma(Kl=>{(function(){"use strict";var n=function(){this.init()};n.prototype={init:function(){var a=this||r;return a._counter=1e3,a._html5AudioPool=[],a.html5PoolSize=10,a._codecs={},a._howls=[],a._muted=!1,a._volume=1,a._canPlayEvent="canplaythrough",a._navigator=typeof window<"u"&&window.navigator?window.navigator:null,a.masterGain=null,a.noAudio=!1,a.usingWebAudio=!0,a.autoSuspend=!0,a.ctx=null,a.autoUnlock=!0,a._setup(),a},volume:function(a){var d=this||r;if(a=parseFloat(a),d.ctx||u(),typeof a<"u"&&a>=0&&a<=1){if(d._volume=a,d._muted)return d;d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a,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*a)}return d}return d._volume},mute:function(a){var d=this||r;d.ctx||u(),d._muted=a,d.usingWebAudio&&d.masterGain.gain.setValueAtTime(a?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=a?!0:h._muted)}return d},stop:function(){for(var a=this||r,d=0;d<a._howls.length;d++)a._howls[d].stop();return a},unload:function(){for(var a=this||r,d=a._howls.length-1;d>=0;d--)a._howls[d].unload();return a.usingWebAudio&&a.ctx&&typeof a.ctx.close<"u"&&(a.ctx.close(),a.ctx=null,u()),a},codecs:function(a){return(this||r)._codecs[a.replace(/^x-/,"")]},_setup:function(){var a=this||r;if(a.state=a.ctx&&a.ctx.state||"suspended",a._autoSuspend(),!a.usingWebAudio)if(typeof Audio<"u")try{var d=new Audio;typeof d.oncanplaythrough>"u"&&(a._canPlayEvent="canplay")}catch{a.noAudio=!0}else a.noAudio=!0;try{var d=new Audio;d.muted&&(a.noAudio=!0)}catch{}return a.noAudio||a._setupCodecs(),a},_setupCodecs:function(){var a=this||r,d=null;try{d=typeof Audio<"u"?new Audio:null}catch{return a}if(!d||typeof d.canPlayType!="function")return a;var p=d.canPlayType("audio/mpeg;").replace(/^no$/,""),f=a._navigator?a._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\/(.*?) /),v=y&&g&&parseInt(g[1],10)<15;return a._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:!!(!v&&d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!v&&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$/,"")},a},_unlockAudio:function(){var a=this||r;if(!(a._audioUnlocked||!a.ctx)){a._audioUnlocked=!1,a.autoUnlock=!1,!a._mobileUnloaded&&a.ctx.sampleRate!==44100&&(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var d=function(p){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,a._releaseHtml5Audio(f)}catch{a.noAudio=!0;break}for(var m=0;m<a._howls.length;m++)if(!a._howls[m]._webAudio)for(var h=a._howls[m]._getSoundIds(),y=0;y<h.length;y++){var g=a._howls[m]._soundById(h[y]);g&&g._node&&!g._node._unlocked&&(g._node._unlocked=!0,g._node.load())}a._autoResume();var v=a.ctx.createBufferSource();v.buffer=a._scratchBuffer,v.connect(a.ctx.destination),typeof v.start>"u"?v.noteOn(0):v.start(0),typeof a.ctx.resume=="function"&&a.ctx.resume(),v.onended=function(){v.disconnect(0),a._audioUnlocked=!0,document.removeEventListener("touchstart",d,!0),document.removeEventListener("touchend",d,!0),document.removeEventListener("click",d,!0),document.removeEventListener("keydown",d,!0);for(var b=0;b<a._howls.length;b++)a._howls[b]._emit("unlock")}};return document.addEventListener("touchstart",d,!0),document.addEventListener("touchend",d,!0),document.addEventListener("click",d,!0),document.addEventListener("keydown",d,!0),a}},_obtainHtml5Audio:function(){var a=this||r;if(a._html5AudioPool.length)return a._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(a){var d=this||r;return a._unlocked&&d._html5AudioPool.push(a),d},_autoSuspend:function(){var a=this;if(!(!a.autoSuspend||!a.ctx||typeof a.ctx.suspend>"u"||!r.usingWebAudio)){for(var d=0;d<a._howls.length;d++)if(a._howls[d]._webAudio){for(var p=0;p<a._howls[d]._sounds.length;p++)if(!a._howls[d]._sounds[p]._paused)return a}return a._suspendTimer&&clearTimeout(a._suspendTimer),a._suspendTimer=setTimeout(function(){if(!!a.autoSuspend){a._suspendTimer=null,a.state="suspending";var f=function(){a.state="suspended",a._resumeAfterSuspend&&(delete a._resumeAfterSuspend,a._autoResume())};a.ctx.suspend().then(f,f)}},3e4),a}},_autoResume:function(){var a=this;if(!(!a.ctx||typeof a.ctx.resume>"u"||!r.usingWebAudio))return a.state==="running"&&a.ctx.state!=="interrupted"&&a._suspendTimer?(clearTimeout(a._suspendTimer),a._suspendTimer=null):a.state==="suspended"||a.state==="running"&&a.ctx.state==="interrupted"?(a.ctx.resume().then(function(){a.state="running";for(var d=0;d<a._howls.length;d++)a._howls[d]._emit("resume")}),a._suspendTimer&&(clearTimeout(a._suspendTimer),a._suspendTimer=null)):a.state==="suspending"&&(a._resumeAfterSuspend=!0),a}};var r=new n,e=function(a){var d=this;if(!a.src||a.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}d.init(a)};e.prototype={init:function(a){var d=this;return r.ctx||u(),d._autoplay=a.autoplay||!1,d._format=typeof a.format!="string"?a.format:[a.format],d._html5=a.html5||!1,d._muted=a.mute||!1,d._loop=a.loop||!1,d._pool=a.pool||5,d._preload=typeof a.preload=="boolean"||a.preload==="metadata"?a.preload:!0,d._rate=a.rate||1,d._sprite=a.sprite||{},d._src=typeof a.src!="string"?a.src:[a.src],d._volume=a.volume!==void 0?a.volume:1,d._xhr={method:a.xhr&&a.xhr.method?a.xhr.method:"GET",headers:a.xhr&&a.xhr.headers?a.xhr.headers:null,withCredentials:a.xhr&&a.xhr.withCredentials?a.xhr.withCredentials:!1},d._duration=0,d._state="unloaded",d._sounds=[],d._endTimers={},d._queue=[],d._playLock=!1,d._onend=a.onend?[{fn:a.onend}]:[],d._onfade=a.onfade?[{fn:a.onfade}]:[],d._onload=a.onload?[{fn:a.onload}]:[],d._onloaderror=a.onloaderror?[{fn:a.onloaderror}]:[],d._onplayerror=a.onplayerror?[{fn:a.onplayerror}]:[],d._onpause=a.onpause?[{fn:a.onpause}]:[],d._onplay=a.onplay?[{fn:a.onplay}]:[],d._onstop=a.onstop?[{fn:a.onstop}]:[],d._onmute=a.onmute?[{fn:a.onmute}]:[],d._onvolume=a.onvolume?[{fn:a.onvolume}]:[],d._onrate=a.onrate?[{fn:a.onrate}]:[],d._onseek=a.onseek?[{fn:a.onseek}]:[],d._onunlock=a.onunlock?[{fn:a.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 a=this,d=null;if(r.noAudio){a._emit("loaderror",null,"No audio support.");return}typeof a._src=="string"&&(a._src=[a._src]);for(var p=0;p<a._src.length;p++){var f,m;if(a._format&&a._format[p])f=a._format[p];else{if(m=a._src[p],typeof m!="string"){a._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=a._src[p];break}}if(!d){a._emit("loaderror",null,"No codec support for selected audio sources.");return}return a._src=d,a._state="loading",window.location.protocol==="https:"&&d.slice(0,5)==="http:"&&(a._html5=!0,a._webAudio=!1),new t(a),a._webAudio&&i(a),a},play:function(a,d){var p=this,f=null;if(typeof a=="number")f=a,a=null;else{if(typeof a=="string"&&p._state==="loaded"&&!p._sprite[a])return null;if(typeof a>"u"&&(a="__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?a=null:f=null}}var y=f?p._soundById(f):p._inactiveSound();if(!y)return null;if(f&&!a&&(a=y._sprite||"__default"),p._state!=="loaded"){y._sprite=a,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 v=Math.max(0,y._seek>0?y._seek:p._sprite[a][0]/1e3),b=Math.max(0,(p._sprite[a][0]+p._sprite[a][1])/1e3-v),w=b*1e3/Math.abs(y._rate),S=p._sprite[a][0]/1e3,P=(p._sprite[a][0]+p._sprite[a][1])/1e3;y._sprite=a,y._ended=!1;var _=function(){y._paused=!1,y._seek=v,y._start=S,y._stop=P,y._loop=!!(y._loop||p._sprite[a][2])};if(v>=P){p._ended(y);return}var x=y._node;if(p._webAudio){var C=function(){p._playLock=!1,_(),p._refreshBuffer(y);var A=y._muted||p._muted?0:y._volume;x.gain.setValueAtTime(A,r.ctx.currentTime),y._playStart=r.ctx.currentTime,typeof x.bufferSource.start>"u"?y._loop?x.bufferSource.noteGrainOn(0,v,86400):x.bufferSource.noteGrainOn(0,v,b):y._loop?x.bufferSource.start(0,v,86400):x.bufferSource.start(0,v,b),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"?C():(p._playLock=!0,p.once("resume",C),p._clearTimer(y._id))}else{var T=function(){x.currentTime=v,x.muted=y._muted||p._muted||r._muted||x.muted,x.volume=y._volume*r.volume(),x.playbackRate=y._rate;try{var A=x.play();if(A&&typeof Promise<"u"&&(A instanceof Promise||typeof A.then=="function")?(p._playLock=!0,_(),A.then(function(){p._playLock=!1,x._unlocked=!0,d?p._loadQueue():p._emit("play",y._id)}).catch(function(){p._playLock=!1,p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),y._ended=!0,y._paused=!0})):d||(p._playLock=!1,_(),p._emit("play",y._id)),x.playbackRate=y._rate,x.paused){p._emit("playerror",y._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}a!=="__default"||y._loop?p._endTimers[y._id]=setTimeout(p._ended.bind(p,y),w):(p._endTimers[y._id]=function(){p._ended(y),x.removeEventListener("ended",p._endTimers[y._id],!1)},x.addEventListener("ended",p._endTimers[y._id],!1))}catch(R){p._emit("playerror",y._id,R)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=p._src,x.load());var N=window&&window.ejecta||!x.readyState&&r._navigator.isCocoonJS;if(x.readyState>=3||N)T();else{p._playLock=!0,p._state="loading";var O=function(){p._state="loaded",T(),x.removeEventListener(r._canPlayEvent,O,!1)};x.addEventListener(r._canPlayEvent,O,!1),p._clearTimer(y._id)}}return y._id},pause:function(a){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"pause",action:function(){d.pause(a)}}),d;for(var p=d._getSoundIds(a),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(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"stop",action:function(){p.stop(a)}}),p;for(var f=p._getSoundIds(a),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(a,d){var p=this;if(p._state!=="loaded"||p._playLock)return p._queue.push({event:"mute",action:function(){p.mute(a,d)}}),p;if(typeof d>"u")if(typeof a=="boolean")p._muted=a;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=a,h._interval&&p._stopFade(h._id),p._webAudio&&h._node?h._node.gain.setValueAtTime(a?0:h._volume,r.ctx.currentTime):h._node&&(h._node.muted=r._muted?!0:a),p._emit("mute",h._id))}return p},volume:function(){var a=this,d=arguments,p,f;if(d.length===0)return a._volume;if(d.length===1||d.length===2&&typeof d[1]>"u"){var m=a._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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"volume",action:function(){a.volume.apply(a,d)}}),a;typeof f>"u"&&(a._volume=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)y=a._soundById(f[g]),y&&(y._volume=p,d[2]||a._stopFade(f[g]),a._webAudio&&y._node&&!y._muted?y._node.gain.setValueAtTime(p,r.ctx.currentTime):y._node&&!y._muted&&(y._node.volume=p*r.volume()),a._emit("volume",y._id))}else return y=f?a._soundById(f):a._sounds[0],y?y._volume:0;return a},fade:function(a,d,p,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(a,d,p,f)}}),m;a=Math.min(Math.max(0,parseFloat(a)),1),d=Math.min(Math.max(0,parseFloat(d)),1),p=parseFloat(p),m.volume(a,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 v=r.ctx.currentTime,b=v+p/1e3;g._volume=a,g._node.gain.setValueAtTime(a,v),g._node.gain.linearRampToValueAtTime(d,b)}m._startFadeInterval(g,a,d,p,h[y],typeof f>"u")}}return m},_startFadeInterval:function(a,d,p,f,m,h){var y=this,g=d,v=p-d,b=Math.abs(v/.01),w=Math.max(4,b>0?f/b:f),S=Date.now();a._fadeTo=p,a._interval=setInterval(function(){var P=(Date.now()-S)/f;S=Date.now(),g+=v*P,g=Math.round(g*100)/100,v<0?g=Math.max(p,g):g=Math.min(p,g),y._webAudio?a._volume=g:y.volume(g,a._id,!0),h&&(y._volume=g),(p<d&&g<=p||p>d&&g>=p)&&(clearInterval(a._interval),a._interval=null,a._fadeTo=null,y.volume(p,a._id),y._emit("fade",a._id))},w)},_stopFade:function(a){var d=this,p=d._soundById(a);return p&&p._interval&&(d._webAudio&&p._node.gain.cancelScheduledValues(r.ctx.currentTime),clearInterval(p._interval),p._interval=null,d.volume(p._fadeTo,a),p._fadeTo=null,d._emit("fade",a)),d},loop:function(){var a=this,d=arguments,p,f,m;if(d.length===0)return a._loop;if(d.length===1)if(typeof d[0]=="boolean")p=d[0],a._loop=p;else return m=a._soundById(parseInt(d[0],10)),m?m._loop:!1;else d.length===2&&(p=d[0],f=parseInt(d[1],10));for(var h=a._getSoundIds(f),y=0;y<h.length;y++)m=a._soundById(h[y]),m&&(m._loop=p,a._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,a.playing(h[y])&&(a.pause(h[y],!0),a.play(h[y],!0)))));return a},rate:function(){var a=this,d=arguments,p,f;if(d.length===0)f=a._sounds[0]._id;else if(d.length===1){var m=a._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(a._state!=="loaded"||a._playLock)return a._queue.push({event:"rate",action:function(){a.rate.apply(a,d)}}),a;typeof f>"u"&&(a._rate=p),f=a._getSoundIds(f);for(var g=0;g<f.length;g++)if(y=a._soundById(f[g]),y){a.playing(f[g])&&(y._rateSeek=a.seek(f[g]),y._playStart=a._webAudio?r.ctx.currentTime:y._playStart),y._rate=p,a._webAudio&&y._node&&y._node.bufferSource?y._node.bufferSource.playbackRate.setValueAtTime(p,r.ctx.currentTime):y._node&&(y._node.playbackRate=p);var v=a.seek(f[g]),b=(a._sprite[y._sprite][0]+a._sprite[y._sprite][1])/1e3-v,w=b*1e3/Math.abs(y._rate);(a._endTimers[f[g]]||!y._paused)&&(a._clearTimer(f[g]),a._endTimers[f[g]]=setTimeout(a._ended.bind(a,y),w)),a._emit("rate",y._id)}}else return y=a._soundById(f),y?y._rate:a._rate;return a},seek:function(){var a=this,d=arguments,p,f;if(d.length===0)a._sounds.length&&(f=a._sounds[0]._id);else if(d.length===1){var m=a._getSoundIds(),h=m.indexOf(d[0]);h>=0?f=parseInt(d[0],10):a._sounds.length&&(f=a._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"&&(a._state!=="loaded"||a._playLock))return a._queue.push({event:"seek",action:function(){a.seek.apply(a,d)}}),a;var y=a._soundById(f);if(y)if(typeof p=="number"&&p>=0){var g=a.playing(f);g&&a.pause(f,!0),y._seek=p,y._ended=!1,a._clearTimer(f),!a._webAudio&&y._node&&!isNaN(y._node.duration)&&(y._node.currentTime=p);var v=function(){g&&a.play(f,!0),a._emit("seek",f)};if(g&&!a._webAudio){var b=function(){a._playLock?setTimeout(b,0):v()};setTimeout(b,0)}else v()}else if(a._webAudio){var w=a.playing(f)?r.ctx.currentTime-y._playStart:0,S=y._rateSeek?y._rateSeek-y._seek:0;return y._seek+(S+w*Math.abs(y._rate))}else return y._node.currentTime;return a},playing:function(a){var d=this;if(typeof a=="number"){var p=d._soundById(a);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(a){var d=this,p=d._duration,f=d._soundById(a);return f&&(p=d._sprite[f._sprite][1]/1e3),p},state:function(){return this._state},unload:function(){for(var a=this,d=a._sounds,p=0;p<d.length;p++)d[p]._paused||a.stop(d[p]._id),a._webAudio||(a._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,a._clearTimer(d[p]._id);var f=r._howls.indexOf(a);f>=0&&r._howls.splice(f,1);var m=!0;for(p=0;p<r._howls.length;p++)if(r._howls[p]._src===a._src||a._src.indexOf(r._howls[p]._src)>=0){m=!1;break}return o&&m&&delete o[a._src],r.noAudio=!1,a._state="unloaded",a._sounds=[],a=null,null},on:function(a,d,p,f){var m=this,h=m["_on"+a];return typeof d=="function"&&h.push(f?{id:p,fn:d,once:f}:{id:p,fn:d}),m},off:function(a,d,p){var f=this,m=f["_on"+a],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(a)f["_on"+a]=[];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(a,d,p){var f=this;return f.on(a,d,p,1),f},_emit:function(a,d,p){for(var f=this,m=f["_on"+a],h=m.length-1;h>=0;h--)(!m[h].id||m[h].id===d||a==="load")&&(setTimeout(function(y){y.call(this,d,p)}.bind(f,m[h].fn),0),m[h].once&&f.off(a,m[h].fn,m[h].id));return f._loadQueue(a),f},_loadQueue:function(a){var d=this;if(d._queue.length>0){var p=d._queue[0];p.event===a&&(d._queue.shift(),d._loadQueue()),a||p.action()}return d},_ended:function(a){var d=this,p=a._sprite;if(!d._webAudio&&a._node&&!a._node.paused&&!a._node.ended&&a._node.currentTime<a._stop)return setTimeout(d._ended.bind(d,a),100),d;var f=!!(a._loop||d._sprite[p][2]);if(d._emit("end",a._id),!d._webAudio&&f&&d.stop(a._id,!0).play(a._id),d._webAudio&&f){d._emit("play",a._id),a._seek=a._start||0,a._rateSeek=0,a._playStart=r.ctx.currentTime;var m=(a._stop-a._start)*1e3/Math.abs(a._rate);d._endTimers[a._id]=setTimeout(d._ended.bind(d,a),m)}return d._webAudio&&!f&&(a._paused=!0,a._ended=!0,a._seek=a._start||0,a._rateSeek=0,d._clearTimer(a._id),d._cleanBuffer(a._node),r._autoSuspend()),!d._webAudio&&!f&&d.stop(a._id,!0),d},_clearTimer:function(a){var d=this;if(d._endTimers[a]){if(typeof d._endTimers[a]!="function")clearTimeout(d._endTimers[a]);else{var p=d._soundById(a);p&&p._node&&p._node.removeEventListener("ended",d._endTimers[a],!1)}delete d._endTimers[a]}return d},_soundById:function(a){for(var d=this,p=0;p<d._sounds.length;p++)if(a===d._sounds[p]._id)return d._sounds[p];return null},_inactiveSound:function(){var a=this;a._drain();for(var d=0;d<a._sounds.length;d++)if(a._sounds[d]._ended)return a._sounds[d].reset();return new t(a)},_drain:function(){var a=this,d=a._pool,p=0,f=0;if(!(a._sounds.length<d)){for(f=0;f<a._sounds.length;f++)a._sounds[f]._ended&&p++;for(f=a._sounds.length-1;f>=0;f--){if(p<=d)return;a._sounds[f]._ended&&(a._webAudio&&a._sounds[f]._node&&a._sounds[f]._node.disconnect(0),a._sounds.splice(f,1),p--)}}},_getSoundIds:function(a){var d=this;if(typeof a>"u"){for(var p=[],f=0;f<d._sounds.length;f++)p.push(d._sounds[f]._id);return p}else return[a]},_refreshBuffer:function(a){var d=this;return a._node.bufferSource=r.ctx.createBufferSource(),a._node.bufferSource.buffer=o[d._src],a._panner?a._node.bufferSource.connect(a._panner):a._node.bufferSource.connect(a._node),a._node.bufferSource.loop=a._loop,a._loop&&(a._node.bufferSource.loopStart=a._start||0,a._node.bufferSource.loopEnd=a._stop||0),a._node.bufferSource.playbackRate.setValueAtTime(a._rate,r.ctx.currentTime),d},_cleanBuffer:function(a){var d=this,p=r._navigator&&r._navigator.vendor.indexOf("Apple")>=0;if(r._scratchBuffer&&a.bufferSource&&(a.bufferSource.onended=null,a.bufferSource.disconnect(0),p))try{a.bufferSource.buffer=r._scratchBuffer}catch{}return a.bufferSource=null,d},_clearSound:function(a){var d=/MSIE |Trident\//.test(r._navigator&&r._navigator.userAgent);d||(a.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var t=function(a){this._parent=a,this.init()};t.prototype={init:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,d._sounds.push(a),a.create(),a},create:function(){var a=this,d=a._parent,p=r._muted||a._muted||a._parent._muted?0:a._volume;return d._webAudio?(a._node=typeof r.ctx.createGain>"u"?r.ctx.createGainNode():r.ctx.createGain(),a._node.gain.setValueAtTime(p,r.ctx.currentTime),a._node.paused=!0,a._node.connect(r.masterGain)):r.noAudio||(a._node=r._obtainHtml5Audio(),a._errorFn=a._errorListener.bind(a),a._node.addEventListener("error",a._errorFn,!1),a._loadFn=a._loadListener.bind(a),a._node.addEventListener(r._canPlayEvent,a._loadFn,!1),a._endFn=a._endListener.bind(a),a._node.addEventListener("ended",a._endFn,!1),a._node.src=d._src,a._node.preload=d._preload===!0?"auto":d._preload,a._node.volume=p*r.volume(),a._node.load()),a},reset:function(){var a=this,d=a._parent;return a._muted=d._muted,a._loop=d._loop,a._volume=d._volume,a._rate=d._rate,a._seek=0,a._rateSeek=0,a._paused=!0,a._ended=!0,a._sprite="__default",a._id=++r._counter,a},_errorListener:function(){var a=this;a._parent._emit("loaderror",a._id,a._node.error?a._node.error.code:0),a._node.removeEventListener("error",a._errorFn,!1)},_loadListener:function(){var a=this,d=a._parent;d._duration=Math.ceil(a._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()),a._node.removeEventListener(r._canPlayEvent,a._loadFn,!1)},_endListener:function(){var a=this,d=a._parent;d._duration===1/0&&(d._duration=Math.ceil(a._node.duration*10)/10,d._sprite.__default[1]===1/0&&(d._sprite.__default[1]=d._duration*1e3),d._ended(a)),a._node.removeEventListener("ended",a._endFn,!1)}};var o={},i=function(a){var d=a._src;if(o[d]){a._duration=o[d].duration,c(a);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);l(f.buffer,a)}else{var h=new XMLHttpRequest;h.open(a._xhr.method,d,!0),h.withCredentials=a._xhr.withCredentials,h.responseType="arraybuffer",a._xhr.headers&&Object.keys(a._xhr.headers).forEach(function(y){h.setRequestHeader(y,a._xhr.headers[y])}),h.onload=function(){var y=(h.status+"")[0];if(y!=="0"&&y!=="2"&&y!=="3"){a._emit("loaderror",null,"Failed loading audio file with status: "+h.status+".");return}l(h.response,a)},h.onerror=function(){a._webAudio&&(a._html5=!0,a._webAudio=!1,a._sounds=[],delete o[d],a.load())},s(h)}},s=function(a){try{a.send()}catch{a.onerror()}},l=function(a,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(a).then(f).catch(p):r.ctx.decodeAudioData(a,f,p)},c=function(a,d){d&&!a._duration&&(a._duration=d.duration),Object.keys(a._sprite).length===0&&(a._sprite={__default:[0,a._duration*1e3]}),a._state!=="loaded"&&(a._state="loaded",a._emit("load"),a._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 a=/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(a&&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 Kl<"u"&&(Kl.Howler=r,Kl.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 l=this;if(!l.ctx||!l.ctx.listener)return l;var c=l._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")l._orientation=[r,e,t,o,i,s],typeof l.ctx.listener.forwardX<"u"?(l.ctx.listener.forwardX.setTargetAtTime(r,Howler.ctx.currentTime,.1),l.ctx.listener.forwardY.setTargetAtTime(e,Howler.ctx.currentTime,.1),l.ctx.listener.forwardZ.setTargetAtTime(t,Howler.ctx.currentTime,.1),l.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),l.ctx.listener.upY.setTargetAtTime(i,Howler.ctx.currentTime,.1),l.ctx.listener.upZ.setTargetAtTime(s,Howler.ctx.currentTime,.1)):l.ctx.listener.setOrientation(r,e,t,o,i,s);else return c;return l},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 l=t._soundById(i[s]);if(l)if(typeof r=="number")l._stereo=r,l._pos=[r,0,0],l._node&&(l._pannerAttr.panningModel="equalpower",(!l._panner||!l._panner.pan)&&n(l,o),o==="spatial"?typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(r,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):l._panner.setPosition(r,0,0):l._panner.pan.setValueAtTime(r,Howler.ctx.currentTime)),t._emit("stereo",l._id);else return l._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),l=0;l<s.length;l++){var c=i._soundById(s[l]);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),l=0;l<s.length;l++){var c=i._soundById(s[l]);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),l=0;l<s.length;l++)if(i=r._soundById(s[l]),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 Hg=ma((f7,Ug)=>{Ug.exports=function(r,e){for(var t=r.split("."),o=e.split("."),i=0;i<3;i++){var s=Number(t[i]),l=Number(o[i]);if(s>l)return 1;if(l>s)return-1;if(!isNaN(s)&&isNaN(l))return 1;if(isNaN(s)&&!isNaN(l))return-1}return 0}});var mT={};gu(mT,{default:()=>hc});module.exports=i0(mT);var yc=require("three");function vu(n){for(let r of Object.keys(n))n[r]===void 0&&delete n[r];return n}function Kr(n,r){return Object.setPrototypeOf(n,r),n}function ha(n){return Array.isArray(n)?n:[n]}function bu(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 s0=typeof global=="object"&&global&&global.Object===Object&&global,ya=s0;var a0=typeof self=="object"&&self&&self.Object===Object&&self,l0=ya||a0||Function("return this")(),it=l0;var c0=it.Symbol,ut=c0;var Su=Object.prototype,d0=Su.hasOwnProperty,u0=Su.toString,ns=ut?ut.toStringTag:void 0;function p0(n){var r=d0.call(n,ns),e=n[ns];try{n[ns]=void 0;var t=!0}catch{}var o=u0.call(n);return t&&(r?n[ns]=e:delete n[ns]),o}var wu=p0;var f0=Object.prototype,m0=f0.toString;function h0(n){return m0.call(n)}var _u=h0;var y0="[object Null]",g0="[object Undefined]",Pu=ut?ut.toStringTag:void 0;function x0(n){return n==null?n===void 0?g0:y0:Pu&&Pu in Object(n)?wu(n):_u(n)}var Yt=x0;function v0(n){return n!=null&&typeof n=="object"}var bt=v0;var b0="[object Symbol]";function S0(n){return typeof n=="symbol"||bt(n)&&Yt(n)==b0}var un=S0;function w0(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 ga=w0;var _0=Array.isArray,Xe=_0;var P0=1/0,Tu=ut?ut.prototype:void 0,Ou=Tu?Tu.toString:void 0;function Au(n){if(typeof n=="string")return n;if(Xe(n))return ga(n,Au)+"";if(un(n))return Ou?Ou.call(n):"";var r=n+"";return r=="0"&&1/n==-P0?"-0":r}var Nu=Au;function T0(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}var Xt=T0;function O0(n){return n}var Cu=O0;var A0="[object AsyncFunction]",N0="[object Function]",C0="[object GeneratorFunction]",I0="[object Proxy]";function M0(n){if(!Xt(n))return!1;var r=Yt(n);return r==N0||r==C0||r==A0||r==I0}var xa=M0;var E0=it["__core-js_shared__"],va=E0;var Iu=function(){var n=/[^.]+$/.exec(va&&va.keys&&va.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function L0(n){return!!Iu&&Iu in n}var Mu=L0;var B0=Function.prototype,D0=B0.toString;function G0(n){if(n!=null){try{return D0.call(n)}catch{}try{return n+""}catch{}}return""}var Zr=G0;var R0=/[\\^$.*+?()[\]{}|]/g,V0=/^\[object .+?Constructor\]$/,z0=Function.prototype,j0=Object.prototype,F0=z0.toString,k0=j0.hasOwnProperty,U0=RegExp("^"+F0.call(k0).replace(R0,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function H0(n){if(!Xt(n)||Mu(n))return!1;var r=xa(n)?U0:V0;return r.test(Zr(n))}var Eu=H0;function q0(n,r){return n?.[r]}var Lu=q0;function W0(n,r){var e=Lu(n,r);return Eu(e)?e:void 0}var Rt=W0;var $0=Rt(it,"WeakMap"),ba=$0;var Bu=Object.create,Y0=function(){function n(){}return function(r){if(!Xt(r))return{};if(Bu)return Bu(r);n.prototype=r;var e=new n;return n.prototype=void 0,e}}(),Du=Y0;function X0(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 Gu=X0;function K0(n,r){var e=-1,t=n.length;for(r||(r=Array(t));++e<t;)r[e]=n[e];return r}var Ru=K0;var Z0=800,Q0=16,J0=Date.now;function ex(n){var r=0,e=0;return function(){var t=J0(),o=Q0-(t-e);if(e=t,o>0){if(++r>=Z0)return arguments[0]}else r=0;return n.apply(void 0,arguments)}}var Vu=ex;function tx(n){return function(){return n}}var zu=tx;var rx=function(){try{var n=Rt(Object,"defineProperty");return n({},"",{}),n}catch{}}(),pn=rx;var ox=pn?function(n,r){return pn(n,"toString",{configurable:!0,enumerable:!1,value:zu(r),writable:!0})}:Cu,ju=ox;var nx=Vu(ju),Fu=nx;function ix(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}var ku=ix;var sx=9007199254740991,ax=/^(?:0|[1-9]\d*)$/;function lx(n,r){var e=typeof n;return r=r??sx,!!r&&(e=="number"||e!="symbol"&&ax.test(n))&&n>-1&&n%1==0&&n<r}var fn=lx;function cx(n,r,e){r=="__proto__"&&pn?pn(n,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[r]=e}var Sa=cx;function dx(n,r){return n===r||n!==n&&r!==r}var mn=dx;var ux=Object.prototype,px=ux.hasOwnProperty;function fx(n,r,e){var t=n[r];(!(px.call(n,r)&&mn(t,e))||e===void 0&&!(r in n))&&Sa(n,r,e)}var hn=fx;function mx(n,r,e,t){var o=!e;e||(e={});for(var i=-1,s=r.length;++i<s;){var l=r[i],c=t?t(e[l],n[l],l,e,n):void 0;c===void 0&&(c=n[l]),o?Sa(e,l,c):hn(e,l,c)}return e}var Cr=mx;var Uu=Math.max;function hx(n,r,e){return r=Uu(r===void 0?n.length-1:r,0),function(){for(var t=arguments,o=-1,i=Uu(t.length-r,0),s=Array(i);++o<i;)s[o]=t[r+o];o=-1;for(var l=Array(r+1);++o<r;)l[o]=t[o];return l[r]=e(s),Gu(n,this,l)}}var Hu=hx;var yx=9007199254740991;function gx(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=yx}var yn=gx;function xx(n){return n!=null&&yn(n.length)&&!xa(n)}var wa=xx;var vx=Object.prototype;function bx(n){var r=n&&n.constructor,e=typeof r=="function"&&r.prototype||vx;return n===e}var gn=bx;function Sx(n,r){for(var e=-1,t=Array(n);++e<n;)t[e]=r(e);return t}var qu=Sx;var wx="[object Arguments]";function _x(n){return bt(n)&&Yt(n)==wx}var xc=_x;var Wu=Object.prototype,Px=Wu.hasOwnProperty,Tx=Wu.propertyIsEnumerable,Ox=xc(function(){return arguments}())?xc:function(n){return bt(n)&&Px.call(n,"callee")&&!Tx.call(n,"callee")},xn=Ox;function Ax(){return!1}var $u=Ax;var Ku=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Yu=Ku&&typeof module=="object"&&module&&!module.nodeType&&module,Nx=Yu&&Yu.exports===Ku,Xu=Nx?it.Buffer:void 0,Cx=Xu?Xu.isBuffer:void 0,Ix=Cx||$u,Do=Ix;var Mx="[object Arguments]",Ex="[object Array]",Lx="[object Boolean]",Bx="[object Date]",Dx="[object Error]",Gx="[object Function]",Rx="[object Map]",Vx="[object Number]",zx="[object Object]",jx="[object RegExp]",Fx="[object Set]",kx="[object String]",Ux="[object WeakMap]",Hx="[object ArrayBuffer]",qx="[object DataView]",Wx="[object Float32Array]",$x="[object Float64Array]",Yx="[object Int8Array]",Xx="[object Int16Array]",Kx="[object Int32Array]",Zx="[object Uint8Array]",Qx="[object Uint8ClampedArray]",Jx="[object Uint16Array]",ev="[object Uint32Array]",Ue={};Ue[Wx]=Ue[$x]=Ue[Yx]=Ue[Xx]=Ue[Kx]=Ue[Zx]=Ue[Qx]=Ue[Jx]=Ue[ev]=!0;Ue[Mx]=Ue[Ex]=Ue[Hx]=Ue[Lx]=Ue[qx]=Ue[Bx]=Ue[Dx]=Ue[Gx]=Ue[Rx]=Ue[Vx]=Ue[zx]=Ue[jx]=Ue[Fx]=Ue[kx]=Ue[Ux]=!1;function tv(n){return bt(n)&&yn(n.length)&&!!Ue[Yt(n)]}var Zu=tv;function rv(n){return function(r){return n(r)}}var vn=rv;var Qu=typeof exports=="object"&&exports&&!exports.nodeType&&exports,is=Qu&&typeof module=="object"&&module&&!module.nodeType&&module,ov=is&&is.exports===Qu,vc=ov&&ya.process,nv=function(){try{var n=is&&is.require&&is.require("util").types;return n||vc&&vc.binding&&vc.binding("util")}catch{}}(),Qr=nv;var Ju=Qr&&Qr.isTypedArray,iv=Ju?vn(Ju):Zu,_a=iv;var sv=Object.prototype,av=sv.hasOwnProperty;function lv(n,r){var e=Xe(n),t=!e&&xn(n),o=!e&&!t&&Do(n),i=!e&&!t&&!o&&_a(n),s=e||t||o||i,l=s?qu(n.length,String):[],c=l.length;for(var u in n)(r||av.call(n,u))&&!(s&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||fn(u,c)))&&l.push(u);return l}var Pa=lv;function cv(n,r){return function(e){return n(r(e))}}var Ta=cv;var dv=Ta(Object.keys,Object),ep=dv;var uv=Object.prototype,pv=uv.hasOwnProperty;function fv(n){if(!gn(n))return ep(n);var r=[];for(var e in Object(n))pv.call(n,e)&&e!="constructor"&&r.push(e);return r}var tp=fv;function mv(n){return wa(n)?Pa(n):tp(n)}var bn=mv;function hv(n){var r=[];if(n!=null)for(var e in Object(n))r.push(e);return r}var rp=hv;var yv=Object.prototype,gv=yv.hasOwnProperty;function xv(n){if(!Xt(n))return rp(n);var r=gn(n),e=[];for(var t in n)t=="constructor"&&(r||!gv.call(n,t))||e.push(t);return e}var op=xv;function vv(n){return wa(n)?Pa(n,!0):op(n)}var Sn=vv;var bv=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Sv=/^\w*$/;function wv(n,r){if(Xe(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||un(n)?!0:Sv.test(n)||!bv.test(n)||r!=null&&n in Object(r)}var np=wv;var _v=Rt(Object,"create"),Jr=_v;function Pv(){this.__data__=Jr?Jr(null):{},this.size=0}var ip=Pv;function Tv(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}var sp=Tv;var Ov="__lodash_hash_undefined__",Av=Object.prototype,Nv=Av.hasOwnProperty;function Cv(n){var r=this.__data__;if(Jr){var e=r[n];return e===Ov?void 0:e}return Nv.call(r,n)?r[n]:void 0}var ap=Cv;var Iv=Object.prototype,Mv=Iv.hasOwnProperty;function Ev(n){var r=this.__data__;return Jr?r[n]!==void 0:Mv.call(r,n)}var lp=Ev;var Lv="__lodash_hash_undefined__";function Bv(n,r){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Jr&&r===void 0?Lv:r,this}var cp=Bv;function wn(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])}}wn.prototype.clear=ip;wn.prototype.delete=sp;wn.prototype.get=ap;wn.prototype.has=lp;wn.prototype.set=cp;var bc=wn;function Dv(){this.__data__=[],this.size=0}var dp=Dv;function Gv(n,r){for(var e=n.length;e--;)if(mn(n[e][0],r))return e;return-1}var uo=Gv;var Rv=Array.prototype,Vv=Rv.splice;function zv(n){var r=this.__data__,e=uo(r,n);if(e<0)return!1;var t=r.length-1;return e==t?r.pop():Vv.call(r,e,1),--this.size,!0}var up=zv;function jv(n){var r=this.__data__,e=uo(r,n);return e<0?void 0:r[e][1]}var pp=jv;function Fv(n){return uo(this.__data__,n)>-1}var fp=Fv;function kv(n,r){var e=this.__data__,t=uo(e,n);return t<0?(++this.size,e.push([n,r])):e[t][1]=r,this}var mp=kv;function _n(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])}}_n.prototype.clear=dp;_n.prototype.delete=up;_n.prototype.get=pp;_n.prototype.has=fp;_n.prototype.set=mp;var po=_n;var Uv=Rt(it,"Map"),fo=Uv;function Hv(){this.size=0,this.__data__={hash:new bc,map:new(fo||po),string:new bc}}var hp=Hv;function qv(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}var yp=qv;function Wv(n,r){var e=n.__data__;return yp(r)?e[typeof r=="string"?"string":"hash"]:e.map}var mo=Wv;function $v(n){var r=mo(this,n).delete(n);return this.size-=r?1:0,r}var gp=$v;function Yv(n){return mo(this,n).get(n)}var xp=Yv;function Xv(n){return mo(this,n).has(n)}var vp=Xv;function Kv(n,r){var e=mo(this,n),t=e.size;return e.set(n,r),this.size+=e.size==t?0:1,this}var bp=Kv;function Pn(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])}}Pn.prototype.clear=hp;Pn.prototype.delete=gp;Pn.prototype.get=xp;Pn.prototype.has=vp;Pn.prototype.set=bp;var Go=Pn;var Zv="Expected a function";function Sc(n,r){if(typeof n!="function"||r!=null&&typeof r!="function")throw new TypeError(Zv);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(Sc.Cache||Go),e}Sc.Cache=Go;var Sp=Sc;var Qv=500;function Jv(n){var r=Sp(n,function(t){return e.size===Qv&&e.clear(),t}),e=r.cache;return r}var wp=Jv;var eb=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tb=/\\(\\)?/g,rb=wp(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(eb,function(e,t,o,i){r.push(o?i.replace(tb,"$1"):t||e)}),r}),_p=rb;function ob(n){return n==null?"":Nu(n)}var Pp=ob;function nb(n,r){return Xe(n)?n:np(n,r)?[n]:_p(Pp(n))}var rr=nb;var ib=1/0;function sb(n){if(typeof n=="string"||un(n))return n;var r=n+"";return r=="0"&&1/n==-ib?"-0":r}var ho=sb;function ab(n,r){r=rr(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[ho(r[e++])];return e&&e==t?n:void 0}var Oa=ab;function lb(n,r){for(var e=-1,t=r.length,o=n.length;++e<t;)n[o+e]=r[e];return n}var Tn=lb;var Tp=ut?ut.isConcatSpreadable:void 0;function cb(n){return Xe(n)||xn(n)||!!(Tp&&n&&n[Tp])}var Op=cb;function Ap(n,r,e,t,o){var i=-1,s=n.length;for(e||(e=Op),o||(o=[]);++i<s;){var l=n[i];r>0&&e(l)?r>1?Ap(l,r-1,e,t,o):Tn(o,l):t||(o[o.length]=l)}return o}var Np=Ap;function db(n){var r=n==null?0:n.length;return r?Np(n,1):[]}var Cp=db;function ub(n){return Fu(Hu(n,void 0,Cp),n+"")}var Aa=ub;var pb=Ta(Object.getPrototypeOf,Object),On=pb;var fb="[object Object]",mb=Function.prototype,hb=Object.prototype,Ip=mb.toString,yb=hb.hasOwnProperty,gb=Ip.call(Object);function xb(n){if(!bt(n)||Yt(n)!=fb)return!1;var r=On(n);if(r===null)return!0;var e=yb.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Ip.call(e)==gb}var Mp=xb;function vb(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 Ep=vb;function bb(){this.__data__=new po,this.size=0}var Lp=bb;function Sb(n){var r=this.__data__,e=r.delete(n);return this.size=r.size,e}var Bp=Sb;function wb(n){return this.__data__.get(n)}var Dp=wb;function _b(n){return this.__data__.has(n)}var Gp=_b;var Pb=200;function Tb(n,r){var e=this.__data__;if(e instanceof po){var t=e.__data__;if(!fo||t.length<Pb-1)return t.push([n,r]),this.size=++e.size,this;e=this.__data__=new Go(t)}return e.set(n,r),this.size=e.size,this}var Rp=Tb;function An(n){var r=this.__data__=new po(n);this.size=r.size}An.prototype.clear=Lp;An.prototype.delete=Bp;An.prototype.get=Dp;An.prototype.has=Gp;An.prototype.set=Rp;var Nn=An;function Ob(n,r){return n&&Cr(r,bn(r),n)}var Vp=Ob;function Ab(n,r){return n&&Cr(r,Sn(r),n)}var zp=Ab;var Up=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jp=Up&&typeof module=="object"&&module&&!module.nodeType&&module,Nb=jp&&jp.exports===Up,Fp=Nb?it.Buffer:void 0,kp=Fp?Fp.allocUnsafe:void 0;function Cb(n,r){if(r)return n.slice();var e=n.length,t=kp?kp(e):new n.constructor(e);return n.copy(t),t}var Hp=Cb;function Ib(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 qp=Ib;function Mb(){return[]}var Na=Mb;var Eb=Object.prototype,Lb=Eb.propertyIsEnumerable,Wp=Object.getOwnPropertySymbols,Bb=Wp?function(n){return n==null?[]:(n=Object(n),qp(Wp(n),function(r){return Lb.call(n,r)}))}:Na,Cn=Bb;function Db(n,r){return Cr(n,Cn(n),r)}var $p=Db;var Gb=Object.getOwnPropertySymbols,Rb=Gb?function(n){for(var r=[];n;)Tn(r,Cn(n)),n=On(n);return r}:Na,Ca=Rb;function Vb(n,r){return Cr(n,Ca(n),r)}var Yp=Vb;function zb(n,r,e){var t=r(n);return Xe(n)?t:Tn(t,e(n))}var Ia=zb;function jb(n){return Ia(n,bn,Cn)}var ss=jb;function Fb(n){return Ia(n,Sn,Ca)}var Ma=Fb;var kb=Rt(it,"DataView"),Ea=kb;var Ub=Rt(it,"Promise"),La=Ub;var Hb=Rt(it,"Set"),Ba=Hb;var Xp="[object Map]",qb="[object Object]",Kp="[object Promise]",Zp="[object Set]",Qp="[object WeakMap]",Jp="[object DataView]",Wb=Zr(Ea),$b=Zr(fo),Yb=Zr(La),Xb=Zr(Ba),Kb=Zr(ba),Ro=Yt;(Ea&&Ro(new Ea(new ArrayBuffer(1)))!=Jp||fo&&Ro(new fo)!=Xp||La&&Ro(La.resolve())!=Kp||Ba&&Ro(new Ba)!=Zp||ba&&Ro(new ba)!=Qp)&&(Ro=function(n){var r=Yt(n),e=r==qb?n.constructor:void 0,t=e?Zr(e):"";if(t)switch(t){case Wb:return Jp;case $b:return Xp;case Yb:return Kp;case Xb:return Zp;case Kb:return Qp}return r});var eo=Ro;var Zb=Object.prototype,Qb=Zb.hasOwnProperty;function Jb(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&Qb.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var ef=Jb;var e1=it.Uint8Array,In=e1;function t1(n){var r=new n.constructor(n.byteLength);return new In(r).set(new In(n)),r}var Mn=t1;function r1(n,r){var e=r?Mn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var tf=r1;var o1=/\w*$/;function n1(n){var r=new n.constructor(n.source,o1.exec(n));return r.lastIndex=n.lastIndex,r}var rf=n1;var of=ut?ut.prototype:void 0,nf=of?of.valueOf:void 0;function i1(n){return nf?Object(nf.call(n)):{}}var sf=i1;function s1(n,r){var e=r?Mn(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var af=s1;var a1="[object Boolean]",l1="[object Date]",c1="[object Map]",d1="[object Number]",u1="[object RegExp]",p1="[object Set]",f1="[object String]",m1="[object Symbol]",h1="[object ArrayBuffer]",y1="[object DataView]",g1="[object Float32Array]",x1="[object Float64Array]",v1="[object Int8Array]",b1="[object Int16Array]",S1="[object Int32Array]",w1="[object Uint8Array]",_1="[object Uint8ClampedArray]",P1="[object Uint16Array]",T1="[object Uint32Array]";function O1(n,r,e){var t=n.constructor;switch(r){case h1:return Mn(n);case a1:case l1:return new t(+n);case y1:return tf(n,e);case g1:case x1:case v1:case b1:case S1:case w1:case _1:case P1:case T1:return af(n,e);case c1:return new t;case d1:case f1:return new t(n);case u1:return rf(n);case p1:return new t;case m1:return sf(n)}}var lf=O1;function A1(n){return typeof n.constructor=="function"&&!gn(n)?Du(On(n)):{}}var cf=A1;var N1="[object Map]";function C1(n){return bt(n)&&eo(n)==N1}var df=C1;var uf=Qr&&Qr.isMap,I1=uf?vn(uf):df,pf=I1;var M1="[object Set]";function E1(n){return bt(n)&&eo(n)==M1}var ff=E1;var mf=Qr&&Qr.isSet,L1=mf?vn(mf):ff,hf=L1;var B1=1,D1=2,G1=4,yf="[object Arguments]",R1="[object Array]",V1="[object Boolean]",z1="[object Date]",j1="[object Error]",gf="[object Function]",F1="[object GeneratorFunction]",k1="[object Map]",U1="[object Number]",xf="[object Object]",H1="[object RegExp]",q1="[object Set]",W1="[object String]",$1="[object Symbol]",Y1="[object WeakMap]",X1="[object ArrayBuffer]",K1="[object DataView]",Z1="[object Float32Array]",Q1="[object Float64Array]",J1="[object Int8Array]",eS="[object Int16Array]",tS="[object Int32Array]",rS="[object Uint8Array]",oS="[object Uint8ClampedArray]",nS="[object Uint16Array]",iS="[object Uint32Array]",je={};je[yf]=je[R1]=je[X1]=je[K1]=je[V1]=je[z1]=je[Z1]=je[Q1]=je[J1]=je[eS]=je[tS]=je[k1]=je[U1]=je[xf]=je[H1]=je[q1]=je[W1]=je[$1]=je[rS]=je[oS]=je[nS]=je[iS]=!0;je[j1]=je[gf]=je[Y1]=!1;function Da(n,r,e,t,o,i){var s,l=r&B1,c=r&D1,u=r&G1;if(e&&(s=o?e(n,t,o,i):e(n)),s!==void 0)return s;if(!Xt(n))return n;var a=Xe(n);if(a){if(s=ef(n),!l)return Ru(n,s)}else{var d=eo(n),p=d==gf||d==F1;if(Do(n))return Hp(n,l);if(d==xf||d==yf||p&&!o){if(s=c||p?{}:cf(n),!l)return c?Yp(n,zp(s,n)):$p(n,Vp(s,n))}else{if(!je[d])return o?n:{};s=lf(n,d,l)}}i||(i=new Nn);var f=i.get(n);if(f)return f;i.set(n,s),hf(n)?n.forEach(function(y){s.add(Da(y,r,e,y,n,i))}):pf(n)&&n.forEach(function(y,g){s.set(g,Da(y,r,e,g,n,i))});var m=u?c?Ma:ss:c?Sn:bn,h=a?void 0:m(n);return ku(h||n,function(y,g){h&&(g=y,y=n[g]),hn(s,g,Da(y,r,e,g,n,i))}),s}var Ga=Da;var sS=1,aS=4;function lS(n){return Ga(n,sS|aS)}var to=lS;var cS="__lodash_hash_undefined__";function dS(n){return this.__data__.set(n,cS),this}var vf=dS;function uS(n){return this.__data__.has(n)}var bf=uS;function Ra(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Go;++r<e;)this.add(n[r])}Ra.prototype.add=Ra.prototype.push=vf;Ra.prototype.has=bf;var Sf=Ra;function pS(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 wf=pS;function fS(n,r){return n.has(r)}var _f=fS;var mS=1,hS=2;function yS(n,r,e,t,o,i){var s=e&mS,l=n.length,c=r.length;if(l!=c&&!(s&&c>l))return!1;var u=i.get(n),a=i.get(r);if(u&&a)return u==r&&a==n;var d=-1,p=!0,f=e&hS?new Sf:void 0;for(i.set(n,r),i.set(r,n);++d<l;){var m=n[d],h=r[d];if(t)var y=s?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(!wf(r,function(g,v){if(!_f(f,v)&&(m===g||o(m,g,e,t,i)))return f.push(v)})){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 Va=yS;function gS(n){var r=-1,e=Array(n.size);return n.forEach(function(t,o){e[++r]=[o,t]}),e}var Pf=gS;function xS(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Tf=xS;var vS=1,bS=2,SS="[object Boolean]",wS="[object Date]",_S="[object Error]",PS="[object Map]",TS="[object Number]",OS="[object RegExp]",AS="[object Set]",NS="[object String]",CS="[object Symbol]",IS="[object ArrayBuffer]",MS="[object DataView]",Of=ut?ut.prototype:void 0,wc=Of?Of.valueOf:void 0;function ES(n,r,e,t,o,i,s){switch(e){case MS:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case IS:return!(n.byteLength!=r.byteLength||!i(new In(n),new In(r)));case SS:case wS:case TS:return mn(+n,+r);case _S:return n.name==r.name&&n.message==r.message;case OS:case NS:return n==r+"";case PS:var l=Pf;case AS:var c=t&vS;if(l||(l=Tf),n.size!=r.size&&!c)return!1;var u=s.get(n);if(u)return u==r;t|=bS,s.set(n,r);var a=Va(l(n),l(r),t,o,i,s);return s.delete(n),a;case CS:if(wc)return wc.call(n)==wc.call(r)}return!1}var Af=ES;var LS=1,BS=Object.prototype,DS=BS.hasOwnProperty;function GS(n,r,e,t,o,i){var s=e&LS,l=ss(n),c=l.length,u=ss(r),a=u.length;if(c!=a&&!s)return!1;for(var d=c;d--;){var p=l[d];if(!(s?p in r:DS.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;++d<c;){p=l[d];var g=n[p],v=r[p];if(t)var b=s?t(v,g,p,r,n,i):t(g,v,p,n,r,i);if(!(b===void 0?g===v||o(g,v,e,t,i):b)){h=!1;break}y||(y=p=="constructor")}if(h&&!y){var w=n.constructor,S=r.constructor;w!=S&&"constructor"in n&&"constructor"in r&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(h=!1)}return i.delete(n),i.delete(r),h}var Nf=GS;var RS=1,Cf="[object Arguments]",If="[object Array]",za="[object Object]",VS=Object.prototype,Mf=VS.hasOwnProperty;function zS(n,r,e,t,o,i){var s=Xe(n),l=Xe(r),c=s?If:eo(n),u=l?If:eo(r);c=c==Cf?za:c,u=u==Cf?za:u;var a=c==za,d=u==za,p=c==u;if(p&&Do(n)){if(!Do(r))return!1;s=!0,a=!1}if(p&&!a)return i||(i=new Nn),s||_a(n)?Va(n,r,e,t,o,i):Af(n,r,c,e,t,o,i);if(!(e&RS)){var f=a&&Mf.call(n,"__wrapped__"),m=d&&Mf.call(r,"__wrapped__");if(f||m){var h=f?n.value():n,y=m?r.value():r;return i||(i=new Nn),o(h,y,e,t,i)}}return p?(i||(i=new Nn),Nf(n,r,e,t,o,i)):!1}var Ef=zS;function Lf(n,r,e,t,o){return n===r?!0:n==null||r==null||!bt(n)&&!bt(r)?n!==n&&r!==r:Ef(n,r,e,t,Lf,o)}var Bf=Lf;function jS(n,r){return n!=null&&r in Object(n)}var Df=jS;function FS(n,r,e){r=rr(r,n);for(var t=-1,o=r.length,i=!1;++t<o;){var s=ho(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&&yn(o)&&fn(s,o)&&(Xe(n)||xn(n)))}var Gf=FS;function kS(n,r){return n!=null&&Gf(n,r,Df)}var Rf=kS;function US(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}var Vf=US;function HS(n,r){return r.length<2?n:Oa(n,Ep(r,0,-1))}var zf=HS;function qS(n,r){return Bf(n,r)}var as=qS;function WS(n,r){return r=rr(r,n),n=zf(n,r),n==null||delete n[ho(Vf(r))]}var jf=WS;function $S(n){return Mp(n)?void 0:n}var Ff=$S;var YS=1,XS=2,KS=4,ZS=Aa(function(n,r){var e={};if(n==null)return e;var t=!1;r=ga(r,function(i){return i=rr(i,n),t||(t=i.length>1),i}),Cr(n,Ma(n),e),t&&(e=Ga(e,YS|XS|KS,Ff));for(var o=r.length;o--;)jf(e,r[o]);return e}),En=ZS;function QS(n,r,e,t){if(!Xt(n))return n;r=rr(r,n);for(var o=-1,i=r.length,s=i-1,l=n;l!=null&&++o<i;){var c=ho(r[o]),u=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(o!=s){var a=l[c];u=t?t(a,c,l):void 0,u===void 0&&(u=Xt(a)?a:fn(r[o+1])?[]:{})}hn(l,c,u),l=l[c]}return n}var kf=QS;function JS(n,r,e){for(var t=-1,o=r.length,i={};++t<o;){var s=r[t],l=Oa(n,s);e(l,s)&&kf(i,rr(s,n),l)}return i}var Uf=JS;function ew(n,r){return Uf(n,r,function(e,t){return Rf(n,t)})}var Hf=ew;var tw=Aa(function(n,r){return n==null?{}:Hf(n,r)}),Ln=tw;var ze=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,ze.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,l={...e,[i]:s};return Object.setPrototypeOf(l,ze.prototype),{data:l,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,ze.prototype),delete i[t],{data:i,actual:r,reverse:{type:1,id:t,data:o}}}}return null}};function ls(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"&&ls(t)}return Object.freeze(n)}function qf(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 Bn=class extends Error{};function ja(n){let r={...n};return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Ir(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 Dn(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 Wf(){return typeof process<"u"}function $f(n,r){for(let e of n)r(e.id,e.data)!==!0&&$f(e.children,r)}function Yf(n,r){if(r(n.id,n.data)!==!0)for(let e of n.children)Yf(e,r)}var st=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,st.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ls(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}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&&Yf(o,t)}}traverse(e){$f(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),l=s.findIndex(a=>a.id===e);if(l<0)throw new Error("not expected");let c=s[l];return s=[...s],s[l]={...c,data:t},this.modifyArrayBy(i,s)}}modifyArrayBy(e,t){let o=e,i=t;for(;o!==null;){let l=i,c=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(a=>a.id===c);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:l}}Object.setPrototypeOf(i,st.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:l}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let c=t,u=this.childrenArray(c),a={fi:o,id:i,data:s,children:l};return u=[...u,a],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(a),{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),s=i.findIndex(u=>u.id===t);e.localIndex=s,i=[...i];let l=i.splice(s,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...l,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 Bn("cyclic tree");f=this.parent(f)}}let s=this.parent(i);if(s===void 0)return null;let l=s,c=this.childrenArray(s),u=c.findIndex(f=>f.id===i);c=[...c];let a=c.splice(u,1)[0],d=this.modifyArrayBy(s,c);s=t,c=d.childrenArray(s);let p=a.fi;return a={...a,fi:o},c=[...c,a],c.sort((f,m)=>f.fi-m.fi),e.localIndex=c.indexOf(a),d=d.modifyArrayBy(s,c),{data:d,actual:e,reverse:{type:9,parent:l,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)=>qf(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 Ir(0,o,o);{let s=i[0].fi;return Ir(s-o,s,o)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let l=i.find(c=>c.fi>s.fi);if(l===void 0){let c=i[i.length-1].fi;return Ir(c,c+o,o)}else return Ir(s.fi,l.fi,o)}}};var Gn;(r=>{function n(e,t){if(t.type!==0)return null;if(Array.isArray(e)){let o=t.props,i={},s=[...e],l=!1;if(o)for(let c of Object.keys(o)){let u=parseInt(c);if(isNaN(u))throw new Error("wrong index");i[c]=s[u],s[u]=o[c],l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}else{let o=t.props,i={},s={...e},l=!1;if(o)for(let c of Object.keys(o)){i[c]=s[c];let u=o[c];u===void 0?delete s[c]:s[c]=u,l=!0}return l?{data:s,actual:t,reverse:{type:0,props:i}}:null}}r.runOp=n})(Gn||(Gn={}));var ye=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ye.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ls(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(u=>u.id===e);if(s<0)throw new Error("not expected");let l=i[s];return i=[...i],i[s]={...l,data:t},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,ye.prototype);let t=e;return Wf()||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,l={fi:t,id:o,data:i};return s=[...s,l],s.sort((u,a)=>u.fi-a.fi),e.localIndex=s.indexOf(l),{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(a=>a.id===o);if(s===-1)return null;let l=i[s].fi,c={...i[s],fi:t};return i[s]=c,i.sort((a,d)=>a.fi-d.fi),e.localIndex=i.indexOf(c),{data:this.modifyArrayBy(i),actual:e,reverse:{type:6,fi:l,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 Ir(0,t,t);{let i=o[0].fi;return Ir(i-t,i,t)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let s=o.find(l=>l.fi>i.fi);if(s===void 0){let l=o[o.length-1].fi;return Ir(l,l+t,t)}else return Ir(i.fi,s.fi,t)}}};function Rn(n){return n&&typeof n=="object"&&n instanceof qe}var qe=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&&!Rn(t))return null;o+=1}t=t?ja(t):new qe;for(let[c,u]of Object.entries(r.props)){let a=t[c];i[c]=a,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=ja(c),delete t[r.path[o-1]])}else{let c=e[o-1];if(c){let u=ja(c);u[r.path[o-1]]=t,t=u}else{let u=new qe;u[r.path[o-1]]=t,t=u}}o-=1}let s=Object.setPrototypeOf(t,qe.prototype),l={...r,props:i};return{data:s,actual:r,reverse:l}}},ro;(t=>{function n(o,i){return cs(o,i)??o}t.apply=n;function r(o,i){return Pc(o,i)}t.merge=r;function e(o,i){let s=0,l=i.path,c=o;for(;s<l.length&&c!==void 0;){if(c=Ct.zoomOnce(c,l[s]),c===void 0)return i;if(!Rn(c))return;s+=1}if(c===void 0)return i;if(!!Rn(c))if(i.type===0){let u={...i.props};for(let a of Object.keys(c))delete u[a];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=_c([i],c);return u?(console.log(u),u):i}else return i}t.filterOp=e})(ro||(ro={}));function _c(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=cs(o.data,r[i]);if(e=e||s!==void 0,s===void 0&&(s=o.data),o.children){let l=_c(o.children,r);return l!==void 0?e=!0:l=o.children,{...o,id:i,data:s,children:l}}else return{...o,id:i,data:s}});if(e)return t}function rw(n,r){if(r===void 0)return;let e=!1,t=n.map(o=>{let i=o.id,s=cs(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 cs(n,r){if(!Rn(r))return r;if(n instanceof st){let e=_c(n,r);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof ye)return rw(n,r);if(Array.isArray(n)){let e=!1,t=n.map((o,i)=>{let s=cs(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 qe)return Pc(n,r);if(n&&typeof n=="object"){let e={},t=!1;for(let[o,i]of Object.entries(n)){let s=cs(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 Pc(n,r){if(n===void 0)return r;if(r===void 0)return n;if(!Rn(r))return r;if(!Rn(n))return ro.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 qe;for(let o of e){let i=Pc(n===void 0?void 0:n[o],r===void 0?void 0:r[o]);t[o]=i}return t}function Xf(n,r){let e={cur:[],result:[],len:0};return n=ds(n,r,e)??n,[n,e.result]}function Fa(n,r){return n===null?null:(n.cur[n.len]=r,n.len+=1,n)}function ka(n){n&&(n.len-=1)}function ow(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Kf(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=ds(i.data,r,Fa(e,s));ka(e),t=t||c!==void 0,c===void 0&&(c=i.data);let u=Kf(i.children,r,e);return u!==void 0?t=!0:u=i.children,{...i,id:s,data:c,children:u}});if(t)return o}function nw(n,r,e){let t=!1,o=n.map(i=>{let s=i.id,l=r[s];if(l!==void 0&&typeof l=="string"&&(t=!0,s=l,e!==null))throw new Error("not supported");let c=ds(i.data,r,Fa(e,s));return ka(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 ds(n,r,e){if(n instanceof st){let t=Kf(n,r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else{if(n instanceof ye)return nw(n,r,e);if(Array.isArray(n)){let t=!1,o=n.map((i,s)=>{let l=ds(i,r,Fa(e,s));return ka(e),t=t||l!==void 0,l===void 0&&(l=i),l});return t?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!Dn(n)){let t={},o=!1;for(let[i,s]of Object.entries(n))if(i!=="name"&&i!=="text"){let l=r[i];if(typeof l=="string"){if(e!==null)throw new Error("not supported");o=!0,i=l}let c=ds(s,r,Fa(e,i));ka(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");ow(e)}return t}else return}}var Ua;(r=>{function n(e,t){let o=Ct.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})(Ua||(Ua={}));var St;(l=>{function n(c,u){return{...c,path:c.path.slice(u)}}l.drop=n;function r(c,u){return e(c,u)?.data??c}l.applySimple=r;function e(c,u){let a=u.path;for(var d=[];;){let p;if(c instanceof qe&&u.type===0&&(p=c.runOp({...u,path:a.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===a.length&&(c instanceof st||c instanceof ye||c instanceof ze?p=c.runOp(u):p=Gn.runOp(c,u)),p!==void 0)if(p!==null){let h=p.data;for(let y=d.length-1;y>=0;y--){let g=a[y],v=d[y];if(v instanceof st){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof ye){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof ze){if(typeof g=="number")throw new Error("illegal arg");h=v.modifyById(g,h)}else if(v instanceof qe){let b={...v,[g]:h};h=Object.setPrototypeOf(b,qe.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let b=h;h=[...v],h[g]=b}else h={...v,[g]:h};else return null}return{data:h,actual:{...p.actual,path:a},reverse:{...p.reverse,path:a}}}else return null;let f=a[d.length],m;if(c instanceof st){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)d.push(c),c=m;else return null}}l.apply=e;function t(c,u){for(let a=0;a<c.length&&a<u.length;a++)if(c[a]!==u[a])return!0;return!1}l.pathDisjoint=t;function o(c,u){if(c.length!==u.length)return!1;for(let a=0;a<c.length;a++)if(c[a]!==u[a])return!1;return!0}l.pathEq=o;function i(c,u){return t(c.path,u.path)}l.commutative=i;function s(c,u){return c.type===0&&u.type===0&&o(c.path,u.path)?Object.keys(c.props).every(a=>u.props[a]!==void 0):!1}l.subsumed=s})(St||(St={}));var Tc;(c=>{function n(){return[]}c.empty=n;function r(u,a){let d=[];for(let p of u){let[f,...m]=p.path;f===a&&d.push({...p,path:m})}return d}c.removePrefix=r;function e(u,a){return u.map(d=>({...d,path:[a,...d.path]}))}c.addPrefix=e;function t(u,a){return[...u,...a]}c.concat=t;function o(u,a){return[...u.filter(p=>!a.some(f=>St.subsumed(p,f))),...a]}c.compress=o;function i(u,a){return u.every(d=>a.every(p=>St.commutative(d,p)))}c.commutative=i;function s(u,a){for(let d of a){let p=l(u,d);p!==null&&(u=p.data)}return u}c.applyAll=s;function l(u,a){var d=u;let p=[],f=[];for(let m of a)try{if(m.type===3){let h=Ct.zoom(d,[...m.path,m.id]),y=St.apply(d,{...m,type:2});if(y!==null){d=y.data;let[g,v]=Xf(d,{[m.id]:h});d=g;for(let b of v){let w=b[b.length-1];b.splice(b.length-1,1),p.push({type:0,path:b,props:{[w]:h}}),f.push({type:0,path:b,props:{[w]:m.id}})}f.push(y.reverse),p.push(y.actual)}}else{let h=St.apply(d,m);h!==null&&(p.push(h.actual),d=h.data,f.push(h.reverse))}}catch(h){if(h instanceof Bn)return null;throw h}return{data:d,actual:p,reverse:f.reverse()}}c.apply=l})(Tc||(Tc={}));var Zf=Symbol(),iw=Symbol(),qa=Symbol(),Vo=class{reportOp(r,e,t=[]){let o=this;if(e===null)return;o._current=e.data;let i=t;for(;!(o instanceof Ha);){let s=o._path,l=o._current;if(s!==""&&i.splice(0,0,s),o=o._parent,o===null)return;o.update(s,l)}o.push(i,r,e.actual,e.reverse)}deleteChildren(r){if(this._children){let e=this._children[r];if(e){let t=e[qa];t&&t(),delete this._children[r]}}}},Ac=class extends Vo{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,Gn.runOp(this._current,r),r.path)}},Nc=class extends Vo{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,ze.prototype)}runOp(r){this.reportOp(r,this._current.runOp(r))}},Qf={get(n,r){if(r===qa)return()=>{n._parent=null};if(r===Zf)return n._current;if(r===iw)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=Wa(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]}}},sw={...Qf,set(n,r,e){let t={type:0,props:{[r]:pt(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}},aw={...Qf,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}},Vn=class extends Vo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[qa]=()=>{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=Wa(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)}},zn=class extends Vo{constructor(r,e,t){super(),this._children={},this._parent=r,this._path=e,this._current=t,this[qa]=()=>{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=Wa(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 Oc(n,r,e){if(n.length>0){let t=n[n.length-1];if(t.type===0&&r.type===0&&Ct.equal(t.path,e)){Object.assign(t.props,r.props);return}}n.push({...r,path:e})}var Ha=class extends Vo{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){Oc(this.ts,e,r),Oc(this.actual,t,r),Oc(this.reverse,o,r)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Wa(n,r,e){return e instanceof st?new Vn(n,r,e):e instanceof ye?new zn(n,r,e):e instanceof ze?new Proxy(new Nc(n,r,e),aw):e!==null&&typeof e=="object"?Dn(e)?e:new Proxy(new Ac(n,r,e),sw):e}function Cc(n){let r=new Ha(n);return[Wa(r,"",n),r]}function jn(n,r){let[e,t]=Cc(n);return r(e),t.result()}function pt(n){return n instanceof Vn||n instanceof zn?n._current:n!==null&&typeof n=="object"?n[Zf]:n}var Ct;(o=>{function n(i,s){if(s.length===i.length)for(var l=0;l<i.length;){if(i[l]!==s[l])return!1;l+=1}else return!1;return!0}o.equal=n;function r(i,s,l){let c=t(l,i);if(c!==void 0&&typeof c=="object"&&c!==null){let u={...s};return Object.keys(c).forEach(a=>{delete u[a]}),u}else return s}o.removeOverridden=r;function e(i,s){if((i instanceof st||i instanceof Vn)&&typeof s=="string")return i.data(s);if((i instanceof ye||i instanceof zn)&&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,l=0){for(;l<s.length&&i!==void 0;)i=e(i,s[l]),l+=1;return i}o.zoom=t})(Ct||(Ct={}));function Jf(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 fr(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 $a=class{},us=class extends $a{constructor(e){super();this.id=e}},ps=class extends $a{constructor(e){super();this.data=e}};var Mc;try{Mc=new TextDecoder}catch{}var ne,go,I=0;var am=[],Ec=am,Lc=0,Vt={},Ce,yo,or=0,Mr=0,Kt,oo,It=[],Le,em={useRecords:!1,mapsAsObjects:!0},fs=class{},Dc=new fs;Dc.name="MessagePack 0xC1";var Fn=!1,Er=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(ne)return pm(()=>(Xa(),this?this.unpack(r,e):Er.prototype.unpack.call(em,r,e)));go=e>-1?e:r.length,I=0,Lc=0,Mr=0,yo=null,Ec=am,Kt=null,ne=r;try{Le=r.dataView||(r.dataView=new DataView(r.buffer,r.byteOffset,r.byteLength))}catch(t){throw ne=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 Er){if(Vt=this,this.structures)return Ce=this.structures,Ya();(!Ce||Ce.length>0)&&(Ce=[])}else Vt=em,(!Ce||Ce.length>0)&&(Ce=[]);return Ya()}unpackMultiple(r,e){let t,o=0;try{Fn=!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(Ya())===!1)return}else{for(t=[s];I<i;)o=I,t.push(Ya());return t}}catch(i){throw i.lastPosition=o,i.values=t,i}finally{Fn=!1,Xa()}}_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 Ya(){try{if(!Vt.trusted&&!Fn){let r=Ce.sharedLength||0;r<Ce.length&&(Ce.length=r)}let n=Ke();if(I==go)Ce.restoreStructures&&tm(),Ce=null,ne=null,oo&&(oo=null);else if(I>go){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}else if(!Fn)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Ce.restoreStructures&&tm(),Xa(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function tm(){for(let n in Ce.restoreStructures)Ce[n]=Ce.restoreStructures[n];Ce.restoreStructures=null}function Ke(){let n=ne[I++];if(n<160)if(n<128){if(n<64)return n;{let r=Ce[n&63]||Vt.getStructures&&lm()[n&63];return r?(r.read||(r.read=Gc(r,n&63)),r.read()):n}}else if(n<144)if(n-=128,Vt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[dm()]=Ke();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Ke(),Ke());return r}else{n-=144;let r=new Array(n);for(let e=0;e<n;e++)r[e]=Ke();return r}else if(n<192){let r=n-160;if(Mr>=I)return yo.slice(I-or,(I+=r)-or);if(Mr==0&&go<140){let e=r<16?Rc(r):cm(r);if(e!=null)return e}return Bc(r)}else{let r;switch(n){case 192:return null;case 193:return Kt?(r=Ke(),r>0?Kt[1].slice(Kt.position1,Kt.position1+=r):Kt[0].slice(Kt.position0,Kt.position0-=r)):Dc;case 194:return!1;case 195:return!0;case 196:return Ic(ne[I++]);case 197:return r=Le.getUint16(I),I+=2,Ic(r);case 198:return r=Le.getUint32(I),I+=4,Ic(r);case 199:return zo(ne[I++]);case 200:return r=Le.getUint16(I),I+=2,zo(r);case 201:return r=Le.getUint32(I),I+=4,zo(r);case 202:if(r=Le.getFloat32(I),Vt.useFloat32>2){let e=Za[(ne[I]&127)<<1|ne[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 ne[I++];case 205:return r=Le.getUint16(I),I+=2,r;case 206:return r=Le.getUint32(I),I+=4,r;case 207:return Vt.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 Vt.int64AsNumber?(r=Le.getInt32(I)*4294967296,r+=Le.getUint32(I+4)):r=Le.getBigInt64(I),I+=8,r;case 212:if(r=ne[I++],r==114)return sm(ne[I++]&63);{let e=It[r];if(e)return e.read?(I++,e.read(Ke())):e.noBuffer?(I++,e()):e(ne.subarray(I,++I));throw new Error("Unknown extension "+r)}case 213:return r=ne[I],r==114?(I++,sm(ne[I++]&63,ne[I++])):zo(2);case 214:return zo(4);case 215:return zo(8);case 216:return zo(16);case 217:return r=ne[I++],Mr>=I?yo.slice(I-or,(I+=r)-or):cw(r);case 218:return r=Le.getUint16(I),I+=2,Mr>=I?yo.slice(I-or,(I+=r)-or):dw(r);case 219:return r=Le.getUint32(I),I+=4,Mr>=I?yo.slice(I-or,(I+=r)-or):uw(r);case 220:return r=Le.getUint16(I),I+=2,om(r);case 221:return r=Le.getUint32(I),I+=4,om(r);case 222:return r=Le.getUint16(I),I+=2,nm(r);case 223:return r=Le.getUint32(I),I+=4,nm(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 lw=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Gc(n,r){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>lw.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(Ke);return n.highByte===0&&(n.read=rm(r,n.read)),o()}let t={};for(let o=0,i=n.length;o<i;o++){let s=n[o];t[s]=Ke()}return t}return e.count=0,n.highByte===0?rm(r,e):e}var rm=(n,r)=>function(){let e=ne[I++];if(e===0)return r();let t=n<32?-(n+(e<<5)):n+(e<<5),o=Ce[t]||lm()[t];if(!o)throw new Error("Record id is not defined for "+t);return o.read||(o.read=Gc(o,n)),o.read()};function lm(){let n=pm(()=>(ne=null,Vt.getStructures()));return Ce=Vt._mergeStructures(n,Ce)}var Bc=Ka,cw=Ka,dw=Ka,uw=Ka;function Ka(n){let r;if(n<16&&(r=Rc(n)))return r;if(n>64&&Mc)return Mc.decode(ne.subarray(I,I+=n));let e=I+n,t=[];for(r="";I<e;){let o=ne[I++];if((o&128)===0)t.push(o);else if((o&224)===192){let i=ne[I++]&63;t.push((o&31)<<6|i)}else if((o&240)===224){let i=ne[I++]&63,s=ne[I++]&63;t.push((o&31)<<12|i<<6|s)}else if((o&248)===240){let i=ne[I++]&63,s=ne[I++]&63,l=ne[I++]&63,c=(o&7)<<18|i<<12|s<<6|l;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+=ft.apply(String,t),t.length=0)}return t.length>0&&(r+=ft.apply(String,t)),r}function om(n){let r=new Array(n);for(let e=0;e<n;e++)r[e]=Ke();return r}function nm(n){if(Vt.mapsAsObjects){let r={};for(let e=0;e<n;e++)r[dm()]=Ke();return r}else{let r=new Map;for(let e=0;e<n;e++)r.set(Ke(),Ke());return r}}var ft=String.fromCharCode;function cm(n){let r=I,e=new Array(n);for(let t=0;t<n;t++){let o=ne[I++];if((o&128)>0){I=r;return}e[t]=o}return ft.apply(String,e)}function Rc(n){if(n<4)if(n<2){if(n===0)return"";{let r=ne[I++];if((r&128)>1){I-=1;return}return ft(r)}}else{let r=ne[I++],e=ne[I++];if((r&128)>0||(e&128)>0){I-=2;return}if(n<3)return ft(r,e);let t=ne[I++];if((t&128)>0){I-=3;return}return ft(r,e,t)}else{let r=ne[I++],e=ne[I++],t=ne[I++],o=ne[I++];if((r&128)>0||(e&128)>0||(t&128)>0||(o&128)>0){I-=4;return}if(n<6){if(n===4)return ft(r,e,t,o);{let i=ne[I++];if((i&128)>0){I-=5;return}return ft(r,e,t,o,i)}}else if(n<8){let i=ne[I++],s=ne[I++];if((i&128)>0||(s&128)>0){I-=6;return}if(n<7)return ft(r,e,t,o,i,s);let l=ne[I++];if((l&128)>0){I-=7;return}return ft(r,e,t,o,i,s,l)}else{let i=ne[I++],s=ne[I++],l=ne[I++],c=ne[I++];if((i&128)>0||(s&128)>0||(l&128)>0||(c&128)>0){I-=8;return}if(n<10){if(n===8)return ft(r,e,t,o,i,s,l,c);{let u=ne[I++];if((u&128)>0){I-=9;return}return ft(r,e,t,o,i,s,l,c,u)}}else if(n<12){let u=ne[I++],a=ne[I++];if((u&128)>0||(a&128)>0){I-=10;return}if(n<11)return ft(r,e,t,o,i,s,l,c,u,a);let d=ne[I++];if((d&128)>0){I-=11;return}return ft(r,e,t,o,i,s,l,c,u,a,d)}else{let u=ne[I++],a=ne[I++],d=ne[I++],p=ne[I++];if((u&128)>0||(a&128)>0||(d&128)>0||(p&128)>0){I-=12;return}if(n<14){if(n===12)return ft(r,e,t,o,i,s,l,c,u,a,d,p);{let f=ne[I++];if((f&128)>0){I-=13;return}return ft(r,e,t,o,i,s,l,c,u,a,d,p,f)}}else{let f=ne[I++],m=ne[I++];if((f&128)>0||(m&128)>0){I-=14;return}if(n<15)return ft(r,e,t,o,i,s,l,c,u,a,d,p,f,m);let h=ne[I++];if((h&128)>0){I-=15;return}return ft(r,e,t,o,i,s,l,c,u,a,d,p,f,m,h)}}}}}function Ic(n){return Vt.copyBuffers?Uint8Array.prototype.slice.call(ne,I,I+=n):ne.subarray(I,I+=n)}function zo(n){let r=ne[I++];if(It[r])return It[r](ne.subarray(I,I+=n));throw new Error("Unknown extension type "+r)}var im=new Array(4096);function dm(){let n=ne[I++];if(n>=160&&n<192){if(n=n-160,Mr>=I)return yo.slice(I-or,(I+=n)-or);if(!(Mr==0&&go<180))return Bc(n)}else return I--,Ke();let r=(n<<5^(n>1?Le.getUint16(I):n>0?ne[I]:0))&4095,e=im[r],t=I,o=I+n-3,i,s=0;if(e&&e.bytes==n){for(;t<o;){if(i=Le.getUint32(t),i!=e[s++]){t=1879048192;break}t+=4}for(o+=3;t<o;)if(i=ne[t++],i!=e[s++]){t=1879048192;break}if(t===o)return I=t,e.string;o-=3,t=I}for(e=[],im[r]=e,e.bytes=n;t<o;)i=Le.getUint32(t),e.push(i),t+=4;for(o+=3;t<o;)i=ne[t++],e.push(i);let l=n<16?Rc(n):cm(n);return l!=null?e.string=l:e.string=Bc(n)}var sm=(n,r)=>{var e=Ke();let t=n;r!==void 0&&(n=n<32?-((r<<5)+n):(r<<5)+n,e.highByte=r);let o=Ce[n];return o&&o.isShared&&((Ce.restoreStructures||(Ce.restoreStructures=[]))[n]=o),Ce[n]=e,e.read=Gc(e,t),e.read()},um=typeof self=="object"?self:global;It[0]=()=>{};It[0].noBuffer=!0;It[101]=()=>{let n=Ke();return(um[n[0]]||Error)(n[1])};It[105]=n=>{let r=Le.getUint32(I-4);oo||(oo=new Map);let e=ne[I],t;e>=144&&e<160||e==220||e==221?t=[]:t={};let o={target:t};oo.set(r,o);let i=Ke();return o.used?Object.assign(t,i):(o.target=i,i)};It[112]=n=>{let r=Le.getUint32(I-4),e=oo.get(r);return e.used=!0,e.target};It[115]=()=>new Set(Ke());var Vc=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");It[116]=n=>{let r=n[0],e=Vc[r];if(!e)throw new Error("Could not find typed array for code "+r);return new um[e](Uint8Array.prototype.slice.call(n,1).buffer)};It[120]=()=>{let n=Ke();return new RegExp(n[0],n[1])};It[98]=n=>{let r=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=I;I+=r-4,Kt=[Ke(),Ke()],Kt.position0=0,Kt.position1=0;let t=I;I=e;try{return Ke()}finally{I=t}};It[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 pm(n){let r=go,e=I,t=Lc,o=or,i=Mr,s=yo,l=Ec,c=oo,u=Kt,a=new Uint8Array(ne.slice(0,go)),d=Ce,p=Ce.slice(0,Ce.length),f=Vt,m=Fn,h=n();return go=r,I=e,Lc=t,or=o,Mr=i,yo=s,Ec=l,oo=c,Kt=u,ne=a,Fn=m,Ce=d,Ce.splice(0,Ce.length,...p),Vt=f,Le=new DataView(ne.buffer,ne.byteOffset,ne.byteLength),h}function Xa(){ne=null,oo=null,Ce=null}function fm(n){n.unpack?It[n.type]=n.unpack:It[n.type]=n}var Za=new Array(147);for(let n=0;n<256;n++)Za[n]=+("1e"+Math.floor(45.15-n*.30103));var Qa=new Er({useRecords:!1}),pw=Qa.unpack,fw=Qa.unpackMultiple,mw=Qa.unpack,Ja={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},hw=new Float32Array(1),LE=new Uint8Array(hw.buffer,0,4);var el;try{el=new TextEncoder}catch{}var tl,jc,rl=typeof Buffer<"u",zc=rl?Buffer.allocUnsafeSlow:Uint8Array,gm=rl?Buffer:Uint8Array,mm=rl?4294967296:2144337920,z,rt,E=0,Lr,Br=null,yw=/[\u0080-\uFFFF]/,ms=Symbol("record-id"),jo=class extends Er{constructor(r){super(r),this.offset=0;let e,t,o,i,s,l,c=0,u=gm.prototype.utf8Write?function(x,C,T){return z.utf8Write(x,C,T)}:el&&el.encodeInto?function(x,C){return el.encodeInto(x,z.subarray(C)).written}:!1,a=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 v=[],b=0,w=0;this.pack=this.encode=function(x,C){if(z||(z=new zc(8192),rt=new DataView(z.buffer,0,8192),E=0),Lr=z.length-10,Lr-E<2048?(z=new zc(z.length),rt=new DataView(z.buffer,0,z.length),Lr=z.length-10,E=0):E=E+7&2147483640,t=E,l=a.structuredClone?new Map:null,a.bundleStrings?(Br=["",""],z[E++]=214,z[E++]=98,Br.position=E-t,E+=4):Br=null,o=a.structures,o){o.uninitialized&&(o=a._mergeStructures(a.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 N=0;N<T;N++){let O=o[N];if(!O)continue;let A,R=o.transitions;for(let k=0,$=O.length;k<$;k++){let te=O[k];A=R[te],A||(A=R[te]=Object.create(null)),R=A}R[ms]=N+64}c=T}d||(o.nextId=T+64)}i&&(i=!1),s=o||[];try{if(S(x),Br){rt.setUint32(Br.position+t,E-Br.position-t);let T=Br;Br=null,S(T[0]),S(T[1])}if(a.offset=E,l&&l.idsToInsert){E+=l.idsToInsert.length*6,E>Lr&&_(E),a.offset=E;let T=xw(z.subarray(t,E),l.idsToInsert);return l=null,T}return C&vm?(z.start=t,z.end=E,z):z.subarray(t,E)}finally{if(o){if(w<10&&w++,b>1e4)o.transitions=null,w=0,b=0,v.length>0&&(v=[]);else if(v.length>0&&!d){for(let T=0,N=v.length;T<N;T++)v[T][ms]=0;v=[]}if(i&&a.saveStructures){let T=o.sharedLength||f;o.length>T&&(o=o.slice(0,T));let N=z.subarray(t,E);return a.saveStructures(o,c)===!1?(a._mergeStructures(a.getStructures()),a.pack(x)):(c=T,N)}}C&Tw&&(E=t)}};let S=x=>{E>Lr&&(z=_(E));var C=typeof x,T;if(C==="string"){let N=x.length;if(Br&&N>=8&&N<4096){let R=yw.test(x);Br[R?0:1]+=x,z[E++]=193,S(R?-N:N);return}let O;N<32?O=1:N<256?O=2:N<65536?O=3:O=5;let A=N*3;if(E+A>Lr&&(z=_(E+A)),N<64||!u){let R,k,$,te=E+O;for(R=0;R<N;R++)k=x.charCodeAt(R),k<128?z[te++]=k:k<2048?(z[te++]=k>>6|192,z[te++]=k&63|128):(k&64512)===55296&&(($=x.charCodeAt(R+1))&64512)===56320?(k=65536+((k&1023)<<10)+($&1023),R++,z[te++]=k>>18|240,z[te++]=k>>12&63|128,z[te++]=k>>6&63|128,z[te++]=k&63|128):(z[te++]=k>>12|224,z[te++]=k>>6&63|128,z[te++]=k&63|128);T=te-E-O}else T=u(x,E+O,A);T<32?z[E++]=160|T:T<256?(O<2&&z.copyWithin(E+2,E+1,E+1+T),z[E++]=217,z[E++]=T):T<65536?(O<3&&z.copyWithin(E+3,E+2,E+2+T),z[E++]=218,z[E++]=T>>8,z[E++]=T&255):(O<5&&z.copyWithin(E+5,E+3,E+3+T),z[E++]=219,rt.setUint32(E,T),E+=4),E+=T}else if(C==="number")if(x>>>0===x)x<64?z[E++]=x:x<256?(z[E++]=204,z[E++]=x):x<65536?(z[E++]=205,z[E++]=x>>8,z[E++]=x&255):(z[E++]=206,rt.setUint32(E,x),E+=4);else if(x>>0===x)x>=-32?z[E++]=256+x:x>=-128?(z[E++]=208,z[E++]=x+256):x>=-32768?(z[E++]=209,rt.setInt16(E,x),E+=2):(z[E++]=210,rt.setInt32(E,x),E+=4);else{let N;if((N=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){z[E++]=202,rt.setFloat32(E,x);let O;if(N<4||(O=x*Za[(z[E]&127)<<1|z[E+1]>>7])>>0===O){E+=4;return}else E--}z[E++]=203,rt.setFloat64(E,x),E+=8}else if(C==="object")if(!x)z[E++]=192;else{if(l){let O=l.get(x);if(O){if(!O.id){let A=l.idsToInsert||(l.idsToInsert=[]);O.id=A.push(O)}z[E++]=214,z[E++]=112,rt.setUint32(E,O.id),E+=4;return}else l.set(x,{offset:E-t})}let N=x.constructor;if(N===Object)P(x,!0);else if(N===Array){T=x.length,T<16?z[E++]=144|T:T<65536?(z[E++]=220,z[E++]=T>>8,z[E++]=T&255):(z[E++]=221,rt.setUint32(E,T),E+=4);for(let O=0;O<T;O++)S(x[O])}else if(N===Map){T=x.size,T<16?z[E++]=128|T:T<65536?(z[E++]=222,z[E++]=T>>8,z[E++]=T&255):(z[E++]=223,rt.setUint32(E,T),E+=4);for(let[O,A]of x)S(O),S(A)}else{for(let O=0,A=tl.length;O<A;O++){let R=jc[O];if(x instanceof R){let k=tl[O];if(k.write){k.type&&(z[E++]=212,z[E++]=k.type,z[E++]=0),S(k.write.call(this,x));return}let $=z,te=rt,Y=E;z=null;let W;try{W=k.pack.call(this,x,H=>(z=$,$=null,E+=H,E>Lr&&_(E),{target:z,targetView:rt,position:E-H}),S)}finally{$&&(z=$,rt=te,E=Y,Lr=z.length-10)}W&&(W.length+E>Lr&&_(W.length+E),E=gw(W,z,E,k.type));return}}P(x,!x.hasOwnProperty)}}else if(C==="boolean")z[E++]=x?195:194;else if(C==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))z[E++]=211,rt.setBigInt64(E,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)z[E++]=207,rt.setBigUint64(E,x);else if(this.largeBigIntToFloat)z[E++]=203,rt.setFloat64(E,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");E+=8}else if(C==="undefined")this.encodeUndefinedAsNil?z[E++]=192:(z[E++]=212,z[E++]=0,z[E++]=0);else if(C==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+C)},P=this.useRecords===!1?this.variableMapSize?x=>{let C=Object.keys(x),T=C.length;T<16?z[E++]=128|T:T<65536?(z[E++]=222,z[E++]=T>>8,z[E++]=T&255):(z[E++]=223,rt.setUint32(E,T),E+=4);let N;for(let O=0;O<T;O++)S(N=C[O]),S(x[N])}:(x,C)=>{z[E++]=222;let T=E-t;E+=2;let N=0;for(let O in x)(C||x.hasOwnProperty(O))&&(S(O),S(x[O]),N++);z[T+++t]=N>>8,z[T+t]=N&255}:x=>{let C=Object.keys(x),T,N=s.transitions||(s.transitions=Object.create(null)),O=0;for(let R=0,k=C.length;R<k;R++){let $=C[R];T=N[$],T||(T=N[$]=Object.create(null),O++),N=T}let A=N[ms];if(A)A>=96&&h?(z[E++]=((A-=96)&31)+96,z[E++]=A>>5):z[E++]=A;else{A=s.nextId,A||(A=64),A<y&&this.shouldShareStructure&&!this.shouldShareStructure(C)?(A=s.nextOwnId,A<g||(A=y),s.nextOwnId=A+1):(A>=g&&(A=y),s.nextId=A+1);let R=C.highByte=A>=96&&h?A-96>>5:-1;N[ms]=A,s[A-64]=C,A<y?(C.isShared=!0,s.sharedLength=A-63,i=!0,R>=0?(z[E++]=(A&31)+96,z[E++]=R):z[E++]=A):(R>=0?(z[E++]=213,z[E++]=114,z[E++]=(A&31)+96,z[E++]=R):(z[E++]=212,z[E++]=114,z[E++]=A),O&&(b+=w*O),v.length>=m&&(v.shift()[ms]=0),v.push(N),S(C))}for(let R=0,k=C.length;R<k;R++)S(x[C[R]])},_=x=>{let C;if(x>16777216){if(x-t>mm)throw new Error("Packed buffer would be larger than maximum buffer size");C=Math.min(mm,Math.round(Math.max((x-t)*(x>67108864?1.25:2),4194304)/4096)*4096)}else C=(Math.max(x-t<<2,z.length-1)>>12)+1<<12;let T=new zc(C);return rt=new DataView(T.buffer,0,C),z.copy?z.copy(T,0,t,x):T.set(z.slice(t,x)),E-=t,t=0,Lr=T.length-10,z=T}}useBuffer(r){z=r,rt=new DataView(z.buffer,z.byteOffset,z.byteLength),E=0}};jc=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,fs];tl=[{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?hm(n,16,r):ym(rl?Buffer.from(n):new Uint8Array(n),r)}},{pack(n,r){let e=n.constructor;e!==gm&&this.structuredClone?hm(n,Vc.indexOf(e.name),r):ym(n,r)}},{pack(n,r){let{target:e,position:t}=r(1);e[t]=193}}];function hm(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:l}=e(7+o);i[s++]=201,l.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=r,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function ym(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 gw(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 xw(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 l=i+t;n[l++]=214,n[l++]=105,n[l++]=s>>24,n[l++]=s>>16&255,n[l++]=s>>8&255,n[l++]=s&255,o=i}return n}function xo(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)");jc.unshift(n.Class),tl.unshift(n)}fm(n)}var xm=new jo({useRecords:!1}),vw=xm.pack,bw=xm.pack;var{NEVER:Sw,ALWAYS:ww,DECIMAL_ROUND:_w,DECIMAL_FIT:Pw}=Ja,vm=512,Tw=1024;var bm=new jo({structuredClone:!0});xo({Class:ze.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,ze.prototype),n}});xo({Class:ye.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,ye.prototype),n}});xo({Class:st.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,st.prototype),n}});xo({Class:us.prototype.constructor,type:4,write(n){return n.id},read(n){return new us(n)}});xo({Class:ps.prototype.constructor,type:5,write(n){return n.data},read(n){return new ps(n)}});xo({Class:qe.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,qe.prototype),n}});function Ow(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 Fc(n){if(Dn(n))return n;if(Array.isArray(n))return n.map(Fc);if(typeof n=="object"&&n!==null){let r={};for(let e of Object.keys(n).sort())r[e]=Fc(n[e]);return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else return n}var ol;(t=>{function n(o){return bm.pack(o)}t.serialize=n;function r(o){return bm.unpack(o)}t.deserialize=r;function e(o){return Ow(n(Fc(o))).toString()}t.checksum=e})(ol||(ol={}));var Sm;(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})(Sm||(Sm={}));var vo;(l=>{function n(c,u){return c[0]===u[0]&&c[1]===u[1]&&c[2]===u[2]}l.isEqual=n;function r(c,u){return[c[0]+u[0],c[1]+u[1],c[2]+u[2]]}l.add=r;function e(c,u){return[c[0]-u[0],c[1]-u[1],c[2]-u[2]]}l.sub=e;function t(c,u){return[c[0]/u[0],c[1]/u[1],c[2]/u[2]]}l.div=t;function o(c,u){return[c[0]*u[0],c[1]*u[1],c[2]*u[2]]}l.mul=o;function i(c,u){return Math.hypot(c[0]-u[0],c[1]-u[1],c[2]-u[2])}l.dist=i;function s(c,u,a){return[c[0]+(u[0]-c[0])*a,c[1]+(u[1]-c[1])*a,c[2]+(u[2]-c[2])*a]}l.lerp=s})(vo||(vo={}));var wm;(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})(wm||(wm={}));var bo;(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 l=0;l<16;l++)if(i[l]!==s[l])return!1;return!0}o.isEqual=r;function e(i){return i??o.identity}o.simplify=e;function t(i,s){let l=s.slice(0);for(var c=0,u=s.length;c<u;c+=3){let a=i[3]*s[c]+i[7]*s[c+1]+i[11]*s[c+2]+i[15];l[c]=(i[0]*s[c]+i[4]*s[c+1]+i[8]*s[c+2]+i[12])/a,l[c+1]=(i[1]*s[c]+i[5]*s[c+1]+i[9]*s[c+2]+i[13])/a,l[c+2]=(i[2]*s[c]+i[6]*s[c+1]+i[10]*s[c+2]+i[14])/a}return l}o.applyMatrix4=t})(bo||(bo={}));var At;(a=>{function n(d){return typeof d=="object"&&typeof d.r=="number"&&typeof d.g=="number"&&typeof d.b=="number"}a.isRGB=n,a.white={r:1,g:1,b:1},a.red={r:1,g:0,b:0},a.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}}a.toRgb255a1=o;function i(d){return{r:d.r,g:d.g,b:d.b}}a.clone=i;function s(d){return d=Math.floor(d),{r:(d>>16&255)/255,g:(d>>8&255)/255,b:(d&255)/255}}a.fromHex=s;function l(d){return Math.round(d.r*255)*65536+Math.round(d.g*255)*256+Math.round(d.b*255)}a.toHex=l;function c(d,p){return d.r===p.r&&d.g===p.g&&d.b===p.b}a.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}}a.lerp=u})(At||(At={}));var Zt;(l=>{l.white={...At.white,a:1},l.transparent={...At.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}l.from0to1=e;function t(c,u){return{...At.fromHex(c),a:u}}l.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}}l.toRgb255a1=o;function i(c,u){return At.equals(c,u)&&c.a===u.a}l.equals=i;function s(c,u,a){return{r:c.r+(u.r-c.r)*a,g:c.g+(u.g-c.g)*a,b:c.b+(u.b-c.b)*a,a:c.a+(u.a-c.a)*a}}l.lerp=s})(Zt||(Zt={}));var nl;(r=>r.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(nl||(nl={}));var _m;(r=>r.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(_m||(_m={}));var Pm;(r=>r.defaultData={control1:[.5,.05],control2:[.1,.3]})(Pm||(Pm={}));var mr;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function r(t){return e.all.includes(t)}e.is=r})(mr||(mr={}));var Fo;(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,autoZoom:!1,autoZoomFrustumSize:790},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function t(i){return i.type==="PerspectiveCamera"?i.perspective.zoom:i.orthographic.zoom}o.getZoom=t})(Fo||(Fo={}));var Dr;(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(Aw.forEach(s=>{Object.assign(i,{[s]:o[s]??t[s]})}),i.radial={...t.radial},o.radial){let s=t.radial,l=o.radial;Nw.forEach(c=>{Object.assign(i.radial,{[c]:l[c]??s[c]})})}if(i.linear={...t.linear},o.linear){let s=t.linear,l=o.linear;Cw.forEach(c=>{Object.assign(i.linear,{[c]:l[c]??s[c]})})}if(i.grid={...t.grid},o.grid){let s=t.grid,l=o.grid;Iw.forEach(c=>{Object.assign(i.grid,{[c]:l[c]??s[c]})})}if(i.toObject={...t.toObject},o.toObject){let s=t.toObject,l=o.toObject;Mw.forEach(c=>{Object.assign(i.toObject,{[c]:l[c]??s[c]})})}if(i.randomnessObject={...t.randomnessObject},o.randomnessObject){let s=t.randomnessObject,l=o.randomnessObject;Ew.forEach(c=>{Object.assign(i.randomnessObject,{[c]:l[c]??s[c]})})}return i}e.merge=r})(Dr||(Dr={}));var il;(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 l of r){let c=o[l];c&&Object.keys(c).length>0&&s.push({type:0,path:[...i,l],props:c})}return s}t.toOps=e})(il||(il={}));var Aw=["count"],Nw=["radius","start","end","position","scale","rotation"],Cw=["position","scale","rotation"],Iw=["count","size"],Mw=["count","position","scale","rotation"],Ew=["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 al;(e=>{function n(t){return r(t)}e.defaultData=n;function r(t){if(t==="PointLight")return{type:t,color:Zt.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(t==="SpotLight")return{type:t,color:Zt.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(t==="DirectionalLight")return{type:t,color:Zt.white,intensity:1,shadows:!0,size:2e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(al||(al={}));var kc;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function r(t,o){return t.castShadow===o.castShadow&&t.receiveShadow===o.receiveShadow}e.equals=r})(kc||(kc={}));var Uc;(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})(Uc||(Uc={}));var ll;(r=>r.defaultData={...Uc.defaultData,...kc.defaultData})(ll||(ll={}));var kn;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(kn||(kn={}));var Tm;(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})(Tm||(Tm={}));function Am(n){return n.type!=="displace"}var Om;(r=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}r.is=n})(Om||(Om={}));var Nm=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Cm=["wrapping","image","video"],Mt;(o=>{function n(i,s){let{texture:l,...c}=s;if(Object.assign(i,c),l){let u=i.texture;u&&Object.assign(u,l)}}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};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(5526619)};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:Zt.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:Zt.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Zt.fromHexAndA(0,1),contourColor:Zt.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}}}})(Mt||(Mt={}));var zt;(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 a="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([p,f])=>{a+=`${p}${f}`,Array.isArray(f)?f.forEach(m=>a+=`${m}`):typeof f=="object"?Object.values(f).forEach(m=>{typeof m=="number"?a+=`${m.toFixed(4)}`:a+=`${m}`}):a+=`${f}`})}),a}c.getHash=r;function e(){return{layers:new ye}}c.defaultEmptyData=e;function t(u="layer1",a="layer2"){return i("phong",u,a)}c.defaultData=t;function o(u,a){return{...u,name:a}}c.withName=o;function i(u,a="layer1",d="layer2"){let p=new ye;return p.push({fi:0,data:Mt.defaultData("light",u),id:a}),p.push({fi:1,data:Mt.defaultData("color"),id:d}),{layers:p}}c.defaultTwoLayerData=i;function s(u,a="phong",d="layer1",p="layer2"){let f=Mt.defaultData("texture");Object.assign(f.texture,{image:u});let m=new ye;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Mt.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,a="phong",d="layer1",p="layer2"){let f=Mt.defaultData("video");Object.assign(f.texture,{video:u});let m=new ye;return m.push({fi:0,data:f,id:d}),m.push({fi:1,data:Mt.defaultData("light",a),id:p}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(zt||(zt={}));var Un;(r=>{function n(){return{points:new ye,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n})(Un||(Un={}));var Hn;(r=>{function n(){return{points:new ye,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}r.defaultData=n})(Hn||(Hn={}));var Hc={type:"Ellipse",width:100,height:100,spikes:64,angle:360,innerRadius:0};var cl;(r=>{function n(e,t){let o={...e};return Lw.forEach(i=>{Object.assign(o,{[i]:t[i]??e[i]})}),o}r.merge=n})(cl||(cl={}));var dl={shape:Hc,depth:1,offset:0,bevel:0,bevelSides:1,angle:0,twist:0,startScale:1,endScale:1},Lw=["depth","offset","angle","twist","startScale","endScale"];var hs;(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})(hs||(hs={}));var ul;(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,cl.merge(o.extrusion,t.extrusion))),o}r.merge=n})(ul||(ul={}));var So;(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:Hn.defaultData(),extrusion:dl};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Un.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})(So||(So={}));var Im;(e=>{function n(t){return t==="Component"||t==="Instance"}e.isComponentRelated=n;function r(t){return t==="Empty"||t==="Instance"}e.isEmptyOrComponent=r})(Im||(Im={}));var qn;(o=>{o.identity={...nl.identity,hiddenMatrix:bo.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 vu({position:vo.isEqual(i.position,s.position)?void 0:s.position,rotation:vo.isEqual(i.rotation,s.rotation)?void 0:s.rotation,scale:vo.isEqual(i.scale,s.scale)?null:s.scale,hiddenMatrix:bo.isEqual(i.hiddenMatrix,s.hiddenMatrix)?void 0:s.hiddenMatrix})}o.diff=t})(qn||(qn={}));var Mm;(r=>r.defaultData={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]})(Mm||(Mm={}));var Qt;(r=>r.defaultData={states:new ye,events:new ye,visible:!0,raycastLock:!1,collision:"visibility",physics:null,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...qn.identity,cloner:null})(Qt||(Qt={}));var Em;(r=>r.defaultData={type:"Empty",...Qt.defaultData})(Em||(Em={}));var Lm;(r=>r.defaultData={type:"Component",...Qt.defaultData})(Lm||(Lm={}));var ko;(r=>r.defaultData={type:"Mesh",...Qt.defaultData,...ll.defaultData})(ko||(ko={}));var Wn;(r=>r.defaultData={...Qt.defaultData,...qn.identity,...Fo.defaultData})(Wn||(Wn={}));var Bm;(r=>{function n(e){return{...Qt.defaultData,...al.defaultData(e)}}r.defaultData=n})(Bm||(Bm={}));var $n;(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 l=Object.keys(s);if(l.length===1&&l[0]==="descendants")return}return s}e.resolve=r})($n||($n={}));var wo;(i=>{i.rootOverrideProps=["physics"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function t(s,l){return{...Qt.defaultData,...l,component:s,overrides:new qe,physics:void 0,type:"Instance"}}i.ofComponent=t;function o(s){let l=qn.fromObject(s.data);return t(s.id,l)}i.fromComponentData=o})(wo||(wo={}));var Dm;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:bo.identity,name:"Play Camera",visible:!0,raycastLock:!1,collision:"visibility",physics:null,states:new ye,events:new ye,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Fo.defaultData},i.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},i.defaultMeshObject={name:"Rectangle",...Qt.defaultData,...ko.defaultData,geometry:So.defaultData("RectangleGeometry"),material:zt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...Qt.defaultData,...ko.defaultData,geometry:So.defaultData("BooleanGeometry"),material:zt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...Qt.defaultData,...ko.defaultData,geometry:So.defaultData("TextGeometry"),material:zt.defaultTwoLayerData("phong","layer1","layer2")}))(Dm||(Dm={}));var Uo;(o=>{function n(i,s){let l={name:s};return i.type==="Mesh"?(l.geometry={},"material"in i&&(l.material={layers:new qe}),"materials"in i&&(l.materials=i.materials.map(c=>({layers:new qe})))):mr.is(i.type)&&(l.perspective={},l.orthographic={}),l}o.newEmpty=n;function r(i,s){if(s===void 0)return i;let l={...i};return"material"in l&&"material"in s&&s.material&&(l.material=jn(l.material,c=>{if(typeof c!="string")for(let[u,a]of Object.entries(s.material.layers)){let d=c.layers.data(u);d&&Mt.patch(d,a)}}).data),l.materials&&s.materials&&(l.materials=jn(l.materials,c=>{for(let u=0;u<l.materials.length;u++){let a=s.materials[u];if(typeof a!="string")for(let[d,p]of Object.entries(a.layers)){let f=c[u]?.layers?.data(d);f&&Mt.patch(f,p)}}}).data),l}function e(i,s){let l,c=[],u={orthographic:0,perspective:0,geometry:0};function a(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(s))if(d!=="name")if(d==="cloner")c.push(...il.toOps(p,["cloner"]));else if(d==="pathSnapping")c.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")a(["material"],p);else if(d==="materials")for(let[f,m]of Object.entries(p))a(["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 l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[d]=p;return c}o.toOps=e;function t(i,s){if(s===void 0)return i;let l={...i};if(Object.assign(l,qn.merge(l,s)),Object.assign(l,{pathSnapping:Object.assign({},l.pathSnapping,{slide:s.pathSnapping?.slide??l.pathSnapping?.slide??0,offset:s.pathSnapping?.offset??l.pathSnapping?.offset??0})}),mr.is(i.type)){l.orthographic={...l.orthographic},l.perspective={...l.perspective};let c=s;c.orthographic?.zoom!==void 0&&(l.orthographic.zoom=c.orthographic.zoom),c.perspective?.zoom!==void 0&&(l.perspective.zoom=c.perspective.zoom),c.isUpVectorFlipped!==void 0&&(l.isUpVectorFlipped=c.isUpVectorFlipped),c.targetOffset!==void 0&&(l.targetOffset=c.targetOffset)}else if(i.type==="Mesh")"geometry"in s&&Object.assign(l,{geometry:ul.merge(l.geometry,s.geometry)}),(s.material||s.materials)&&(l=r(l,s)),l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Dr.merge(l.cloner,s.cloner)});else if(i.type==="Empty")l.cloner&&"cloner"in s&&Object.assign(l,{cloner:Dr.merge(l.cloner,s.cloner)});else if(sl.is(i.type)){let c=s;c.intensity!==void 0&&(l.intensity=c.intensity),c.color!==void 0&&(typeof c.color=="string"?l.color=c.color:l.color=At.clone(c.color))}return l}o.patch=t})(Uo||(Uo={}));var Yn;(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,autoZoom:!1})(Yn||(Yn={}));var pl;(r=>r.defaultData={orbitControls:Yn.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",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,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"]}),gameControlObject:null,hdTransmission:!1})(pl||(pl={}));var qc;(r=>r.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(qc||(qc={}));var Wc;(r=>r.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(Wc||(Wc={}));var fl;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...qc.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:Wc.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(fl||(fl={}));var Xn;(r=>r.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Xn||(Xn={}));var ml;(t=>{function n(){let o={};return o["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Kr(o,ze.prototype)}t.defaultColors=n;function r(o){let i={};return o?.withAITexture&&(i["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...Xn.emptyImage,name:"AI generated image"}),Kr(i,ze.prototype)}t.defaultImages=r;function e(){return{materials:new ze,images:new ze,videos:new ze,colors:new ze,audios:new ze,fonts:new ze,penumbraSize:[2,2,2]}}t.emptyData=e})(ml||(ml={}));var gs=require("three");var hl;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",speedTranslate:1e3,speedRotate:100,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"]],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},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Zt.fromHexAndA(3728051,1)}}))(hl||(hl={}));function Gm(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 l=2;l<10;l++)o.push(o[1]),i.push(1);let s={...Ln(pt(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={...pt(r),near:Math.max(r.near,0),far:Math.max(r.far,0)};Object.assign(r,e)}})}function Kn(n,r){Object.values(n.shared.materials).forEach(e=>r(e))}function Zn(n,r){n.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(o=>{typeof o!="string"&&r(o)}):"material"in t&&typeof t.material!="string"&&r(t.material)})}function Bw(n){Object.assign(n.scene.publish,{orbitControls:{...Yn.defaultData,...pt(n.scene.publish.orbitControls)}})}function Dw(n){Object.assign(n.scene.publish.settings,{video:{...pl.defaultData.settings.video,...pt(n.scene.publish.settings.video)}})}function Gw(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((Nm.includes(o)||typeof i=="boolean")&&delete t[o],o==="texture")for(let[s,l]of Object.entries(i))(Cm.includes(s)||typeof l=="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 Rw(n){n.scene.publish.withBackground=!0}function Vw(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function zw(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 jw(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 Fw(n){n.scene.objects.traverse((r,e)=>{let t=n.scene.objects.unproxy().parent(r);if(t){let o=pt(n.scene.objects.data(t));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=pt(e).booleanExclude!==!0)}})}function kw(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 Uw(n){function r(t){Object.setPrototypeOf(t,qe.prototype),t.texture&&Object.setPrototypeOf(t.texture,qe.prototype)}function e(t){Object.setPrototypeOf(t,qe.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 l=pt(s.material).layers;e(l),s.material.layers=l}if(s.materials)for(let l=0;l<s.materials.length;l++){let c=s.materials[l],u=pt(c).layers;e(u),c.layers=u}})})}function Rm(n){n.layers===void 0&&Object.assign(n,zt.defaultTwoLayerData("lambert"))}function $c(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={...pt(r),colors:e,steps:t};Object.assign(r,o)}})}function Hw(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function Vm(n){n.scene.objects.traverse((r,e)=>{"materials"in e?e.materials.forEach(t=>{typeof t!="string"&&$c(t)}):"material"in e&&typeof e.material!="string"&&$c(e.material)}),Object.values(n.shared.materials).forEach(r=>$c(r))}function qw(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 Ww(n){n.shared.audios=Kr({},ze.prototype)}function $w(n){n.shared.videos=Kr({},ze.prototype)}function Yw(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 Xw(n){Object.entries(pt(n.shared.images)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.images[t]}),Object.entries(pt(n.shared.audios)).filter(t=>t[1].asset===!1).map(t=>t[0]).forEach(t=>{delete n.shared.audios[t]})}function Kw(n){n.scene.publish.settings.web.preload=!1}function zm(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 jm(n){n.layers&&n.layers.forEach(r=>{Am(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 Zw(n){n.shared.fonts=Kr({},ze.prototype)}function Qw(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 Jw(n){let r=[];n.scene.objects.traverse((e,t)=>{let o=t;if(o.type==="TextFrame"){let i=zt.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 l=Qw(o.font);n.shared.fonts[l]===void 0&&(n.shared.fonts[l]={name:l});let c={name:o.name,...Qt.defaultData,...ko.defaultData,flatShading:!1,wireframe:!1,geometry:{...So.defaultData("TextGeometry"),width:o.width,height:o.height,font:l,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:pt(o.states),events:pt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=pt(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 e_(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:gs.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((s,l,c)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},a={easing:s.easing,duration:s.duration};s.easing===6?Object.assign(a,Ln(s,"mass","stiffness","damping","velocity")):s.easing===5&&Object.assign(a,{control1:{...s.control1},control2:{...s.control2}});let d={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,...d,...a},f={allowSlerp:!0,type:"Transition",object:s.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ye({fi:0,id:gs.MathUtils.generateUUID(),data:u},{fi:1,id:gs.MathUtils.generateUUID(),data:p})};i.push({fi:c,id:l,data:f})}),delete o.targets)}})})}function t_(n){n.scene.objects.traverse((r,e)=>{function t(o,i){let s=new ye,l=[];if(e.events.forEach((c,u,a)=>{if(c.type==="Audio"&&c.trigger===i){let d;l.push(u),c.interaction==="play"?d={...Ln(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={...Ln(c,"interaction","delay","object","playAudio"),type:"Audio"}),d&&s.push({fi:a,id:u,data:d})}}),l.forEach(c=>e.events.delete(c)),s.length){let c=e.events.find(u=>u.type===o)?.data;c?"actions"in c&&c.actions.insertBefore(null,s):e.events.insertBefore(null,[{id:gs.MathUtils.generateUUID(),data:{type:o,actions:s}}])}}t("Start","start"),t("MouseDown","mouseDown"),t("MouseUp","mouseUp"),t("KeyDown","keyDown"),t("KeyUp","keyUp")})}function Fm(n){let r=n.layers.find(e=>e.type==="light")?.data;if(r?.category==="basic"){let e=Mt.defaultData("light","phong"),t=r;Object.assign(t,e),t.visible=!1}}function km(n){Kn(n,Fm),Zn(n,Fm)}function r_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function o_(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 n_(n){n.scene.objects.traverse((r,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=zt.defaultTwoLayerData("phong"))})}function i_(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 s_(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 a_(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 l_(n){let{video:r}=n.scene.publish.settings;r.format==="gif"&&r.fps>48&&(r.fps=15)}function c_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.resetYPosition=Math.abs(t.resetYPosition-e.position[1]))})})}function d_(n){let r=n.scene.environment.usePhysics;n.scene.objects.traverse((e,t)=>{r&&t.physics===null?t.collision=!1:t.collision="visibility"})}function u_(n){n.scene.objects.traverse((r,e)=>{e.events.forEach(t=>{t.type==="GameControl"&&(t.navmesh=hl.defaultDataThirdPerson.navmesh)})})}function p_(n){n.scene.styles||(n.scene.styles=fl.defaultData())}function Um(n){n.layers.forEach(r=>{r.type==="light"&&r.category!=="toon"&&r.occlusion===void 0&&(r.occlusion=!0)})}function f_(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}),Zn(n,Um),Kn(n,Um)}var Hm=41;function qm(n){let r=n.schema??0;r!==Hm&&(console.warn("updating from ",r,"to ",Hm),r<1&&(Zn(n,Gm),Kn(n,Gm),n.schema=1),r<2&&(Bw(n),n.schema=2),r<3&&(Gw(n),n.schema=3),r<4&&(Rw(n),n.schema=4),r<5&&(Vw(n),n.schema=5),r<6&&(zw(n),n.schema=6),r<7&&(jw(n),n.schema=7),r<8&&(n.schema=8),r<9&&(Vm(n),n.schema=9),r<10&&(Hw(n),n.schema=10),r<11&&(qw(n),n.schema=11),r<12&&(Vm(n),n.schema=12),r<13&&(Ww(n),n.schema=13),r<14&&(Yw(n),n.schema=14),r<15&&(Xw(n),n.schema=15),r<16&&(Kw(n),n.schema=16),r<17&&(Zn(n,zm),Kn(n,zm),n.schema=17),r<18&&(Zn(n,Rm),Kn(n,Rm),n.schema=18),r<19&&(Dw(n),n.schema=19),r<20&&(Zw(n),Jw(n),n.schema=20),r<21&&(e_(n),t_(n),n.schema=21),r<22&&(km(n),n.schema=22),r<23&&(r_(n),n.schema=23),r<24&&(o_(n),n.schema=24),(r<25||n.shared.videos===void 0)&&($w(n),r<25&&(n.schema=25)),r<26&&(Fw(n),n.schema=26),r<27&&(kw(n),n.schema=27),r<28&&(km(n),n.schema=28),r<29&&(Uw(n),n.schema=29),r<30&&(n_(n),n.schema=30),r<31&&(i_(n),n.schema=31),r<33&&(s_(n),n.schema=33),r<34&&(a_(n),n.schema=34),r<35&&(l_(n),n.schema=35),r<36&&(c_(n),n.schema=36),r<37&&(d_(n),n.schema=37),r<38&&(Zn(n,jm),Kn(n,jm),n.schema=38),r<39&&(u_(n),n.schema=39),r<40&&(p_(n),n.schema=40),r<41&&(f_(n),n.schema=41))}var Ee=require("three"),$i=dn($m());var m_=.5*(Math.sqrt(3)-1),vs=(3-Math.sqrt(3))/6,h_=1/3,Gr=1/6,tD=(Math.sqrt(5)-1)/4,rD=(5-Math.sqrt(5))/20,bs=n=>Math.floor(n)|0,Ym=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]),Xc=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=Km(n),e=new Float64Array(r).map(o=>Ym[o%12*2]),t=new Float64Array(r).map(o=>Ym[o%12*2+1]);return function(i,s){let l=0,c=0,u=0,a=(i+s)*m_,d=bs(i+a),p=bs(s+a),f=(d+p)*vs,m=d-f,h=p-f,y=i-m,g=s-h,v,b;y>g?(v=1,b=0):(v=0,b=1);let w=y-v+vs,S=g-b+vs,P=y-1+2*vs,_=g-1+2*vs,x=d&255,C=p&255,T=.5-y*y-g*g;if(T>=0){let A=x+r[C],R=e[A],k=t[A];T*=T,l=T*T*(R*y+k*g)}let N=.5-w*w-S*S;if(N>=0){let A=x+v+r[C+b],R=e[A],k=t[A];N*=N,c=N*N*(R*w+k*S)}let O=.5-P*P-_*_;if(O>=0){let A=x+1+r[C+1],R=e[A],k=t[A];O*=O,u=O*O*(R*P+k*_)}return 70*(l+c+u)}}function Xm(n=Math.random){let r=Km(n),e=new Float64Array(r).map(i=>Xc[i%12*3]),t=new Float64Array(r).map(i=>Xc[i%12*3+1]),o=new Float64Array(r).map(i=>Xc[i%12*3+2]);return function(s,l,c){let u,a,d,p,f=(s+l+c)*h_,m=bs(s+f),h=bs(l+f),y=bs(c+f),g=(m+h+y)*Gr,v=m-g,b=h-g,w=y-g,S=s-v,P=l-b,_=c-w,x,C,T,N,O,A;S>=P?P>=_?(x=1,C=0,T=0,N=1,O=1,A=0):S>=_?(x=1,C=0,T=0,N=1,O=0,A=1):(x=0,C=0,T=1,N=1,O=0,A=1):P<_?(x=0,C=0,T=1,N=0,O=1,A=1):S<_?(x=0,C=1,T=0,N=0,O=1,A=1):(x=0,C=1,T=0,N=1,O=1,A=0);let R=S-x+Gr,k=P-C+Gr,$=_-T+Gr,te=S-N+2*Gr,Y=P-O+2*Gr,W=_-A+2*Gr,H=S-1+3*Gr,V=P-1+3*Gr,G=_-1+3*Gr,B=m&255,L=h&255,D=y&255,X=.6-S*S-P*P-_*_;if(X<0)u=0;else{let M=B+r[L+r[D]];X*=X,u=X*X*(e[M]*S+t[M]*P+o[M]*_)}let q=.6-R*R-k*k-$*$;if(q<0)a=0;else{let M=B+x+r[L+C+r[D+T]];q*=q,a=q*q*(e[M]*R+t[M]*k+o[M]*$)}let j=.6-te*te-Y*Y-W*W;if(j<0)d=0;else{let M=B+N+r[L+O+r[D+A]];j*=j,d=j*j*(e[M]*te+t[M]*Y+o[M]*W)}let F=.6-H*H-V*V-G*G;if(F<0)p=0;else{let M=B+1+r[L+1+r[D+1]];F*=F,p=F*F*(e[M]*H+t[M]*V+o[M]*G)}return 32*(u+a+d+p)}}function Km(n){let e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){let o=t+~~(n()*(256-t)),i=e[t];e[t]=e[o],e[o]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Zm=require("three"),yr=new Zm.Triangle,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;yr.a.fromBufferAttribute(r,o),yr.b.fromBufferAttribute(r,o+1),yr.c.fromBufferAttribute(r,o+2),i*=yr.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),yr.a.fromBufferAttribute(this.positionAttribute,r*3),yr.b.fromBufferAttribute(this.positionAttribute,r*3+1),yr.c.fromBufferAttribute(this.positionAttribute,r*3+2),e.set(0,0,0).addScaledVector(yr.a,o).addScaledVector(yr.b,i).addScaledVector(yr.c,1-(o+i)),yr.getNormal(t),this}};var th=require("three");var Jt=require("three"),eh=dn(Jm()),y_=new Jt.Matrix4,g_=new Jt.Matrix4,x_=new Jt.Matrix4,Ss;(r=>{function n(e){return e&&e.__isSPEObject}r.is=n})(Ss||(Ss={}));var Qn=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new Jt.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Jt.Matrix4;this.matrixWorldRigid=new Jt.Matrix4;this.shearScale=new Jt.Matrix4;this.shearScaleInv=new Jt.Matrix4}get __isSPEObject(){return!0}isDescendantOf(t){t instanceof Jt.Object3D&&(t=t.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===t)return!0;o=o.parent}return!1}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let o of this.children)o.updateMatrixWorld(t)}updateWorldMatrix(t,o){let i=this.parent;if(t&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let s of this.children)s.updateWorldMatrix(!1,!0)}traverseObject(t,o=0){if(t(this,o)!==!0)for(let s of this.children)Ss.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:l}=(0,eh.SVD)(o),c=y_.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=g_.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),a=x_.copy(u).transpose();this.shearScale.makeScale(l[0],l[1],l[2]).multiply(a).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(c,a).copyPosition(this.matrixWorld),l.every(d=>Math.abs(l[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(t,o){this.updateWorldMatrix(!0,!1);let i=new Jt.Matrix4().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),"hiddenMatrix"in t&&t.hiddenMatrix instanceof Jt.Matrix4?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),o!==void 0&&(this.children.pop(),this.children.splice(o,0,t)),this}copy(t,o=!1){return super.copy(t,o),this.hasNonUniformScale=t.hasNonUniformScale,this}onAfterRender(t,o,i,s,l,c){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Kc=class extends Qn(th.Object3D){},v_=n=>n.type==="Mesh",no=class extends Kc{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,t){}expand(){let e=0,t=this.object.entityChildren(e);for(;t;){let o=this.children[e];o?.object!==t&&(o&&this.remove(o),o=new no(t),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=t.matrix,o.hiddenMatrix=t.hiddenMatrix),o.expand(),e+=1,t=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return v_(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}};var xi=require("three");var Gl=require("three");var io=require("three");var Ze=require("three"),Ho=new Ze.Vector3,qo=new Ze.Vector3,Jn=new Ze.Matrix4,oh=[new Ze.Vector3(-1,1,1),new Ze.Vector3(-1,-1,1),new Ze.Vector3(1,-1,1),new Ze.Vector3(1,1,1),new Ze.Vector3(-1,1,-1),new Ze.Vector3(-1,-1,-1),new Ze.Vector3(1,-1,-1),new Ze.Vector3(1,1,-1)],b_=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],S_=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],rh=(n,r,e)=>{n.updateEntityBoxSize(Ho,qo),Jn.copy(r).multiply(n.matrixWorld),qo.x===0&&qo.y===0&&qo.z===0?e.push(new Ze.Vector3(Ho.x,Ho.y,Ho.z).applyMatrix4(Jn)):oh.forEach(t=>{e.push(t.clone().multiply(qo).add(Ho).applyMatrix4(Jn))})},ws=class extends Ze.Box3{constructor(){super(...arguments);this.matrix=new Ze.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Ze.Matrix4().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 Ze.Vector3);return}rh(s,t,i)}}):rh(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(Jn.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(qo).multiplyScalar(.5),this.getCenter(Ho),Jn.copy(this.matrix).setPosition(Ho),this.vertices=oh.map(e=>e.clone().multiply(qo).applyMatrix4(Jn))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=b_.map(([e,t])=>new Ze.Line3(this.vertices[e],this.vertices[t])),this.centerEdges=this.edges.map(e=>e.getCenter(new Ze.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=S_.map(([e,t])=>this.vertices[e].clone().add(this.vertices[t]).multiplyScalar(.5))}};var gr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var mt=require("three"),Qc=class extends mt.CurvePath{constructor(){super()}getPoints(r=12){let e=[],t,o=this.getCurveLengths(),s=o[o.length-1]/o.length;for(let l=0,c=this.curves;l<c.length;l++){let u=c[l],a=l===0?o[l]:o[l]-o[l-1],d=Math.ceil(r*a/s),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 Jc=.001;function ed(n,r,e){return r.clone().sub(n).cross(r.clone().sub(e)).length()<=Jc}function Zc(n,r){let e=new mt.Vector3(...n.position),t=new mt.Vector3(...n.controlNext.position),o=new mt.Vector3(...r.controlPrevious.position),i=new mt.Vector3(...r.position);return ed(e,t,i)&&ed(e,o,i)}function vl(n){let r=n.points.map(a=>new mt.Vector3(...a.data.position)),e=[n.points[0]],t=new mt.Vector3(...e[0].data.position);for(let a=0;a<n.points.length-1;a++)ed(t,r[a],r[a+1])||(e.push(n.points[a]),t=r[a]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),s=e.length,l=[];for(let a=0;a<s;a++){let d=e[a].data,p=new mt.Vector3(...d.position),f=new mt.Vector3(...d.controlPrevious.position),m=new mt.Vector3(...d.controlNext.position),h={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:m};if(d.roundness===0||!n.isClosed&&(a===0||a===s-1)){l[a]={...h,removedLength:0};continue}let y=o&&a==0?s-1:a-1,g=o&&a==s-1?0:a+1,v=e[y].data,b=e[g].data,w=new mt.Vector3(...v.position),S=new mt.Vector3(...b.position),P=w.clone().sub(p).normalize(),_=S.clone().sub(p).normalize();Object.assign(h,{prevDir:P,nextDir:_});let x=Zc(v,d),C=Zc(d,b);if(!x||!C)l[a]={...h,removedLength:0};else{let T=P.clone().add(_).normalize(),N=T.clone().cross(P).length()/P.dot(T);l[a]={...h,tan:N,removedLength:d.roundness/N}}}for(let a=0;a<i;a++){let d=a,p=o&&a===s-1?0:a+1,f=l[d],m=l[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 a=0;a<i;a++){let d=a,p=o&&a===s-1?0:a+1,f=l[d],m=l[p],h=null;if(!Zc(e[d].data,e[p].data))f.position.distanceTo(m.position)>Jc&&(h=new mt.CubicBezierCurve3(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)>Jc&&(h=new mt.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}c[2*a+1]=h}for(let a=0;a<s;a++){let d=l[a];if(d.removedLength===0){c[2*a]=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),v=f.distanceTo(m)/2,b=y.clone().multiplyScalar(Math.sqrt(Math.pow(h,2)-Math.pow(v,2))).add(g),w=y.clone().multiplyScalar(-h).add(b),S=p.distanceTo(w)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),_=P.clone().lerp(w,2),x=f.clone().lerp(P,4/3),C=m.clone().lerp(_,4/3);c[2*a]=new mt.CubicBezierCurve3(f,x,C,m)}let u=new Qc;return c.forEach(a=>{a&&u.add(a)}),u}var Re;(r=>{function n(e){return e&&e.__isEntity}r.is=n})(Re||(Re={}));var _s=n=>Re.is(n),w_={type:"completeState",isfromEntity:!0},bl=n=>class extends Qn(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 ws;this._recursiveBBox=new ws;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(Re.is(o))return o}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(Re.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)Uo.toOps(this.data,s.data).forEach(c=>{let u=Ua.replaceProps(c,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(t!==null){let s=this.data.states.data(t);s&&(this.dataPatched=Uo.patch(this.data,s),Uo.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=>{_s(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(Re.is(o[i]))return o[i];if(Re.is(t))return t.traverseSortNextHelper()}}sortNext(){let t=this.children;return this.children.length>0&&Re.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)_s(o)&&t(o)}traverseEntityAncestors(t){this.traverseAncestors(o=>{Re.is(o)&&t(o)})}traverseEntity(t,o=0){if(t(this,o)!==!0)for(let s of this.children)_s(s)&&s.traverseEntity(t,o+1)}traverseVisibleEntity(t){t(this);for(let o of this.children)_s(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=>_s(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 En(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??bo.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)Re.is(t)&&t.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(t=>{Re.is(t)&&t.disposeRecursively()})}toState(t=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(t)};return En(o,t)}updateByOp(t,o,i,s){let l=this.data;this.data=o;let c=t,u=fr(t.path,["states","*"]);if(u!==null){if(t.type===0){let[a]=u;if(this?.stateSelection===a){let d={...t.props};if(Object.values(t.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=Ct.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 a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:p,...f}=a;a=f}if(t.props.material!==void 0&&"material"in a){let{material:p,...f}=a;a=f}let d=Ct.removeOverridden(t.path,t.props,a);c={...t,props:d}}}if(this.updateByPatchedOpBase(c,Uo.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),fr(t.path,["overrides"])){let a=[],d=[...t.path];for(a.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)a.push(d[1]),d.splice(0,2);if(a[a.length-1]===void 0){if(t.type===0)for(let p of Object.keys(t.props)){a[a.length-1]=p;let f=i.scene.findInstance([this.uuid,...a]);f&&(f.overrideData=t.props[p],f.updateState(ro.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...a]);if(p){let f=Ct.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=$n.resolve(o.overrides,a),p.updateByOp(t,St.applySimple(p.data,t),i,!1)}}}else if(this.instances.length>0){let a;if(t.path.length===0&&t.type===0){let d;for(let p of wo.rootOverrideProps)p in t.props&&(d===void 0&&(d={}),d[p]=t.props[p]);d&&(a={...t,props:d})}else for(let d of wo.rootOverrideProps)if(fr(t.path,[d])){a=t;break}a!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=ro.filterOp(d.overrideData,a);p&&d.updateByOp(p,St.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=ro.filterOp(d.overrideData,t);if(p){let f;l===d.data&&t===p?f=o:f=St.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&&!mr.is(t.props.type)&&gr.changeEntityProptotype(this,o,i);else if(t.path.length===1&&t.path[0]==="geometry"&&t.type===0&&"type"in t.props){gr.changeEntityProptotype(this,o,i);for(let s of this.children)Re.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),fr(t.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),fr(t.path,["cloner"])!==null){let s=St.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,l=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,a=vl(u.geometry.path),d=(i+s)%1;i+s===1&&d===0&&(d=1);let p=a.getPointAt(d),f=this.parent?this.parent?.matrixWorld:new io.Matrix4;c.updateMatrixWorld();let m=new io.Matrix4().multiplyMatrices(f.clone().invert(),c.matrixWorld);p.applyMatrix4(m);let h={position:p.toArray(),rotation:u.rotation};if(l==="tangential"){let y=new io.Matrix4().extractRotation(c.matrixWorld),g=a.getTangentAt(d).applyMatrix4(y).add(p),v=new io.Matrix4().lookAt(p,g,new io.Vector3(0,1,0)),b=new io.Euler().setFromRotationMatrix(v);h={...h,rotation:[b.x,b.y,b.z]}}this.updateTransformState(h),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(w_)})}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()),"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 gr.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 gr.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)}};var sh=require("three");var He=require("three"),ih=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:l,thetaLength:c,radiusTop:u,radiusBottom:a,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,m;return d||f?m=new Ps(u,a,t,o,i,s,l,c*Math.PI/180,d,d,p,f):m=new He.CylinderGeometry(u,a,t,o,i,s,l,c*Math.PI/180),m.scale(1,1,e/r),Object.assign(m,{userData:{...n,type:"CylinderGeometry"}})}};function _o(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function nh(n){return new He.Vector2(n.y,-n.x)}var Ps=class extends He.BufferGeometry{constructor(r,e,t,o,i,s,l,c,u,a,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,s=s!==void 0?s:!1,l=l!==void 0?l:0,c=c!==void 0?c:Math.PI*2,s&&(u=0,a=0);let m=[],h=[],y=[],g=[],v=0,b=t/2,w=new He.Vector3,S=new He.Vector3;f&&r==0&&(r=u),f&&e==0&&(e=a);let P=new He.Vector2(r,b),_=new He.Vector2(e,-b),x=null,C=null,T=null,N=null,O=P.clone().sub(_),A=0,R=0,k=0;p>0&&(A=Math.min(r,e)*(1-p),R=r-A,k=e-A);let $=P.clone();$.x-=A;let te=Math.PI-O.angle(),Y=O.angle(),W=Math.tan(Y/2),H=Math.tan(te/2),V=W+H,G=p?V:H,B=p?V:W;if(u=Math.min(u,(r-R)/G,O.length()/V),a=Math.min(a,(e-k)/B,O.length()/V),u>0){let F=u/W;x=P.clone().sub(new He.Vector2(F,u)),p&&(T=x.clone(),T.x-=A-V*u),P.sub(O.clone().setLength(F))}if(a>0){let F=a/H;C=_.clone().sub(new He.Vector2(F,-a)),_.add(O.clone().setLength(F)),p&&(N=C.clone(),N.x-=A-V*a,$.sub(O.clone().setLength(F)))}O=P.clone().sub(_);let L=O.length()<.5,D=[];for(let F=0;F<=o;F++){let M=[],Q=F/o,re=Q*c+l,oe=new He.Vector2(Math.sin(re),Math.cos(re));N&&C?(X(M,Q,oe,te,a,N,-1,!0),X(M,Q,oe,Y,a,C,-1,!1)):C?(q(M,oe,C.x,0,-1),X(M,Q,oe,Y,a,C,-1,!1)):s||q(M,oe,e,k,-1);let K=nh(O).normalize();if(_o(K,oe,w),!L)for(let ee=0;ee<=i;ee++){let J=ee/i,se=O.clone().multiplyScalar(J).add(_);_o(se,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(v++)}if(T&&x?(X(M,Q,oe,te,u,x,1,!1),X(M,Q,oe,Y,u,T,1,!0)):x?(X(M,Q,oe,te,u,x,1,!1),q(M,oe,x.x,0,1)):s||q(M,oe,r,R,1),p&&!L){let ee=nh(O).multiplyScalar(-1).normalize();_o(ee,oe,w);for(let J=0;J<=i;J++){let se=J/i,de=O.clone().multiplyScalar(-se).add($);_o(de,oe,S),h.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z),g.push(Q,.5+S.y/t),M.push(v++)}}p&&!s&&M.push(M[0]),D.push(M)}for(let F=0;F<D.length-1;F++)for(let M=0;M<D[0].length-1;M++){if(s&&p&&M==i)continue;let Q=D[F][M],re=D[F+1][M],oe=D[F+1][M+1],K=D[F][M+1],ee=h[oe*3+0],J=h[oe*3+2];m.push(Q,re,K),(ee!=0||J!=0)&&m.push(re,oe,K)}c<Math.PI*2&&(j(-1,D[0],l),j(1,D[D.length-1],l+c)),this.setIndex(m),this.setAttribute("position",new He.Float32BufferAttribute(h,3)),this.setAttribute("normal",new He.Float32BufferAttribute(y,3)),this.setAttribute("uv",new He.Float32BufferAttribute(g,2));function X(F,M,Q,re,oe,K,ee,J){for(let se=0;se<d+1;se++){let de=se/d,ae=ee<0?de:1-de;J&&(ae-=1),ae*=re;let me=new He.Vector2(Math.sin(ae),Math.cos(ae)*ee),Ye=me.clone().multiplyScalar(oe).add(K);_o(Ye,Q,S),h.push(S.x,S.y,S.z),_o(me,Q,w),y.push(w.x,w.y,w.z),g.push(M,.5+S.y/t),F.push(v++)}}function q(F,M,Q,re,oe){let K=new He.Vector3,ee=new He.Vector2,J=[Q,re];oe<0&&J.reverse();for(let se of J)ee.set(se,b*oe),_o(ee,M,K),h.push(K.x,K.y,K.z),y.push(0,oe,0),g.push(.5,.5),F.push(v++)}function j(F,M,Q){let re=new He.Vector2(Math.sin(Q),Math.cos(Q)),oe=new He.Vector2(-Math.cos(Q),Math.sin(Q)),K=new He.Vector3,ee=F<0?(de,ae,me)=>m.push(de,ae,me):(de,ae,me)=>m.push(de,me,ae),J=new He.Vector2((r+e+R+k)/4,0);_o(J,re,K),h.push(K.x,K.y,K.z),y.push(oe.x,0,oe.y),g.push(.5,.5);let se=v++;for(let de of M){let ae=h.slice(de*3,de*3+3);h.push(...ae),y.push(oe.x,0,oe.y);let me=g.slice(de*2,de*2+2);g.push(...me),v++}for(let de=se+1;de<v-1;de++)ee(se,de,de+1);ee(se,v-1,se+1)}}};var ah=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:l,thetaLength:c,cornerRadiusTop:u,cornerRadiusBottom:a,cornerSegments:d}=n.parameters,p;return u>0||a>0||c<360?p=new Ps(0,r/2,t,o,i,s,l,c*Math.PI/180,u,a,d,0,!0):p=new sh.ConeGeometry(r/2,t,o,i,s),p.scale(1,1,e/r),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};var jt=require("three"),lh=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:l,cornerSegments:c}=n.parameters,u;return l==0?u=new jt.BoxGeometry(r,e,t,o,i,s):u=new rd(r,e,t,o,i,s,l,c),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},td=Math.PI/2,rd=class extends jt.BufferGeometry{constructor(r=1,e=1,t=1,o=1,i=1,s=1,l=0,c=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),s=Math.floor(s),c=Math.floor(c),l=Math.min(l,r/2,e/2,t/2);let a=[],d=[],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),l>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),v(1,1,1),v(-1,1,1),v(1,-1,1),v(-1,-1,1),v(1,1,-1),v(-1,1,-1),v(1,-1,-1),v(-1,-1,-1)),this.setIndex(a),this.setAttribute("position",new jt.Float32BufferAttribute(d,3)),this.setAttribute("normal",new jt.Float32BufferAttribute(p,3)),this.setAttribute("uv",new jt.Float32BufferAttribute(f,2));function y(b,w,S,P,_,x,C,T,N,O,A){let R=(x-2*l)/N,k=(C-2*l)/O,$=x/2-l,te=C/2-l,Y=T/2,W=N+1,H=O+1,V=0,G=0,B=new jt.Vector3;for(let L=0;L<H;L++){let D=L*k-te;for(let X=0;X<W;X++){let q=X*R-$;B[b]=q*P,B[w]=D*_,B[S]=Y,d.push(B.x,B.y,B.z),B[b]=0,B[w]=0,B[S]=T>0?1:-1,p.push(B.x,B.y,B.z),f.push(X/N),f.push(1-L/O),V+=1}}for(let L=0;L<O;L++)for(let D=0;D<N;D++){let X=m+D+W*L,q=m+D+W*(L+1),j=m+(D+1)+W*(L+1),F=m+(D+1)+W*L;a.push(X,q,F),a.push(q,j,F),G+=6}u.addGroup(h,G,A),h+=G,m+=V}function g(b,w,S,P,_,x,C,T,N,O,A){let R=(C-2*l)/O,k=C/2-l,$=T/2-l,te=N/2,Y=O+1,W=0,H=0,V=new jt.Vector3,G=new jt.Vector3;for(let B=0;B<c+1;B++){let L=B/c*td,D=Math.sin(L)*l,X=(1-Math.cos(L))*l,q=Math.sin(L),j=Math.cos(L);V[w]=($+D)*_,V[S]=(te-X)*x,G[b]=0,G[w]=q*Math.sign(V[w]),G[S]=j*Math.sign(V[S]);for(let F=0;F<Y;F++){let M=F*R-k;V[b]=M*P,d.push(V.x,V.y,V.z),p.push(G.x,G.y,G.z),f.push(F/O),f.push(0),W+=1}}for(let B=0;B<c;B++)for(let L=0;L<O;L++){let D=m+L+Y*B,X=m+L+Y*(B+1),q=m+(L+1)+Y*(B+1),j=m+(L+1)+Y*B;a.push(D,X,j),a.push(X,q,j),H+=6}u.addGroup(h,H,A),h+=H,m+=W}function v(b,w,S){let P=new jt.Vector3,_=new jt.Vector3(r/2,e/2,t/2);_.subScalar(l);let x=[],C=b*w*S>0?(N,O,A)=>a.push(N,O,A):(N,O,A)=>a.push(N,A,O);for(let N=0;N<=c;N++){let O=[],A=td*(1-N/c),R=Math.cos(A),k=Math.sin(A),$=0;for(let te=0;te<=N;te++){let Y=Math.cos($),W=Math.sin($);P.x=R*Y,P.y=k,P.z=R*W;let H=_.clone().addScaledVector(P,l);d.push(b*H.x,w*H.y,S*H.z),p.push(b*P.x,w*P.y,S*P.z),f.push(0,0),O.push(m++),$+=td/N}x.push(O)}let T=x.length-1;for(let N=0;N<T;N++){let O=x[N],A=x[N+1],R=O.length-1;C(O[0],A[1],A[0]);for(let k=1;k<=R;k++)C(O[k-1],O[k],A[k]),C(O[k],A[k+1],A[k])}}}};var Qe=require("three"),Po=class extends Qe.BufferGeometry{constructor(r=[],e=[],t="",o=1,i=.2,s=4){super(),this.type="PolyhedronGeometryRound";let l=[],c=[],u=[];a(),d(),this.setAttribute("position",new Qe.Float32BufferAttribute(l,3)),this.setAttribute("normal",new Qe.Float32BufferAttribute(u,3)),this.setAttribute("uv",new Qe.Float32BufferAttribute(c,2));return;function a(){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 Qe.Vector3,h=m.clone(),y=new Qe.Triangle,g=i*o,v=o-g,b=s+1,w=new Qe.Vector3,S=(W,H)=>w.subVectors(W,H).normalize(),P=(W,H)=>Array(W).fill(void 0).map(H),_=P(r.length/3,(W,H)=>new Qe.Vector3().fromArray(r,H*3).setLength(o)),x=[],C=1e6;for(let W=0;W<_.length;W++){let H=_[W],V=[],G,B,L,D=1e10,X=-1;for(;(X=e.indexOf(W,X+1))!=-1;){let M=X-X%3;G=e[M+(X+1)%3],B=e[M+(X+2)%3],L=H.distanceToSquared(_[G]),D=Math.min(D,L),V.push([G,B,L])}D+=1e-6;let q=[],j=0,F=V.length;for(let M=0;M<F;M++){[G,B,L]=V[j];let Q=x[G]?.includes(W)==!0;L<=D&&q.push(G+ +Q*C),j=V.findIndex(re=>re[0]==B)}x.push(q)}let T=[];{let W=0,H=0,V,G,B=f==3;for(let L=0;L<=s;L++){V=L*(L+1)/2,G=(L+1)*(L+2)/2;for(let D=0;D<s-L;D++)[W,H]=[V+D+L+2,G+D+L+3],T.push(V,G,...B?[H,V]:[W,G],H,W),[V,G]=[W,H];T.push(V,G,V+s+2)}}let N=m.clone(),O=m.clone(),A=m.clone(),R=m.clone(),k=m.clone(),$=[],te=P(_.length,()=>P(f,()=>m.clone()));for(let W=0;W<_.length;W++){m.copy(_[W]).normalize(),N.copy(m).multiplyScalar(v);let H=x[W];for(let q=0;q<H.length;q++){let j=H[q],F=H[(q+1)%f];y.setFromPointsAndIndices(_,W,j%C,F%C),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(N,te[W][q])}let V=[],G=[],B=[],L=new Qe.Vector3;s==0&&[...te[W]].reduce((q,j)=>q.add(j),L).multiplyScalar(1/f);for(let q=0;q<f;q++){let j=[],F=(q-1+f)%f,M=te[W][F],Q=te[W][q];m.copy(M).sub(N),h.copy(Q).sub(N);let re=N.angleTo(m),oe=m.angleTo(h),K=Math.cos(re)*g;s==0?O.copy(L):O.copy(N).setLength(v+K),G.push(K);let ee=[O,M,Q];for(let J=0;J<2;J++){let se=ee[J],de=ee[J+1];R.subVectors(se,N),k.subVectors(de,N),A.crossVectors(R,k).normalize();for(let ae=0;ae<b;ae++){let me=[re,oe][J]*ae/b;m.copy(R).applyAxisAngle(A,me).add(N),V.push(m.clone()),J&&(S(m,N),j.push([ae==0?se:m.clone(),w.clone()]))}J&&(S(de,N),j.push([de,w.clone()]))}B.push(j)}$.push(B);let D=2*b,X=2;for(let q=0;q<f;q++){let j=D*q,F=D*((q+1)%f),M=[V[j]];for(let re=1;re<b;re++){R=V[j+re],k=V[F+re],M.push(R);for(let oe=1,K=re-X+1;oe<=K;oe++)m.lerpVectors(R,k,oe/(K+1)),m.sub(N).setLength(G[q]).add(N),M.push(m.clone());M.push(k)}for(let re=0;re<b;re++)M.push(V[re+b+j]);M.push(V[F+b]);let Q=T.map(re=>M[re]);l.push(...Q.map(re=>[re.x,re.y,re.z]).flat()),u.push(...Q.map(re=>(S(re,N),[w.x,w.y,w.z])).flat())}}let Y=[];for(let W=0;W<x.length;W++)for(let H=0;H<f;H++){let V=x[W][H];if(V<C){let G=x[V].findIndex(D=>D%C==W),B=$[W][H],L=$[V][G];for(let D=0;D<b;D++){let X=B[D],q=L[b-D],j=B[D+1],F=L[b-(D+1)];[X,q,j,j,q,F].forEach(M=>{l.push(M[0].x,M[0].y,M[0].z),u.push(M[1].x,M[1].y,M[1].z)})}Y.push(B[0][0],L[b][0],B[b][0],L[0][0])}}for(;Y.length;){let W,H,V,G;[W,H]=Y.splice(0,2);let B=[W];for(;W!=H;)B.push(H),V=Y.indexOf(H),G=V%2,H=Y.splice(V-G,2)[1-G];w.subVectors(B[0],B[1]).cross(m.subVectors(B[0],B[2])).normalize();let L=w.dot(B[0])<0;L&&w.negate();for(let D=1;D<=B.length-2;D++)[B[D+ +L],B[D+1-+L],B[0]].forEach(X=>{l.push(X.x,X.y,X.z),u.push(w.x,w.y,w.z)})}}function d(){let p=new Qe.Vector3;for(let _=0;_<l.length;_+=3){p.x=l[_+0],p.y=l[_+1],p.z=l[_+2];let x=S(p)/2/Math.PI+.5,C=P(p)/Math.PI+.5;c.push(x,1-C)}let f=new Qe.Vector3,m=new Qe.Vector3,h=new Qe.Vector3,y=new Qe.Vector3,g=new Qe.Vector2,v=new Qe.Vector2,b=new Qe.Vector2,w=(_,x,C,T)=>{T<0&&_.x===1&&(c[x]=_.x-1),C.x===0&&C.z===0&&(c[x]=T/2/Math.PI+.5)};for(let _=0,x=0;_<l.length;_+=9,x+=6){f.set(l[_+0],l[_+1],l[_+2]),m.set(l[_+3],l[_+4],l[_+5]),h.set(l[_+6],l[_+7],l[_+8]),g.set(c[x+0],c[x+1]),v.set(c[x+2],c[x+3]),b.set(c[x+4],c[x+5]),y.copy(f).add(m).add(h).divideScalar(3);let C=S(y);w(g,x+0,f,C),w(v,x+2,m,C),w(b,x+4,h,C)}for(let _=0;_<c.length;_+=6){let x=c[_+0],C=c[_+2],T=c[_+4],N=Math.max(x,C,T),O=Math.min(x,C,T);N>.9&&O<.1&&(x<.2&&(c[_+0]+=1),C<.2&&(c[_+2]+=1),T<.2&&(c[_+4]+=1))}function S(_){return Math.atan2(_.z,-_.x)}function P(_){return Math.atan2(-_.y,Math.sqrt(_.x*_.x+_.z*_.z))}}}static fromJSON(r){return new Po(r.vertices,r.indices,r.radius,r.corner,r.cornerSides)}};var ch=require("three"),dh=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,l=o===0&&i!==0?new Ts(r*.5,i,s):new ch.DodecahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"DodecahedronGeometry"}})}},Ts=class extends Po{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],l=[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,l,c,r,e,t),this.type=c}static fromJSON(r){return new Ts(r.radius,r.corner,r.cornerSides)}};var Ae=require("three");var ge=require("three"),Os=1e-12,ei=class{constructor(r){this.position=new ge.Vector2;this.startPosition=new ge.Vector2;this.uuid=ge.MathUtils.generateUUID();this.position=r.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(r){this.position.copy(this.startPosition).add(r)}copy(r){return this.position.copy(r.position),this.startPosition.copy(r.startPosition),this}clone(){return new ei(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ti=class extends ei{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ti(this.parent).copy(this)}},xr=class extends ei{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ti(this),new ti(this))}static create(e,t){let o=new xr(e,new ge.Vector2(...t.position));return o.controls[0].position.set(...t.controlPrevious.position),o.controls[1].position.set(...t.controlNext.position),o.roundness=t.roundness,o.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,o}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let o=0,i=this.controls.length;o<i;o++){let 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 xr(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 ge.Vector2,t=new ge.Vector2){let[o,i]=this.computeTangents();return o&&i&&(uh(o,e),uh(i,t)),[e,t]}computeTangent(e=new ge.Vector2){let[t,o]=this.computeTangents();return t&&o&&e.copy(t).add(o).normalize(),e}computeNormal(e=new ge.Vector2){let[t,o]=this.computeNormals();return e.copy(t).add(o).normalize(),e}};function uh(n,r=new ge.Vector2){let e=n.length();return r.set(-n.y/e,n.x/e)}var nd=n=>n,ri=new ge.Vector2,Sl=new ge.Vector2,__=new ge.Vector2,P_=new ge.Vector2,T_=new ge.Vector2,O_=new ge.Vector2,fh=new ge.Vector3,mh=new ge.Vector3;function hh(n){let r=new ge.Vector2;r.addVectors(n.v0,ri.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new ge.Vector2;return e.addVectors(n.v2,Sl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new ge.CubicBezierCurve(n.v0,r,e,n.v2)}function As(n,r,e=Number.EPSILON){return Math.abs(n-r)<e}function A_(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function N_(n,r,e=Number.EPSILON){return n.distanceTo(r)<e}function id(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 yh(n,r,e){return ph(n,r)&&ph(r,e)&&od(n.position,r.position,e.position)}function od(n,r,e){return ri.copy(r).sub(n).cross(Sl.copy(e).sub(n))===0}function gh(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,l=(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(l+c,s+u),o.set(l-c,s-u),[t,o]}function xh(n,r,e){let t=n.distanceTo(e),o=r.distanceTo(e);return t<o?r:n}function vh(n,r,e,t,o,i){let s=r.x-n.x,l=r.y-n.y,c=e.x-n.x,u=e.y-n.y,a=Math.sqrt((s+c)*(s+c)+(l+u)*(l+u)),d;return id(r,n,e)>Math.PI&&(a*=-1),As(u,l)?d=(l+u)*(t/a-.5)*8/3/(s-c):d=(s+c)*(t/a-.5)*8/3/(u-l),o.set(r.x-d*l,r.y+d*s),i.set(e.x+d*u,e.y-d*c),[o,i]}function sd(n,r){return n.position.equals(n.controls[1].position)&&r.position.equals(r.controls[0].position)}function ph(n,r){return od(n.position,n.controls[1].position,r.position)&&od(n.position,r.controls[0].position,r.position)}function bh(n,r,e,t,o=.5){let i=ri.subVectors(r,n).multiplyScalar(o).add(n),s=Sl.subVectors(e,r).multiplyScalar(o).add(r),l=__.subVectors(t,e).multiplyScalar(o).add(e),c=i,u=P_.subVectors(s,i).multiplyScalar(o).add(i),a=T_.subVectors(l,s).multiplyScalar(o).add(s),d=l,p=O_.subVectors(a,u).multiplyScalar(o).add(u);return[n.x,n.y,c.x,c.y,u.x,u.y,p.x,p.y,a.x,a.y,d.x,d.y,t.x,t.y]}function Sh(n,r,e=12,t=!0){let o=mh.set(0,0,0),i,s=0,l=[];for(let c=0;c<r.length;c++){let u=nd(r[c]),a=ri,d=To(u,e);l.push(d);for(let p=0;p<=d;p++)if(u instanceof ge.CubicBezierCurve||u instanceof ge.QuadraticBezierCurve||u instanceof ge.LineCurve){if(u.getPoint(p/d,a),o.set(a.x,a.y,0),i!==void 0&&N_(i,o))continue;i===void 0&&(i=fh),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 wh(n,r,e,t=12,o=!0){let i=mh.set(0,0,0),s=0,l=[];for(let c=0;c<r.length;c++){if(e[c]===!1)continue;let u,a=nd(r[c]),d=ri,p=To(a,t);l.push(p);for(let f=0;f<=p;f++)if(a instanceof ge.CubicBezierCurve||a instanceof ge.QuadraticBezierCurve||a instanceof ge.LineCurve){if(a.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=fh:(n.setXYZ(s,u.x,u.y,u.z),s++,n.setXYZ(s,i.x,i.y,i.z),s++),u.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++),l}function ad(n,r=12,e=!1){let t=[];for(let o=0,i=n.length;o<i;o++){let s=n[o],l=0;if(e&&s.roundedCurveCorner!==void 0){let c=To(s.roundedCurveCorner,r)*.5;o>0&&(t[o-1]+=c),l+=c}s.curveAfter!==void 0&&(l+=To(s.curveAfter,r)),t.push(l)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(t[n.length-1]+=To(n[0].roundedCurveCorner,r)*.5),t}function To(n,r=12){return n&&n instanceof ge.EllipseCurve?r*2:n&&(n instanceof ge.LineCurve||n instanceof ge.LineCurve3)?1:n&&n instanceof ge.SplineCurve?r*n.points.length:r}function _h(n,r,e=12,t=!0){let o,i=0;for(let s=0;s<r.length;s++){let l=nd(r[s]),c=To(l,e),u=ri;for(let a=0;a<=c;a++)if(l instanceof ge.CubicBezierCurve||l instanceof ge.QuadraticBezierCurve||l instanceof ge.LineCurve){if(l.getPoint(a/c,u),o!==void 0&&A_(o,u,Os))continue;o===void 0&&(o=Sl),o.copy(u),n.push(u.x,u.y),i++}}return As(n[0],n[n.length-2],Os)&&As(n[1],n[n.length-1],Os)&&(n.pop(),n.pop()),t&&i>1&&!(As(n[i-1],n[1],Os)&&As(n[i-2],n[0],Os))&&(n.push(n[0],n[1]),i++),n}var ld=new Ae.Vector2,C_=new Ae.Vector2,I_=new Ae.Vector2,M_=new Ae.Vector2,E_=new Ae.Vector2,L_=new Ae.Vector2,Oe=class extends Ae.Shape{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ae.Plane(new Ae.Vector3(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=Ae.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,o){let i=new Oe;return i.isClosed=e.isClosed,i.points=e.points.map(s=>xr.create(s.id,s.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(s=>Oe.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,l=this.shapeHoles.length;s<l;s++){let c=this.shapeHoles[s],u=c.points.length,a=c.getPointIndexById(e);if(a<0)i+=u;else return a+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],l=e-t;if(l<=s.points.length-1)return s.points[l];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],l=s.points.indexOf(e);if(l>=0)return t+l;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let o=ld.set(e,t);for(let i=0,s=this.points.length;i<s;i++){let l=this.points[i];l.position.multiply(o),l.controls[0].position.multiply(o),l.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=Ae.MathUtils.generateUUID()){let i;e instanceof Ae.Vector2?i=e:i=new Ae.Vector2(e,t);let s=new xr(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 Sh(e,o?this.roundedCurves:this.curves,t,this.autoClose),i.reduce((s,l)=>s+l,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=ad(this.points,e,!1),this.roundedCurveDivisions=ad(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,o=12){return wh(e,this.curves,t,o,this.autoClose).reduce((s,l)=>s+l,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),_h(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=To(this.points[0].roundedCurveCorner,this.subdivision)*.5);let l=e-s;l<0&&(l+=i.reduce((c,u)=>c+u,0));for(let c=0,u=i.length;c<u;c++){let a=i[c];if(l<o+a)return[c,(l-o+1)/a];o+=a}return[0,1]}getCurveT(e,t,o){let i=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],l=this.curveDivisions,c=l[e];if(sd(i,s)){let d=i.position.distanceTo(s.position);return i.position.distanceTo(ld.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=l[d];return(t-u)/c}dispose(){}_applyCurveForPoint(e,t){sd(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],l=this.points[o-1]??this.points[this.points.length-1],c=this.points[o+1]??this.points[0],u=s.roundness,a=l&&c&&yh(l,s,c);if(!s.controlsMoved()&&u>0&&!a){let d=s.curveBefore,p=s.curveAfter;if(d===void 0||p===void 0)continue;let f=s.roundedCurveBefore,m=s.roundedCurveAfter,h=d.getLength(),y=p.getLength(),g=Math.min(u,h*.499),v=Math.min(u,y*.499),b=Math.min(g,v),w=1-b/h,S=b/y,P=d.getPointAt(w,ld),_=p.getPointAt(S,C_);this._subSplitCurve(d,f,w,P,void 0),this._subSplitCurve(p,m,S,void 0,_);let x;if(this.useCubicForRoundedCorners){let C=id(P,s.position,_)/2,T=Math.tan(C)*P.distanceTo(s.position),[N,O]=gh(P,_,T,I_,M_),A=xh(N,O,s.position),[R,k]=vh(A,P,_,T,E_,L_);x=new Ae.CubicBezierCurve(P.clone(),R.clone(),k.clone(),_.clone())}else x=new Ae.QuadraticBezierCurve(P.clone(),s.position.clone(),_.clone());s.roundedCurveCorner=x,this.roundedCurves.splice(o+t,0,x),t++}}}}_subSplitCurve(e,t,o,i,s){if(e instanceof Ae.LineCurve)i!==void 0&&t.v2.copy(i),s!==void 0&&t.v1.copy(s);else{let l=e,c=t,u=l.getUtoTmapping(o,0),a=bh(l.v0,l.v1,l.v2,l.v3,u);return i!==void 0&&(c.v0.set(a[0],a[1]),c.v1.set(a[2],a[3]),c.v2.set(a[4],a[5]),c.v3.set(a[6],a[7])),s!==void 0&&(c.v0.set(a[6],a[7]),c.v1.set(a[8],a[9]),c.v2.set(a[10],a[11]),c.v3.set(a[12],a[13])),c}return t}clone(){let e=new Oe(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],l=e.points[i+1],c=e.points[i+2],u=e.points[i+3],a=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new xr(Ae.MathUtils.generateUUID(),new Ae.Vector2(s,l));f.controls[0].position.set(c,u),f.controls[1].position.set(a,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new Oe;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(i,s)=>{s instanceof Ae.CubicBezierCurve&&s.v3.equals(i.position)&&i.controls[0].position.copy(s.v2)},o=i=>{let s=[],l,c;for(l=0,c=i.length;l<c;l++)i[l]instanceof Ae.QuadraticBezierCurve&&(i[l]=hh(i[l]));for(l=0,c=i.length;l<c;l++){let d=i[l],p=l>0?i[l-1]:null,f;d instanceof Ae.CubicBezierCurve?(f=this.createPoint(d.v0),f.controls[1].position.copy(d.v1)):d instanceof Ae.LineCurve&&(f=this.createPoint(d.v1)),f!==void 0&&(p!==null&&t(f,p),s.push(f))}let u=i[i.length-1],a=!1;return u instanceof Ae.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),a=!0):u instanceof Ae.LineCurve&&u.v2.equals(s[0].position)&&(a=!0),this.isClosed=a,s};return this.points=o(e.curves),e instanceof Ae.Shape&&(this.shapeHoles=e.holes.map(i=>{let s=new Oe;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 dd=Math.PI*2;function cd({x:n,y:r},e,t,o,i){return{x:n*e+o,y:r*t+i}}function B_(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 Ph(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 D_(n,r,e,t,o,i,s,l,c,u){let a=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(s,2),f=Math.pow(l,2),m=a*d-a*f-d*p;m<0&&(m=0),m/=a*f+d*p,m=Math.sqrt(m)*(c===u?-1:1);let h=m*o/i*l,y=m*-i/o*s,g=h+(n+e)/2,v=y+(r+t)/2,b=(s-h)/o,w=(l-y)/i,S=(-s-h)/o,P=(-l-y)/i,_=Ph(1,0,b,w),x=Ph(b,w,S,P);return!u&&x>0&&(x-=dd),u&&x<0&&(x+=dd),{centerx:g,centery:v,ang1:_,ang2:x}}function Th({px:n,py:r,cx:e,cy:t,rx:o,ry:i,largeArcFlag:s,sweepFlag:l}){let c=[];if(o===0||i===0)return[];let u=(n-e)/2,a=(r-t)/2;if(u===0&&a===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(a,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=D_(n,r,e,t,o,i,u,a,s,l),{ang1:f,ang2:m}=p,{centerx:h,centery:y}=p,g=Math.abs(m)/(dd/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);m/=v;for(let b=0;b<v;b++)c.push(B_(f,m)),f+=m;return c.map(b=>{let{x:w,y:S}=cd(b[0],o,i,h,y),{x:P,y:_}=cd(b[1],o,i,h,y),{x,y:C}=cd(b[2],o,i,h,y);return{x1:w,y1:S,x2:P,y2:_,x,y:C}})}var $o=require("three");var Pe;(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"})(Pe||(Pe={}));var $e;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})($e||($e={}));function pe(n,r){if(!n)throw r||"Assertion Failed!"}var ce=function(){function n(){}return n.vertEq=function(r,e){return r.s===e.s&&r.t===e.t},n.vertLeq=function(r,e){return r.s<e.s||r.s===e.s&&r.t<=e.t},n.transLeq=function(r,e){return r.t<e.t||r.t===e.t&&r.s<=e.s},n.edgeGoesLeft=function(r){return n.vertLeq(r.Dst,r.Org)},n.edgeGoesRight=function(r){return n.vertLeq(r.Org,r.Dst)},n.vertL1dist=function(r,e){return Math.abs(r.s-e.s)+Math.abs(r.t-e.t)},n.edgeEval=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?o<i?e.t-r.t+(r.t-t.t)*(o/(o+i)):e.t-t.t+(t.t-r.t)*(i/(o+i)):0},n.edgeSign=function(r,e,t){pe(n.vertLeq(r,e)&&n.vertLeq(e,t));var o=e.s-r.s,i=t.s-e.s;return o+i>0?(e.t-t.t)*o+(e.t-r.t)*i:0},n.transEval=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?o<i?e.s-r.s+(r.s-t.s)*(o/(o+i)):e.s-t.s+(t.s-r.s)*(i/(o+i)):0},n.transSign=function(r,e,t){pe(n.transLeq(r,e)&&n.transLeq(e,t));var o=e.t-r.t,i=t.t-e.t;return o+i>0?(e.s-t.s)*o+(e.s-r.s)*i:0},n.vertCCW=function(r,e,t){return r.s*(e.t-t.t)+e.s*(t.t-r.t)+t.s*(r.t-e.t)>=0},n.interpolate=function(r,e,t,o){return r=r<0?0:r,t=t<0?0:t,r<=t?t===0?(e+o)/2:e+(o-e)*(r/(r+t)):o+(e-o)*(t/(r+t))},n.intersect=function(r,e,t,o,i){var s,l,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),l=n.edgeEval(t,e,o),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,e.s)):(s=n.edgeSign(r,t,e),l=-n.edgeSign(r,o,e),s+l<0&&(s=-s,l=-l),i.s=n.interpolate(s,t.s,l,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),l=n.transEval(t,e,o),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,e.t)):(s=n.transSign(r,t,e),l=-n.transSign(r,o,e),s+l<0&&(s=-s,l=-l),i.t=n.interpolate(s,t.t,l,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}(),wl=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}(),oi=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}(),Oh=function(){function n(){var r=new oi,e=new Ns,t=new wl(0),o=new wl(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 wl(0),t=new wl(1);r.Sym.side<r.side&&(r=r.Sym);var o=r.Sym.next;return t.next=o,o.Sym.next=e,e.next=r,r.Sym.next=t,e.Sym=t,e.Onext=e,e.Lnext=t,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,t.Sym=e,t.Onext=t,t.Lnext=e,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,e},n.prototype.splice_=function(r,e){var t=r.Onext,o=e.Onext;t.Sym.Lnext=e,o.Sym.Lnext=r,r.Onext=o,e.Onext=t},n.prototype.makeVertex_=function(r,e,t){var o=r;pe(o,"Vertex can't be null!");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e;var s=e;do s.Org=o,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(r,e,t){var o=r;pe(o,"Face can't be null");var i=t.prev;o.prev=i,i.next=o,o.next=t,t.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=t.inside;var 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 oi,e=new oi,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 oi;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 oi;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,l;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,l=r.next,l.prev=s,s.next=l},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,l,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&&(l=this.countFaceVerts_(e),c=this.countFaceVerts_(i.Lface),l+c-2<=r&&ce.vertCCW(t.Lprev.Org,t.Org,i.Lnext.Lnext.Org)&&ce.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,l,c,u;for(i=r,i=r;(o=i.next)!==r;i=o){pe(o.prev===i),c=o.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Lface===o),c=c.Lnext;while(c!==o.anEdge)}for(pe(o.prev===i&&o.anEdge===null),l=e,l=e;(s=l.next)!==e;l=s){pe(s.prev===l),c=s.anEdge;do pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c),pe(c.Org===s),c=c.Onext;while(c!==s.anEdge)}for(pe(s.prev===l&&s.anEdge===null),u=t,u=t;(c=u.next)!==t;u=c)pe(c.Sym.next===u.Sym),pe(c.Sym!==c),pe(c.Sym.Sym===c),pe(c.Org!==null),pe(c.Dst!==null),pe(c.Lnext.Onext.Sym===c),pe(c.Onext.Sym.Lnext===c);pe(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}(),Ah=function(){function n(){this.handle=null}return n}(),Nh=function(){function n(){this.key=null,this.node=0}return n}(),G_=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 Ah,this.handles[t]=new Nh;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,pe(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 Ah;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new Nh}return this.freeList===0?t=e:(t=this.freeList,this.freeList=this.handles[t].node),this.nodes[e].handle=t,this.handles[t].node=e,this.handles[t].key=r,this.initialized&&this.floatUp_(e),t},n.prototype.extractMin=function(){var r=this.nodes,e=this.handles,t=r[1].handle,o=e[t].key;return this.size>0&&(r[1].handle=r[this.size].handle,e[r[1].handle].node=1,e[t].key=null,e[t].node=this.freeList,this.freeList=t,--this.size,this.size>0&&this.floatDown_(1)),o},n.prototype.delete=function(r){var e=this.nodes,t=this.handles,o;pe(r>=1&&r<=this.max&&t[r].key!==null),o=t[r].node,e[o].handle=e[this.size].handle,t[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(t[e[o>>1].handle].key,t[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),t[r].key=null,t[r].node=this.freeList,this.freeList=r},n}(),ud=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}(),Ch=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),R_=function(){function n(r,e){this.frame=r,this.leq=e,this.head=new Ch,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 Ch;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}(),V_=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?ce.vertLeq(i.Org,s.Org)?ce.edgeSign(s.Dst,i.Org,s.Org)<=0:ce.edgeSign(i.Dst,s.Org,i.Org)>=0:ce.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return ce.edgeSign(i.Dst,o,i.Org)>=0;var l=ce.edgeEval(i.Dst,o,i.Org),c=ce.edgeEval(s.Dst,o,s.Org);return l>=c},n.deleteRegion=function(r,e){e.fixUpperEdge&&pe(e.eUp.winding===0),e.eUp.activeRegion=null,r.dict.delete(e.nodeUp)},n.fixUpperEdge=function(r,e,t){pe(e.fixUpperEdge),r.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=t,t.activeRegion=e},n.topLeftRegion=function(r,e){var t=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===t);if(e.fixUpperEdge){if(o=r.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(r,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(r){var e=r.eUp.Dst;do r=n.regionAbove(r);while(r.eUp.Dst===e);return r},n.addRegionBelow=function(r,e,t){var o=new ud;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 Pe.ODD:return(e&1)!==0;case Pe.NONZERO:return e!==0;case Pe.POSITIVE:return e>0;case Pe.NEGATIVE:return e<0;case Pe.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,l=e.eUp;s!==t;){if(s.fixUpperEdge=!1,i=n.regionBelow(s),o=i.eUp,o.Org!=l.Org){if(!i.fixUpperEdge){n.finishRegion(r,s);break}o=r.mesh.connect(l.Lprev,o.Sym),n.fixUpperEdge(r,i,o)}l.Onext!==o&&(r.mesh.splice(o.Oprev,o),r.mesh.splice(l,o)),n.finishRegion(r,s),l=i.eUp,s=i}return l},n.addRightEdges=function(r,e,t,o,i,s){var l,c,u,a,d=!0;u=t;do pe(ce.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,a=i;l=n.regionBelow(c),u=l.eUp.Sym,u.Org===a.Org;)u.Onext!==a&&(r.mesh.splice(u.Oprev,u),r.mesh.splice(a.Oprev,u)),l.windingNumber=c.windingNumber-u.winding,l.inside=n.isWindingInside(r,l.windingNumber),c.dirty=!0,!d&&n.checkForRightSplice(r,c)&&(n.addWinding(u,a),n.deleteRegion(r,c),r.mesh.delete(a)),d=!1,c=l,a=u;c.dirty=!0,pe(c.windingNumber-u.winding===l.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=ce.vertL1dist(e,r),i=ce.vertL1dist(t,r),s=.5*i/(o+i),l=.5*o/(o+i);r.coords[0]+=s*e.coords[0]+l*t.coords[0],r.coords[1]+=s*e.coords[1]+l*t.coords[1],r.coords[2]+=s*e.coords[2]+l*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(ce.vertLeq(o.Org,i.Org)){if(ce.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ce.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(ce.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(pe(!ce.vertEq(o.Dst,i.Dst)),ce.vertLeq(o.Dst,i.Dst)){if(ce.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(ce.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,l=i.Org,c=o.Dst,u=i.Dst,a,d,p=new oi,f,m;if(pe(!ce.vertEq(u,c)),pe(ce.edgeSign(c,r.event,s)<=0),pe(ce.edgeSign(u,r.event,l)>=0),pe(s!==r.event&&l!==r.event),pe(!e.fixUpperEdge&&!t.fixUpperEdge),s===l||(a=Math.min(s.t,c.t),d=Math.max(l.t,u.t),a>d))return!1;if(ce.vertLeq(s,l)){if(ce.edgeSign(u,s,l)>0)return!1}else if(ce.edgeSign(c,l,s)<0)return!1;return n.debugEvent(r),ce.intersect(c,s,u,l,p),pe(Math.min(s.t,c.t)<=p.t),pe(p.t<=Math.max(l.t,u.t)),pe(Math.min(u.s,c.s)<=p.s),pe(p.s<=Math.max(l.s,s.s)),ce.vertLeq(p,r.event)&&(p.s=r.event.s,p.t=r.event.t),f=ce.vertLeq(s,l)?s:l,ce.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ce.vertEq(p,s)||ce.vertEq(p,l)?(n.checkForRightSplice(r,e),!1):!ce.vertEq(c,r.event)&&ce.edgeSign(c,r.event,p)>=0||!ce.vertEq(u,r.event)&&ce.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):(ce.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),ce.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,s,c,l,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,s=n.regionBelow(e),l=e.eUp,c=s.eUp,u=!1;if(l.Dst!==c.Dst&&n.checkForIntersect(r,e),ce.vertEq(l.Org,r.event)&&(r.mesh.splice(i.Oprev,l),e=n.topLeftRegion(r,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(r,n.regionBelow(e),s),u=!0),ce.vertEq(c.Org,r.event)&&(r.mesh.splice(t,c.Oprev),t=n.finishLeftRegions(r,s,null),u=!0),u){n.addRightEdges(r,e,t.Onext,i,i,!0);return}ce.vertLeq(c.Org,l.Org)?o=c.Oprev:o=l,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,l,c;if(o=e.eUp,ce.vertEq(o.Org,t)){pe(!1),n.spliceMergeVertices(r,o,t.anEdge);return}if(!ce.vertEq(o.Dst,t)){r.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(r.mesh.delete(o.Onext),e.fixUpperEdge=!1),r.mesh.splice(t.anEdge,o),n.sweepEvent(r,t);return}pe(!1),e=n.topRightRegion(e),c=n.regionBelow(e),s=c.eUp.Sym,i=l=s.Onext,c.fixUpperEdge&&(pe(i!==s),n.deleteRegion(r,c),r.mesh.delete(s),s=i.Oprev),r.mesh.splice(t.anEdge,s),ce.edgeGoesLeft(i)||(i=null),n.addRightEdges(r,e,s.Onext,l,i,!0)},n.connectLeftVertex=function(r,e){var t,o,i,s,l,c,u=new ud;if(u.eUp=e.anEdge.Sym,t=r.dict.search(u).key,o=n.regionBelow(t),!!o){if(s=t.eUp,l=o.eUp,ce.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(r,t,e);return}if(i=ce.vertLeq(l.Dst,s.Dst)?t:o,t.inside||i.fixUpperEdge){if(i===t)c=r.mesh.connect(e.anEdge.Sym,s.Lnext);else{var a=r.mesh.connect(l.Dnext,e.anEdge);c=a.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);pe(o!==null);var i=n.regionBelow(o),s=i.eUp,l=n.finishLeftRegions(r,i,null);l.Onext===s?n.connectRightVertex(r,o,l):n.addRightEdges(r,o,l.Onext,s,s,!0)},n.addSentinel=function(r,e,t,o){var i=new ud,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 R_(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,l=r.bmax[1]+t;n.addSentinel(r,o,i,s),n.addSentinel(r,o,i,l)},n.doneEdgeDict=function(r){for(var e,t=0;(e=r.dict.min().key)!==null;)e.sentinel||(pe(e.fixUpperEdge),pe(++t===1)),pe(e.windingNumber===0),n.deleteRegion(r,e)},n.removeDegenerateEdges=function(r){var e,t,o,i=r.mesh.eHead;for(e=i.next;e!==i;e=t)t=e.next,o=e.Lnext,ce.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 G_(i,ce.vertLeq),o=r.mesh.vHead,t=o.next;t!==o;t=t.next)t.pqHandle=e.insert(t);return t!==o?!1:(e.init(),!0)},n.donePriorityQ=function(r){r.pq=null},n.removeDegenerateFaces=function(r,e){var t,o,i;for(t=e.fHead.next;t!==e.fHead;t=o)o=t.next,i=t.anEdge,pe(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),r.mesh.delete(i));return!0},n.computeInterior=function(r,e){e===void 0&&(e=!0);var t,o;if(n.removeDegenerateEdges(r),!n.initPriorityQ(r))return!1;for(n.initEdgeDict(r);(t=r.pq.extractMin())!==null;){for(;o=r.pq.min(),!(o===null||!ce.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}(),z_=function(){function n(){this.mesh=new Oh,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=Pe.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,l,c=[0,0,0],u=[0,0,0],a=[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 v=0;if(c[1]-u[1]>c[0]-u[0]&&(v=1),c[2]-u[2]>c[v]-u[v]&&(v=2),u[v]>=c[v]){r[0]=0,r[1]=0,r[2]=1;return}for(l=0,t=m[v],o=f[v],a[0]=t.coords[0]-o.coords[0],a[1]=t.coords[1]-o.coords[1],a[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]=a[1]*d[2]-a[2]*d[1],p[1]=a[2]*d[0]-a[0]*d[2],p[2]=a[0]*d[1]-a[1]*d[0],s=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],s>l&&(l=s,r[0]=p[0],r[1]=p[1],r[2]=p[2]);l<=0&&(r[0]=r[1]=r[2]=0,r[this.longAxis_(a)]=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 l=r.next;l!==r;l=l.next)l.s=this.dot_(l.coords,t),l.t=this.dot_(l.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(;ce.vertLeq(t.Dst,t.Org);t=t.Lprev);for(;ce.vertLeq(t.Org,t.Dst);t=t.Lnext);o=t.Lprev;for(var i=void 0;t.Lnext!==o;)if(ce.vertLeq(t.Dst,o.Org)){for(;o.Lnext!==t&&(ce.edgeGoesLeft(o.Lnext)||ce.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&&(ce.edgeGoesRight(t.Lprev)||ce.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,l=0,c;t>3&&r.mergeConvexFaces(t);for(var u=r.vHead.next;u!==r.vHead;u=u.next)u.n=-1;for(var a=r.fHead.next;a!==r.fHead;a=a.next)if(a.n=-1,!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;u.n===-1&&(u.n=l,l++),c++,i=i.Lnext}while(i!==a.anEdge);if(c>t)throw"Face vertex greater that support polygon";a.n=s,++s}this.elementCount=s,e===$e.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*t,this.vertexCount=l,this.vertices=[],this.vertices.length=l*o,this.vertexIndices=[],this.vertexIndices.length=l;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,a=r.fHead.next;a!==r.fHead;a=a.next)if(!!a.inside){i=a.anEdge,c=0;do{var u=i.Org;this.elements[p++]=u.n,c++,i=i.Lnext}while(i!==a.anEdge);for(var f=c;f<t;++f)this.elements[p++]=-1;if(e===$e.CONNECTED_POLYGONS){i=a.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==a.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 l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){o=t=l.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,a=0;i=0;for(var l=r.fHead.next;l!==r.fHead;l=l.next)if(!!l.inside){s=0,o=t=l.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,s++,t=t.Lnext;while(t!==o);this.elements[a++]=i,this.elements[a++]=s,i+=s}},n.prototype.addContour=function(r,e){this.mesh===null&&(this.mesh=new Oh),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=Pe.ODD),e===void 0&&(e=$e.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_(),V_.computeInterior(this,s);var l=this.mesh;return e===$e.BOUNDARY_CONTOURS?this.setWindingNumber_(l,1,!0):this.tessellateInterior_(l),s&&l.check(),e===$e.BOUNDARY_CONTOURS?this.outputContours_(l,o):this.outputPolymesh_(l,e,t,o),!0},n}();function vr(n){var r=n.windingRule,e=r===void 0?Pe.ODD:r,t=n.elementType,o=t===void 0?$e.POLYGONS:t,i=n.polySize,s=i===void 0?3:i,l=n.vertexSize,c=l===void 0?2:l,u=n.normal,a=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 z_;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(c||2,p[v]);return g.tesselate(e,o,s,c,a,m),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var yG=Pe.ODD,gG=Pe.NONZERO,xG=Pe.POSITIVE,vG=Pe.NEGATIVE,bG=Pe.ABS_GEQ_TWO,SG=$e.POLYGONS,wG=$e.CONNECTED_POLYGONS,_G=$e.BOUNDARY_CONTOURS;var Wo=require("three");var _l=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*_l.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*_l.eSize,o=new ArrayBuffer(t),i=Float32Array.BYTES_PER_ELEMENT,s=0,l=new Float32Array(o,s*i,3*r);s+=3*r;let c=new Float32Array(o,s*i,3*r);s+=3*r;let u=new Float32Array(o,s*i,2*r);l.set(this.positions.slice(0,this.size*3)),c.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=l,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)}},Cs=_l;Cs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Is={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},md={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},pd=(n,r)=>([e,t])=>(t<e&&(t+=r),(n>=e?n:n+r)<=t),ni=class extends Wo.BufferGeometry{constructor(e,t,o=0,i=12,s=3,l=Pe.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=o,this._curveSegments=i,this._bevelSegmentsInput=s,o<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(o,t/2-1e-12),this._bevelSegments=Math.floor(s));let c=this._shape.extractShapePointsToFlatArray([],i),u=this._shape.shapeHoles.map(_=>{let x=_.extractShapePointsToFlatArray([],i),C=[];for(let T=x.length-1;T>=1;T-=2){let N=x[T-1],O=x[T-0];C.push(N,O)}return C}),a;try{a=vr({windingRule:l,elementType:$e.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{a=Is}let d;try{d=vr({windingRule:Pe.ODD,elementType:$e.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{d=fd}if(!a)throw new Error("error generating geometry");let p=a.elementCount;if(d){a.elementCount+=d.elementCount;for(let _=0;_<d.elements.length;_++){let x=d.elements[_],C=_%2===0?a.vertexCount:0;a.elements.push(x+C)}for(let _=0;_<d.vertexIndices.length;_++){let x=d.vertexIndices[_],C=a.vertexCount;a.vertexIndices.push(x+C)}for(let _=0;_<d.vertices.length;_++){let x=d.vertices[_];a.vertices.push(x)}}let f=1/0,m=-1/0,h=1/0,y=-1/0;for(let _=0,x=a.vertexCount;_<x;_++){let C=_*2,T=a.vertices[C+0],N=a.vertices[C+1];T<f&&(f=T),T>m&&(m=T),N<h&&(h=N),N>y&&(y=N)}this._minX=f,this._minY=h,this._width=m-f,this._height=y-h,this._buffer=new Cs(this._computeBufferEstimatedSize(a));let g=[],v=[];for(let _=a.elementCount-1;_>=0;_--){let x=_>=p,C=_*2,T=a.elements[C+0],N=a.elements[C+1],O=T+N,A={start:T,count:N,normals:[],continuous:[],concave:[]},R=T,k=O-1,$=T+1,te=this._shape.roundedCurves.length;do{let V=R-T,G=a.vertices[k*2+0],B=a.vertices[k*2+1],L=a.vertices[R*2+0],D=a.vertices[R*2+1],X=a.vertices[$*2+0],q=a.vertices[$*2+1],j=L-G,F=D-B,M=Math.sqrt(j*j+F*F);j/=M,F/=M;let Q=L-X,re=D-q,oe=Math.sqrt(Q*Q+re*re);Q/=oe,re/=oe,A.normals[V*2+0]=-re,A.normals[V*2+1]=Q,A.concave[V]=j*re-F*Q>0;let K=a.vertexIndices[R];if(Array.isArray(K))A.continuous[V]=!1;else{let[ee,J]=this._shape.getCurveIndexFromVertexId(K-1,!0);if(J>0&&J<1)A.continuous[V]=!0;else{let se=J===1?ee+1:ee-1;se=(se+te)%te;let de=J===1?0:1,ae=this._shape.roundedCurves[ee].getTangent(J),me=this._shape.roundedCurves[se].getTangent(de);A.continuous[V]=ae.dot(me)>.95}}x&&(A.normals[V*2+0]*=-1,A.normals[V*2+1]*=-1),[k,R,$]=[R,$,$+1],$>=O&&($-=N)}while($!==T+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:a.vertices.slice(T*2,O*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((V,G)=>[G,G]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:a.vertices.slice(T*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let G=V/this._bevelSegments*Math.PI/2,B=(1-Math.cos(G))*this._bevelSize,L=[],D=[],X=[],q=[],j=0;for(let M=0;M<N;M++){let Q=M*2,re=(M-1+N)%N*2,oe=a.vertices[A.start*2+Q+0],K=a.vertices[A.start*2+Q+1],ee=-A.normals[re+0]*B,J=-A.normals[re+1]*B,se=-A.normals[Q+0]*B,de=-A.normals[Q+1]*B;if(A.concave[M]||!A.concave[M]&&x){let ae=Math.atan2(J,ee),me=Math.atan2(de,se);me>ae&&(me-=Math.PI*2);let Ye=me-ae;if(A.continuous[M]||x){let ve=ae+Ye/2,nt=Math.cos(ve)*B,Ie=Math.sin(ve)*B;L[2*j+0]=oe+nt*(x?-1:1),L[2*j+1]=K+Ie*(x?-1:1),q[j]=M,j++}else{let ve=Math.max(1,Math.floor(i/4*Math.abs(Ye)/Math.PI));for(let nt=0;nt<=ve;nt++){let Ie=ae+Ye*(nt/ve),Dt=Math.cos(Ie)*B,tr=Math.sin(Ie)*B;L[2*j+0]=oe+Dt,L[2*j+1]=K+tr,q[j]=M,j++}}}else L[2*j+0]=oe+ee,L[2*j+1]=K+J,q[j]=M,D[M]=j,j++,L[2*j+0]=oe,L[2*j+1]=K,q[j]=M,j++,L[2*j+0]=oe+se,L[2*j+1]=K+de,q[j]=M,X[M]=j,j++}let F=vr({windingRule:Pe.POSITIVE,elementType:$e.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[L],edgeCreateCallback:M=>{let re=M.Org.idx,oe=q[re],K=q[(re+1)%q.length];M.idx=[oe,K],M.Sym.idx=[K,oe]},vertexIdCallback:M=>{let Q=M.Lprev.idx;return[Q?Q[1]:0,M.idx?M.idx[0]:0]}});if(!F)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!F.vertexCount)break;for(let M=0;M<F.vertexIndices.length;M++){let[Q,re]=F.vertexIndices[M];if(Q===re)continue;let oe=re;re<Q&&(oe+=N);for(let K=Q;K<oe;K++){let ee=K%N,J=(K+1)%N;if(!A.continuous[ee]||!A.continuous[J]){F.vertexIndices[M]=[Q,ee],F.vertexIndices.splice(M+1,0,[J,re]),F.vertices.splice((M+1)*2,0,F.vertices[M*2],F.vertices[M*2+1]);break}}}Y.push({bevelI:V,angle:G,size:B,boundary:F,reverseMap:q,insetPoints:L})}let W=(V,G,B)=>{let L=0,D=V.boundary.vertexIndices.length;for(;L<D&&B(V.boundary.vertexIndices[G]);)G=(G+1)%D,L++;return L},H=g.length;for(let V=1;V<Y.length;V++){let G=Y[V-1],B=Y[V],L=G.boundary.vertexIndices.length,D=B.boundary.vertexIndices.length;if(!L||!D)break;let X=A.concave.length,q=0,j=pd(q,N);for(;!G.boundary.vertexIndices.filter(j).length||!B.boundary.vertexIndices.filter(j).length;)q++,j=pd(q,N);let F=G.boundary.vertexIndices.findIndex(j),M=B.boundary.vertexIndices.findIndex(j);do F=(F+1)%L;while(j(G.boundary.vertexIndices[F]));do M=(M+1)%D;while(j(B.boundary.vertexIndices[M]));q=(q+1)%N;let Q=q,re=this._buildBevelVert(A,G,(F-1+L)%L),oe=this._buildBevelVert(A,B,(M-1+D)%D),K=re,ee=oe,J,se,de=!1;do{j=pd(q,N);let ae=W(G,F,j),me=W(B,M,j),Ye=de;if(de=!1,ae&&!me){for(let ve=0;ve<ae;ve++)J=this._buildBevelVert(A,G,(F+ve)%L,ve/(ae-1)),g.push(K.topN,J.topP,ee.topN),g.push(J.bottomP,K.bottomN,ee.bottomN),K=J;de=!0}else if(!ae&&me)for(let ve=0;ve<me;ve++)se=this._buildBevelVert(A,B,(M+ve)%D,ve/(me-1)),g.push(ee.topN,K.topP,se.topP),g.push(K.bottomP,ee.bottomN,se.bottomP),ee=se;else if(ae&&me)if(J=this._buildBevelVert(A,G,F,0),se=this._buildBevelVert(A,B,M,0),Ye?(g.push(K.topN,se.topP,ee.topN),g.push(K.topN,J.topP,se.topP),g.push(se.bottomP,K.bottomN,ee.bottomN),g.push(se.bottomP,J.bottomP,K.bottomN)):(g.push(ee.topN,K.topN,J.topP),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,K.bottomN,ee.bottomN),g.push(J.bottomP,ee.bottomN,se.bottomP)),K=J,ee=se,ae===me)for(let ve=1;ve<ae;ve++)J=this._buildBevelVert(A,G,(F+ve)%L,ve/(ae-1)),se=this._buildBevelVert(A,B,(M+ve)%D,ve/(me-1)),g.push(K.topN,J.topP,ee.topN),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,K.bottomN,ee.bottomN),g.push(J.bottomP,ee.bottomN,se.bottomP),K=J,ee=se;else if(ae>me){let ve=ae/me,nt=0;for(let Ie=1;Ie<ae;Ie++)J=this._buildBevelVert(A,G,(F+Ie)%L,Ie/(ae-1)),g.push(K.topN,J.topP,ee.topN),g.push(J.bottomP,K.bottomN,ee.bottomN),K=J,Ie>(nt+1)*ve&&(nt++,se=this._buildBevelVert(A,B,(M+nt)%D,nt/(me-1)),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,ee.bottomN,se.bottomP),ee=se)}else{let ve=me/ae,nt=0;for(let Ie=1;Ie<me;Ie++)se=this._buildBevelVert(A,B,(M+Ie)%D,Ie/(me-1)),g.push(ee.topN,J.topP,se.topP),g.push(J.bottomP,ee.bottomN,se.bottomP),ee=se,Ie>(nt+1)*ve&&(nt++,J=this._buildBevelVert(A,G,(F+nt)%L,nt/(ae-1)),g.push(K.topN,J.topP,ee.topN),g.push(J.bottomP,K.bottomN,ee.bottomN),K=J)}F=(F+ae)%L,M=(M+me)%D,q=(q+1)%X}while(q!==Q)}if(this._buildWall(Y,A,g),x){let V=[];for(let G=g.length-1;G>=H+2;G-=3){let B=g[G-2],L=g[G-1],D=g[G-0];V.push(D,L,B)}g.splice(H,g.length-H,...V)}if(x){let V=[];for(let G=Y[Y.length-1].boundary.vertices.length-1;G>=1;G-=2){let B=Y[Y.length-1].boundary.vertices[G-1],L=Y[Y.length-1].boundary.vertices[G-0];V.push(B,L)}v.push(V)}if(!x){let V=Y[Y.length-1],G;try{G=vr({windingRule:Y.length>1?Pe.POSITIVE:Pe.ODD,elementType:$e.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...v]})}catch{G=md}if(!G)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:g.length});for(let B=0;B<G.elementCount*3;B+=3){let L=this._buildSurfaceVert(G,G.elements[B+0]),D=this._buildSurfaceVert(G,G.elements[B+1]),X=this._buildSurfaceVert(G,G.elements[B+2]);g.push(L.top,D.top,X.top),g.push(X.bottom,D.bottom,L.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new Wo.BufferAttribute(Uint32Array.from(g),1),w=new Wo.BufferAttribute(this._buffer.positions,3),S=new Wo.BufferAttribute(this._buffer.normals,3),P=new Wo.BufferAttribute(this._buffer.uvs,2);w.needsUpdate=!0,S.needsUpdate=!0,P.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",S),this.setAttribute("uv",P),this.setIndex(b)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,l=i.boundary.vertexCount;s<l;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%l);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}_buildSurfaceVert(e,t){let o=t.toString();if(o in this.vertexCache)return this.vertexCache[o];let i=e.vertices[t*2+0],s=e.vertices[t*2+1],l=(i-this._minX)/this._width,c=(s-this._minY)/this._height,u=this._buffer.get(2),a=u*3,d=u*2,p={top:u+0,bottom:u+1};return this._buffer.positions[a+0]=i,this._buffer.positions[a+1]=s,this._buffer.positions[a+2]=this._depth,this._buffer.normals[a+0]=0,this._buffer.normals[a+1]=0,this._buffer.normals[a+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this._buffer.positions[a+3]=i,this._buffer.positions[a+4]=s,this._buffer.positions[a+5]=0,this._buffer.normals[a+3]=0,this._buffer.normals[a+4]=0,this._buffer.normals[a+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c,this.vertexCache[o]=p,p}_buildBevelVert(e,t,o,i=1){let s=`${t.bevelI}:${o}`;if(s in this.vertexCache)return this.vertexCache[s];let[l,c]=t.boundary.vertexIndices[o],u,a,d,p;l!==c?(a=l,u=c,p=!1,d=e.continuous[a]&&e.continuous[u]):(u=l,a=(u-1+e.count)%e.count,p=e.concave[u]&&t.bevelI>0,d=e.continuous[u]||p);let f=Math.cos(t.angle),m=Math.sin(t.angle),h=o*2,y=u*2,g=a*2,v=t.boundary.vertices[h+0],b=t.boundary.vertices[h+1],w=(1-m)*this._bevelSize,S=(v-this._minX)/this._width,P=(b-this._minY)/this._height,_=e.normals[y+0],x=e.normals[y+1],C=e.normals[g+0],T=e.normals[g+1];if(p){let k=C-_,$=T-x;_=_+k*(1-i),x=x+$*(1-i);let te=Math.sqrt(_*_+x*x);_/=te,x/=te}let N=this._buffer.get(d?2:4),O=N*3,A=N*2,R={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1};return this._buffer.positions[O+0]=v,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=_*f,this._buffer.normals[O+1]=x*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=P,this._buffer.positions[O+3]=v,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=_*f,this._buffer.normals[O+4]=x*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=P,this._buffer.uvs[A+3]=S,d||(N+=2,O+=6,A+=4,R.topP=N+0,R.bottomP=N+1,this._buffer.positions[O+0]=v,this._buffer.positions[O+1]=b,this._buffer.positions[O+2]=this._depth-w,this._buffer.normals[O+0]=C*f,this._buffer.normals[O+1]=T*f,this._buffer.normals[O+2]=m,this._buffer.uvs[A+0]=S,this._buffer.uvs[A+1]=P,this._buffer.positions[O+3]=v,this._buffer.positions[O+4]=b,this._buffer.positions[O+5]=w,this._buffer.normals[O+3]=C*f,this._buffer.normals[O+4]=T*f,this._buffer.normals[O+5]=-m,this._buffer.uvs[A+2]=P,this._buffer.uvs[A+3]=S),this.vertexCache[s]=R,R}clone(){let e=new ni(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=to(this.userData),e}};var ii=class extends $o.BufferGeometry{constructor(e,t=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Pe.ODD;this.elementType=$e.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=t,this._triangulationOptions=Object.assign({windingRule:Pe.ODD,elementType:$e.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)),l,c=!0,u=!0,a,d;for(let m=0,h=i.length/2;m<h;m++){let y=m*2,g=i[y+0],v=i[y+1];if(a!==void 0&&g!==a&&(c=!1),d!==void 0&&v!==d&&(u=!1),a=g,d=v,!c&&!u)break}if(!c&&!u)try{l=vr({contours:[i,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{l=Is}let p=l?.vertexCount??1,f=l?.elementCount??1;if(this._positionAttribute=new $o.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new $o.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new $o.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new $o.BufferAttribute(new Uint32Array(f*3),1),l){let m=1/0,h=-1/0,y=1/0,g=-1/0;for(let w=0,S=p;w<S;w++){let P=w*2,_=l.vertices[P+0],x=l.vertices[P+1];_<m&&(m=_),_>h&&(h=_),x<y&&(y=x),x>g&&(g=x)}let v=h-m,b=g-y;for(let w=0,S=p;w<S;w++){let P=w*2,_=l.vertices[P+0],x=l.vertices[P+1],C=(_-m)/v,T=(x-y)/b;this._positionAttribute.setXYZ(w,_,x,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,C,T)}for(let w=0,S=f;w<S;w++){let P=w*3,_=l.elements[P+0],x=l.elements[P+1],C=l.elements[P+2];this._indexAttribute.setX(P+0,_),this._indexAttribute.setX(P+1,x),this._indexAttribute.setX(P+2,C)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(l?.elementCount??1)*3)}clone(){let e=new ii(this._shape,this._curveSegments);return e.userData=to(this.userData),e}};var si=class extends ni{constructor(e,t,o=0,i=12,s=3,l=Pe.ODD){super(e,t,o,i,s,l);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,t,o){let i=e[0];for(let s=0,l=i.boundary.vertexCount;s<l;s++){let c=this._buildBevelVert(t,i,s),u=this._buildBevelVert(t,i,(s+1)%l);o.push(u.topP,c.topN,c.bottomN),o.push(u.topP,c.bottomN,u.bottomP)}}clone(){let e=new si(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=to(this.userData),e}};var Ft=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:Pe.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,l=s?.roundness??e.roundness;s!==void 0&&(s instanceof Oe?(s.width!==t||s.height!==o)&&s.applySize(t,o):s=new Oe(t,o).fromJSON(s),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&s.update());let c=s??new Oe(t,o);return{parameters:Object.assign(e,{width:t,height:o,depth:i,roundness:l}),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 l;return r<=0?l=new ii(n.shape,o,{windingRule:s}):l=new si(n.shape,r,e,o,t,s),Object.assign(l,{userData:{...n,type:"VectorGeometry"}})}};var li=require("three"),Mh=Math.PI*2,ci=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 Oe?n.shape:new Oe,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:l,extrudeBevelSegments:c}=n.parameters,u=n.shape,a=r*.5,d=e*.5,p=j_(u,a,d,o*Math.PI/180,t,i);u.isClosed=!0,u.update();let f=Ft.create({shape:u,parameters:{subdivisions:p,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function j_(n,r,e,t,o,i){if(t>=Mh)return o>30||o%4===0?(k_(n,r,e,i),Math.round(o/4)):Ih(n,t,o,r,e,i);t=Math.max(t,.001);let s={x:0,y:e},l=t+Math.PI*.5,c={x:Math.cos(l)*r,y:Math.sin(l)*e},u=Th({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%u.length===0?F_(n,s.x,s.y,u,o,r,e,i):Ih(n,t,o,r,e,i)}function F_(n,r,e,t,o,i,s,l){let c=Math.round(o/t.length);n.addPoint(ai(r,e));for(let u=0,a=t.length;u<a;u++){let d=t[u],p=n.points[u],f=ai(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 l>0?Eh(n,i,s,l):n.addPoint(ai(0,0)),c}function Ih(n,r,e,t,o,i){let s=-r/e;for(let l=0;l<=e;l++){let c=s*l,u=Math.sin(c)*t,a=Math.cos(c)*o;n.addPoint(ai(u,a))}return r<Mh?i>0?Eh(n,t,o,i):n.addPoint(ai(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Lh(n,t,o,i)),1}function k_(n,r,e,t=0,o=0,i=0){let s=.5522847498,l=r*s,c=e*s;n.addPoint(Pl(o-r,i,o-r,i-c,o-r,i+c)),n.addPoint(Pl(o,i+e,o-l,i+e,o+l,i+e)),n.addPoint(Pl(o+r,i,o+r,i+c,o+r,i-c)),n.addPoint(Pl(o,i-e,o+l,i-e,o-l,i-e)),t>0&&Lh(n,r,e,t)}function ai(n,r){return new xr(li.MathUtils.generateUUID(),new li.Vector2(n,r))}function Pl(n,r,e,t,o,i){let s=ai(n,r);return s.controls[0].position.set(e,t),s.controls[1].position.set(o,i),s}function Eh(n,r,e,t){Bh(n,r,e,t).forEach(i=>n.addPoint(i))}function Lh(n,r,e,t){let o=Bh(n,r,e,t),i=new Oe;o.forEach(s=>i.addPoint(s)),i.isClosed=!0,n.shapeHoles.push(i)}function Bh(n,r,e,t){let o=t*r/100,i=o*(Math.abs(e)/Math.abs(r)),s=new li.Vector2(o/r,i/e),l=n.points.map(c=>{let u=c.clone();return u.uuid=li.MathUtils.generateUUID(),u}).reverse();return l.forEach(c=>{c.position.multiply(s);let u=c.controls[0].position.clone().multiply(s),a=c.controls[1].position.clone().multiply(s);c.controls[0].position.copy(a),c.controls[1].position.copy(u)}),l}var br=require("three"),Dh=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:l,pathType:c,pathSegments:u,cornerRadius:a,cornerSegments:d}=n.parameters,p=new Ms(!1,r,e,t,o,i,s,l,c,u,a,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},hd=new br.Uint32BufferAttribute([0,0,0],1),Ms=class extends br.BufferGeometry{constructor(r=!0,e=1,t=1,o=1,i=1,s=1,l=1,c=1,u=1,a=1,d=1,p=1){if(super(),s===0)return;let f=r&&s===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let m=()=>new br.Vector3,h=new br.Vector3,y=m(),g=m(),v=m(),b,w,S,P,_,x,C,T,N=m(),O=m(),A=m(),R=m(),k=m(),$=m(),te=m(),Y=m(),W=t-2*c+.001,H=W/s,V=Math.ceil(l*s),G=V+1,B=W/V,L=-W/2,D=a+1,X=2*Math.PI/a,q=Math.PI/2/p,j=.01,F=Math.min((1-d/100)*c,c-j),M=c-F,Q=0,re=2,oe=p*re+re,K=D*oe/re,ee=K+D*G,J=D*(G+oe),[se,de,ae]=[3,3,2].map(tt=>Array(J*tt).fill(0)),me=[],Ye=i-c;function ve(tt,$t){let Nr=Math.PI/2;x=$t*B,T=2*Math.PI*(x%H)/H+Nr,x+=L,C=Math.sin(T)*Ye,_=Math.cos(T)*Ye,r?tt.set(_,C,x):tt.set(_,x,C)}ve(h,-1e-10),ve(y,0),N.copy(h),ve(h,1);let nt=h.distanceTo(y),Ie=f?0:M+F,Dt=nt*V+2*Ie,tr=F,cn=Dt-Ie;for(let tt=0;tt<=V;tt++){ve(g,tt),Y.subVectors(g,N).normalize(),N.copy(g),$.copy(g).setComponent(+r+1,0).normalize(),te.crossVectors(Y,$).normalize();let $t=tt===0,Nr=tt===V,$g=$t?3*Math.PI/2:q,Yg=$t?tr:cn,Xg=$t?D:ee,Kg=$t?0:J-D,Zg=Y.clone().multiplyScalar($t?-M:M).add(g),Qg=Y.clone().multiplyScalar($t?-1:1).normalize();for(let Xr=0;Xr<D;Xr++){let yu=Xr*X;if(O.addVectors(h.copy($).multiplyScalar(c*Math.cos(yu)),y.copy(te).multiplyScalar(c*Math.sin(yu))),A.copy(O).normalize(),$t||Nr){f||(Q=Kg+Xr,[0,1,2].forEach(Gt=>{se[Q*3+Gt]=Zg.getComponent(Gt),de[Q*3+Gt]=Qg.getComponent(Gt)}),ae[Q*2]=+Nr,ae[Q*2+1]=Xr/a),y.copy(A).multiplyScalar(F),v.addVectors(g,y);for(let Gt=0;Gt<p;Gt++){let gc=Gt*q+$g;R.addVectors(h.copy(Y).multiplyScalar(M*Math.sin(gc)),y.copy(A).multiplyScalar(M*Math.cos(gc))),k.copy(R).normalize(),y.addVectors(v,R),R.normalize(),Q=Xg+Gt*D+Xr,[0,1,2].forEach(pa=>{se[Q*3+pa]=y.getComponent(pa),de[Q*3+pa]=k.getComponent(pa)});let Jg=+$t+Math.sin(gc);ae[Q*2]=(Yg+M*Jg)/Dt,ae[Q*2+1]=Xr/a}}y.addVectors(g,O),Q=K+tt*D+Xr,[0,1,2].forEach(Gt=>{se[Q*3+Gt]=y.getComponent(Gt),de[Q*3+Gt]=A.getComponent(Gt)}),ae[Q*2]=(Ie+tt*nt)/Dt,ae[Q*2+1]=Xr/a}}let Wt=G+2*p+re,ca=1,[da,ua]=[+f,Wt-1];for(let tt=da;tt<=ua-1;tt++){let $t=f&&tt===ua-1;for(let Nr=0;Nr<D-1;Nr++)b=tt*D+Nr,w=b+1,S=($t?Nr:b)+D,P=($t?Nr+1:w)+D,tt===0?me.push(w,P,S):tt===Wt-2?me.push(b,w,S):me.push(b,w,S,w,P,S)}this.setIndex(me),this.setAttribute("position",new br.Float32BufferAttribute(se,3)),this.setAttribute("normal",new br.Float32BufferAttribute(de,3)),this.setAttribute("uv",new br.Float32BufferAttribute(ae,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let r=this.userData.parameters,e=Math.ceil(r.tubularSegments),t=r.radialSegments+1,o=Array.from(this.getIndex().array),i,s,l,c,u=6*(e-1)*r.radialSegments,a=e,d=a===e;for(let p=0;p<r.radialSegments;p++)i=a*t+p,s=i+1,l=(d?p:i)+t,c=(d?p+1:s)+t,o[u++]=i,o[u++]=s,o[u++]=l,o[u++]=s,o[u++]=c,o[u++]=l;return o.length=u,hd.array=o,hd.count=o.length,hd}};var Gh=require("three");var Rh=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,l=o===0&&i!==0?new Es(r*.5,i,s):new Gh.IcosahedronGeometry(r*.5,o);return l.scale(1,e/r,t/r),Object.assign(l,{userData:{...n,type:"IcosahedronGeometry"}})}},Es=class extends Po{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],l="IcosahedronGeometry";super(i,s,l,r,e,t),this.type=l}static fromJSON(r){return new Es(r.radius,r.corner,r.cornerSides)}};var Tl=require("three"),Vh=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 Tl.Shape;o.moveTo(r[0].x,r[0].y),o.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);let i=new Tl.LatheGeometry(o.extractPoints(t).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};var Vr=require("three");var so=require("three");var ie=require("three"),Rr=new ie.Matrix4,yd=new ie.Object3D,Ol=new ie.Vector3,Oo=class extends ie.EventDispatcher{constructor(){super(),this.uuid=ie.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(r){let e=new ie.Matrix3().getNormalMatrix(r);for(let t=0,o=this.vertices.length;t<o;t++)this.vertices[t].applyMatrix4(r);for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let s=0,l=i.vertexNormals.length;s<l;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 Rr.makeRotationX(r),this.applyMatrix4(Rr),this}rotateY(r){return Rr.makeRotationY(r),this.applyMatrix4(Rr),this}rotateZ(r){return Rr.makeRotationZ(r),this.applyMatrix4(Rr),this}translate(r,e,t){return Rr.makeTranslation(r,e,t),this.applyMatrix4(Rr),this}scale(r,e,t){return Rr.makeScale(r,e,t),this.applyMatrix4(Rr),this}lookAt(r){return yd.lookAt(r),yd.updateMatrix(),this.applyMatrix4(yd.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,l=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 ie.Vector3().fromBufferAttribute(i,p)),l!==void 0&&e.colors.push(new ie.Color().fromBufferAttribute(l,p));function a(p,f,m,h){let y=l===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[m].clone()],g=s===void 0?[]:[new ie.Vector3().fromBufferAttribute(s,p),new ie.Vector3().fromBufferAttribute(s,f),new ie.Vector3().fromBufferAttribute(s,m)],v=new di(p,f,m,g,y,h);e.faces.push(v),c!==void 0&&e.faceVertexUvs[0].push([new ie.Vector2().fromBufferAttribute(c,p),new ie.Vector2().fromBufferAttribute(c,f),new ie.Vector2().fromBufferAttribute(c,m)]),u!==void 0&&e.faceVertexUvs[1].push([new ie.Vector2().fromBufferAttribute(u,p),new ie.Vector2().fromBufferAttribute(u,f),new ie.Vector2().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?a(t.getX(y),t.getX(y+1),t.getX(y+2),f.materialIndex):a(y,y+1,y+2,f.materialIndex)}else if(t!==void 0)for(let p=0;p<t.count;p+=3)a(t.getX(p),t.getX(p+1),t.getX(p+2));else for(let p=0;p<i.count;p+=3)a(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(Ol).negate(),this.translate(Ol.x,Ol.y,Ol.z),this}normalize(){this.computeBoundingSphere();let r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,o=new ie.Matrix4;return o.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let r=new ie.Vector3,e=new ie.Vector3;for(let t=0,o=this.faces.length;t<o;t++){let i=this.faces[t],s=this.vertices[i.a],l=this.vertices[i.b],c=this.vertices[i.c];r.subVectors(c,l),e.subVectors(s,l),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 ie.Vector3;if(r){let t=new ie.Vector3,o=new ie.Vector3;for(let i=0,s=this.faces.length;i<s;i++){let l=this.faces[i],c=this.vertices[l.a],u=this.vertices[l.b],a=this.vertices[l.c];t.subVectors(a,u),o.subVectors(c,u),t.cross(o),e[l.a].add(t),e[l.b].add(t),e[l.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 Oo;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 l=0,c=this.faces.length;l<c;l++){let u=new ie.Vector3,a={a:new ie.Vector3,b:new ie.Vector3,c:new ie.Vector3};i.push(u),s.push(a)}}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 l=this.faces[i],c=o.faceNormals[i],u=o.vertexNormals[i];c.copy(l.normal),u.a.copy(l.vertexNormals[0]),u.b.copy(l.vertexNormals[1]),u.c.copy(l.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 ie.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ie.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let o,i=this.vertices.length,s=this.vertices,l=r.vertices,c=this.faces,u=r.faces,a=this.colors,d=r.colors;e!==void 0&&(o=new ie.Matrix3().getNormalMatrix(e));for(let p=0,f=l.length;p<f;p++){let h=l[p].clone();e!==void 0&&h.applyMatrix4(e),s.push(h)}for(let p=0,f=d.length;p<f;p++)a.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let m=u[p],h,y,g=m.vertexNormals,v=m.vertexColors,b=new di(m.a+i,m.b+i,m.c+i);b.normal.copy(m.normal),o!==void 0&&b.normal.applyMatrix3(o).normalize();for(let w=0,S=g.length;w<S;w++)h=g[w].clone(),o!==void 0&&h.applyMatrix3(o).normalize(),b.vertexNormals.push(h);b.color.copy(m.color);for(let w=0,S=v.length;w<S;w++)y=v[w],b.vertexColors.push(y.clone());b.materialIndex=m.materialIndex+t,c.push(b)}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],v=[];for(let b=0,w=g.length;b<w;b++)v.push(g[b].clone());this.faceVertexUvs[p].push(v)}}}mergeMesh(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)}mergeVertices(r=4){let e={},t=[],o=[],i=Math.pow(10,r);for(let c=0,u=this.vertices.length;c<u;c++){let a=this.vertices[c],d=Math.round(a.x*i)+"_"+Math.round(a.y*i)+"_"+Math.round(a.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 s=[];for(let c=0,u=this.faces.length;c<u;c++){let a=this.faces[c];a.a=o[a.a],a.b=o[a.b],a.c=o[a.c];let d=[a.a,a.b,a.c];for(let p=0;p<3;p++)if(d[p]===d[(p+1)%3]){s.push(c);break}}for(let c=s.length-1;c>=0;c--){let u=s[c];this.faces.splice(u,1);for(let a=0,d=this.faceVertexUvs.length;a<d;a++)this.faceVertexUvs[a].splice(u,1)}let l=this.vertices.length-t.length;return this.vertices=t,l}setFromPoints(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){let o=r[e];this.vertices.push(new ie.Vector3(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],s,l;o&&o.length===e&&(s=[]),i&&i.length===e&&(l=[]);for(let c=0;c<e;c++){let u=r[c]._id;s&&s.push(o[u]),l&&l.push(i[u])}s&&(this.faceVertexUvs[0]=s),l&&(this.faceVertexUvs[1]=l)}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=[],l={},c=[],u={};for(let m=0;m<this.faces.length;m++){let h=this.faces[m],y=!0,g=!1,v=this.faceVertexUvs[0][m]!==void 0,b=h.normal.length()>0,w=h.vertexNormals.length>0,S=h.color.r!==1||h.color.g!==1||h.color.b!==1,P=h.vertexColors.length>0,_=0;if(_=a(_,0,0),_=a(_,1,y),_=a(_,2,g),_=a(_,3,v),_=a(_,4,b),_=a(_,5,w),_=a(_,6,S),_=a(_,7,P),t.push(_),t.push(h.a,h.b,h.c),t.push(h.materialIndex),v){let x=this.faceVertexUvs[0][m];t.push(f(x[0]),f(x[1]),f(x[2]))}if(b&&t.push(d(h.normal)),w){let x=h.vertexNormals;t.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&t.push(p(h.color)),P){let x=h.vertexColors;t.push(p(x[0]),p(x[1]),p(x[2]))}}function a(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 l[h]!==void 0||(l[h]=s.length,s.push(m.getHex())),l[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,s.length>0&&(r.data.colors=s),c.length>0&&(r.data.uvs=[c]),r.data.faces=t,r}clone(){return new Oo().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],v=[];for(let b=0,w=g.length;b<w;b++){let S=g[b];v.push(S.clone())}this.faceVertexUvs[p].push(v)}}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],v={};v.a=g.a.clone(),v.b=g.b.clone(),v.c=g.c.clone(),m.vertexNormals.push(v)}}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 l=r.skinWeights;for(let p=0,f=l.length;p<f;p++)this.skinWeights.push(l[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 a=r.boundingBox;a!==null&&(this.boundingBox=a.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 gd().fromGeometry(this),e=new ie.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",Al.call(new ie.BufferAttribute(t,3),r.vertices)),r.normals.length>0){let o=new Float32Array(r.normals.length*3);e.setAttribute("normal",Al.call(new ie.BufferAttribute(o,3),r.normals))}if(r.colors.length>0){let o=new Float32Array(r.colors.length*3);e.setAttribute("color",zh.call(new ie.BufferAttribute(o,3),r.colors))}if(r.uvs.length>0){let o=new Float32Array(r.uvs.length*2);e.setAttribute("uv",jh.call(new ie.BufferAttribute(o,2),r.uvs))}if(r.uvs2.length>0){let o=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",jh.call(new ie.BufferAttribute(o,2),r.uvs2))}e.groups=r.groups;for(let o in r.morphTargets){let i=[],s=r.morphTargets[o];for(let l=0,c=s.length;l<c;l++){let u=s[l],a=new ie.Float32BufferAttribute(u.data.length*3,3);a.name=u.name,i.push(Al.call(a,u.data))}e.morphAttributes[o]=i}if(r.skinIndices.length>0){let o=new ie.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",Fh.call(o,r.skinIndices))}if(r.skinWeights.length>0){let o=new ie.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",Fh.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 ie.BufferGeometry,t=r.geometry;if(r.isPoints||r.isLine){let o=new ie.Float32BufferAttribute(t.vertices.length*3,3),i=new ie.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",Al.call(o,t.vertices)),e.setAttribute("color",zh.call(i,t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){let s=new ie.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",U_.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}};Oo.prototype.isGeometry=!0;var gd=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 l=s[o];l.materialIndex!==i&&(i=l.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,l=r.morphTargets,c=l.length,u;if(c>0){u=[];for(let g=0;g<c;g++)u[g]={name:l[g].name,data:[]};this.morphTargets.position=u}let a=r.morphNormals,d=a.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:a[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 v=e[g];this.vertices.push(t[v.a],t[v.b],t[v.c]);let b=v.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let S=v.normal;this.normals.push(S,S,S)}let w=v.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=v.color;this.colors.push(S,S,S)}if(i===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new ie.Vector2,new ie.Vector2,new ie.Vector2))}if(s===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new ie.Vector2,new ie.Vector2,new ie.Vector2))}for(let S=0;S<c;S++){let P=l[S].vertices;u[S].data.push(P[v.a],P[v.b],P[v.c])}for(let S=0;S<d;S++){let P=a[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.c)}h&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(m[v.a],m[v.b],m[v.c])}return this.computeGroups(r),this.verticesNeedUpdate=r.verticesNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),this}},di=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 ie.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new ie.Color,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 U_(n){return this.array.set(n),this}function zh(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 ie.Color),r[e++]=i.r,r[e++]=i.g,r[e++]=i.b}return this}function jh(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 ie.Vector2),r[e++]=i.x,r[e++]=i.y}return this}function Al(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 ie.Vector3),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z}return this}function Fh(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 ie.Vector4),r[e++]=i.x,r[e++]=i.y,r[e++]=i.z,r[e++]=i.w}return this}var H_=["a","b","c"];function q_(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 vd(n,r,e,t,o,i){let s=Math.min(n,r),l=Math.max(n,r),c=s+"_"+l,u;if(t.has(c))u=t.get(c);else{let a=e[s],d=e[l];u={a,b:d,newEdge:null,faces:[]},t.set(c,u)}u.faces.push(o),i[n].edges.push(u),i[r].edges.push(u)}function W_(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],vd(s.a,s.b,n,t,s,e),vd(s.b,s.c,n,t,s,e),vd(s.c,s.a,n,t,s,e)}function Nl(n,r,e,t,o){n.push(new di(r,e,t,void 0,void 0,o))}function ui(n,r){return Math.abs(r-n)/2+Math.min(n,r)}function Cl(n,r,e,t){n.push([r.clone(),e.clone(),t.clone()])}var Il=class{constructor(r=1){this.subdivisions=r}modify(r){r instanceof so.BufferGeometry?r=new Oo().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 so.Vector3,t,o,i,s,l,c=r.vertices,u=r.faces,a=r.faceVertexUvs[0],d=a!==void 0&&a.length>0,p=[],f=new Map;W_(c,u,p,f);let m=[],h,y,g,v,b,w,S;for(let j of Array.from(f.keys())){for(y=f.get(j),g=new so.Vector3,b=3/8,w=1/8,S=y.faces.length,S!=2&&(b=.5,w=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(b),e.set(0,0,0),s=0;s<S;s++){for(v=y.faces[s],l=0;l<3&&(h=c[q_(v,H_[l])],!(h!==y.a&&h!==y.b));l++);h&&e.add(h)}e.multiplyScalar(w),g.add(e),y.newEdge=m.length,m.push(g)}let P,_,x,C,T,N,O,A=[];for(o=0,i=c.length;o<i;o++){for(N=c[o],T=p[o].edges,t=T.length,t==3?P=3/16:t>3&&(P=3/(8*t)),_=1-t*Number(P),x=P,t<=2&&(t==2?(_=3/4,x=1/8):t==1||t==0),O=N.clone().multiplyScalar(_),e.set(0,0,0),s=0;s<t;s++)C=T[s],h=C.a!==N?C.a:C.b,e.add(h);e.multiplyScalar(Number(x)),O.add(e),A.push(O)}let R=A.concat(m),k=A.length,$,te,Y,W=[],H=[],V,G,B,L,D=new so.Vector2,X=new so.Vector2,q=new so.Vector2;for(o=0,i=u.length;o<i;o++)v=u[o],$=Number(xd(v.a,v.b,f).newEdge)+k,te=Number(xd(v.b,v.c,f).newEdge)+k,Y=Number(xd(v.c,v.a,f).newEdge)+k,Nl(W,$,te,Y,v.materialIndex),Nl(W,v.a,$,Y,v.materialIndex),Nl(W,v.b,te,$,v.materialIndex),Nl(W,v.c,Y,te,v.materialIndex),d&&(V=a[o],G=V[0],B=V[1],L=V[2],D.set(ui(G.x,B.x),ui(G.y,B.y)),X.set(ui(B.x,L.x),ui(B.y,L.y)),q.set(ui(G.x,L.x),ui(G.y,L.y)),Cl(H,D,X,q),Cl(H,G,D,q),Cl(H,B,X,D),Cl(H,L,q,X));r.vertices=R,r.faces=W,d&&(r.faceVertexUvs[0]=H)}};var at=new Vr.Vector3,kh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,r){let e=n.geometry??r?.geometry??new Vr.BufferGeometry().copy(new Vr.BoxGeometry(100,100,100)),t;r===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(at),t={width:at.x,height:at.y,depth:at.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 Vr.BufferGeometry().copy(new Vr.BoxGeometry(100,100,100)),s=i.userData.parameters;s===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(at)):at.set(s.width,s.height,s.depth),(r!==at.x||e!==at.y||t!==at.z)&&i.scale(at.x===0?1:r/at.x,at.y===0?1:e/at.y,at.z===0?1:t/at.z);let l=i.originalGeometry;try{o>0?(l===void 0||s?.subdivisions!==o)&&(l===void 0&&(l=i),i=new Il(o).modify(l).toBufferGeometry()):(l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{l!==void 0&&(i=l),l=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return l!==void 0&&Object.assign(i,{originalGeometry:l}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,r,e){new Vr.BufferGeometryLoader(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(at);let s=100/at.x;Object.assign(i.parameters,{width:100,height:at.y*s,depth:at.z*s}),r(this.build(i))})}};var Ml=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 Oe?n.shape:new Oe,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:l}=n.parameters,c=n.shape,u=r*.5,a=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,v=p+Math.cos(y)*a;c.addPoint(c.createPoint(g,v))}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=Ft.create({shape:c,parameters:{roundness:o,depth:i,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(m,{userData:{...n,type:"PolygonGeometry"}})}};var _e=require("three"),Uh=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:l,cornerSegments:c}=n.parameters,u=new Sd(r*.5,e,o,i,s,l,c);return u.scale(1,1,t/r),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function Ls(n,r,e){e.x=n.x*r.x,e.y=n.y,e.z=n.x*r.y}function bd(n,r,e,t,o,i){let s=r.clone().sub(n),l=e.clone().sub(n),c=s.angleTo(l);if(s.normalize(),l.normalize(),t===o){let u=s.add(l).normalize();i.copy(n).addScaledVector(u,t/Math.sin(c/2))}else{let u=s.angleTo(l);i.copy(n),i.addScaledVector(s,o/Math.sin(u)),i.addScaledVector(l,t/Math.sin(u))}}function $_(n,r,e){let t=n.clone().sub(r),o=e.clone().sub(r);return t.projectOnVector(o),t.add(r)}var Sd=class extends _e.BufferGeometry{constructor(r=.5,e=1,t=4,o=1,i=!1,s=0,l=4){super(),t=Math.floor(Math.max(3,t)),o=Math.floor(o),l=Math.floor(l);let c=[],u=[],a=[],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,v=Math.PI-g,b=new _e.Vector3(0,-f,0),w=new _e.Vector3(0,f,0),S=new _e.Vector2(r,-f),P=new _e.Vector2(h,-f),_=new _e.Vector2(0,w.y).sub(P),x=new _e.Vector2(0,w.y).sub(S),C=new _e.Vector2(_.y,-_.x).normalize(),T=new _e.Vector2(x.y,-x.x).normalize(),O=r*Math.cos(Math.PI/t)*Math.tan((Math.PI-_.angle())/2)-1e-8;s=Math.min(s,O);let A;{let H=new _e.Vector3(C.x,C.y,0),V=new _e.Vector3(Math.cos(y)*H.x,H.y,Math.sin(y)*H.x);A=H.angleTo(V)}let R=s/Math.tan((Math.PI-_.angle())/2),k=s/Math.tan((Math.PI-A)/2),$=new _e.Vector3;if(!i){u.push(b.x,b.y,b.z),a.push(0,-1,0),d.push(0,0);let H=p++,V=[],G=S.clone(),B=R/Math.cos(Math.PI/t);G.x-=B;for(let L=0;L<t;L++){let D=L/t*Math.PI*2+m,X=new _e.Vector2(Math.sin(D),Math.cos(D));Ls(G,X,$),u.push($.x,$.y,$.z),a.push(0,-1,0),d.push(0,0),V.push(p++)}for(let L=0;L<V.length;L++)c.push(V[L],H,V[(L+1)%V.length])}let te=[];{let H=new _e.Vector3,V=new _e.Vector3,G=new _e.Vector3,B=new _e.Vector3,L=new _e.Vector3,D=new _e.Vector3;for(let X=0;X<t;X++){let q=X/t*Math.PI*2+m,j=(X+.5)/t*Math.PI*2+m,F=(X+1)/t*Math.PI*2+m,M=new _e.Vector2(Math.sin(q),Math.cos(q)),Q=new _e.Vector2(Math.sin(j),Math.cos(j)),re=new _e.Vector2(Math.sin(F),Math.cos(F));Ls(S,M,V),Ls(S,re,G),Ls(C,Q,H),bd(w,V,G,k,k,B),u.push(B.x,B.y,B.z),bd(V,w,G,k,R,L),u.push(L.x,L.y,L.z),bd(G,V,w,R,k,D),u.push(D.x,D.y,D.z),a.push(H.x,H.y,H.z),a.push(H.x,H.y,H.z),a.push(H.x,H.y,H.z),d.push(0,0),d.push(0,0),d.push(0,0);let oe=p++,K=p++,ee=p++;if(c.push(oe,K,ee),s>0){{let de=V.clone().add(G).multiplyScalar(.5),ae=w.clone().sub(de).normalize(),Ye=b.clone().sub(de).normalize().add(ae).normalize().multiplyScalar(-1),ve=D.clone().sub(L);Y(de,ve,Ye,_.angle())}let J,se;{let de=new _e.Vector3;Ls(T,re,de);let ae=D.clone().add(B).multiplyScalar(.5);ae=$_(ae,G,w);let me=D.clone().sub(B);[J,se]=Y(ae,me,de,A,B.y)}{let de=J,ae=de.clone().setY(0).normalize(),me=new _e.Vector3(0,-1,0),Ye=ae.clone().cross(me);W(de,ae,me,Ye)}te.concat(se);{let de=_.angle(),ae=Math.PI-de,me=w.clone();me.y-=s/Math.sin(de-Math.PI/2);let Ye=new _e.Vector3,ve=[];for(let Ie=0;Ie<l;Ie++){let Dt=[],tr=Math.PI/2-ae*Ie/l,cn=Math.cos(tr),Wt=Math.sin(tr),ca=j;for(let da=0;da<=Ie;da++){let ua=Math.cos(ca),tt=Math.sin(ca);H.x=cn*tt,H.y=Wt,H.z=cn*ua,Ye.copy(me).addScaledVector(H,s),u.push(Ye.x,Ye.y,Ye.z),a.push(H.x,H.y,H.z),d.push(0,0),Dt.push(p++),ca+=Math.PI*2/Ie/t}ve.push(Dt)}se.reverse(),ve.push(se);let nt=ve.length-1;for(let Ie=0;Ie<nt;Ie++){let Dt=ve[Ie],tr=ve[Ie+1],cn=Dt.length-1;c.push(tr[1],Dt[0],tr[0]);for(let Wt=1;Wt<=cn;Wt++)c.push(Dt[Wt],Dt[Wt-1],tr[Wt]),c.push(tr[Wt+1],Dt[Wt],tr[Wt])}}}}}this.setIndex(c),this.setAttribute("position",new _e.Float32BufferAttribute(u,3)),this.setAttribute("normal",new _e.Float32BufferAttribute(a,3)),this.setAttribute("uv",new _e.Float32BufferAttribute(d,2));function Y(H,V,G,B,L){let D=-B/2,X=(Math.PI-B)/2,q=V.clone().normalize().cross(G);H.addScaledVector(G,-s/Math.sin(X));let j=new _e.Vector3,F=new _e.Vector3,M=1,Q=p,re=[];for(let oe=0;oe<=l;oe++){let K=D+oe/l*B;F.set(0,0,0),F.addScaledVector(q,Math.sin(K)),F.addScaledVector(G,Math.cos(K));for(let ee=0;ee<=M;ee++){let J=ee/M-.5;if(j.copy(H),j.addScaledVector(V,J),j.addScaledVector(F,s),L!=null){let se=Math.max(0,j.y-L);j.addScaledVector(V,-se/V.y)}u.push(j.x,j.y,j.z),a.push(F.x,F.y,F.z),d.push(0,0),ee===0&&re.push(p),p++}}for(let oe=0;oe<l;oe++)for(let K=0;K<M;K++){let ee=Q+K+(M+1)*oe,J=ee+(M+1),se=J+1,de=ee+1;c.push(ee,J,de),c.push(J,se,de)}return[H.clone().addScaledVector(V,.5),re]}function W(H,V,G,B){let L=Math.PI/2,D=x.angle()-L,X=[],q=new _e.Vector3,j=new _e.Vector3;for(let M=0;M<=l;M++){let Q=[],re=M/l;for(let oe=0;oe<=M;oe++){let ee=((M?oe/M:0)-.5)*v,J=Math.cos(ee),se=Math.sin(ee),de=Math.atan(Math.tan(D)*J),ae=(L+de)*re,me=Math.cos(ae),Ye=Math.sin(ae);q.set(0,0,0),q.addScaledVector(V,Ye*J),q.addScaledVector(G,me),q.addScaledVector(B,Ye*se),j.copy(H).addScaledVector(q,s),u.push(j.x,j.y,j.z),a.push(q.x,q.y,q.z),d.push(0,0),Q.push(p++)}X.push(Q)}let F=X.length-1;for(let M=0;M<F;M++){let Q=X[M],re=X[M+1],oe=Q.length-1;c.push(Q[0],re[1],re[0]);for(let K=1;K<=oe;K++)c.push(Q[K-1],Q[K],re[K]),c.push(Q[K],re[K+1],re[K])}}}};var El=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 Oe?n.shape:new Oe,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:l,extrudeBevelSegments:c}=n.parameters,u={x:e*.5,y:t*.5},a={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(w,S,P){return S>e&&P>t?Math.min(w*e/S,w*t/P):S>e?w*e/S:P>t?w*t/P: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=a.x,h=d.x,y=d.y,g=a.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 v=!0;for(let w=0,S=r.points.length;w<S;w++)r.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(v=!1);v&&(r.roundness=f[0]),r.useCubicForRoundedCorners=i!==1,r.update();let b=Ft.create({shape:r,parameters:{depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(b,{userData:{...n,type:"RectangleGeometry"}})}};var Hh=require("three"),qh=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:l,thetaStart:c,thetaLength:u}=n.parameters,a=new Hh.SphereGeometry(.5*r,o,i,s,l,c,u);return a.scale(1,e/r,t/r),Object.assign(a,{userData:{...n,type:"SphereGeometry"}})}};var Wh=require("three"),$h=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 Wh.PlaneGeometry(r,e,t,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};var Ao=require("three"),Yh=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,l=new wd(r,e,t,o,i,s);return Object.assign(l,{userData:{...n,type:"BackdropGeometry"}})}},wd=class extends Ao.BufferGeometry{constructor(r=1,e=1,t=1,o=90,i=10,s=24){super(),this.type="BackdropGeometry";let l=[],c=[],u=[],a=.001;i==0&&(s=1),s=Math.max(1,Math.floor(s)),i=Math.min(i,100),o=Math.min(180-a,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(j=0,F=0,M=0)=>new Ao.Vector3(j,F,M),m=f(),h=f(),[y,g,v]=[e/2,r/2,t/2],b=-g,w=+g,[S,P,_]=[f(b,-y,+v),f(b,-y,-v),f(b,+y,-v)],x=(j,F=!1)=>Math.sin(j-Math.PI/(1+ +F)),C=(j,F=!1)=>Math.cos(j-Math.PI/(1+ +F));_.y=Math.sin(o)*e-y;let T=Math.cos(o)*e-v,N=S.z-a;o<=p?(_.z=Math.min(T,N),_.z==N&&(_.y-=(T-N)/Math.tan(p-o))):P.z=Math.min(P.z-T-v,S.z-a),m.subVectors(S,P),h.subVectors(_,P);let O=Math.min(m.length(),h.length())*i/100,A=O*Math.tan(o/2),R=O/Math.cos(o/2),k=m.clone().normalize().add(h.normalize()).setLength(R).add(P);m.set(0,x(o,!0),C(o,!0)),d.push([_,m.clone()]);let $=(Math.PI-o)/s;for(let j=0;j<=s;j++){let F=p+o+j*$;m.set(0,Math.sin(F)*A,Math.cos(F)*A),m.add(k),h.set(0,x(F),C(F)),d.push([m.clone(),h.clone()])}d.push([S,f(0,1,0)]);let te=Math.sin($/2)*A*2,Y=d.length-1,W=d[0][0].distanceTo(d[1][0]),H=d[Y-1][0].distanceTo(d[Y][0]),V=W+te*s+H;d[0].push(1);for(let j=0;j<=s;j++)d[j+1].push(1-(W+j*te)/V);d[Y].push(0);let[G,B,L]=d[0],D,X,q;for(let j=1;j<d.length;j++)[D,X,q]=d[j],l.push(b,G.y,G.z,b,D.y,D.z,w,G.y,G.z,w,G.y,G.z,b,D.y,D.z,w,D.y,D.z),c.push(0,B.y,B.z,0,X.y,X.z,0,B.y,B.z,0,B.y,B.z,0,X.y,X.z,0,X.y,X.z),u.push(0,L,0,q,1,L,1,L,0,q,1,q),[G,B,L]=[D,X,q];this.setAttribute("position",new Ao.Float32BufferAttribute(l,3)),this.setAttribute("normal",new Ao.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Ao.Float32BufferAttribute(u,2))}};var Ll=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 Oe?n.shape:new Oe,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:l,extrudeBevelSize:c,extrudeBevelSegments:u}=n.parameters,a=n.shape,d=r*.5,p=e*.5,f=0,m=0,h=s*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*t/100,v=p*t/100;if(o===3&&t===50){h=2*Math.PI/o;for(let w=0;w<o;w++){let S=h*w,P=f+Math.sin(S)*d,_=m+Math.cos(S)*p;a.addPoint(a.createPoint(P,_))}}else for(let w=0;w<o;w++){let S=f+Math.cos(y)*d,P=m+Math.sin(y)*p;a.addPoint(a.createPoint(S,P)),y+=h,S=f+Math.cos(y)*g,P=m+Math.sin(y)*v,w<=o,a.addPoint(a.createPoint(S,P)),y+=h}a.isClosed=!0;for(let w=0,S=a.points.length;w<S;w++)a.points[w].roundness=i;a.roundness=i,a.update();let b=Ft.create({shape:a,parameters:{roundness:i,depth:l,extrudeBevelSize:c,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...n,type:"StarGeometry"}})}};var Xh=require("three"),Kh=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 Xh.PlaneGeometry(r,e);return Object.assign(t,{userData:{...n,type:"TextFrameGeometry"}})}};var Zh=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:l,cornerSegments:c}=n.parameters,u=Y_(r,e,t,r*.5,s,i,0,0,o,l,c);return u.scale(1,e/r,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function Y_(n,r,e,t,o,i,s,l,c,u,a){return[r,e]=[e,r],s=r/2,o/=2*Math.PI,o==1&&(u=0),new Ms(!0,n,r,e,t,o,i,s,l,c,u,a)}var Qh=require("three"),Jh=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,l=r*.5;l!==e&&(l-=e);let c=new Qh.TorusKnotGeometry(l,e,t,o,i,s);return Object.assign(c,{userData:{...n,type:"TorusKnotGeometry"}})}};var ey=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 Oe?n.shape:new Oe,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:l}=n.parameters,c=n.shape,u=r*.5,a=e*.5;l?(c.addPoint(c.createPoint(-u,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))):(c.addPoint(c.createPoint(0,a)),c.addPoint(c.createPoint(u,-a)),c.addPoint(c.createPoint(-u,-a))),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=Ft.create({shape:c,parameters:{roundness:t,depth:o,extrudeBevelSize:i,extrudeBevelSegments:s}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};var be=require("three");function ty(n,r){let e=2*Math.PI;return(n%e+e)%e===(r%e+e)%e}function X_(n,r,e){let t=[new be.Vector3,new be.Vector3,new be.Vector3],o=[new be.Vector3,new be.Vector3,new be.Vector3];return n.extractBasis(t[0],t[1],t[2]),r.extractBasis(o[0],o[1],o[2]),t.forEach((i,s)=>{let l=o[s],c=be.MathUtils.lerp(i.length(),l.length(),e);i.lerp(l,e).setLength(c)}),new be.Matrix4().makeBasis(t[0],t[1],t[2])}var ry=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??ci.create({parameters:Hc}).userData.shape;return{path:n.path??Hn.defaultData(),parameters:Object.assign(e,{width:t,height:o,depth:i,extrusion:{...dl,...e.extrusion}}),shapeData:s}}static build(n){if(n.path.points.length>=2){let e=new _d(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new be.BufferGeometry,{userData:{...n,type:"PathGeometry"}})}},_d=class extends be.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!ty(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,l=Math.floor(i*s),c=this.inputs.path.isClosed?Math.ceil((o+i)*s):Math.ceil(Math.min(1,o+i)*s),u=Math.min(Math.max(2,c-l+1),s+2),a=[],d=[];for(let O=0;O<u;O++){let A=this.inputs.path.isClosed?(O+l)%e.length:Math.min(O+l,e.length-1);a.push(e[A].clone()),d.push(t[A].clone())}let p=(O,A,R)=>{a[O]=a[O].clone().lerp(a[A],R),d[O]=X_(d[O],d[A],R)},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(a.length-1,a.length-2,1-h)),o===0){let O=a.length-1;a[O].copy(a[0]),d[O].copy(d[0])}this._applyPathModifiers(d,f,h);let{regions:g,infos:v,vertices:b}=this._computeShapePoints(5),w=0,S=0;v.sort((O,A)=>O.start-A.start),v.forEach(O=>{O.verticesStart=w,O.verticesCount=O.continuous.reduce((A,R,k)=>A+(k===0||!R?2:1),0),S+=O.verticesCount,w=S});let P=S*u,_,x=0;if(this._isOpenEnded()){try{_=vr({windingRule:Pe.ODD,elementType:$e.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:g})}catch{_=md}x=_.vertexCount}let C=P+2*x,T={positions:new Float32Array(C*3),normals:new Float32Array(C*3),uvs:new Float32Array(C*2)},N=[];v.forEach(O=>{this._extrudeRegion(O,b,d,a,T,N,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,P,N,T,d[0],a[0],!1),this._closeEnd(_,P+x,N,T,d[d.length-1],a[a.length-1],!0)),this.setAttribute("position",new be.BufferAttribute(T.positions,3)),this.setAttribute("normal",new be.BufferAttribute(T.normals,3)),this.setAttribute("uv",new be.BufferAttribute(T.uvs,2)),this.setIndex(N)}_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 be.Vector3,l=new be.Vector3,c=new be.Vector3,u=new be.Vector3,a=new be.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],v;y===0?v=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===o-1?b=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):b=e[y+1];let w=g.clone().sub(v).normalize(),S=b.clone().sub(g).normalize(),P=w.clone().add(S).normalize();c.copy(P),y===0&&(P.equals(a)||P.clone().negate().equals(a))&&a.set(0,0,1);let _=a.clone().cross(P).normalize(),x=P.clone().cross(_).normalize();a.copy(x),u.copy(_),y===0&&(s.copy(x),l.copy(P));let C=new be.Matrix4().makeBasis(_,x,P);t.push(C)}let d=i?l:c,p=i?s:new be.Vector3(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 be.Matrix4().makeRotationZ(m*y/t.length);t[y].multiply(g)}return t}_applyPathModifiers(e,t,o){let i=e.length,{angle:s,twist:l,startScale:c,endScale:u}=this.inputs.parameters.extrusion,a=new be.Matrix4,d=new be.Matrix4;return e.forEach((p,f)=>{let m=f===0?0:f===i-1?1:(f-t)/(i-(o===0?0:1)-(t+(1-o)));a.makeRotationZ(be.MathUtils.lerp(s,s+l,m));let h=be.MathUtils.lerp(c,u,m);d.makeScale(h,h,h),p.multiply(a).multiply(d)}),e}_computeShapePoints(e=12,t=Pe.ODD){let o=this.inputs.shapeData,i=o.extractShapePointsToFlatArray([],e),s=o.shapeHoles.map(h=>{let y=h.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],w=y[v-0];g.push(b,w)}return g}),l;try{l=vr({windingRule:t,elementType:$e.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{l=Is}let c;try{c=vr({windingRule:Pe.ODD,elementType:$e.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...s]})}catch{c=fd}if(!l)throw new Error("error generating geometry");let u=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let h=0;h<c.elements.length;h++){let y=c.elements[h],g=h%2===0?l.vertexCount:0;l.elements.push(y+g)}for(let h=0;h<c.vertexIndices.length;h++){let y=c.vertexIndices[h],g=l.vertexCount;l.vertexIndices.push(y+g)}for(let h=0;h<c.vertices.length;h++){let y=c.vertices[h];l.vertices.push(y)}}let a=1/0,d=-1/0,p=1/0,f=-1/0;for(let h=0,y=l.vertexCount;h<y;h++){let g=h*2,v=l.vertices[g+0],b=l.vertices[g+1];v<a&&(a=v),v>d&&(d=v),b<p&&(p=b),b>f&&(f=b)}let m=[];for(let h=l.elementCount-1;h>=0;h--){let y=h>=u,g=h*2,v=l.elements[g+0],b=l.elements[g+1],w=v+b,S={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};m.push(S);let P=v,_=w-1,x=v+1,C=o.roundedCurves.length;do{let T=P-v,N=l.vertices[_*2+0],O=l.vertices[_*2+1],A=l.vertices[P*2+0],R=l.vertices[P*2+1],k=l.vertices[x*2+0],$=l.vertices[x*2+1],te=A-N,Y=R-O,W=Math.sqrt(te*te+Y*Y);te/=W,Y/=W;let H=A-k,V=R-$,G=Math.sqrt(H*H+V*V);H/=G,V/=G,S.normals[T*2+0]=-V,S.normals[T*2+1]=H;let B=l.vertexIndices[P];if(Array.isArray(B))S.continuous[T]=!1;else{let[L,D]=o.getCurveIndexFromVertexId(B-1,!0);if(D>0&&D<1)S.continuous[T]=!0;else{let X=D===1?L+1:L-1;X=(X+C)%C;let q=D===1?0:1,j=o.roundedCurves[L].getTangent(D),F=o.roundedCurves[X].getTangent(q);S.continuous[T]=j.dot(F)>.95}}y&&(S.normals[T*2+0]*=-1,S.normals[T*2+1]*=-1),[_,P,x]=[P,x,x+1],x>=w&&(x-=b)}while(x!==v+1)}return{regions:[i,...s],infos:m,vertices:l.vertices}}_insertVertex(e,t,o,i,s){let l=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[l+0]=s.x,e.uvs[l+1]=s.y}_extrudeRegion(e,t,o,i,s,l,c){let u=new be.Vector3,a=new be.Vector3,d=new be.Vector3,p=new be.Vector3,f=new be.Vector2;o.forEach((h,y)=>{let g=i[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let b=0;b<e.count;b++){let w=(e.start+b)*2;if(u.set(t[w+0],t[w+1],0),d.copy(u).applyMatrix4(h).add(g),e.continuous[b])p.set(e.normals[b*2+0],e.normals[b*2+1],0);else{let S=b==0?(e.start+e.count-1)*2:w-2;a.set(t[S+0],t[S+1],0),p.copy(u).sub(a),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(h).normalize(),f.set(b===0?1:b/e.count,y/(o.length-1)),this._insertVertex(s,v,d,p,f),v++,!e.continuous[b]||b===0){if(b===0)p.set(e.normals[b*2+0],e.normals[b*2+1],0),f.set(0,y/(o.length-1));else{let S=b===e.count-1?e.start*2:w+2;a.set(t[S+0],t[S+1],0),p.copy(a).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(h).normalize(),this._insertVertex(s,v,d,p,f),v++}}});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),v=0;for(let b=0;b<e.count;b++){(!e.continuous[b]||b===0)&&v++;let w=b===e.count-1?0:v+1,S=y+v,P=y+w,_=g+w,x=g+v;e.isHole?l.push(S,_,P,S,x,_):l.push(S,P,_,S,_,x),v++}}}_closeEnd(e,t,o,i,s,l,c){let u=e.vertexCount,a=new be.Vector3(0,0,c?-1:1).applyMatrix4(s),d=new be.Vector3,p=new be.Vector2;for(let m=0;m<u;m++){let h=2*m;d.set(e.vertices[h+0],e.vertices[h+1],0).applyMatrix4(s).add(l),this._insertVertex(i,t+m,d,a,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,v=f[h+(c?2:1)]+t;o.push(y,g,v)}}};var Yo=require("three"),oy=require("three/examples/jsm/utils/BufferGeometryUtils.js");function ny(){let n=new Yo.BufferGeometry;return n.setAttribute("position",new Yo.BufferAttribute(new Float32Array([]),3)),n.setIndex(new Yo.BufferAttribute(new Uint16Array([]),1)),n}var K_=ny().attributes,Z_=12,Q_=1,pi=class extends Yo.BufferGeometry{constructor(e,t){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,K_),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:l,extrudeBevelSegments:c,text:u,textTransform:a}=e,d=a===2?u.toUpperCase():a===3?u.toLowerCase():u,p=J_(e,t,d),{shapes:f,charWidths:m,charCoords:h}=t.generateShapes(p,e),y=o*.5,g=i*.5,v=f.map(S=>new Oe().fromShape(S));this.vectorShapes=v;let b=v.map(S=>Ft.create({shape:S,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Pe.NONZERO:Pe.ODD,subdivisions:this.isLowResolution&&s>0?Q_:Z_}})),w=b.length?(0,oy.mergeBufferGeometries)(b):ny();w.translate(-y,g,0),this.dispose(),this.wrappedText=p,this.charCoords=h,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(w.attributes).forEach(([S,P])=>{this.setAttribute(S,P)}),this.setIndex(w.index),this.computeBoundingSphere()}clone(){let e=Kr(new Yo.BufferGeometry,pi.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 J_(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}var Ge=require("three");var ny,di=new Promise(n=>{ny=n}),oy=!1;async function iy(){if(oy)return;let r=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.357/build",[e,t]=await Promise.all([import("./process.js"),fetch(`${r}/process.wasm`).then(s=>s.arrayBuffer())]),o=e.default,i=await o({wasmBinary:t});ny(i),oy=!0}var sy=require("three");function Xo(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=Pe.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 sy.BufferGeometryLoader().parse(n);else{if(n.type==="SubdivGeometry")return new tt(n,e);if(n.type==="TextGeometry")return new li(n,r)}let o;try{o=wd(t)}catch(i){console.error(i)}if(!o){let i=Pe.createFromState(Fn.defaultData(),100,100);t.shape=i,o=wd(t)}return o}var ay=require("three"),W_=new ay.Matrix4;function Ls(n,r,e,t){let o=n.position.array,i=n.normal.array,s=W_.makeScale(r,e,t).invert().elements,l,c,u;for(var a=0,d=o.length;a<d;a+=3)o[a]*=r,o[a+1]*=e,o[a+2]*=t,l=i[a],c=i[a+1],u=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*u,i[a+1]=s[1]*l+s[5]*c+s[9]*u,i[a+2]=s[2]*l+s[6]*c+s[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Ll=new Ge.Box3,ui=new Ge.Vector3,ue;di.then(n=>{ue=n});var ly=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),cy=new Uint32Array([0,1,2,3]),dy=new Uint8Array([4]),tt=class extends Ge.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=xo.div(t,o);this.subdividedGeometry&&Ls(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Ls(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(ui.fromArray(i));let l=ui.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=l/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=tt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Ge.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(tt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ge.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Ll.setFromBufferAttribute(t),Ll.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ll.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ll.getSize(ui);let i={width:ui.x,height:ui.y,depth:ui.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,l,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(ue.free_bvh(t),ue.free_subdivision_surface(t));try{s=tt.allocate(e,i)}catch(a){console.error(a,e),s=tt.allocate({positionWASM:ly,indexWASM:cy,verticesPerFaceWASM:dy},i)}if(ue.set_destination_refinement_level(s,0),l=tt.buildLevel(s,!0,u),e.subdivisions>0)try{ue.set_destination_refinement_level(s,e.subdivisions),c=tt.buildLevel(s,!1,u)}catch{try{ue.set_destination_refinement_level(s,e.subdivisions-1),c=tt.buildLevel(s,!1,u)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:l,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?t.geometry:Xo(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let l,c,u,a;({positions:l,triIndices:a}=Od(i.getAttribute("position"),s));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}=Ad(l,a,i,d),{positions:l,indices:c,verticesPerFace:u}}static allocate(e,t){let o,i,s,l=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=ly,i=cy,s=dy);let u=o.length,a=i.length,d=s.length,p=o.length+l.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=ue._malloc(m),v=new Float32Array(ue.HEAPF32.buffer,g,p),b=new Uint32Array(ue.HEAPU32.buffer,g+h,f);v.set(o,0),v.set(l,o.length),v.set(c,o.length+l.length),b.set(i,0),b.set(s,i.length);let w;e?.scaleBaked?.some(T=>T!==1)&&(w=new Ge.Matrix4().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let S=w?ue.alloc_subdivision_surface2(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):ue.alloc_subdivision_surface(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return ue._free(g),S}static buildLevel(e,t,o,i,s){let l=s?ue.get_mesh_data2(e,t?ue.Level.CONTROL:ue.Level.REFINED,o,s.elements):ue.get_mesh_data(e,t?ue.Level.CONTROL:ue.Level.REFINED,o),c=8,u=ue.HEAPU32.subarray(l>>2,(l>>2)+c),a=u.subarray(4,4+4),d=0,p=ue.HEAPU32[u[d]>>2],f=ue.HEAPF32.subarray(p>>2,(p>>2)+a[d]);d++;let m=ue.HEAPU32[u[d]>>2],h=ue.HEAPF32.subarray(m>>2,(m>>2)+a[d]);d++;let y=ue.HEAPU32[u[d]>>2],g=ue.HEAPU32.subarray(y>>2,(y>>2)+a[d]);d++;let v=ue.HEAPU32[u[d]>>2],b=ue.HEAPU32.subarray(v>>2,(v>>2)+a[d]);if(d++,i===void 0){let w=new Ge.BufferGeometry;if(w.setIndex(new Ge.Uint32BufferAttribute(b,1)),w.setAttribute("position",new Ge.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Ge.Float32BufferAttribute(h,3)),t){w.setAttribute("faceMap",new Ge.Uint32BufferAttribute(g,1));let S=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new Ge.BufferAttribute(S,4))}return ue.free_mesh_data(l),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,ue.free_mesh_data(l)}static freeSubdivPointer(e){ue.free_bvh(e),ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=ue.get_wireframe_data_for_base_level(e),s=4,l=ue.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+2),u=0,a=ue.HEAPU32[l[u]>>2],d=ue.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=ue.HEAPU32[l[u]>>2],f=ue.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new Ge.BufferGeometry;m.setAttribute("position",new Ge.Float32BufferAttribute(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 Ge.BufferAttribute(h,3)),m.setIndex(new Ge.Uint32BufferAttribute(f,1)),ue.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(d),t.attributes.position.needsUpdate=!0,ue.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||ue.set_destination_refinement_level(e,t);let s=o?ue.get_topological_data2(e,i?ue.Level.CONTROL:ue.Level.REFINED,o.elements):ue.get_topological_data(e,i?ue.Level.CONTROL:ue.Level.REFINED),l=6,c=ue.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(3,3+3),a=0,d=ue.HEAPU32[c[a]>>2],p=new Float32Array(ue.HEAPF32.subarray(d>>2,(d>>2)+u[a]));a++;let f=ue.HEAPU32[c[a]>>2],m=new Uint32Array(ue.HEAPU32.subarray(f>>2,(f>>2)+u[a]));a++;let h=ue.HEAPU32[c[a]>>2],y=new Uint8Array(ue.HEAPU32.subarray(h>>2,(h>>2)+u[a]));return ue.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var uy=["getX","getY","getZ"];function Od(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],l=1e4;for(let u=0;u<t;u++){let a=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[uy[p]](a)*l)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)s.push(n[uy[p]](a));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:s,triIndices:c}}var Bl=new Ge.Vector3,_d=new Ge.Vector3,Td=new Ge.Vector3,Pd=new Ge.Vector3;function Ad(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 s=e.userData.shape.extractShapePointsToFlatArray([]),l=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&l<=24&&l%4===0&&e.userData.parameters.angle>=360){let a=s.length/2/l;s=s.filter((d,p)=>Math.floor(p/2)%a===0)}let c=0;for(let a=0;a<s.length;a+=2)c+=(s[a]-s[(a===0?s.length:a)-2])*(s[a+1]+s[(a===0?s.length:a)-1]);n.length=0;let u=0;if(c<0)for(let a=0;a<s.length;a+=2)n.push(s[a],s[a+1],0),o.push(u++);else for(let a=s.length-2;a>=0;a-=2)n.push(s[a],s[a+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}for(let s=0,l=e.capStartIndex??r.length;s<l;)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]){Bl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),_d.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Td.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Pd.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),_d.sub(Bl).normalize(),Td.sub(Bl).normalize(),Pd.sub(Bl).normalize();let c=_d.cross(Td).dot(Pd);Math.abs(c)>.005||t&&t.some((u,a)=>a%2===1?!1:s>=t[a]&&s<t[a+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.capStartIndex!==void 0){let s=[],l=[],c=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let a=0,d=0;a<n.length;a+=3,d++)n[a+2]===0&&(s.push(d),c++),n[a+2]===u&&l.push(d);if(e.userData.parameters.extrudeBevelSize===0){let a=l[0];l[0]=l[1],l[1]=a}s.reverse(),o.push(...s,...l),i.push(c,c)}return{indices:o,verticesPerFace:i}}var xr={};yu(xr,{calcBoolean:()=>K_,calcBooleanTopological:()=>Y_,freeMeshSet:()=>J_,getMeshSet:()=>Z_,transformMeshSet:()=>Q_});var $_,py=new Promise(n=>{$_=n});var Bs=require("three");var be,pi;py.then(n=>be=n);function X_(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}=Od(n.getAttribute("position"),o),l;if(r&&e){let{indices:c,verticesPerFace:u}=Ad(i,s,n);l=u.length,t=[];for(let a=0,d=0;a<l;a++){t.push(u[a]);for(let p=0;p<u[a];p++)t.push(c[d++])}}else{let c=s.length;t=Array(c+c/3),l=0;for(let u=0,a=0;a<t.length;)t[a++]=3,l++,t[a++]=s[u++],t[a++]=s[u++],t[a++]=s[u++]}return{positions:i,faceIndices:t,nFaces:l}}function fy(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 my(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 Y_(n,r){pi===void 0&&(pi=be.init_csg());let e=fy(n),t=be.csg_calc_topological(pi,e,n.length,my(r));be._free(e);let o=6,i=be.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),l=0,c=be.HEAPU32[i[l]>>2],u=new Float32Array(be.HEAPF32.subarray(c>>2,(c>>2)+s[l]));l++;let a=be.HEAPU32[i[l]>>2],d=new Uint32Array(be.HEAPU32.subarray(a>>2,(a>>2)+s[l]));l++;let p=be.HEAPU32[i[l]>>2],f=new Uint8Array(be.HEAPU32.subarray(p>>2,(p>>2)+s[l]));return be.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function K_(n,r,e,t){pi===void 0&&(pi=be.init_csg());let o=fy(n),i=be.csg_calc(pi,o,n.length,t,my(r));be._free(o);let s=5,l=be.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+3),u=0,a=be.HEAPU32[l[u]>>2],d=be.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=be.HEAPU32[l[u]>>2],f=be.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new Bs.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Bs.Float32BufferAttribute(f,3));let h=be.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Bs.Sphere),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 Z_(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,v)=>g+v,0)+i);for(let g=0,v=0,b=0;g<y.verticesPerFace.length;g++){o[b++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[b++]=y.indices[v++]}}else({positions:t,faceIndices:o,nFaces:i}=X_(n,r,e));let s=t.length,l=o.length,c=t.length,u=o.length,a=c*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=c*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=be._malloc(a),m=new Float32Array(be.HEAPF32.buffer,f,c),h=new Uint32Array(be.HEAPU32.buffer,f+d,u);return m.set(t,0),h.set(o,0),be.get_csg_mesh(f,s,f+d,l,i)}function Q_(n,r){be.transform_csg_mesh(n,r.elements)}function J_(n){be.free_csg_mesh(n)}var eT={ConeGeometry:ih,CubeGeometry:sh,CylinderGeometry:oh,DodecahedronGeometry:lh,EllipseGeometry:ii,HelixGeometry:Lh,IcosahedronGeometry:Dh,LatheGeometry:Gh,NonParametricGeometry:jh,PolygonGeometry:Il,PyramidGeometry:Fh,RectangleGeometry:Ml,SphereGeometry:Uh,PlaneGeometry:qh,BackdropGeometry:Wh,StarGeometry:El,TextFrameGeometry:Xh,TorusGeometry:Yh,TorusKnotGeometry:Zh,TriangleGeometry:Qh,PathGeometry:ey,VectorGeometry:Vt},wd=n=>eT[n.type].create(n);function Ds(n){return n!==null&&"booleanOp"in n}var fi=class extends vl(Dl.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Dl.Matrix4}updateVisible(){super.updateVisible(),this.visible=!Ds(this.parent)&&this.visible,Ds(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Ds(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof fi&&(e.freeBooleanPointer(),Ds(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Ds(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var Gl=new mi.Box3;function Gs(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,a=-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<s&&(s=f),m<l&&(l=m),p>c&&(c=p),f>u&&(u=f),m>a&&(a=m)}Gl.min.set(i,s,l),Gl.max.set(c,u,a),Gl.getCenter(t),Gl.getSize(o).multiplyScalar(.5)}var tT=new mi.BufferGeometry,rT=new mi.MeshBasicMaterial,bt=class extends fi{constructor(r,e){super(tT,rT),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?Gs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var so=require("three");var Zt=require("three");var My=require("three");var br=require("three");var Rs=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var hy=require("three"),mt=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=hy.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,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 mt&&(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 Nd=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}},st=new Nd;var Cd=require("three");var yy=require("three"),le=class extends mt{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=yy.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let l=e.getNodeData(o),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return l.name=l.name||super.build(e,t,o),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.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,l.output,i);let a=this.generate(e,c,o);return e.addNodeCode(u+" = "+a+";"),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,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 Ve=class extends le{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,l){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,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}};var Qe=class extends Ve{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Cd.Vector2?e:new Cd.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var Id=require("three");var St=class extends Ve{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Id.Vector3?e:new Id.Vector3(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var gy=require("three"),at=class extends gy.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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],l=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))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(l))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 zt=class extends Ve{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof at?e:new at(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var oT=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,xy=/[a-z_0-9]+/gi,U=class extends le{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 l,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 a=[];for(;l=xy.exec(this.src);)a.push(l);for(let d=0;d<a.length;d++){let p=a[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&st.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=st.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||st.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&&st.contains(h)&&e.include(st.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 s=oT.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(xy);if(l){let c=0;for(;c<l.length;){let u=l[c++],a;u==="in"||u==="out"||u==="inout"?a=l[c++]:(a=u,u="");let d=l[c++];this.inputs.push({name:d,type:a,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var nT=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Md=class extends le{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Md.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 l,c,u="",a=nT.exec(e);this.useDefine=s??this.src.charAt(0)==="#",a&&a.length>1?(c=a[1],l=a[2],u=a[3]):(l=this.src,c="f"),this.name=l,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,s){return e.format(this.name,this.getType(e),t)}},Te=Md;Te.PI="PI",Te.PI2="PI2",Te.RECIPROCAL_PI="RECIPROCAL_PI",Te.RECIPROCAL_PI2="RECIPROCAL_PI2",Te.LOG2="LOG2",Te.EPSILON="EPSILON";var iT=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
- )*?)}`,"gim"),sT=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),hi=class extends le{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=iT.exec(e);if(t){let o=t[2],i;for(;i=sT.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var yi=class extends le{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)}};st.addKeyword("uv",function(){return new yi});st.addKeyword("uv2",function(){return new yi(1)});var Rl=require("three");var Yo=class extends le{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??Yo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Rl.LinearEncoding:return["Linear"];case Rl.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=Yo.Nodes[this.method],l=e.include(s);if(l===Yo.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(l+"( "+o+", "+c+" )",i,t)}else return e.format(l+"( "+o+" )",i,t)}fromEncoding(e){let t=Yo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Yo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},It=Yo;It.Nodes={LinearToLinear:new U(["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}var Ve=require("three");var sy,mi=new Promise(n=>{sy=n}),iy=!1;async function ay(){if(iy)return;let r=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.360/build",[e,t]=await Promise.all([import("./process.js"),fetch(`${r}/process.wasm`).then(s=>s.arrayBuffer())]),o=e.default,i=await o({wasmBinary:t});sy(i),iy=!0}var ly=require("three");function Xo(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=Oe.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 ly.BufferGeometryLoader().parse(n);else{if(n.type==="SubdivGeometry")return new ot(n,e);if(n.type==="TextGeometry")return new pi(n,r)}let o;try{o=Pd(t)}catch(i){console.error(i)}if(!o){let i=Oe.createFromState(Un.defaultData(),100,100);t.shape=i,o=Pd(t)}return o}var cy=require("three"),eP=new cy.Matrix4;function Bs(n,r,e,t){let o=n.position.array,i=n.normal.array,s=eP.makeScale(r,e,t).invert().elements,l,c,u;for(var a=0,d=o.length;a<d;a+=3)o[a]*=r,o[a+1]*=e,o[a+2]*=t,l=i[a],c=i[a+1],u=i[a+2],i[a]=s[0]*l+s[4]*c+s[8]*u,i[a+1]=s[1]*l+s[5]*c+s[9]*u,i[a+2]=s[2]*l+s[6]*c+s[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Bl=new Ve.Box3,hi=new Ve.Vector3,ue;mi.then(n=>{ue=n});var dy=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),uy=new Uint32Array([0,1,2,3]),py=new Uint8Array([4]),ot=class extends Ve.BufferGeometry{constructor(e,t){super();this.data=e;this.flatShading=t;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,t){this.freeSubdivPointer();let o=this.data.scaleBaked,i=vo.div(t,o);this.subdividedGeometry&&Bs(this.subdividedGeometry.attributes,...i),this.originalGeometry&&Bs(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(hi.fromArray(i));let l=hi.set(s.width,s.height,s.depth).length();this.originalGeometry.boundingSphere.radius=l/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,t,o;try{({originalGeometry:e,subdividedGeometry:t,subdivPointer:o}=ot.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Ve.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=t??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(ot.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ve.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Bl.setFromBufferAttribute(t),Bl.getCenter(o),e.boundingSphere.radius=o.distanceTo(Bl.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Bl.getSize(hi);let i={width:hi.x,height:hi.y,depth:hi.z};return this.userData.parameters=i,i}static build(e,t,o,i){let s,l,c,u=e?.phongAngle??35;o===!1&&(u=-1),t&&(ue.free_bvh(t),ue.free_subdivision_surface(t));try{s=ot.allocate(e,i)}catch(a){console.error(a,e),s=ot.allocate({positionWASM:dy,indexWASM:uy,verticesPerFaceWASM:py},i)}if(ue.set_destination_refinement_level(s,0),l=ot.buildLevel(s,!0,u),e.subdivisions>0)try{ue.set_destination_refinement_level(s,e.subdivisions),c=ot.buildLevel(s,!1,u)}catch{try{ue.set_destination_refinement_level(s,e.subdivisions-1),c=ot.buildLevel(s,!1,u)}catch{c=null}}else c=null;return{subdivPointer:s,originalGeometry:l,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?t.geometry:Xo(e,o,!1),s;e.type==="TorusGeometry"&&e.arc===Math.PI*2?s=i.getClosedTorusIndicesForBooleanOrSubdiv():s=i.getIndex();let l,c,u,a;({positions:l,triIndices:a}=Nd(i.getAttribute("position"),s));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}=Cd(l,a,i,d),{positions:l,indices:c,verticesPerFace:u}}static allocate(e,t){let o,i,s,l=[],c=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,s=e.verticesPerFaceWASM):(o=dy,i=uy,s=py);let u=o.length,a=i.length,d=s.length,p=o.length+l.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=ue._malloc(m),v=new Float32Array(ue.HEAPF32.buffer,g,p),b=new Uint32Array(ue.HEAPU32.buffer,g+h,f);v.set(o,0),v.set(l,o.length),v.set(c,o.length+l.length),b.set(i,0),b.set(s,i.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new Ve.Matrix4().makeScale(...e.scaleBaked)),t&&(w?w.premultiply(t):w=t);let S=w?ue.alloc_subdivision_surface2(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):ue.alloc_subdivision_surface(g,u,g+h,a,g+h+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return ue._free(g),S}static buildLevel(e,t,o,i,s){let l=s?ue.get_mesh_data2(e,t?ue.Level.CONTROL:ue.Level.REFINED,o,s.elements):ue.get_mesh_data(e,t?ue.Level.CONTROL:ue.Level.REFINED,o),c=8,u=ue.HEAPU32.subarray(l>>2,(l>>2)+c),a=u.subarray(4,4+4),d=0,p=ue.HEAPU32[u[d]>>2],f=ue.HEAPF32.subarray(p>>2,(p>>2)+a[d]);d++;let m=ue.HEAPU32[u[d]>>2],h=ue.HEAPF32.subarray(m>>2,(m>>2)+a[d]);d++;let y=ue.HEAPU32[u[d]>>2],g=ue.HEAPU32.subarray(y>>2,(y>>2)+a[d]);d++;let v=ue.HEAPU32[u[d]>>2],b=ue.HEAPU32.subarray(v>>2,(v>>2)+a[d]);if(d++,i===void 0){let w=new Ve.BufferGeometry;if(w.setIndex(new Ve.Uint32BufferAttribute(b,1)),w.setAttribute("position",new Ve.Float32BufferAttribute(f,3)),w.setAttribute("normal",new Ve.Float32BufferAttribute(h,3)),t){w.setAttribute("faceMap",new Ve.Uint32BufferAttribute(g,1));let S=new Float32Array(h.length/3*4).fill(0);w.setAttribute("color",new Ve.BufferAttribute(S,4))}return ue.free_mesh_data(l),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,ue.free_mesh_data(l)}static freeSubdivPointer(e){ue.free_bvh(e),ue.free_subdivision_surface(e)}static buildControlCageWireframe(e,t,o){let i=ue.get_wireframe_data_for_base_level(e),s=4,l=ue.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+2),u=0,a=ue.HEAPU32[l[u]>>2],d=ue.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=ue.HEAPU32[l[u]>>2],f=ue.HEAPU32.subarray(p>>2,(p>>2)+c[u]);if(t===void 0){let m=new Ve.BufferGeometry;m.setAttribute("position",new Ve.Float32BufferAttribute(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 Ve.BufferAttribute(h,3)),m.setIndex(new Ve.Uint32BufferAttribute(f,1)),ue.free_wireframe_data_for_base_level(i),m}t.getAttribute("position").copyArray(d),t.attributes.position.needsUpdate=!0,ue.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,t,o){let i=t===0;i||ue.set_destination_refinement_level(e,t);let s=o?ue.get_topological_data2(e,i?ue.Level.CONTROL:ue.Level.REFINED,o.elements):ue.get_topological_data(e,i?ue.Level.CONTROL:ue.Level.REFINED),l=6,c=ue.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(3,3+3),a=0,d=ue.HEAPU32[c[a]>>2],p=new Float32Array(ue.HEAPF32.subarray(d>>2,(d>>2)+u[a]));a++;let f=ue.HEAPU32[c[a]>>2],m=new Uint32Array(ue.HEAPU32.subarray(f>>2,(f>>2)+u[a]));a++;let h=ue.HEAPU32[c[a]>>2],y=new Uint8Array(ue.HEAPU32.subarray(h>>2,(h>>2)+u[a]));return ue.free_topological_data(s),{positions:p,indices:m,verticesPerFace:y}}};var fy=["getX","getY","getZ"];function Nd(n,r){let e={},t=r?r.count:n.count,o=0,i=[],s=[],l=1e4;for(let u=0;u<t;u++){let a=r?r.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[fy[p]](a)*l)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)s.push(n[fy[p]](a));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:s,triIndices:c}}var Dl=new Ve.Vector3,Td=new Ve.Vector3,Od=new Ve.Vector3,Ad=new Ve.Vector3;function Cd(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 s=e.userData.shape.extractShapePointsToFlatArray([]),l=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&l<=24&&l%4===0&&e.userData.parameters.angle>=360){let a=s.length/2/l;s=s.filter((d,p)=>Math.floor(p/2)%a===0)}let c=0;for(let a=0;a<s.length;a+=2)c+=(s[a]-s[(a===0?s.length:a)-2])*(s[a+1]+s[(a===0?s.length:a)-1]);n.length=0;let u=0;if(c<0)for(let a=0;a<s.length;a+=2)n.push(s[a],s[a+1],0),o.push(u++);else for(let a=s.length-2;a>=0;a-=2)n.push(s[a],s[a+1],0),o.push(u++);return i.push(u),{indices:o,verticesPerFace:i}}for(let s=0,l=e.capStartIndex??r.length;s<l;)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]){Dl.set(n[r[s]*3],n[r[s]*3+1],n[r[s]*3+2]),Td.set(n[r[s+1]*3],n[r[s+1]*3+1],n[r[s+1]*3+2]),Od.set(n[r[s+4]*3],n[r[s+4]*3+1],n[r[s+4]*3+2]),Ad.set(n[r[s+5]*3],n[r[s+5]*3+1],n[r[s+5]*3+2]),Td.sub(Dl).normalize(),Od.sub(Dl).normalize(),Ad.sub(Dl).normalize();let c=Td.cross(Od).dot(Ad);Math.abs(c)>.005||t&&t.some((u,a)=>a%2===1?!1:s>=t[a]&&s<t[a+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.capStartIndex!==void 0){let s=[],l=[],c=0,u=new Float32Array([e.userData.parameters.depth])[0];for(let a=0,d=0;a<n.length;a+=3,d++)n[a+2]===0&&(s.push(d),c++),n[a+2]===u&&l.push(d);if(e.userData.parameters.extrudeBevelSize===0){let a=l[0];l[0]=l[1],l[1]=a}s.reverse(),o.push(...s,...l),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Sr={};gu(Sr,{calcBoolean:()=>nP,calcBooleanTopological:()=>oP,freeMeshSet:()=>aP,getMeshSet:()=>iP,transformMeshSet:()=>sP});var tP,my=new Promise(n=>{tP=n});var Ds=require("three");var Se,yi;my.then(n=>Se=n);function rP(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}=Nd(n.getAttribute("position"),o),l;if(r&&e){let{indices:c,verticesPerFace:u}=Cd(i,s,n);l=u.length,t=[];for(let a=0,d=0;a<l;a++){t.push(u[a]);for(let p=0;p<u[a];p++)t.push(c[d++])}}else{let c=s.length;t=Array(c+c/3),l=0;for(let u=0,a=0;a<t.length;)t[a++]=3,l++,t[a++]=s[u++],t[a++]=s[u++],t[a++]=s[u++]}return{positions:i,faceIndices:t,nFaces:l}}function hy(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 yy(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 oP(n,r){yi===void 0&&(yi=Se.init_csg());let e=hy(n),t=Se.csg_calc_topological(yi,e,n.length,yy(r));Se._free(e);let o=6,i=Se.HEAPU32.subarray(t>>2,(t>>2)+o),s=i.subarray(3,3+3),l=0,c=Se.HEAPU32[i[l]>>2],u=new Float32Array(Se.HEAPF32.subarray(c>>2,(c>>2)+s[l]));l++;let a=Se.HEAPU32[i[l]>>2],d=new Uint32Array(Se.HEAPU32.subarray(a>>2,(a>>2)+s[l]));l++;let p=Se.HEAPU32[i[l]>>2],f=new Uint8Array(Se.HEAPU32.subarray(p>>2,(p>>2)+s[l]));return Se.free_mesh_data(t),{positions:u,indices:d,verticesPerFace:f}}function nP(n,r,e,t){yi===void 0&&(yi=Se.init_csg());let o=hy(n),i=Se.csg_calc(yi,o,n.length,t,yy(r));Se._free(o);let s=5,l=Se.HEAPU32.subarray(i>>2,(i>>2)+s),c=l.subarray(2,2+3),u=0,a=Se.HEAPU32[l[u]>>2],d=Se.HEAPF32.subarray(a>>2,(a>>2)+c[u]);u++;let p=Se.HEAPU32[l[u]>>2],f=Se.HEAPF32.subarray(p>>2,(p>>2)+c[u]);u++;let m=c[u];e.setAttribute("position",new Ds.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ds.Float32BufferAttribute(f,3));let h=Se.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ds.Sphere),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 iP(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,v)=>g+v,0)+i);for(let g=0,v=0,b=0;g<y.verticesPerFace.length;g++){o[b++]=y.verticesPerFace[g];for(let w=0;w<y.verticesPerFace[g];w++)o[b++]=y.indices[v++]}}else({positions:t,faceIndices:o,nFaces:i}=rP(n,r,e));let s=t.length,l=o.length,c=t.length,u=o.length,a=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(a),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,s,f+d,l,i)}function sP(n,r){Se.transform_csg_mesh(n,r.elements)}function aP(n){Se.free_csg_mesh(n)}var lP={ConeGeometry:ah,CubeGeometry:lh,CylinderGeometry:ih,DodecahedronGeometry:dh,EllipseGeometry:ci,HelixGeometry:Dh,IcosahedronGeometry:Rh,LatheGeometry:Vh,NonParametricGeometry:kh,PolygonGeometry:Ml,PyramidGeometry:Uh,RectangleGeometry:El,SphereGeometry:qh,PlaneGeometry:$h,BackdropGeometry:Yh,StarGeometry:Ll,TextFrameGeometry:Kh,TorusGeometry:Zh,TorusKnotGeometry:Jh,TriangleGeometry:ey,PathGeometry:ry,VectorGeometry:Ft},Pd=n=>lP[n.type].create(n);function Gs(n){return n!==null&&"booleanOp"in n}var gi=class extends bl(Gl.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new Gl.Matrix4}updateVisible(){super.updateVisible(),this.visible=!Gs(this.parent)&&this.visible,Gs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Sr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Gs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof gi&&(e.freeBooleanPointer(),Gs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e){let t=super.updateTransformState(e);return t&&Gs(this.parent)&&this.invalidateDownstreamBooleanData(!0),t}};var Rl=new xi.Box3;function Rs(n,r=0,e=n.count,t,o){let i=1/0,s=1/0,l=1/0,c=-1/0,u=-1/0,a=-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<s&&(s=f),m<l&&(l=m),p>c&&(c=p),f>u&&(u=f),m>a&&(a=m)}Rl.min.set(i,s,l),Rl.max.set(c,u,a),Rl.getCenter(t),Rl.getSize(o).multiplyScalar(.5)}var cP=new xi.BufferGeometry,dP=new xi.MeshBasicMaterial,wt=class extends gi{constructor(r,e){super(cP,dP),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?Rs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ao=require("three");var er=require("three");var Vy=require("three");var _r=require("three");var Vs=class{constructor(r){r=r??{},this.name=r.name,this.type=r.type,this.node=r.node,this.size=r.size,this.needsUpdate=r.needsUpdate}get value(){return this.node.value}set value(r){this.node.value=r}};var gy=require("three"),ht=class{constructor(r){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=gy.MathUtils.generateUUID(),this.type=r,this.name=""}analyze(r,e){e=e??{},r.analyzing=!0,this.build(r.addFlow(e.slot,e.cache,e.context),"v4"),r.clearVertexNodeCode(),r.clearFragmentNodeCode(),r.removeFlow(),r.analyzing=!1}analyzeAndFlow(r,e,t){return t=t??{},this.analyze(r,t),this.flow(r,e,t)}flow(r,e,t){t=t??{},r.addFlow(t.slot,t.cache,t.context);let o={result:this.build(r,e),code:r.clearNodeCode(),extra:r.context.extra};return r.removeFlow(),o}build(r,e,t){e=e??this.getType(r,e);let o=r.getNodeData(t??this);return r.analyzing&&this.appendDepsNode(r,o,e),r.nodes.indexOf(this)===-1&&r.nodes.push(this),this.updateFrame!==void 0&&r.updaters.indexOf(this)===-1&&r.updaters.push(this),this.generate(r,e,t)}updateFrame(r){}generateReadonly(r,e,t,o,i,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 ht&&(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 Id=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}},lt=new Id;var Md=require("three");var xy=require("three"),le=class extends ht{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=xy.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!s);let l=e.getNodeData(o),c=l.output||this.getType(e);if(e.analyzing)return(l.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,l,t),this.generate(e,t,o)):super.build(e,t,o);if(s)return l.name=l.name||super.build(e,t,o),l.name;if(!this.getLabel()&&(!this.getShared(e,c)||e.context.ignoreCache||l.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,l.output,i);let a=this.generate(e,c,o);return e.addNodeCode(u+" = "+a+";"),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,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 Be=class extends le{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,l){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,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}};var Je=class extends Be{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Md.Vector2?e:new Md.Vector2(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,o,i,s,l){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}};var Ed=require("three");var _t=class extends Be{constructor(e=0,t,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Ed.Vector3?e:new Ed.Vector3(e,t,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}};var vy=require("three"),ct=class extends vy.Color{constructor(e,t,o,i){super(e,t,o);this.isColorA=!0;this.a=i}setRGBA(e,t,o,i){super.setRGB(e,t,o),this.a=i}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}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],l=o[2];switch(s){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))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(l))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 kt=class extends Be{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof ct?e:new ct(e.r,e.g,e.b,e.a)}generateReadonly(e,t,o,i,s,l){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,t)}};var uP=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,by=/[a-z_0-9]+/gi,U=class extends le{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 l,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 a=[];for(;l=by.exec(this.src);)a.push(l);for(let d=0;d<a.length;d++){let p=a[d],f=p[0],m=this.isMethod?!this.getInputByName(f):!0,h=f;if(this.keywords[f]||this.useKeywords&&m&&lt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=lt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||lt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}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&&lt.contains(h)&&e.include(lt.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 s=uP.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let l=s[3].match(by);if(l){let c=0;for(;c<l.length;){let u=l[c++],a;u==="in"||u==="out"||u==="inout"?a=l[c++]:(a=u,u="");let d=l[c++];this.inputs.push({name:d,type:a,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var pP=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Ld=class extends le{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 l,c,u="",a=pP.exec(e);this.useDefine=s??this.src.charAt(0)==="#",a&&a.length>1?(c=a[1],l=a[2],u=a[3]):(l=this.src,c="f"),this.name=l,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,s){return e.format(this.name,this.getType(e),t)}},Te=Ld;Te.PI="PI",Te.PI2="PI2",Te.RECIPROCAL_PI="RECIPROCAL_PI",Te.RECIPROCAL_PI2="RECIPROCAL_PI2",Te.LOG2="LOG2",Te.EPSILON="EPSILON";var fP=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
4
+ )*?)}`,"gim"),mP=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),vi=class extends le{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=fP.exec(e);if(t){let o=t[2],i;for(;i=mP.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=t[1]}else this.name="";this.type=this.name}};var bi=class extends le{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)}};lt.addKeyword("uv",function(){return new bi});lt.addKeyword("uv2",function(){return new bi(1)});var Vl=require("three");var Ko=class extends le{constructor(e,t){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=t??Ko.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case Vl.LinearEncoding:return["Linear"];case Vl.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,t){let o=this.input.build(e,"v4"),i=this.getType(e),s=Ko.Nodes[this.method],l=e.include(s);if(l===Ko.LINEAR_TO_LINEAR)return e.format(o,i,t);if(s.inputs?.length===2){let c=this.factor.build(e,"f");return e.format(l+"( "+o+", "+c+" )",i,t)}else return e.format(l+"( "+o+" )",i,t)}fromEncoding(e){let t=Ko.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Ko.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}},Et=Ko;Et.Nodes={LinearToLinear:new U(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
5
5
  `)),sRGBToLinear:new U(["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 U(["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
- `))},It.LINEAR_TO_LINEAR="LinearToLinear",It.SRGB_TO_LINEAR="sRGBToLinear",It.LINEAR_TO_SRGB="LinearTosRGB";var Ae=class extends U{constructor(e="",t,o,i,s){super(e,s,i,o,t);this.nodeType="Expression"}};var vy=require("three"),jt=class extends Ve{constructor(e=new vy.Texture,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new yi,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 l,c;this.project?l="texture2DProj":l=s?"tex2DBias":"tex2D",s?c=l+"( "+o+", "+i+", "+s+" )":c=l+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},a=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new It(new Ae("",a)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,a),e.removeContext(),e.format(c,a,t)}};var Z=class extends Ve{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,s,l){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var Vs=class extends le{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 l=this.value,c=l.build(e,t)+"( ",u=[];if(l.inputs){for(let a=0;a<l.inputs.length;a++){let d=l.inputs[a],p=this.inputs[a]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var Ed=class extends le{constructor(e,t,o=Ed.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)}},ht=Ed;ht.ADD="+",ht.SUB="-",ht.MUL="*",ht.DIV="/";var Le=class extends le{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,l=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,a=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case Le.NEGATE:return e.format("( -"+this.a.build(e,a)+" )",a,t);case Le.INVERT:return e.format("( 1.0 - "+this.a.build(e,a)+" )",a,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,l===1?"f":a),i=this.b.build(e,a);break;case Le.MIN:case Le.MAX:case Le.MOD:o=this.a.build(e,a),i=this.b.build(e,c===1?"f":a);break;case Le.REFRACT:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,"f");break;case Le.MIX:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,u===1?"f":a);break;default:o=this.a.build(e,a),this.b&&(i=this.b.build(e,a)),this.c&&(s=this.c.build(e,a));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(", ")+" )",d,t)}},fe=Le;fe.RAD="radians",fe.DEG="degrees",fe.EXP="exp",fe.EXP2="exp2",fe.LOG="log",fe.LOG2="log2",fe.SQRT="sqrt",fe.INV_SQRT="inversesqrt",fe.FLOOR="floor",fe.CEIL="ceil",fe.NORMALIZE="normalize",fe.FRACT="fract",fe.SATURATE="saturate",fe.SIN="sin",fe.COS="cos",fe.TAN="tan",fe.ASIN="asin",fe.ACOS="acos",fe.ARCTAN="atan",fe.ABS="abs",fe.SIGN="sign",fe.LENGTH="length",fe.NEGATE="negate",fe.INVERT="invert",fe.MIN="min",fe.MAX="max",fe.MOD="mod",fe.STEP="step",fe.REFLECT="reflect",fe.DISTANCE="distance",fe.DOT="dot",fe.CROSS="cross",fe.POW="pow",fe.MIX="mix",fe.CLAMP="clamp",fe.REFRACT="refract",fe.SMOOTHSTEP="smoothstep",fe.FACEFORWARD="faceforward";var gi=class extends le{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 Vs(gi.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new It(new Ae("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new It(new Ae("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new It(new Ae("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new It(new Ae("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let l={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(l),this.colorSpaceTLExp=new Ae(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Ae(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Ae(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Ae(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let c=new Ae("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 Vs(gi.Nodes.roughnessToMip,[i]),l=new fe(s,gi.Nodes.m0,gi.Nodes.cubeUV_maxMipLevel,fe.CLAMP),c=new fe(l,fe.FLOOR),u=new fe(l,fe.FRACT),a=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new ht(c,new Z(1).setReadonly(!0),ht.ADD)),p=new fe(a,d,u,fe.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)}},xi=gi;xi.Nodes=function(){let e=new hi(`struct TextureCubeUVData {
7
+ `))},Et.LINEAR_TO_LINEAR="LinearToLinear",Et.SRGB_TO_LINEAR="sRGBToLinear",Et.LINEAR_TO_SRGB="LinearTosRGB";var Ne=class extends U{constructor(e="",t,o,i,s){super(e,s,i,o,t);this.nodeType="Expression"}};var Sy=require("three"),Lt=class extends Be{constructor(e=new Sy.Texture,t,o,i){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t??new bi,this.bias=o,this.project=i!==void 0?i:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){if(t==="sampler2D")return this.getTexture(e,t);let o=this.getTexture(e,t),i=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let l,c;this.project?l="texture2DProj":l=s?"tex2DBias":"tex2D",s?c=l+"( "+o+", "+i+", "+s+" )":c=l+"( "+o+", "+i+" )";let u={include:e.isShader("vertex"),ignoreCache:!0},a=this.getType(e);return e.addContext(u),this.colorSpace=this.colorSpace??new Et(new Ne("",a)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(c),c=this.colorSpace.build(e,a),e.removeContext(),e.format(c,a,t)}};var Z=class extends Be{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,t,o,i,s,l){return e.format(this.value+(this.value%1?"":".0"),i,t)}};var zs=class extends le{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 l=this.value,c=l.build(e,t)+"( ",u=[];if(l.inputs){for(let a=0;a<l.inputs.length;a++){let d=l.inputs[a],p=this.inputs[a]||this.inputs[d.name];u.push(p.build(e,e.getTypeByFormat(d.type)))}c+=u.join(", ")+" )"}return e.format(c,i,t)}};var Bd=class extends le{constructor(e,t,o=Bd.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)}},yt=Bd;yt.ADD="+",yt.SUB="-",yt.MUL="*",yt.DIV="/";var De=class extends le{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,s,l=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,a=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case De.NEGATE:return e.format("( -"+this.a.build(e,a)+" )",a,t);case De.INVERT:return e.format("( 1.0 - "+this.a.build(e,a)+" )",a,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,l===1?"f":a),i=this.b.build(e,a);break;case De.MIN:case De.MAX:case De.MOD:o=this.a.build(e,a),i=this.b.build(e,c===1?"f":a);break;case De.REFRACT:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,"f");break;case De.MIX:o=this.a.build(e,a),i=this.b.build(e,a),s=this.c.build(e,u===1?"f":a);break;default:o=this.a.build(e,a),this.b&&(i=this.b.build(e,a)),this.c&&(s=this.c.build(e,a));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(", ")+" )",d,t)}},fe=De;fe.RAD="radians",fe.DEG="degrees",fe.EXP="exp",fe.EXP2="exp2",fe.LOG="log",fe.LOG2="log2",fe.SQRT="sqrt",fe.INV_SQRT="inversesqrt",fe.FLOOR="floor",fe.CEIL="ceil",fe.NORMALIZE="normalize",fe.FRACT="fract",fe.SATURATE="saturate",fe.SIN="sin",fe.COS="cos",fe.TAN="tan",fe.ASIN="asin",fe.ACOS="acos",fe.ARCTAN="atan",fe.ABS="abs",fe.SIGN="sign",fe.LENGTH="length",fe.NEGATE="negate",fe.INVERT="invert",fe.MIN="min",fe.MAX="max",fe.MOD="mod",fe.STEP="step",fe.REFLECT="reflect",fe.DISTANCE="distance",fe.DOT="dot",fe.CROSS="cross",fe.POW="pow",fe.MIX="mix",fe.CLAMP="clamp",fe.REFRACT="refract",fe.SMOOTHSTEP="smoothstep",fe.FACEFORWARD="faceforward";var Si=class extends le{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 zs(Si.Nodes.bilinearCubeUV,[t,o,i]);this.colorSpaceTL=this.colorSpaceTL??new Et(new Ne("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new Et(new Ne("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new Et(new Ne("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new Et(new Ne("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let l={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(l),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=s,c}generate(e,t){if(e.isShader("fragment")){let o=this.uv,i=this.bias||e.context.roughness,s=new zs(Si.Nodes.roughnessToMip,[i]),l=new fe(s,Si.Nodes.m0,Si.Nodes.cubeUV_maxMipLevel,fe.CLAMP),c=new fe(l,fe.FLOOR),u=new fe(l,fe.FRACT),a=this.bilinearCubeUV(e,this.value,o,c),d=this.bilinearCubeUV(e,this.value,o,new yt(c,new Z(1).setReadonly(!0),yt.ADD)),p=new fe(a,d,u,fe.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)}},wi=Si;wi.Nodes=function(){let e=new vi(`struct TextureCubeUVData {
8
8
  vec4 tl;
9
9
  vec4 tr;
10
10
  vec4 br;
@@ -69,7 +69,7 @@
69
69
  uv.x -= texelSize;
70
70
  vec4 bl = texture2D(envMap, uv);
71
71
  return TextureCubeUVData( tl, tr, br, bl, f );
72
- }`,[e,l,c,t,o,i,s]);u.useKeywords=!1;let a=new Te("float r0 1.0",!0),d=new Te("float v0 0.339",!0),p=new Te("float m0 -2.0",!0),f=new Te("float r1 0.8",!0),m=new Te("float v1 0.276",!0),h=new Te("float m1 -1.0",!0),y=new Te("float r4 0.4",!0),g=new Te("float v4 0.046",!0),v=new Te("float m4 2.0",!0),b=new Te("float r5 0.305",!0),w=new Te("float v5 0.016",!0),S=new Te("float m5 3.0",!0),T=new Te("float r6 0.21",!0),_=new Te("float v6 0.0038",!0),x=new Te("float m6 4.0",!0),C=[a,d,p,f,m,h,y,g,v,b,w,S,T,_,x],P=new U(`float roughnessToMip(float roughness) {
72
+ }`,[e,l,c,t,o,i,s]);u.useKeywords=!1;let a=new Te("float r0 1.0",!0),d=new Te("float v0 0.339",!0),p=new Te("float m0 -2.0",!0),f=new Te("float r1 0.8",!0),m=new Te("float v1 0.276",!0),h=new Te("float m1 -1.0",!0),y=new Te("float r4 0.4",!0),g=new Te("float v4 0.046",!0),v=new Te("float m4 2.0",!0),b=new Te("float r5 0.305",!0),w=new Te("float v5 0.016",!0),S=new Te("float m5 3.0",!0),P=new Te("float r6 0.21",!0),_=new Te("float v6 0.0038",!0),x=new Te("float m6 4.0",!0),C=[a,d,p,f,m,h,y,g,v,b,w,S,P,_,x],T=new U(`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,108 @@
83
83
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
84
84
  }
85
85
  return mip;
86
- }`,C);return{bilinearCubeUV:u,roughnessToMip:P,m0:p,cubeUV_maxMipLevel:t}}();var Ko=class extends le{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Ko.VIEW}getShared(){return this.scope===Ko.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 l;switch(this.scope){case Ko.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case Ko.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case Ko.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}},yt=Ko;yt.LOCAL="local",yt.WORLD="world",yt.VIEW="view",yt.NORMAL="normal";st.addKeyword("viewNormal",function(){return new yt(yt.VIEW)});st.addKeyword("localNormal",function(){return new yt(yt.NORMAL)});st.addKeyword("worldNormal",function(){return new yt(yt.WORLD)});var Vr=class extends le{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Vr.LOCAL}getType(){switch(this.scope){case Vr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Vr.LOCAL:case Vr.WORLD:return!1}return!0}generate(e,t,o,i,s){let l;switch(this.scope){case Vr.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case Vr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case Vr.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Vr.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}},Ft=Vr;Ft.LOCAL="local",Ft.WORLD="world",Ft.VIEW="view",Ft.PROJECTION="projection";st.addKeyword("position",function(){return new Ft});st.addKeyword("worldPosition",function(){return new Ft(Ft.WORLD)});st.addKeyword("viewPosition",function(){return new Ft(Ft.VIEW)});var vr=class extends le{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??vr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case vr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case vr.VECTOR:{let s=new yt(yt.VIEW),l=e.context.roughness,c=s.build(e,"v3"),u=new Ft(Ft.VIEW).build(e,"v3"),a=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;a&&(d=`normalize( mix( ${d}, ${c}, ${a} * ${a} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case vr.CUBE:{let s=new vr(vr.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),i="reflectCubeVec"):i=l;break}case vr.SPHERE:{let l="normalize( ( viewMatrix * vec4( "+new vr(vr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),i="reflectSphereVec"):i=l;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)}},zr=vr;zr.CUBE="cube",zr.SPHERE="sphere",zr.VECTOR="vector";var Vl=class extends le{constructor(e=new jt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new xi(this.value,t??new zr(zr.VECTOR),o),this.irradianceNode=new xi(this.value,new yt(yt.WORLD),new Z(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};var by=require("three");var zl=class extends Ve{constructor(e=new by.CubeTexture,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new zr,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 l;s?l="texCubeBias( "+o+", "+i+", "+s+" )":l="texCube( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new It(new Ae("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var Sy=["x","y","z","w"],aT=["float","vec2","vec3","vec4"],lT={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},cT={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.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 l=0;l<i.length;l++)i[l].src&&(s+=i[l].src+`
86
+ }`,C);return{bilinearCubeUV:u,roughnessToMip:T,m0:p,cubeUV_maxMipLevel:t}}();var Zo=class extends le{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Zo.VIEW}getShared(){return this.scope===Zo.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 l;switch(this.scope){case Zo.VIEW:e.isShader("vertex")?l="transformedNormal":l="geometryNormal";break;case Zo.LOCAL:e.isShader("vertex")?l="objectNormal":(e.requires.normal=!0,l="vObjectNormal");break;case Zo.WORLD:e.isShader("vertex")?l="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,l="vWNormal");break}return e.format(l,this.getType(e),t)}},gt=Zo;gt.LOCAL="local",gt.WORLD="world",gt.VIEW="view",gt.NORMAL="normal";lt.addKeyword("viewNormal",function(){return new gt(gt.VIEW)});lt.addKeyword("localNormal",function(){return new gt(gt.NORMAL)});lt.addKeyword("worldNormal",function(){return new gt(gt.WORLD)});var zr=class extends le{constructor(e){super("v3");this.nodeType="Position";this.scope=e??zr.LOCAL}getType(){switch(this.scope){case zr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case zr.LOCAL:case zr.WORLD:return!1}return!0}generate(e,t,o,i,s){let l;switch(this.scope){case zr.LOCAL:e.isShader("vertex")?l="transformed":(e.requires.position=!0,l="vPosition");break;case zr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,l="vWPosition";break;case zr.VIEW:l=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case zr.PROJECTION:l=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(l,this.getType(),t)}},Ut=zr;Ut.LOCAL="local",Ut.WORLD="world",Ut.VIEW="view",Ut.PROJECTION="projection";lt.addKeyword("position",function(){return new Ut});lt.addKeyword("worldPosition",function(){return new Ut(Ut.WORLD)});lt.addKeyword("viewPosition",function(){return new Ut(Ut.VIEW)});var wr=class extends le{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??wr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case wr.SPHERE:return"v2"}return this.type}generate(e,t){let o=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case wr.VECTOR:{let s=new gt(gt.VIEW),l=e.context.roughness,c=s.build(e,"v3"),u=new Ut(Ut.VIEW).build(e,"v3"),a=l?l.build(e,"f"):void 0,d=`reflect( -normalize( ${u} ), ${c} )`;a&&(d=`normalize( mix( ${d}, ${c}, ${a} * ${a} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),i="reflectVec"):i=p;break}case wr.CUBE:{let s=new wr(wr.VECTOR).build(e,"v3"),l="vec3( -"+s+".x, "+s+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${l};`),i="reflectCubeVec"):i=l;break}case wr.SPHERE:{let l="normalize( ( viewMatrix * vec4( "+new wr(wr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${l};`),i="reflectSphereVec"):i=l;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)}},jr=wr;jr.CUBE="cube",jr.SPHERE="sphere",jr.VECTOR="vector";var zl=class extends le{constructor(e=new Lt,t,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new wi(this.value,t??new jr(jr.VECTOR),o),this.irradianceNode=new wi(this.value,new gt(gt.WORLD),new Z(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}};var wy=require("three");var jl=class extends Be{constructor(e=new wy.CubeTexture,t,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t??new jr,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 l;s?l="texCubeBias( "+o+", "+i+", "+s+" )":l="texCube( "+o+", "+i+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new Et(new Ne("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,t)}};var _y=`
87
+ uniform int frameIndex;
88
+ uniform vec2 resolution;
89
+ uniform mat4 previousModelViewMatrix;
90
+ uniform mat4 previousProjectionMatrix;
91
+
92
+ varying vec4 vCurrentPosition;
93
+ varying vec4 vPreviousPosition;
94
+ `,Py=`
95
+ layout(location = 1) out vec4 gVelocity;
96
+
97
+ uniform int frameIndex;
98
+ uniform vec2 resolution;
99
+
100
+ varying vec4 vCurrentPosition;
101
+ varying vec4 vPreviousPosition;
102
+
103
+ const vec2 haltonSequence[16] = vec2[16](
104
+ vec2( 0.000000,-0.333334),
105
+ vec2(-0.500000, 0.333334),
106
+ vec2( 0.500000,-0.777778),
107
+ vec2(-0.750000,-0.111112),
108
+ vec2( 0.250000, 0.555556),
109
+ vec2(-0.250000,-0.555556),
110
+ vec2( 0.750000, 0.111112),
111
+ vec2(-0.875000, 0.777778),
112
+ vec2(0.125000, -0.925926),
113
+ vec2(-0.375000, -0.259260),
114
+ vec2(0.625000, 0.407408),
115
+ vec2(-0.625000, -0.703704),
116
+ vec2(0.375000, -0.037038),
117
+ vec2(-0.125000, 0.629630),
118
+ vec2(0.875000, -0.481482),
119
+ vec2(-0.937500, 0.185186));
120
+
121
+ vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {
122
+ const float goldenAngle = 2.399963f; // radians
123
+ float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));
124
+ float theta = float(sampleIndex) * goldenAngle + angle;
125
+ float sine = sin(theta);
126
+ float cosine = cos(theta);
127
+ return vec2(cosine, sine) * r;
128
+ }
129
+
130
+ // Derived from the interleaved gradient function from Jimenez 2014 http:goo.gl/eomGso
131
+ float getNoiseInterleavedGradient(vec2 screenPos) {
132
+ vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
133
+ return fract(magic.z * fract(dot(screenPos, magic.xy)));
134
+ }
135
+
136
+ `,Ty=`
137
+ // TODO: This could be generated CPU side and passed to the shader every frame
138
+ const vec2 haltonSequence[16] = vec2[16](
139
+ vec2( 0.000000,-0.333334),
140
+ vec2(-0.500000, 0.333334),
141
+ vec2( 0.500000,-0.777778),
142
+ vec2(-0.750000,-0.111112),
143
+ vec2( 0.250000, 0.555556),
144
+ vec2(-0.250000,-0.555556),
145
+ vec2( 0.750000, 0.111112),
146
+ vec2(-0.875000, 0.777778),
147
+ vec2(0.125000, -0.925926),
148
+ vec2(-0.375000, -0.259260),
149
+ vec2(0.625000, 0.407408),
150
+ vec2(-0.625000, -0.703704),
151
+ vec2(0.375000, -0.037038),
152
+ vec2(-0.125000, 0.629630),
153
+ vec2(0.875000, -0.481482),
154
+ vec2(-0.937500, 0.185186));
155
+
156
+ // TODO: Pass correct view size
157
+ vec2 offset = haltonSequence[frameIndex];
158
+ offset.x /= resolution.x;
159
+ offset.y /= resolution.y;
160
+
161
+ vec4 currentPosition = gl_Position;
162
+ vec4 currentPositionJittered = currentPosition + (vec4(offset.x, offset.y, 0.0, 0.0) * currentPosition.w);
163
+
164
+ // We want to calculate the velocity with unjittered positions
165
+ // so that things that are not moving get a velocity = 0
166
+ vCurrentPosition = currentPosition;
167
+ vPreviousPosition = previousProjectionMatrix * previousModelViewMatrix * vec4(transformed, 1.0);
168
+ #ifdef OUTLINE_COMPENSATION
169
+ vPreviousPosition.xy += OUTLINE_COMPENSATION;
170
+ #endif
171
+ gl_Position = currentPositionJittered;
172
+
173
+ `,Oy=`
174
+ vec2 oldPos = vPreviousPosition.xy;
175
+ oldPos /= vPreviousPosition.w;
176
+ oldPos.xy = (oldPos.xy+1.)/2.0;
177
+
178
+ vec2 newPos = vCurrentPosition.xy;
179
+ newPos /= vCurrentPosition.w;
180
+ newPos.xy = (newPos.xy+1.)/2.0;
181
+
182
+ vec2 velocity = (newPos - oldPos);
183
+
184
+ // NOTE: We use the blue channel to avoid temporal reprojection
185
+ // with incorrect velocity if the fragment is transparent.
186
+ gVelocity = vec4(velocity, gl_FragColor.a < 1.0 ? 0.0 : 1.0, 1.);
187
+ `;var Ay=["x","y","z","w"],hP=["float","vec2","vec3","vec4"],yP={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},gP={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[]"},Fl=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};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 l=0;l<i.length;l++)i[l].src&&(s+=i[l].src+`
87
188
  `);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",`
88
189
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
89
190
  #define SPE_BLENDING_NORMAL 0
@@ -121,40 +222,20 @@
121
222
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
122
223
  accumAlpha += (1.0 - accumAlpha) * alpha;
123
224
  }`,""].join(`
124
- `)},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.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}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+`
225
+ `)},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(_y),this.addFragmentParsCode(Py),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.addVertexFinalCode(Ty),this.addFragmentFinalCode(Oy),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+`
125
226
  `}addVertexNodeCode(r){this.addNodeCode(r,"vertex")}addFragmentNodeCode(r){this.addNodeCode(r,"fragment")}addNodeCode(r,e){this.nodeCode[e??this.shader]+=r+`
126
227
  `}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+`
127
228
  `}addVertexParsCode(r){this.addParsCode(r,"vertex")}addFragmentParsCode(r){this.addParsCode(r,"fragment")}addParsCode(r,e){this.parsCode[e??this.shader]+=r+`
128
229
  `}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 l=this.getVars(o),c=l[r];if(!c){let u=l.length;c={name:t||"node"+i+u+(s?"_"+s:""),type:e},l.push(c),l[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(`
129
230
  `)}getVarListCode(r,e){e=e??"";let t="";for(let o=0,i=r.length;o<i;++o){let s=r[o],l=s.type,c=s.name,u=s.size,a=this.getFormatByType(l);if(a===void 0)throw new Error("Node pars "+a+" not found.");a.includes("[]")?t+=e+" "+a.substring(0,a.length-2)+" "+c+`[${u}];
130
231
  `:t+=e+" "+a+" "+c+`;
131
- `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof mt?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,s){if(e.includes("[]")){let l=this.inputs.arrayUniforms,c=l.list.length,u=new Rs({type:e,size:t.size,name:o||"nodeUA"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[r][u.name]=u,this.uniforms[u.name]=u,u}else{let l=this.inputs.uniforms,c=l.list.length,u=new Rs({type:e,name:o||"nodeU"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[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"?st.get(r):r,this.context.include===!1)return r.name;r instanceof U?o=this.includes.functions:r instanceof Te?o=this.includes.consts:r instanceof hi&&(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 U&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let l=0;do this.include(r.includes[l++],e);while(l<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 aT[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 br.CubeReflectionMapping:case br.CubeRefractionMapping:return new zl(t);case br.CubeUVReflectionMapping:return new Vl(new jt(t));default:return new jt(t)}else{if(t.isVector2)return new Qe(t);if(t.isVector3)return new St(t);if(t.isVector4)return new zt(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 lT[r]||r}getFormatByType(r){return cT[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Sy[r]}getIndexByElement(r){return Sy.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=br.LinearEncoding,e===br.LinearEncoding&&this.context.gamma&&(e=br.sRGBEncoding),e}};var Be=require("three");var Ie=class extends Ve{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof at?e:new at(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,s,l){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 a=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${a};`)}return u?this.generateReadonly(e,t,o,i,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var Se=class extends Ve{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,s,l){return e.format(this.value.toString(),i,t)}};var Fl=require("three");var Zo=class extends mt{constructor(){super("basic");this.nodeType="Basic";this.color=new Ie(5526619),this.shadingAlpha=new Z(1),this.shadingBlend=new Se(0)}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(Fl.UniformsUtils.merge([Fl.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
132
- `));let i=["#include <beginnormal_vertex>",`
133
- #if !defined( USE_LAYER_DISPLACE )
134
- #include <defaultnormal_vertex>
135
- #endif
136
-
137
- vec3 displaced_position = position;
138
- vec3 displaced_normal = normal;
139
-
140
- #if defined( USE_LAYER_DISPLACE )
141
- vec3 transformed;
142
- vec3 transformedNormal;
143
- #endif
144
- `,"#include <normal_vertex>",`
145
- #if !defined( USE_LAYER_DISPLACE )
146
- #include <begin_vertex>
147
- #endif /* !USE_LAYER_DISPLACE */
148
- `];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(`
149
- `)}else{this.color===void 0&&(this.color=new Ie(5526619)),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.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(`
150
- `));let l=["#include <normal_fragment_begin>",o.code];i&&l.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${c} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
151
- `)}return t}};var Fs=require("three");var Sr=class extends Ve{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};var wr=class extends Ve{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 wy=require("three");var Ao=class extends Ve{};var kl=class extends Ao{constructor(e){super("v3");this.image=e;this._value=new wy.Vector3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var Qo=class extends Ao{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};var _y=require("three");var vi=class extends Ve{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new _y.Matrix3}generateReadonly(e,t,o,i,s,l){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Py=require("three");function Ty(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var Ul=class extends vi{constructor(e,t){super(new Py.Matrix3);this.repeat=e;this.offset=t;Ty(this.value,e,t)}updateMatrix(){Ty(this.value,this.repeat,this.offset)}};var Ld=require("three");var _r=class extends Ve{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Ld.Vector4?new Array(e).fill(t):new Array(e).fill(new Ld.Vector4(0))}};var bi=class extends le{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 Bd=class extends le{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(Bd.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)}},Jo=Bd;Jo.Nodes=function(){return{customColor:new U(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
232
+ `}return t}getVars(r){return this.inputs.vars[r??this.shader]}getNodeData(r){let e=r instanceof ht?r.uuid:r;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(r,e,t,o,i,s){if(e.includes("[]")){let l=this.inputs.arrayUniforms,c=l.list.length,u=new Vs({type:e,size:t.size,name:o||"nodeUA"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[r][u.name]=u,this.uniforms[u.name]=u,u}else{let l=this.inputs.uniforms,c=l.list.length,u=new Vs({type:e,name:o||"nodeU"+c+(s?"_"+s:""),node:t,needsUpdate:i});return l.list.push(u),l[r].push(u),l[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"?lt.get(r):r,this.context.include===!1)return r.name;r instanceof U?o=this.includes.functions:r instanceof Te?o=this.includes.consts:r instanceof vi&&(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 U&&e&&i[e.name]&&i[e.name].deps.indexOf(r)===-1&&(i[e.name].deps.push(r),r.includes?.length)){let l=0;do this.include(r.includes[l++],e);while(l<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 hP[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 _r.CubeReflectionMapping:case _r.CubeRefractionMapping:return new jl(t);case _r.CubeUVReflectionMapping:return new zl(new Lt(t));default:return new Lt(t)}else{if(t.isVector2)return new Je(t);if(t.isVector3)return new _t(t);if(t.isVector4)return new kt(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 yP[r]||r}getFormatByType(r){return gP[r]||r}getUUID(r,e){return e=e!==void 0?e:!0,e&&this.cache&&(r=this.cache+"-"+r),r}getElementByIndex(r){return Ay[r]}getIndexByElement(r){return Ay.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=_r.LinearEncoding,e===_r.LinearEncoding&&this.context.gamma&&(e=_r.sRGBEncoding),e}};var Ge=require("three");var Me=class extends Be{constructor(e=0,t,o,i){super("c");this.nodeType="Color";this.value=e instanceof ct?e:new ct(e||0,t,o,i)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,o,i,s,l){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 a=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${a};`)}return u?this.generateReadonly(e,t,o,i,s,l):e.isShader("vertex")?(c.vertex||(c.vertex=e.createVertexUniform(i,this,s,l,this.getLabel())),e.format(c.vertex.name,i,t)):(c.fragment||(c.fragment=e.createFragmentUniform(i,this,s,l,this.getLabel())),e.format(c.fragment.name,i,t))}generateReadonly(e,t,o,i,s,l){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}};var we=class extends Be{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,t,o,i,s,l){return e.format(this.value.toString(),i,t)}};var Hl=require("three");var et=class extends Be{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 Pr=class extends Be{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}};var Ny=require("three");var No=class extends Be{};var kl=class extends No{constructor(e){super("v3");this.image=e;this._value=new Ny.Vector3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var Qo=class extends No{constructor(e,t){super("t");this.image=e;this.wrap=t}get value(){return this.image.getTexture(this.wrap)}};var Cy=require("three");var _i=class extends Be{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Cy.Matrix3}generateReadonly(e,t,o,i,s,l){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Iy=require("three");var Pt=class extends Be{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new Iy.Matrix4}generateReadonly(e,t,o,i,s,l){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Ey=require("three");function My(n,r,e){n.setUvTransform(e[0],e[1],r[0],r[1],0,0,0)}var Ul=class extends _i{constructor(e,t){super(new Ey.Matrix3);this.repeat=e;this.offset=t;My(this.value,e,t)}updateMatrix(){My(this.value,this.repeat,this.offset)}};var Dd=require("three");var Tr=class extends Be{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Dd.Vector4?new Array(e).fill(t):new Array(e).fill(new Dd.Vector4(0))}};var Pi=class extends le{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 Gd=class extends le{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(Gd.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)}},Jo=Gd;Jo.Nodes=function(){return{customColor:new U(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
152
233
  float lalpha = alpha * mask;
153
234
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
154
235
  accumAlpha += (1.0 - accumAlpha) * lalpha;
155
236
 
156
237
  return color;
157
- }`)}}();var Dd=class extends le{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)}},Si=Dd;Si.Nodes=function(){return{customNormal:new U(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
238
+ }`)}}();var Rd=class extends le{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(Rd.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)}},Ti=Rd;Ti.Nodes=function(){return{customNormal:new U(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
158
239
  vec3 normal = packNormalToRGB( norm ).rgb;
159
240
  normal *= step( vec3(0.5), cnormal );
160
241
 
@@ -163,7 +244,7 @@
163
244
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
164
245
 
165
246
  return normal;
166
- }`)}}();var wi=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=s,this.side=l,this.size=c,this.blending=u,this.mat=a,this.alpha=d,this.mode=p,this.isMask=f,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(wi.Nodes.cylindrical);break;case 2:i=e.include(wi.Nodes.spherical);break;case 1:let l=["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=new U(`
247
+ }`)}}();var Oi=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=o,this.projection=i,this.axis=s,this.side=l,this.size=c,this.blending=u,this.mat=a,this.alpha=d,this.mode=p,this.isMask=f,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(Oi.Nodes.cylindrical);break;case 2:i=e.include(Oi.Nodes.spherical);break;case 1:let l=["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=new U(`
167
248
  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) {
168
249
 
169
250
  vec2 uvs = ( mat * vec3( (${o}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -186,7 +267,7 @@
186
267
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
187
268
 
188
269
  return col;
189
- }`);i=e.include(c);break;case 4:i=e.include(wi.Nodes.triplanar);break;default:i=e.include(wi.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){e.addVertexParsCode(`varying vec2 ${o}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${o}_vCustomUv;`);let l=["zy","xz","xy"][this.axis.value];e.addVertexFinalCode(`${o}_vCustomUv = (1. + (transformed.${l})) / 2.;`)}e.addFragmentVariable(this.calpha,"float");let s=[];return 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.firstTime=!this.firstTime,e.format(i+"("+s.join(",")+")",this.getType(e),t)}},_i=wi;_i.Nodes=function(){let e=new U(`
270
+ }`);i=e.include(c);break;case 4:i=e.include(Oi.Nodes.triplanar);break;default:i=e.include(Oi.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){e.addVertexParsCode(`varying vec2 ${o}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${o}_vCustomUv;`);let l=["zy","xz","xy"][this.axis.value];e.addVertexFinalCode(`${o}_vCustomUv = (1. + (transformed.${l})) / 2.;`)}e.addFragmentVariable(this.calpha,"float");let s=[];return 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.firstTime=!this.firstTime,e.format(i+"("+s.join(",")+")",this.getType(e),t)}},Ai=Oi;Ai.Nodes=function(){let e=new U(`
190
271
  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) {
191
272
  vec3 posN = normalize(position);
192
273
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -332,7 +413,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
332
413
 
333
414
  return col;//n * 0.5 + 0.5;
334
415
  }
335
- `);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var Ti=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=s,this.isWorldSpace=l,this.origin=c,this.direction=u,this.colors=a,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 U(`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) {
416
+ `);return{cylindrical:e,spherical:t,uv:o,triplanar:i}}();var Ni=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=o,this.far=i,this.isVector=s,this.isWorldSpace=l,this.origin=c,this.direction=u,this.colors=a,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 U(`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) {
336
417
  vec4 color = colors[0];
337
418
  #ifdef ${o}_IS_VECTOR
338
419
  #ifdef ${o}_LINEAR
@@ -372,7 +453,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
372
453
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
373
454
 
374
455
  return color.rgb;
375
- }`,[Ti.Nodes.vectorLinearWorldSpaceDepth,Ti.Nodes.vectorLinearObjectSpaceDepth,Ti.Nodes.vectorSphericalObjectSpaceDepth,Ti.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),l=[];return l.push(this.near.build(e,"f")),l.push(this.far.build(e,"f")),l.push(this.origin.build(e,"v3")),l.push(this.direction.build(e,"v3")),l.push(this.colors.build(e,"v4[]")),l.push(this.steps.build(e,"f[]")),l.push(this.isMask.build(e,"b")),l.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.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)}},Pi=Ti;Pi.Nodes=function(){let e=new U(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
456
+ }`,[Ni.Nodes.vectorLinearWorldSpaceDepth,Ni.Nodes.vectorLinearObjectSpaceDepth,Ni.Nodes.vectorSphericalObjectSpaceDepth,Ni.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),l=[];return l.push(this.near.build(e,"f")),l.push(this.far.build(e,"f")),l.push(this.origin.build(e,"v3")),l.push(this.direction.build(e,"v3")),l.push(this.colors.build(e,"v4[]")),l.push(this.steps.build(e,"f[]")),l.push(this.isMask.build(e,"b")),l.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),l.push(this.alpha.build(e,"f")),l.push(this.calpha),e.format(s+"("+l.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)}},Ci=Ni;Ci.Nodes=function(){let e=new U(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
376
457
  vec3 n = normalize(direction);
377
458
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
378
459
  return ( dist - near ) / ( far - near );
@@ -386,7 +467,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
386
467
  }`),i=new U(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
387
468
  float dist = length(position - origin);
388
469
  return ( dist - near ) / ( far - near );
389
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var zs=class extends le{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=s,this.isMask=u,this.alpha=l,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 U(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
470
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:o,vectorSphericalObjectSpaceDepth:i}}();var js=class extends le{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=o,this.intensity=i,this.factor=s,this.isMask=u,this.alpha=l,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 U(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, bool isMask, float mask, float alpha, int mode, out float calpha) {
390
471
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
391
472
 
392
473
  float lalpha = clamp(fresnel, 0.0, 1.0) * alpha * mask;
@@ -394,7 +475,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
394
475
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
395
476
 
396
477
  return color;
397
- }`),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 Gd=class extends le{constructor(e,t,o,i,s,l,c,u,a){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=s,this.morph=l,this.angle=c,this.isMask=a,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(Gd.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)}},Oi=Gd;Oi.Nodes=function(){return{gradient:new U(`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) {
478
+ }`),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 Vd=class extends le{constructor(e,t,o,i,s,l,c,u,a){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=o,this.steps=i,this.offset=s,this.morph=l,this.angle=c,this.isMask=a,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(Vd.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)}},Ii=Vd;Ii.Nodes=function(){return{gradient:new U(`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) {
398
479
  vec4 color = colors[0];
399
480
  vec2 m = morph / vUv.xy;
400
481
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -436,7 +517,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
436
517
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
437
518
 
438
519
  return color.xyz;
439
- }`)}}();var Rd=class extends le{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(Rd.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)}},Ai=Rd;Ai.Nodes=function(){return{matcap:new U(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
520
+ }`)}}();var zd=class extends le{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(zd.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)}},Mi=zd;Mi.Nodes=function(){return{matcap:new U(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha) {
440
521
  vec3 viewDir = normalize( vViewPosition );
441
522
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
442
523
  vec3 y = cross( viewDir, x );
@@ -448,7 +529,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
448
529
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
449
530
 
450
531
  return matcapColor.rgb;
451
- }`)}}();var js=(s=>(s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin",s.VORONOI="voronoi",s))(js||{}),gt=function(){let r=new U(`vec3 random3(vec3 c) {
532
+ }`)}}();var Fs=(s=>(s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin",s.VORONOI="voronoi",s))(Fs||{}),xt=function(){let r=new U(`vec3 random3(vec3 c) {
452
533
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
453
534
  vec3 r;
454
535
  r.z = fract(512.0*j);
@@ -801,7 +882,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
801
882
  return hashwithoutsine13(vec3(p + mb) + seed);
802
883
  }
803
884
  }
804
- `,[f,m,h,y,g,v]);return{simplex:e,simplexFractal:t,simplexAshima:s,fbm:a,perlin:p,voronoi:b}}();var Ni=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b,w){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=s,this.distortion=l,this.colorA=c,this.colorB=u,this.colorC=a,this.colorD=d,this.noiseType=f,this.voronoiStyle=h,this.highCut=y,this.lowCut=g,this.smoothness=v,this.seed=b,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 l=Object.values(js)[this.noiseType.value],c=l=="voronoi"?`
885
+ `,[f,m,h,y,g,v]);return{simplex:e,simplexFractal:t,simplexAshima:s,fbm:a,perlin:p,voronoi:b}}();var Ei=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b,w){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=o,this.fA=i,this.fB=s,this.distortion=l,this.colorA=c,this.colorB=u,this.colorC=a,this.colorD=d,this.noiseType=f,this.voronoiStyle=h,this.highCut=y,this.lowCut=g,this.smoothness=v,this.seed=b,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 l=Object.values(Fs)[this.noiseType.value],c=l=="voronoi"?`
805
886
  float v = ${l}(st + move, voronoiStyle, smoothness, seed, quality);
806
887
 
807
888
  // Apply clipping to colors
@@ -838,37 +919,43 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
838
919
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
839
920
 
840
921
  return clamp(color, 0.0, 1.0).rgb;
841
- }`,[gt.simplex,gt.simplexFractal,gt.simplexAshima,gt.fbm,gt.perlin,gt.voronoi]),a=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(a+"("+d.join(",")+")",this.getType(e),t)}};Ni.numOctaves=5;var Vd=class extends le{constructor(e,t,o,i,s,l,c,u,a,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=s,this.outlineThreshold=l,this.contourFrequency=c,this.outlineSmoothing=u,this.contourDirection=a,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){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.firstTime){let o=this.outlineWidth.build(e,"f"),i=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(o,"uniform float"),e.addVertexParsVariable(i,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float");let c=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexFinalCode(`
922
+ }`,[xt.simplex,xt.simplexFractal,xt.simplexAshima,xt.fbm,xt.perlin,xt.voronoi]),a=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(a+"("+d.join(",")+")",this.getType(e),t)}};Ei.numOctaves=5;var jd=class extends le{constructor(e,t,o,i,s,l,c,u,a,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=s,this.outlineThreshold=l,this.contourFrequency=c,this.outlineSmoothing=u,this.contourDirection=a,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"),s=this.resolution.build(e,"v2"),l=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(l,"uniform bool"),e.addVertexParsVariable(c,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
842
923
  vID = randomColor.r;
843
- if (${s}) {
844
- vec4 ${c}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
924
+ vec2 ${o}_offset = vec2(0.0);
925
+ if (${l}) {
926
+ vec4 ${o}_clipPosition = projectionMatrix * (modelViewMatrix * vec4(position, 1.0));
845
927
  // NOTE: For certain shapes, like spheres, we get incorrect extrusion when the
846
928
  // normals face the camera directly. So we hackily fix this by offsetting the normal
847
929
  // by a tiny amount.
848
- vec3 ${c}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
849
- vec2 ${c}_offset = normalize(${c}_clipNormal.xy) / ${i} * (${o} / 2.0) * ${c}_clipPosition.w * 2.0 * ${l};
850
- ${c}_clipPosition.xy += ${c}_offset;
930
+ vec3 ${o}_clipNormal = mat3(projectionMatrix) * (mat3(modelViewMatrix) * extrudeNormal) + 0.0000001;
931
+ ${o}_offset = normalize(${o}_clipNormal.xy) / ${s} * (${i} / 2.0) * ${o}_clipPosition.w * 2.0 * ${c};
932
+ ${o}_clipPosition.xy += ${o}_offset;
851
933
  // TODO(MAX): To handle multiple outline layers, we only want to extrude
852
934
  // if this offset is the biggest of all the potential offsets
853
- gl_Position = ${c}_clipPosition;
935
+ gl_Position = ${o}_clipPosition;
854
936
  }
855
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(Vd.Nodes.outline),i=[];return i.push(this.outlineColor.build(e,"c")),i.push(this.contourColor.build(e,"c")),i.push(this.outlineWidth.build(e,"f")),i.push(this.contourWidth.build(e,"f")),i.push(this.contourThreshold.build(e,"f")),i.push(this.outlineThreshold.build(e,"f")),i.push(this.contourFrequency.build(e,"f")),i.push(this.outlineSmoothing.build(e,"f")),i.push(this.contourDirection.build(e,"v3")),i.push(this.positionalLines.build(e,"b")),i.push(this.resolution.build(e,"v2")),i.push(this.normalMap.getTexture(e,"t")),i.push(this.depthMap.getTexture(e,"t")),i.push(this.pixelRatio.build(e,"f")),i.push(this.compensation.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),this.firstTime=!this.firstTime,e.format(o+"("+i.join(",")+")",this.getType(e),t)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Ci=Vd;Ci.Nodes=function(){let e=new U(`
937
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let i=e.include(jd.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."),""}},Li=jd;Li.Nodes=function(){let e=new U(`
856
938
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
857
939
  {
858
- vec2 texelSize = (vec2(1.0) / resolution) * outlineWidth * pixelRatio;
940
+ vec2 halton = haltonSequence[frameIndex];
941
+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
942
+ float temporalAngle = temporalOffset * PI2;
943
+
944
+ vec2 texelSize = (vec2(1.0) / resolution);
945
+ vec2 offsetSize = texelSize * outlineWidth * pixelRatio;
859
946
 
860
947
  vec2 uvSamples[9];
861
948
  vec4 normalSamples[9];
862
949
 
863
- uvSamples[0] = uv + vec2( -texelSize.x, -texelSize.y);
864
- uvSamples[1] = uv + vec2(0.0, -texelSize.y);
865
- uvSamples[2] = uv + vec2( texelSize.x, -texelSize.y);
866
- uvSamples[3] = uv + vec2( -texelSize.x, 0.0);
950
+ uvSamples[0] = uv + vec2( -offsetSize.x, -offsetSize.y) + (vogelDiskSample(0, 9, temporalAngle) * texelSize);
951
+ uvSamples[1] = uv + vec2(0.0, -offsetSize.y) + (vogelDiskSample(1, 9, temporalAngle) * texelSize);
952
+ uvSamples[2] = uv + vec2( offsetSize.x, -offsetSize.y) + (vogelDiskSample(2, 9, temporalAngle) * texelSize);
953
+ uvSamples[3] = uv + vec2( -offsetSize.x, 0.0) + (vogelDiskSample(3, 9, temporalAngle) * texelSize);
867
954
  uvSamples[4] = uv;
868
- uvSamples[5] = uv + vec2( texelSize.x, 0.0);
869
- uvSamples[6] = uv + vec2( -texelSize.x, texelSize.y);
870
- uvSamples[7] = uv + vec2(0.0, texelSize.y);
871
- uvSamples[8] = uv + vec2( texelSize.x, texelSize.y);
955
+ uvSamples[5] = uv + vec2( offsetSize.x, 0.0) + (vogelDiskSample(5, 9, temporalAngle) * texelSize);
956
+ uvSamples[6] = uv + vec2( -offsetSize.x, offsetSize.y) + (vogelDiskSample(6, 9, temporalAngle) * texelSize);
957
+ uvSamples[7] = uv + vec2(0.0, offsetSize.y) + (vogelDiskSample(7, 9, temporalAngle) * texelSize);
958
+ uvSamples[8] = uv + vec2( offsetSize.x, offsetSize.y) + (vogelDiskSample(8, 9, temporalAngle) * texelSize);
872
959
 
873
960
 
874
961
  normalSamples[0] = texture2D(t, uvSamples[0]);
@@ -947,8 +1034,8 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
947
1034
  }
948
1035
  }
949
1036
 
950
- vec4 sobel_edge_h = normalSamples[2] + (2.0*normalSamples[5]) + normalSamples[8] - (normalSamples[0] + (2.0*normalSamples[3]) + normalSamples[6]);
951
- vec4 sobel_edge_v = normalSamples[0] + (2.0*normalSamples[1]) + normalSamples[2] - (normalSamples[6] + (2.0*normalSamples[7]) + normalSamples[8]);
1037
+ vec3 sobel_edge_h = normalSamples[2].rgb + (2.0*normalSamples[5].rgb) + normalSamples[8].rgb - (normalSamples[0].rgb + (2.0*normalSamples[3].rgb) + normalSamples[6].rgb);
1038
+ vec3 sobel_edge_v = normalSamples[0].rgb + (2.0*normalSamples[1].rgb) + normalSamples[2].rgb - (normalSamples[6].rgb + (2.0*normalSamples[7].rgb) + normalSamples[8].rgb);
952
1039
 
953
1040
  float edgeNormal = sqrt(dot(sobel_edge_h, sobel_edge_h) + dot(sobel_edge_v, sobel_edge_v));
954
1041
  return edgeNormal;
@@ -962,6 +1049,9 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
962
1049
  float sobelSample = compensation ? sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth / 2., pixelRatio) : sobelSample(normalMap, depthMap, nuv, resolution, outlineWidth, pixelRatio);
963
1050
  resultAlpha = smoothstep(outlineThreshold - outlineSmoothing, outlineThreshold + outlineSmoothing, sobelSample);
964
1051
 
1052
+ //resultAlpha = 1.0;
1053
+ //result = vec3(sobelSample);
1054
+
965
1055
  float t = 1.0 - contourThreshold;
966
1056
  if(positionalLines) {
967
1057
  vec3 NDir = position * contourDirection;
@@ -993,7 +1083,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
993
1083
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
994
1084
 
995
1085
  return result;
996
- }`,[e])}}();var jr=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b){super("v3");this.nodeType="Pattern";this.style=e,this.projection=t,this.axis=o,this.blending=i,this.offset=s,this.colorA=l,this.colorB=c,this.frequency=u,this.size=a,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=m,this.vertical=h,this.horizontal=y,this.sides=g,this.isMask=b,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,s=new U(`float hashwithoutsine12(vec2 p)
1086
+ }`,[e])}}();var Fr=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b){super("v3");this.nodeType="Pattern";this.style=e,this.projection=t,this.axis=o,this.blending=i,this.offset=s,this.colorA=l,this.colorB=c,this.frequency=u,this.size=a,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=m,this.vertical=h,this.horizontal=y,this.sides=g,this.isMask=b,this.alpha=v,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let i=`g${this.uuid.toString().replace(/-/g,"")}`,s=new U(`float hashwithoutsine12(vec2 p)
997
1087
  {
998
1088
  vec3 p3 = fract(vec3(p.xyx) * .1031);
999
1089
  p3 += dot(p3, p3.yzx + 33.33);
@@ -1079,7 +1169,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1079
1169
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1080
1170
 
1081
1171
  return clamp(color, 0.0, 1.0).rgb;
1082
- }`,[l,s,jr.DrawFunctions.circle,jr.DrawFunctions.ring,jr.DrawFunctions.polygon,jr.DrawFunctions.cross,jr.DrawFunctions.diamond,jr.DrawFunctions.checkerboard,jr.DrawFunctions.line,jr.DrawFunctions.wave]),a=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(a+"("+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)}},Ii=jr;Ii.DrawFunctions=function(){let e=new U(`float hashwithoutsine12(vec2 p) {
1172
+ }`,[l,s,Fr.DrawFunctions.circle,Fr.DrawFunctions.ring,Fr.DrawFunctions.polygon,Fr.DrawFunctions.cross,Fr.DrawFunctions.diamond,Fr.DrawFunctions.checkerboard,Fr.DrawFunctions.line,Fr.DrawFunctions.wave]),a=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(a+"("+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)}},Bi=Fr;Bi.DrawFunctions=function(){let e=new U(`float hashwithoutsine12(vec2 p) {
1083
1173
  vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1084
1174
  p3 += dot(p3, p3.yzx + 33.33);
1085
1175
  return fract((p3.x + p3.y) * p3.z);
@@ -1244,7 +1334,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1244
1334
  float s = mix(size, size * rand, variation);
1245
1335
 
1246
1336
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1247
- }`);return{tileAndCenter:t,circle:o,ring:i,polygon:s,cross:l,diamond:c,checkerboard:u,line:a,wave:d}}();var zd=class extends le{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=s,this.offset=l,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(zd.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)}},Mi=zd;Mi.Nodes=function(){let e=new U(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1337
+ }`);return{tileAndCenter:t,circle:o,ring:i,polygon:s,cross:l,diamond:c,checkerboard:u,line:a,wave:d}}();var Fd=class extends le{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=o,this.noiseStrength=i,this.noiseScale=s,this.offset=l,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(Fd.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)}},Di=Fd;Di.Nodes=function(){let e=new U(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1248
1338
  vec3 st = position / noiseScale;
1249
1339
  vec3 q = vec3(simplex3d(st),
1250
1340
  simplex3d(st + vec3(1.0)),
@@ -1257,7 +1347,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1257
1347
  float noise = simplex3d(st + r);
1258
1348
 
1259
1349
  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);
1260
- }`,[gt.simplex]);return{rainbow:new U(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
1350
+ }`,[xt.simplex]);return{rainbow:new U(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, bool isMask, float mask, float alpha, out float calpha) {
1261
1351
  vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
1262
1352
 
1263
1353
  float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
@@ -1267,7 +1357,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1267
1357
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1268
1358
 
1269
1359
  return res;
1270
- }`,[e])}}();var jd=class extends le{constructor(e,t,o,i,s,l,c,u,a,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=s,this.noiseStrength=l,this.noiseScale=c,this.shadowColor=u,this.offset=a,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(jd.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)}},Ei=jd;Ei.Nodes=function(){let e=new U(`float rand(float n) {
1360
+ }`,[e])}}();var kd=class extends le{constructor(e,t,o,i,s,l,c,u,a,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=t,this.steps=o,this.source=i,this.isWorldSpace=s,this.noiseStrength=l,this.noiseScale=c,this.shadowColor=u,this.offset=a,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(kd.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)}},Gi=kd;Gi.Nodes=function(){let e=new U(`float rand(float n) {
1271
1361
  return fract(sin(n) * 43758.5453123);
1272
1362
  }`),t=new U(`float hash1(float p) {
1273
1363
  p = fract(p * 0.011);
@@ -1503,11 +1593,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1503
1593
 
1504
1594
  return color.xyz;
1505
1595
 
1506
- }`,[gt.simplex,e,o,s])}}();var Fd=class extends le{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=l,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",30),e.define("BLUR_SLOD",Math.pow(2,lt.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(Fd.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)}},Li=Fd;Li.Nodes=function(){let e=new U(`
1507
- float gaussian(vec2 i) {
1508
- const float sigma = float(NUM_SAMPLES) * .25;
1509
- return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
1510
- }`),t=new U(`
1596
+ }`,[xt.simplex,e,o,s])}}();var Ud=class extends le{constructor(e,t,o,i,s,l,c,u){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=o,this.transmissionSamplerSize=i,this.transmissionSamplerMap=s,this.transmissionDepthMap=l,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,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(Ud.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)}},Ri=Ud;Ri.Nodes=function(){let e=new U(`
1511
1597
  vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1512
1598
  // Slightly modified version of this:
1513
1599
  // https://www.shadertoy.com/view/ltScRG
@@ -1515,37 +1601,34 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1515
1601
  // Special case for blur == 0.0
1516
1602
  if (lod == 0.0) {
1517
1603
  #ifdef TEXTURE_LOD_EXT
1518
- return texture2DLodEXT( sp, U, 0.0).rgb;
1519
- #else
1520
- return textureLod( sp, U, 0.0).rgb;
1521
- #endif
1604
+ return texture2DLodEXT( sp, U, 0.0).rgb;
1605
+ #else
1606
+ return textureLod( sp, U, 0.0).rgb;
1607
+ #endif
1522
1608
  }
1523
-
1524
- const int sLOD = BLUR_SLOD; // tile size = 2^LOD
1525
-
1526
- vec3 O = vec3(0);
1527
- float a = 0.0;
1528
- const int s = NUM_SAMPLES/sLOD;
1529
- for ( int i = 0; i < s*s; i++ ) {
1530
- int modulo = (i)-((i)/(s))*(s);
1531
- vec2 d = vec2(float(modulo), float(i/s))*float(sLOD) - float(NUM_SAMPLES)/2.;
1532
- vec2 uv = U + (scale * aspectRatio) * d;
1533
- // What is the depth of the opaque object we're trying to sample
1534
- float opaqueDepth = unpackRGBAToDepth(texture2D(dm, uv));
1609
+
1610
+ vec2 texelSize = vec2(1.0) / resolution;
1611
+ vec2 halton = haltonSequence[frameIndex];
1612
+ float temporalOffset = getNoiseInterleavedGradient(gl_FragCoord.xy + halton);
1613
+ float temporalAngle = temporalOffset * PI2;
1614
+ vec3 res = vec3(0.0);
1615
+ vec2 uv = vec2(0.0);
1616
+ vec2 offset = vec2(0.0);
1617
+ vec2 vogelSample = vec2(0.0);
1618
+ for (int i = 0; i < NUM_SAMPLES; i++) {
1619
+ vogelSample = vogelDiskSample(i, NUM_SAMPLES, temporalAngle) * texelSize;
1620
+ offset = vogelSample * scale * 20.; // TODO: Magic number to match old method
1621
+ uv = U + offset;
1622
+ float opaqueDepth = unpackRGBAToDepth(textureLod(dm, uv, lod));
1535
1623
  if (opaqueDepth != 0.0 && opaqueDepth < gl_FragCoord.z) {
1536
- uv = unrefractedU + ((scale * min(lod / 2., 1.)) * aspectRatio) * d;
1624
+ uv = unrefractedU;
1537
1625
  lod = lod > 4.0 ? lod : lod / 2.0;
1538
1626
  }
1539
- float gaussian = gaussian(d);
1540
- #ifdef TEXTURE_LOD_EXT
1541
- O += gaussian * texture2DLodEXT( sp, uv, lod).rgb;
1542
- #else
1543
- O += gaussian * textureLod( sp, uv, lod).rgb;
1544
- #endif
1545
- a += gaussian;
1627
+ res += textureLod(sp, uv, lod).rgb;
1546
1628
  }
1547
- return O / a;
1548
- }`,[e]),o=new U(`
1629
+ return res / float(NUM_SAMPLES);
1630
+
1631
+ }`),t=new U(`
1549
1632
  vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
1550
1633
  // Direction of refracted light.
1551
1634
  vec3 refractionVector = refract( -v, n, 1.0 / ior );
@@ -1556,18 +1639,18 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1556
1639
  modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
1557
1640
  // The thickness is specified in local space.
1558
1641
  return normalize( refractionVector ) * thickness * modelScale;
1559
- }`),i=new U(`
1642
+ }`),o=new U(`
1560
1643
  float applyIorToRoughness( float roughness, float ior ) {
1561
1644
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
1562
1645
  // an IOR of 1.5 results in the default amount of microfacet refraction.
1563
1646
  return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
1564
- } `),s=new U(`
1647
+ } `),i=new U(`
1565
1648
  vec3 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
1566
1649
  float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
1567
1650
  float lod = applyIorToRoughness(roughness, ior);
1568
1651
 
1569
- return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1570
- }`,[i,t]),l=new U(`
1652
+ return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1653
+ }`,[o,e]),s=new U(`
1571
1654
  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 ) {
1572
1655
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1573
1656
  vec3 refractedRayExit = position + transmissionRay;
@@ -1585,7 +1668,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1585
1668
 
1586
1669
  // Sample framebuffer to get pixel the refracted ray hits.
1587
1670
  return getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
1588
- }`,[s,o]);return{transmission:new U(`
1671
+ }`,[i,t]);return{transmission:new U(`
1589
1672
  vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float mask, float alpha, out float calpha) {
1590
1673
  vec3 v = vec3(0.);
1591
1674
  if (isOrthographic) {
@@ -1600,7 +1683,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1600
1683
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1601
1684
 
1602
1685
  return transmission;
1603
- }`,[l])}}();var kd=(e=>(e.NOISE="noise",e.MAP="map",e))(kd||{}),Ud=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p){super("v3");this.displacementTypeIndex=new Se(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(kd)[this.displacementTypeIndex.value]==="map"&&(this.mat=new vi(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=s,this.seed=l,this.highCut=c,this.lowCut=u,this.quality=a}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(kd)[this.displacementTypeIndex.value]){case"map":{o=e.include(Ud.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 l=Object.values(js)[this.noiseFunctionIndex.value],c=new U(`vec3 orthogonal(vec3 v) {
1686
+ }`,[s])}}();var Hd=(e=>(e.NOISE="noise",e.MAP="map",e))(Hd||{}),qd=class extends le{constructor(e,t,o,i,s,l,c,u,a,d,p){super("v3");this.displacementTypeIndex=new we(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=t,Object.values(Hd)[this.displacementTypeIndex.value]==="map"&&(this.mat=new _i(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=i,this.smoothness=s,this.seed=l,this.highCut=c,this.lowCut=u,this.quality=a}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(Hd)[this.displacementTypeIndex.value]){case"map":{o=e.include(qd.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 l=Object.values(Fs)[this.noiseFunctionIndex.value],c=new U(`vec3 orthogonal(vec3 v) {
1604
1687
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1605
1688
  }`),u=l=="voronoi"?`
1606
1689
  float v = ${l}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1613,7 +1696,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1613
1696
  return p + n * ${l}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
1614
1697
  `,a=new U(`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) {
1615
1698
  ${u}
1616
- }`,[gt.simplex,gt.simplexFractal,gt.simplexAshima,gt.fbm,gt.perlin,gt.voronoi]),d=new U(`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) {
1699
+ }`,[xt.simplex,xt.simplexFractal,xt.simplexAshima,xt.fbm,xt.perlin,xt.voronoi]),d=new U(`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) {
1617
1700
  vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1618
1701
  vec3 tangent1 = orthogonal(normal);
1619
1702
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -1629,7 +1712,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1629
1712
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1630
1713
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1631
1714
  return displaced_position;
1632
- }`,[a,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)}},Bi=Ud;Bi.Nodes=function(){let e=new U(`vec3 orthogonal(vec3 v) {
1715
+ }`,[a,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)}},Vi=qd;Vi.Nodes=function(){let e=new U(`vec3 orthogonal(vec3 v) {
1633
1716
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1634
1717
  }`),t=new U(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1635
1718
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -1651,7 +1734,27 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1651
1734
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1652
1735
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1653
1736
  return displaced_position;
1654
- }`,[e,t])}}();var lt={normalRenderTarget:new jt,normalRenderTargetDepth:new jt,transmissionRenderTarget:new jt,transmissionSize:new Qe(2048,2048),transmissionRenderTargetDepth:new jt,pixelRatioNode:new Z(1),resolution:new Qe,penumbraSize:new Sr(5,.5),transmissionLod:new Se(2)};for(let n of Object.values(lt))n.isRenderGlobal=!0;var ks=class extends mt{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ie(5526619),this.emissive=new Ie(0),this.emissiveIntensity=new Z(1),this.shadingAlpha=new Z(1),this.shadingBlend=new Se(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(Fs.UniformsUtils.merge([Fs.UniformsLib.fog,Fs.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1737
+ }`,[e,t])}}();var xe={normalRenderTarget:new Lt,normalRenderTargetDepth:new Lt,transmissionRenderTarget:new Lt,transmissionSize:new Je(2048,2048),transmissionRenderTargetDepth:new Lt,aoRenderTarget:new Lt,aoEnabled:new et,pixelRatioNode:new Z(1),resolution:new Je,penumbraSize:new Pr(5,.5),frameIndex:new we(0),transmissionLod:new we(2)};for(let n of Object.values(xe))n.isRenderGlobal=!0;var en=class extends ht{constructor(){super("basic");this.nodeType="Basic";this.color=new Me(5526619),this.shadingAlpha=new Z(1),this.shadingBlend=new we(0),this.previousModelViewMatrix=new Pt,this.previouseProjectionMatrix=new Pt}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(Hl.UniformsUtils.merge([Hl.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1738
+ `));let i=["#include <beginnormal_vertex>",`
1739
+ #if !defined( USE_LAYER_DISPLACE )
1740
+ #include <defaultnormal_vertex>
1741
+ #endif
1742
+
1743
+ vec3 displaced_position = position;
1744
+ vec3 displaced_normal = normal;
1745
+
1746
+ #if defined( USE_LAYER_DISPLACE )
1747
+ vec3 transformed;
1748
+ vec3 transformedNormal;
1749
+ #endif
1750
+ `,"#include <normal_vertex>",`
1751
+ #if !defined( USE_LAYER_DISPLACE )
1752
+ #include <begin_vertex>
1753
+ #endif /* !USE_LAYER_DISPLACE */
1754
+ `];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(`
1755
+ `)}else{this.color===void 0&&(this.color=new Me(5526619)),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.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(`
1756
+ `));let l=["#include <normal_fragment_begin>",o.code];i&&l.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),i?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} * ${c} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),l.push("#include <fog_fragment>","#include <dithering_fragment>"),t=l.join(`
1757
+ `)}return t}};var ks=require("three");var Us=class extends ht{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Me(5526619),this.emissive=new Me(0),this.emissiveIntensity=new Z(1),this.previousModelViewMatrix=new Pt,this.previouseProjectionMatrix=new Pt,this.shadingAlpha=new Z(1),this.shadingBlend=new we(0),this.occlusion=new et(!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(ks.UniformsUtils.merge([ks.UniformsLib.fog,ks.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1655
1758
  `));let i=["#include <beginnormal_vertex>",`
1656
1759
  #ifndef USE_LAYER_DISPLACE
1657
1760
  #include <defaultnormal_vertex>
@@ -1743,21 +1846,23 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1743
1846
  #pragma unroll_loop_end
1744
1847
  #endif
1745
1848
  `," #include <shadowmap_vertex>"," #include <fog_vertex>"),i.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),t=i.join(`
1746
- `)}else{e.mergeUniform({penumbraSize:lt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5526619)),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"}),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"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(`
1747
- `));let d=["#include <normal_fragment_begin>",`
1849
+ `)}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 Me(5526619)),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"}),l=this.occlusion.flow(e,"b",{slot:"occlusion"}),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.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(`
1850
+ `));let p=["#include <normal_fragment_begin>",`
1748
1851
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1749
1852
  vec3 viewdx = dFdx(vViewPosition);
1750
1853
  vec3 viewdy = dFdy(vViewPosition);
1751
1854
  vec3 faceNormal = normalize(cross(viewdx, viewdy));
1752
1855
  bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
1753
- `,"#include <clipping_planes_fragment>"];d.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),a&&d.push(a.code,"#ifdef ALPHATEST","if ( "+a.result+" <= ALPHATEST ) discard;","#endif"),d.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&&d.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+s.result+";"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
1856
+ `,"#include <clipping_planes_fragment>"];p.push(o.code,"vec3 diffuseColor = "+o.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),d&&p.push(d.code,"#ifdef ALPHATEST","if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.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&&p.push(i.code,"reflectedLight.directDiffuse += "+i.result+" * "+s.result+";"),p.push("vec3 ao = aoEnabled && "+l.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) ;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
1754
1857
  if (outgoingLight != diffuseColor) {
1755
1858
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1756
- accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
1757
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${c.result} );
1859
+ accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${f} * lightAccu;
1860
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${f}, ${u.result} );
1861
+
1862
+ outgoingLight *= ao;
1758
1863
  }
1759
- `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),a?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
1760
- `)}return t}};var Us=require("three");var Hs=class extends mt{constructor(){super("phong");this.nodeType="Phong";this.color=new Ie(5526619),this.specular=new Ie(1118481),this.shininess=new Z(30),this.shadingAlpha=new Z(1),this.shadingBlend=new Se(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(Us.UniformsUtils.merge([Us.UniformsLib.fog,Us.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1864
+ `),a&&p.push(a.code,`outgoingLight = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
1865
+ `)}return t}};var Hs=require("three");var qs=class extends ht{constructor(){super("phong");this.nodeType="Phong";this.color=new Me(5526619),this.specular=new Me(1118481),this.shininess=new Z(30),this.previousModelViewMatrix=new Pt,this.previouseProjectionMatrix=new Pt,this.shadingAlpha=new Z(1),this.shadingBlend=new we(0),this.occlusion=new et(!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(Hs.UniformsUtils.merge([Hs.UniformsLib.fog,Hs.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1761
1866
  `));let i=["#include <beginnormal_vertex>",`
1762
1867
  #ifndef USE_LAYER_DISPLACE
1763
1868
  #include <defaultnormal_vertex>
@@ -1776,8 +1881,8 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1776
1881
  #include <begin_vertex>
1777
1882
  #endif
1778
1883
  `];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 <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(`
1779
- `)}else{e.mergeUniform({penumbraSize:lt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5526619)),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"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode(["varying vec3 vWPosition;","uniform vec3 emissive;",`uniform float penumbraSize[${5}];`,"#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(`
1780
- `));let d=["#include <normal_fragment_begin>",`
1884
+ `)}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 Me(5526619)),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"),l=this.shininess.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.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(`
1885
+ `));let p=["#include <normal_fragment_begin>",`
1781
1886
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1782
1887
  vec3 viewdx = dFdx(vViewPosition);
1783
1888
  vec3 viewdy = dFdy(vViewPosition);
@@ -1785,14 +1890,16 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1785
1890
  if (dot(normal, faceNormal) < 0.0) {
1786
1891
  normal *= -1.0;
1787
1892
  }
1788
- `," BlinnPhongMaterial material;"];d.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),a&&d.push(a.code,"#ifdef ALPHATEST","if ( "+a.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
1893
+ `," BlinnPhongMaterial material;"];p.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+";",l.code," float shininess = max( 0.0001, "+l.result+" );"," float specularStrength = 1.0;"),d&&p.push(d.code,"#ifdef ALPHATEST","if ( "+d.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 && "+o.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;");let f="1.0";this.mask&&(this.mask.analyze(e),f=`luminance(${this.mask.flow(e,"v3").result})`),p.push(`
1789
1894
  if (outgoingLight != diffuseColor) {
1790
1895
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1791
- accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
1792
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${c.result} );
1896
+ accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${f} * lightAccu;
1897
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${f}, ${u.result} );
1898
+
1899
+ outgoingLight *= ao;
1793
1900
  }
1794
- `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),a?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
1795
- `)}return t}};var Di=require("three");var qs=class extends mt{constructor(){super("standard");this.nodeType="Standard";this.color=new Ie(5526619),this.roughness=new Z(.3),this.metalness=new Z(0),this.reflectivity=new Z(.5),this.shadingAlpha=new Z(1),this.shadingBlend=new Se(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(Di.UniformsUtils.merge([Di.UniformsLib.fog,Di.UniformsLib.lights])),Di.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1901
+ `),a&&p.push(a.code,`outgoingLight = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
1902
+ `)}return t}};var zi=require("three");var Ws=class extends ht{constructor(){super("standard");this.nodeType="Standard";this.color=new Me(5526619),this.roughness=new Z(.3),this.metalness=new Z(0),this.reflectivity=new Z(.5),this.previousModelViewMatrix=new Pt,this.previouseProjectionMatrix=new Pt,this.shadingAlpha=new Z(1),this.shadingBlend=new we(0),this.occlusion=new et(!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(zi.UniformsUtils.merge([zi.UniformsLib.fog,zi.UniformsLib.lights])),zi.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1796
1903
  `));let i=["#include <beginnormal_vertex>",`
1797
1904
  #if !defined( USE_LAYER_DISPLACE )
1798
1905
  #include <defaultnormal_vertex>
@@ -1810,8 +1917,8 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1810
1917
  #include <begin_vertex>
1811
1918
  #endif /* !USE_LAYER_DISPLACE */
1812
1919
  `];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(`
1813
- `)}else{e.mergeUniform({penumbraSize:lt.penumbraSize});let o={gamma:!0};this.color===void 0&&(this.color=new Ie(5526619)),this.color.analyze(e,{slot:"color",context:o}),this.roughness.analyze(e),this.metalness.analyze(e),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 i=this.color.flow(e,"c",{slot:"color",context:o}),s=this.roughness.flow(e,"f"),l=this.metalness.flow(e,"f"),c=this.shadingAlpha.flow(e,"f"),u=this.shadingBlend.flow(e,"i"),a=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;",`uniform float penumbraSize[${5}];`,"#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(`
1814
- `));let f=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
1920
+ `)}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 Me(5526619)),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}),l=this.roughness.flow(e,"f"),c=this.metalness.flow(e,"f"),u=this.shadingAlpha.flow(e,"f"),a=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.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(`
1921
+ `));let m=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
1815
1922
  // NOTE: gl_FrontFacing alternative using face normal estimation.
1816
1923
  vec3 viewdx = dFdx(vViewPosition);
1817
1924
  vec3 viewdy = dFdy(vViewPosition);
@@ -1819,14 +1926,16 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1819
1926
  if (dot(normal, faceNormal) < 0.0) {
1820
1927
  normal *= -1.0;
1821
1928
  }
1822
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];f.push(i.code," vec3 diffuseColor = "+i.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",l.code," float metalnessFactor = "+l.result+";"),d&&f.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),f.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),f.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 );"),p?f.push(p.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+p.result+" ) ), diffuseColor, metalnessFactor );"):f.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),f.push("#include <lights_fragment_begin>"),f.push("#include <lights_fragment_end>"),f.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let m="1.0";this.mask&&(this.mask.analyze(e),m=`luminance(${this.mask.flow(e,"v3").result})`),f.push(`
1929
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];m.push(s.code," vec3 diffuseColor = "+s.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",l.code," float roughnessFactor = "+l.result+";",c.code," float metalnessFactor = "+c.result+";"),p&&m.push(p.code,"#ifdef ALPHATEST"," if ( "+p.result+" <= ALPHATEST ) discard;","#endif"),m.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),m.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),f?m.push(f.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+f.result+" ) ), diffuseColor, metalnessFactor );"):m.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),m.push("#include <lights_fragment_begin>"),m.push("#include <lights_fragment_end>"),m.push("vec3 ao = aoEnabled && "+i.result+" ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse)) + reflectedLight.directSpecular + reflectedLight.indirectSpecular;");let h="1.0";this.mask&&(this.mask.analyze(e),h=`luminance(${this.mask.flow(e,"v3").result})`),m.push(`
1823
1930
  if (outgoingLight != diffuseColor) {
1824
1931
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1825
- accumAlpha += ( 1.0 - accumAlpha ) * ${c.result} * ${m} * lightAccu;
1826
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${c.result} * ${m}, ${u.result} );
1932
+ accumAlpha += ( 1.0 - accumAlpha ) * ${u.result} * ${h} * lightAccu;
1933
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${u.result} * ${h}, ${a.result} );
1934
+
1935
+ outgoingLight *= ao;
1827
1936
  }
1828
- `),a&&f.push(a.code,`outgoingLight = spe_blend(outgoingLight, ${a.result}, 1.0, SPE_BLENDING_NORMAL);`),d?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=f.join(`
1829
- `)}return t}};var Ws=require("three");var $s=class extends mt{constructor(){super("toon");this.nodeType="Toon";this.color=new Ie(5526619),this.specular=new Ie(1118481),this.shininess=new Z(30),this.shadingAlpha=new Z(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(Ws.UniformsUtils.merge([Ws.UniformsLib.fog,Ws.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1937
+ `),d&&m.push(d.code,`outgoingLight = spe_blend(outgoingLight, ${d.result}, 1.0, SPE_BLENDING_NORMAL);`),p?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=m.join(`
1938
+ `)}return t}};var $s=require("three");var Ys=class extends ht{constructor(){super("toon");this.nodeType="Toon";this.color=new Me(5526619),this.specular=new Me(1118481),this.shininess=new Z(30),this.previousModelViewMatrix=new Pt,this.previouseProjectionMatrix=new Pt,this.shadingAlpha=new Z(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:xe.frameIndex}),e.mergeUniform({resolution:xe.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform($s.UniformsUtils.merge([$s.UniformsLib.fog,$s.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1830
1939
  `));let i=["#include <beginnormal_vertex>",`
1831
1940
  #ifndef USE_LAYER_DISPLACE
1832
1941
  #include <defaultnormal_vertex>
@@ -1844,7 +1953,7 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1844
1953
  #include <begin_vertex>
1845
1954
  #endif
1846
1955
  `];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(`
1847
- `)}else{e.mergeUniform({penumbraSize:lt.penumbraSize}),this.color===void 0&&(this.color=new Ie(5526619)),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"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==void 0,e.addParsCode([`uniform float penumbraSize[${5}];`,"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>",`
1956
+ `)}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 Me(5526619)),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"),l=this.shadingAlpha.flow(e,"f"),c=this.shadingBlend.flow(e,"i"),u=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,a=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=a!==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>",`
1848
1957
  varying vec3 vViewPosition;
1849
1958
  struct ToonMaterial {
1850
1959
  vec3 diffuseColor;
@@ -1873,15 +1982,15 @@ vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
1873
1982
  if (dot(normal, faceNormal) < 0.0) {
1874
1983
  normal *= -1.0;
1875
1984
  }
1876
- `," ToonMaterial material;"];d.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),a&&d.push(a.code,"#ifdef ALPHATEST","if ( "+a.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
1985
+ `," ToonMaterial material;"];d.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",i.code," vec3 specular = "+i.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),a&&d.push(a.code,"#ifdef ALPHATEST","if ( "+a.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 ao = aoEnabled ? tex2D(aoMap, gl_FragCoord.xy / resolution).rgb : vec3(1.0);","vec3 outgoingLight = ((reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * ao) + reflectedLight.directSpecular;");let p="1.0";this.mask&&(this.mask.analyze(e),p=`luminance(${this.mask.flow(e,"v3").result})`),d.push(`
1877
1986
  if (outgoingLight != diffuseColor) {
1878
1987
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
1879
1988
  accumAlpha += ( 1.0 - accumAlpha ) * ${l.result} * ${p} * lightAccu;
1880
1989
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result} * ${p}, ${c.result} );
1881
1990
  }
1882
1991
  `),u&&d.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),a?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${a.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
1883
- `)}return t}};var $l=require("three");var Hl=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 qd=class extends Hl{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Hd;function Oy(n){return typeof n=="string"?n:(Hd||(Hd=new qd),Hd.load(n))}var ql=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")}},Wl=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 Gi=class extends ql{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 l=this[s];l&&(l.image=this.img,l.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=l=>{i=l.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=Oy(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new $l.VideoTexture(this.img,void 0,e,e):o=new $l.Texture(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 rr=class extends Gi{};var je=require("three");function wt(n,r){return r.color(n)}function Ay(n,r){switch(n.type){case"fresnel":return pT(n,r);case"gradient":return fT(n);case"depth":return mT(n);case"normal":return hT(n);case"noise":return yT(n,r);case"rainbow":return gT(n);case"toon":return xT(n,r);case"outline":return vT(n,r);case"transmission":return bT(n,r);case"color":return uT(n,r);case"pattern":return ST(n,r)}}function dT(n){return{type:n.type}}function Tr(n){let{alpha:r,mode:e,isMask:t}=n;return{...dT(n),alpha:r,mode:e,isMask:t}}function uT(n,r){return{...Tr(n),color:wt(n.color,r)}}function pT(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s,isMask:l}=n;return{...Tr(n),color:wt(s,r),bias:e,scale:t,intensity:o,factor:i}}function fT(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:l}=n;return{...Tr(n),gradientType:r,smooth:e,colors:t.map(c=>new je.Vector4(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new je.Vector2(...s),morph:new je.Vector2(...l),angle:i}}function mT(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:l,colors:c,steps:u,smooth:a}=n;return{...Tr(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new je.Vector3(...s),direction:l?new je.Vector3(...l):new je.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new je.Vector4(d[0],d[1],d[2],d[3]):new je.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:a}}function hT(n){let{cnormal:r}=n;return{...Tr(n),cnormal:new je.Vector3(r[0],r[1],r[2])}}function yT(n,r){return{...Tr(n),scale:n.scale,move:n.move,fA:new je.Vector2(...n.fA),fB:new je.Vector2(...n.fB),size:new je.Vector3(...n.size),distortion:new je.Vector2(...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 gT(n){return{...Tr(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new je.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new je.Vector3(...n.offset)}}function xT(n,r){return{...Tr(n),positioning:n.positioning,colors:n.colors.map(e=>new je.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new je.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:wt(n.shadowColor,r),offset:new je.Vector3(...n.offset)}}function vT(n,r){return{...Tr(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 je.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function bT(n,r){return{...Tr(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function ST(n,r){return{...Tr(n),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new je.Vector2(...n.offset),colorA:wt(n.colorA,r),colorB:wt(n.colorB,r),frequency:new je.Vector2(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new je.Vector2(...n.vertical),horizontal:new je.Vector2(...n.horizontal),sides:n.sides}}var No=class extends at{};var Ny=require("three");var Wd={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},$d={depth:["colors"]};function wT(n,r,e){if(r==="isMask")return!0;let t=Wd[n.type],o=$d[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 Xd(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,l=r.image(s),c=t;c.image instanceof rr||c.image.deref(),c.image=l}if("video"in i){let s=i.video,l=r.video(s),c=t;c.image instanceof rr||c.image.deref(),c.image=l}if("wrapping"in i){let s=t;s.wrap=i.wrapping}if("repeat"in i||"offset"in i){let s="mat",l=e.uniforms[`f${e.id}_${s}`];"repeat"in i&&(l.repeat=i.repeat),"offset"in i&&(l.offset=i.offset),l.updateMatrix()}return o}function Cy(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(!i||s===void 0)continue;if(Yd(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let l=e.uniforms[`f${e.id}_${i}`];if(!!l&&!(l instanceof Ao))switch(o=o||wT(e,i,s),l.constructor){case Ie:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof No?l.value=new at(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case zt:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof No?l.value=new at(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case Qe:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]);break}case St:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case jt:{Xd(s,r,e);break}case _r:{l.value=s.map(c=>new Ny.Vector4(...c));break}default:{l.value=s;break}}}return o}var Fr=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)Yd(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return nr.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 Qo(i,t.texture.wrapping),l=new kl(i),c=new Ul(t.texture.repeat,t.texture.offset),u=new Z(t.crop?1:0),a=new Se(t.projection??0),d=new Se(["x","y","z"].indexOf(t.axis)??0),p=new Se(t.side??0),f=new Qe(t.size?new Be.Vector2(t.size[0],t.size[1]):new Be.Vector2(100,100)),m=new Z(t.blending??0),h=new Z(t.alpha??1),y=new Se(t.mode??0),g=new wr(t.isMask??!1),v=new _i(s,l,u,a,d,p,f,m,c,h,y,g),b=new Ae(v.calpha,"f");return new He(r,e,t,{texture:s,textureSize:l,crop:u,projection:a,axis:d,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},v,y,b,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new Qo(i,t.texture.wrapping),l=new Z(t.alpha??1),c=new Se(t.mode??0),u=new wr(t.isMask??!1),a=new Ai(s,l,c,u),d=new Ae(a.calpha,"f");return new He(r,e,t,{texture:s,alpha:l,mode:c,isMask:u},a,c,d,u)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new St(new Be.Vector3(...t.offset)),s=new Z(t.scale??10),l=new Z(t.intensity??8),c=new Z(t.movement??1),u=new Se(t.noiseType??0),a=new Se(t.voronoiStyle??0),d=new Z(t.smoothness??.5),p=new Z(t.seed??0),f=new Z(t.highCut??1),m=new Z(t.lowCut??0),h=new Se(t.quality??1),y=new Bi(l,c,i,a,d,p,f,m,h,s,u);return new Xs(r,e,t,{offset:i,scale:s,intensity:l,movement:c,noiseType:u,voronoiStyle:a,smoothness:d,seed:p,highCut:f,lowCut:m,quality:h},y)}else throw new Error;else return PT(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):Cy(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Xd(o.props,t.shared,this):!0;return!1}dispose(){if(_T(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof rr||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}},He=class extends Fr{constructor(e,t,o,i,s,l,c,u){super(e,t,o,i);this.params=i;this.color=s;this.mode=l;this.alpha=c;this.isMask=u}},Xs=class extends Fr{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},nr=class extends Fr{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,l=new Z(o.alpha),c=new Se(o.mode),u;if(!o.visible)s=new Zo,u={};else if(o.category==="lambert"){s=new ks;let a=new Ie(i.color(o.emissive)??0);u={emissive:a},s.emissive=a}else if(o.category==="toon"){s=new $s;let a=new Z(o.shininess??30),d=new Ie(i.color(o.specular)??1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}else if(o.category==="physical"){s=new qs;let a=new Z(o.roughness??.3),d=new Z(o.metalness??0),p=new Z(o.reflectivity??.5);u={roughness:a,metalness:d,reflectivity:p},s.roughness=a,s.metalness=d,s.reflectivity=p}else{s=new Hs;let a=new Z(o.shininess??30),d=new Ie(o.specular!==void 0?i.color(o.specular)??1118481:1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}return s.alpha=new Z(1),s.shadingAlpha=l,s.shadingBlend=c,u.alpha=s.shadingAlpha,u.mode=s.shadingBlend,new nr(e,t,o,s,u)}get category(){return this.node.category}};function _T(n){let r=n instanceof Fr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function or(n){return{alpha:new Z(n.alpha??1),mode:new Se(n.mode??0),isMask:new wr(n.isMask??!1)}}function TT(n,r,e,t){switch(n.type){case"color":{let o=new Ie(t.color??5526619),i=or(t),s=new Jo(o,i.alpha),l=new Ae(s.calpha,"f");return new He(r,e,n,{color:o,...i},s,i.mode,l,i.isMask)}case"fresnel":{let o=new Ie(t.color??16777215),i=new Z(t.bias??.1),s=new Z(t.scale??1),l=new Z(t.intensity??2),c=new Z(t.factor??1),u=or(t),a=new zs(o,i,s,l,c,u.alpha,u.mode,u.isMask),d=new Ae(a.calpha,"f");return new He(r,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,...u},a,u.mode,d,u.isMask)}case"rainbow":{let o=new Z(t.filmThickness??30),i=new Z(t.movement??0),s=new St(t.wavelengths??new Be.Vector3(0,0,0)),l=new Z(t.noiseStrength??0),c=new Z(t.noiseScale??1),u=new St(t.offset??new Be.Vector3(0,0,0)),a=or(t),d=new Mi(o,i,s,l,c,u,a.alpha,a.isMask),p=new Ae(d.calpha,"f");return new He(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...a},d,a.mode,p,a.isMask)}case"transmission":{let o=new Z(t.thickness??10),i=new Z(t.ior??1.5),s=new Z(t.roughness??.5),l=lt.transmissionSize,c=lt.transmissionRenderTarget,u=lt.transmissionRenderTargetDepth,a=window.innerWidth,d=window.innerHeight,p=a>=d?new Qe(d/a,1):new Qe(1,a/d),f=or(t),m=new Li(o,i,s,l,c,u,p,f.alpha),h=new Ae(m.calpha,"f");return new He(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 _r(t.colors.length,t.colors):(i=new _r(10,new Be.Vector4(0,0,0,1)),i.value[1]=new Be.Vector4(1,1,1,1));let s;t.steps?s=new Sr(t.steps.length,t.steps):(s=new Sr(10,1),s.value[0]=0);let l=new St(t.source??new Be.Vector3(0,0,0)),c=new wr(t.isWorldSpace??!0),u=new Z(t.noiseStrength??0),a=new Z(t.noiseScale??1),d=new zt(t.shadowColor),p=new St(t.offset??new Be.Vector3(0,0,0)),f=or(t),m=new Ei(o,i,s,l,c,u,a,d,p,f.alpha),h=new Ae(m.calpha,"f");return new He(r,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:a,shadowColor:d,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 Z(t.outlineWidth??.1),l=new Z(t.contourWidth??.1),c=new Z(t.outlineThreshold??.1),u=new Z(t.contourThreshold??.1),a=new Z(t.outlineSmoothing??.1),d=new Z(t.contourFrequency??.1),p=new St(t.contourDirection??new Be.Vector3(0,1,0)),f=new wr(t.positionalLines??!1),m=new wr(t.compensation??!0),h=lt.normalRenderTarget,y=lt.normalRenderTargetDepth,g=lt.pixelRatioNode,v=lt.resolution,b=or(t),w=new Ci(o,i,s,l,c,u,a,d,p,f,m,v,h,y,g,b.alpha),S=new Ae(w.calpha,"f");return new He(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:a,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,...b},w,b.mode,S,b.isMask)}case"depth":{let o=new Se(t.gradientType??0),i=new wr(t.smooth??!1),s=new Z(t.near??50),l=new Z(t.far??200),c=new Z(t.isVector??1),u=new Z(t.isWorldSpace??0),a=new St(t.origin??new Be.Vector3),d=new St(t.direction??new Be.Vector3),p;t.colors?p=new _r(t.colors.length,t.colors):(p=new _r(2,new Be.Vector4(0,0,0,1)),p.value[1]=new Be.Vector4(1,1,1,1));let f;t.steps?f=new Sr(t.steps.length,t.steps):(f=new Sr(2,1),f.value[0]=0);let m=or(t),h=new Pi(o,i,s,l,c,u,a,d,p,f,m.alpha,m.isMask),y=new Ae(h.calpha,"f");return new He(r,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:u,origin:a,direction:d,colors:p,steps:f,...m},h,m.mode,y,m.isMask)}case"noise":{let o=new Z(t.scale??1),i=new St(t.size??new Be.Vector3(100,100,100)),s=new Z(t.move??1),l=new Qe(t.fA??new Be.Vector2(1.7,9.2)),c=new Qe(t.fB??new Be.Vector2(8.3,2.8)),u=new Qe(t.distortion??new Be.Vector2(1,1)),a=new zt(t.colorA),d=new zt(t.colorB),p=new zt(t.colorC),f=new zt(t.colorD),m=new Se(t.noiseType??0),h=new Se(t.voronoiStyle??0),y=new Z(t.highCut??1),g=new Z(t.lowCut??0),v=new Z(t.smoothness??.5),b=new Z(t.seed??.5),w=new Se(t.quality??1),S=or(t),T=new Ni(o,i,s,l,c,u,a,d,p,f,S.alpha,m,S.isMask,h,y,g,v,b,w),_=new Ae(T.calpha,"f");return new He(r,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:u,colorA:a,colorB:d,colorC:p,colorD:f,noiseType:m,...S,voronoiStyle:h,highCut:y,lowCut:g,smoothness:v,seed:b,quality:w},T,S.mode,_,S.isMask)}case"normal":{let o=new St(t.cnormal??new Be.Vector3(1,1,1)),i=or(t),s=new Si(o,i.alpha),l=new Ae(s.calpha,"f");return new He(r,e,n,{cnormal:o,...i},s,i.mode,l,i.isMask)}case"gradient":{let o=new Se(t.gradientType??0),i=new wr(t.smooth??!1),s;t.colors?s=new _r(t.colors.length,t.colors):(s=new _r(10,new Be.Vector4(0,0,0,1)),s.value[1]=new Be.Vector4(1,1,1,1));let l;t.steps?l=new Sr(t.steps.length,t.steps):(l=new Sr(10,1),l.value[0]=0);let c=new Qe(t.offset??new Be.Vector2(0,0)),u=new Qe(t.morph??new Be.Vector2(0,0)),a=new Z(t.angle??0),d=or(t),p=new Oi(o,i,s,l,c,u,a,d.alpha,d.isMask),f=new Ae(p.calpha,"f");return new He(r,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:u,angle:a,...d},p,d.mode,f,d.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),l=new Z(t.blending??0),c=new Qe(t.offset??new Be.Vector2(0,0)),u=new zt(t.colorA),a=new zt(t.colorB),d=new Qe(t.frequency??new Be.Vector2(10,10)),p=new Z(t.size??.5),f=new Z(t.variation??0),m=new Z(t.smoothness??.5),h=new Z(t.zigzag??0),y=new Z(t.rotation??0),g=new Qe(t.vertical??new Be.Vector2(0,1)),v=new Qe(t.horizontal??new Be.Vector2(0,1)),b=new Se(t.sides??6),w=or(t),S=new Ii(o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b,w.alpha,w.isMask),T=new Ae(S.calpha,"f");return new He(r,e,n,{style:o,projection:i,axis:s,blending:l,offset:c,colorA:u,colorB:a,frequency:d,size:p,variation:f,smoothness:m,zigzag:h,rotation:y,vertical:g,horizontal:v,sides:b,...w},S,w.mode,T,w.isMask)}default:{let o=new Ie(1,0,0,1),i=or(t),s=new Jo(o,i.alpha),l=new Ae(s.calpha,"f");return new He(r,e,n,{color:o,...i},s,i.mode,l,i.isMask)}}}function PT(n,r,e,t){let o=Ay(e,t);return TT(e,n,r,o)}function Yd(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 Iy(n,r){let e=0;for(let t of n.layers){if(t.data.type!=="displace"&&t.data.isMask)return!0;if(t.data.type!=="displace"&&"alpha"in t.data&&t.data.type!=="light"&&t.data.type!=="fresnel"&&t.data.type!=="texture"&&t.data.type!=="matcap"&&t.data.type!=="rainbow"&&t.data.type!=="outline"&&t.data.type!=="pattern"){let o=t.data.visible?t.data.alpha:0;if(o===1&&t.data.type==="depth"||t.data.type==="gradient"){for(let i of t.data.colors)if(i[3]<1){o=i[3];break}}else if(o===1&&t.data.type==="noise"){let i=r.color(t.data.colorA).a,s=r.color(t.data.colorB).a,l=r.color(t.data.colorC).a,c=r.color(t.data.colorD).a,u=Math.min(i,Math.min(s,Math.min(l,c)));u<1&&(o=u)}e+=(1-e)*o}}return e<1}var kt=class extends My.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Kd=class extends kt{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}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()}},Ri=class extends kt{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 Kd(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}reset(e,t){this.data!==e&&this.reset0(e,t)}reset0(e,t){this.data=e;let o=e.layers??Gt.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>Fr.create(this.layerIdGen++,i.id,i.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Iy(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 nr),this.lightLayer===void 0&&(this.lightLayer=new nr(0,"",{...Ct.defaultData("light","phong"),visible:!1},new Zo,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=Iy(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 l=Fr.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,l),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 l=this.layers.findIndex(u=>u.uuid===e.id),c=this.layers[l];this.layers.splice(l,1),this.layers.splice(e.localIndex,0,c),o.scene?.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate()}else{let l=this.layers.find(c=>c.uuid===s);if(l){let c=t.layers.data(s);if(l.updateByOp({...e,path:e.path.slice(2)},c,o)){let a=Fr.create(this.layerIdGen++,s,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===s),1,a),this.onUpdate()}}}}else this.reset(t,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof He?t.color.mask=void 0:t instanceof nr&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof He&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof nr?i.node.mask=new ht(t.color,t.alpha,ht.MUL):i instanceof He&&(i.isMask.value||(i.color.mask=new ht(t.color,t.alpha,ht.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof He),t=this.layers.findIndex(o=>o instanceof nr);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 He){if(s.isMask.value)continue;o=new bi(o,s.color,s.alpha,s.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ae("outgoingLight","f"),t=this.layers.findIndex(o=>o instanceof nr);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof He){if(i.isMask.value)continue;e=new bi(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 Xs);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new ht(t,e[o].position,ht.ADD),t=new ht(t,new Z(.5).setReadonly(!0),ht.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,l)=>Math.min(Math.max(i,s),l);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=(Wd[t.type]??[]).map(l=>t[l]),i=($d[t.type]??[]).map(l=>t[l]?.length??0),s=[...o,...i];s.length?e+=`["${t.type}", "${s.join('","')}"],`:e+=`"${t.type}",`}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;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 He){let t=e.params.texture;if(t instanceof Qo&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(kt.prototype,{properties:{get:function(){return this.fragment.properties}}});var en=class extends Ri{};var Dy=ln(Ey());var Ly=new Map;function By(n){if(typeof n=="string")return n;let r=Ly.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},Ly.set(n,r)),r.url}var tn=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:By(r),format:"wav"},this.sound=new Dy.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var ct=require("three"),Yl=class{constructor(){this.type="ShapePath";this.color=new ct.Color;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new ct.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,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,v){let b=h.x,w=y.x,S=g.x,T=v.x,_=h.y,x=y.y,C=g.y,P=v.y,N=(T-S)*(_-C)-(P-C)*(b-S),O=(w-b)*(_-C)-(x-_)*(b-S),A=(P-C)*(w-b)-(T-S)*(x-_),R=N/A,k=O/A;if(A===0&&N!==0||R<=0||R>=1||k<0||k>1)return null;if(N===0&&A===0){for(let $=0;$<2;$++)if(i($===0?g:v,h,y),t.loc===e.ORIGIN){let te=$===0?g:v;return{x:te.x,y:te.y,t:t.t}}else if(t.loc===e.BETWEEN){let te=+(b+t.t*(w-b)).toPrecision(10),X=+(_+t.t*(x-_)).toPrecision(10);return{x:te,y:X,t:t.t}}return null}else{for(let X=0;X<2;X++)if(i(X===0?g:v,h,y),t.loc===e.ORIGIN){let W=X===0?g:v;return{x:W.x,y:W.y,t:t.t}}let $=+(b+R*(w-b)).toPrecision(10),te=+(_+R*(x-_)).toPrecision(10);return{x:$,y:te,t:R}}}function i(h,y,g){let v=g.x-y.x,b=g.y-y.y,w=h.x-y.x,S=h.y-y.y,T=v*S-w*b;if(h.x===y.x&&h.y===y.y){t.loc=e.ORIGIN,t.t=0;return}if(h.x===g.x&&h.y===g.y){t.loc=e.DESTINATION,t.t=1;return}if(T<-Number.EPSILON){t.loc=e.LEFT;return}if(T>Number.EPSILON){t.loc=e.RIGHT;return}if(v*w<0||b*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+b*b)<Math.sqrt(w*w+S*S)){t.loc=e.BEYOND;return}let _;v!==0?_=w/v:_=S/b,t.loc=e.BETWEEN,t.t=_}function s(h,y){let g=[],v=[];for(let b=1;b<h.length;b++){let w=h[b-1],S=h[b];for(let T=1;T<y.length;T++){let _=y[T-1],x=y[T],C=o(w,S,_,x);C!==null&&g.find(P=>P.t<=C.t+Number.EPSILON&&P.t>=C.t-Number.EPSILON)===void 0&&(g.push(C),v.push(new ct.Vector2(C.x,C.y)))}}return v}function l(h,y,g){let v=new ct.Vector2;y.getCenter(v);let b=[];return g.forEach(w=>{w.boundingBox.containsPoint(v)&&s(h,w.points).forEach(T=>{b.push({identifier:w.identifier,isCW:w.isCW,point:T})})}),b.sort((w,S)=>w.point.x-S.point.x),b}function c(h,y,g,v,b){(b==null||b==="")&&(b="nonzero");let w=new ct.Vector2;h.boundingBox.getCenter(w);let S=[new ct.Vector2(g,w.y),new ct.Vector2(v,w.y)],T=l(S,h.boundingBox,y);T.sort((O,A)=>O.point.x-A.point.x);let _=[],x=[];T.forEach(O=>{O.identifier===h.identifier?_.push(O):x.push(O)});let C=_[0].point.x,P=[],N=0;for(;N<x.length&&x[N].point.x<C;)P.length>0&&P[P.length-1]===x[N].identifier?P.pop():P.push(x[N].identifier),N++;if(P.push(h.identifier),b==="evenodd"){let O=P.length%2===0,A=P[P.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(b==="nonzero"){let O=!0,A=null,R=null;for(let k=0;k<P.length;k++){let $=P[k];y[$]&&(O?(R=y[$].isCW,O=!1,A=$):R!==y[$].isCW&&(R=y[$].isCW,O=!0))}return{identifier:h.identifier,isHole:O,for:A}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let u=0,a=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,v=999999999,b=-999999999,w=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<v&&(v=T.y),T.x>b&&(b=T.x),T.x<w&&(w=T.x)}d<=b&&(d=b+1),a>=w&&(a=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:ct.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new ct.Box2(new ct.Vector2(w,v),new ct.Vector2(b,g))})});let f=p.map(h=>c(h,p,a,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new ct.Shape;g.curves=h.curves,f.filter(b=>b?.isHole&&b.for===h.identifier).forEach(b=>{if(b){let w=p[b.identifier],S=new ct.Path;S.curves=w.curves,g.holes.push(S)}}),m.push(g)}}),m}};var Ry,Zd=new Promise(n=>{Ry=n}),Gy=!1;async function Vy(){if(Gy)return;let n=await import("./opentype.js");Ry(n),Gy=!0}var Ys=class{async load(r,e,t=()=>{}){let{load:o}=await Zd;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await Zd;try{let o=e(r),i=new t,s=l=>o.charToGlyphIndex(l.char);return i.registerModifier("glyphIndex",null,s),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function OT(n){return await(await fetch(n)).arrayBuffer()}var AT=new Ys;async function Qd(n){let r,e,t=!1;if(n.url?(r=await OT(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer),r){let o=await AT.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}var Vi=require("three");function NT(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Kl=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Qd(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=Qd(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=[],l=0,c=t.length===i.length;for(let u=0;u<t.length;u++){let a=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[l];if(NT(a,p)||c)s.push({char:d,index:a,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),l++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)l++,m=e.charAt(l),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===a&&(g=!0),l>e.length&&(g=!0);s.push({char:d,index:a,replacements:h,replacementChars:Array.from(f)}),l++}}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(v=>this.getTextWidth(v,e)),l=e.width,c=this.getCharWidth(`
1884
- `,e),u=e.horizontalAlign===1?c:0,a=this.computeSpaceWidthForLine(r,0,e),d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,r[0],c),p=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),f=[],m=r.map(v=>[]),h=r.map(v=>[]),y;for(let v=0;v<r.length;v++){let b=r[v],w={features:{liga:!0}},S=[];try{S=t.stringToGlyphs(b,w)}catch(_){console.warn(_)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,b,c);let T=[];try{T=this.reverseLigaturesTable(t,b,S)}catch(_){console.warn(_)}a=this.computeSpaceWidthForLine(r,v,e);for(let _=0;_<S.length;_++){let x=S[_],C=x.index===0?`
1885
- `:x.unicode?String.fromCharCode(x.unicode):void 0,P=T[_],N=0,O=0;_===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(O=-x.leftSideBearing*o),y&&(N=t.getKerningValue(x,y)*o),d+=O+N;let A=0;if(C===`
1886
- `)A=u;else if(C===" ")A=a;else{let R=this.createPath(x,o,d,p,e);R&&(A=R.offsetX-(N+O),f.push(R.path))}if(P.replacements.length===1)h[v].push([d,p]),m[v].push(A);else{let R=P.replacements.map(X=>(t.glyphs.get(X).advanceWidth??0)*o),k=R.reduce((X,W)=>X+=W,0),$=R.map(X=>X/k),te=d;for(let X=0;X<$.length;X++){let W=A*$[X];h[v].push([te,p]),m[v].push(W),te+=W}}d+=A,y=x}p-=i}let g=[];for(let v=0,b=f.length;v<b;v++)g.push(...f[v].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(`
1887
- `)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let s=e*r,l=Math.abs(this.ascender-this.descender)*o,c=r-l,u=-this.ascender*o-c/2;return i===3?-(t-s-u):i===2?-(t*.5-s*.5-u):u}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 l=new Yl,c=(r.advanceWidth??1)*e;if(r)for(let u of s.commands){let a=l.currentPath?.currentPoint;if(!(a&&u.type!=="Z"&&a.x===u.x&&-a.y===u.y))switch(u.type){case"M":l.moveTo(u.x,-u.y);break;case"L":l.lineTo(u.x,-u.y);break;case"Q":l.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":l.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return l.subPaths.forEach(u=>{let a=CT(u.curves);a!==void 0&&u.currentPoint.distanceTo(a)>0&&u.lineTo(a.x,a.y)}),{offsetX:c+i.fontSize*i.letterSpacing,path:l}}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 l=t.width,c=this.getTextWidth(i,t);return(l-(c-s*o))/s}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function CT(n){if(n.length){let r=n[0];if(r instanceof Vi.LineCurve)return r.v1;if(r instanceof Vi.CubicBezierCurve||r instanceof Vi.QuadraticBezierCurve)return r.v0}}var Jd=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 Jd{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=Xo(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var zy={find(n){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(n){},addPendingUpdateCloner(n){},addPendingCommand(n){}};var eu=class extends Wl{constructor(e){super();this.shared=e}create(e){return new Gi(e,this.shared)}},rn=class{constructor(r,e={}){this.geometryCache=new Ks(!0);this.geometryCache2=new Ks(!1);this.imageHolderCache=new eu(this);this.thisContext={scene:zy,shared:this};this.deletedMaterial=new en(Gt.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new rr($n.emptyImage,this);this.deletedVideo=new rr(jn.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];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 en(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);this.penumbraSize=r.penumbraSize}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):new Ri(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 rr(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 rr(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 No(e.r,e.g,e.b,e.a):this.colors[r]=new No(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 at(0,0,0,0))}else return"a"in r?new at(r.r,r.g,r.b,r.a):new at(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 tn)return e;{let t=new tn({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof tn&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Kl(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 tn&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},jy=new rn(fl.emptyData());var Pr=class extends bt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Qf(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,s]of Object.entries(e.props)){let l=o.shared.material(s);this.material[Number(i)]=l}else if(dr(e.path,["material"])&&this.material instanceof kt)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(vt.drop(e,1),t.material,o);else if(dr(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(vt.drop(e,2),s,o)}}}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&&ma(this.material).forEach(e=>{e instanceof kt&&(e instanceof en||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Fy=require("three");var _t=class extends Pr{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Fy.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof rn){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 ps.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return ps.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),dr(e.path,["geometry"])&&this.updateByPatchedOpGeometry(vt.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 a={...this.data.geometry,...i};this.localGeometry=Xo(a,t,this.data.flatShading)}let s,l,c;i.scaleBaked?[s,l,c]=i.scaleBaked:{width:s,height:l,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Ls(this.localGeometry.attributes,s/u.sxPrev,l/u.syPrev,c/u.szPrev),u.sxPrev=s,u.syPrev=l,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Xo(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&&ns(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof tt&&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)}};function IT(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 l=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=new Zt.Vector3(o[s],o[s+1],o[s+2]);r.has(l)?r.get(l)?.normals.push(c):r.set(l,{normals:[c],result:new Zt.Vector3})}r.forEach((s,l)=>{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 l=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=r.get(l)?.result;c&&(i[s]=c.x,i[s+1]=c.y,i[s+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new Zt.Float32BufferAttribute(i,3))}function MT(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 Zt.Vector3;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=o.x,t[i+1]=o.y,t[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new Zt.Float32BufferAttribute(t,3))}function zi(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof kt)||n.material.getLayersOfType("outline").length===0)return;n instanceof _t&&n.is2DAndNoDepth?MT(n):IT(n)}function ji(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=[Zt.MathUtils.seededRandom(o),Zt.MathUtils.seededRandom(o+1e4),Zt.MathUtils.seededRandom(o+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];n.geometry.setAttribute("randomColor",new Zt.BufferAttribute(t,3))}var ET;di.then(n=>{ET=n});var kr=new so.Box3,Zs=new so.Vector3;function ky(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var on=class extends _t{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new so.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=tt.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,zi(this),ji(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){tt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&tt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=tt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=tt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,t){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,bt.prototype.raycast.call(this,e,t),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new so.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;kr.setFromBufferAttribute(t),kr.getCenter(o),e.boundingSphere.radius=o.distanceTo(kr.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),kr.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;kr.min.set(e[0],e[2],e[4]),kr.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(kr.min.applyMatrix4(this.shearScaleInv),kr.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new so.Sphere);let o=t.boundingSphere.center;kr.getCenter(o),t.boundingSphere.radius=o.distanceTo(kr.max)}freeSubdivPointer(){this.subdivPointer&&(tt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};var Ur=require("three"),Uy=-1,LT=1,Hy={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},qy={polygon_center:0,edge:1,vertex:2},Qs=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,he=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-Uy)*(e-t)/(LT-Uy)+t};function Wy(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 BT=new Ur.Vector3,Zl=new Ur.Vector3,DT=new Ur.Vector3,GT=new Ur.Vector3;function Fi(n,r){let e=DT.fromArray(n),t=GT.fromArray(r);Zl.copy(t).sub(e);let o=Zl.length();return Zl.normalize().multiplyScalar(o*.5),BT.copy(e).add(Zl).toArray()}var ir=new Ur.Triangle,Ql=new Ur.Vector3,Jl=new Ur.Vector3,nn=new Ur.Vector3;function $y(n){let r=[];for(let e=0;e<=n.index.count;e++)if(Ql.fromArray(n.index.array,e*3),ir.setFromAttributeAndIndices(n.attributes.position,Ql.x,Ql.y,Ql.z),ir.getNormal(Jl),ir.getMidpoint(nn),!(isNaN(nn.x)||isNaN(nn.y)||isNaN(nn.z))){let{a:t,b:o,c:i}=ir,s=t.toArray(),l=o.toArray(),c=i.toArray(),u=t.distanceTo(o),a=o.distanceTo(i),d=i.distanceTo(t),p=Fi(s,l),f=Fi(l,c),m=Fi(c,s),h=[u,a,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,v=[],b=ir.getMidpoint(nn).toArray();y===u&&!g&&(v=[f,m,m],b=p),y===a&&!g&&(v=[p,m,m],b=f),y===d&&!g&&(v=[p,f,f],b=m),g&&(v=[p,f,m]),r.push({vertices:[s,l,c],faceCenters:v,midpoint:b,norm:ir.getNormal(Jl).toArray()})}return r}function Xy(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){ir.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),ir.getNormal(Jl),ir.getMidpoint(nn);let o=ir.a.toArray(),i=ir.b.toArray(),s=ir.c.toArray();r.push({vertices:[o,i,s],faceCenters:[Fi(o,i),Fi(i,s),Fi(s,o)],midpoint:nn.toArray(),norm:Jl.toArray()})}return r}var RT=4,VT=.5,tu=n=>.5*(1-Math.cos(n*Math.PI)),ru=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),l=r-o,c=e-i,u=t-s,a,d,p=0,f=.5,m,h,y;for(let g=0;g<RT;g++){let v=o+(i<<4)+(s<<8);a=tu(l),d=tu(c),m=this.perlin[v&4095],m+=a*(this.perlin[v+1&4095]-m),h=this.perlin[v+16&4095],h+=a*(this.perlin[v+16+1&4095]-h),m+=d*(h-m),v+=256,h=this.perlin[v&4095],h+=a*(this.perlin[v+1&4095]-h),y=this.perlin[v+16&4095],y+=a*(this.perlin[v+16+1&4095]-y),h+=d*(y-h),m+=tu(u)*(h-m),p+=m*f,f*=VT,o<<=1,l*=2,i<<=1,c*=2,s<<=1,u*=2,l>=1&&(o++,l--),c>=1&&(i++,c--),u>=1&&(s++,u--)}return p}noiseSeed(r){let e=(()=>{let s,l;return{setSeed(c){l=s=(c??Math.random()*4294967296)>>>0},getSeed(){return s},rand(){return l=(1664525*l+1013904223)%4294967296,l/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},Yy=ru;var Ui=require("three");var Ky=new Ui.Vector3,Zy=new Ui.Matrix4,Qy=new Ui.Ray;function Jy(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var ki=class extends _t{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)&&(Zy.copy(o).invert(),Qy.copy(e.ray).applyMatrix4(Zy),Qy.intersectBox(this.singleBBox,Ky))){let i=Ky.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var Mt=1e-4,Hr,rg,og,ng,eg=new Me.Vector3,tg=new Me.Vector3;di.then(n=>{Hr=n,rg=[Hr.get_face_center,Hr.get_edge_midpoint,Hr.get_vertex_position],og=[Hr.get_face_normal,Hr.get_edge_normal,Hr.get_vertex_normal],ng=[Hr.face_count,Hr.edge_count,Hr.vertex_count]});var zT=new Me.Matrix4,jT=new Me.Matrix4,Co=new Me.Vector3,sn=new Me.Vector3,Js=new Me.Vector3,ou=new Me.Vector3,FT=new Me.Vector3,kT=new Me.Vector3;var ao=new Yy,qi=class extends Xn(Me.Object3D){constructor(e,t){super();this.parameters=t;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof 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,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 l=new oo(this.object);l.expand(),this.add(l)}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 oo(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*Me.MathUtils.DEG2RAD,i=t.end*Me.MathUtils.DEG2RAD,s=o-i,l=new Me.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Me.Vector3(0,0,1);break;case"y":c=new Me.Vector3(0,1,0);break;default:case"x":c=new Me.Vector3(1,0,0);break}let u=e.randomnessObject??Br.defaultData([1,1,1]).randomnessObject,a=u.noiseType==="perlin";ao.noiseSeed(u.seed);let d=hl((0,Hi.default)(u.seed)),p=Qs(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=a?ao.noise(h):d(h,h);m.scale.x=t.scale[0]+p(f,he(y,u.scale[0]))||Mt,m.scale.y=t.scale[1]+p(f,he(y,u.scale[1]))||Mt,m.scale.z=t.scale[2]+p(f,he(y,u.scale[2]))||Mt,m.position.setScalar(0);let g=s/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,g,0);break;case"y":m.rotation.set(0,0,g);break;case"z":m.rotation.set(g,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(f,he(y,u.position[0])),m.position.y+=t.position[1]+p(f,he(y,u.position[1])),m.position.z+=t.position[2]+p(f,he(y,u.position[2]));let v=p(f,he(y,u.rotation[0])),b=p(f,he(y,u.rotation[1])),w=p(f,he(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=l.x+v,m.rotation.y+=l.y+b,m.rotation.z+=l.z+w):m.rotation.set(l.x+v,l.y+b,l.z+w)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Me.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Br.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";ao.noiseSeed(i.seed);let l=hl((0,Hi.default)(i.seed)),c=Qs(i.strength,this.parameters.randomness);for(let[u,a]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=s?ao.noise(d):l(d,d),f=c(u,he(p,i.rotation[0])),m=c(u,he(p,i.rotation[1])),h=c(u,he(p,i.rotation[2]));a.scale.x=1+(t.scale[0]-1)*u+c(u,he(p,i.scale[0]))||Mt,a.scale.y=1+(t.scale[1]-1)*u+c(u,he(p,i.scale[1]))||Mt,a.scale.z=1+(t.scale[2]-1)*u+c(u,he(p,i.scale[2]))||Mt,a.rotation.x=o.x*u+f,a.rotation.y=o.y*u+m,a.rotation.z=o.z*u+h,a.position.x=t.position[0]*u+c(u,he(p,i.position[0])),a.position.y=t.position[1]*u+c(u,he(p,i.position[1])),a.position.z=t.position[2]*u+c(u,he(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Br.defaultData([1,1,1]).randomnessObject,s=Qs(i.strength,this.parameters.randomness),l=i.noiseType==="perlin";ao.noiseSeed(i.seed);let c=$m((0,Hi.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},a=new Me.Vector3(o.size[0]*(o.count[0]-u.x)*.5,o.size[1]*(o.count[1]-u.y)*.5,o.size[2]*(o.count[2]-u.z)*.5);for(let d=0;d<o.count[0];d++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let m=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=l?ao.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,he(h,i.scale[0]))||Mt,y.scale.y=1+s(t,he(h,i.scale[1]))||Mt,y.scale.z=1+s(t,he(h,i.scale[2]))||Mt;let g=s(t,he(h,i.rotation[0])),v=s(t,he(h,i.rotation[1])),b=s(t,he(h,i.rotation[2]));y.rotation.set(g,v,b),y.position.x=o.size[0]*d-a.x+s(t,he(h,i.position[0])),y.position.y=o.size[1]*p-a.y+s(t,he(h,i.position[1])),y.position.z=o.size[2]*f-a.z+s(t,he(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let a=0;a<o.count[1];a++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(a+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=l?ao.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,he(f,i.scale[0]))||Mt,m.scale.y=1+s(t,he(f,i.scale[1]))||Mt,m.scale.z=1+s(t,he(f,i.scale[2]))||Mt;let h=s(t,he(f,i.rotation[0])),y=s(t,he(f,i.rotation[1])),g=s(t,he(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*u+s(t,he(f,i.position[0])),m.position.y=-o.size[1]*a+s(t,he(f,i.position[1])),m.position.z=-o.size[2]*d+s(t,he(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Me.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Br.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";ao.noiseSeed(i.seed);let l=hl((0,Hi.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 ki)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(),a=[],d=g=>{let v=g.length,b=g.map(T=>T[0]).reduce((T,_)=>T+_,0),w=g.map(T=>T[1]).reduce((T,_)=>T+_,0),S=g.map(T=>T[2]).reduce((T,_)=>T+_,0);return[b/v,w/v,S/v]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let v=u.filter(b=>p(g.pos[0])===p(b.pos[0])&&p(g.pos[1])===p(b.pos[1])&&p(g.pos[2])===p(b.pos[2]));v.length>1?a.push({pos:g.pos,norm:d(v.map(b=>b.norm))}):a.push(g)});let f=Wy(a);if(u.length>0){let g=Math.round(f.length*t.count/100);this._updateCount(g)}this.objectForSample.updateMatrixWorld();let m=new yl(this.objectForSample).build(),h=Hy[t.axis],y=this.children;m.setRandomGenerator((0,Hi.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let b=g*(i.freqScale/10)+i.movement,w=s?ao.noise(b):l(b,b),S=c(g,he(w,i.rotation[0])),T=c(g,he(w,i.rotation[1])),_=c(g,he(w,i.rotation[2]));t.spreadType==="random"?m.sample(Js,ou):(f.length&&(Js.fromArray(f[g].pos),ou.fromArray(f[g].norm)),this.objectForSample instanceof on&&Js.applyMatrix4(zT.copy(this.objectForSample.matrixWorld).invert())),Js.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(Js),Co.fromArray(h);let x=t.align==="normal"?ou:this.object.getWorldDirection(kT),C=sn.fromArray(t.position);sn.x+=sn.x+c(g,he(w,i.position[0])),sn.y+=sn.y+c(g,he(w,i.position[1])),sn.z+=sn.z+c(g,he(w,i.position[2]));let P=Math.acos(x.dot(Co)),N=FT.crossVectors(Co,x).normalize(),O=jT.makeRotationAxis(N,P),A=x.clone().cross(this.object.up).normalize(),R=A.clone().cross(x).normalize(),k=new Me.Matrix4().makeBasis(A,x,R),$=new Me.Vector3(Co.y,Co.z,Co.x).normalize(),te=$.clone().cross(Co).normalize(),X=new Me.Matrix4().makeBasis($,Co,te).invert(),W=new Me.Matrix4().multiplyMatrices(k,X);v.rotation.setFromRotationMatrix(W),C.applyMatrix4(O),v.position.add(C),v.rotation.x=v.rotation.x+o.x+S,v.rotation.y=v.rotation.y+o.y+T,v.rotation.z=v.rotation.z+o.z+_,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+c(g,he(w,i.scale[0]))||Mt,v.scale.y=v.scale.y+t.scale[1]+c(g,he(w,i.scale[1]))||Mt,v.scale.z=v.scale.z+t.scale[2]+c(g,he(w,i.scale[2]))||Mt,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof on){let t=this.objectForSample,o=qy[e],i=ng[o],s=rg[o],l=og[o],c=[],u=i(t.subdivPointerNew);for(let a=0;a<=u-1;a++){let d=s(t.subdivPointerNew,a),p=l(t.subdivPointerNew,a);eg.fromArray(d).applyMatrix4(t.matrixWorld),tg.fromArray(p),c.push({pos:eg.toArray(),norm:tg.toArray()})}return c}else return(this.objectForSample.geometry.index?$y(this.objectForSample.geometry):Xy(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=eo(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=t.find(this.parameters.toObject.object);o instanceof bt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new Me.Matrix4,this.hiddenMatrix=new Me.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var cr=require("three");var qe=require("three");var Tt=require("three");var ig=require("three"),qr=n=>{var r;return r=class extends n{},r.geometryHelper=new ig.BoxGeometry(30,30,30),r};var Ot=require("three"),ec=new Ot.Ray,nu=new Ot.Sphere,sg=new Ot.Matrix4,Wr=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),nu.copy(i.boundingSphere),nu.applyMatrix4(s),e.ray.intersectsSphere(nu)===!1||(sg.copy(s).invert(),ec.copy(e.ray).applyMatrix4(sg),i.boundingBox!==null&&ec.intersectsBox(i.boundingBox)===!1))return;let l,c,u,a,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),v=Math.min(d.count,f.start+f.count);for(m=g,h=v;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),a=d.getX(m+2),l=y(n,e,ec,p,c,u,a),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let v=i.attributes.position,b=new Ot.Vector3,w=new Ot.Vector3,S=new Ot.Vector3,T=new Ot.Vector3,_=2,C=1/((n.scale.x+n.scale.y+n.scale.z)/3),P=C*C,N=Math.max(0,f.start),O=Math.min(v.count,f.start+f.count);for(let A=N,R=O-1;A<R;A+=_){if(b.fromBufferAttribute(v,A),w.fromBufferAttribute(v,A+1),ec.distanceSqToSegment(b,w,T,S)>P)continue;T.applyMatrix4(n.matrixWorld);let $=e.ray.origin.distanceTo(T);$<e.near||$>e.far||t.push({distance:$,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,b,w,S,T,_){let x=new Ot.Vector3,C=new Ot.Vector3,P=new Ot.Vector3,N=new Ot.Vector3,O=new Ot.Vector3;if(x.fromBufferAttribute(w,S),C.fromBufferAttribute(w,T),P.fromBufferAttribute(w,_),b.intersectTriangle(x,C,P,!1,N)===null)return null;O.copy(N),O.applyMatrix4(g.matrixWorld);let R=v.ray.origin.distanceTo(O);return R<v.near||R>v.far?null:{faceIndex:1,distance:R,point:O.clone(),object:g}}};var tc=new Tt.Vector3,sr=new Tt.Camera,iu=class extends Tt.LineSegments{constructor(e){let t=new Tt.BufferGeometry,o=new Tt.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new Tt.Color(15711266),u=new Tt.Color(15711266),a=new Tt.Color(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",a),d("u2","u3",a),d("u3","u1",a);function d(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),l[f]===void 0&&(l[f]=[]),l[f].push(i.length/3-1)}t.setAttribute("position",new Tt.Float32BufferAttribute(i,3)),t.setAttribute("color",new Tt.Float32BufferAttribute(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=l,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;sr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,l=o?.8:1e-4;Or("n1",t,e,sr,-i,-s,l),Or("n2",t,e,sr,i,-s,l),Or("n3",t,e,sr,-i,s,l),Or("n4",t,e,sr,i,s,l);let c=l;Or("f1",t,e,sr,-i,-s,c),Or("f2",t,e,sr,i,-s,c),Or("f3",t,e,sr,-i,s,c),Or("f4",t,e,sr,i,s,c);let u=c,a=.5;Or("u1",t,e,sr,i*.7*a,s*1.1,u),Or("u2",t,e,sr,-i*.7*a,s*1.1,u),Or("u3",t,e,sr,0,s*(1.1+.9*a),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Or(n,r,e,t,o,i,s){tc.set(o,i,s).unproject(t);let l=r[n];if(l!==void 0){let c=e.getAttribute("position");for(let u=0,a=l.length;u<a;u++)c.setXYZ(l[u],tc.x,tc.y,tc.z)}}var rc=class extends qr(iu){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){Wr(this.object,this.geometry,e,t,!0)}};var ea=require("three");var oc;(r=>r.is=e=>"objectHelper"in e)(oc||(oc={}));var Io=(n,r)=>class extends vl(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 ea.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof ea.BoxGeometry?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof ea.Box3Helper&&(i.visible=!1)}}};var su=790,Wi=new qe.Vector3,au=new qe.Vector3,lu=new qe.Quaternion,cu=new qe.Vector3,ta=new qe.Vector3,du=new qe.Vector3,$r=class extends Io(qe.Camera,rc){constructor(e="",t={...Hn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=jo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;if(t.orthographic.autoZoom){let s=t.orthographic.autoZoomFrustumSize??su,l=o/i,c=o>i?l:1,u=o>i?1:l;this.orthoCamera=new qe.OrthographicCamera(-s*.5*c,s*.5*c,s*.5*(1/u),-s*.5*(1/u),-5e4,1e4)}else this.orthoCamera=new qe.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4);this.perspCamera=new qe.PerspectiveCamera(45,o/i,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,o){typeof e=="number"&&(e=new qe.Vector3(e,t,o)),super.lookAt(e),this.getWorldPosition(Wi),this.targetOffset=Wi.distanceTo(e)}getTarget(e=new qe.Vector3){return this.getWorldDirection(au),this.getWorldPosition(Wi),au.multiplyScalar(this.targetOffset),e.copy(Wi).add(au),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Wi),Wi.distanceTo(e)}updateUp(){this.getWorldQuaternion(lu),cu.set(0,0,1).applyQuaternion(lu),ta.copy(qe.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&ta.negate(),ta.applyQuaternion(lu),du.copy(qe.Object3D.DEFAULT_UP).projectOnPlane(cu),this.angleOffsetFromUp=du.angleTo(ta),this.angleOffsetFromUp*=du.cross(ta).dot(cu)>=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 qe.Vector3),i=e.getWorldDirection(new qe.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToObject(e){let t=e.getWorldPosition(new qe.Vector3),i=this.getWorldDirection(new qe.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().sub(i),target:t}}setViewplaneSize(e,t){if(this.aspect=e/t,this.data.type==="OrthographicCamera"&&this.data.orthographic.autoZoom){let o=this.data.orthographic.autoZoomFrustumSize??su,i=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-o*.5*i,this.right=o*.5*i,this.top=o*.5*(1/s),this.bottom=-o*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;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,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,s,l):this.orthoCamera.setViewOffset(e,t,o,i,s,l)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}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,autoZoom:!0,autoZoomFrustumSize:su},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return In(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var Mo=require("three");var $i=new Mo.Matrix4,HT=new Mo.Matrix4;var ar=class extends Pr{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Mo.BufferGeometry;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 ar&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof bt&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if($i.multiplyMatrices(s.hiddenMatrix,s.matrix),s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=xr.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;xr.transformMeshSet(s.booleanMeshSetAddress,$i),s.booleanMatrixInvOld.copy($i).invert(),s.booleanWasTransformed=!1}else s instanceof ar&&s.needsTransformForDownstream===!0?(xr.transformMeshSet(s.booleanMeshSetAddress,$i),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(xr.transformMeshSet(s.booleanMeshSetAddress,HT.multiplyMatrices($i,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy($i).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new Mo.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return xr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Mo.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=xr.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,zi(this),ji(this)}dispose(){super.dispose(),this.geometry.dispose()}};var lg=require("three");var ag;(r=>{function n(e){return De.is(e)&&e instanceof lg.Light}r.is=n})(ag||(ag={}));var Xi=(n,r)=>class extends Io(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 Yi=n=>n instanceof bt,ra=n=>n!==null&&n instanceof ar,cg=n=>n instanceof $r;var uu=n=>oc.is(n);var ug=require("three");var dg=require("three");var Eo=class extends qr(dg.AxesHelper){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Wr(this.object,Eo.geometryHelper,e,t)}update(){}};var oa=class extends Io(ug.Group,Eo){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};var ia=require("three");var pg=require("three");var Ki=class extends qr(pg.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Wr(this.object,Ki.geometryHelper,e,t)}};var fg=require("three");var Zi=class extends qr(fg.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Wr(this.object,Zi.geometryHelper,e,t)}};var ic=require("three");var nc=class extends qr(ic.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Wr(this.object,nc.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=nc._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,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},na=nc;na._vector=new ic.Vector3;function qT(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 sc=class extends Xi(ia.DirectionalLight,Ki){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 ia.CameraHelper(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 ia.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&qT(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)),t&&this.update()}};var Ut=require("three");var ac=class extends Xi(Ut.PointLight,Zi){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 Ut.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),l=new Ut.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new Ut.Box3(s,l),u=new Ut.Box3Helper(c,new Ut.Color(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 Ut.Box3Helper){let t=this.shadow.camera,o=new Ut.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new Ut.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var lr=require("three");var mg=new lr.Vector3,hg=new lr.Vector3,yg=new lr.Quaternion,lc=class extends Xi(lr.SpotLight,na){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=lr.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new lr.CameraHelper(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 lr.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),hg.setFromMatrixPosition(this.matrixWorld),yg.setFromRotationMatrix(this.matrixWorld),mg.copy(this.up).applyQuaternion(yg).negate().multiplyScalar(this.distance),this.target.position.copy(hg).add(mg),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.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var cc=class extends _t{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Gs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var Qi=class extends _t{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=Ml;break;case"Ellipse":i=ii;break;case"Polygon":i=Il;break;case"Star":i=El;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?Gs(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var xg=require("three");var lo=class extends Io(xg.Group,Eo){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 l of So.rootOverrideProps)e[l]===void 0?(i===void 0&&(i={...e}),i[l]=o.data[l]):(s===void 0&&(s={}),s[l]=e[l]);return this.overrideData=s,i??e}return e}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i&&(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component))for(let l of So.rootOverrideProps)l in e.props&&e.props[l]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[l]=this.component.data[l]);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){this.component=e.scene.find(t.component)??null;let o=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let i=0;for(let s of this.children)if(De.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),dc(s),i+=1;else break;this.children.splice(0,i)}o=!0}this.component&&vg(e,[this.uuid],t.overrides,this,this.component,this.component,0,o),this.oldComponent=this.component}}};function dc(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)De.is(e)&&dc(e)}}function gg(n,r,e,t){return n.component===r&&ns(n.identity,t)?n.overrideData===e?2:1:0}function vg(n,r,e,t,o,i,s,l){if(s>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.push(t),t.component=o}o instanceof lo&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(De.is(u)){let a=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=qn.resolve(e,a,1),p=null,f;if(!l){let m=t.children[c];if(p=De.is(m)?m:null,p!==null){let h=gg(p,u,d,a);f=h>=1?p.stateSelection:void 0,h!==2&&(p=null)}if(p===null&&(p=n.scene.findInstance(a)??null,p!==null)){let h=gg(p,u,d,a);if(f=h>=1?p.stateSelection:void 0,h!==2)p=null;else{let y=p.parent.children.indexOf(p);p.parent.children.splice(y,1),t.children.splice(c,0,p),p.parent===t?(y<=c&&console.error("not possible"),void 0):(p.parent=t,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),n.pendingDeletes.delete(p),void 0)}}}if(p===null){let m=d?to.apply(u.data,d):u.data;ur.is(m.type)&&(m={...m,type:"Empty"}),p=mr.createEntity(a,m,n),p.overrideData=d,t.add(p),t.children.splice(t.children.length-1,1),t.children.splice(c,0,p),p.updateState(p.data,n),f&&p.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(p)}c+=1,vg(n,r,e,p,u,i,s+1,l)}if(!l){let u=c;for(;;){let a=t.children[c];if(De.is(a))n.pendingDeletes.add(a);else break;c+=1}t.children.splice(u,c-u)}return!0}function WT(n,r,e){let t;return r.geometry.type==="TextGeometry"?new ki(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new on(n,r,e):r.geometry.type==="PathGeometry"?t=new Qi(n,r,e):r.geometry.type==="VectorGeometry"?t=new cc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new ar(n,r,e):t=new _t(n,r,e),t)}function uc(n,r,e){return r.type==="Mesh"?WT(n,r,e):r.type==="Empty"?new oa(n,r):r.type==="PointLight"?new ac(n,r,e):r.type==="SpotLight"?new lc(n,r,e):r.type==="DirectionalLight"?new sc(n,r,e):r.type==="Component"||r.type==="Instance"?new lo(n,r,e):ur.is(r.type)?new $r(n,r):(console.error(r),new oa(n,r))}mr.createEntity=uc;function $T(n,r,e){let t=uc(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,l=n.component,c=n.instances,u=n.overrideData,a=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=s,n.component=l,n.instances=c,n.uuid=a,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}mr.changeEntityProptotype=$T;mr.Cloner=qi;function bg(n,r,e,t){n.updateByOp(r,e,t,!1)}var Ji=require("three");function Sg(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,ji(n),zi(n)),t.length===0&&o.length===0&&n.layers.set(0),e}function wg(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),e}function _g(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Pr)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Sg(e,e.material[t])&&(r=!0);else Sg(e,e.material)&&(r=!0)}),r}function Tg(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof Pr)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)wg(e,e.material[t])&&(r=!0);else wg(e,e.material)&&(r=!0)}),r}var YT=new Ji.Raycaster,KT=new Ji.Matrix4,ZT=new Ji.Ray;function pu(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=KT.copy(i.matrixWorld).invert(),l=ZT.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;l.applyMatrix4(c);let u=YT;u.set(l.origin,l.direction),u.near=r.near,u.far=r.far;let a=u.intersectObject(n,!1);a.length>0&&e.push({...a[0],object:t?i:n})}}var pc=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 l=i.length-2;l>=0;l--)if(!e.has(i[l])){let c=r.find(i[l]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[l]}`),e.add(i[l])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var QT=new cr.MeshBasicMaterial;QT.wireframe=!0;var Pg=new cr.Vector3,fu=class extends cr.Scene{constructor(e,t){super();this.data=e;this.backupFog=new cr.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.bgColor=new at(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new pc;this.needsRecomputeInstances=!1;this.ambientLight=new cr.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Tg(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=_g(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}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}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 l=i.children.indexOf(s);o.splice(0,0,l)}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)=>vu(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(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(),Yi(i)&&ra(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i)}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),o.parent.remove(o),ra(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Yi(o)&&(o.freeBooleanPointer(),i instanceof ar&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qi&&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();let l=e.localIndex;s.children.splice(l,0,s.children.pop()),Yi(o)&&(o.invalidateUpstreamBooleanData(),ra(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof ar&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props){let{states:l,rest:c}=t.props;t={...t,props:c},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{bg(s,t,o,{scene:this,shared:i}),s instanceof _t&&s.updateGeometryGroupsIfNeeded()}catch(l){console.error(l)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(wt(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof $r&&this.switchActiveCamera(o)}this.expandInstances(t,!0),this.traverseEntity(o=>{ra(o)&&o.recomputeBoolean(),o instanceof $r&&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){De.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{De.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,l,c){e&&e!==i.uuid&&i.find(e)&&s.forInstancesRec(a=>{a.isInstanceRoot||(a.data=Vn(a.data,d=>{let p=d.events.data(c.id),f=a.goUp(l);if(f){let m=[...ma(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid;At.zoom(p,t)[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof lo&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{i.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=Vn(s.data,l=>{l.events.delete(i.id)}).data)}):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)),i.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,o,i)}),i.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,o,i)})):"actions"in i.data&&i.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,o,i)})})}),!0})}expandInstances(e,t){let o=new Set;this.traverseEntity(i=>{if(i instanceof lo&&i.isInstanceRoot)return i.expandInstanceChildren({scene:this,shared:e,pendingDeletes:o}),t||i.resetBBoxNeedsUpdate(),!0});for(let i of o)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),dc(i)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof lo&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}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)De.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new $r(fu.PERSONAL_CAMERA_ID,{...Hn.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],o=i=>{for(let s of i.children){let l=s.cloner;De.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible)&&((Yi(s)||uu(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),pu(s,e,t)),o(s))}};return o(this),t}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let l=s.cloner;De.is(s)&&(s.visible||l?.object.data.visible)&&((Yi(s)||uu(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),pu(s,e,t,!0)),o(s))}};return o(this),t}forEachEntity(e){for(let t of this.children)De.is(t)&&e(t)}traverseEntity(e){for(let t of this.children)De.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)bs.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)De.is(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,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}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=wt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=wt(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}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,l){let c={scene:this,shared:l},u=uc(e,t,c);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(s,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,l)),u.updateState(t,c),u instanceof _t&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),u}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],u=this.find(l),a=c?u.recursiveBBox:u.singleBBox;t.push(...a.vertices)}let o=new cr.Box3;return o.setFromPoints(t),o.getCenter(Pg),Pg}copyMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e);o?t.copy(o.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){if(e===null){t.identity();return}let o=this.find(e)?.parent;o?t.copy(o.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof bt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof kt&&e(t.material[o]);else t.material instanceof kt&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let o,i;e>=t?(o=t/e,i=1):(o=1,i=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},es=fu;es.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera",es.PERSONAL_CAMERA_EXPORT_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCameraExport";var Og=require("three/examples/jsm/loaders/DRACOLoader.js");var Lo;function JT(){return Lo||(Lo=new Og.DRACOLoader,Lo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Lo.decoderPending}async function eP(n){if(Lo){let r={attributeIDs:Lo.defaultAttributeIDs,attributeTypes:Lo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Lo.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 Ag(n,r){let[e,t]=Ac(rl.deserialize(new Uint8Array(n)));Um(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 JT();for(let i of o){let s=await eP(ut(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:u,itemSize:a})=>{l[c]={array:u,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}var tP=require("three"),rP=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Ng(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var aa=require("three");function Cg(n){let r=new Set;return n.traverse(e=>{if(e instanceof Pr)if(Xe(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(oP(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new aa.Color,specularColor:new aa.Color});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},aa.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(l=>{if(i.uniforms.transmissionSamplerMap.value){let c=l.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else nP(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function oP(n){return n.getLayersOfType("transmission").length>0}function nP(n){let r=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let t=e.uniforms["f"+e.id+"_alpha"];t&&(r+=(1-r)*t.value)}}),r<1}function Ig(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function Mg(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(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}var Eg=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Lg(n){let r=[];return n.traverse(e=>{e instanceof qi&&r.push(e)}),r.forEach(e=>{let t=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Ng(c),c}),s=(0,Eg.mergeBufferGeometries)(e.parameters.hideBase?i:[t instanceof bt?t.geometry:[],...i]);t instanceof bt&&(t.geometry=s),e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:jy})}),n}function Bg(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function Dg(n){Object.values(n.shared.materials).forEach(r=>{mu(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?mu(e.material):"materials"in e&&e.materials.forEach(t=>{mu(t)})})}function mu(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 zg=ln(Rg(),1),Vg="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",fc=class extends mc.Loader{load(r,e,t,o=console.error){let i=new mc.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(Vg+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(Vg),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},t,o)}async parse(r){let e=await Ag(r,Dg);e.version&&(0,zg.default)(e.version,"0.9.357")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([ky(e)&&iy(),Jy(e)&&Vy()].filter(Boolean));let t=new rn(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new es(e.scene,t);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&cg(s)&&Object.assign(s,{makeDefault:!0})}return o=Lg(o),o=Cg(o),o=Ig(o),o=Mg(o),o=Bg(o),o}};
1992
+ `)}return t}};var Yl=require("three");var ql=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 $d=class extends ql{create(r){return URL.createObjectURL(new Blob([r]))}dispose(r,e){URL.revokeObjectURL(e)}},Wd;function Ly(n){return typeof n=="string"?n:(Wd||(Wd=new $d),Wd.load(n))}var Wl=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")}},$l=class{constructor(){this.cache=new Map}remove(r){if(this.cache.delete(r.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(r){let e=this.cache.get(r);return e===void 0&&(e=this.create(r),this.cache.set(r,e)),e.refCount+=1,e}};var ji=class extends Wl{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 l=this[s];l&&(l.image=this.img,l.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=l=>{i=l.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=Ly(e),this.img.onload=t}getTexture(e){let t=this[e];if(t)return t;{let o;return this.isVideo?o=new Yl.VideoTexture(this.img,void 0,e,e):o=new Yl.Texture(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 nr=class extends ji{};var Fe=require("three");function vt(n,r){return r.color(n)}function By(n,r){switch(n.type){case"fresnel":return bP(n,r);case"gradient":return SP(n);case"depth":return wP(n);case"normal":return _P(n);case"noise":return PP(n,r);case"rainbow":return TP(n);case"toon":return OP(n,r);case"outline":return AP(n,r);case"transmission":return NP(n,r);case"color":return vP(n,r);case"pattern":return CP(n,r)}}function xP(n){return{type:n.type}}function Or(n){let{alpha:r,mode:e,isMask:t}=n;return{...xP(n),alpha:r,mode:e,isMask:t}}function vP(n,r){return{...Or(n),color:vt(n.color,r)}}function bP(n,r){let{bias:e,scale:t,intensity:o,factor:i,color:s,isMask:l}=n;return{...Or(n),color:vt(s,r),bias:e,scale:t,intensity:o,factor:i}}function SP(n){let{gradientType:r,smooth:e,colors:t,steps:o,angle:i,offset:s,morph:l}=n;return{...Or(n),gradientType:r,smooth:e,colors:t.map(c=>new Fe.Vector4(c[0],c[1],c[2],c[3])),num:t.length,steps:o,offset:new Fe.Vector2(...s),morph:new Fe.Vector2(...l),angle:i}}function wP(n){let{gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:s,direction:l,colors:c,steps:u,smooth:a}=n;return{...Or(n),gradientType:r,near:e,far:t,isVector:o,isWorldSpace:i,origin:new Fe.Vector3(...s),direction:l?new Fe.Vector3(...l):new Fe.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new Fe.Vector4(d[0],d[1],d[2],d[3]):new Fe.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:a}}function _P(n){let{cnormal:r}=n;return{...Or(n),cnormal:new Fe.Vector3(r[0],r[1],r[2])}}function PP(n,r){return{...Or(n),scale:n.scale,move:n.move,fA:new Fe.Vector2(...n.fA),fB:new Fe.Vector2(...n.fB),size:new Fe.Vector3(...n.size),distortion:new Fe.Vector2(...n.distortion),colorA:vt(n.colorA,r),colorB:vt(n.colorB,r),colorC:vt(n.colorC,r),colorD:vt(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 TP(n){return{...Or(n),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Fe.Vector3(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Fe.Vector3(...n.offset)}}function OP(n,r){return{...Or(n),positioning:n.positioning,colors:n.colors.map(e=>new Fe.Vector4(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Fe.Vector3(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:vt(n.shadowColor,r),offset:new Fe.Vector3(...n.offset)}}function AP(n,r){return{...Or(n),outlineColor:vt(n.outlineColor,r),contourColor:vt(n.contourColor,r),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Fe.Vector3(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function NP(n,r){return{...Or(n),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function CP(n,r){return{...Or(n),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Fe.Vector2(...n.offset),colorA:vt(n.colorA,r),colorB:vt(n.colorB,r),frequency:new Fe.Vector2(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Fe.Vector2(...n.vertical),horizontal:new Fe.Vector2(...n.horizontal),sides:n.sides}}var Co=class extends ct{};var Dy=require("three");var Yd={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Xd={depth:["colors"]};function IP(n,r,e){if(r==="isMask")return!0;let t=Yd[n.type],o=Xd[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 Kd(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,l=r.image(s),c=t;c.image instanceof nr||c.image.deref(),c.image=l}if("video"in i){let s=i.video,l=r.video(s),c=t;c.image instanceof nr||c.image.deref(),c.image=l}if("wrapping"in i){let s=t;s.wrap=i.wrapping}if("repeat"in i||"offset"in i){let s="mat",l=e.uniforms[`f${e.id}_${s}`];"repeat"in i&&(l.repeat=i.repeat),"offset"in i&&(l.offset=i.offset),l.updateMatrix()}return o}function Gy(n,r,e,t){let o=!1;for(let[i,s]of Object.entries(n)){if(!i||s===void 0)continue;if(Zd(i,e,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=t.visible;let l=e.uniforms[`f${e.id}_${i}`];if(!!l&&!(l instanceof No))switch(o=o||IP(e,i,s),l.constructor){case Me:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof Co?l.value=new ct(c.r,c.g,c.b,c.a):l.setRGBA(c);break}case kt:if(typeof s=="string"){let c=r.getColor(s);c&&(l.value=c);break}else{let c=s;l.value instanceof Co?l.value=new ct(c.r,c.g,c.b,c.a):l.value.setRGBA(c.r,c.g,c.b,c.a);break}case Je:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]);break}case _t:{let c=s;l.value.setX(c[0]),l.value.setY(c[1]),l.value.setZ(c[2]);break}case Lt:{Kd(s,r,e);break}case Tr:{l.value=s.map(c=>new Dy.Vector4(...c));break}default:{l.value=s;break}}}return o}var kr=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)Zd(i,this,t)}get type(){return this.data.type}static create(r,e,t,o){if(t.type==="light")return sr.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 Qo(i,t.texture.wrapping),l=new kl(i),c=new Ul(t.texture.repeat,t.texture.offset),u=new Z(t.crop?1:0),a=new we(t.projection??0),d=new we(["x","y","z"].indexOf(t.axis)??0),p=new we(t.side??0),f=new Je(t.size?new Ge.Vector2(t.size[0],t.size[1]):new Ge.Vector2(100,100)),m=new Z(t.blending??0),h=new Z(t.alpha??1),y=new we(t.mode??0),g=new et(t.isMask??!1),v=new Ai(s,l,u,a,d,p,f,m,c,h,y,g),b=new Ne(v.calpha,"f");return new We(r,e,t,{texture:s,textureSize:l,crop:u,projection:a,axis:d,side:p,size:f,blending:m,mat:c,alpha:h,mode:y,isMask:g},v,y,b,g)}else if(t.type==="matcap"){let i=o.image(t.texture.image),s=new Qo(i,t.texture.wrapping),l=new Z(t.alpha??1),c=new we(t.mode??0),u=new et(t.isMask??!1),a=new Mi(s,l,c,u),d=new Ne(a.calpha,"f");return new We(r,e,t,{texture:s,alpha:l,mode:c,isMask:u},a,c,d,u)}else if(t.type==="displace")if(t.displacementType==="noise"){let i=new _t(new Ge.Vector3(...t.offset)),s=new Z(t.scale??10),l=new Z(t.intensity??8),c=new Z(t.movement??1),u=new we(t.noiseType??0),a=new we(t.voronoiStyle??0),d=new Z(t.smoothness??.5),p=new Z(t.seed??0),f=new Z(t.highCut??1),m=new Z(t.lowCut??0),h=new we(t.quality??1),y=new Vi(l,c,i,a,d,p,f,m,h,s,u);return new Xs(r,e,t,{offset:i,scale:s,intensity:l,movement:c,noiseType:u,voronoiStyle:a,smoothness:d,seed:p,highCut:f,lowCut:m,quality:h},y)}else throw new Error;else return LP(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):Gy(o.props,t.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Kd(o.props,t.shared,this):!0;return!1}dispose(){if(MP(this)){let r=this.uniforms[`f${this.id}_texture`];if(!r)return!1;let e=r;e.image instanceof nr||e.image.deref()}}hasValueByKey(r){return this.uniforms[r]!==void 0}hasValue(r){return this.hasValueByKey(`f${this.id}_${r}`)}setValue(r,e){let t=`f${this.id}_${r}`;this.hasValueByKey(t)&&e!==void 0&&(this.uniforms[t].value=e)}getNode(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(r){let e=`f${this.id}_${r}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(r){let t=/f\d+_(.*)/.exec(r);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${r}`)}getNames(){let r=[];for(let e in this.uniforms){let t=this.getName(e);t&&r.push(t)}return r}},We=class extends kr{constructor(e,t,o,i,s,l,c,u){super(e,t,o,i);this.params=i;this.color=s;this.mode=l;this.alpha=c;this.isMask=u}},Xs=class extends kr{constructor(e,t,o,i,s){super(e,t,o,i);this.position=s}},sr=class extends kr{constructor(e,t,o,i,s){super(e,t,o,s);this.node=i}static createLigherLayer(e,t,o,i){let s,l=new Z(o.alpha),c=new we(o.mode),u;if(!o.visible)s=new en,u={};else if(o.category==="lambert"){s=new Us;let a=new Me(i.color(o.emissive)??0),d=new et(o.occlusion??!0);u={emissive:a,occlusion:d},s.emissive=a,s.occlusion=d}else if(o.category==="toon"){s=new Ys;let a=new Z(o.shininess??30),d=new Me(i.color(o.specular)??1118481);u={shininess:a,specular:d},s.shininess=a,s.specular=d}else if(o.category==="physical"){s=new Ws;let a=new Z(o.roughness??.3),d=new Z(o.metalness??0),p=new Z(o.reflectivity??.5),f=new et(o.occlusion??!0);u={roughness:a,metalness:d,reflectivity:p,occlusion:f},s.roughness=a,s.metalness=d,s.reflectivity=p,s.occlusion=f}else{s=new qs;let a=new Z(o.shininess??30),d=new Me(o.specular!==void 0?i.color(o.specular)??1118481:1118481),p=new et(o.occlusion??!0);u={shininess:a,specular:d,occlusion:p},s.shininess=a,s.specular=d,s.occlusion=p}return s.alpha=new Z(1),s.shadingAlpha=l,s.shadingBlend=c,u.alpha=s.shadingAlpha,u.mode=s.shadingBlend,new sr(e,t,o,s,u)}get category(){return this.node.category}};function MP(n){let r=n instanceof kr?n.type:n;return r==="texture"||r==="video"||r==="displace_map"||r==="matcap"}function ir(n){return{alpha:new Z(n.alpha??1),mode:new we(n.mode??0),isMask:new et(n.isMask??!1)}}function EP(n,r,e,t){switch(n.type){case"color":{let o=new Me(t.color??5526619),i=ir(t),s=new Jo(o,i.alpha),l=new Ne(s.calpha,"f");return new We(r,e,n,{color:o,...i},s,i.mode,l,i.isMask)}case"fresnel":{let o=new Me(t.color??16777215),i=new Z(t.bias??.1),s=new Z(t.scale??1),l=new Z(t.intensity??2),c=new Z(t.factor??1),u=ir(t),a=new js(o,i,s,l,c,u.alpha,u.mode,u.isMask),d=new Ne(a.calpha,"f");return new We(r,e,n,{color:o,bias:i,scale:s,intensity:l,factor:c,...u},a,u.mode,d,u.isMask)}case"rainbow":{let o=new Z(t.filmThickness??30),i=new Z(t.movement??0),s=new _t(t.wavelengths??new Ge.Vector3(0,0,0)),l=new Z(t.noiseStrength??0),c=new Z(t.noiseScale??1),u=new _t(t.offset??new Ge.Vector3(0,0,0)),a=ir(t),d=new Di(o,i,s,l,c,u,a.alpha,a.isMask),p=new Ne(d.calpha,"f");return new We(r,e,n,{filmThickness:o,movement:i,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...a},d,a.mode,p,a.isMask)}case"transmission":{let o=new Z(t.thickness??10),i=new Z(t.ior??1.5),s=new Z(t.roughness??.5),l=xe.transmissionSize,c=xe.transmissionRenderTarget,u=xe.transmissionRenderTargetDepth,a=window.innerWidth,d=window.innerHeight,p=a>=d?new Je(d/a,1):new Je(1,a/d),f=ir(t),m=new Ri(o,i,s,l,c,u,p,f.alpha),h=new Ne(m.calpha,"f");return new We(r,e,n,{thickness:o,ior:i,roughness:s,aspectRatio:p,...f},m,f.mode,h,f.isMask)}case"toon":{let o=new we(t.positioning??0),i;t.colors?i=new Tr(t.colors.length,t.colors):(i=new Tr(10,new Ge.Vector4(0,0,0,1)),i.value[1]=new Ge.Vector4(1,1,1,1));let s;t.steps?s=new Pr(t.steps.length,t.steps):(s=new Pr(10,1),s.value[0]=0);let l=new _t(t.source??new Ge.Vector3(0,0,0)),c=new et(t.isWorldSpace??!0),u=new Z(t.noiseStrength??0),a=new Z(t.noiseScale??1),d=new kt(t.shadowColor),p=new _t(t.offset??new Ge.Vector3(0,0,0)),f=ir(t),m=new Gi(o,i,s,l,c,u,a,d,p,f.alpha),h=new Ne(m.calpha,"f");return new We(r,e,n,{positioning:o,colors:i,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:a,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),s=new Z(t.outlineWidth??.1),l=new Z(t.contourWidth??.1),c=new Z(t.outlineThreshold??.1),u=new Z(t.contourThreshold??.1),a=new Z(t.outlineSmoothing??.1),d=new Z(t.contourFrequency??.1),p=new _t(t.contourDirection??new Ge.Vector3(0,1,0)),f=new et(t.positionalLines??!1),m=new et(t.compensation??!0),h=xe.normalRenderTarget,y=xe.normalRenderTargetDepth,g=xe.pixelRatioNode,v=xe.resolution,b=ir(t),w=new Li(o,i,s,l,c,u,a,d,p,f,m,v,h,y,g,b.alpha),S=new Ne(w.calpha,"f");return new We(r,e,n,{outlineColor:o,contourColor:i,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:a,contourFrequency:d,contourDirection:p,positionalLines:f,compensation:m,...b},w,b.mode,S,b.isMask)}case"depth":{let o=new we(t.gradientType??0),i=new et(t.smooth??!1),s=new Z(t.near??50),l=new Z(t.far??200),c=new Z(t.isVector??1),u=new Z(t.isWorldSpace??0),a=new _t(t.origin??new Ge.Vector3),d=new _t(t.direction??new Ge.Vector3),p;t.colors?p=new Tr(t.colors.length,t.colors):(p=new Tr(2,new Ge.Vector4(0,0,0,1)),p.value[1]=new Ge.Vector4(1,1,1,1));let f;t.steps?f=new Pr(t.steps.length,t.steps):(f=new Pr(2,1),f.value[0]=0);let m=ir(t),h=new Ci(o,i,s,l,c,u,a,d,p,f,m.alpha,m.isMask),y=new Ne(h.calpha,"f");return new We(r,e,n,{gradientType:o,smooth:i,near:s,far:l,isVector:c,isWorldSpace:u,origin:a,direction:d,colors:p,steps:f,...m},h,m.mode,y,m.isMask)}case"noise":{let o=new Z(t.scale??1),i=new _t(t.size??new Ge.Vector3(100,100,100)),s=new Z(t.move??1),l=new Je(t.fA??new Ge.Vector2(1.7,9.2)),c=new Je(t.fB??new Ge.Vector2(8.3,2.8)),u=new Je(t.distortion??new Ge.Vector2(1,1)),a=new kt(t.colorA),d=new kt(t.colorB),p=new kt(t.colorC),f=new kt(t.colorD),m=new we(t.noiseType??0),h=new we(t.voronoiStyle??0),y=new Z(t.highCut??1),g=new Z(t.lowCut??0),v=new Z(t.smoothness??.5),b=new Z(t.seed??.5),w=new we(t.quality??1),S=ir(t),P=new Ei(o,i,s,l,c,u,a,d,p,f,S.alpha,m,S.isMask,h,y,g,v,b,w),_=new Ne(P.calpha,"f");return new We(r,e,n,{scale:o,size:i,move:s,fA:l,fB:c,distortion:u,colorA:a,colorB:d,colorC:p,colorD:f,noiseType:m,...S,voronoiStyle:h,highCut:y,lowCut:g,smoothness:v,seed:b,quality:w},P,S.mode,_,S.isMask)}case"normal":{let o=new _t(t.cnormal??new Ge.Vector3(1,1,1)),i=ir(t),s=new Ti(o,i.alpha),l=new Ne(s.calpha,"f");return new We(r,e,n,{cnormal:o,...i},s,i.mode,l,i.isMask)}case"gradient":{let o=new we(t.gradientType??0),i=new et(t.smooth??!1),s;t.colors?s=new Tr(t.colors.length,t.colors):(s=new Tr(10,new Ge.Vector4(0,0,0,1)),s.value[1]=new Ge.Vector4(1,1,1,1));let l;t.steps?l=new Pr(t.steps.length,t.steps):(l=new Pr(10,1),l.value[0]=0);let c=new Je(t.offset??new Ge.Vector2(0,0)),u=new Je(t.morph??new Ge.Vector2(0,0)),a=new Z(t.angle??0),d=ir(t),p=new Ii(o,i,s,l,c,u,a,d.alpha,d.isMask),f=new Ne(p.calpha,"f");return new We(r,e,n,{gradientType:o,smooth:i,colors:s,steps:l,offset:c,morph:u,angle:a,...d},p,d.mode,f,d.isMask)}case"pattern":{let o=new we(t.style??0),i=new we(t.projection??0),s=new we(["x","y","z"].indexOf(t.axis)??0),l=new Z(t.blending??0),c=new Je(t.offset??new Ge.Vector2(0,0)),u=new kt(t.colorA),a=new kt(t.colorB),d=new Je(t.frequency??new Ge.Vector2(10,10)),p=new Z(t.size??.5),f=new Z(t.variation??0),m=new Z(t.smoothness??.5),h=new Z(t.zigzag??0),y=new Z(t.rotation??0),g=new Je(t.vertical??new Ge.Vector2(0,1)),v=new Je(t.horizontal??new Ge.Vector2(0,1)),b=new we(t.sides??6),w=ir(t),S=new Bi(o,i,s,l,c,u,a,d,p,f,m,h,y,g,v,b,w.alpha,w.isMask),P=new Ne(S.calpha,"f");return new We(r,e,n,{style:o,projection:i,axis:s,blending:l,offset:c,colorA:u,colorB:a,frequency:d,size:p,variation:f,smoothness:m,zigzag:h,rotation:y,vertical:g,horizontal:v,sides:b,...w},S,w.mode,P,w.isMask)}default:{let o=new Me(1,0,0,1),i=ir(t),s=new Jo(o,i.alpha),l=new Ne(s.calpha,"f");return new We(r,e,n,{color:o,...i},s,i.mode,l,i.isMask)}}}function LP(n,r,e,t){let o=By(e,t);return EP(e,n,r,o)}function Zd(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 Ry(n,r){let e=0;for(let t of n.layers){if(t.data.type!=="displace"&&t.data.isMask)return!0;if(t.data.type!=="displace"&&"alpha"in t.data&&t.data.type!=="light"&&t.data.type!=="fresnel"&&t.data.type!=="texture"&&t.data.type!=="matcap"&&t.data.type!=="rainbow"&&t.data.type!=="outline"&&t.data.type!=="pattern"){let o=t.data.visible?t.data.alpha:0;if(o===1&&t.data.type==="depth"||t.data.type==="gradient"){for(let i of t.data.colors)if(i[3]<1){o=i[3];break}}else if(o===1&&t.data.type==="noise"){let i=r.color(t.data.colorA).a,s=r.color(t.data.colorB).a,l=r.color(t.data.colorC).a,c=r.color(t.data.colorD).a,u=Math.min(i,Math.min(s,Math.min(l,c)));u<1&&(o=u)}e+=(1-e)*o}}return e<1}var Ht=class extends Vy.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},Xl=class extends Ht{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()}},tn=class extends Ht{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 Xl(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??zt.defaultTwoLayerData("phong").layers;this.layers=o.map(i=>kr.create(this.layerIdGen++,i.id,i.data,t.shared)),this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(),this.transparent=Ry(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 sr),this.lightLayer===void 0&&(this.lightLayer=new sr(0,"",{...Mt.defaultData("light","phong"),visible:!1},new en,{})),this.dispose();for(let e of this.flavors)e&&e.dispose();this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(e,t,o){if(t!==void 0?this.data=t:t=this.data,this.transparent=Ry(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 l=kr.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,l),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 l=this.layers.findIndex(u=>u.uuid===e.id),c=this.layers[l];this.layers.splice(l,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 l=this.layers.find(c=>c.uuid===s);if(l){let c=t.layers.data(s);if(l.updateByOp({...e,path:e.path.slice(2)},c,o)){let a=kr.create(this.layerIdGen++,s,c,i);this.layers.splice(this.layers.findIndex(d=>d.uuid===s),1,a),this.onUpdate()}}}}else this.reset(t,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof We?t.color.mask=void 0:t instanceof sr&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof We&&t.isMask.value&&t.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof sr?i.node.mask=new yt(t.color,t.alpha,yt.MUL):i instanceof We&&(i.isMask.value||(i.color.mask=new yt(t.color,t.alpha,yt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof We),t=this.layers.findIndex(o=>o instanceof sr);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 We){if(s.isMask.value)continue;o=new Pi(o,s.color,s.alpha,s.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 sr);if(this.layers.length>t+1){for(let o=t+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof We){if(i.isMask.value)continue;e=new Pi(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 Xs);if(e.length>0){let t=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(t=new yt(t,e[o].position,yt.ADD),t=new yt(t,new Z(.5).setReadonly(!0),yt.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,l)=>Math.min(Math.max(i,s),l);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=(Yd[t.type]??[]).map(l=>t[l]),i=(Xd[t.type]??[]).map(l=>t[l]?.length??0),s=[...o,...i];s.length?e+=`["${t.type}", "${s.join('","')}"],`:e+=`"${t.type}",`}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 Fl;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 We){let t=e.params.texture;if(t instanceof Qo&&!t.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(Ht.prototype,{properties:{get:function(){return this.fragment.properties}}});var rn=class extends tn{};var ky=dn(zy());var jy=new Map;function Fy(n){if(typeof n=="string")return n;let r=jy.get(n);return r||(r={url:URL.createObjectURL(new Blob([n]))},jy.set(n,r)),r.url}var on=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:Fy(r),format:"wav"},this.sound=new ky.Howl(i),this.sound.on("end",this.onEnd),this.src=r,e!==void 0&&(this.volume=e),t!==void 0&&(this.delay=t),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(r){this._volume=r,this.sound.volume(r)}get loop(){return this._loop}set loop(r){this._loop=r,this.loopsRemaining=r}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(r,e=1e3){r?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},r)):this.sound.fade(this._volume,0,e)}on(r,e,t){this.sound.on(r,e,t)}off(r,e,t){this.sound.off(r,e,t)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(r=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var dt=require("three"),Zl=class{constructor(){this.type="ShapePath";this.color=new dt.Color;this.subPaths=[];this.currentPath=null}moveTo(r,e){return this.currentPath=new dt.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(r,e),this}lineTo(r,e){return this.currentPath?.lineTo(r,e),this}quadraticCurveTo(r,e,t,o){return this.currentPath?.quadraticCurveTo(r,e,t,o),this}bezierCurveTo(r,e,t,o,i,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,v){let b=h.x,w=y.x,S=g.x,P=v.x,_=h.y,x=y.y,C=g.y,T=v.y,N=(P-S)*(_-C)-(T-C)*(b-S),O=(w-b)*(_-C)-(x-_)*(b-S),A=(T-C)*(w-b)-(P-S)*(x-_),R=N/A,k=O/A;if(A===0&&N!==0||R<=0||R>=1||k<0||k>1)return null;if(N===0&&A===0){for(let $=0;$<2;$++)if(i($===0?g:v,h,y),t.loc===e.ORIGIN){let te=$===0?g:v;return{x:te.x,y:te.y,t:t.t}}else if(t.loc===e.BETWEEN){let te=+(b+t.t*(w-b)).toPrecision(10),Y=+(_+t.t*(x-_)).toPrecision(10);return{x:te,y:Y,t:t.t}}return null}else{for(let Y=0;Y<2;Y++)if(i(Y===0?g:v,h,y),t.loc===e.ORIGIN){let W=Y===0?g:v;return{x:W.x,y:W.y,t:t.t}}let $=+(b+R*(w-b)).toPrecision(10),te=+(_+R*(x-_)).toPrecision(10);return{x:$,y:te,t:R}}}function i(h,y,g){let v=g.x-y.x,b=g.y-y.y,w=h.x-y.x,S=h.y-y.y,P=v*S-w*b;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(P<-Number.EPSILON){t.loc=e.LEFT;return}if(P>Number.EPSILON){t.loc=e.RIGHT;return}if(v*w<0||b*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(v*v+b*b)<Math.sqrt(w*w+S*S)){t.loc=e.BEYOND;return}let _;v!==0?_=w/v:_=S/b,t.loc=e.BETWEEN,t.t=_}function s(h,y){let g=[],v=[];for(let b=1;b<h.length;b++){let w=h[b-1],S=h[b];for(let P=1;P<y.length;P++){let _=y[P-1],x=y[P],C=o(w,S,_,x);C!==null&&g.find(T=>T.t<=C.t+Number.EPSILON&&T.t>=C.t-Number.EPSILON)===void 0&&(g.push(C),v.push(new dt.Vector2(C.x,C.y)))}}return v}function l(h,y,g){let v=new dt.Vector2;y.getCenter(v);let b=[];return g.forEach(w=>{w.boundingBox.containsPoint(v)&&s(h,w.points).forEach(P=>{b.push({identifier:w.identifier,isCW:w.isCW,point:P})})}),b.sort((w,S)=>w.point.x-S.point.x),b}function c(h,y,g,v,b){(b==null||b==="")&&(b="nonzero");let w=new dt.Vector2;h.boundingBox.getCenter(w);let S=[new dt.Vector2(g,w.y),new dt.Vector2(v,w.y)],P=l(S,h.boundingBox,y);P.sort((O,A)=>O.point.x-A.point.x);let _=[],x=[];P.forEach(O=>{O.identifier===h.identifier?_.push(O):x.push(O)});let C=_[0].point.x,T=[],N=0;for(;N<x.length&&x[N].point.x<C;)T.length>0&&T[T.length-1]===x[N].identifier?T.pop():T.push(x[N].identifier),N++;if(T.push(h.identifier),b==="evenodd"){let O=T.length%2===0,A=T[T.length-2];return{identifier:h.identifier,isHole:O,for:A}}else if(b==="nonzero"){let O=!0,A=null,R=null;for(let k=0;k<T.length;k++){let $=T[k];y[$]&&(O?(R=y[$].isCW,O=!1,A=$):R!==y[$].isCW&&(R=y[$].isCW,O=!0))}return{identifier:h.identifier,isHole:O,for:A}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let u=0,a=999999999,d=-999999999,p=[];this.subPaths.forEach(h=>{let y=h.getPoints(),g=-999999999,v=999999999,b=-999999999,w=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<v&&(v=P.y),P.x>b&&(b=P.x),P.x<w&&(w=P.x)}d<=b&&(d=b+1),a>=w&&(a=w-1),y.length&&p.push({curves:h.curves,points:y,isCW:dt.ShapeUtils.isClockWise(y),identifier:u++,boundingBox:new dt.Box2(new dt.Vector2(w,v),new dt.Vector2(b,g))})});let f=p.map(h=>c(h,p,a,d,this.userData?.style.fillRule)),m=[];return p.forEach(h=>{let y=f[h.identifier];if(y&&!y.isHole){let g=new dt.Shape;g.curves=h.curves,f.filter(b=>b?.isHole&&b.for===h.identifier).forEach(b=>{if(b){let w=p[b.identifier],S=new dt.Path;S.curves=w.curves,g.holes.push(S)}}),m.push(g)}}),m}};var Hy,Qd=new Promise(n=>{Hy=n}),Uy=!1;async function qy(){if(Uy)return;let n=await import("./opentype.js");Hy(n),Uy=!0}var Ks=class{async load(r,e,t=()=>{}){let{load:o}=await Qd;o(r,(i,s)=>{i||!s?t(i??"Something went wrong"):e(s)})}async parse(r){let{parse:e,Bidi:t}=await Qd;try{let o=e(r),i=new t,s=l=>o.charToGlyphIndex(l.char);return i.registerModifier("glyphIndex",null,s),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function BP(n){return await(await fetch(n)).arrayBuffer()}var DP=new Ks;async function Jd(n){let r,e,t=!1;if(n.url?(r=await BP(n.url),e=n.url,t=n.url.startsWith("/")):n.data&&(r=n.data.buffer),r){let o=await DP.parse(r);if(o)return{font:o.font,url:e,intercepted:t,arr:r,bidi:o.bidi}}}var Fi=require("three");function GP(n,r){return r.state.glyphIndex===n||r.state.fina===n||r.state.medi===n||r.state.init===n}var Ql=class{constructor(r){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=r.isUserFont??!1,this._loadingPromise=Jd(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=Jd(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=[],l=0,c=t.length===i.length;for(let u=0;u<t.length;u++){let a=t[u].index,d=String.fromCharCode(t[u].unicode),p=i[l];if(GP(a,p)||c)s.push({char:d,index:a,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),l++;else{let f=p.char,m="",h=[p.state.glyphIndex],y=[],g=!1;for(;!g;)l++,m=e.charAt(l),f+=m,h.push(r.charToGlyphIndex(m)),y=r.stringToGlyphs(f),y.length===1&&y[0].index===a&&(g=!0),l>e.length&&(g=!0);s.push({char:d,index:a,replacements:h,replacementChars:Array.from(f)}),l++}}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(v=>this.getTextWidth(v,e)),l=e.width,c=this.getCharWidth(`
1993
+ `,e),u=e.horizontalAlign===1?c:0,a=this.computeSpaceWidthForLine(r,0,e),d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,r[0],c),p=this.getLineInitialOffsetY(i,r.length,e.height,o,e.verticalAlign),f=[],m=r.map(v=>[]),h=r.map(v=>[]),y;for(let v=0;v<r.length;v++){let b=r[v],w={features:{liga:!0}},S=[];try{S=t.stringToGlyphs(b,w)}catch(_){console.warn(_)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,b,c);let P=[];try{P=this.reverseLigaturesTable(t,b,S)}catch(_){console.warn(_)}a=this.computeSpaceWidthForLine(r,v,e);for(let _=0;_<S.length;_++){let x=S[_],C=x.index===0?`
1994
+ `:x.unicode?String.fromCharCode(x.unicode):void 0,T=P[_],N=0,O=0;_===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(O=-x.leftSideBearing*o),y&&(N=t.getKerningValue(x,y)*o),d+=O+N;let A=0;if(C===`
1995
+ `)A=u;else if(C===" ")A=a;else{let R=this.createPath(x,o,d,p,e);R&&(A=R.offsetX-(N+O),f.push(R.path))}if(T.replacements.length===1)h[v].push([d,p]),m[v].push(A);else{let R=T.replacements.map(Y=>(t.glyphs.get(Y).advanceWidth??0)*o),k=R.reduce((Y,W)=>Y+=W,0),$=R.map(Y=>Y/k),te=d;for(let Y=0;Y<$.length;Y++){let W=A*$[Y];h[v].push([te,p]),m[v].push(W),te+=W}}d+=A,y=x}p-=i}let g=[];for(let v=0,b=f.length;v<b;v++)g.push(...f[v].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(`
1996
+ `)>=0&&(r-=i),t===3?e*.5-r*.5:t===2?e-r:0}getLineInitialOffsetY(r,e,t,o,i){let s=e*r,l=Math.abs(this.ascender-this.descender)*o,c=r-l,u=-this.ascender*o-c/2;return i===3?-(t-s-u):i===2?-(t*.5-s*.5-u):u}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 l=new Zl,c=(r.advanceWidth??1)*e;if(r)for(let u of s.commands){let a=l.currentPath?.currentPoint;if(!(a&&u.type!=="Z"&&a.x===u.x&&-a.y===u.y))switch(u.type){case"M":l.moveTo(u.x,-u.y);break;case"L":l.lineTo(u.x,-u.y);break;case"Q":l.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":l.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return l.subPaths.forEach(u=>{let a=RP(u.curves);a!==void 0&&u.currentPoint.distanceTo(a)>0&&u.lineTo(a.x,a.y)}),{offsetX:c+i.fontSize*i.letterSpacing,path:l}}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 l=t.width,c=this.getTextWidth(i,t);return(l-(c-s*o))/s}}return o}countSpaces(r){return(r.match(/ /g)||[]).length}};function RP(n){if(n.length){let r=n[0];if(r instanceof Fi.LineCurve)return r.v1;if(r instanceof Fi.CubicBezierCurve||r instanceof Fi.QuadraticBezierCurve)return r.v0}}var eu=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()}},Zs=class extends eu{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,t){let o=Xo(e,t,this.flatShading);return o.computeBoundingSphere(),o}};var Wy={find(n){},markNeedsUpdateRendererDirty:function(){},markGeometryCacheDirty:function(){},addPendingExpandCloner:function(n){},addPendingUpdateCloner(n){},addPendingCommand(n){}};var tu=class extends $l{constructor(e){super();this.shared=e}create(e){return new ji(e,this.shared)}},nn=class{constructor(r,e={}){this.geometryCache=new Zs(!0);this.geometryCache2=new Zs(!1);this.imageHolderCache=new tu(this);this.thisContext={scene:Wy,shared:this};this.deletedMaterial=new rn(zt.defaultTwoLayerData("phong"),this.thisContext);this.deletedImage=new nr(Xn.emptyImage,this);this.deletedVideo=new nr(kn.defaultVideo,this);this.materials={};this.images={};this.videos={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];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 rn(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);this.penumbraSize=r.penumbraSize}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):new tn(r,this.thisContext)}getMaterials(){return this.materials}addImage(r,e){return this.images[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[r].updateSrc(e.data),!0):(this.images[r]=new nr(e,this),!1)}deleteImage(r){let e=this.images[r];e&&(e.dispose(),delete this.images[r])}getDefaultImage(){return this.images.image_0}getImage(r){return this.images[r]??this.deletedImage}image(r){return typeof r=="string"?this.getImage(r):this.imageHolderCache.load(r)}addVideo(r,e){return this.videos[r]?(this.videos[r].updateSrc(e.data),!0):(this.videos[r]=new nr(e,this),!1)}deleteVideo(r){let e=this.videos[r];e&&(e.dispose(),delete this.videos[r])}getVideo(r){return this.videos[r]??this.deletedVideo}video(r){return typeof r=="string"?this.getVideo(r):this.imageHolderCache.load(r)}addColor(r,e){return this.colors[r]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[r].setRGBA(e.r,e.g,e.b,e.a):this.colors[r].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[r]=new Co(e.r,e.g,e.b,e.a):this.colors[r]=new Co(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 ct(0,0,0,0))}else return"a"in r?new ct(r.r,r.g,r.b,r.a):new ct(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 on)return e;{let t=new on({src:e});return this.audios[r]=t,t}}deleteAudio(r){let e=this.audios[r];e&&(e instanceof on&&e.dispose(),delete this.audios[r])}addFont(r,e){this.fonts[r]=new Ql(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 on&&e.dispose()}),this.audios={},this.geometryCache.dispose(),this.geometryCache2.dispose()}},$y=new nn(ml.emptyData());var ar=class extends wt{updateByPatchedOp(e,t,o){if(super.updateByPatchedOp(e,t,o),Jf(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[i,s]of Object.entries(e.props)){let l=o.shared.material(s);this.material[Number(i)]=l}else if(fr(e.path,["material"])&&this.material instanceof Ht)"material"in t&&typeof t.material!="string"&&this.material.updateByOp(St.drop(e,1),t.material,o);else if(fr(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(St.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&&ha(this.material).forEach(e=>{e instanceof Ht&&(e instanceof rn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var Yy=require("three");var Tt=class extends ar{constructor(e,t,o){super(e,t);this.data=t;this.localGeometry=void 0}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Yy.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof nn){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 hs.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return hs.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),fr(e.path,["geometry"])&&this.updateByPatchedOpGeometry(St.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 a={...this.data.geometry,...i};this.localGeometry=Xo(a,t,this.data.flatShading)}let s,l,c;i.scaleBaked?[s,l,c]=i.scaleBaked:{width:s,height:l,depth:c}=i;let u=this.localGeometry.userData;u.sxPrev!==void 0&&Bs(this.localGeometry.attributes,s/u.sxPrev,l/u.syPrev,c/u.szPrev),u.sxPrev=s,u.syPrev=l,u.szPrev=c}else{let i={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Xo(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&&as(["scaleBaked"],Object.keys(e.props))&&this.geometryCreateDeleyed instanceof ot&&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)}};function VP(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 l=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=new er.Vector3(o[s],o[s+1],o[s+2]);r.has(l)?r.get(l)?.normals.push(c):r.set(l,{normals:[c],result:new er.Vector3})}r.forEach((s,l)=>{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 l=`${t[s]}_${t[s+1]}_${t[s+2]}`,c=r.get(l)?.result;c&&(i[s]=c.x,i[s+1]=c.y,i[s+2]=c.z)}n.geometry.setAttribute("extrudeNormal",new er.Float32BufferAttribute(i,3))}function zP(n){if(n.geometry.attributes.extrudeNormals||!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=new er.Vector3;for(let i=0;i<e.length;i+=3)o.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=o.x,t[i+1]=o.y,t[i+2]=o.z;n.geometry.setAttribute("extrudeNormal",new er.Float32BufferAttribute(t,3))}function ki(n){if(Array.isArray(n.material)){for(let r of n.material)if(r.getLayersOfType("outline").length===0)return}else if(!(n.material instanceof Ht)||n.material.getLayersOfType("outline").length===0)return;n instanceof Tt&&n.is2DAndNoDepth?zP(n):VP(n)}function Ui(n){if(!n.geometry.attributes.position)return;let e=n.geometry.attributes.position.array,t=new Float32Array(e.length),o=parseInt(n.uuid.replace(/\D/g,"")),i=[er.MathUtils.seededRandom(o),er.MathUtils.seededRandom(o+1e4),er.MathUtils.seededRandom(o+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];n.geometry.setAttribute("randomColor",new er.BufferAttribute(t,3))}var jP;mi.then(n=>{jP=n});var Ur=new ao.Box3,Qs=new ao.Vector3;function Xy(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="SubdivGeometry"&&(r=!0)}),r}var sn=class extends Tt{constructor(e,t,o){super(e,t,o);this.data=t;this.hiddenMatrixOld=new ao.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,t){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),t.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let t=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:i,subdivPointer:s}=ot.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,ki(this),Ui(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){ot.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&ot.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=ot.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=ot.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,wt.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 ao.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let t=e.attributes.position,o=e.boundingSphere.center;Ur.setFromBufferAttribute(t),Ur.getCenter(o),e.boundingSphere.radius=o.distanceTo(Ur.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ur.getSize(Qs),this.hasNonUniformScale&&Qs.divide(this.scale);let i={width:Qs.x,height:Qs.y,depth:Qs.z};return this.geometry.userData.parameters=i,i}updateBoundingSphere(e){let t=this.originalGeometry;Ur.min.set(e[0],e[2],e[4]),Ur.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Ur.min.applyMatrix4(this.shearScaleInv),Ur.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new ao.Sphere);let o=t.boundingSphere.center;Ur.getCenter(o),t.boundingSphere.radius=o.distanceTo(Ur.max)}freeSubdivPointer(){this.subdivPointer&&(ot.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,t,o){super.updateByPatchedOpGeometry(e,t,o),this.localGeometry&&this.createGeometryByControls(t)}};var Hr=require("three"),Ky=-1,FP=1,Zy={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Qy={polygon_center:0,edge:1,vertex:2},Js=(n,r)=>(e,t)=>!r||e===0||n===0?0:n*t/100,he=(n,r)=>{let e=Math.abs(r),t=e*-1;return(n-Ky)*(e-t)/(FP-Ky)+t};function Jy(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 kP=new Hr.Vector3,Jl=new Hr.Vector3,UP=new Hr.Vector3,HP=new Hr.Vector3;function Hi(n,r){let e=UP.fromArray(n),t=HP.fromArray(r);Jl.copy(t).sub(e);let o=Jl.length();return Jl.normalize().multiplyScalar(o*.5),kP.copy(e).add(Jl).toArray()}var lr=new Hr.Triangle,ec=new Hr.Vector3,tc=new Hr.Vector3,an=new Hr.Vector3;function eg(n){let r=[];for(let e=0;e<=n.index.count;e++)if(ec.fromArray(n.index.array,e*3),lr.setFromAttributeAndIndices(n.attributes.position,ec.x,ec.y,ec.z),lr.getNormal(tc),lr.getMidpoint(an),!(isNaN(an.x)||isNaN(an.y)||isNaN(an.z))){let{a:t,b:o,c:i}=lr,s=t.toArray(),l=o.toArray(),c=i.toArray(),u=t.distanceTo(o),a=o.distanceTo(i),d=i.distanceTo(t),p=Hi(s,l),f=Hi(l,c),m=Hi(c,s),h=[u,a,d],y=Math.max(...h),g=h.filter(w=>Math.round(w)===Math.round(y)).length>1,v=[],b=lr.getMidpoint(an).toArray();y===u&&!g&&(v=[f,m,m],b=p),y===a&&!g&&(v=[p,m,m],b=f),y===d&&!g&&(v=[p,f,f],b=m),g&&(v=[p,f,m]),r.push({vertices:[s,l,c],faceCenters:v,midpoint:b,norm:lr.getNormal(tc).toArray()})}return r}function tg(n){let r=[],{position:e}=n.attributes;for(let t=0;t<e.count;t++){lr.setFromAttributeAndIndices(e,t*3,t*3+1,t*3+2),lr.getNormal(tc),lr.getMidpoint(an);let o=lr.a.toArray(),i=lr.b.toArray(),s=lr.c.toArray();r.push({vertices:[o,i,s],faceCenters:[Hi(o,i),Hi(i,s),Hi(s,o)],midpoint:an.toArray(),norm:tc.toArray()})}return r}var qP=4,WP=.5,ru=n=>.5*(1-Math.cos(n*Math.PI)),ou=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),l=r-o,c=e-i,u=t-s,a,d,p=0,f=.5,m,h,y;for(let g=0;g<qP;g++){let v=o+(i<<4)+(s<<8);a=ru(l),d=ru(c),m=this.perlin[v&4095],m+=a*(this.perlin[v+1&4095]-m),h=this.perlin[v+16&4095],h+=a*(this.perlin[v+16+1&4095]-h),m+=d*(h-m),v+=256,h=this.perlin[v&4095],h+=a*(this.perlin[v+1&4095]-h),y=this.perlin[v+16&4095],y+=a*(this.perlin[v+16+1&4095]-y),h+=d*(y-h),m+=ru(u)*(h-m),p+=m*f,f*=WP,o<<=1,l*=2,i<<=1,c*=2,s<<=1,u*=2,l>=1&&(o++,l--),c>=1&&(i++,c--),u>=1&&(s++,u--)}return p}noiseSeed(r){let e=(()=>{let s,l;return{setSeed(c){l=s=(c??Math.random()*4294967296)>>>0},getSeed(){return s},rand(){return l=(1664525*l+1013904223)%4294967296,l/4294967296}}})();e.setSeed(r),this.perlin=new Array(4095+1);for(let t=0;t<4095+1;t++)this.perlin[t]=e.rand()}},rg=ou;var Wi=require("three");var og=new Wi.Vector3,ng=new Wi.Matrix4,ig=new Wi.Ray;function sg(n){let r=!1;return n.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&t.geometry.type==="TextGeometry"&&(r=!0)}),r}var qi=class extends Tt{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)&&(ng.copy(o).invert(),ig.copy(e.ray).applyMatrix4(ng),ig.intersectBox(this.singleBBox,og))){let i=og.applyMatrix4(o),s=e.ray.origin.distanceTo(i);t.push({distance:s,point:i.clone(),object:this})}}};var Bt=1e-4,qr,cg,dg,ug,ag=new Ee.Vector3,lg=new Ee.Vector3;mi.then(n=>{qr=n,cg=[qr.get_face_center,qr.get_edge_midpoint,qr.get_vertex_position],dg=[qr.get_face_normal,qr.get_edge_normal,qr.get_vertex_normal],ug=[qr.face_count,qr.edge_count,qr.vertex_count]});var $P=new Ee.Matrix4,YP=new Ee.Matrix4,Io=new Ee.Vector3,ln=new Ee.Vector3,ea=new Ee.Vector3,nu=new Ee.Vector3,XP=new Ee.Vector3,KP=new Ee.Vector3;var lo=new rg,Yi=class extends Qn(Ee.Object3D){constructor(e,t){super();this.parameters=t;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let t of this.children)t instanceof no&&t.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(t=>{t instanceof no&&t.object===e&&(t.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters);break;case"toObject":this._updateToObject(this.parameters)}for(let e of this.children)e.updateMatrix(),e.hasNonUniformScale&&(e.updateMatrixWorld(),e.updateMatrixWorldSVD())}_updateCount(e){let t;if(e!==void 0?t=e:t=this.parameters.type==="grid"?Math.round(this.parameters.grid.count[0])*Math.round(this.parameters.grid.count[1])*Math.round(this.parameters.grid.count[2]):this.parameters.count,this.parameters.type==="toObject"&&!this.parameters.toObject.object&&(t=0),this.parameters.type==="toObject"&&this.objectForSample){for(let i=0,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 l=new no(this.object);l.expand(),this.add(l)}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 no(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*Ee.MathUtils.DEG2RAD,i=t.end*Ee.MathUtils.DEG2RAD,s=o-i,l=new Ee.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),c;switch(t.axis){case"z":c=new Ee.Vector3(0,0,1);break;case"y":c=new Ee.Vector3(0,1,0);break;default:case"x":c=new Ee.Vector3(1,0,0);break}let u=e.randomnessObject??Dr.defaultData([1,1,1]).randomnessObject,a=u.noiseType==="perlin";lo.noiseSeed(u.seed);let d=yl((0,$i.default)(u.seed)),p=Js(u.strength,this.parameters.randomness);for(let[f,m]of this.children.entries()){let h=f*(u.freqScale/10)+u.movement,y=a?lo.noise(h):d(h,h);m.scale.x=t.scale[0]+p(f,he(y,u.scale[0]))||Bt,m.scale.y=t.scale[1]+p(f,he(y,u.scale[1]))||Bt,m.scale.z=t.scale[2]+p(f,he(y,u.scale[2]))||Bt,m.position.setScalar(0);let g=s/e.count*f-o;switch(t.axis){case"x":m.rotation.set(0,g,0);break;case"y":m.rotation.set(0,0,g);break;case"z":m.rotation.set(g,0,0);break}m.translateOnAxis(c,t.radius),m.position.x+=t.position[0]+p(f,he(y,u.position[0])),m.position.y+=t.position[1]+p(f,he(y,u.position[1])),m.position.z+=t.position[2]+p(f,he(y,u.position[2]));let v=p(f,he(y,u.rotation[0])),b=p(f,he(y,u.rotation[1])),w=p(f,he(y,u.rotation[2]));t.alignment===!0?(m.rotation.x+=l.x+v,m.rotation.y+=l.y+b,m.rotation.z+=l.z+w):m.rotation.set(l.x+v,l.y+b,l.z+w)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,o=new Ee.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Dr.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";lo.noiseSeed(i.seed);let l=yl((0,$i.default)(i.seed)),c=Js(i.strength,this.parameters.randomness);for(let[u,a]of this.children.entries()){let d=u*(i.freqScale/10)+i.movement,p=s?lo.noise(d):l(d,d),f=c(u,he(p,i.rotation[0])),m=c(u,he(p,i.rotation[1])),h=c(u,he(p,i.rotation[2]));a.scale.x=1+(t.scale[0]-1)*u+c(u,he(p,i.scale[0]))||Bt,a.scale.y=1+(t.scale[1]-1)*u+c(u,he(p,i.scale[1]))||Bt,a.scale.z=1+(t.scale[2]-1)*u+c(u,he(p,i.scale[2]))||Bt,a.rotation.x=o.x*u+f,a.rotation.y=o.y*u+m,a.rotation.z=o.z*u+h,a.position.x=t.position[0]*u+c(u,he(p,i.position[0])),a.position.y=t.position[1]*u+c(u,he(p,i.position[1])),a.position.z=t.position[2]*u+c(u,he(p,i.position[2]))}}_updateGrid(e){let t=0,o=e.grid,i=e.randomnessObject??Dr.defaultData([1,1,1]).randomnessObject,s=Js(i.strength,this.parameters.randomness),l=i.noiseType==="perlin";lo.noiseSeed(i.seed);let c=Xm((0,$i.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},a=new Ee.Vector3(o.size[0]*(o.count[0]-u.x)*.5,o.size[1]*(o.count[1]-u.y)*.5,o.size[2]*(o.count[2]-u.z)*.5);for(let d=0;d<o.count[0];d++)for(let p=0;p<o.count[1];p++)for(let f=0;f<o.count[2];f++){let m=[(d+1)*(i.freqScale/10)+i.movement,(p+1)*(i.freqScale/10)+i.movement,(f+1)*(i.freqScale/10)+i.movement],h=l?lo.noise(...m):c(...m),y=this.children[t++];y.scale.x=1+s(t,he(h,i.scale[0]))||Bt,y.scale.y=1+s(t,he(h,i.scale[1]))||Bt,y.scale.z=1+s(t,he(h,i.scale[2]))||Bt;let g=s(t,he(h,i.rotation[0])),v=s(t,he(h,i.rotation[1])),b=s(t,he(h,i.rotation[2]));y.rotation.set(g,v,b),y.position.x=o.size[0]*d-a.x+s(t,he(h,i.position[0])),y.position.y=o.size[1]*p-a.y+s(t,he(h,i.position[1])),y.position.z=o.size[2]*f-a.z+s(t,he(h,i.position[2]))}}else for(let u=0;u<o.count[0];u++)for(let a=0;a<o.count[1];a++)for(let d=0;d<o.count[2];d++){let p=[(u+1)*(i.freqScale/10)+i.movement,(a+1)*(i.freqScale/10)+i.movement,(d+1)*(i.freqScale/10)+i.movement],f=l?lo.noise(...p):c(...p),m=this.children[t++];m.scale.x=1+s(t,he(f,i.scale[0]))||Bt,m.scale.y=1+s(t,he(f,i.scale[1]))||Bt,m.scale.z=1+s(t,he(f,i.scale[2]))||Bt;let h=s(t,he(f,i.rotation[0])),y=s(t,he(f,i.rotation[1])),g=s(t,he(f,i.rotation[2]));m.rotation.set(h,y,g),m.position.x=o.size[0]*u+s(t,he(f,i.position[0])),m.position.y=-o.size[1]*a+s(t,he(f,i.position[1])),m.position.z=-o.size[2]*d+s(t,he(f,i.position[2]))}}_updateToObject(e){if(e.type!=="toObject")throw new Error;let{toObject:t}=e,o=new Ee.Euler(t.rotation[0],t.rotation[1],t.rotation[2]),i=e.randomnessObject??Dr.defaultData([1,1,1]).randomnessObject,s=i.noiseType==="perlin";lo.noiseSeed(i.seed);let l=yl((0,$i.default)(i.seed)),c=Js(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 qi)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(),a=[],d=g=>{let v=g.length,b=g.map(P=>P[0]).reduce((P,_)=>P+_,0),w=g.map(P=>P[1]).reduce((P,_)=>P+_,0),S=g.map(P=>P[2]).reduce((P,_)=>P+_,0);return[b/v,w/v,S/v]},p=g=>Math.round(g*1e6)/1e6;u.forEach(g=>{let v=u.filter(b=>p(g.pos[0])===p(b.pos[0])&&p(g.pos[1])===p(b.pos[1])&&p(g.pos[2])===p(b.pos[2]));v.length>1?a.push({pos:g.pos,norm:d(v.map(b=>b.norm))}):a.push(g)});let f=Jy(a);if(u.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=Zy[t.axis],y=this.children;m.setRandomGenerator((0,$i.default)(this.object.uuid+t.seed));for(let[g,v]of y.entries()){let b=g*(i.freqScale/10)+i.movement,w=s?lo.noise(b):l(b,b),S=c(g,he(w,i.rotation[0])),P=c(g,he(w,i.rotation[1])),_=c(g,he(w,i.rotation[2]));t.spreadType==="random"?m.sample(ea,nu):(f.length&&(ea.fromArray(f[g].pos),nu.fromArray(f[g].norm)),this.objectForSample instanceof sn&&ea.applyMatrix4($P.copy(this.objectForSample.matrixWorld).invert())),ea.applyMatrix4(this.object.hiddenMatrix.clone().invert()),v.position.copy(ea),Io.fromArray(h);let x=t.align==="normal"?nu:this.object.getWorldDirection(KP),C=ln.fromArray(t.position);ln.x+=ln.x+c(g,he(w,i.position[0])),ln.y+=ln.y+c(g,he(w,i.position[1])),ln.z+=ln.z+c(g,he(w,i.position[2]));let T=Math.acos(x.dot(Io)),N=XP.crossVectors(Io,x).normalize(),O=YP.makeRotationAxis(N,T),A=x.clone().cross(this.object.up).normalize(),R=A.clone().cross(x).normalize(),k=new Ee.Matrix4().makeBasis(A,x,R),$=new Ee.Vector3(Io.y,Io.z,Io.x).normalize(),te=$.clone().cross(Io).normalize(),Y=new Ee.Matrix4().makeBasis($,Io,te).invert(),W=new Ee.Matrix4().multiplyMatrices(k,Y);v.rotation.setFromRotationMatrix(W),C.applyMatrix4(O),v.position.add(C),v.rotation.x=v.rotation.x+o.x+S,v.rotation.y=v.rotation.y+o.y+P,v.rotation.z=v.rotation.z+o.z+_,v.scale.setScalar(1),v.scale.x=v.scale.x+t.scale[0]+c(g,he(w,i.scale[0]))||Bt,v.scale.y=v.scale.y+t.scale[1]+c(g,he(w,i.scale[1]))||Bt,v.scale.z=v.scale.z+t.scale[2]+c(g,he(w,i.scale[2]))||Bt,v.scale.multiply(this.object.scale),v.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];if(this.objectForSample instanceof sn){let t=this.objectForSample,o=Qy[e],i=ug[o],s=cg[o],l=dg[o],c=[],u=i(t.subdivPointerNew);for(let a=0;a<=u-1;a++){let d=s(t.subdivPointerNew,a),p=l(t.subdivPointerNew,a);ag.fromArray(d).applyMatrix4(t.matrixWorld),lg.fromArray(p),c.push({pos:ag.toArray(),norm:lg.toArray()})}return c}else return(this.objectForSample.geometry.index?eg(this.objectForSample.geometry):tg(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=to(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 wt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new Ee.Matrix4,this.hiddenMatrix=new Ee.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update()}get pendingMediaLoad(){return this._pendingMediaLoad}};var pr=require("three");var ke=require("three");var Ot=require("three");var pg=require("three"),Wr=n=>{var r;return r=class extends n{},r.geometryHelper=new pg.BoxGeometry(30,30,30),r};var Nt=require("three"),rc=new Nt.Ray,iu=new Nt.Sphere,fg=new Nt.Matrix4,$r=(n,r,e,t,o=!1)=>{let i=r,s=n.matrixWorld;if(i.boundingSphere===null&&i.computeBoundingSphere(),iu.copy(i.boundingSphere),iu.applyMatrix4(s),e.ray.intersectsSphere(iu)===!1||(fg.copy(s).invert(),rc.copy(e.ray).applyMatrix4(fg),i.boundingBox!==null&&rc.intersectsBox(i.boundingBox)===!1))return;let l,c,u,a,d=i.index,p=i.attributes.position,f=i.drawRange,m,h;if(o===!1){let g=Math.max(0,f.start),v=Math.min(d.count,f.start+f.count);for(m=g,h=v;m<h;m+=3)if(c=d.getX(m),u=d.getX(m+1),a=d.getX(m+2),l=y(n,e,rc,p,c,u,a),l){l.faceIndex=Math.floor(m/3),t.push(l);return}}else{let v=i.attributes.position,b=new Nt.Vector3,w=new Nt.Vector3,S=new Nt.Vector3,P=new Nt.Vector3,_=2,C=1/((n.scale.x+n.scale.y+n.scale.z)/3),T=C*C,N=Math.max(0,f.start),O=Math.min(v.count,f.start+f.count);for(let A=N,R=O-1;A<R;A+=_){if(b.fromBufferAttribute(v,A),w.fromBufferAttribute(v,A+1),rc.distanceSqToSegment(b,w,P,S)>T)continue;P.applyMatrix4(n.matrixWorld);let $=e.ray.origin.distanceTo(P);$<e.near||$>e.far||t.push({distance:$,point:S.clone().applyMatrix4(n.matrixWorld),object:n})}}function y(g,v,b,w,S,P,_){let x=new Nt.Vector3,C=new Nt.Vector3,T=new Nt.Vector3,N=new Nt.Vector3,O=new Nt.Vector3;if(x.fromBufferAttribute(w,S),C.fromBufferAttribute(w,P),T.fromBufferAttribute(w,_),b.intersectTriangle(x,C,T,!1,N)===null)return null;O.copy(N),O.applyMatrix4(g.matrixWorld);let R=v.ray.origin.distanceTo(O);return R<v.near||R>v.far?null:{faceIndex:1,distance:R,point:O.clone(),object:g}}};var oc=new Ot.Vector3,cr=new Ot.Camera,su=class extends Ot.LineSegments{constructor(e){let t=new Ot.BufferGeometry,o=new Ot.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],l={},c=new Ot.Color(15711266),u=new Ot.Color(15711266),a=new Ot.Color(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",a),d("u2","u3",a),d("u3","u1",a);function d(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),l[f]===void 0&&(l[f]=[]),l[f].push(i.length/3-1)}t.setAttribute("position",new Ot.Float32BufferAttribute(i,3)),t.setAttribute("color",new Ot.Float32BufferAttribute(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=l,this.update()}update(){let e=this.geometry,t=this.pointMap,o=!0;cr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let i=1,s=1,l=o?.8:1e-4;Ar("n1",t,e,cr,-i,-s,l),Ar("n2",t,e,cr,i,-s,l),Ar("n3",t,e,cr,-i,s,l),Ar("n4",t,e,cr,i,s,l);let c=l;Ar("f1",t,e,cr,-i,-s,c),Ar("f2",t,e,cr,i,-s,c),Ar("f3",t,e,cr,-i,s,c),Ar("f4",t,e,cr,i,s,c);let u=c,a=.5;Ar("u1",t,e,cr,i*.7*a,s*1.1,u),Ar("u2",t,e,cr,-i*.7*a,s*1.1,u),Ar("u3",t,e,cr,0,s*(1.1+.9*a),u),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ar(n,r,e,t,o,i,s){oc.set(o,i,s).unproject(t);let l=r[n];if(l!==void 0){let c=e.getAttribute("position");for(let u=0,a=l.length;u<a;u++)c.setXYZ(l[u],oc.x,oc.y,oc.z)}}var nc=class extends Wr(su){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){$r(this.object,this.geometry,e,t,!0)}};var ta=require("three");var ic;(r=>r.is=e=>"objectHelper"in e)(ic||(ic={}));var Mo=(n,r)=>class extends bl(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 ta.Box3Helper&&(i.visible=!0)}}updateEntityBoxSize(o,i){this.objectHelper.visible&&this.geometryHelper instanceof ta.BoxGeometry?(o.setScalar(0),i.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,i)}hideGizmos(){for(let o in this.gizmos){let i=this.gizmos[o];i instanceof ta.Box3Helper&&(i.visible=!1)}}};var au=790,Xi=new ke.Vector3,lu=new ke.Vector3,cu=new ke.Quaternion,du=new ke.Vector3,ra=new ke.Vector3,uu=new ke.Vector3,Yr=class extends Mo(ke.Camera,nc){constructor(e="",t={...Wn.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Fo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,t),this.previousProjectionMatrix=new ke.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,i=this.height;if(t.orthographic.autoZoom){let s=t.orthographic.autoZoomFrustumSize??au,l=o/i,c=o>i?l:1,u=o>i?1:l;this.orthoCamera=new ke.OrthographicCamera(-s*.5*c,s*.5*c,s*.5*(1/u),-s*.5*(1/u),-5e4,1e4)}else this.orthoCamera=new ke.OrthographicCamera(o*-.5,o*.5,i*.5,i*-.5,-5e4,1e4);this.perspCamera=new ke.PerspectiveCamera(45,o/i,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,t,o){typeof e=="number"&&(e=new ke.Vector3(e,t,o)),super.lookAt(e),this.getWorldPosition(Xi),this.targetOffset=Xi.distanceTo(e)}getTarget(e=new ke.Vector3){return this.getWorldDirection(lu),this.getWorldPosition(Xi),lu.multiplyScalar(this.targetOffset),e.copy(Xi).add(lu),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Xi),Xi.distanceTo(e)}updateUp(){this.getWorldQuaternion(cu),du.set(0,0,1).applyQuaternion(cu),ra.copy(ke.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&ra.negate(),ra.applyQuaternion(cu),uu.copy(ke.Object3D.DEFAULT_UP).projectOnPlane(du),this.angleOffsetFromUp=uu.angleTo(ra),this.angleOffsetFromUp*=uu.cross(ra).dot(du)>=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 ke.Vector3),i=e.getWorldDirection(new ke.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().add(i),target:t}}getViewToObject(e){let t=e.getWorldPosition(new ke.Vector3),i=this.getWorldDirection(new ke.Vector3).multiplyScalar(this.targetOffset);return{position:t.clone().sub(i),target:t}}setViewplaneSize(e,t){if(this.aspect=e/t,this.data.type==="OrthographicCamera"&&this.data.orthographic.autoZoom){let o=this.data.orthographic.autoZoomFrustumSize??au,i=e>t?this.aspect:1,s=e>t?1:this.aspect;this.left=-o*.5*i,this.right=o*.5*i,this.top=o*.5*(1/s),this.bottom=-o*.5*(1/s)}else this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5;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,l){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,o,i,s,l):this.orthoCamera.setViewOffset(e,t,o,i,s,l)}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,autoZoom:!0,autoZoomFrustumSize:au},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return En(t,e)}updateCameraSubtype(e,t){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";t.zoom!==void 0&&this.setZoom(o,t.zoom),t.near!==void 0&&this.setNear(o,t.near),t.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=t.fov)}updateState(e,t){this.updateCameraState(e,t)}updateCameraState(e,t){this.updateState_Entity(e,t),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,t,o){super.updateByPatchedOp(e,t,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var Eo=require("three");var Ki=new Eo.Matrix4,QP=new Eo.Matrix4;var dr=class extends ar{constructor(e,t,o){super(e,t);this.data=t;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new Eo.BufferGeometry;this.onAfterRender=(e,t,o,i,s,l)=>{super.onAfterRender(e,t,o,i,s,l),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 dr&&s.recomputeBoolean(e===!0,t)}this.meshSetAddresses=[];for(let i=0;i<this.children.length;i++){let s=this.children[i];if(s instanceof wt&&s.dataPatched.visible===!0&&s.geometry.attributes.position?.count>0&&s.geometry.drawRange.count>0){if(Ki.multiplyMatrices(s.hiddenMatrix,s.matrix),s.booleanMeshSetAddress===-1){if((s.geometry.index??s.geometry.getAttribute("position")).count/3<15e5&&(s.booleanMeshSetAddress=Sr.getMeshSet(s.geometry,e===!0,t)),s.booleanMeshSetAddress===-1)return;Sr.transformMeshSet(s.booleanMeshSetAddress,Ki),s.booleanMatrixInvOld.copy(Ki).invert(),s.booleanWasTransformed=!1}else s instanceof dr&&s.needsTransformForDownstream===!0?(Sr.transformMeshSet(s.booleanMeshSetAddress,Ki),s.needsTransformForDownstream=!1):s.booleanWasTransformed===!0&&(Sr.transformMeshSet(s.booleanMeshSetAddress,QP.multiplyMatrices(Ki,s.booleanMatrixInvOld)),s.booleanMatrixInvOld.copy(Ki).invert(),s.booleanWasTransformed=!1);this.meshSetAddresses.push(s.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new Eo.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Sr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new Eo.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Sr.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,ki(this),Ui(this)}dispose(){super.dispose(),this.geometry.dispose()}};var hg=require("three");var mg;(r=>{function n(e){return Re.is(e)&&e instanceof hg.Light}r.is=n})(mg||(mg={}));var Zi=(n,r)=>class extends Mo(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 Qi=n=>n instanceof wt,oa=n=>n!==null&&n instanceof dr,yg=n=>n instanceof Yr;var pu=n=>ic.is(n);var xg=require("three");var gg=require("three");var Lo=class extends Wr(gg.AxesHelper){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){$r(this.object,Lo.geometryHelper,e,t)}update(){}};var na=class extends Mo(xg.Group,Lo){constructor(r,e){super(),this.super_Entity(r,e),this.objectHelper.update()}updateState(r,e){this.updateState_Entity(r,e)}};var sa=require("three");var vg=require("three");var Ji=class extends Wr(vg.DirectionalLightHelper){constructor(e,t=15,o=10066329){super(e,t,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){$r(this.object,Ji.geometryHelper,e,t)}};var bg=require("three");var es=class extends Wr(bg.PointLightHelper){constructor(e,t=15,o=6710886){super(e,t,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){$r(this.object,es.geometryHelper,e,t)}};var ac=require("three");var sc=class extends Wr(ac.SpotLightHelper){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){$r(this.object,sc.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=sc._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,l=this.cone.material.length;s<l;s++)this.cone.material[s].color.set(i);else this.cone.material.color.set(i)}}},ia=sc;ia._vector=new ac.Vector3;function JP(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 lc=class extends Zi(sa.DirectionalLight,Ji){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 sa.CameraHelper(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 sa.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e);let t=r.depth!==void 0&&r.depth!==this.shadow.camera.far||r.size!==void 0&&r.size/2!==this.shadow.camera.right;r.size!==void 0&&JP(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)),t&&this.update()}};var qt=require("three");var cc=class extends Zi(qt.PointLight,es){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 qt.Vector3(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),l=new qt.Vector3(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),c=new qt.Box3(s,l),u=new qt.Box3Helper(c,new qt.Color(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 qt.Box3Helper){let t=this.shadow.camera,o=new qt.Vector3(-t.far+this.position.x,-t.far+this.position.y,-t.far+this.position.z),i=new qt.Vector3(t.far+this.position.x,t.far+this.position.y,t.far+this.position.z);e.box.set(o,i),e.updateMatrixWorld(!0)}}}updateMatrixWorld(r){super.updateMatrixWorld(r),this.objectHelper&&this.objectHelper.update()}updateState(r,e){this.updateState_Light(r,e),r.distance!==void 0&&(this.distance=r.distance),r.decay!==void 0&&(this.decay=r.decay),r.shadowRadius!==void 0&&(this.shadow.radius=r.shadowRadius),r.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var ur=require("three");var Sg=new ur.Vector3,wg=new ur.Vector3,_g=new ur.Quaternion,dc=class extends Zi(ur.SpotLight,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=ur.MathUtils.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new ur.CameraHelper(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 ur.CameraHelper&&e.update()}}updateMatrixWorld(r){super.updateMatrixWorld(r),wg.setFromMatrixPosition(this.matrixWorld),_g.setFromRotationMatrix(this.matrixWorld),Sg.copy(this.up).applyQuaternion(_g).negate().multiplyScalar(this.distance),this.target.position.copy(wg).add(Sg),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.shadowResolution!==void 0&&(this.shadow.mapSize.set(r.shadowResolution,r.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var uc=class extends Tt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(r,e){let t=this.geometry.getAttribute("position");t!==void 0?Rs(t,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:t.count,r,e):super.updateEntityBoxSize(r,e)}};var ts=class extends Tt{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=El;break;case"Ellipse":i=ci;break;case"Polygon":i=Ml;break;case"Star":i=Ll;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?Rs(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,t):super.updateEntityBoxSize(e,t)}};var Tg=require("three");var co=class extends Mo(Tg.Group,Lo){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 l of wo.rootOverrideProps)e[l]===void 0?(i===void 0&&(i={...e}),i[l]=o.data[l]):(s===void 0&&(s={}),s[l]=e[l]);return this.overrideData=s,i??e}return e}updateByOp(e,t,o,i){let s;if(this.isInstanceRoot&&!i&&(t=this.transformAssignData(t,o),e.type===0&&e.path.length===0&&this.component))for(let l of wo.rootOverrideProps)l in e.props&&e.props[l]===void 0&&(s===void 0&&(s={...e,props:{...e.props}}),s.props[l]=this.component.data[l]);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){this.component=e.scene.find(t.component)??null;let o=!1;if(this.component!==this.oldComponent){if(this.oldComponent){let i=0;for(let s of this.children)if(Re.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),pc(s),i+=1;else break;this.children.splice(0,i)}o=!0}this.component&&Og(e,[this.uuid],t.overrides,this,this.component,this.component,0,o),this.oldComponent=this.component}}};function pc(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)Re.is(e)&&pc(e)}}function Pg(n,r,e,t){return n.component===r&&as(n.identity,t)?n.overrideData===e?2:1:0}function Og(n,r,e,t,o,i,s,l){if(s>50)return!1;if(t.component!==o){if(t.component){let u=t.component.instances.indexOf(t);u>=0&&t.component.instances.splice(u,1)}o.instances.push(t),t.component=o}o instanceof co&&o.isInstanceRoot&&o.expandInstanceChildren(n);let c=0;for(let u of o.children)if(Re.is(u)){let a=[...r,...typeof u.identity=="string"?[u.identity]:u.identity],d=$n.resolve(e,a,1),p=null,f;if(!l){let m=t.children[c];if(p=Re.is(m)?m:null,p!==null){let h=Pg(p,u,d,a);f=h>=1?p.stateSelection:void 0,h!==2&&(p=null)}if(p===null&&(p=n.scene.findInstance(a)??null,p!==null)){let h=Pg(p,u,d,a);if(f=h>=1?p.stateSelection:void 0,h!==2)p=null;else{let y=p.parent.children.indexOf(p);p.parent.children.splice(y,1),t.children.splice(c,0,p),p.parent===t?(y<=c&&console.error("not possible"),void 0):(p.parent=t,p.matrixWorldNeedsUpdate=!0,p.resetBBoxNeedsUpdate(),p.updateVisible(),n.pendingDeletes.delete(p),void 0)}}}if(p===null){let m=d?ro.apply(u.data,d):u.data;mr.is(m.type)&&(m={...m,type:"Empty"}),p=gr.createEntity(a,m,n),p.overrideData=d,t.add(p),t.children.splice(t.children.length-1,1),t.children.splice(c,0,p),p.updateState(p.data,n),f&&p.changeSelectedState(f,n),n.scene.registerInstanceAndSetUuid(p)}c+=1,Og(n,r,e,p,u,i,s+1,l)}if(!l){let u=c;for(;;){let a=t.children[c];if(Re.is(a))n.pendingDeletes.add(a);else break;c+=1}t.children.splice(u,c-u)}return!0}function eT(n,r,e){let t;return r.geometry.type==="TextGeometry"?new qi(n,r,e):(r.geometry.type==="SubdivGeometry"?t=new sn(n,r,e):r.geometry.type==="PathGeometry"?t=new ts(n,r,e):r.geometry.type==="VectorGeometry"?t=new uc(n,r,e):r.geometry.type==="BooleanGeometry"?t=new dr(n,r,e):t=new Tt(n,r,e),t)}function fc(n,r,e){return r.type==="Mesh"?eT(n,r,e):r.type==="Empty"?new na(n,r):r.type==="PointLight"?new cc(n,r,e):r.type==="SpotLight"?new dc(n,r,e):r.type==="DirectionalLight"?new lc(n,r,e):r.type==="Component"||r.type==="Instance"?new co(n,r,e):mr.is(r.type)?new Yr(n,r):(console.error(r),new na(n,r))}gr.createEntity=fc;function tT(n,r,e){let t=fc(n.identity,r,e),o=n.children,i=n.attachedPaths,s=n.parent,l=n.component,c=n.instances,u=n.overrideData,a=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=s,n.component=l,n.instances=c,n.uuid=a,n.overrideData=u,n.updateState(n.data,e),d&&n.changeSelectedState(d,e),n.resetBBoxNeedsUpdate()}gr.changeEntityProptotype=tT;gr.Cloner=Yi;function Ag(n,r,e,t){n.updateByOp(r,e,t,!1)}var rs=require("three");function Ng(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,Ui(n),ki(n)),t.length===0&&o.length===0&&n.layers.set(0),n instanceof ar&&n.needsAO&&n.layers.enable(5),e}function Cg(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 Ig(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof ar)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Ng(e,e.material[t])&&(r=!0);else Ng(e,e.material)&&(r=!0)}),r}function Mg(n){let r=!1;return n.traverseEntity(e=>{if(e instanceof ar)if(Array.isArray(e.material))for(let t=0;t<e.material.length;t++)Cg(e,e.material[t])&&(r=!0);else Cg(e,e.material)&&(r=!0)}),r}var nT=new rs.Raycaster,iT=new rs.Matrix4,sT=new rs.Ray;function fu(n,r,e,t=!1){let o=n.cloner;if(o)for(let i of o.children){let s=iT.copy(i.matrixWorld).invert(),l=sT.copy(r.ray).applyMatrix4(s),c=n.matrixWorld;l.applyMatrix4(c);let u=nT;u.set(l.origin,l.direction),u.near=r.near,u.far=r.far;let a=u.intersectObject(n,!1);a.length>0&&e.push({...a[0],object:t?i:n})}}var mc=class{constructor(){this._constraints=new Map}setConstraint(r,e){e===null?this._constraints.delete(r):this._constraints.set(r,e)}removeDependencies(r){this._constraints.delete(r)}applyConstraints(r){let e=new Set;this._constraints.forEach((t,o)=>{let i=[o,t],s=t;for(;this._constraints.has(s);)s=this._constraints.get(s),e.has(s)||i.push(s);for(let l=i.length-2;l>=0;l--)if(!e.has(i[l])){let c=r.find(i[l]);c?c.applyPathSnapping(r):console.warn(`missing entity ${i[l]}`),e.add(i[l])}})}findDependency(r,e){let t=r;for(;this._constraints.has(t);)if(t=this._constraints.get(t),t===e)return!0;return!1}};var aT=new pr.MeshBasicMaterial;aT.wireframe=!0;var Eg=new pr.Vector3,mu=class extends pr.Scene{constructor(e,t){super();this.data=e;this.backupFog=new pr.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.occlusion=!1;this.aoFullRes=!1;this.radius=128;this.bias=.5;this.aoColor={r:0,g:0,b:0};this.geometryCacheChanged=!1;this.bgColor=new ct(1,1,1,1);this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new mc;this.needsRecomputeInstances=!1;this.ambientLight=new pr.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=e.postprocessing,this.init(e,t),this.matrixAutoUpdate=!1}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=Mg(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=Ig(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}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}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 l=i.children.indexOf(s);o.splice(0,0,l)}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)=>bu(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(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(),Qi(i)&&oa(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i)}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),o.parent.remove(o),oa(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Qi(o)&&(o.freeBooleanPointer(),i instanceof dr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof ts&&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();let l=e.localIndex;s.children.splice(l,0,s.children.pop()),Qi(o)&&(o.invalidateUpstreamBooleanData(),oa(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof dr&&i.invalidateDownstreamBooleanData().recomputeBoolean())}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}updateEntityByOp(e,t,o,i){if(t.type===0){if(("overrides"in t.props||"component"in t.props)&&this.markNeedsRecomputeInstances(),t.path.includes("overrides")&&"states"in t.props){let{rest:l}=t.props;t={...t,props:l},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{Ag(s,t,o,{scene:this,shared:i}),s instanceof Tt&&s.updateGeometryGroupsIfNeeded()}catch(l){console.error(l)}}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(vt(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let o=this.find(e.publish.playCamera);o instanceof Yr&&this.switchActiveCamera(o)}this.expandInstances(t,!0),this.traverseEntity(o=>{oa(o)&&o.recomputeBoolean(),o instanceof Yr&&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){Re.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(t=>{Re.is(t)&&t.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,t,o,i,s,l,c){e&&e!==i.uuid&&i.find(e)&&s.forInstancesRec(a=>{a.isInstanceRoot||(a.data=jn(a.data,d=>{let p=d.events.data(c.id),f=a.goUp(l);if(f){let m=[...ha(f.identity),e].join("-"),h=this.entityIdentityToEntity[m];if(h){let y=h.uuid;Ct.zoom(p,t)[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof co&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((t,o)=>{t.data.events.forEach(i=>{i.data.type==="GameControl"?t.forInstancesRec(s=>{s.isInstanceRoot||(s.data=jn(s.data,l=>{l.events.delete(i.id)}).data)}):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)),i.data.inActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["inActions",s.id],"object",e,t,o,i)}),i.data.outActions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["outActions",s.id],"object",e,t,o,i)})):"actions"in i.data&&i.data.actions.forEach(s=>{s.data.type==="Transition"&&this.relativeizeInner(s.data.object,["actions",s.id],"object",e,t,o,i)})})}),!0})}expandInstances(e,t){let o=new Set;this.traverseEntity(i=>{if(i instanceof co&&i.isInstanceRoot)return i.expandInstanceChildren({scene:this,shared:e,pendingDeletes:o}),t||i.resetBBoxNeedsUpdate(),!0});for(let i of o)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(i),pc(i)}recomputeInstances(e){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(t=>{t instanceof co&&t.isInstanceRoot&&(t.component=void 0)}),this.expandInstances(e,!1))}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)Re.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=new Yr(mu.PERSONAL_CAMERA_ID,{...Wn.defaultData,name:"Personal Camera"});return e.objectHelper.visible=!1,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],o=i=>{for(let s of i.children){let l=s.cloner;Re.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible)&&((Qi(s)||pu(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),fu(s,e,t)),o(s))}};return o(this),t}raycastWithClones(e){let t=[],o=i=>{for(let s of i.children){let l=s.cloner;Re.is(s)&&(s.visible||l?.object.data.visible)&&((Qi(s)||pu(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,t),fu(s,e,t,!0)),o(s))}};return o(this),t}forEachEntity(e){for(let t of this.children)Re.is(t)&&e(t)}traverseEntity(e){for(let t of this.children)Re.is(t)&&t.traverseEntity(e)}traverseObject(e){for(let t of this.children)Ss.is(t)&&t.traverseObject(e)}traverseVisibleEntity(e){for(let t of this.children)Re.is(t)&&t.visible&&t.traverseVisibleEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=vt(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}dispose(){this.clearScene()}updateAmbientLight(e,t){e.color!==void 0&&(this.ambientLight.color=vt(e.color,t)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.groundColor!==void 0&&(this.ambientLight.groundColor=vt(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled),e.occlusion!==void 0&&(this.occlusion=e.occlusion),e.aoFullRes!==void 0&&(this.aoFullRes=e.aoFullRes),e.radius!==void 0&&(this.radius=e.radius),e.bias!==void 0&&(this.bias=e.bias),e.aoColor!==void 0&&(this.aoColor=vt(e.aoColor,t))}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}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,l){let c={scene:this,shared:l},u=fc(e,t,c);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(s,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,l)),u.updateState(t,c),u instanceof Tt&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(),u.cloner&&this.toExpandCloner.add(u),t.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,t.pathSnapping.pathId)),u}getCenter(e){let t=[];for(let i=0,s=e.length;i<s;++i){let{id:l,recursive:c}=e[i],u=this.find(l),a=c?u.recursiveBBox:u.singleBBox;t.push(...a.vertices)}let o=new pr.Box3;return o.setFromPoints(t),o.getCenter(Eg),Eg}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 wt)if(Array.isArray(t.material))for(let o=0;o<t.material.length;o++)t.material[o]instanceof Ht&&e(t.material[o]);else t.material instanceof Ht&&e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let o,i;e>=t?(o=t/e,i=1):(o=1,i=e/t),this.traverseMaterial(s=>{s.getLayersOfType("transmission").forEach(c=>{c.uniforms[`f${c.id}_aspectRatio`].value.x=o,c.uniforms[`f${c.id}_aspectRatio`].value.y=i})})}},os=mu;os.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera",os.PERSONAL_CAMERA_EXPORT_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCameraExport";var Lg=require("three/examples/jsm/loaders/DRACOLoader.js");var Bo;function lT(){return Bo||(Bo=new Lg.DRACOLoader,Bo.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),Bo.decoderPending}async function cT(n){if(Bo){let r={attributeIDs:Bo.defaultAttributeIDs,attributeTypes:Bo.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await Bo.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 Bg(n,r){let[e,t]=Cc(ol.deserialize(new Uint8Array(n)));qm(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 lT();for(let i of o){let s=await cT(pt(i.geometry.data.draco));if(s){s.index&&(i.geometry.data.index={array:s.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let l={};s.attributes.forEach(({name:c,array:u,itemSize:a})=>{l[c]={array:u,itemSize:a,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=l,i.geometry.data.draco=void 0}}return r&&r(e),t.result().data}var dT=require("three"),uT=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Dg(n){let r;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)r=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=r}var la=require("three");function Gg(n){let r=new Set;return n.traverse(e=>{if(e instanceof ar)if(Xe(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(pT(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new la.Color,specularColor:new la.Color});let o=0;e.onBeforeCompile=(i,s)=>{t&&t(i,s),i.uniforms=Object.assign({},la.ShaderLib.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(l=>{if(i.uniforms.transmissionSamplerMap.value){let c=l.color;c&&(c.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,c.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value)}else o++,o<2&&(e.needsUpdate=!0)})}}else fT(e)||(e.onBeforeCompile=(o,i)=>{t&&t(o,i),e.transparent=!1})}),n}function pT(n){return n.getLayersOfType("transmission").length>0}function fT(n){let r=0;return n.layers.forEach(e=>{if(e.type!=="light"&&e.type!=="fresnel"){let t=e.uniforms["f"+e.id+"_alpha"];t&&(r+=(1-r)*t.value)}}),r<1}function Rg(n){return n.traverse(r=>{if(r.type==="Camera"){let e=r;e.type=e.cameraType}}),n}function Vg(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(l=>{l.name=l.name.replace(o,i)}):s.material.isAsset||(s.material.name=s.material.name.replace(o,i))}}r.push(t.name)}),n}var zg=require("three/examples/jsm/utils/BufferGeometryUtils.js");function jg(n){let r=[];return n.traverse(e=>{e instanceof Yi&&r.push(e)}),r.forEach(e=>{let t=e.object,i=e.children.map(l=>{l.updateMatrix();let c=l.geometry.clone().applyMatrix4(l.matrix);return l.matrix.determinant()<0&&Dg(c),c}),s=(0,zg.mergeBufferGeometries)(e.parameters.hideBase?i:[t instanceof wt?t.geometry:[],...i]);t instanceof wt&&(t.geometry=s),e.removeFromParent(),t.setFromClonerState(null,{scene:n,shared:$y})}),n}function Fg(n){return n.traverse(r=>{r.matrixAutoUpdate=!0}),n}function kg(n){Object.values(n.shared.materials).forEach(r=>{hu(r)}),n.scene.objects.traverse((r,e)=>{"material"in e?hu(e.material):"materials"in e&&e.materials.forEach(t=>{hu(t)})})}function hu(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 Wg=dn(Hg(),1),qg="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",hc=class extends yc.Loader{load(r,e,t,o=console.error){let i=new yc.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),r.endsWith(".spline")?console.warn(qg+" The .spline files are only meant to be used by the Editor."):r.endsWith(".splinecode")||console.warn(qg),i.load(r,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let l=await this.parse(s);e(l)}catch(l){o(l)}},t,o)}async parse(r){let e=await Bg(r,kg);e.version&&(0,Wg.default)(e.version,"0.9.360")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.all([Xy(e)&&ay(),sg(e)&&qy()].filter(Boolean));let t=new nn(e.shared);Object.values(t.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let o=new os(e.scene,t);o.remove(o.personalCamera),e.scene.environment.ambientLight.enabled||o.remove(o.ambientLight);let i=e.scene.publish.playCamera;if(i){let s=o.find(i);s&&yg(s)&&Object.assign(s,{makeDefault:!0})}return o=jg(o),o=Gg(o),o=Rg(o),o=Vg(o),o=Fg(o),o}};