@splinetool/runtime 0.9.127 → 0.9.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
- var SC=Object.create;var lg=Object.defineProperty;var AC=Object.getOwnPropertyDescriptor;var _C=Object.getOwnPropertyNames;var TC=Object.getPrototypeOf,MC=Object.prototype.hasOwnProperty;var Vx=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),EC=(r,e)=>{for(var t in e)lg(r,t,{get:e[t],enumerable:!0})},CC=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _C(e))!MC.call(r,i)&&i!==t&&lg(r,i,{get:()=>e[i],enumerable:!(n=AC(e,i))||n.enumerable});return r};var Hx=(r,e,t)=>(t=r!=null?SC(TC(r)):{},CC(e||!r||!r.__esModule?lg(t,"default",{value:r,enumerable:!0}):t,r));var gM=Vx((fm,mM)=>{(function(r,e){typeof fm=="object"&&typeof mM<"u"?e(fm):typeof define=="function"&&define.amd?define(["exports"],e):e((r=typeof globalThis<"u"?globalThis:r||self).SVDJS={})})(fm,function(r){"use strict";r.SVD=function(e,t,n,i,s){if(t=t===void 0||t,n=n===void 0||n,s=1e-64/(i=i||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var o,a,l,u,c,h,d,f,m,p,g,v,y=e[0].length,w=e.length;if(w<y)throw new TypeError("Invalid matrix: m < n");for(var b=[],S=[],_=[],M=t==="f"?w:y,x=p=d=0;x<w;x++)S[x]=new Array(M).fill(0);for(x=0;x<y;x++)_[x]=new Array(y).fill(0);var T,E=new Array(y).fill(0);for(x=0;x<w;x++)for(o=0;o<y;o++)S[x][o]=e[x][o];for(x=0;x<y;x++){for(b[x]=d,m=0,l=x+1,o=x;o<w;o++)m+=Math.pow(S[o][x],2);if(m<s)d=0;else for(f=(h=S[x][x])*(d=h<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x]=h-d,o=l;o<y;o++){for(m=0,a=x;a<w;a++)m+=S[a][x]*S[a][o];for(h=m/f,a=x;a<w;a++)S[a][o]=S[a][o]+h*S[a][x]}for(E[x]=d,m=0,o=l;o<y;o++)m+=Math.pow(S[x][o],2);if(m<s)d=0;else{for(f=(h=S[x][x+1])*(d=h<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x+1]=h-d,o=l;o<y;o++)b[o]=S[x][o]/f;for(o=l;o<w;o++){for(m=0,a=l;a<y;a++)m+=S[o][a]*S[x][a];for(a=l;a<y;a++)S[o][a]=S[o][a]+m*b[a]}}p<(g=Math.abs(E[x])+Math.abs(b[x]))&&(p=g)}if(n)for(x=y-1;0<=x;x--){if(d!==0){for(f=S[x][x+1]*d,o=l;o<y;o++)_[o][x]=S[x][o]/f;for(o=l;o<y;o++){for(m=0,a=l;a<y;a++)m+=S[x][a]*_[a][o];for(a=l;a<y;a++)_[a][o]=_[a][o]+m*_[a][x]}}for(o=l;o<y;o++)_[x][o]=0,_[o][x]=0;_[x][x]=1,d=b[x],l=x}if(t){if(t==="f")for(x=y;x<w;x++){for(o=y;o<w;o++)S[x][o]=0;S[x][x]=1}for(x=y-1;0<=x;x--){for(l=x+1,d=E[x],o=l;o<M;o++)S[x][o]=0;if(d!==0){for(f=S[x][x]*d,o=l;o<M;o++){for(m=0,a=l;a<w;a++)m+=S[a][x]*S[a][o];for(h=m/f,a=x;a<w;a++)S[a][o]=S[a][o]+h*S[a][x]}for(o=x;o<w;o++)S[o][x]=S[o][x]/d}else for(o=x;o<w;o++)S[o][x]=0;S[x][x]=S[x][x]+1}}for(i*=p,a=y-1;0<=a;a--)for(var C=0;C<50;C++){for(T=!1,l=a;0<=l;l--){if(Math.abs(b[l])<=i){T=!0;break}if(Math.abs(E[l-1])<=i)break}if(!T){for(c=0,u=l-(m=1),x=l;x<a+1&&(h=m*b[x],b[x]=c*b[x],!(Math.abs(h)<=i));x++)if(d=E[x],E[x]=Math.sqrt(h*h+d*d),c=d/(f=E[x]),m=-h/f,t)for(o=0;o<w;o++)g=S[o][u],v=S[o][x],S[o][u]=g*c+v*m,S[o][x]=-g*m+v*c}if(v=E[a],l===a){if(v<0&&(E[a]=-v,n))for(o=0;o<y;o++)_[o][a]=-_[o][a];break}for(p=E[l],h=(((g=E[a-1])-v)*(g+v)+((d=b[a-1])-(f=b[a]))*(d+f))/(2*f*g),d=Math.sqrt(h*h+1),h=((p-v)*(p+v)+f*(g/(h<0?h-d:h+d)-f))/p,x=l+(m=c=1);x<a+1;x++){if(d=b[x],g=E[x],f=m*d,d*=c,v=Math.sqrt(h*h+f*f),h=p*(c=h/(b[x-1]=v))+d*(m=f/v),d=-p*m+d*c,f=g*m,g*=c,n)for(o=0;o<y;o++)p=_[o][x-1],v=_[o][x],_[o][x-1]=p*c+v*m,_[o][x]=-p*m+v*c;if(v=Math.sqrt(h*h+f*f),h=(c=h/(E[x-1]=v))*d+(m=f/v)*g,p=-m*d+c*g,t)for(o=0;o<w;o++)g=S[o][x-1],v=S[o][x],S[o][x-1]=g*c+v*m,S[o][x]=-g*m+v*c}b[l]=0,b[a]=h,E[a]=p}for(x=0;x<y;x++)E[x]<i&&(E[x]=0);return{u:S,q:E,v:_}},r.VERSION="1.1.1",Object.defineProperty(r,"__esModule",{value:!0})})});var qM=Vx(wm=>{(function(){"use strict";var r=function(){this.init()};r.prototype={init:function(){var c=this||e;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var h=this||e;if(c=parseFloat(c),h.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(h._volume=c,h._muted)return h;h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c,e.ctx.currentTime);for(var d=0;d<h._howls.length;d++)if(!h._howls[d]._webAudio)for(var f=h._howls[d]._getSoundIds(),m=0;m<f.length;m++){var p=h._howls[d]._soundById(f[m]);p&&p._node&&(p._node.volume=p._volume*c)}return h}return h._volume},mute:function(c){var h=this||e;h.ctx||u(),h._muted=c,h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c?0:h._volume,e.ctx.currentTime);for(var d=0;d<h._howls.length;d++)if(!h._howls[d]._webAudio)for(var f=h._howls[d]._getSoundIds(),m=0;m<f.length;m++){var p=h._howls[d]._soundById(f[m]);p&&p._node&&(p._node.muted=c?!0:p._muted)}return h},stop:function(){for(var c=this||e,h=0;h<c._howls.length;h++)c._howls[h].stop();return c},unload:function(){for(var c=this||e,h=c._howls.length-1;h>=0;h--)c._howls[h].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||e)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||e;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var h=new Audio;typeof h.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var h=new Audio;h.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||e,h=null;try{h=typeof Audio<"u"?new Audio:null}catch{return c}if(!h||typeof h.canPlayType!="function")return c;var d=h.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),p=m&&parseInt(m[0].split("/")[1],10)<33,g=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,v=f.match(/Version\/(.*?) /),y=g&&v&&parseInt(v[1],10)<15;return c._codecs={mp3:!!(!p&&(d||h.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!d,opus:!!h.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(h.canPlayType('audio/wav; codecs="1"')||h.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!h.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!h.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(h.canPlayType("audio/x-m4b;")||h.canPlayType("audio/m4b;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(h.canPlayType("audio/x-mp4;")||h.canPlayType("audio/mp4;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!y&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!y&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!h.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(h.canPlayType("audio/x-flac;")||h.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||e;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var h=function(d){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var m=0;m<c._howls.length;m++)if(!c._howls[m]._webAudio)for(var p=c._howls[m]._getSoundIds(),g=0;g<p.length;g++){var v=c._howls[m]._soundById(p[g]);v&&v._node&&!v._node._unlocked&&(v._node._unlocked=!0,v._node.load())}c._autoResume();var y=c.ctx.createBufferSource();y.buffer=c._scratchBuffer,y.connect(c.ctx.destination),typeof y.start>"u"?y.noteOn(0):y.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),y.onended=function(){y.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",h,!0),document.removeEventListener("touchend",h,!0),document.removeEventListener("click",h,!0),document.removeEventListener("keydown",h,!0);for(var w=0;w<c._howls.length;w++)c._howls[w]._emit("unlock")}};return document.addEventListener("touchstart",h,!0),document.addEventListener("touchend",h,!0),document.addEventListener("click",h,!0),document.addEventListener("keydown",h,!0),c}},_obtainHtml5Audio:function(){var c=this||e;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var h=new Audio().play();return h&&typeof Promise<"u"&&(h instanceof Promise||typeof h.then=="function")&&h.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var h=this||e;return c._unlocked&&h._html5AudioPool.push(c),h},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!e.usingWebAudio)){for(var h=0;h<c._howls.length;h++)if(c._howls[h]._webAudio){for(var d=0;d<c._howls[h]._sounds.length;d++)if(!c._howls[h]._sounds[d]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!e.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var h=0;h<c._howls.length;h++)c._howls[h]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var e=new r,t=function(c){var h=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}h.init(c)};t.prototype={init:function(c){var h=this;return e.ctx||u(),h._autoplay=c.autoplay||!1,h._format=typeof c.format!="string"?c.format:[c.format],h._html5=c.html5||!1,h._muted=c.mute||!1,h._loop=c.loop||!1,h._pool=c.pool||5,h._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,h._rate=c.rate||1,h._sprite=c.sprite||{},h._src=typeof c.src!="string"?c.src:[c.src],h._volume=c.volume!==void 0?c.volume:1,h._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},h._duration=0,h._state="unloaded",h._sounds=[],h._endTimers={},h._queue=[],h._playLock=!1,h._onend=c.onend?[{fn:c.onend}]:[],h._onfade=c.onfade?[{fn:c.onfade}]:[],h._onload=c.onload?[{fn:c.onload}]:[],h._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],h._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],h._onpause=c.onpause?[{fn:c.onpause}]:[],h._onplay=c.onplay?[{fn:c.onplay}]:[],h._onstop=c.onstop?[{fn:c.onstop}]:[],h._onmute=c.onmute?[{fn:c.onmute}]:[],h._onvolume=c.onvolume?[{fn:c.onvolume}]:[],h._onrate=c.onrate?[{fn:c.onrate}]:[],h._onseek=c.onseek?[{fn:c.onseek}]:[],h._onunlock=c.onunlock?[{fn:c.onunlock}]:[],h._onresume=[],h._webAudio=e.usingWebAudio&&!h._html5,typeof e.ctx<"u"&&e.ctx&&e.autoUnlock&&e._unlockAudio(),e._howls.push(h),h._autoplay&&h._queue.push({event:"play",action:function(){h.play()}}),h._preload&&h._preload!=="none"&&h.load(),h},load:function(){var c=this,h=null;if(e.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var d=0;d<c._src.length;d++){var f,m;if(c._format&&c._format[d])f=c._format[d];else{if(m=c._src[d],typeof m!="string"){c._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&&e.codecs(f)){h=c._src[d];break}}if(!h){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=h,c._state="loading",window.location.protocol==="https:"&&h.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new n(c),c._webAudio&&s(c),c},play:function(c,h){var d=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&d._state==="loaded"&&!d._sprite[c])return null;if(typeof c>"u"&&(c="__default",!d._playLock)){for(var m=0,p=0;p<d._sounds.length;p++)d._sounds[p]._paused&&!d._sounds[p]._ended&&(m++,f=d._sounds[p]._id);m===1?c=null:f=null}}var g=f?d._soundById(f):d._inactiveSound();if(!g)return null;if(f&&!c&&(c=g._sprite||"__default"),d._state!=="loaded"){g._sprite=c,g._ended=!1;var v=g._id;return d._queue.push({event:"play",action:function(){d.play(v)}}),v}if(f&&!g._paused)return h||d._loadQueue("play"),g._id;d._webAudio&&e._autoResume();var y=Math.max(0,g._seek>0?g._seek:d._sprite[c][0]/1e3),w=Math.max(0,(d._sprite[c][0]+d._sprite[c][1])/1e3-y),b=w*1e3/Math.abs(g._rate),S=d._sprite[c][0]/1e3,_=(d._sprite[c][0]+d._sprite[c][1])/1e3;g._sprite=c,g._ended=!1;var M=function(){g._paused=!1,g._seek=y,g._start=S,g._stop=_,g._loop=!!(g._loop||d._sprite[c][2])};if(y>=_){d._ended(g);return}var x=g._node;if(d._webAudio){var T=function(){d._playLock=!1,M(),d._refreshBuffer(g);var O=g._muted||d._muted?0:g._volume;x.gain.setValueAtTime(O,e.ctx.currentTime),g._playStart=e.ctx.currentTime,typeof x.bufferSource.start>"u"?g._loop?x.bufferSource.noteGrainOn(0,y,86400):x.bufferSource.noteGrainOn(0,y,w):g._loop?x.bufferSource.start(0,y,86400):x.bufferSource.start(0,y,w),b!==1/0&&(d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),b)),h||setTimeout(function(){d._emit("play",g._id),d._loadQueue()},0)};e.state==="running"&&e.ctx.state!=="interrupted"?T():(d._playLock=!0,d.once("resume",T),d._clearTimer(g._id))}else{var E=function(){x.currentTime=y,x.muted=g._muted||d._muted||e._muted||x.muted,x.volume=g._volume*e.volume(),x.playbackRate=g._rate;try{var O=x.play();if(O&&typeof Promise<"u"&&(O instanceof Promise||typeof O.then=="function")?(d._playLock=!0,M(),O.then(function(){d._playLock=!1,x._unlocked=!0,h?d._loadQueue():d._emit("play",g._id)}).catch(function(){d._playLock=!1,d._emit("playerror",g._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."),g._ended=!0,g._paused=!0})):h||(d._playLock=!1,M(),d._emit("play",g._id)),x.playbackRate=g._rate,x.paused){d._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}c!=="__default"||g._loop?d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),b):(d._endTimers[g._id]=function(){d._ended(g),x.removeEventListener("ended",d._endTimers[g._id],!1)},x.addEventListener("ended",d._endTimers[g._id],!1))}catch(I){d._emit("playerror",g._id,I)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=d._src,x.load());var C=window&&window.ejecta||!x.readyState&&e._navigator.isCocoonJS;if(x.readyState>=3||C)E();else{d._playLock=!0,d._state="loading";var P=function(){d._state="loaded",E(),x.removeEventListener(e._canPlayEvent,P,!1)};x.addEventListener(e._canPlayEvent,P,!1),d._clearTimer(g._id)}}return g._id},pause:function(c){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"pause",action:function(){h.pause(c)}}),h;for(var d=h._getSoundIds(c),f=0;f<d.length;f++){h._clearTimer(d[f]);var m=h._soundById(d[f]);if(m&&!m._paused&&(m._seek=h.seek(d[f]),m._rateSeek=0,m._paused=!0,h._stopFade(d[f]),m._node))if(h._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),h._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||h._emit("pause",m?m._id:null)}return h},stop:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"stop",action:function(){d.stop(c)}}),d;for(var f=d._getSoundIds(c),m=0;m<f.length;m++){d._clearTimer(f[m]);var p=d._soundById(f[m]);p&&(p._seek=p._start||0,p._rateSeek=0,p._paused=!0,p._ended=!0,d._stopFade(f[m]),p._node&&(d._webAudio?p._node.bufferSource&&(typeof p._node.bufferSource.stop>"u"?p._node.bufferSource.noteOff(0):p._node.bufferSource.stop(0),d._cleanBuffer(p._node)):(!isNaN(p._node.duration)||p._node.duration===1/0)&&(p._node.currentTime=p._start||0,p._node.pause(),p._node.duration===1/0&&d._clearSound(p._node))),h||d._emit("stop",p._id))}return d},mute:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"mute",action:function(){d.mute(c,h)}}),d;if(typeof h>"u")if(typeof c=="boolean")d._muted=c;else return d._muted;for(var f=d._getSoundIds(h),m=0;m<f.length;m++){var p=d._soundById(f[m]);p&&(p._muted=c,p._interval&&d._stopFade(p._id),d._webAudio&&p._node?p._node.gain.setValueAtTime(c?0:p._volume,e.ctx.currentTime):p._node&&(p._node.muted=e._muted?!0:c),d._emit("mute",p._id))}return d},volume:function(){var c=this,h=arguments,d,f;if(h.length===0)return c._volume;if(h.length===1||h.length===2&&typeof h[1]>"u"){var m=c._getSoundIds(),p=m.indexOf(h[0]);p>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length>=2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d<"u"&&d>=0&&d<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,h)}}),c;typeof f>"u"&&(c._volume=d),f=c._getSoundIds(f);for(var v=0;v<f.length;v++)g=c._soundById(f[v]),g&&(g._volume=d,h[2]||c._stopFade(f[v]),c._webAudio&&g._node&&!g._muted?g._node.gain.setValueAtTime(d,e.ctx.currentTime):g._node&&!g._muted&&(g._node.volume=d*e.volume()),c._emit("volume",g._id))}else return g=f?c._soundById(f):c._sounds[0],g?g._volume:0;return c},fade:function(c,h,d,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(c,h,d,f)}}),m;c=Math.min(Math.max(0,parseFloat(c)),1),h=Math.min(Math.max(0,parseFloat(h)),1),d=parseFloat(d),m.volume(c,f);for(var p=m._getSoundIds(f),g=0;g<p.length;g++){var v=m._soundById(p[g]);if(v){if(f||m._stopFade(p[g]),m._webAudio&&!v._muted){var y=e.ctx.currentTime,w=y+d/1e3;v._volume=c,v._node.gain.setValueAtTime(c,y),v._node.gain.linearRampToValueAtTime(h,w)}m._startFadeInterval(v,c,h,d,p[g],typeof f>"u")}}return m},_startFadeInterval:function(c,h,d,f,m,p){var g=this,v=h,y=d-h,w=Math.abs(y/.01),b=Math.max(4,w>0?f/w:f),S=Date.now();c._fadeTo=d,c._interval=setInterval(function(){var _=(Date.now()-S)/f;S=Date.now(),v+=y*_,v=Math.round(v*100)/100,y<0?v=Math.max(d,v):v=Math.min(d,v),g._webAudio?c._volume=v:g.volume(v,c._id,!0),p&&(g._volume=v),(d<h&&v<=d||d>h&&v>=d)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,g.volume(d,c._id),g._emit("fade",c._id))},b)},_stopFade:function(c){var h=this,d=h._soundById(c);return d&&d._interval&&(h._webAudio&&d._node.gain.cancelScheduledValues(e.ctx.currentTime),clearInterval(d._interval),d._interval=null,h.volume(d._fadeTo,c),d._fadeTo=null,h._emit("fade",c)),h},loop:function(){var c=this,h=arguments,d,f,m;if(h.length===0)return c._loop;if(h.length===1)if(typeof h[0]=="boolean")d=h[0],c._loop=d;else return m=c._soundById(parseInt(h[0],10)),m?m._loop:!1;else h.length===2&&(d=h[0],f=parseInt(h[1],10));for(var p=c._getSoundIds(f),g=0;g<p.length;g++)m=c._soundById(p[g]),m&&(m._loop=d,c._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=d,d&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,c.playing(p[g])&&(c.pause(p[g],!0),c.play(p[g],!0)))));return c},rate:function(){var c=this,h=arguments,d,f;if(h.length===0)f=c._sounds[0]._id;else if(h.length===1){var m=c._getSoundIds(),p=m.indexOf(h[0]);p>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,h)}}),c;typeof f>"u"&&(c._rate=d),f=c._getSoundIds(f);for(var v=0;v<f.length;v++)if(g=c._soundById(f[v]),g){c.playing(f[v])&&(g._rateSeek=c.seek(f[v]),g._playStart=c._webAudio?e.ctx.currentTime:g._playStart),g._rate=d,c._webAudio&&g._node&&g._node.bufferSource?g._node.bufferSource.playbackRate.setValueAtTime(d,e.ctx.currentTime):g._node&&(g._node.playbackRate=d);var y=c.seek(f[v]),w=(c._sprite[g._sprite][0]+c._sprite[g._sprite][1])/1e3-y,b=w*1e3/Math.abs(g._rate);(c._endTimers[f[v]]||!g._paused)&&(c._clearTimer(f[v]),c._endTimers[f[v]]=setTimeout(c._ended.bind(c,g),b)),c._emit("rate",g._id)}}else return g=c._soundById(f),g?g._rate:c._rate;return c},seek:function(){var c=this,h=arguments,d,f;if(h.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(h.length===1){var m=c._getSoundIds(),p=m.indexOf(h[0]);p>=0?f=parseInt(h[0],10):c._sounds.length&&(f=c._sounds[0]._id,d=parseFloat(h[0]))}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));if(typeof f>"u")return 0;if(typeof d=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,h)}}),c;var g=c._soundById(f);if(g)if(typeof d=="number"&&d>=0){var v=c.playing(f);v&&c.pause(f,!0),g._seek=d,g._ended=!1,c._clearTimer(f),!c._webAudio&&g._node&&!isNaN(g._node.duration)&&(g._node.currentTime=d);var y=function(){v&&c.play(f,!0),c._emit("seek",f)};if(v&&!c._webAudio){var w=function(){c._playLock?setTimeout(w,0):y()};setTimeout(w,0)}else y()}else if(c._webAudio){var b=c.playing(f)?e.ctx.currentTime-g._playStart:0,S=g._rateSeek?g._rateSeek-g._seek:0;return g._seek+(S+b*Math.abs(g._rate))}else return g._node.currentTime;return c},playing:function(c){var h=this;if(typeof c=="number"){var d=h._soundById(c);return d?!d._paused:!1}for(var f=0;f<h._sounds.length;f++)if(!h._sounds[f]._paused)return!0;return!1},duration:function(c){var h=this,d=h._duration,f=h._soundById(c);return f&&(d=h._sprite[f._sprite][1]/1e3),d},state:function(){return this._state},unload:function(){for(var c=this,h=c._sounds,d=0;d<h.length;d++)h[d]._paused||c.stop(h[d]._id),c._webAudio||(c._clearSound(h[d]._node),h[d]._node.removeEventListener("error",h[d]._errorFn,!1),h[d]._node.removeEventListener(e._canPlayEvent,h[d]._loadFn,!1),h[d]._node.removeEventListener("ended",h[d]._endFn,!1),e._releaseHtml5Audio(h[d]._node)),delete h[d]._node,c._clearTimer(h[d]._id);var f=e._howls.indexOf(c);f>=0&&e._howls.splice(f,1);var m=!0;for(d=0;d<e._howls.length;d++)if(e._howls[d]._src===c._src||c._src.indexOf(e._howls[d]._src)>=0){m=!1;break}return i&&m&&delete i[c._src],e.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,h,d,f){var m=this,p=m["_on"+c];return typeof h=="function"&&p.push(f?{id:d,fn:h,once:f}:{id:d,fn:h}),m},off:function(c,h,d){var f=this,m=f["_on"+c],p=0;if(typeof h=="number"&&(d=h,h=null),h||d)for(p=0;p<m.length;p++){var g=d===m[p].id;if(h===m[p].fn&&g||!h&&g){m.splice(p,1);break}}else if(c)f["_on"+c]=[];else{var v=Object.keys(f);for(p=0;p<v.length;p++)v[p].indexOf("_on")===0&&Array.isArray(f[v[p]])&&(f[v[p]]=[])}return f},once:function(c,h,d){var f=this;return f.on(c,h,d,1),f},_emit:function(c,h,d){for(var f=this,m=f["_on"+c],p=m.length-1;p>=0;p--)(!m[p].id||m[p].id===h||c==="load")&&(setTimeout(function(g){g.call(this,h,d)}.bind(f,m[p].fn),0),m[p].once&&f.off(c,m[p].fn,m[p].id));return f._loadQueue(c),f},_loadQueue:function(c){var h=this;if(h._queue.length>0){var d=h._queue[0];d.event===c&&(h._queue.shift(),h._loadQueue()),c||d.action()}return h},_ended:function(c){var h=this,d=c._sprite;if(!h._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(h._ended.bind(h,c),100),h;var f=!!(c._loop||h._sprite[d][2]);if(h._emit("end",c._id),!h._webAudio&&f&&h.stop(c._id,!0).play(c._id),h._webAudio&&f){h._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=e.ctx.currentTime;var m=(c._stop-c._start)*1e3/Math.abs(c._rate);h._endTimers[c._id]=setTimeout(h._ended.bind(h,c),m)}return h._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,h._clearTimer(c._id),h._cleanBuffer(c._node),e._autoSuspend()),!h._webAudio&&!f&&h.stop(c._id,!0),h},_clearTimer:function(c){var h=this;if(h._endTimers[c]){if(typeof h._endTimers[c]!="function")clearTimeout(h._endTimers[c]);else{var d=h._soundById(c);d&&d._node&&d._node.removeEventListener("ended",h._endTimers[c],!1)}delete h._endTimers[c]}return h},_soundById:function(c){for(var h=this,d=0;d<h._sounds.length;d++)if(c===h._sounds[d]._id)return h._sounds[d];return null},_inactiveSound:function(){var c=this;c._drain();for(var h=0;h<c._sounds.length;h++)if(c._sounds[h]._ended)return c._sounds[h].reset();return new n(c)},_drain:function(){var c=this,h=c._pool,d=0,f=0;if(!(c._sounds.length<h)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&d++;for(f=c._sounds.length-1;f>=0;f--){if(d<=h)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),d--)}}},_getSoundIds:function(c){var h=this;if(typeof c>"u"){for(var d=[],f=0;f<h._sounds.length;f++)d.push(h._sounds[f]._id);return d}else return[c]},_refreshBuffer:function(c){var h=this;return c._node.bufferSource=e.ctx.createBufferSource(),c._node.bufferSource.buffer=i[h._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,e.ctx.currentTime),h},_cleanBuffer:function(c){var h=this,d=e._navigator&&e._navigator.vendor.indexOf("Apple")>=0;if(e._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),d))try{c.bufferSource.buffer=e._scratchBuffer}catch{}return c.bufferSource=null,h},_clearSound:function(c){var h=/MSIE |Trident\//.test(e._navigator&&e._navigator.userAgent);h||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var n=function(c){this._parent=c,this.init()};n.prototype={init:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++e._counter,h._sounds.push(c),c.create(),c},create:function(){var c=this,h=c._parent,d=e._muted||c._muted||c._parent._muted?0:c._volume;return h._webAudio?(c._node=typeof e.ctx.createGain>"u"?e.ctx.createGainNode():e.ctx.createGain(),c._node.gain.setValueAtTime(d,e.ctx.currentTime),c._node.paused=!0,c._node.connect(e.masterGain)):e.noAudio||(c._node=e._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(e._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=h._src,c._node.preload=h._preload===!0?"auto":h._preload,c._node.volume=d*e.volume(),c._node.load()),c},reset:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++e._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,h=c._parent;h._duration=Math.ceil(c._node.duration*10)/10,Object.keys(h._sprite).length===0&&(h._sprite={__default:[0,h._duration*1e3]}),h._state!=="loaded"&&(h._state="loaded",h._emit("load"),h._loadQueue()),c._node.removeEventListener(e._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,h=c._parent;h._duration===1/0&&(h._duration=Math.ceil(c._node.duration*10)/10,h._sprite.__default[1]===1/0&&(h._sprite.__default[1]=h._duration*1e3),h._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var i={},s=function(c){var h=c._src;if(i[h]){c._duration=i[h].duration,l(c);return}if(/^data:[^;]+;base64,/.test(h)){for(var d=atob(h.split(",")[1]),f=new Uint8Array(d.length),m=0;m<d.length;++m)f[m]=d.charCodeAt(m);a(f.buffer,c)}else{var p=new XMLHttpRequest;p.open(c._xhr.method,h,!0),p.withCredentials=c._xhr.withCredentials,p.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(g){p.setRequestHeader(g,c._xhr.headers[g])}),p.onload=function(){var g=(p.status+"")[0];if(g!=="0"&&g!=="2"&&g!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+p.status+".");return}a(p.response,c)},p.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete i[h],c.load())},o(p)}},o=function(c){try{c.send()}catch{c.onerror()}},a=function(c,h){var d=function(){h._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&h._sounds.length>0?(i[h._src]=m,l(h,m)):d()};typeof Promise<"u"&&e.ctx.decodeAudioData.length===1?e.ctx.decodeAudioData(c).then(f).catch(d):e.ctx.decodeAudioData(c,f,d)},l=function(c,h){h&&!c._duration&&(c._duration=h.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!e.usingWebAudio){try{typeof AudioContext<"u"?e.ctx=new AudioContext:typeof webkitAudioContext<"u"?e.ctx=new webkitAudioContext:e.usingWebAudio=!1}catch{e.usingWebAudio=!1}e.ctx||(e.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(e._navigator&&e._navigator.platform),h=e._navigator&&e._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=h?parseInt(h[1],10):null;if(c&&d&&d<9){var f=/safari/.test(e._navigator&&e._navigator.userAgent.toLowerCase());e._navigator&&!f&&(e.usingWebAudio=!1)}e.usingWebAudio&&(e.masterGain=typeof e.ctx.createGain>"u"?e.ctx.createGainNode():e.ctx.createGain(),e.masterGain.gain.setValueAtTime(e._muted?0:e._volume,e.ctx.currentTime),e.masterGain.connect(e.ctx.destination)),e._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:e,Howl:t}}),typeof wm<"u"&&(wm.Howler=e,wm.Howl=t),typeof global<"u"?(global.HowlerGlobal=r,global.Howler=e,global.Howl=t,global.Sound=n):typeof window<"u"&&(window.HowlerGlobal=r,window.Howler=e,window.Howl=t,window.Sound=n)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(e){var t=this;if(!t.ctx||!t.ctx.listener)return t;for(var n=t._howls.length-1;n>=0;n--)t._howls[n].stereo(e);return t},HowlerGlobal.prototype.pos=function(e,t,n){var i=this;if(!i.ctx||!i.ctx.listener)return i;if(t=typeof t!="number"?i._pos[1]:t,n=typeof n!="number"?i._pos[2]:n,typeof e=="number")i._pos=[e,t,n],typeof i.ctx.listener.positionX<"u"?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]);else return i._pos;return i},HowlerGlobal.prototype.orientation=function(e,t,n,i,s,o){var a=this;if(!a.ctx||!a.ctx.listener)return a;var l=a._orientation;if(t=typeof t!="number"?l[1]:t,n=typeof n!="number"?l[2]:n,i=typeof i!="number"?l[3]:i,s=typeof s!="number"?l[4]:s,o=typeof o!="number"?l[5]:o,typeof e=="number")a._orientation=[e,t,n,i,s,o],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(s,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(o,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(e,t,n,i,s,o);else return l;return a},Howl.prototype.init=function(e){return function(t){var n=this;return n._orientation=t.orientation||[1,0,0],n._stereo=t.stereo||null,n._pos=t.pos||null,n._pannerAttr={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:360,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:360,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:0,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:"inverse",maxDistance:typeof t.maxDistance<"u"?t.maxDistance:1e4,panningModel:typeof t.panningModel<"u"?t.panningModel:"HRTF",refDistance:typeof t.refDistance<"u"?t.refDistance:1,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:1},n._onstereo=t.onstereo?[{fn:t.onstereo}]:[],n._onpos=t.onpos?[{fn:t.onpos}]:[],n._onorientation=t.onorientation?[{fn:t.onorientation}]:[],e.call(this,t)}}(Howl.prototype.init),Howl.prototype.stereo=function(e,t){var n=this;if(!n._webAudio)return n;if(n._state!=="loaded")return n._queue.push({event:"stereo",action:function(){n.stereo(e,t)}}),n;var i=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof t>"u")if(typeof e=="number")n._stereo=e,n._pos=[e,0,0];else return n._stereo;for(var s=n._getSoundIds(t),o=0;o<s.length;o++){var a=n._soundById(s[o]);if(a)if(typeof e=="number")a._stereo=e,a._pos=[e,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",(!a._panner||!a._panner.pan)&&r(a,i),i==="spatial"?typeof a._panner.positionX<"u"?(a._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(e,0,0):a._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),n._emit("stereo",a._id);else return a._stereo}return n},Howl.prototype.pos=function(e,t,n,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"pos",action:function(){s.pos(e,t,n,i)}}),s;if(t=typeof t!="number"?0:t,n=typeof n!="number"?-.5:n,typeof i>"u")if(typeof e=="number")s._pos=[e,t,n];else return s._pos;for(var o=s._getSoundIds(i),a=0;a<o.length;a++){var l=s._soundById(o[a]);if(l)if(typeof e=="number")l._pos=[e,t,n],l._node&&((!l._panner||l._panner.pan)&&r(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(n,Howler.ctx.currentTime)):l._panner.setPosition(e,t,n)),s._emit("pos",l._id);else return l._pos}return s},Howl.prototype.orientation=function(e,t,n,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"orientation",action:function(){s.orientation(e,t,n,i)}}),s;if(t=typeof t!="number"?s._orientation[1]:t,n=typeof n!="number"?s._orientation[2]:n,typeof i>"u")if(typeof e=="number")s._orientation=[e,t,n];else return s._orientation;for(var o=s._getSoundIds(i),a=0;a<o.length;a++){var l=s._soundById(o[a]);if(l)if(typeof e=="number")l._orientation=[e,t,n],l._node&&(l._panner||(l._pos||(l._pos=s._pos||[0,0,-.5]),r(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(n,Howler.ctx.currentTime)):l._panner.setOrientation(e,t,n)),s._emit("orientation",l._id);else return l._orientation}return s},Howl.prototype.pannerAttr=function(){var e=this,t=arguments,n,i,s;if(!e._webAudio)return e;if(t.length===0)return e._pannerAttr;if(t.length===1)if(typeof t[0]=="object")n=t[0],typeof i>"u"&&(n.pannerAttr||(n.pannerAttr={coneInnerAngle:n.coneInnerAngle,coneOuterAngle:n.coneOuterAngle,coneOuterGain:n.coneOuterGain,distanceModel:n.distanceModel,maxDistance:n.maxDistance,refDistance:n.refDistance,rolloffFactor:n.rolloffFactor,panningModel:n.panningModel}),e._pannerAttr={coneInnerAngle:typeof n.pannerAttr.coneInnerAngle<"u"?n.pannerAttr.coneInnerAngle:e._coneInnerAngle,coneOuterAngle:typeof n.pannerAttr.coneOuterAngle<"u"?n.pannerAttr.coneOuterAngle:e._coneOuterAngle,coneOuterGain:typeof n.pannerAttr.coneOuterGain<"u"?n.pannerAttr.coneOuterGain:e._coneOuterGain,distanceModel:typeof n.pannerAttr.distanceModel<"u"?n.pannerAttr.distanceModel:e._distanceModel,maxDistance:typeof n.pannerAttr.maxDistance<"u"?n.pannerAttr.maxDistance:e._maxDistance,refDistance:typeof n.pannerAttr.refDistance<"u"?n.pannerAttr.refDistance:e._refDistance,rolloffFactor:typeof n.pannerAttr.rolloffFactor<"u"?n.pannerAttr.rolloffFactor:e._rolloffFactor,panningModel:typeof n.pannerAttr.panningModel<"u"?n.pannerAttr.panningModel:e._panningModel});else return s=e._soundById(parseInt(t[0],10)),s?s._pannerAttr:e._pannerAttr;else t.length===2&&(n=t[0],i=parseInt(t[1],10));for(var o=e._getSoundIds(i),a=0;a<o.length;a++)if(s=e._soundById(o[a]),s){var l=s._pannerAttr;l={coneInnerAngle:typeof n.coneInnerAngle<"u"?n.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof n.coneOuterAngle<"u"?n.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof n.coneOuterGain<"u"?n.coneOuterGain:l.coneOuterGain,distanceModel:typeof n.distanceModel<"u"?n.distanceModel:l.distanceModel,maxDistance:typeof n.maxDistance<"u"?n.maxDistance:l.maxDistance,refDistance:typeof n.refDistance<"u"?n.refDistance:l.refDistance,rolloffFactor:typeof n.rolloffFactor<"u"?n.rolloffFactor:l.rolloffFactor,panningModel:typeof n.panningModel<"u"?n.panningModel:l.panningModel};var u=s._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(s._pos||(s._pos=e._pos||[0,0,-.5]),r(s,"spatial"))}return e},Sound.prototype.init=function(e){return function(){var t=this,n=t._parent;t._orientation=n._orientation,t._stereo=n._stereo,t._pos=n._pos,t._pannerAttr=n._pannerAttr,e.call(this),t._stereo?n.stereo(t._stereo):t._pos&&n.pos(t._pos[0],t._pos[1],t._pos[2],t._id)}}(Sound.prototype.init),Sound.prototype.reset=function(e){return function(){var t=this,n=t._parent;return t._orientation=n._orientation,t._stereo=n._stereo,t._pos=n._pos,t._pannerAttr=n._pannerAttr,t._stereo?n.stereo(t._stereo):t._pos?n.pos(t._pos[0],t._pos[1],t._pos[2],t._id):t._panner&&(t._panner.disconnect(0),t._panner=void 0,n._refreshBuffer(t)),e.call(this)}}(Sound.prototype.reset);var r=function(e,t){t=t||"spatial",t==="spatial"?(e._panner=Howler.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,typeof e._panner.positionX<"u"?(e._panner.positionX.setValueAtTime(e._pos[0],Howler.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],Howler.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],Howler.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),typeof e._panner.orientationX<"u"?(e._panner.orientationX.setValueAtTime(e._orientation[0],Howler.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],Howler.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],Howler.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=Howler.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,Howler.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}})()});var Qo="142";var Cr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},PC=0,Wx=1,DC=2;var ff=1,Iy=2,fu=3,Gr=0,un=1,tr=2,IC=1;var Rt=0,Ns=1,jx=2,qx=3,Xx=4,LC=5,Ha=100,OC=101,RC=102,Yx=103,Qx=104,NC=200,BC=201,FC=202,UC=203,Aw=204,_w=205,GC=206,zC=207,kC=208,VC=209,HC=210,WC=0,jC=1,qC=2,jg=3,XC=4,YC=5,QC=6,ZC=7,Tw=0,KC=1,JC=2,us=0,$C=1,eP=2,tP=3,nP=4,rP=5,Mw=300,Fs=301,Us=302,qg=303,Xg=304,dl=306,Xa=1e3,er=1001,Yg=1002,Ft=1003,Zx=1004;var Kx=1005;var at=1006,iP=1007;var fl=1008;var Ut=1009,sP=1010,oP=1011,Ew=1012,aP=1013,cs=1014,Ti=1015,bu=1016,lP=1017,cP=1018,Bs=1020,uP=1021,hP=1022,si=1023,dP=1024,fP=1025,Bo=1026,Gs=1027,pP=1028,mP=1029,gP=1030,yP=1031,vP=1033,cg=33776,ug=33777,hg=33778,dg=33779,Jx=35840,$x=35841,eb=35842,tb=35843,xP=36196,nb=37492,rb=37496,ib=37808,sb=37809,ob=37810,ab=37811,lb=37812,cb=37813,ub=37814,hb=37815,db=37816,fb=37817,pb=37818,mb=37819,gb=37820,yb=37821,vb=36492;var jd=2300,qd=2301,fg=2302,xb=2400,bb=2401,wb=2402;var bP=2501;var Mr=3e3,Xe=3001,Cn=3200,Ly=3201,wP=0,SP=1;var ls="srgb",No="srgb-linear";var pg=7680;var AP=519,Qg=35044;var Sb="300 es",Zg=1035,Lt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}},Vn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Ab=1234567,mu=Math.PI/180,wu=180/Math.PI;function Mi(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vn[r&255]+Vn[r>>8&255]+Vn[r>>16&255]+Vn[r>>24&255]+"-"+Vn[e&255]+Vn[e>>8&255]+"-"+Vn[e>>16&15|64]+Vn[e>>24&255]+"-"+Vn[t&63|128]+Vn[t>>8&255]+"-"+Vn[t>>16&255]+Vn[t>>24&255]+Vn[n&255]+Vn[n>>8&255]+Vn[n>>16&255]+Vn[n>>24&255]).toLowerCase()}function pn(r,e,t){return Math.max(e,Math.min(t,r))}function Oy(r,e){return(r%e+e)%e}function _P(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function TP(r,e,t){return r!==e?(t-r)/(e-r):0}function gu(r,e,t){return(1-t)*r+t*e}function MP(r,e,t,n){return gu(r,e,1-Math.exp(-t*n))}function EP(r,e=1){return e-Math.abs(Oy(r,e*2)-e)}function CP(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function PP(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function DP(r,e){return r+Math.floor(Math.random()*(e-r+1))}function IP(r,e){return r+Math.random()*(e-r)}function LP(r){return r*(.5-Math.random())}function OP(r){r!==void 0&&(Ab=r);let e=Ab+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function RP(r){return r*mu}function NP(r){return r*wu}function Kg(r){return(r&r-1)===0&&r!==0}function BP(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Xd(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function FP(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),u=s((e+n)/2),c=o((e+n)/2),h=s((e-n)/2),d=o((e-n)/2),f=s((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":r.set(a*c,l*h,l*d,a*u);break;case"YZY":r.set(l*d,a*c,l*h,a*u);break;case"ZXZ":r.set(l*h,l*d,a*c,a*u);break;case"XZX":r.set(a*c,l*m,l*f,a*u);break;case"YXY":r.set(l*f,a*c,l*m,a*u);break;case"ZYZ":r.set(l*m,l*f,a*c,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function UP(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function GP(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}var Be=Object.freeze({__proto__:null,DEG2RAD:mu,RAD2DEG:wu,generateUUID:Mi,clamp:pn,euclideanModulo:Oy,mapLinear:_P,inverseLerp:TP,lerp:gu,damp:MP,pingpong:EP,smoothstep:CP,smootherstep:PP,randInt:DP,randFloat:IP,randFloatSpread:LP,seededRandom:OP,degToRad:RP,radToDeg:NP,isPowerOfTwo:Kg,ceilPowerOfTwo:BP,floorPowerOfTwo:Xd,setQuaternionFromProperEuler:FP,normalize:GP,denormalize:UP}),B=class{constructor(e=0,t=0){B.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},jt=class{constructor(){jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,s,o,a,l,u){let c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=n,c[7]=o,c[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],u=n[1],c=n[4],h=n[7],d=n[2],f=n[5],m=n[8],p=i[0],g=i[3],v=i[6],y=i[1],w=i[4],b=i[7],S=i[2],_=i[5],M=i[8];return s[0]=o*p+a*y+l*S,s[3]=o*g+a*w+l*_,s[6]=o*v+a*b+l*M,s[1]=u*p+c*y+h*S,s[4]=u*g+c*w+h*_,s[7]=u*v+c*b+h*M,s[2]=d*p+f*y+m*S,s[5]=d*g+f*w+m*_,s[8]=d*v+f*b+m*M,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8];return t*o*c-t*a*u-n*s*c+n*a*l+i*s*u-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=c*o-a*u,d=a*l-c*s,f=u*s-o*l,m=t*h+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let p=1/m;return e[0]=h*p,e[1]=(i*u-c*n)*p,e[2]=(a*n-i*o)*p,e[3]=d*p,e[4]=(c*t-i*l)*p,e[5]=(i*s-a*t)*p,e[6]=f*p,e[7]=(n*l-u*t)*p,e[8]=(o*t-n*s)*p,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){let l=Math.cos(s),u=Math.sin(s);return this.set(n*l,n*u,-n*(l*o+u*a)+o+e,-i*u,i*l,-i*(-u*o+l*a)+a+t,0,0,1),this}scale(e,t){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],u=i[4],c=i[7];return i[0]=t*s+n*l,i[3]=t*o+n*u,i[6]=t*a+n*c,i[1]=-n*s+t*l,i[4]=-n*o+t*u,i[7]=-n*a+t*c,this}translate(e,t){let n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};function Cw(r){for(let e=r.length-1;e>=0;--e)if(r[e]>65535)return!0;return!1}var zP={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function gd(r,e){return new zP[r](e)}function Yd(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Fo(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Wd(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var mg={[ls]:{[No]:Fo},[No]:{[ls]:Wd}},ti={legacyMode:!0,get workingColorSpace(){return No},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.legacyMode||e===t||!e||!t)return r;if(mg[e]&&mg[e][t]!==void 0){let n=mg[e][t];return r.r=n(r.r),r.g=n(r.g),r.b=n(r.b),r}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}},Pw={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dn={r:0,g:0,b:0},ni={h:0,s:0,l:0},yd={h:0,s:0,l:0};function gg(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function vd(r,e){return e.r=r.r,e.g=r.g,e.b=r.b,e}var Le=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ls){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ti.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=No){return this.r=e,this.g=t,this.b=n,ti.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=No){if(e=Oy(e,1),t=pn(t,0,1),n=pn(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=gg(o,s,e+1/3),this.g=gg(o,s,e),this.b=gg(o,s,e-1/3)}return ti.toWorkingColorSpace(this,i),this}setStyle(e,t=ls){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,ti.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,ti.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,u=parseInt(s[2],10)/100,c=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(l,u,c,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,ti.toWorkingColorSpace(this,t),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,ti.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=ls){let n=Pw[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Fo(e.r),this.g=Fo(e.g),this.b=Fo(e.b),this}copyLinearToSRGB(e){return this.r=Wd(e.r),this.g=Wd(e.g),this.b=Wd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ls){return ti.fromWorkingColorSpace(vd(this,dn),e),pn(dn.r*255,0,255)<<16^pn(dn.g*255,0,255)<<8^pn(dn.b*255,0,255)<<0}getHexString(e=ls){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=No){ti.fromWorkingColorSpace(vd(this,dn),t);let n=dn.r,i=dn.g,s=dn.b,o=Math.max(n,i,s),a=Math.min(n,i,s),l,u,c=(a+o)/2;if(a===o)l=0,u=0;else{let h=o-a;switch(u=c<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=u,e.l=c,e}getRGB(e,t=No){return ti.fromWorkingColorSpace(vd(this,dn),t),e.r=dn.r,e.g=dn.g,e.b=dn.b,e}getStyle(e=ls){return ti.fromWorkingColorSpace(vd(this,dn),e),e!==ls?`color(${e} ${dn.r} ${dn.g} ${dn.b})`:`rgb(${dn.r*255|0},${dn.g*255|0},${dn.b*255|0})`}offsetHSL(e,t,n){return this.getHSL(ni),ni.h+=e,ni.s+=t,ni.l+=n,this.setHSL(ni.h,ni.s,ni.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ni),e.getHSL(yd);let n=gu(ni.h,yd.h,t),i=gu(ni.s,yd.s,t),s=gu(ni.l,yd.l,t);return this.setHSL(n,i,s),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};Le.NAMES=Pw;var Pa,Qd=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Pa===void 0&&(Pa=Yd("canvas")),Pa.width=e.width,Pa.height=e.height;let n=Pa.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Pa}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Yd("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Fo(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Fo(t[n]/255)*255):t[n]=Fo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Zd=class{constructor(e=null){this.isSource=!0,this.uuid=Mi(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(yg(i[o].image)):s.push(yg(i[o]))}else s=yg(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function yg(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Qd.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var kP=0,Yt=class extends Lt{constructor(e=Yt.DEFAULT_IMAGE,t=Yt.DEFAULT_MAPPING,n=er,i=er,s=at,o=fl,a=si,l=Ut,u=1,c=Mr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kP++}),this.uuid=Mi(),this.name="",this.source=new Zd(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=a,this.internalFormat=null,this.type=l,this.offset=new B(0,0),this.repeat=new B(1,1),this.center=new B(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Mw)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xa:e.x=e.x-Math.floor(e.x);break;case er:e.x=e.x<0?0:1;break;case Yg:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Xa:e.y=e.y-Math.floor(e.y);break;case er:e.y=e.y<0?0:1;break;case Yg:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}};Yt.DEFAULT_IMAGE=null;Yt.DEFAULT_MAPPING=Mw;var He=class{constructor(e=0,t=0,n=0,i=1){He.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,l=e.elements,u=l[0],c=l[4],h=l[8],d=l[1],f=l[5],m=l[9],p=l[2],g=l[6],v=l[10];if(Math.abs(c-d)<.01&&Math.abs(h-p)<.01&&Math.abs(m-g)<.01){if(Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(m+g)<.1&&Math.abs(u+f+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let w=(u+1)/2,b=(f+1)/2,S=(v+1)/2,_=(c+d)/4,M=(h+p)/4,x=(m+g)/4;return w>b&&w>S?w<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(w),i=_/n,s=M/n):b>S?b<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(b),n=_/i,s=x/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=M/s,i=x/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-m)*(g-m)+(h-p)*(h-p)+(d-c)*(d-c));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(h-p)/y,this.z=(d-c)/y,this.w=Math.acos((u+f+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},dt=class extends Lt{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new He(0,0,e,t),this.scissorTest=!1,this.viewport=new He(0,0,e,t);let i={width:e,height:t,depth:1};this.texture=new Yt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:at,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Zd(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Kd=class extends Yt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ft,this.minFilter=Ft,this.wrapR=er,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Jg=class extends Yt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ft,this.minFilter=Ft,this.wrapR=er,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var nt=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,i)}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],u=n[i+1],c=n[i+2],h=n[i+3],d=s[o+0],f=s[o+1],m=s[o+2],p=s[o+3];if(a===0){e[t+0]=l,e[t+1]=u,e[t+2]=c,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=m,e[t+3]=p;return}if(h!==p||l!==d||u!==f||c!==m){let g=1-a,v=l*d+u*f+c*m+h*p,y=v>=0?1:-1,w=1-v*v;if(w>Number.EPSILON){let S=Math.sqrt(w),_=Math.atan2(S,v*y);g=Math.sin(g*_)/S,a=Math.sin(a*_)/S}let b=a*y;if(l=l*g+d*b,u=u*g+f*b,c=c*g+m*b,h=h*g+p*b,g===1-a){let S=1/Math.sqrt(l*l+u*u+c*c+h*h);l*=S,u*=S,c*=S,h*=S}}e[t]=l,e[t+1]=u,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],u=n[i+2],c=n[i+3],h=s[o],d=s[o+1],f=s[o+2],m=s[o+3];return e[t]=a*m+c*h+l*f-u*d,e[t+1]=l*m+c*d+u*h-a*f,e[t+2]=u*m+c*f+a*d-l*h,e[t+3]=c*m-a*h-l*d-u*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,u=a(n/2),c=a(i/2),h=a(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=d*c*h+u*f*m,this._y=u*f*h-d*c*m,this._z=u*c*m+d*f*h,this._w=u*c*h-d*f*m;break;case"YXZ":this._x=d*c*h+u*f*m,this._y=u*f*h-d*c*m,this._z=u*c*m-d*f*h,this._w=u*c*h+d*f*m;break;case"ZXY":this._x=d*c*h-u*f*m,this._y=u*f*h+d*c*m,this._z=u*c*m+d*f*h,this._w=u*c*h-d*f*m;break;case"ZYX":this._x=d*c*h-u*f*m,this._y=u*f*h+d*c*m,this._z=u*c*m-d*f*h,this._w=u*c*h+d*f*m;break;case"YZX":this._x=d*c*h+u*f*m,this._y=u*f*h+d*c*m,this._z=u*c*m-d*f*h,this._w=u*c*h-d*f*m;break;case"XZY":this._x=d*c*h-u*f*m,this._y=u*f*h-d*c*m,this._z=u*c*m+d*f*h,this._w=u*c*h+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],u=t[2],c=t[6],h=t[10],d=n+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(c-l)*f,this._y=(s-u)*f,this._z=(o-i)*f}else if(n>a&&n>h){let f=2*Math.sqrt(1+n-a-h);this._w=(c-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+u)/f}else if(a>h){let f=2*Math.sqrt(1+a-n-h);this._w=(s-u)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+c)/f}else{let f=2*Math.sqrt(1+h-n-a);this._w=(o-i)/f,this._x=(s+u)/f,this._y=(l+c)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(pn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,u=t._z,c=t._w;return this._x=n*c+o*a+i*u-s*l,this._y=i*c+o*l+s*a-n*u,this._z=s*c+o*u+n*l-i*a,this._w=o*c-n*a-i*l-s*u,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let u=Math.sqrt(l),c=Math.atan2(u,a),h=Math.sin((1-t)*c)/u,d=Math.sin(t*c)/u;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},A=class{constructor(e=0,t=0,n=0){A.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(_b.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_b.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,u=l*t+o*i-a*n,c=l*n+a*t-s*i,h=l*i+s*n-o*t,d=-s*t-o*n-a*i;return this.x=u*l+d*-s+c*-a-h*-o,this.y=c*l+d*-o+h*-s-u*-a,this.z=h*l+d*-a+u*-o-c*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return vg.copy(this).projectOnVector(e),this.sub(vg)}reflect(e){return this.sub(vg.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(pn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},vg=new A,_b=new nt,Mt=class{constructor(e=new A(1/0,1/0,1/0),t=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=e.length;l<u;l+=3){let c=e[l],h=e[l+1],d=e[l+2];c<t&&(t=c),h<n&&(n=h),d<i&&(i=d),c>s&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=e.count;l<u;l++){let c=e.getX(l),h=e.getY(l),d=e.getZ(l);c<t&&(t=c),h<n&&(n=h),d<i&&(i=d),c>s&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Do.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0)if(t&&n.attributes!=null&&n.attributes.position!==void 0){let s=n.attributes.position;for(let o=0,a=s.count;o<a;o++)Do.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(Do)}else n.boundingBox===null&&n.computeBoundingBox(),xg.copy(n.boundingBox),xg.applyMatrix4(e.matrixWorld),this.union(xg);let i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Do),Do.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(cu),xd.subVectors(this.max,cu),Da.subVectors(e.a,cu),Ia.subVectors(e.b,cu),La.subVectors(e.c,cu),Es.subVectors(Ia,Da),Cs.subVectors(La,Ia),Io.subVectors(Da,La);let t=[0,-Es.z,Es.y,0,-Cs.z,Cs.y,0,-Io.z,Io.y,Es.z,0,-Es.x,Cs.z,0,-Cs.x,Io.z,0,-Io.x,-Es.y,Es.x,0,-Cs.y,Cs.x,0,-Io.y,Io.x,0];return!bg(t,Da,Ia,La,xd)||(t=[1,0,0,0,1,0,0,0,1],!bg(t,Da,Ia,La,xd))?!1:(bd.crossVectors(Es,Cs),t=[bd.x,bd.y,bd.z],bg(t,Da,Ia,La,xd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Do.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Do).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ns[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ns[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ns[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ns[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ns[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ns[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ns[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ns[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ns),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},ns=[new A,new A,new A,new A,new A,new A,new A,new A],Do=new A,xg=new Mt,Da=new A,Ia=new A,La=new A,Es=new A,Cs=new A,Io=new A,cu=new A,xd=new A,bd=new A,Lo=new A;function bg(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Lo.fromArray(r,s);let a=i.x*Math.abs(Lo.x)+i.y*Math.abs(Lo.y)+i.z*Math.abs(Lo.z),l=e.dot(Lo),u=t.dot(Lo),c=n.dot(Lo);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>a)return!1}return!0}var VP=new Mt,Tb=new A,wd=new A,wg=new A,En=class{constructor(e=new A,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):VP.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){wg.subVectors(e,this.center);let t=wg.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(wg.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?wd.set(0,0,1).multiplyScalar(e.radius):wd.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Tb.copy(e.center).add(wd)),this.expandByPoint(Tb.copy(e.center).sub(wd)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},rs=new A,Sg=new A,Sd=new A,Ps=new A,Ag=new A,Ad=new A,_g=new A,oi=class{constructor(e=new A,t=new A(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,rs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=rs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(rs.copy(this.direction).multiplyScalar(t).add(this.origin),rs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Sg.copy(e).add(t).multiplyScalar(.5),Sd.copy(t).sub(e).normalize(),Ps.copy(this.origin).sub(Sg);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Sd),a=Ps.dot(this.direction),l=-Ps.dot(Sd),u=Ps.lengthSq(),c=Math.abs(1-o*o),h,d,f,m;if(c>0)if(h=o*l-a,d=o*a-l,m=s*c,h>=0)if(d>=-m)if(d<=m){let p=1/c;h*=p,d*=p,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+u}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d<=-m?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+u):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+u):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+u);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(Sd).multiplyScalar(d).add(Sg),f}intersectSphere(e,t){rs.subVectors(e.center,this.origin);let n=rs.dot(this.direction),i=rs.dot(rs)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return u>=0?(n=(e.min.x-d.x)*u,i=(e.max.x-d.x)*u):(n=(e.max.x-d.x)*u,i=(e.min.x-d.x)*u),c>=0?(s=(e.min.y-d.y)*c,o=(e.max.y-d.y)*c):(s=(e.max.y-d.y)*c,o=(e.min.y-d.y)*c),n>o||s>i||((s>n||n!==n)&&(n=s),(o<i||i!==i)&&(i=o),h>=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,rs)!==null}intersectTriangle(e,t,n,i,s){Ag.subVectors(t,e),Ad.subVectors(n,e),_g.crossVectors(Ag,Ad);let o=this.direction.dot(_g),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ps.subVectors(this.origin,e);let l=a*this.direction.dot(Ad.crossVectors(Ps,Ad));if(l<0)return null;let u=a*this.direction.dot(Ag.cross(Ps));if(u<0||l+u>o)return null;let c=-a*Ps.dot(_g);return c<0?null:this.at(c/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},be=class{constructor(){be.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,s,o,a,l,u,c,h,d,f,m,p,g){let v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=s,v[5]=o,v[9]=a,v[13]=l,v[2]=u,v[6]=c,v[10]=h,v[14]=d,v[3]=f,v[7]=m,v[11]=p,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new be().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/Oa.setFromMatrixColumn(e,0).length(),s=1/Oa.setFromMatrixColumn(e,1).length(),o=1/Oa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),u=Math.sin(i),c=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=o*c,f=o*h,m=a*c,p=a*h;t[0]=l*c,t[4]=-l*h,t[8]=u,t[1]=f+m*u,t[5]=d-p*u,t[9]=-a*l,t[2]=p-d*u,t[6]=m+f*u,t[10]=o*l}else if(e.order==="YXZ"){let d=l*c,f=l*h,m=u*c,p=u*h;t[0]=d+p*a,t[4]=m*a-f,t[8]=o*u,t[1]=o*h,t[5]=o*c,t[9]=-a,t[2]=f*a-m,t[6]=p+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*c,f=l*h,m=u*c,p=u*h;t[0]=d-p*a,t[4]=-o*h,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*c,t[9]=p-d*a,t[2]=-o*u,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*c,f=o*h,m=a*c,p=a*h;t[0]=l*c,t[4]=m*u-f,t[8]=d*u+p,t[1]=l*h,t[5]=p*u+d,t[9]=f*u-m,t[2]=-u,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,f=o*u,m=a*l,p=a*u;t[0]=l*c,t[4]=p-d*h,t[8]=m*h+f,t[1]=h,t[5]=o*c,t[9]=-a*c,t[2]=-u*c,t[6]=f*h+m,t[10]=d-p*h}else if(e.order==="XZY"){let d=o*l,f=o*u,m=a*l,p=a*u;t[0]=l*c,t[4]=-h,t[8]=u*c,t[1]=d*h+p,t[5]=o*c,t[9]=f*h-m,t[2]=m*h-f,t[6]=a*c,t[10]=p*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(HP,e,WP)}lookAt(e,t,n){let i=this.elements;return _r.subVectors(e,t),_r.lengthSq()===0&&(_r.z=1),_r.normalize(),Ds.crossVectors(n,_r),Ds.lengthSq()===0&&(Math.abs(n.z)===1?_r.x+=1e-4:_r.z+=1e-4,_r.normalize(),Ds.crossVectors(n,_r)),Ds.normalize(),_d.crossVectors(_r,Ds),i[0]=Ds.x,i[4]=_d.x,i[8]=_r.x,i[1]=Ds.y,i[5]=_d.y,i[9]=_r.y,i[2]=Ds.z,i[6]=_d.z,i[10]=_r.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],u=n[12],c=n[1],h=n[5],d=n[9],f=n[13],m=n[2],p=n[6],g=n[10],v=n[14],y=n[3],w=n[7],b=n[11],S=n[15],_=i[0],M=i[4],x=i[8],T=i[12],E=i[1],C=i[5],P=i[9],O=i[13],I=i[2],N=i[6],F=i[10],G=i[14],Y=i[3],U=i[7],z=i[11],Q=i[15];return s[0]=o*_+a*E+l*I+u*Y,s[4]=o*M+a*C+l*N+u*U,s[8]=o*x+a*P+l*F+u*z,s[12]=o*T+a*O+l*G+u*Q,s[1]=c*_+h*E+d*I+f*Y,s[5]=c*M+h*C+d*N+f*U,s[9]=c*x+h*P+d*F+f*z,s[13]=c*T+h*O+d*G+f*Q,s[2]=m*_+p*E+g*I+v*Y,s[6]=m*M+p*C+g*N+v*U,s[10]=m*x+p*P+g*F+v*z,s[14]=m*T+p*O+g*G+v*Q,s[3]=y*_+w*E+b*I+S*Y,s[7]=y*M+w*C+b*N+S*U,s[11]=y*x+w*P+b*F+S*z,s[15]=y*T+w*O+b*G+S*Q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],u=e[13],c=e[2],h=e[6],d=e[10],f=e[14],m=e[3],p=e[7],g=e[11],v=e[15];return m*(+s*l*h-i*u*h-s*a*d+n*u*d+i*a*f-n*l*f)+p*(+t*l*f-t*u*d+s*o*d-i*o*f+i*u*c-s*l*c)+g*(+t*u*h-t*a*f-s*o*h+n*o*f+s*a*c-n*u*c)+v*(-i*a*c-t*l*h+t*a*d+i*o*h-n*o*d+n*l*c)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],f=e[11],m=e[12],p=e[13],g=e[14],v=e[15],y=h*g*u-p*d*u+p*l*f-a*g*f-h*l*v+a*d*v,w=m*d*u-c*g*u-m*l*f+o*g*f+c*l*v-o*d*v,b=c*p*u-m*h*u+m*a*f-o*p*f-c*a*v+o*h*v,S=m*h*l-c*p*l-m*a*d+o*p*d+c*a*g-o*h*g,_=t*y+n*w+i*b+s*S;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/_;return e[0]=y*M,e[1]=(p*d*s-h*g*s-p*i*f+n*g*f+h*i*v-n*d*v)*M,e[2]=(a*g*s-p*l*s+p*i*u-n*g*u-a*i*v+n*l*v)*M,e[3]=(h*l*s-a*d*s-h*i*u+n*d*u+a*i*f-n*l*f)*M,e[4]=w*M,e[5]=(c*g*s-m*d*s+m*i*f-t*g*f-c*i*v+t*d*v)*M,e[6]=(m*l*s-o*g*s-m*i*u+t*g*u+o*i*v-t*l*v)*M,e[7]=(o*d*s-c*l*s+c*i*u-t*d*u-o*i*f+t*l*f)*M,e[8]=b*M,e[9]=(m*h*s-c*p*s-m*n*f+t*p*f+c*n*v-t*h*v)*M,e[10]=(o*p*s-m*a*s+m*n*u-t*p*u-o*n*v+t*a*v)*M,e[11]=(c*a*s-o*h*s-c*n*u+t*h*u+o*n*f-t*a*f)*M,e[12]=S*M,e[13]=(c*p*i-m*h*i+m*n*d-t*p*d-c*n*g+t*h*g)*M,e[14]=(m*a*i-o*p*i-m*n*l+t*p*l+o*n*g-t*a*g)*M,e[15]=(o*h*i-c*a*i+c*n*l-t*h*l-o*n*d+t*a*d)*M,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,u=s*o,c=s*a;return this.set(u*o+n,u*a-i*l,u*l+i*a,0,u*a+i*l,c*a+n,c*l-i*o,0,u*l-i*a,c*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,u=s+s,c=o+o,h=a+a,d=s*u,f=s*c,m=s*h,p=o*c,g=o*h,v=a*h,y=l*u,w=l*c,b=l*h,S=n.x,_=n.y,M=n.z;return i[0]=(1-(p+v))*S,i[1]=(f+b)*S,i[2]=(m-w)*S,i[3]=0,i[4]=(f-b)*_,i[5]=(1-(d+v))*_,i[6]=(g+y)*_,i[7]=0,i[8]=(m+w)*M,i[9]=(g-y)*M,i[10]=(1-(d+p))*M,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=Oa.set(i[0],i[1],i[2]).length(),o=Oa.set(i[4],i[5],i[6]).length(),a=Oa.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],ri.copy(this);let u=1/s,c=1/o,h=1/a;return ri.elements[0]*=u,ri.elements[1]*=u,ri.elements[2]*=u,ri.elements[4]*=c,ri.elements[5]*=c,ri.elements[6]*=c,ri.elements[8]*=h,ri.elements[9]*=h,ri.elements[10]*=h,t.setFromRotationMatrix(ri),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,l=2*s/(t-e),u=2*s/(n-i),c=(t+e)/(t-e),h=(n+i)/(n-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=u,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,s,o){let a=this.elements,l=1/(t-e),u=1/(n-i),c=1/(o-s),h=(t+e)*l,d=(n+i)*u,f=(o+s)*c;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*u,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Oa=new A,ri=new be,HP=new A(0,0,0),WP=new A(1,1,1),Ds=new A,_d=new A,_r=new A,Mb=new be,Eb=new nt,Qt=class{constructor(e=0,t=0,n=0,i=Qt.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],u=i[5],c=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(pn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-pn(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(pn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-pn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(pn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-pn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Mb.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Mb,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Eb.setFromEuler(this),this.setFromQuaternion(Eb,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}};Qt.DefaultOrder="XYZ";Qt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var Su=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},jP=0,Cb=new A,Ra=new nt,is=new be,Td=new A,uu=new A,qP=new A,XP=new nt,Pb=new A(1,0,0),Db=new A(0,1,0),Ib=new A(0,0,1),YP={type:"added"},Lb={type:"removed"},ht=class extends Lt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jP++}),this.uuid=Mi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ht.DefaultUp.clone();let e=new A,t=new Qt,n=new nt,i=new A(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new be},normalMatrix:{value:new jt}}),this.matrix=new be,this.matrixWorld=new be,this.matrixAutoUpdate=ht.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Su,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ra.setFromAxisAngle(e,t),this.quaternion.multiply(Ra),this}rotateOnWorldAxis(e,t){return Ra.setFromAxisAngle(e,t),this.quaternion.premultiply(Ra),this}rotateX(e){return this.rotateOnAxis(Pb,e)}rotateY(e){return this.rotateOnAxis(Db,e)}rotateZ(e){return this.rotateOnAxis(Ib,e)}translateOnAxis(e,t){return Cb.copy(e).applyQuaternion(this.quaternion),this.position.add(Cb.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pb,e)}translateY(e){return this.translateOnAxis(Db,e)}translateZ(e){return this.translateOnAxis(Ib,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(is.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Td.copy(e):Td.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),uu.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?is.lookAt(uu,Td,this.up):is.lookAt(Td,uu,this.up),this.quaternion.setFromRotationMatrix(is),i&&(is.extractRotation(i.matrixWorld),Ra.setFromRotationMatrix(is),this.quaternion.premultiply(Ra.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(YP)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Lb)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(Lb)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),is.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),is.multiply(e.parent.matrixWorld)),e.applyMatrix4(is),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uu,e,qP),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uu,XP,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let u=0,c=l.length;u<c;u++){let h=l[u];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,u=this.material.length;l<u;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),u=o(e.textures),c=o(e.images),h=o(e.shapes),d=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),u.length>0&&(n.textures=u),c.length>0&&(n.images=c),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){let l=[];for(let u in a){let c=a[u];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};ht.DefaultUp=new A(0,1,0);ht.DefaultMatrixAutoUpdate=!0;var ii=new A,ss=new A,Tg=new A,os=new A,Na=new A,Ba=new A,Ob=new A,Mg=new A,Eg=new A,Cg=new A,Mn=class{constructor(e=new A,t=new A,n=new A){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ii.subVectors(e,t),i.cross(ii);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){ii.subVectors(i,t),ss.subVectors(n,t),Tg.subVectors(e,t);let o=ii.dot(ii),a=ii.dot(ss),l=ii.dot(Tg),u=ss.dot(ss),c=ss.dot(Tg),h=o*u-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(u*l-a*c)*d,m=(o*c-a*l)*d;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,os),os.x>=0&&os.y>=0&&os.x+os.y<=1}static getUV(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,os),l.set(0,0),l.addScaledVector(s,os.x),l.addScaledVector(o,os.y),l.addScaledVector(a,os.z),l}static isFrontFacing(e,t,n,i){return ii.subVectors(n,t),ss.subVectors(e,t),ii.cross(ss).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ii.subVectors(this.c,this.b),ss.subVectors(this.a,this.b),ii.cross(ss).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Mn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Mn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Mn.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Mn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Mn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;Na.subVectors(i,n),Ba.subVectors(s,n),Mg.subVectors(e,n);let l=Na.dot(Mg),u=Ba.dot(Mg);if(l<=0&&u<=0)return t.copy(n);Eg.subVectors(e,i);let c=Na.dot(Eg),h=Ba.dot(Eg);if(c>=0&&h<=c)return t.copy(i);let d=l*h-c*u;if(d<=0&&l>=0&&c<=0)return o=l/(l-c),t.copy(n).addScaledVector(Na,o);Cg.subVectors(e,s);let f=Na.dot(Cg),m=Ba.dot(Cg);if(m>=0&&f<=m)return t.copy(s);let p=f*u-l*m;if(p<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(Ba,a);let g=c*m-f*h;if(g<=0&&h-c>=0&&f-m>=0)return Ob.subVectors(s,i),a=(h-c)/(h-c+(f-m)),t.copy(i).addScaledVector(Ob,a);let v=1/(g+p+d);return o=p*v,a=d*v,t.copy(n).addScaledVector(Na,o).addScaledVector(Ba,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},QP=0,Uo=class extends Lt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:QP++}),this.uuid=Mi(),this.name="",this.type="Material",this.blending=Ns,this.side=Gr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Aw,this.blendDst=_w,this.blendEquation=Ha,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=jg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AP,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pg,this.stencilZFail=pg,this.stencilZPass=pg,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===IC;continue}let i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ns&&(n.blending=this.blending),this.side!==Gr&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Au=class extends Uo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Le(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Tw,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},cn=new A,Md=new B,Ge=class{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=Qg,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new Le),t[n++]=o.r,t[n++]=o.g,t[n++]=o.b}return this}copyVector2sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new B),t[n++]=o.x,t[n++]=o.y}return this}copyVector3sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new A),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z}return this}copyVector4sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new He),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z,t[n++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Md.fromBufferAttribute(this,t),Md.applyMatrix3(e),this.setXY(t,Md.x,Md.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Qg&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}};var Jd=class extends Ge{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var zs=class extends Ge{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Ae=class extends Ge{constructor(e,t,n){super(new Float32Array(e),t,n)}};var ZP=0,Ur=new be,Pg=new ht,Fa=new A,Tr=new Mt,hu=new Mt,Tn=new A,De=class extends Lt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ZP++}),this.uuid=Mi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Cw(e)?zs:Jd)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new jt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ur.makeRotationFromQuaternion(e),this.applyMatrix4(Ur),this}rotateX(e){return Ur.makeRotationX(e),this.applyMatrix4(Ur),this}rotateY(e){return Ur.makeRotationY(e),this.applyMatrix4(Ur),this}rotateZ(e){return Ur.makeRotationZ(e),this.applyMatrix4(Ur),this}translate(e,t,n){return Ur.makeTranslation(e,t,n),this.applyMatrix4(Ur),this}scale(e,t,n){return Ur.makeScale(e,t,n),this.applyMatrix4(Ur),this}lookAt(e){return Pg.lookAt(e),Pg.updateMatrix(),this.applyMatrix4(Pg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fa).negate(),this.translate(Fa.x,Fa.y,Fa.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n<i;n++){let s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Ae(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];Tr.setFromBufferAttribute(s),this.morphTargetsRelative?(Tn.addVectors(this.boundingBox.min,Tr.min),this.boundingBox.expandByPoint(Tn),Tn.addVectors(this.boundingBox.max,Tr.max),this.boundingBox.expandByPoint(Tn)):(this.boundingBox.expandByPoint(Tr.min),this.boundingBox.expandByPoint(Tr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new En);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new A,1/0);return}if(e){let n=this.boundingSphere.center;if(Tr.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];hu.setFromBufferAttribute(a),this.morphTargetsRelative?(Tn.addVectors(Tr.min,hu.min),Tr.expandByPoint(Tn),Tn.addVectors(Tr.max,hu.max),Tr.expandByPoint(Tn)):(Tr.expandByPoint(hu.min),Tr.expandByPoint(hu.max))}Tr.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Tn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Tn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let u=0,c=a.count;u<c;u++)Tn.fromBufferAttribute(a,u),l&&(Fa.fromBufferAttribute(e,u),Tn.add(Fa)),i=Math.max(i,n.distanceToSquared(Tn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ge(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,u=[],c=[];for(let E=0;E<a;E++)u[E]=new A,c[E]=new A;let h=new A,d=new A,f=new A,m=new B,p=new B,g=new B,v=new A,y=new A;function w(E,C,P){h.fromArray(i,E*3),d.fromArray(i,C*3),f.fromArray(i,P*3),m.fromArray(o,E*2),p.fromArray(o,C*2),g.fromArray(o,P*2),d.sub(h),f.sub(h),p.sub(m),g.sub(m);let O=1/(p.x*g.y-g.x*p.y);!isFinite(O)||(v.copy(d).multiplyScalar(g.y).addScaledVector(f,-p.y).multiplyScalar(O),y.copy(f).multiplyScalar(p.x).addScaledVector(d,-g.x).multiplyScalar(O),u[E].add(v),u[C].add(v),u[P].add(v),c[E].add(y),c[C].add(y),c[P].add(y))}let b=this.groups;b.length===0&&(b=[{start:0,count:n.length}]);for(let E=0,C=b.length;E<C;++E){let P=b[E],O=P.start,I=P.count;for(let N=O,F=O+I;N<F;N+=3)w(n[N+0],n[N+1],n[N+2])}let S=new A,_=new A,M=new A,x=new A;function T(E){M.fromArray(s,E*3),x.copy(M);let C=u[E];S.copy(C),S.sub(M.multiplyScalar(M.dot(C))).normalize(),_.crossVectors(x,C);let O=_.dot(c[E])<0?-1:1;l[E*4]=S.x,l[E*4+1]=S.y,l[E*4+2]=S.z,l[E*4+3]=O}for(let E=0,C=b.length;E<C;++E){let P=b[E],O=P.start,I=P.count;for(let N=O,F=O+I;N<F;N+=3)T(n[N+0]),T(n[N+1]),T(n[N+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Ge(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new A,s=new A,o=new A,a=new A,l=new A,u=new A,c=new A,h=new A;if(e)for(let d=0,f=e.count;d<f;d+=3){let m=e.getX(d+0),p=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,p),o.fromBufferAttribute(t,g),c.subVectors(o,s),h.subVectors(i,s),c.cross(h),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,p),u.fromBufferAttribute(n,g),a.add(c),l.add(c),u.add(c),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(p,l.x,l.y,l.z),n.setXYZ(g,u.x,u.y,u.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),c.subVectors(o,s),h.subVectors(i,s),c.cross(h),n.setXYZ(d+0,c.x,c.y,c.z),n.setXYZ(d+1,c.x,c.y,c.z),n.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let n=this.attributes;for(let i in n){if(e.attributes[i]===void 0)continue;let o=n[i].array,a=e.attributes[i],l=a.array,u=a.itemSize*t,c=Math.min(l.length,o.length-u);for(let h=0,d=u;h<c;h++,d++)o[d]=l[h]}return this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Tn.fromBufferAttribute(e,t),Tn.normalize(),e.setXYZ(t,Tn.x,Tn.y,Tn.z)}toNonIndexed(){function e(a,l){let u=a.array,c=a.itemSize,h=a.normalized,d=new u.constructor(l.length*c),f=0,m=0;for(let p=0,g=l.length;p<g;p++){a.isInterleavedBufferAttribute?f=l[p]*a.data.stride+a.offset:f=l[p]*c;for(let v=0;v<c;v++)d[m++]=u[f++]}return new Ge(d,c,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new De,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],u=e(l,n);t.setAttribute(a,u)}let s=this.morphAttributes;for(let a in s){let l=[],u=s[a];for(let c=0,h=u.length;c<h;c++){let d=u[c],f=e(d,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let u=o[a];t.addGroup(u.start,u.count,u.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let u in l)l[u]!==void 0&&(e[u]=l[u]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let u=n[l];e.data.attributes[l]=u.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let u=this.morphAttributes[l],c=[];for(let h=0,d=u.length;h<d;h++){let f=u[h];c.push(f.toJSON(e.data))}c.length>0&&(i[l]=c,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let u in i){let c=i[u];this.setAttribute(u,c.clone(t))}let s=e.morphAttributes;for(let u in s){let c=[],h=s[u];for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone(t));this.morphAttributes[u]=c}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let u=0,c=o.length;u<c;u++){let h=o[u];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},Rb=new be,Ua=new oi,Dg=new En,Is=new A,Ls=new A,Os=new A,Ig=new A,Lg=new A,Og=new A,Ed=new A,Cd=new A,Pd=new A,Dd=new B,Id=new B,Ld=new B,Rg=new A,Od=new A,rn=class extends ht{constructor(e=new De,t=new Au){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Dg.copy(n.boundingSphere),Dg.applyMatrix4(s),e.ray.intersectsSphere(Dg)===!1)||(Rb.copy(s).invert(),Ua.copy(e.ray).applyMatrix4(Rb),n.boundingBox!==null&&Ua.intersectsBox(n.boundingBox)===!1))return;let o,a=n.index,l=n.attributes.position,u=n.morphAttributes.position,c=n.morphTargetsRelative,h=n.attributes.uv,d=n.attributes.uv2,f=n.groups,m=n.drawRange;if(a!==null)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let v=f[p],y=i[v.materialIndex],w=Math.max(v.start,m.start),b=Math.min(a.count,Math.min(v.start+v.count,m.start+m.count));for(let S=w,_=b;S<_;S+=3){let M=a.getX(S),x=a.getX(S+1),T=a.getX(S+2);o=Rd(this,y,e,Ua,l,u,c,h,d,M,x,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=v.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(a.count,m.start+m.count);for(let v=p,y=g;v<y;v+=3){let w=a.getX(v),b=a.getX(v+1),S=a.getX(v+2);o=Rd(this,i,e,Ua,l,u,c,h,d,w,b,S),o&&(o.faceIndex=Math.floor(v/3),t.push(o))}}else if(l!==void 0)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let v=f[p],y=i[v.materialIndex],w=Math.max(v.start,m.start),b=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let S=w,_=b;S<_;S+=3){let M=S,x=S+1,T=S+2;o=Rd(this,y,e,Ua,l,u,c,h,d,M,x,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=v.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(l.count,m.start+m.count);for(let v=p,y=g;v<y;v+=3){let w=v,b=v+1,S=v+2;o=Rd(this,i,e,Ua,l,u,c,h,d,w,b,S),o&&(o.faceIndex=Math.floor(v/3),t.push(o))}}}};function KP(r,e,t,n,i,s,o,a){let l;if(e.side===un?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side!==tr,a),l===null)return null;Od.copy(a),Od.applyMatrix4(r.matrixWorld);let u=t.ray.origin.distanceTo(Od);return u<t.near||u>t.far?null:{distance:u,point:Od.clone(),object:r}}function Rd(r,e,t,n,i,s,o,a,l,u,c,h){Is.fromBufferAttribute(i,u),Ls.fromBufferAttribute(i,c),Os.fromBufferAttribute(i,h);let d=r.morphTargetInfluences;if(s&&d){Ed.set(0,0,0),Cd.set(0,0,0),Pd.set(0,0,0);for(let m=0,p=s.length;m<p;m++){let g=d[m],v=s[m];g!==0&&(Ig.fromBufferAttribute(v,u),Lg.fromBufferAttribute(v,c),Og.fromBufferAttribute(v,h),o?(Ed.addScaledVector(Ig,g),Cd.addScaledVector(Lg,g),Pd.addScaledVector(Og,g)):(Ed.addScaledVector(Ig.sub(Is),g),Cd.addScaledVector(Lg.sub(Ls),g),Pd.addScaledVector(Og.sub(Os),g)))}Is.add(Ed),Ls.add(Cd),Os.add(Pd)}r.isSkinnedMesh&&(r.boneTransform(u,Is),r.boneTransform(c,Ls),r.boneTransform(h,Os));let f=KP(r,e,t,n,Is,Ls,Os,Rg);if(f){a&&(Dd.fromBufferAttribute(a,u),Id.fromBufferAttribute(a,c),Ld.fromBufferAttribute(a,h),f.uv=Mn.getUV(Rg,Is,Ls,Os,Dd,Id,Ld,new B)),l&&(Dd.fromBufferAttribute(l,u),Id.fromBufferAttribute(l,c),Ld.fromBufferAttribute(l,h),f.uv2=Mn.getUV(Rg,Is,Ls,Os,Dd,Id,Ld,new B));let m={a:u,b:c,c:h,normal:new A,materialIndex:0};Mn.getNormal(Is,Ls,Os,m.normal),f.face=m}return f}var ur=class extends De{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],u=[],c=[],h=[],d=0,f=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function m(p,g,v,y,w,b,S,_,M,x,T){let E=b/M,C=S/x,P=b/2,O=S/2,I=_/2,N=M+1,F=x+1,G=0,Y=0,U=new A;for(let z=0;z<F;z++){let Q=z*C-O;for(let V=0;V<N;V++){let k=V*E-P;U[p]=k*y,U[g]=Q*w,U[v]=I,u.push(U.x,U.y,U.z),U[p]=0,U[g]=0,U[v]=_>0?1:-1,c.push(U.x,U.y,U.z),h.push(V/M),h.push(1-z/x),G+=1}}for(let z=0;z<x;z++)for(let Q=0;Q<M;Q++){let V=d+Q+N*z,k=d+Q+N*(z+1),j=d+(Q+1)+N*(z+1),q=d+(Q+1)+N*z;l.push(V,k,q),l.push(k,j,q),Y+=6}a.addGroup(f,Y,T),f+=Y,d+=G}}static fromJSON(e){return new ur(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Ya(r){let e={};for(let t in r){e[t]={};for(let n in r[t]){let i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Hn(r){let e={};for(let t=0;t<r.length;t++){let n=Ya(r[t]);for(let i in n)e[i]=n[i]}return e}var ci={clone:Ya,merge:Hn},JP=`void main() {
1
+ var SC=Object.create;var lg=Object.defineProperty;var AC=Object.getOwnPropertyDescriptor;var _C=Object.getOwnPropertyNames;var TC=Object.getPrototypeOf,MC=Object.prototype.hasOwnProperty;var Vx=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),EC=(r,e)=>{for(var t in e)lg(r,t,{get:e[t],enumerable:!0})},CC=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _C(e))!MC.call(r,i)&&i!==t&&lg(r,i,{get:()=>e[i],enumerable:!(n=AC(e,i))||n.enumerable});return r};var Hx=(r,e,t)=>(t=r!=null?SC(TC(r)):{},CC(e||!r||!r.__esModule?lg(t,"default",{value:r,enumerable:!0}):t,r));var gM=Vx((fm,mM)=>{(function(r,e){typeof fm=="object"&&typeof mM<"u"?e(fm):typeof define=="function"&&define.amd?define(["exports"],e):e((r=typeof globalThis<"u"?globalThis:r||self).SVDJS={})})(fm,function(r){"use strict";r.SVD=function(e,t,n,i,s){if(t=t===void 0||t,n=n===void 0||n,s=1e-64/(i=i||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var o,a,l,u,c,h,d,f,m,p,g,v,y=e[0].length,b=e.length;if(b<y)throw new TypeError("Invalid matrix: m < n");for(var w=[],S=[],_=[],M=t==="f"?b:y,x=p=d=0;x<b;x++)S[x]=new Array(M).fill(0);for(x=0;x<y;x++)_[x]=new Array(y).fill(0);var T,E=new Array(y).fill(0);for(x=0;x<b;x++)for(o=0;o<y;o++)S[x][o]=e[x][o];for(x=0;x<y;x++){for(w[x]=d,m=0,l=x+1,o=x;o<b;o++)m+=Math.pow(S[o][x],2);if(m<s)d=0;else for(f=(h=S[x][x])*(d=h<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x]=h-d,o=l;o<y;o++){for(m=0,a=x;a<b;a++)m+=S[a][x]*S[a][o];for(h=m/f,a=x;a<b;a++)S[a][o]=S[a][o]+h*S[a][x]}for(E[x]=d,m=0,o=l;o<y;o++)m+=Math.pow(S[x][o],2);if(m<s)d=0;else{for(f=(h=S[x][x+1])*(d=h<0?Math.sqrt(m):-Math.sqrt(m))-m,S[x][x+1]=h-d,o=l;o<y;o++)w[o]=S[x][o]/f;for(o=l;o<b;o++){for(m=0,a=l;a<y;a++)m+=S[o][a]*S[x][a];for(a=l;a<y;a++)S[o][a]=S[o][a]+m*w[a]}}p<(g=Math.abs(E[x])+Math.abs(w[x]))&&(p=g)}if(n)for(x=y-1;0<=x;x--){if(d!==0){for(f=S[x][x+1]*d,o=l;o<y;o++)_[o][x]=S[x][o]/f;for(o=l;o<y;o++){for(m=0,a=l;a<y;a++)m+=S[x][a]*_[a][o];for(a=l;a<y;a++)_[a][o]=_[a][o]+m*_[a][x]}}for(o=l;o<y;o++)_[x][o]=0,_[o][x]=0;_[x][x]=1,d=w[x],l=x}if(t){if(t==="f")for(x=y;x<b;x++){for(o=y;o<b;o++)S[x][o]=0;S[x][x]=1}for(x=y-1;0<=x;x--){for(l=x+1,d=E[x],o=l;o<M;o++)S[x][o]=0;if(d!==0){for(f=S[x][x]*d,o=l;o<M;o++){for(m=0,a=l;a<b;a++)m+=S[a][x]*S[a][o];for(h=m/f,a=x;a<b;a++)S[a][o]=S[a][o]+h*S[a][x]}for(o=x;o<b;o++)S[o][x]=S[o][x]/d}else for(o=x;o<b;o++)S[o][x]=0;S[x][x]=S[x][x]+1}}for(i*=p,a=y-1;0<=a;a--)for(var C=0;C<50;C++){for(T=!1,l=a;0<=l;l--){if(Math.abs(w[l])<=i){T=!0;break}if(Math.abs(E[l-1])<=i)break}if(!T){for(c=0,u=l-(m=1),x=l;x<a+1&&(h=m*w[x],w[x]=c*w[x],!(Math.abs(h)<=i));x++)if(d=E[x],E[x]=Math.sqrt(h*h+d*d),c=d/(f=E[x]),m=-h/f,t)for(o=0;o<b;o++)g=S[o][u],v=S[o][x],S[o][u]=g*c+v*m,S[o][x]=-g*m+v*c}if(v=E[a],l===a){if(v<0&&(E[a]=-v,n))for(o=0;o<y;o++)_[o][a]=-_[o][a];break}for(p=E[l],h=(((g=E[a-1])-v)*(g+v)+((d=w[a-1])-(f=w[a]))*(d+f))/(2*f*g),d=Math.sqrt(h*h+1),h=((p-v)*(p+v)+f*(g/(h<0?h-d:h+d)-f))/p,x=l+(m=c=1);x<a+1;x++){if(d=w[x],g=E[x],f=m*d,d*=c,v=Math.sqrt(h*h+f*f),h=p*(c=h/(w[x-1]=v))+d*(m=f/v),d=-p*m+d*c,f=g*m,g*=c,n)for(o=0;o<y;o++)p=_[o][x-1],v=_[o][x],_[o][x-1]=p*c+v*m,_[o][x]=-p*m+v*c;if(v=Math.sqrt(h*h+f*f),h=(c=h/(E[x-1]=v))*d+(m=f/v)*g,p=-m*d+c*g,t)for(o=0;o<b;o++)g=S[o][x-1],v=S[o][x],S[o][x-1]=g*c+v*m,S[o][x]=-g*m+v*c}w[l]=0,w[a]=h,E[a]=p}for(x=0;x<y;x++)E[x]<i&&(E[x]=0);return{u:S,q:E,v:_}},r.VERSION="1.1.1",Object.defineProperty(r,"__esModule",{value:!0})})});var qM=Vx(wm=>{(function(){"use strict";var r=function(){this.init()};r.prototype={init:function(){var c=this||e;return c._counter=1e3,c._html5AudioPool=[],c.html5PoolSize=10,c._codecs={},c._howls=[],c._muted=!1,c._volume=1,c._canPlayEvent="canplaythrough",c._navigator=typeof window<"u"&&window.navigator?window.navigator:null,c.masterGain=null,c.noAudio=!1,c.usingWebAudio=!0,c.autoSuspend=!0,c.ctx=null,c.autoUnlock=!0,c._setup(),c},volume:function(c){var h=this||e;if(c=parseFloat(c),h.ctx||u(),typeof c<"u"&&c>=0&&c<=1){if(h._volume=c,h._muted)return h;h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c,e.ctx.currentTime);for(var d=0;d<h._howls.length;d++)if(!h._howls[d]._webAudio)for(var f=h._howls[d]._getSoundIds(),m=0;m<f.length;m++){var p=h._howls[d]._soundById(f[m]);p&&p._node&&(p._node.volume=p._volume*c)}return h}return h._volume},mute:function(c){var h=this||e;h.ctx||u(),h._muted=c,h.usingWebAudio&&h.masterGain.gain.setValueAtTime(c?0:h._volume,e.ctx.currentTime);for(var d=0;d<h._howls.length;d++)if(!h._howls[d]._webAudio)for(var f=h._howls[d]._getSoundIds(),m=0;m<f.length;m++){var p=h._howls[d]._soundById(f[m]);p&&p._node&&(p._node.muted=c?!0:p._muted)}return h},stop:function(){for(var c=this||e,h=0;h<c._howls.length;h++)c._howls[h].stop();return c},unload:function(){for(var c=this||e,h=c._howls.length-1;h>=0;h--)c._howls[h].unload();return c.usingWebAudio&&c.ctx&&typeof c.ctx.close<"u"&&(c.ctx.close(),c.ctx=null,u()),c},codecs:function(c){return(this||e)._codecs[c.replace(/^x-/,"")]},_setup:function(){var c=this||e;if(c.state=c.ctx&&c.ctx.state||"suspended",c._autoSuspend(),!c.usingWebAudio)if(typeof Audio<"u")try{var h=new Audio;typeof h.oncanplaythrough>"u"&&(c._canPlayEvent="canplay")}catch{c.noAudio=!0}else c.noAudio=!0;try{var h=new Audio;h.muted&&(c.noAudio=!0)}catch{}return c.noAudio||c._setupCodecs(),c},_setupCodecs:function(){var c=this||e,h=null;try{h=typeof Audio<"u"?new Audio:null}catch{return c}if(!h||typeof h.canPlayType!="function")return c;var d=h.canPlayType("audio/mpeg;").replace(/^no$/,""),f=c._navigator?c._navigator.userAgent:"",m=f.match(/OPR\/([0-6].)/g),p=m&&parseInt(m[0].split("/")[1],10)<33,g=f.indexOf("Safari")!==-1&&f.indexOf("Chrome")===-1,v=f.match(/Version\/(.*?) /),y=g&&v&&parseInt(v[1],10)<15;return c._codecs={mp3:!!(!p&&(d||h.canPlayType("audio/mp3;").replace(/^no$/,""))),mpeg:!!d,opus:!!h.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!h.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(h.canPlayType('audio/wav; codecs="1"')||h.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!h.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!h.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(h.canPlayType("audio/x-m4a;")||h.canPlayType("audio/m4a;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(h.canPlayType("audio/x-m4b;")||h.canPlayType("audio/m4b;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(h.canPlayType("audio/x-mp4;")||h.canPlayType("audio/mp4;")||h.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!!(!y&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!!(!y&&h.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!h.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(h.canPlayType("audio/x-flac;")||h.canPlayType("audio/flac;")).replace(/^no$/,"")},c},_unlockAudio:function(){var c=this||e;if(!(c._audioUnlocked||!c.ctx)){c._audioUnlocked=!1,c.autoUnlock=!1,!c._mobileUnloaded&&c.ctx.sampleRate!==44100&&(c._mobileUnloaded=!0,c.unload()),c._scratchBuffer=c.ctx.createBuffer(1,1,22050);var h=function(d){for(;c._html5AudioPool.length<c.html5PoolSize;)try{var f=new Audio;f._unlocked=!0,c._releaseHtml5Audio(f)}catch{c.noAudio=!0;break}for(var m=0;m<c._howls.length;m++)if(!c._howls[m]._webAudio)for(var p=c._howls[m]._getSoundIds(),g=0;g<p.length;g++){var v=c._howls[m]._soundById(p[g]);v&&v._node&&!v._node._unlocked&&(v._node._unlocked=!0,v._node.load())}c._autoResume();var y=c.ctx.createBufferSource();y.buffer=c._scratchBuffer,y.connect(c.ctx.destination),typeof y.start>"u"?y.noteOn(0):y.start(0),typeof c.ctx.resume=="function"&&c.ctx.resume(),y.onended=function(){y.disconnect(0),c._audioUnlocked=!0,document.removeEventListener("touchstart",h,!0),document.removeEventListener("touchend",h,!0),document.removeEventListener("click",h,!0),document.removeEventListener("keydown",h,!0);for(var b=0;b<c._howls.length;b++)c._howls[b]._emit("unlock")}};return document.addEventListener("touchstart",h,!0),document.addEventListener("touchend",h,!0),document.addEventListener("click",h,!0),document.addEventListener("keydown",h,!0),c}},_obtainHtml5Audio:function(){var c=this||e;if(c._html5AudioPool.length)return c._html5AudioPool.pop();var h=new Audio().play();return h&&typeof Promise<"u"&&(h instanceof Promise||typeof h.then=="function")&&h.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(c){var h=this||e;return c._unlocked&&h._html5AudioPool.push(c),h},_autoSuspend:function(){var c=this;if(!(!c.autoSuspend||!c.ctx||typeof c.ctx.suspend>"u"||!e.usingWebAudio)){for(var h=0;h<c._howls.length;h++)if(c._howls[h]._webAudio){for(var d=0;d<c._howls[h]._sounds.length;d++)if(!c._howls[h]._sounds[d]._paused)return c}return c._suspendTimer&&clearTimeout(c._suspendTimer),c._suspendTimer=setTimeout(function(){if(!!c.autoSuspend){c._suspendTimer=null,c.state="suspending";var f=function(){c.state="suspended",c._resumeAfterSuspend&&(delete c._resumeAfterSuspend,c._autoResume())};c.ctx.suspend().then(f,f)}},3e4),c}},_autoResume:function(){var c=this;if(!(!c.ctx||typeof c.ctx.resume>"u"||!e.usingWebAudio))return c.state==="running"&&c.ctx.state!=="interrupted"&&c._suspendTimer?(clearTimeout(c._suspendTimer),c._suspendTimer=null):c.state==="suspended"||c.state==="running"&&c.ctx.state==="interrupted"?(c.ctx.resume().then(function(){c.state="running";for(var h=0;h<c._howls.length;h++)c._howls[h]._emit("resume")}),c._suspendTimer&&(clearTimeout(c._suspendTimer),c._suspendTimer=null)):c.state==="suspending"&&(c._resumeAfterSuspend=!0),c}};var e=new r,t=function(c){var h=this;if(!c.src||c.src.length===0){console.error("An array of source files must be passed with any new Howl.");return}h.init(c)};t.prototype={init:function(c){var h=this;return e.ctx||u(),h._autoplay=c.autoplay||!1,h._format=typeof c.format!="string"?c.format:[c.format],h._html5=c.html5||!1,h._muted=c.mute||!1,h._loop=c.loop||!1,h._pool=c.pool||5,h._preload=typeof c.preload=="boolean"||c.preload==="metadata"?c.preload:!0,h._rate=c.rate||1,h._sprite=c.sprite||{},h._src=typeof c.src!="string"?c.src:[c.src],h._volume=c.volume!==void 0?c.volume:1,h._xhr={method:c.xhr&&c.xhr.method?c.xhr.method:"GET",headers:c.xhr&&c.xhr.headers?c.xhr.headers:null,withCredentials:c.xhr&&c.xhr.withCredentials?c.xhr.withCredentials:!1},h._duration=0,h._state="unloaded",h._sounds=[],h._endTimers={},h._queue=[],h._playLock=!1,h._onend=c.onend?[{fn:c.onend}]:[],h._onfade=c.onfade?[{fn:c.onfade}]:[],h._onload=c.onload?[{fn:c.onload}]:[],h._onloaderror=c.onloaderror?[{fn:c.onloaderror}]:[],h._onplayerror=c.onplayerror?[{fn:c.onplayerror}]:[],h._onpause=c.onpause?[{fn:c.onpause}]:[],h._onplay=c.onplay?[{fn:c.onplay}]:[],h._onstop=c.onstop?[{fn:c.onstop}]:[],h._onmute=c.onmute?[{fn:c.onmute}]:[],h._onvolume=c.onvolume?[{fn:c.onvolume}]:[],h._onrate=c.onrate?[{fn:c.onrate}]:[],h._onseek=c.onseek?[{fn:c.onseek}]:[],h._onunlock=c.onunlock?[{fn:c.onunlock}]:[],h._onresume=[],h._webAudio=e.usingWebAudio&&!h._html5,typeof e.ctx<"u"&&e.ctx&&e.autoUnlock&&e._unlockAudio(),e._howls.push(h),h._autoplay&&h._queue.push({event:"play",action:function(){h.play()}}),h._preload&&h._preload!=="none"&&h.load(),h},load:function(){var c=this,h=null;if(e.noAudio){c._emit("loaderror",null,"No audio support.");return}typeof c._src=="string"&&(c._src=[c._src]);for(var d=0;d<c._src.length;d++){var f,m;if(c._format&&c._format[d])f=c._format[d];else{if(m=c._src[d],typeof m!="string"){c._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&&e.codecs(f)){h=c._src[d];break}}if(!h){c._emit("loaderror",null,"No codec support for selected audio sources.");return}return c._src=h,c._state="loading",window.location.protocol==="https:"&&h.slice(0,5)==="http:"&&(c._html5=!0,c._webAudio=!1),new n(c),c._webAudio&&s(c),c},play:function(c,h){var d=this,f=null;if(typeof c=="number")f=c,c=null;else{if(typeof c=="string"&&d._state==="loaded"&&!d._sprite[c])return null;if(typeof c>"u"&&(c="__default",!d._playLock)){for(var m=0,p=0;p<d._sounds.length;p++)d._sounds[p]._paused&&!d._sounds[p]._ended&&(m++,f=d._sounds[p]._id);m===1?c=null:f=null}}var g=f?d._soundById(f):d._inactiveSound();if(!g)return null;if(f&&!c&&(c=g._sprite||"__default"),d._state!=="loaded"){g._sprite=c,g._ended=!1;var v=g._id;return d._queue.push({event:"play",action:function(){d.play(v)}}),v}if(f&&!g._paused)return h||d._loadQueue("play"),g._id;d._webAudio&&e._autoResume();var y=Math.max(0,g._seek>0?g._seek:d._sprite[c][0]/1e3),b=Math.max(0,(d._sprite[c][0]+d._sprite[c][1])/1e3-y),w=b*1e3/Math.abs(g._rate),S=d._sprite[c][0]/1e3,_=(d._sprite[c][0]+d._sprite[c][1])/1e3;g._sprite=c,g._ended=!1;var M=function(){g._paused=!1,g._seek=y,g._start=S,g._stop=_,g._loop=!!(g._loop||d._sprite[c][2])};if(y>=_){d._ended(g);return}var x=g._node;if(d._webAudio){var T=function(){d._playLock=!1,M(),d._refreshBuffer(g);var O=g._muted||d._muted?0:g._volume;x.gain.setValueAtTime(O,e.ctx.currentTime),g._playStart=e.ctx.currentTime,typeof x.bufferSource.start>"u"?g._loop?x.bufferSource.noteGrainOn(0,y,86400):x.bufferSource.noteGrainOn(0,y,b):g._loop?x.bufferSource.start(0,y,86400):x.bufferSource.start(0,y,b),w!==1/0&&(d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),w)),h||setTimeout(function(){d._emit("play",g._id),d._loadQueue()},0)};e.state==="running"&&e.ctx.state!=="interrupted"?T():(d._playLock=!0,d.once("resume",T),d._clearTimer(g._id))}else{var E=function(){x.currentTime=y,x.muted=g._muted||d._muted||e._muted||x.muted,x.volume=g._volume*e.volume(),x.playbackRate=g._rate;try{var O=x.play();if(O&&typeof Promise<"u"&&(O instanceof Promise||typeof O.then=="function")?(d._playLock=!0,M(),O.then(function(){d._playLock=!1,x._unlocked=!0,h?d._loadQueue():d._emit("play",g._id)}).catch(function(){d._playLock=!1,d._emit("playerror",g._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."),g._ended=!0,g._paused=!0})):h||(d._playLock=!1,M(),d._emit("play",g._id)),x.playbackRate=g._rate,x.paused){d._emit("playerror",g._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");return}c!=="__default"||g._loop?d._endTimers[g._id]=setTimeout(d._ended.bind(d,g),w):(d._endTimers[g._id]=function(){d._ended(g),x.removeEventListener("ended",d._endTimers[g._id],!1)},x.addEventListener("ended",d._endTimers[g._id],!1))}catch(D){d._emit("playerror",g._id,D)}};x.src==="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"&&(x.src=d._src,x.load());var C=window&&window.ejecta||!x.readyState&&e._navigator.isCocoonJS;if(x.readyState>=3||C)E();else{d._playLock=!0,d._state="loading";var P=function(){d._state="loaded",E(),x.removeEventListener(e._canPlayEvent,P,!1)};x.addEventListener(e._canPlayEvent,P,!1),d._clearTimer(g._id)}}return g._id},pause:function(c){var h=this;if(h._state!=="loaded"||h._playLock)return h._queue.push({event:"pause",action:function(){h.pause(c)}}),h;for(var d=h._getSoundIds(c),f=0;f<d.length;f++){h._clearTimer(d[f]);var m=h._soundById(d[f]);if(m&&!m._paused&&(m._seek=h.seek(d[f]),m._rateSeek=0,m._paused=!0,h._stopFade(d[f]),m._node))if(h._webAudio){if(!m._node.bufferSource)continue;typeof m._node.bufferSource.stop>"u"?m._node.bufferSource.noteOff(0):m._node.bufferSource.stop(0),h._cleanBuffer(m._node)}else(!isNaN(m._node.duration)||m._node.duration===1/0)&&m._node.pause();arguments[1]||h._emit("pause",m?m._id:null)}return h},stop:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"stop",action:function(){d.stop(c)}}),d;for(var f=d._getSoundIds(c),m=0;m<f.length;m++){d._clearTimer(f[m]);var p=d._soundById(f[m]);p&&(p._seek=p._start||0,p._rateSeek=0,p._paused=!0,p._ended=!0,d._stopFade(f[m]),p._node&&(d._webAudio?p._node.bufferSource&&(typeof p._node.bufferSource.stop>"u"?p._node.bufferSource.noteOff(0):p._node.bufferSource.stop(0),d._cleanBuffer(p._node)):(!isNaN(p._node.duration)||p._node.duration===1/0)&&(p._node.currentTime=p._start||0,p._node.pause(),p._node.duration===1/0&&d._clearSound(p._node))),h||d._emit("stop",p._id))}return d},mute:function(c,h){var d=this;if(d._state!=="loaded"||d._playLock)return d._queue.push({event:"mute",action:function(){d.mute(c,h)}}),d;if(typeof h>"u")if(typeof c=="boolean")d._muted=c;else return d._muted;for(var f=d._getSoundIds(h),m=0;m<f.length;m++){var p=d._soundById(f[m]);p&&(p._muted=c,p._interval&&d._stopFade(p._id),d._webAudio&&p._node?p._node.gain.setValueAtTime(c?0:p._volume,e.ctx.currentTime):p._node&&(p._node.muted=e._muted?!0:c),d._emit("mute",p._id))}return d},volume:function(){var c=this,h=arguments,d,f;if(h.length===0)return c._volume;if(h.length===1||h.length===2&&typeof h[1]>"u"){var m=c._getSoundIds(),p=m.indexOf(h[0]);p>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length>=2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d<"u"&&d>=0&&d<=1){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"volume",action:function(){c.volume.apply(c,h)}}),c;typeof f>"u"&&(c._volume=d),f=c._getSoundIds(f);for(var v=0;v<f.length;v++)g=c._soundById(f[v]),g&&(g._volume=d,h[2]||c._stopFade(f[v]),c._webAudio&&g._node&&!g._muted?g._node.gain.setValueAtTime(d,e.ctx.currentTime):g._node&&!g._muted&&(g._node.volume=d*e.volume()),c._emit("volume",g._id))}else return g=f?c._soundById(f):c._sounds[0],g?g._volume:0;return c},fade:function(c,h,d,f){var m=this;if(m._state!=="loaded"||m._playLock)return m._queue.push({event:"fade",action:function(){m.fade(c,h,d,f)}}),m;c=Math.min(Math.max(0,parseFloat(c)),1),h=Math.min(Math.max(0,parseFloat(h)),1),d=parseFloat(d),m.volume(c,f);for(var p=m._getSoundIds(f),g=0;g<p.length;g++){var v=m._soundById(p[g]);if(v){if(f||m._stopFade(p[g]),m._webAudio&&!v._muted){var y=e.ctx.currentTime,b=y+d/1e3;v._volume=c,v._node.gain.setValueAtTime(c,y),v._node.gain.linearRampToValueAtTime(h,b)}m._startFadeInterval(v,c,h,d,p[g],typeof f>"u")}}return m},_startFadeInterval:function(c,h,d,f,m,p){var g=this,v=h,y=d-h,b=Math.abs(y/.01),w=Math.max(4,b>0?f/b:f),S=Date.now();c._fadeTo=d,c._interval=setInterval(function(){var _=(Date.now()-S)/f;S=Date.now(),v+=y*_,v=Math.round(v*100)/100,y<0?v=Math.max(d,v):v=Math.min(d,v),g._webAudio?c._volume=v:g.volume(v,c._id,!0),p&&(g._volume=v),(d<h&&v<=d||d>h&&v>=d)&&(clearInterval(c._interval),c._interval=null,c._fadeTo=null,g.volume(d,c._id),g._emit("fade",c._id))},w)},_stopFade:function(c){var h=this,d=h._soundById(c);return d&&d._interval&&(h._webAudio&&d._node.gain.cancelScheduledValues(e.ctx.currentTime),clearInterval(d._interval),d._interval=null,h.volume(d._fadeTo,c),d._fadeTo=null,h._emit("fade",c)),h},loop:function(){var c=this,h=arguments,d,f,m;if(h.length===0)return c._loop;if(h.length===1)if(typeof h[0]=="boolean")d=h[0],c._loop=d;else return m=c._soundById(parseInt(h[0],10)),m?m._loop:!1;else h.length===2&&(d=h[0],f=parseInt(h[1],10));for(var p=c._getSoundIds(f),g=0;g<p.length;g++)m=c._soundById(p[g]),m&&(m._loop=d,c._webAudio&&m._node&&m._node.bufferSource&&(m._node.bufferSource.loop=d,d&&(m._node.bufferSource.loopStart=m._start||0,m._node.bufferSource.loopEnd=m._stop,c.playing(p[g])&&(c.pause(p[g],!0),c.play(p[g],!0)))));return c},rate:function(){var c=this,h=arguments,d,f;if(h.length===0)f=c._sounds[0]._id;else if(h.length===1){var m=c._getSoundIds(),p=m.indexOf(h[0]);p>=0?f=parseInt(h[0],10):d=parseFloat(h[0])}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));var g;if(typeof d=="number"){if(c._state!=="loaded"||c._playLock)return c._queue.push({event:"rate",action:function(){c.rate.apply(c,h)}}),c;typeof f>"u"&&(c._rate=d),f=c._getSoundIds(f);for(var v=0;v<f.length;v++)if(g=c._soundById(f[v]),g){c.playing(f[v])&&(g._rateSeek=c.seek(f[v]),g._playStart=c._webAudio?e.ctx.currentTime:g._playStart),g._rate=d,c._webAudio&&g._node&&g._node.bufferSource?g._node.bufferSource.playbackRate.setValueAtTime(d,e.ctx.currentTime):g._node&&(g._node.playbackRate=d);var y=c.seek(f[v]),b=(c._sprite[g._sprite][0]+c._sprite[g._sprite][1])/1e3-y,w=b*1e3/Math.abs(g._rate);(c._endTimers[f[v]]||!g._paused)&&(c._clearTimer(f[v]),c._endTimers[f[v]]=setTimeout(c._ended.bind(c,g),w)),c._emit("rate",g._id)}}else return g=c._soundById(f),g?g._rate:c._rate;return c},seek:function(){var c=this,h=arguments,d,f;if(h.length===0)c._sounds.length&&(f=c._sounds[0]._id);else if(h.length===1){var m=c._getSoundIds(),p=m.indexOf(h[0]);p>=0?f=parseInt(h[0],10):c._sounds.length&&(f=c._sounds[0]._id,d=parseFloat(h[0]))}else h.length===2&&(d=parseFloat(h[0]),f=parseInt(h[1],10));if(typeof f>"u")return 0;if(typeof d=="number"&&(c._state!=="loaded"||c._playLock))return c._queue.push({event:"seek",action:function(){c.seek.apply(c,h)}}),c;var g=c._soundById(f);if(g)if(typeof d=="number"&&d>=0){var v=c.playing(f);v&&c.pause(f,!0),g._seek=d,g._ended=!1,c._clearTimer(f),!c._webAudio&&g._node&&!isNaN(g._node.duration)&&(g._node.currentTime=d);var y=function(){v&&c.play(f,!0),c._emit("seek",f)};if(v&&!c._webAudio){var b=function(){c._playLock?setTimeout(b,0):y()};setTimeout(b,0)}else y()}else if(c._webAudio){var w=c.playing(f)?e.ctx.currentTime-g._playStart:0,S=g._rateSeek?g._rateSeek-g._seek:0;return g._seek+(S+w*Math.abs(g._rate))}else return g._node.currentTime;return c},playing:function(c){var h=this;if(typeof c=="number"){var d=h._soundById(c);return d?!d._paused:!1}for(var f=0;f<h._sounds.length;f++)if(!h._sounds[f]._paused)return!0;return!1},duration:function(c){var h=this,d=h._duration,f=h._soundById(c);return f&&(d=h._sprite[f._sprite][1]/1e3),d},state:function(){return this._state},unload:function(){for(var c=this,h=c._sounds,d=0;d<h.length;d++)h[d]._paused||c.stop(h[d]._id),c._webAudio||(c._clearSound(h[d]._node),h[d]._node.removeEventListener("error",h[d]._errorFn,!1),h[d]._node.removeEventListener(e._canPlayEvent,h[d]._loadFn,!1),h[d]._node.removeEventListener("ended",h[d]._endFn,!1),e._releaseHtml5Audio(h[d]._node)),delete h[d]._node,c._clearTimer(h[d]._id);var f=e._howls.indexOf(c);f>=0&&e._howls.splice(f,1);var m=!0;for(d=0;d<e._howls.length;d++)if(e._howls[d]._src===c._src||c._src.indexOf(e._howls[d]._src)>=0){m=!1;break}return i&&m&&delete i[c._src],e.noAudio=!1,c._state="unloaded",c._sounds=[],c=null,null},on:function(c,h,d,f){var m=this,p=m["_on"+c];return typeof h=="function"&&p.push(f?{id:d,fn:h,once:f}:{id:d,fn:h}),m},off:function(c,h,d){var f=this,m=f["_on"+c],p=0;if(typeof h=="number"&&(d=h,h=null),h||d)for(p=0;p<m.length;p++){var g=d===m[p].id;if(h===m[p].fn&&g||!h&&g){m.splice(p,1);break}}else if(c)f["_on"+c]=[];else{var v=Object.keys(f);for(p=0;p<v.length;p++)v[p].indexOf("_on")===0&&Array.isArray(f[v[p]])&&(f[v[p]]=[])}return f},once:function(c,h,d){var f=this;return f.on(c,h,d,1),f},_emit:function(c,h,d){for(var f=this,m=f["_on"+c],p=m.length-1;p>=0;p--)(!m[p].id||m[p].id===h||c==="load")&&(setTimeout(function(g){g.call(this,h,d)}.bind(f,m[p].fn),0),m[p].once&&f.off(c,m[p].fn,m[p].id));return f._loadQueue(c),f},_loadQueue:function(c){var h=this;if(h._queue.length>0){var d=h._queue[0];d.event===c&&(h._queue.shift(),h._loadQueue()),c||d.action()}return h},_ended:function(c){var h=this,d=c._sprite;if(!h._webAudio&&c._node&&!c._node.paused&&!c._node.ended&&c._node.currentTime<c._stop)return setTimeout(h._ended.bind(h,c),100),h;var f=!!(c._loop||h._sprite[d][2]);if(h._emit("end",c._id),!h._webAudio&&f&&h.stop(c._id,!0).play(c._id),h._webAudio&&f){h._emit("play",c._id),c._seek=c._start||0,c._rateSeek=0,c._playStart=e.ctx.currentTime;var m=(c._stop-c._start)*1e3/Math.abs(c._rate);h._endTimers[c._id]=setTimeout(h._ended.bind(h,c),m)}return h._webAudio&&!f&&(c._paused=!0,c._ended=!0,c._seek=c._start||0,c._rateSeek=0,h._clearTimer(c._id),h._cleanBuffer(c._node),e._autoSuspend()),!h._webAudio&&!f&&h.stop(c._id,!0),h},_clearTimer:function(c){var h=this;if(h._endTimers[c]){if(typeof h._endTimers[c]!="function")clearTimeout(h._endTimers[c]);else{var d=h._soundById(c);d&&d._node&&d._node.removeEventListener("ended",h._endTimers[c],!1)}delete h._endTimers[c]}return h},_soundById:function(c){for(var h=this,d=0;d<h._sounds.length;d++)if(c===h._sounds[d]._id)return h._sounds[d];return null},_inactiveSound:function(){var c=this;c._drain();for(var h=0;h<c._sounds.length;h++)if(c._sounds[h]._ended)return c._sounds[h].reset();return new n(c)},_drain:function(){var c=this,h=c._pool,d=0,f=0;if(!(c._sounds.length<h)){for(f=0;f<c._sounds.length;f++)c._sounds[f]._ended&&d++;for(f=c._sounds.length-1;f>=0;f--){if(d<=h)return;c._sounds[f]._ended&&(c._webAudio&&c._sounds[f]._node&&c._sounds[f]._node.disconnect(0),c._sounds.splice(f,1),d--)}}},_getSoundIds:function(c){var h=this;if(typeof c>"u"){for(var d=[],f=0;f<h._sounds.length;f++)d.push(h._sounds[f]._id);return d}else return[c]},_refreshBuffer:function(c){var h=this;return c._node.bufferSource=e.ctx.createBufferSource(),c._node.bufferSource.buffer=i[h._src],c._panner?c._node.bufferSource.connect(c._panner):c._node.bufferSource.connect(c._node),c._node.bufferSource.loop=c._loop,c._loop&&(c._node.bufferSource.loopStart=c._start||0,c._node.bufferSource.loopEnd=c._stop||0),c._node.bufferSource.playbackRate.setValueAtTime(c._rate,e.ctx.currentTime),h},_cleanBuffer:function(c){var h=this,d=e._navigator&&e._navigator.vendor.indexOf("Apple")>=0;if(e._scratchBuffer&&c.bufferSource&&(c.bufferSource.onended=null,c.bufferSource.disconnect(0),d))try{c.bufferSource.buffer=e._scratchBuffer}catch{}return c.bufferSource=null,h},_clearSound:function(c){var h=/MSIE |Trident\//.test(e._navigator&&e._navigator.userAgent);h||(c.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var n=function(c){this._parent=c,this.init()};n.prototype={init:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++e._counter,h._sounds.push(c),c.create(),c},create:function(){var c=this,h=c._parent,d=e._muted||c._muted||c._parent._muted?0:c._volume;return h._webAudio?(c._node=typeof e.ctx.createGain>"u"?e.ctx.createGainNode():e.ctx.createGain(),c._node.gain.setValueAtTime(d,e.ctx.currentTime),c._node.paused=!0,c._node.connect(e.masterGain)):e.noAudio||(c._node=e._obtainHtml5Audio(),c._errorFn=c._errorListener.bind(c),c._node.addEventListener("error",c._errorFn,!1),c._loadFn=c._loadListener.bind(c),c._node.addEventListener(e._canPlayEvent,c._loadFn,!1),c._endFn=c._endListener.bind(c),c._node.addEventListener("ended",c._endFn,!1),c._node.src=h._src,c._node.preload=h._preload===!0?"auto":h._preload,c._node.volume=d*e.volume(),c._node.load()),c},reset:function(){var c=this,h=c._parent;return c._muted=h._muted,c._loop=h._loop,c._volume=h._volume,c._rate=h._rate,c._seek=0,c._rateSeek=0,c._paused=!0,c._ended=!0,c._sprite="__default",c._id=++e._counter,c},_errorListener:function(){var c=this;c._parent._emit("loaderror",c._id,c._node.error?c._node.error.code:0),c._node.removeEventListener("error",c._errorFn,!1)},_loadListener:function(){var c=this,h=c._parent;h._duration=Math.ceil(c._node.duration*10)/10,Object.keys(h._sprite).length===0&&(h._sprite={__default:[0,h._duration*1e3]}),h._state!=="loaded"&&(h._state="loaded",h._emit("load"),h._loadQueue()),c._node.removeEventListener(e._canPlayEvent,c._loadFn,!1)},_endListener:function(){var c=this,h=c._parent;h._duration===1/0&&(h._duration=Math.ceil(c._node.duration*10)/10,h._sprite.__default[1]===1/0&&(h._sprite.__default[1]=h._duration*1e3),h._ended(c)),c._node.removeEventListener("ended",c._endFn,!1)}};var i={},s=function(c){var h=c._src;if(i[h]){c._duration=i[h].duration,l(c);return}if(/^data:[^;]+;base64,/.test(h)){for(var d=atob(h.split(",")[1]),f=new Uint8Array(d.length),m=0;m<d.length;++m)f[m]=d.charCodeAt(m);a(f.buffer,c)}else{var p=new XMLHttpRequest;p.open(c._xhr.method,h,!0),p.withCredentials=c._xhr.withCredentials,p.responseType="arraybuffer",c._xhr.headers&&Object.keys(c._xhr.headers).forEach(function(g){p.setRequestHeader(g,c._xhr.headers[g])}),p.onload=function(){var g=(p.status+"")[0];if(g!=="0"&&g!=="2"&&g!=="3"){c._emit("loaderror",null,"Failed loading audio file with status: "+p.status+".");return}a(p.response,c)},p.onerror=function(){c._webAudio&&(c._html5=!0,c._webAudio=!1,c._sounds=[],delete i[h],c.load())},o(p)}},o=function(c){try{c.send()}catch{c.onerror()}},a=function(c,h){var d=function(){h._emit("loaderror",null,"Decoding audio data failed.")},f=function(m){m&&h._sounds.length>0?(i[h._src]=m,l(h,m)):d()};typeof Promise<"u"&&e.ctx.decodeAudioData.length===1?e.ctx.decodeAudioData(c).then(f).catch(d):e.ctx.decodeAudioData(c,f,d)},l=function(c,h){h&&!c._duration&&(c._duration=h.duration),Object.keys(c._sprite).length===0&&(c._sprite={__default:[0,c._duration*1e3]}),c._state!=="loaded"&&(c._state="loaded",c._emit("load"),c._loadQueue())},u=function(){if(!!e.usingWebAudio){try{typeof AudioContext<"u"?e.ctx=new AudioContext:typeof webkitAudioContext<"u"?e.ctx=new webkitAudioContext:e.usingWebAudio=!1}catch{e.usingWebAudio=!1}e.ctx||(e.usingWebAudio=!1);var c=/iP(hone|od|ad)/.test(e._navigator&&e._navigator.platform),h=e._navigator&&e._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=h?parseInt(h[1],10):null;if(c&&d&&d<9){var f=/safari/.test(e._navigator&&e._navigator.userAgent.toLowerCase());e._navigator&&!f&&(e.usingWebAudio=!1)}e.usingWebAudio&&(e.masterGain=typeof e.ctx.createGain>"u"?e.ctx.createGainNode():e.ctx.createGain(),e.masterGain.gain.setValueAtTime(e._muted?0:e._volume,e.ctx.currentTime),e.masterGain.connect(e.ctx.destination)),e._setup()}};typeof define=="function"&&define.amd&&define([],function(){return{Howler:e,Howl:t}}),typeof wm<"u"&&(wm.Howler=e,wm.Howl=t),typeof global<"u"?(global.HowlerGlobal=r,global.Howler=e,global.Howl=t,global.Sound=n):typeof window<"u"&&(window.HowlerGlobal=r,window.Howler=e,window.Howl=t,window.Sound=n)})();(function(){"use strict";HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(e){var t=this;if(!t.ctx||!t.ctx.listener)return t;for(var n=t._howls.length-1;n>=0;n--)t._howls[n].stereo(e);return t},HowlerGlobal.prototype.pos=function(e,t,n){var i=this;if(!i.ctx||!i.ctx.listener)return i;if(t=typeof t!="number"?i._pos[1]:t,n=typeof n!="number"?i._pos[2]:n,typeof e=="number")i._pos=[e,t,n],typeof i.ctx.listener.positionX<"u"?(i.ctx.listener.positionX.setTargetAtTime(i._pos[0],Howler.ctx.currentTime,.1),i.ctx.listener.positionY.setTargetAtTime(i._pos[1],Howler.ctx.currentTime,.1),i.ctx.listener.positionZ.setTargetAtTime(i._pos[2],Howler.ctx.currentTime,.1)):i.ctx.listener.setPosition(i._pos[0],i._pos[1],i._pos[2]);else return i._pos;return i},HowlerGlobal.prototype.orientation=function(e,t,n,i,s,o){var a=this;if(!a.ctx||!a.ctx.listener)return a;var l=a._orientation;if(t=typeof t!="number"?l[1]:t,n=typeof n!="number"?l[2]:n,i=typeof i!="number"?l[3]:i,s=typeof s!="number"?l[4]:s,o=typeof o!="number"?l[5]:o,typeof e=="number")a._orientation=[e,t,n,i,s,o],typeof a.ctx.listener.forwardX<"u"?(a.ctx.listener.forwardX.setTargetAtTime(e,Howler.ctx.currentTime,.1),a.ctx.listener.forwardY.setTargetAtTime(t,Howler.ctx.currentTime,.1),a.ctx.listener.forwardZ.setTargetAtTime(n,Howler.ctx.currentTime,.1),a.ctx.listener.upX.setTargetAtTime(i,Howler.ctx.currentTime,.1),a.ctx.listener.upY.setTargetAtTime(s,Howler.ctx.currentTime,.1),a.ctx.listener.upZ.setTargetAtTime(o,Howler.ctx.currentTime,.1)):a.ctx.listener.setOrientation(e,t,n,i,s,o);else return l;return a},Howl.prototype.init=function(e){return function(t){var n=this;return n._orientation=t.orientation||[1,0,0],n._stereo=t.stereo||null,n._pos=t.pos||null,n._pannerAttr={coneInnerAngle:typeof t.coneInnerAngle<"u"?t.coneInnerAngle:360,coneOuterAngle:typeof t.coneOuterAngle<"u"?t.coneOuterAngle:360,coneOuterGain:typeof t.coneOuterGain<"u"?t.coneOuterGain:0,distanceModel:typeof t.distanceModel<"u"?t.distanceModel:"inverse",maxDistance:typeof t.maxDistance<"u"?t.maxDistance:1e4,panningModel:typeof t.panningModel<"u"?t.panningModel:"HRTF",refDistance:typeof t.refDistance<"u"?t.refDistance:1,rolloffFactor:typeof t.rolloffFactor<"u"?t.rolloffFactor:1},n._onstereo=t.onstereo?[{fn:t.onstereo}]:[],n._onpos=t.onpos?[{fn:t.onpos}]:[],n._onorientation=t.onorientation?[{fn:t.onorientation}]:[],e.call(this,t)}}(Howl.prototype.init),Howl.prototype.stereo=function(e,t){var n=this;if(!n._webAudio)return n;if(n._state!=="loaded")return n._queue.push({event:"stereo",action:function(){n.stereo(e,t)}}),n;var i=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof t>"u")if(typeof e=="number")n._stereo=e,n._pos=[e,0,0];else return n._stereo;for(var s=n._getSoundIds(t),o=0;o<s.length;o++){var a=n._soundById(s[o]);if(a)if(typeof e=="number")a._stereo=e,a._pos=[e,0,0],a._node&&(a._pannerAttr.panningModel="equalpower",(!a._panner||!a._panner.pan)&&r(a,i),i==="spatial"?typeof a._panner.positionX<"u"?(a._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):a._panner.setPosition(e,0,0):a._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),n._emit("stereo",a._id);else return a._stereo}return n},Howl.prototype.pos=function(e,t,n,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"pos",action:function(){s.pos(e,t,n,i)}}),s;if(t=typeof t!="number"?0:t,n=typeof n!="number"?-.5:n,typeof i>"u")if(typeof e=="number")s._pos=[e,t,n];else return s._pos;for(var o=s._getSoundIds(i),a=0;a<o.length;a++){var l=s._soundById(o[a]);if(l)if(typeof e=="number")l._pos=[e,t,n],l._node&&((!l._panner||l._panner.pan)&&r(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(t,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(n,Howler.ctx.currentTime)):l._panner.setPosition(e,t,n)),s._emit("pos",l._id);else return l._pos}return s},Howl.prototype.orientation=function(e,t,n,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"orientation",action:function(){s.orientation(e,t,n,i)}}),s;if(t=typeof t!="number"?s._orientation[1]:t,n=typeof n!="number"?s._orientation[2]:n,typeof i>"u")if(typeof e=="number")s._orientation=[e,t,n];else return s._orientation;for(var o=s._getSoundIds(i),a=0;a<o.length;a++){var l=s._soundById(o[a]);if(l)if(typeof e=="number")l._orientation=[e,t,n],l._node&&(l._panner||(l._pos||(l._pos=s._pos||[0,0,-.5]),r(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(t,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(n,Howler.ctx.currentTime)):l._panner.setOrientation(e,t,n)),s._emit("orientation",l._id);else return l._orientation}return s},Howl.prototype.pannerAttr=function(){var e=this,t=arguments,n,i,s;if(!e._webAudio)return e;if(t.length===0)return e._pannerAttr;if(t.length===1)if(typeof t[0]=="object")n=t[0],typeof i>"u"&&(n.pannerAttr||(n.pannerAttr={coneInnerAngle:n.coneInnerAngle,coneOuterAngle:n.coneOuterAngle,coneOuterGain:n.coneOuterGain,distanceModel:n.distanceModel,maxDistance:n.maxDistance,refDistance:n.refDistance,rolloffFactor:n.rolloffFactor,panningModel:n.panningModel}),e._pannerAttr={coneInnerAngle:typeof n.pannerAttr.coneInnerAngle<"u"?n.pannerAttr.coneInnerAngle:e._coneInnerAngle,coneOuterAngle:typeof n.pannerAttr.coneOuterAngle<"u"?n.pannerAttr.coneOuterAngle:e._coneOuterAngle,coneOuterGain:typeof n.pannerAttr.coneOuterGain<"u"?n.pannerAttr.coneOuterGain:e._coneOuterGain,distanceModel:typeof n.pannerAttr.distanceModel<"u"?n.pannerAttr.distanceModel:e._distanceModel,maxDistance:typeof n.pannerAttr.maxDistance<"u"?n.pannerAttr.maxDistance:e._maxDistance,refDistance:typeof n.pannerAttr.refDistance<"u"?n.pannerAttr.refDistance:e._refDistance,rolloffFactor:typeof n.pannerAttr.rolloffFactor<"u"?n.pannerAttr.rolloffFactor:e._rolloffFactor,panningModel:typeof n.pannerAttr.panningModel<"u"?n.pannerAttr.panningModel:e._panningModel});else return s=e._soundById(parseInt(t[0],10)),s?s._pannerAttr:e._pannerAttr;else t.length===2&&(n=t[0],i=parseInt(t[1],10));for(var o=e._getSoundIds(i),a=0;a<o.length;a++)if(s=e._soundById(o[a]),s){var l=s._pannerAttr;l={coneInnerAngle:typeof n.coneInnerAngle<"u"?n.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof n.coneOuterAngle<"u"?n.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof n.coneOuterGain<"u"?n.coneOuterGain:l.coneOuterGain,distanceModel:typeof n.distanceModel<"u"?n.distanceModel:l.distanceModel,maxDistance:typeof n.maxDistance<"u"?n.maxDistance:l.maxDistance,refDistance:typeof n.refDistance<"u"?n.refDistance:l.refDistance,rolloffFactor:typeof n.rolloffFactor<"u"?n.rolloffFactor:l.rolloffFactor,panningModel:typeof n.panningModel<"u"?n.panningModel:l.panningModel};var u=s._panner;u?(u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel):(s._pos||(s._pos=e._pos||[0,0,-.5]),r(s,"spatial"))}return e},Sound.prototype.init=function(e){return function(){var t=this,n=t._parent;t._orientation=n._orientation,t._stereo=n._stereo,t._pos=n._pos,t._pannerAttr=n._pannerAttr,e.call(this),t._stereo?n.stereo(t._stereo):t._pos&&n.pos(t._pos[0],t._pos[1],t._pos[2],t._id)}}(Sound.prototype.init),Sound.prototype.reset=function(e){return function(){var t=this,n=t._parent;return t._orientation=n._orientation,t._stereo=n._stereo,t._pos=n._pos,t._pannerAttr=n._pannerAttr,t._stereo?n.stereo(t._stereo):t._pos?n.pos(t._pos[0],t._pos[1],t._pos[2],t._id):t._panner&&(t._panner.disconnect(0),t._panner=void 0,n._refreshBuffer(t)),e.call(this)}}(Sound.prototype.reset);var r=function(e,t){t=t||"spatial",t==="spatial"?(e._panner=Howler.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,typeof e._panner.positionX<"u"?(e._panner.positionX.setValueAtTime(e._pos[0],Howler.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],Howler.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],Howler.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),typeof e._panner.orientationX<"u"?(e._panner.orientationX.setValueAtTime(e._orientation[0],Howler.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],Howler.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],Howler.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=Howler.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,Howler.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}})()});var Qo="142";var Cr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},PC=0,Wx=1,DC=2;var ff=1,Iy=2,fu=3,Gr=0,un=1,tr=2,IC=1;var Rt=0,Ns=1,jx=2,qx=3,Xx=4,LC=5,Ha=100,OC=101,RC=102,Yx=103,Qx=104,NC=200,BC=201,FC=202,UC=203,Aw=204,_w=205,GC=206,zC=207,kC=208,VC=209,HC=210,WC=0,jC=1,qC=2,jg=3,XC=4,YC=5,QC=6,ZC=7,Tw=0,KC=1,JC=2,us=0,$C=1,eP=2,tP=3,nP=4,rP=5,Mw=300,Fs=301,Us=302,qg=303,Xg=304,dl=306,Xa=1e3,er=1001,Yg=1002,Ft=1003,Zx=1004;var Kx=1005;var at=1006,iP=1007;var fl=1008;var Ut=1009,sP=1010,oP=1011,Ew=1012,aP=1013,cs=1014,Ti=1015,bu=1016,lP=1017,cP=1018,Bs=1020,uP=1021,hP=1022,si=1023,dP=1024,fP=1025,Bo=1026,Gs=1027,pP=1028,mP=1029,gP=1030,yP=1031,vP=1033,cg=33776,ug=33777,hg=33778,dg=33779,Jx=35840,$x=35841,eb=35842,tb=35843,xP=36196,nb=37492,rb=37496,ib=37808,sb=37809,ob=37810,ab=37811,lb=37812,cb=37813,ub=37814,hb=37815,db=37816,fb=37817,pb=37818,mb=37819,gb=37820,yb=37821,vb=36492;var jd=2300,qd=2301,fg=2302,xb=2400,bb=2401,wb=2402;var bP=2501;var Mr=3e3,Xe=3001,Cn=3200,Ly=3201,wP=0,SP=1;var ls="srgb",No="srgb-linear";var pg=7680;var AP=519,Qg=35044;var Sb="300 es",Zg=1035,Lt=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,e);e.target=null}}},Vn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],Ab=1234567,mu=Math.PI/180,wu=180/Math.PI;function Mi(){let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vn[r&255]+Vn[r>>8&255]+Vn[r>>16&255]+Vn[r>>24&255]+"-"+Vn[e&255]+Vn[e>>8&255]+"-"+Vn[e>>16&15|64]+Vn[e>>24&255]+"-"+Vn[t&63|128]+Vn[t>>8&255]+"-"+Vn[t>>16&255]+Vn[t>>24&255]+Vn[n&255]+Vn[n>>8&255]+Vn[n>>16&255]+Vn[n>>24&255]).toLowerCase()}function pn(r,e,t){return Math.max(e,Math.min(t,r))}function Oy(r,e){return(r%e+e)%e}function _P(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function TP(r,e,t){return r!==e?(t-r)/(e-r):0}function gu(r,e,t){return(1-t)*r+t*e}function MP(r,e,t,n){return gu(r,e,1-Math.exp(-t*n))}function EP(r,e=1){return e-Math.abs(Oy(r,e*2)-e)}function CP(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function PP(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function DP(r,e){return r+Math.floor(Math.random()*(e-r+1))}function IP(r,e){return r+Math.random()*(e-r)}function LP(r){return r*(.5-Math.random())}function OP(r){r!==void 0&&(Ab=r);let e=Ab+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function RP(r){return r*mu}function NP(r){return r*wu}function Kg(r){return(r&r-1)===0&&r!==0}function BP(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Xd(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function FP(r,e,t,n,i){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),u=s((e+n)/2),c=o((e+n)/2),h=s((e-n)/2),d=o((e-n)/2),f=s((n-e)/2),m=o((n-e)/2);switch(i){case"XYX":r.set(a*c,l*h,l*d,a*u);break;case"YZY":r.set(l*d,a*c,l*h,a*u);break;case"ZXZ":r.set(l*h,l*d,a*c,a*u);break;case"XZX":r.set(a*c,l*m,l*f,a*u);break;case"YXY":r.set(l*f,a*c,l*m,a*u);break;case"ZYZ":r.set(l*m,l*f,a*c,a*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function UP(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function GP(r,e){switch(e.constructor){case Float32Array:return r;case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}var Be=Object.freeze({__proto__:null,DEG2RAD:mu,RAD2DEG:wu,generateUUID:Mi,clamp:pn,euclideanModulo:Oy,mapLinear:_P,inverseLerp:TP,lerp:gu,damp:MP,pingpong:EP,smoothstep:CP,smootherstep:PP,randInt:DP,randFloat:IP,randFloatSpread:LP,seededRandom:OP,degToRad:RP,radToDeg:NP,isPowerOfTwo:Kg,ceilPowerOfTwo:BP,floorPowerOfTwo:Xd,setQuaternionFromProperEuler:FP,normalize:GP,denormalize:UP}),B=class{constructor(e=0,t=0){B.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*i+e.x,this.y=s*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},jt=class{constructor(){jt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,s,o,a,l,u){let c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=s,c[5]=l,c[6]=n,c[7]=o,c[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],u=n[1],c=n[4],h=n[7],d=n[2],f=n[5],m=n[8],p=i[0],g=i[3],v=i[6],y=i[1],b=i[4],w=i[7],S=i[2],_=i[5],M=i[8];return s[0]=o*p+a*y+l*S,s[3]=o*g+a*b+l*_,s[6]=o*v+a*w+l*M,s[1]=u*p+c*y+h*S,s[4]=u*g+c*b+h*_,s[7]=u*v+c*w+h*M,s[2]=d*p+f*y+m*S,s[5]=d*g+f*b+m*_,s[8]=d*v+f*w+m*M,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8];return t*o*c-t*a*u-n*s*c+n*a*l+i*s*u-i*o*l}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=c*o-a*u,d=a*l-c*s,f=u*s-o*l,m=t*h+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let p=1/m;return e[0]=h*p,e[1]=(i*u-c*n)*p,e[2]=(a*n-i*o)*p,e[3]=d*p,e[4]=(c*t-i*l)*p,e[5]=(i*s-a*t)*p,e[6]=f*p,e[7]=(n*l-u*t)*p,e[8]=(o*t-n*s)*p,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,o,a){let l=Math.cos(s),u=Math.sin(s);return this.set(n*l,n*u,-n*(l*o+u*a)+o+e,-i*u,i*l,-i*(-u*o+l*a)+a+t,0,0,1),this}scale(e,t){let n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),i=this.elements,s=i[0],o=i[3],a=i[6],l=i[1],u=i[4],c=i[7];return i[0]=t*s+n*l,i[3]=t*o+n*u,i[6]=t*a+n*c,i[1]=-n*s+t*l,i[4]=-n*o+t*u,i[7]=-n*a+t*c,this}translate(e,t){let n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};function Cw(r){for(let e=r.length-1;e>=0;--e)if(r[e]>65535)return!0;return!1}var zP={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function gd(r,e){return new zP[r](e)}function Yd(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function Fo(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Wd(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}var mg={[ls]:{[No]:Fo},[No]:{[ls]:Wd}},ti={legacyMode:!0,get workingColorSpace(){return No},set workingColorSpace(r){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(r,e,t){if(this.legacyMode||e===t||!e||!t)return r;if(mg[e]&&mg[e][t]!==void 0){let n=mg[e][t];return r.r=n(r.r),r.g=n(r.g),r.b=n(r.b),r}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(r,e){return this.convert(r,this.workingColorSpace,e)},toWorkingColorSpace:function(r,e){return this.convert(r,e,this.workingColorSpace)}},Pw={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},dn={r:0,g:0,b:0},ni={h:0,s:0,l:0},yd={h:0,s:0,l:0};function gg(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?r+(e-r)*6*t:t<1/2?e:t<2/3?r+(e-r)*6*(2/3-t):r}function vd(r,e){return e.r=r.r,e.g=r.g,e.b=r.b,e}var Le=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&n===void 0?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ls){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ti.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=No){return this.r=e,this.g=t,this.b=n,ti.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=No){if(e=Oy(e,1),t=pn(t,0,1),n=pn(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=gg(o,s,e+1/3),this.g=gg(o,s,e),this.b=gg(o,s,e-1/3)}return ti.toWorkingColorSpace(this,i),this}setStyle(e,t=ls){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let s,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(s[1],10))/255,this.g=Math.min(255,parseInt(s[2],10))/255,this.b=Math.min(255,parseInt(s[3],10))/255,ti.toWorkingColorSpace(this,t),n(s[4]),this;if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(s[1],10))/100,this.g=Math.min(100,parseInt(s[2],10))/100,this.b=Math.min(100,parseInt(s[3],10))/100,ti.toWorkingColorSpace(this,t),n(s[4]),this;break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){let l=parseFloat(s[1])/360,u=parseInt(s[2],10)/100,c=parseInt(s[3],10)/100;return n(s[4]),this.setHSL(l,u,c,t)}break}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=i[1],o=s.length;if(o===3)return this.r=parseInt(s.charAt(0)+s.charAt(0),16)/255,this.g=parseInt(s.charAt(1)+s.charAt(1),16)/255,this.b=parseInt(s.charAt(2)+s.charAt(2),16)/255,ti.toWorkingColorSpace(this,t),this;if(o===6)return this.r=parseInt(s.charAt(0)+s.charAt(1),16)/255,this.g=parseInt(s.charAt(2)+s.charAt(3),16)/255,this.b=parseInt(s.charAt(4)+s.charAt(5),16)/255,ti.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=ls){let n=Pw[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Fo(e.r),this.g=Fo(e.g),this.b=Fo(e.b),this}copyLinearToSRGB(e){return this.r=Wd(e.r),this.g=Wd(e.g),this.b=Wd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ls){return ti.fromWorkingColorSpace(vd(this,dn),e),pn(dn.r*255,0,255)<<16^pn(dn.g*255,0,255)<<8^pn(dn.b*255,0,255)<<0}getHexString(e=ls){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=No){ti.fromWorkingColorSpace(vd(this,dn),t);let n=dn.r,i=dn.g,s=dn.b,o=Math.max(n,i,s),a=Math.min(n,i,s),l,u,c=(a+o)/2;if(a===o)l=0,u=0;else{let h=o-a;switch(u=c<=.5?h/(o+a):h/(2-o-a),o){case n:l=(i-s)/h+(i<s?6:0);break;case i:l=(s-n)/h+2;break;case s:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=u,e.l=c,e}getRGB(e,t=No){return ti.fromWorkingColorSpace(vd(this,dn),t),e.r=dn.r,e.g=dn.g,e.b=dn.b,e}getStyle(e=ls){return ti.fromWorkingColorSpace(vd(this,dn),e),e!==ls?`color(${e} ${dn.r} ${dn.g} ${dn.b})`:`rgb(${dn.r*255|0},${dn.g*255|0},${dn.b*255|0})`}offsetHSL(e,t,n){return this.getHSL(ni),ni.h+=e,ni.s+=t,ni.l+=n,this.setHSL(ni.h,ni.s,ni.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ni),e.getHSL(yd);let n=gu(ni.h,yd.h,t),i=gu(ni.s,yd.s,t),s=gu(ni.l,yd.l,t);return this.setHSL(n,i,s),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};Le.NAMES=Pw;var Pa,Qd=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Pa===void 0&&(Pa=Yd("canvas")),Pa.width=e.width,Pa.height=e.height;let n=Pa.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Pa}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=Yd("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=Fo(s[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Fo(t[n]/255)*255):t[n]=Fo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Zd=class{constructor(e=null){this.isSource=!0,this.uuid=Mi(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(yg(i[o].image)):s.push(yg(i[o]))}else s=yg(i);n.url=s}return t||(e.images[this.uuid]=n),n}};function yg(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?Qd.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var kP=0,Yt=class extends Lt{constructor(e=Yt.DEFAULT_IMAGE,t=Yt.DEFAULT_MAPPING,n=er,i=er,s=at,o=fl,a=si,l=Ut,u=1,c=Mr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kP++}),this.uuid=Mi(),this.name="",this.source=new Zd(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=u,this.format=a,this.internalFormat=null,this.type=l,this.offset=new B(0,0),this.repeat=new B(1,1),this.center=new B(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new jt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Mw)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xa:e.x=e.x-Math.floor(e.x);break;case er:e.x=e.x<0?0:1;break;case Yg:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Xa:e.y=e.y-Math.floor(e.y);break;case er:e.y=e.y<0?0:1;break;case Yg:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}};Yt.DEFAULT_IMAGE=null;Yt.DEFAULT_MAPPING=Mw;var He=class{constructor(e=0,t=0,n=0,i=1){He.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s,l=e.elements,u=l[0],c=l[4],h=l[8],d=l[1],f=l[5],m=l[9],p=l[2],g=l[6],v=l[10];if(Math.abs(c-d)<.01&&Math.abs(h-p)<.01&&Math.abs(m-g)<.01){if(Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(m+g)<.1&&Math.abs(u+f+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let b=(u+1)/2,w=(f+1)/2,S=(v+1)/2,_=(c+d)/4,M=(h+p)/4,x=(m+g)/4;return b>w&&b>S?b<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(b),i=_/n,s=M/n):w>S?w<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(w),n=_/i,s=x/i):S<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(S),n=M/s,i=x/s),this.set(n,i,s,t),this}let y=Math.sqrt((g-m)*(g-m)+(h-p)*(h-p)+(d-c)*(d-c));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(h-p)/y,this.z=(d-c)/y,this.w=Math.acos((u+f+v-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},dt=class extends Lt{constructor(e,t,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new He(0,0,e,t),this.scissorTest=!1,this.viewport=new He(0,0,e,t);let i={width:e,height:t,depth:1};this.texture=new Yt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:at,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new Zd(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Kd=class extends Yt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ft,this.minFilter=Ft,this.wrapR=er,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Jg=class extends Yt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ft,this.minFilter=Ft,this.wrapR=er,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var nt=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerp(e,t,n,i){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),n.slerpQuaternions(e,t,i)}static slerpFlat(e,t,n,i,s,o,a){let l=n[i+0],u=n[i+1],c=n[i+2],h=n[i+3],d=s[o+0],f=s[o+1],m=s[o+2],p=s[o+3];if(a===0){e[t+0]=l,e[t+1]=u,e[t+2]=c,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=f,e[t+2]=m,e[t+3]=p;return}if(h!==p||l!==d||u!==f||c!==m){let g=1-a,v=l*d+u*f+c*m+h*p,y=v>=0?1:-1,b=1-v*v;if(b>Number.EPSILON){let S=Math.sqrt(b),_=Math.atan2(S,v*y);g=Math.sin(g*_)/S,a=Math.sin(a*_)/S}let w=a*y;if(l=l*g+d*w,u=u*g+f*w,c=c*g+m*w,h=h*g+p*w,g===1-a){let S=1/Math.sqrt(l*l+u*u+c*c+h*h);l*=S,u*=S,c*=S,h*=S}}e[t]=l,e[t+1]=u,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,s,o){let a=n[i],l=n[i+1],u=n[i+2],c=n[i+3],h=s[o],d=s[o+1],f=s[o+2],m=s[o+3];return e[t]=a*m+c*h+l*f-u*d,e[t+1]=l*m+c*d+u*h-a*f,e[t+2]=u*m+c*f+a*d-l*h,e[t+3]=c*m-a*h-l*d-u*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");let n=e._x,i=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,u=a(n/2),c=a(i/2),h=a(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=d*c*h+u*f*m,this._y=u*f*h-d*c*m,this._z=u*c*m+d*f*h,this._w=u*c*h-d*f*m;break;case"YXZ":this._x=d*c*h+u*f*m,this._y=u*f*h-d*c*m,this._z=u*c*m-d*f*h,this._w=u*c*h+d*f*m;break;case"ZXY":this._x=d*c*h-u*f*m,this._y=u*f*h+d*c*m,this._z=u*c*m+d*f*h,this._w=u*c*h-d*f*m;break;case"ZYX":this._x=d*c*h-u*f*m,this._y=u*f*h+d*c*m,this._z=u*c*m-d*f*h,this._w=u*c*h+d*f*m;break;case"YZX":this._x=d*c*h+u*f*m,this._y=u*f*h+d*c*m,this._z=u*c*m-d*f*h,this._w=u*c*h-d*f*m;break;case"XZY":this._x=d*c*h-u*f*m,this._y=u*f*h-d*c*m,this._z=u*c*m+d*f*h,this._w=u*c*h+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],s=t[8],o=t[1],a=t[5],l=t[9],u=t[2],c=t[6],h=t[10],d=n+a+h;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(c-l)*f,this._y=(s-u)*f,this._z=(o-i)*f}else if(n>a&&n>h){let f=2*Math.sqrt(1+n-a-h);this._w=(c-l)/f,this._x=.25*f,this._y=(i+o)/f,this._z=(s+u)/f}else if(a>h){let f=2*Math.sqrt(1+a-n-h);this._w=(s-u)/f,this._x=(i+o)/f,this._y=.25*f,this._z=(l+c)/f}else{let f=2*Math.sqrt(1+h-n-a);this._w=(o-i)/f,this._x=(s+u)/f,this._y=(l+c)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(pn(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return t!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,s=e._z,o=e._w,a=t._x,l=t._y,u=t._z,c=t._w;return this._x=n*c+o*a+i*u-s*l,this._y=i*c+o*l+s*a-n*u,this._z=s*c+o*u+n*l-i*a,this._w=o*c-n*a-i*l-s*u,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+i*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=s,this;let l=1-a*a;if(l<=Number.EPSILON){let f=1-t;return this._w=f*o+t*this._w,this._x=f*n+t*this._x,this._y=f*i+t*this._y,this._z=f*s+t*this._z,this.normalize(),this._onChangeCallback(),this}let u=Math.sqrt(l),c=Math.atan2(u,a),h=Math.sin((1-t)*c)/u,d=Math.sin(t*c)/u;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),s=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(s),n*Math.cos(s),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},A=class{constructor(e=0,t=0,n=0){A.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return t!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return t!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(_b.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(_b.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z,l=e.w,u=l*t+o*i-a*n,c=l*n+a*t-s*i,h=l*i+s*n-o*t,d=-s*t-o*n-a*i;return this.x=u*l+d*-s+c*-a-h*-o,this.y=c*l+d*-o+h*-s-u*-a,this.z=h*l+d*-a+u*-o-c*-s,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return t!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-s*a,this.y=s*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return vg.copy(this).projectOnVector(e),this.sub(vg)}reflect(e){return this.sub(vg.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(pn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return n!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},vg=new A,_b=new nt,Mt=class{constructor(e=new A(1/0,1/0,1/0),t=new A(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=e.length;l<u;l+=3){let c=e[l],h=e[l+1],d=e[l+2];c<t&&(t=c),h<n&&(n=h),d<i&&(i=d),c>s&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,s=-1/0,o=-1/0,a=-1/0;for(let l=0,u=e.count;l<u;l++){let c=e.getX(l),h=e.getY(l),d=e.getZ(l);c<t&&(t=c),h<n&&(n=h),d<i&&(i=d),c>s&&(s=c),h>o&&(o=h),d>a&&(a=d)}return this.min.set(t,n,i),this.max.set(s,o,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=Do.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0)if(t&&n.attributes!=null&&n.attributes.position!==void 0){let s=n.attributes.position;for(let o=0,a=s.count;o<a;o++)Do.fromBufferAttribute(s,o).applyMatrix4(e.matrixWorld),this.expandByPoint(Do)}else n.boundingBox===null&&n.computeBoundingBox(),xg.copy(n.boundingBox),xg.applyMatrix4(e.matrixWorld),this.union(xg);let i=e.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Do),Do.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(cu),xd.subVectors(this.max,cu),Da.subVectors(e.a,cu),Ia.subVectors(e.b,cu),La.subVectors(e.c,cu),Es.subVectors(Ia,Da),Cs.subVectors(La,Ia),Io.subVectors(Da,La);let t=[0,-Es.z,Es.y,0,-Cs.z,Cs.y,0,-Io.z,Io.y,Es.z,0,-Es.x,Cs.z,0,-Cs.x,Io.z,0,-Io.x,-Es.y,Es.x,0,-Cs.y,Cs.x,0,-Io.y,Io.x,0];return!bg(t,Da,Ia,La,xd)||(t=[1,0,0,0,1,0,0,0,1],!bg(t,Da,Ia,La,xd))?!1:(bd.crossVectors(Es,Cs),t=[bd.x,bd.y,bd.z],bg(t,Da,Ia,La,xd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Do.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Do).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ns[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ns[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ns[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ns[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ns[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ns[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ns[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ns[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ns),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},ns=[new A,new A,new A,new A,new A,new A,new A,new A],Do=new A,xg=new Mt,Da=new A,Ia=new A,La=new A,Es=new A,Cs=new A,Io=new A,cu=new A,xd=new A,bd=new A,Lo=new A;function bg(r,e,t,n,i){for(let s=0,o=r.length-3;s<=o;s+=3){Lo.fromArray(r,s);let a=i.x*Math.abs(Lo.x)+i.y*Math.abs(Lo.y)+i.z*Math.abs(Lo.z),l=e.dot(Lo),u=t.dot(Lo),c=n.dot(Lo);if(Math.max(-Math.max(l,u,c),Math.min(l,u,c))>a)return!1}return!0}var VP=new Mt,Tb=new A,wd=new A,wg=new A,En=class{constructor(e=new A,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):VP.setFromPoints(e).getCenter(n);let i=0;for(let s=0,o=e.length;s<o;s++)i=Math.max(i,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){wg.subVectors(e,this.center);let t=wg.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.add(wg.multiplyScalar(i/n)),this.radius+=i}return this}union(e){return this.center.equals(e.center)===!0?wd.set(0,0,1).multiplyScalar(e.radius):wd.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Tb.copy(e.center).add(wd)),this.expandByPoint(Tb.copy(e.center).sub(wd)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},rs=new A,Sg=new A,Sd=new A,Ps=new A,Ag=new A,Ad=new A,_g=new A,oi=class{constructor(e=new A,t=new A(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,rs)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=rs.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(rs.copy(this.direction).multiplyScalar(t).add(this.origin),rs.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Sg.copy(e).add(t).multiplyScalar(.5),Sd.copy(t).sub(e).normalize(),Ps.copy(this.origin).sub(Sg);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Sd),a=Ps.dot(this.direction),l=-Ps.dot(Sd),u=Ps.lengthSq(),c=Math.abs(1-o*o),h,d,f,m;if(c>0)if(h=o*l-a,d=o*a-l,m=s*c,h>=0)if(d>=-m)if(d<=m){let p=1/c;h*=p,d*=p,f=h*(h+o*d+2*a)+d*(o*h+d+2*l)+u}else d=s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d=-s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;else d<=-m?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+u):d<=m?(h=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+u):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-l),s),f=-h*h+d*(d+2*l)+u);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),f=-h*h+d*(d+2*l)+u;return n&&n.copy(this.direction).multiplyScalar(h).add(this.origin),i&&i.copy(Sd).multiplyScalar(d).add(Sg),f}intersectSphere(e,t){rs.subVectors(e.center,this.origin);let n=rs.dot(this.direction),i=rs.dot(rs)-n*n,s=e.radius*e.radius;if(i>s)return null;let o=Math.sqrt(s-i),a=n-o,l=n+o;return a<0&&l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,s,o,a,l,u=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return u>=0?(n=(e.min.x-d.x)*u,i=(e.max.x-d.x)*u):(n=(e.max.x-d.x)*u,i=(e.min.x-d.x)*u),c>=0?(s=(e.min.y-d.y)*c,o=(e.max.y-d.y)*c):(s=(e.max.y-d.y)*c,o=(e.min.y-d.y)*c),n>o||s>i||((s>n||n!==n)&&(n=s),(o<i||i!==i)&&(i=o),h>=0?(a=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||a>i)||((a>n||n!==n)&&(n=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,rs)!==null}intersectTriangle(e,t,n,i,s){Ag.subVectors(t,e),Ad.subVectors(n,e),_g.crossVectors(Ag,Ad);let o=this.direction.dot(_g),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Ps.subVectors(this.origin,e);let l=a*this.direction.dot(Ad.crossVectors(Ps,Ad));if(l<0)return null;let u=a*this.direction.dot(Ag.cross(Ps));if(u<0||l+u>o)return null;let c=-a*Ps.dot(_g);return c<0?null:this.at(c/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},be=class{constructor(){be.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,s,o,a,l,u,c,h,d,f,m,p,g){let v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=s,v[5]=o,v[9]=a,v[13]=l,v[2]=u,v[6]=c,v[10]=h,v[14]=d,v[3]=f,v[7]=m,v[11]=p,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new be().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/Oa.setFromMatrixColumn(e,0).length(),s=1/Oa.setFromMatrixColumn(e,1).length(),o=1/Oa.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");let t=this.elements,n=e.x,i=e.y,s=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),u=Math.sin(i),c=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=o*c,f=o*h,m=a*c,p=a*h;t[0]=l*c,t[4]=-l*h,t[8]=u,t[1]=f+m*u,t[5]=d-p*u,t[9]=-a*l,t[2]=p-d*u,t[6]=m+f*u,t[10]=o*l}else if(e.order==="YXZ"){let d=l*c,f=l*h,m=u*c,p=u*h;t[0]=d+p*a,t[4]=m*a-f,t[8]=o*u,t[1]=o*h,t[5]=o*c,t[9]=-a,t[2]=f*a-m,t[6]=p+d*a,t[10]=o*l}else if(e.order==="ZXY"){let d=l*c,f=l*h,m=u*c,p=u*h;t[0]=d-p*a,t[4]=-o*h,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*c,t[9]=p-d*a,t[2]=-o*u,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let d=o*c,f=o*h,m=a*c,p=a*h;t[0]=l*c,t[4]=m*u-f,t[8]=d*u+p,t[1]=l*h,t[5]=p*u+d,t[9]=f*u-m,t[2]=-u,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let d=o*l,f=o*u,m=a*l,p=a*u;t[0]=l*c,t[4]=p-d*h,t[8]=m*h+f,t[1]=h,t[5]=o*c,t[9]=-a*c,t[2]=-u*c,t[6]=f*h+m,t[10]=d-p*h}else if(e.order==="XZY"){let d=o*l,f=o*u,m=a*l,p=a*u;t[0]=l*c,t[4]=-h,t[8]=u*c,t[1]=d*h+p,t[5]=o*c,t[9]=f*h-m,t[2]=m*h-f,t[6]=a*c,t[10]=p*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(HP,e,WP)}lookAt(e,t,n){let i=this.elements;return _r.subVectors(e,t),_r.lengthSq()===0&&(_r.z=1),_r.normalize(),Ds.crossVectors(n,_r),Ds.lengthSq()===0&&(Math.abs(n.z)===1?_r.x+=1e-4:_r.z+=1e-4,_r.normalize(),Ds.crossVectors(n,_r)),Ds.normalize(),_d.crossVectors(_r,Ds),i[0]=Ds.x,i[4]=_d.x,i[8]=_r.x,i[1]=Ds.y,i[5]=_d.y,i[9]=_r.y,i[2]=Ds.z,i[6]=_d.z,i[10]=_r.z,this}multiply(e,t){return t!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,s=this.elements,o=n[0],a=n[4],l=n[8],u=n[12],c=n[1],h=n[5],d=n[9],f=n[13],m=n[2],p=n[6],g=n[10],v=n[14],y=n[3],b=n[7],w=n[11],S=n[15],_=i[0],M=i[4],x=i[8],T=i[12],E=i[1],C=i[5],P=i[9],O=i[13],D=i[2],N=i[6],F=i[10],z=i[14],Y=i[3],U=i[7],G=i[11],Q=i[15];return s[0]=o*_+a*E+l*D+u*Y,s[4]=o*M+a*C+l*N+u*U,s[8]=o*x+a*P+l*F+u*G,s[12]=o*T+a*O+l*z+u*Q,s[1]=c*_+h*E+d*D+f*Y,s[5]=c*M+h*C+d*N+f*U,s[9]=c*x+h*P+d*F+f*G,s[13]=c*T+h*O+d*z+f*Q,s[2]=m*_+p*E+g*D+v*Y,s[6]=m*M+p*C+g*N+v*U,s[10]=m*x+p*P+g*F+v*G,s[14]=m*T+p*O+g*z+v*Q,s[3]=y*_+b*E+w*D+S*Y,s[7]=y*M+b*C+w*N+S*U,s[11]=y*x+b*P+w*F+S*G,s[15]=y*T+b*O+w*z+S*Q,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],o=e[1],a=e[5],l=e[9],u=e[13],c=e[2],h=e[6],d=e[10],f=e[14],m=e[3],p=e[7],g=e[11],v=e[15];return m*(+s*l*h-i*u*h-s*a*d+n*u*d+i*a*f-n*l*f)+p*(+t*l*f-t*u*d+s*o*d-i*o*f+i*u*c-s*l*c)+g*(+t*u*h-t*a*f-s*o*h+n*o*f+s*a*c-n*u*c)+v*(-i*a*c-t*l*h+t*a*d+i*o*h-n*o*d+n*l*c)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],f=e[11],m=e[12],p=e[13],g=e[14],v=e[15],y=h*g*u-p*d*u+p*l*f-a*g*f-h*l*v+a*d*v,b=m*d*u-c*g*u-m*l*f+o*g*f+c*l*v-o*d*v,w=c*p*u-m*h*u+m*a*f-o*p*f-c*a*v+o*h*v,S=m*h*l-c*p*l-m*a*d+o*p*d+c*a*g-o*h*g,_=t*y+n*b+i*w+s*S;if(_===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/_;return e[0]=y*M,e[1]=(p*d*s-h*g*s-p*i*f+n*g*f+h*i*v-n*d*v)*M,e[2]=(a*g*s-p*l*s+p*i*u-n*g*u-a*i*v+n*l*v)*M,e[3]=(h*l*s-a*d*s-h*i*u+n*d*u+a*i*f-n*l*f)*M,e[4]=b*M,e[5]=(c*g*s-m*d*s+m*i*f-t*g*f-c*i*v+t*d*v)*M,e[6]=(m*l*s-o*g*s-m*i*u+t*g*u+o*i*v-t*l*v)*M,e[7]=(o*d*s-c*l*s+c*i*u-t*d*u-o*i*f+t*l*f)*M,e[8]=w*M,e[9]=(m*h*s-c*p*s-m*n*f+t*p*f+c*n*v-t*h*v)*M,e[10]=(o*p*s-m*a*s+m*n*u-t*p*u-o*n*v+t*a*v)*M,e[11]=(c*a*s-o*h*s-c*n*u+t*h*u+o*n*f-t*a*f)*M,e[12]=S*M,e[13]=(c*p*i-m*h*i+m*n*d-t*p*d-c*n*g+t*h*g)*M,e[14]=(m*a*i-o*p*i-m*n*l+t*p*l+o*n*g-t*a*g)*M,e[15]=(o*h*i-c*a*i+c*n*l-t*h*l-o*n*d+t*a*d)*M,this}scale(e){let t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),s=1-n,o=e.x,a=e.y,l=e.z,u=s*o,c=s*a;return this.set(u*o+n,u*a-i*l,u*l+i*a,0,u*a+i*l,c*a+n,c*l-i*o,0,u*l-i*a,c*l+i*o,s*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,o){return this.set(1,n,s,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,s=t._x,o=t._y,a=t._z,l=t._w,u=s+s,c=o+o,h=a+a,d=s*u,f=s*c,m=s*h,p=o*c,g=o*h,v=a*h,y=l*u,b=l*c,w=l*h,S=n.x,_=n.y,M=n.z;return i[0]=(1-(p+v))*S,i[1]=(f+w)*S,i[2]=(m-b)*S,i[3]=0,i[4]=(f-w)*_,i[5]=(1-(d+v))*_,i[6]=(g+y)*_,i[7]=0,i[8]=(m+b)*M,i[9]=(g-y)*M,i[10]=(1-(d+p))*M,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,s=Oa.set(i[0],i[1],i[2]).length(),o=Oa.set(i[4],i[5],i[6]).length(),a=Oa.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],ri.copy(this);let u=1/s,c=1/o,h=1/a;return ri.elements[0]*=u,ri.elements[1]*=u,ri.elements[2]*=u,ri.elements[4]*=c,ri.elements[5]*=c,ri.elements[6]*=c,ri.elements[8]*=h,ri.elements[9]*=h,ri.elements[10]*=h,t.setFromRotationMatrix(ri),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,i,s,o){o===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");let a=this.elements,l=2*s/(t-e),u=2*s/(n-i),c=(t+e)/(t-e),h=(n+i)/(n-i),d=-(o+s)/(o-s),f=-2*o*s/(o-s);return a[0]=l,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=u,a[9]=h,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,s,o){let a=this.elements,l=1/(t-e),u=1/(n-i),c=1/(o-s),h=(t+e)*l,d=(n+i)*u,f=(o+s)*c;return a[0]=2*l,a[4]=0,a[8]=0,a[12]=-h,a[1]=0,a[5]=2*u,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},Oa=new A,ri=new be,HP=new A(0,0,0),WP=new A(1,1,1),Ds=new A,_d=new A,_r=new A,Mb=new be,Eb=new nt,Qt=class{constructor(e=0,t=0,n=0,i=Qt.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,s=i[0],o=i[4],a=i[8],l=i[1],u=i[5],c=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(pn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,f),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,u),this._z=0);break;case"YXZ":this._x=Math.asin(-pn(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(pn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-pn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(pn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-pn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,u),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-c,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Mb.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Mb,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Eb.setFromEuler(this),this.setFromQuaternion(Eb,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}};Qt.DefaultOrder="XYZ";Qt.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var Su=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},jP=0,Cb=new A,Ra=new nt,is=new be,Td=new A,uu=new A,qP=new A,XP=new nt,Pb=new A(1,0,0),Db=new A(0,1,0),Ib=new A(0,0,1),YP={type:"added"},Lb={type:"removed"},ht=class extends Lt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jP++}),this.uuid=Mi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ht.DefaultUp.clone();let e=new A,t=new Qt,n=new nt,i=new A(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new be},normalMatrix:{value:new jt}}),this.matrix=new be,this.matrixWorld=new be,this.matrixAutoUpdate=ht.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Su,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ra.setFromAxisAngle(e,t),this.quaternion.multiply(Ra),this}rotateOnWorldAxis(e,t){return Ra.setFromAxisAngle(e,t),this.quaternion.premultiply(Ra),this}rotateX(e){return this.rotateOnAxis(Pb,e)}rotateY(e){return this.rotateOnAxis(Db,e)}rotateZ(e){return this.rotateOnAxis(Ib,e)}translateOnAxis(e,t){return Cb.copy(e).applyQuaternion(this.quaternion),this.position.add(Cb.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Pb,e)}translateY(e){return this.translateOnAxis(Db,e)}translateZ(e){return this.translateOnAxis(Ib,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(is.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Td.copy(e):Td.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),uu.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?is.lookAt(uu,Td,this.up):is.lookAt(Td,uu,this.up),this.quaternion.setFromRotationMatrix(is),i&&(is.extractRotation(i.matrixWorld),Ra.setFromRotationMatrix(is),this.quaternion.premultiply(Ra.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(YP)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Lb)),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){let t=this.children[e];t.parent=null,t.dispatchEvent(Lb)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),is.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),is.multiply(e.parent.matrixWorld)),e.applyMatrix4(is),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uu,e,qP),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(uu,XP,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){let i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let u=0,c=l.length;u<c;u++){let h=l[u];s(e.shapes,h)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,u=this.material.length;l<u;l++)a.push(s(e.materials,this.material[l]));i.material=a}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];i.animations.push(s(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),u=o(e.textures),c=o(e.images),h=o(e.shapes),d=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),u.length>0&&(n.textures=u),c.length>0&&(n.images=c),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function o(a){let l=[];for(let u in a){let c=a[u];delete c.metadata,l.push(c)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};ht.DefaultUp=new A(0,1,0);ht.DefaultMatrixAutoUpdate=!0;var ii=new A,ss=new A,Tg=new A,os=new A,Na=new A,Ba=new A,Ob=new A,Mg=new A,Eg=new A,Cg=new A,Mn=class{constructor(e=new A,t=new A,n=new A){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ii.subVectors(e,t),i.cross(ii);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,n,i,s){ii.subVectors(i,t),ss.subVectors(n,t),Tg.subVectors(e,t);let o=ii.dot(ii),a=ii.dot(ss),l=ii.dot(Tg),u=ss.dot(ss),c=ss.dot(Tg),h=o*u-a*a;if(h===0)return s.set(-2,-1,-1);let d=1/h,f=(u*l-a*c)*d,m=(o*c-a*l)*d;return s.set(1-f-m,m,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,os),os.x>=0&&os.y>=0&&os.x+os.y<=1}static getUV(e,t,n,i,s,o,a,l){return this.getBarycoord(e,t,n,i,os),l.set(0,0),l.addScaledVector(s,os.x),l.addScaledVector(o,os.y),l.addScaledVector(a,os.z),l}static isFrontFacing(e,t,n,i){return ii.subVectors(n,t),ss.subVectors(e,t),ii.cross(ss).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ii.subVectors(this.c,this.b),ss.subVectors(this.a,this.b),ii.cross(ss).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Mn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Mn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,s){return Mn.getUV(e,this.a,this.b,this.c,t,n,i,s)}containsPoint(e){return Mn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Mn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,s=this.c,o,a;Na.subVectors(i,n),Ba.subVectors(s,n),Mg.subVectors(e,n);let l=Na.dot(Mg),u=Ba.dot(Mg);if(l<=0&&u<=0)return t.copy(n);Eg.subVectors(e,i);let c=Na.dot(Eg),h=Ba.dot(Eg);if(c>=0&&h<=c)return t.copy(i);let d=l*h-c*u;if(d<=0&&l>=0&&c<=0)return o=l/(l-c),t.copy(n).addScaledVector(Na,o);Cg.subVectors(e,s);let f=Na.dot(Cg),m=Ba.dot(Cg);if(m>=0&&f<=m)return t.copy(s);let p=f*u-l*m;if(p<=0&&u>=0&&m<=0)return a=u/(u-m),t.copy(n).addScaledVector(Ba,a);let g=c*m-f*h;if(g<=0&&h-c>=0&&f-m>=0)return Ob.subVectors(s,i),a=(h-c)/(h-c+(f-m)),t.copy(i).addScaledVector(Ob,a);let v=1/(g+p+d);return o=p*v,a=d*v,t.copy(n).addScaledVector(Na,o).addScaledVector(Ba,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},QP=0,Uo=class extends Lt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:QP++}),this.uuid=Mi(),this.name="",this.type="Material",this.blending=Ns,this.side=Gr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=Aw,this.blendDst=_w,this.blendEquation=Ha,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=jg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=AP,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pg,this.stencilZFail=pg,this.stencilZPass=pg,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if(t==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===IC;continue}let i=this[t];if(i===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ns&&(n.blending=this.blending),this.side!==Gr&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData);function i(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=i(e.textures),o=i(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let i=t.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Au=class extends Uo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Le(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Tw,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},cn=new A,Md=new B,Ge=class{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n===!0,this.usage=Qg,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new Le),t[n++]=o.r,t[n++]=o.g,t[n++]=o.b}return this}copyVector2sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new B),t[n++]=o.x,t[n++]=o.y}return this}copyVector3sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new A),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z}return this}copyVector4sArray(e){let t=this.array,n=0;for(let i=0,s=e.length;i<s;i++){let o=e[i];o===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new He),t[n++]=o.x,t[n++]=o.y,t[n++]=o.z,t[n++]=o.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Md.fromBufferAttribute(this,t),Md.applyMatrix3(e),this.setXY(t,Md.x,Md.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix3(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyMatrix4(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.applyNormalMatrix(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)cn.fromBufferAttribute(this,t),cn.transformDirection(e),this.setXYZ(t,cn.x,cn.y,cn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){return this.array[e*this.itemSize]}setX(e,t){return this.array[e*this.itemSize]=t,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,t){return this.array[e*this.itemSize+1]=t,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,t){return this.array[e*this.itemSize+2]=t,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,t){return this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Qg&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}};var Jd=class extends Ge{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var zs=class extends Ge{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Ae=class extends Ge{constructor(e,t,n){super(new Float32Array(e),t,n)}};var ZP=0,Ur=new be,Pg=new ht,Fa=new A,Tr=new Mt,hu=new Mt,Tn=new A,De=class extends Lt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ZP++}),this.uuid=Mi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Cw(e)?zs:Jd)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new jt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ur.makeRotationFromQuaternion(e),this.applyMatrix4(Ur),this}rotateX(e){return Ur.makeRotationX(e),this.applyMatrix4(Ur),this}rotateY(e){return Ur.makeRotationY(e),this.applyMatrix4(Ur),this}rotateZ(e){return Ur.makeRotationZ(e),this.applyMatrix4(Ur),this}translate(e,t,n){return Ur.makeTranslation(e,t,n),this.applyMatrix4(Ur),this}scale(e,t,n){return Ur.makeScale(e,t,n),this.applyMatrix4(Ur),this}lookAt(e){return Pg.lookAt(e),Pg.updateMatrix(),this.applyMatrix4(Pg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Fa).negate(),this.translate(Fa.x,Fa.y,Fa.z),this}setFromPoints(e){let t=[];for(let n=0,i=e.length;n<i;n++){let s=e[n];t.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new Ae(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let s=t[n];Tr.setFromBufferAttribute(s),this.morphTargetsRelative?(Tn.addVectors(this.boundingBox.min,Tr.min),this.boundingBox.expandByPoint(Tn),Tn.addVectors(this.boundingBox.max,Tr.max),this.boundingBox.expandByPoint(Tn)):(this.boundingBox.expandByPoint(Tr.min),this.boundingBox.expandByPoint(Tr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new En);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new A,1/0);return}if(e){let n=this.boundingSphere.center;if(Tr.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];hu.setFromBufferAttribute(a),this.morphTargetsRelative?(Tn.addVectors(Tr.min,hu.min),Tr.expandByPoint(Tn),Tn.addVectors(Tr.max,hu.max),Tr.expandByPoint(Tn)):(Tr.expandByPoint(hu.min),Tr.expandByPoint(hu.max))}Tr.getCenter(n);let i=0;for(let s=0,o=e.count;s<o;s++)Tn.fromBufferAttribute(e,s),i=Math.max(i,n.distanceToSquared(Tn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],l=this.morphTargetsRelative;for(let u=0,c=a.count;u<c;u++)Tn.fromBufferAttribute(a,u),l&&(Fa.fromBufferAttribute(e,u),Tn.add(Fa)),i=Math.max(i,n.distanceToSquared(Tn))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.array,i=t.position.array,s=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ge(new Float32Array(4*a),4));let l=this.getAttribute("tangent").array,u=[],c=[];for(let E=0;E<a;E++)u[E]=new A,c[E]=new A;let h=new A,d=new A,f=new A,m=new B,p=new B,g=new B,v=new A,y=new A;function b(E,C,P){h.fromArray(i,E*3),d.fromArray(i,C*3),f.fromArray(i,P*3),m.fromArray(o,E*2),p.fromArray(o,C*2),g.fromArray(o,P*2),d.sub(h),f.sub(h),p.sub(m),g.sub(m);let O=1/(p.x*g.y-g.x*p.y);!isFinite(O)||(v.copy(d).multiplyScalar(g.y).addScaledVector(f,-p.y).multiplyScalar(O),y.copy(f).multiplyScalar(p.x).addScaledVector(d,-g.x).multiplyScalar(O),u[E].add(v),u[C].add(v),u[P].add(v),c[E].add(y),c[C].add(y),c[P].add(y))}let w=this.groups;w.length===0&&(w=[{start:0,count:n.length}]);for(let E=0,C=w.length;E<C;++E){let P=w[E],O=P.start,D=P.count;for(let N=O,F=O+D;N<F;N+=3)b(n[N+0],n[N+1],n[N+2])}let S=new A,_=new A,M=new A,x=new A;function T(E){M.fromArray(s,E*3),x.copy(M);let C=u[E];S.copy(C),S.sub(M.multiplyScalar(M.dot(C))).normalize(),_.crossVectors(x,C);let O=_.dot(c[E])<0?-1:1;l[E*4]=S.x,l[E*4+1]=S.y,l[E*4+2]=S.z,l[E*4+3]=O}for(let E=0,C=w.length;E<C;++E){let P=w[E],O=P.start,D=P.count;for(let N=O,F=O+D;N<F;N+=3)T(n[N+0]),T(n[N+1]),T(n[N+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Ge(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);let i=new A,s=new A,o=new A,a=new A,l=new A,u=new A,c=new A,h=new A;if(e)for(let d=0,f=e.count;d<f;d+=3){let m=e.getX(d+0),p=e.getX(d+1),g=e.getX(d+2);i.fromBufferAttribute(t,m),s.fromBufferAttribute(t,p),o.fromBufferAttribute(t,g),c.subVectors(o,s),h.subVectors(i,s),c.cross(h),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,p),u.fromBufferAttribute(n,g),a.add(c),l.add(c),u.add(c),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(p,l.x,l.y,l.z),n.setXYZ(g,u.x,u.y,u.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),c.subVectors(o,s),h.subVectors(i,s),c.cross(h),n.setXYZ(d+0,c.x,c.y,c.z),n.setXYZ(d+1,c.x,c.y,c.z),n.setXYZ(d+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(e,t){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}t===void 0&&(t=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));let n=this.attributes;for(let i in n){if(e.attributes[i]===void 0)continue;let o=n[i].array,a=e.attributes[i],l=a.array,u=a.itemSize*t,c=Math.min(l.length,o.length-u);for(let h=0,d=u;h<c;h++,d++)o[d]=l[h]}return this}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Tn.fromBufferAttribute(e,t),Tn.normalize(),e.setXYZ(t,Tn.x,Tn.y,Tn.z)}toNonIndexed(){function e(a,l){let u=a.array,c=a.itemSize,h=a.normalized,d=new u.constructor(l.length*c),f=0,m=0;for(let p=0,g=l.length;p<g;p++){a.isInterleavedBufferAttribute?f=l[p]*a.data.stride+a.offset:f=l[p]*c;for(let v=0;v<c;v++)d[m++]=u[f++]}return new Ge(d,c,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new De,n=this.index.array,i=this.attributes;for(let a in i){let l=i[a],u=e(l,n);t.setAttribute(a,u)}let s=this.morphAttributes;for(let a in s){let l=[],u=s[a];for(let c=0,h=u.length;c<h;c++){let d=u[c],f=e(d,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let u=o[a];t.addGroup(u.start,u.count,u.materialIndex)}return t}toJSON(){let e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let u in l)l[u]!==void 0&&(e[u]=l[u]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let u=n[l];e.data.attributes[l]=u.toJSON(e.data)}let i={},s=!1;for(let l in this.morphAttributes){let u=this.morphAttributes[l],c=[];for(let h=0,d=u.length;h<d;h++){let f=u[h];c.push(f.toJSON(e.data))}c.length>0&&(i[l]=c,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let u in i){let c=i[u];this.setAttribute(u,c.clone(t))}let s=e.morphAttributes;for(let u in s){let c=[],h=s[u];for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone(t));this.morphAttributes[u]=c}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let u=0,c=o.length;u<c;u++){let h=o[u];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}},Rb=new be,Ua=new oi,Dg=new En,Is=new A,Ls=new A,Os=new A,Ig=new A,Lg=new A,Og=new A,Ed=new A,Cd=new A,Pd=new A,Dd=new B,Id=new B,Ld=new B,Rg=new A,Od=new A,rn=class extends ht{constructor(e=new De,t=new Au){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}raycast(e,t){let n=this.geometry,i=this.material,s=this.matrixWorld;if(i===void 0||(n.boundingSphere===null&&n.computeBoundingSphere(),Dg.copy(n.boundingSphere),Dg.applyMatrix4(s),e.ray.intersectsSphere(Dg)===!1)||(Rb.copy(s).invert(),Ua.copy(e.ray).applyMatrix4(Rb),n.boundingBox!==null&&Ua.intersectsBox(n.boundingBox)===!1))return;let o,a=n.index,l=n.attributes.position,u=n.morphAttributes.position,c=n.morphTargetsRelative,h=n.attributes.uv,d=n.attributes.uv2,f=n.groups,m=n.drawRange;if(a!==null)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let v=f[p],y=i[v.materialIndex],b=Math.max(v.start,m.start),w=Math.min(a.count,Math.min(v.start+v.count,m.start+m.count));for(let S=b,_=w;S<_;S+=3){let M=a.getX(S),x=a.getX(S+1),T=a.getX(S+2);o=Rd(this,y,e,Ua,l,u,c,h,d,M,x,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=v.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(a.count,m.start+m.count);for(let v=p,y=g;v<y;v+=3){let b=a.getX(v),w=a.getX(v+1),S=a.getX(v+2);o=Rd(this,i,e,Ua,l,u,c,h,d,b,w,S),o&&(o.faceIndex=Math.floor(v/3),t.push(o))}}else if(l!==void 0)if(Array.isArray(i))for(let p=0,g=f.length;p<g;p++){let v=f[p],y=i[v.materialIndex],b=Math.max(v.start,m.start),w=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let S=b,_=w;S<_;S+=3){let M=S,x=S+1,T=S+2;o=Rd(this,y,e,Ua,l,u,c,h,d,M,x,T),o&&(o.faceIndex=Math.floor(S/3),o.face.materialIndex=v.materialIndex,t.push(o))}}else{let p=Math.max(0,m.start),g=Math.min(l.count,m.start+m.count);for(let v=p,y=g;v<y;v+=3){let b=v,w=v+1,S=v+2;o=Rd(this,i,e,Ua,l,u,c,h,d,b,w,S),o&&(o.faceIndex=Math.floor(v/3),t.push(o))}}}};function KP(r,e,t,n,i,s,o,a){let l;if(e.side===un?l=n.intersectTriangle(o,s,i,!0,a):l=n.intersectTriangle(i,s,o,e.side!==tr,a),l===null)return null;Od.copy(a),Od.applyMatrix4(r.matrixWorld);let u=t.ray.origin.distanceTo(Od);return u<t.near||u>t.far?null:{distance:u,point:Od.clone(),object:r}}function Rd(r,e,t,n,i,s,o,a,l,u,c,h){Is.fromBufferAttribute(i,u),Ls.fromBufferAttribute(i,c),Os.fromBufferAttribute(i,h);let d=r.morphTargetInfluences;if(s&&d){Ed.set(0,0,0),Cd.set(0,0,0),Pd.set(0,0,0);for(let m=0,p=s.length;m<p;m++){let g=d[m],v=s[m];g!==0&&(Ig.fromBufferAttribute(v,u),Lg.fromBufferAttribute(v,c),Og.fromBufferAttribute(v,h),o?(Ed.addScaledVector(Ig,g),Cd.addScaledVector(Lg,g),Pd.addScaledVector(Og,g)):(Ed.addScaledVector(Ig.sub(Is),g),Cd.addScaledVector(Lg.sub(Ls),g),Pd.addScaledVector(Og.sub(Os),g)))}Is.add(Ed),Ls.add(Cd),Os.add(Pd)}r.isSkinnedMesh&&(r.boneTransform(u,Is),r.boneTransform(c,Ls),r.boneTransform(h,Os));let f=KP(r,e,t,n,Is,Ls,Os,Rg);if(f){a&&(Dd.fromBufferAttribute(a,u),Id.fromBufferAttribute(a,c),Ld.fromBufferAttribute(a,h),f.uv=Mn.getUV(Rg,Is,Ls,Os,Dd,Id,Ld,new B)),l&&(Dd.fromBufferAttribute(l,u),Id.fromBufferAttribute(l,c),Ld.fromBufferAttribute(l,h),f.uv2=Mn.getUV(Rg,Is,Ls,Os,Dd,Id,Ld,new B));let m={a:u,b:c,c:h,normal:new A,materialIndex:0};Mn.getNormal(Is,Ls,Os,m.normal),f.face=m}return f}var ur=class extends De{constructor(e=1,t=1,n=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o};let a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);let l=[],u=[],c=[],h=[],d=0,f=0;m("z","y","x",-1,-1,n,t,e,o,s,0),m("z","y","x",1,-1,n,t,-e,o,s,1),m("x","z","y",1,1,e,n,t,i,o,2),m("x","z","y",1,-1,e,n,-t,i,o,3),m("x","y","z",1,-1,e,t,n,i,s,4),m("x","y","z",-1,-1,e,t,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function m(p,g,v,y,b,w,S,_,M,x,T){let E=w/M,C=S/x,P=w/2,O=S/2,D=_/2,N=M+1,F=x+1,z=0,Y=0,U=new A;for(let G=0;G<F;G++){let Q=G*C-O;for(let V=0;V<N;V++){let k=V*E-P;U[p]=k*y,U[g]=Q*b,U[v]=D,u.push(U.x,U.y,U.z),U[p]=0,U[g]=0,U[v]=_>0?1:-1,c.push(U.x,U.y,U.z),h.push(V/M),h.push(1-G/x),z+=1}}for(let G=0;G<x;G++)for(let Q=0;Q<M;Q++){let V=d+Q+N*G,k=d+Q+N*(G+1),j=d+(Q+1)+N*(G+1),q=d+(Q+1)+N*G;l.push(V,k,q),l.push(k,j,q),Y+=6}a.addGroup(f,Y,T),f+=Y,d+=z}}static fromJSON(e){return new ur(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Ya(r){let e={};for(let t in r){e[t]={};for(let n in r[t]){let i=r[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Hn(r){let e={};for(let t=0;t<r.length;t++){let n=Ya(r[t]);for(let i in n)e[i]=n[i]}return e}var ci={clone:Ya,merge:Hn},JP=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
3
  }`,$P=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
@@ -37,7 +37,7 @@ var SC=Object.create;var lg=Object.defineProperty;var AC=Object.getOwnPropertyDe
37
37
  gl_FragColor = texture2D( tEquirect, sampleUV );
38
38
 
39
39
  }
40
- `},i=new ur(5,5,5),s=new mt({name:"CubemapFromEquirect",uniforms:Ya(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:un,blending:Rt});s.uniforms.tEquirect.value=t;let o=new rn(i,s),a=t.minFilter;return t.minFilter===fl&&(t.minFilter=at),new $g(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}},Ng=new A,e2=new A,t2=new jt,mn=class{constructor(e=new A(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Ng.subVectors(n,t).cross(e2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let n=e.delta(Ng),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||t2.getNormalMatrix(e),i=this.coplanarPoint(Ng).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},ka=new En,Nd=new A,_u=class{constructor(e=new mn,t=new mn,n=new mn,i=new mn,s=new mn,o=new mn){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,i=n[0],s=n[1],o=n[2],a=n[3],l=n[4],u=n[5],c=n[6],h=n[7],d=n[8],f=n[9],m=n[10],p=n[11],g=n[12],v=n[13],y=n[14],w=n[15];return t[0].setComponents(a-i,h-l,p-d,w-g).normalize(),t[1].setComponents(a+i,h+l,p+d,w+g).normalize(),t[2].setComponents(a+s,h+u,p+f,w+v).normalize(),t[3].setComponents(a-s,h-u,p-f,w-v).normalize(),t[4].setComponents(a-o,h-c,p-m,w-y).normalize(),t[5].setComponents(a+o,h+c,p+m,w+y).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),ka.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(ka)}intersectsSprite(e){return ka.center.set(0,0,0),ka.radius=.7071067811865476,ka.applyMatrix4(e.matrixWorld),this.intersectsSphere(ka)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Nd.x=i.normal.x>0?e.max.x:e.min.x,Nd.y=i.normal.y>0?e.max.y:e.min.y,Nd.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Nd)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Dw(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function n2(r,e){let t=e.isWebGL2,n=new WeakMap;function i(u,c){let h=u.array,d=u.usage,f=r.createBuffer();r.bindBuffer(c,f),r.bufferData(c,h,d),u.onUploadCallback();let m;if(h instanceof Float32Array)m=5126;else if(h instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(t)m=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=5123;else if(h instanceof Int16Array)m=5122;else if(h instanceof Uint32Array)m=5125;else if(h instanceof Int32Array)m=5124;else if(h instanceof Int8Array)m=5120;else if(h instanceof Uint8Array)m=5121;else if(h instanceof Uint8ClampedArray)m=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:f,type:m,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version}}function s(u,c,h){let d=c.array,f=c.updateRange;r.bindBuffer(h,u),f.count===-1?r.bufferSubData(h,0,d):(t?r.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),n.get(u)}function a(u){u.isInterleavedBufferAttribute&&(u=u.data);let c=n.get(u);c&&(r.deleteBuffer(c.buffer),n.delete(u))}function l(u,c){if(u.isGLBufferAttribute){let d=n.get(u);(!d||d.version<u.version)&&n.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);let h=n.get(u);h===void 0?n.set(u,i(u,c)):h.version<u.version&&(s(h.buffer,u,c),h.version=u.version)}return{get:o,remove:a,update:l}}var hs=class extends De{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),u=a+1,c=l+1,h=e/a,d=t/l,f=[],m=[],p=[],g=[];for(let v=0;v<c;v++){let y=v*d-o;for(let w=0;w<u;w++){let b=w*h-s;m.push(b,-y,0),p.push(0,0,1),g.push(w/a),g.push(1-v/l)}}for(let v=0;v<l;v++)for(let y=0;y<a;y++){let w=y+u*v,b=y+u*(v+1),S=y+1+u*(v+1),_=y+1+u*v;f.push(w,b,_),f.push(b,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(e){return new hs(e.width,e.height,e.widthSegments,e.heightSegments)}},r2=`#ifdef USE_ALPHAMAP
40
+ `},i=new ur(5,5,5),s=new mt({name:"CubemapFromEquirect",uniforms:Ya(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:un,blending:Rt});s.uniforms.tEquirect.value=t;let o=new rn(i,s),a=t.minFilter;return t.minFilter===fl&&(t.minFilter=at),new $g(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(s)}},Ng=new A,e2=new A,t2=new jt,mn=class{constructor(e=new A(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=Ng.subVectors(n,t).cross(e2.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let n=e.delta(Ng),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||t2.getNormalMatrix(e),i=this.coplanarPoint(Ng).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},ka=new En,Nd=new A,_u=class{constructor(e=new mn,t=new mn,n=new mn,i=new mn,s=new mn,o=new mn){this.planes=[e,t,n,i,s,o]}set(e,t,n,i,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(s),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){let t=this.planes,n=e.elements,i=n[0],s=n[1],o=n[2],a=n[3],l=n[4],u=n[5],c=n[6],h=n[7],d=n[8],f=n[9],m=n[10],p=n[11],g=n[12],v=n[13],y=n[14],b=n[15];return t[0].setComponents(a-i,h-l,p-d,b-g).normalize(),t[1].setComponents(a+i,h+l,p+d,b+g).normalize(),t[2].setComponents(a+s,h+u,p+f,b+v).normalize(),t[3].setComponents(a-s,h-u,p-f,b-v).normalize(),t[4].setComponents(a-o,h-c,p-m,b-y).normalize(),t[5].setComponents(a+o,h+c,p+m,b+y).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),ka.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(ka)}intersectsSprite(e){return ka.center.set(0,0,0),ka.radius=.7071067811865476,ka.applyMatrix4(e.matrixWorld),this.intersectsSphere(ka)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Nd.x=i.normal.x>0?e.max.x:e.min.x,Nd.y=i.normal.y>0?e.max.y:e.min.y,Nd.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Nd)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Dw(){let r=null,e=!1,t=null,n=null;function i(s,o){t(s,o),n=r.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=r.requestAnimationFrame(i),e=!0)},stop:function(){r.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){r=s}}}function n2(r,e){let t=e.isWebGL2,n=new WeakMap;function i(u,c){let h=u.array,d=u.usage,f=r.createBuffer();r.bindBuffer(c,f),r.bufferData(c,h,d),u.onUploadCallback();let m;if(h instanceof Float32Array)m=5126;else if(h instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(t)m=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else m=5123;else if(h instanceof Int16Array)m=5122;else if(h instanceof Uint32Array)m=5125;else if(h instanceof Int32Array)m=5124;else if(h instanceof Int8Array)m=5120;else if(h instanceof Uint8Array)m=5121;else if(h instanceof Uint8ClampedArray)m=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:f,type:m,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version}}function s(u,c,h){let d=c.array,f=c.updateRange;r.bindBuffer(h,u),f.count===-1?r.bufferSubData(h,0,d):(t?r.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d,f.offset,f.count):r.bufferSubData(h,f.offset*d.BYTES_PER_ELEMENT,d.subarray(f.offset,f.offset+f.count)),f.count=-1)}function o(u){return u.isInterleavedBufferAttribute&&(u=u.data),n.get(u)}function a(u){u.isInterleavedBufferAttribute&&(u=u.data);let c=n.get(u);c&&(r.deleteBuffer(c.buffer),n.delete(u))}function l(u,c){if(u.isGLBufferAttribute){let d=n.get(u);(!d||d.version<u.version)&&n.set(u,{buffer:u.buffer,type:u.type,bytesPerElement:u.elementSize,version:u.version});return}u.isInterleavedBufferAttribute&&(u=u.data);let h=n.get(u);h===void 0?n.set(u,i(u,c)):h.version<u.version&&(s(h.buffer,u,c),h.version=u.version)}return{get:o,remove:a,update:l}}var hs=class extends De{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let s=e/2,o=t/2,a=Math.floor(n),l=Math.floor(i),u=a+1,c=l+1,h=e/a,d=t/l,f=[],m=[],p=[],g=[];for(let v=0;v<c;v++){let y=v*d-o;for(let b=0;b<u;b++){let w=b*h-s;m.push(w,-y,0),p.push(0,0,1),g.push(b/a),g.push(1-v/l)}}for(let v=0;v<l;v++)for(let y=0;y<a;y++){let b=y+u*v,w=y+u*(v+1),S=y+1+u*(v+1),_=y+1+u*v;f.push(b,w,_),f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(e){return new hs(e.width,e.height,e.widthSegments,e.heightSegments)}},r2=`#ifdef USE_ALPHAMAP
41
41
  diffuseColor.a *= texture2D( alphaMap, vUv ).g;
42
42
  #endif`,i2=`#ifdef USE_ALPHAMAP
43
43
  uniform sampler2D alphaMap;
@@ -2926,7 +2926,7 @@ void main() {
2926
2926
  #include <tonemapping_fragment>
2927
2927
  #include <encodings_fragment>
2928
2928
  #include <fog_fragment>
2929
- }`,tt={alphamap_fragment:r2,alphamap_pars_fragment:i2,alphatest_fragment:s2,alphatest_pars_fragment:o2,aomap_fragment:a2,aomap_pars_fragment:l2,begin_vertex:c2,beginnormal_vertex:u2,bsdfs:h2,iridescence_fragment:d2,bumpmap_pars_fragment:f2,clipping_planes_fragment:p2,clipping_planes_pars_fragment:m2,clipping_planes_pars_vertex:g2,clipping_planes_vertex:y2,color_fragment:v2,color_pars_fragment:x2,color_pars_vertex:b2,color_vertex:w2,common:S2,cube_uv_reflection_fragment:A2,defaultnormal_vertex:_2,displacementmap_pars_vertex:T2,displacementmap_vertex:M2,emissivemap_fragment:E2,emissivemap_pars_fragment:C2,encodings_fragment:P2,encodings_pars_fragment:D2,envmap_fragment:I2,envmap_common_pars_fragment:L2,envmap_pars_fragment:O2,envmap_pars_vertex:R2,envmap_physical_pars_fragment:j2,envmap_vertex:N2,fog_vertex:B2,fog_pars_vertex:F2,fog_fragment:U2,fog_pars_fragment:G2,gradientmap_pars_fragment:z2,lightmap_fragment:k2,lightmap_pars_fragment:V2,lights_lambert_vertex:H2,lights_pars_begin:W2,lights_toon_fragment:q2,lights_toon_pars_fragment:X2,lights_phong_fragment:Y2,lights_phong_pars_fragment:Q2,lights_physical_fragment:Z2,lights_physical_pars_fragment:K2,lights_fragment_begin:J2,lights_fragment_maps:$2,lights_fragment_end:eD,logdepthbuf_fragment:tD,logdepthbuf_pars_fragment:nD,logdepthbuf_pars_vertex:rD,logdepthbuf_vertex:iD,map_fragment:sD,map_pars_fragment:oD,map_particle_fragment:aD,map_particle_pars_fragment:lD,metalnessmap_fragment:cD,metalnessmap_pars_fragment:uD,morphcolor_vertex:hD,morphnormal_vertex:dD,morphtarget_pars_vertex:fD,morphtarget_vertex:pD,normal_fragment_begin:mD,normal_fragment_maps:gD,normal_pars_fragment:yD,normal_pars_vertex:vD,normal_vertex:xD,normalmap_pars_fragment:bD,clearcoat_normal_fragment_begin:wD,clearcoat_normal_fragment_maps:SD,clearcoat_pars_fragment:AD,iridescence_pars_fragment:_D,output_fragment:TD,packing:MD,premultiplied_alpha_fragment:ED,project_vertex:CD,dithering_fragment:PD,dithering_pars_fragment:DD,roughnessmap_fragment:ID,roughnessmap_pars_fragment:LD,shadowmap_pars_fragment:OD,shadowmap_pars_vertex:RD,shadowmap_vertex:ND,shadowmask_pars_fragment:BD,skinbase_vertex:FD,skinning_pars_vertex:UD,skinning_vertex:GD,skinnormal_vertex:zD,specularmap_fragment:kD,specularmap_pars_fragment:VD,tonemapping_fragment:HD,tonemapping_pars_fragment:WD,transmission_fragment:jD,transmission_pars_fragment:qD,uv_pars_fragment:XD,uv_pars_vertex:YD,uv_vertex:QD,uv2_pars_fragment:ZD,uv2_pars_vertex:KD,uv2_vertex:JD,worldpos_vertex:$D,background_vert:eI,background_frag:tI,cube_vert:nI,cube_frag:rI,depth_vert:iI,depth_frag:sI,distanceRGBA_vert:oI,distanceRGBA_frag:aI,equirect_vert:lI,equirect_frag:cI,linedashed_vert:uI,linedashed_frag:hI,meshbasic_vert:dI,meshbasic_frag:fI,meshlambert_vert:pI,meshlambert_frag:mI,meshmatcap_vert:gI,meshmatcap_frag:yI,meshnormal_vert:vI,meshnormal_frag:xI,meshphong_vert:bI,meshphong_frag:wI,meshphysical_vert:SI,meshphysical_frag:AI,meshtoon_vert:_I,meshtoon_frag:TI,points_vert:MI,points_frag:EI,shadow_vert:CI,shadow_frag:PI,sprite_vert:DI,sprite_frag:II},pe={common:{diffuse:{value:new Le(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new jt},uv2Transform:{value:new jt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new B(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Le(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Le(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new jt}},sprite:{diffuse:{value:new Le(16777215)},opacity:{value:1},center:{value:new B(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new jt}}},_i={basic:{uniforms:Hn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:tt.meshbasic_vert,fragmentShader:tt.meshbasic_frag},lambert:{uniforms:Hn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.fog,pe.lights,{emissive:{value:new Le(0)}}]),vertexShader:tt.meshlambert_vert,fragmentShader:tt.meshlambert_frag},phong:{uniforms:Hn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new Le(0)},specular:{value:new Le(1118481)},shininess:{value:30}}]),vertexShader:tt.meshphong_vert,fragmentShader:tt.meshphong_frag},standard:{uniforms:Hn([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new Le(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag},toon:{uniforms:Hn([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new Le(0)}}]),vertexShader:tt.meshtoon_vert,fragmentShader:tt.meshtoon_frag},matcap:{uniforms:Hn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:tt.meshmatcap_vert,fragmentShader:tt.meshmatcap_frag},points:{uniforms:Hn([pe.points,pe.fog]),vertexShader:tt.points_vert,fragmentShader:tt.points_frag},dashed:{uniforms:Hn([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tt.linedashed_vert,fragmentShader:tt.linedashed_frag},depth:{uniforms:Hn([pe.common,pe.displacementmap]),vertexShader:tt.depth_vert,fragmentShader:tt.depth_frag},normal:{uniforms:Hn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:tt.meshnormal_vert,fragmentShader:tt.meshnormal_frag},sprite:{uniforms:Hn([pe.sprite,pe.fog]),vertexShader:tt.sprite_vert,fragmentShader:tt.sprite_frag},background:{uniforms:{uvTransform:{value:new jt},t2D:{value:null}},vertexShader:tt.background_vert,fragmentShader:tt.background_frag},cube:{uniforms:Hn([pe.envmap,{opacity:{value:1}}]),vertexShader:tt.cube_vert,fragmentShader:tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tt.equirect_vert,fragmentShader:tt.equirect_frag},distanceRGBA:{uniforms:Hn([pe.common,pe.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tt.distanceRGBA_vert,fragmentShader:tt.distanceRGBA_frag},shadow:{uniforms:Hn([pe.lights,pe.fog,{color:{value:new Le(0)},opacity:{value:1}}]),vertexShader:tt.shadow_vert,fragmentShader:tt.shadow_frag}};_i.physical={uniforms:Hn([_i.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new B(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Le(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new B},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Le(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Le(1,1,1)},specularColorMap:{value:null}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag};function LI(r,e,t,n,i,s){let o=new Le(0),a=i===!0?0:1,l,u,c=null,h=0,d=null;function f(p,g){let v=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=e.get(y));let w=r.xr,b=w.getSession&&w.getSession();b&&b.environmentBlendMode==="additive"&&(y=null),y===null?m(o,a):y&&y.isColor&&(m(y,1),v=!0),(r.autoClear||v)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),y&&(y.isCubeTexture||y.mapping===dl)?(u===void 0&&(u=new rn(new ur(1,1,1),new mt({name:"BackgroundCubeMaterial",uniforms:Ya(_i.cube.uniforms),vertexShader:_i.cube.vertexShader,fragmentShader:_i.cube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(S,_,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),u.material.uniforms.envMap.value=y,u.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,(c!==y||h!==y.version||d!==r.toneMapping)&&(u.material.needsUpdate=!0,c=y,h=y.version,d=r.toneMapping),u.layers.enableAll(),p.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new rn(new hs(2,2),new mt({name:"BackgroundMaterial",uniforms:Ya(_i.background.uniforms),vertexShader:_i.background.vertexShader,fragmentShader:_i.background.fragmentShader,side:Gr,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(c!==y||h!==y.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,c=y,h=y.version,d=r.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function m(p,g){t.buffers.color.setClear(p.r,p.g,p.b,g,s)}return{getClearColor:function(){return o},setClearColor:function(p,g=1){o.set(p),a=g,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(p){a=p,m(o,a)},render:f}}function OI(r,e,t,n){let i=r.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=g(null),u=l,c=!1;function h(I,N,F,G,Y){let U=!1;if(o){let z=p(G,F,N);u!==z&&(u=z,f(u.object)),U=v(I,G,F,Y),U&&y(I,G,F,Y)}else{let z=N.wireframe===!0;(u.geometry!==G.id||u.program!==F.id||u.wireframe!==z)&&(u.geometry=G.id,u.program=F.id,u.wireframe=z,U=!0)}Y!==null&&t.update(Y,34963),(U||c)&&(c=!1,x(I,N,F,G),Y!==null&&r.bindBuffer(34963,t.get(Y).buffer))}function d(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function f(I){return n.isWebGL2?r.bindVertexArray(I):s.bindVertexArrayOES(I)}function m(I){return n.isWebGL2?r.deleteVertexArray(I):s.deleteVertexArrayOES(I)}function p(I,N,F){let G=F.wireframe===!0,Y=a[I.id];Y===void 0&&(Y={},a[I.id]=Y);let U=Y[N.id];U===void 0&&(U={},Y[N.id]=U);let z=U[G];return z===void 0&&(z=g(d()),U[G]=z),z}function g(I){let N=[],F=[],G=[];for(let Y=0;Y<i;Y++)N[Y]=0,F[Y]=0,G[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:F,attributeDivisors:G,object:I,attributes:{},index:null}}function v(I,N,F,G){let Y=u.attributes,U=N.attributes,z=0,Q=F.getAttributes();for(let V in Q)if(Q[V].location>=0){let j=Y[V],q=U[V];if(q===void 0&&(V==="instanceMatrix"&&I.instanceMatrix&&(q=I.instanceMatrix),V==="instanceColor"&&I.instanceColor&&(q=I.instanceColor)),j===void 0||j.attribute!==q||q&&j.data!==q.data)return!0;z++}return u.attributesNum!==z||u.index!==G}function y(I,N,F,G){let Y={},U=N.attributes,z=0,Q=F.getAttributes();for(let V in Q)if(Q[V].location>=0){let j=U[V];j===void 0&&(V==="instanceMatrix"&&I.instanceMatrix&&(j=I.instanceMatrix),V==="instanceColor"&&I.instanceColor&&(j=I.instanceColor));let q={};q.attribute=j,j&&j.data&&(q.data=j.data),Y[V]=q,z++}u.attributes=Y,u.attributesNum=z,u.index=G}function w(){let I=u.newAttributes;for(let N=0,F=I.length;N<F;N++)I[N]=0}function b(I){S(I,0)}function S(I,N){let F=u.newAttributes,G=u.enabledAttributes,Y=u.attributeDivisors;F[I]=1,G[I]===0&&(r.enableVertexAttribArray(I),G[I]=1),Y[I]!==N&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](I,N),Y[I]=N)}function _(){let I=u.newAttributes,N=u.enabledAttributes;for(let F=0,G=N.length;F<G;F++)N[F]!==I[F]&&(r.disableVertexAttribArray(F),N[F]=0)}function M(I,N,F,G,Y,U){n.isWebGL2===!0&&(F===5124||F===5125)?r.vertexAttribIPointer(I,N,F,Y,U):r.vertexAttribPointer(I,N,F,G,Y,U)}function x(I,N,F,G){if(n.isWebGL2===!1&&(I.isInstancedMesh||G.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;w();let Y=G.attributes,U=F.getAttributes(),z=N.defaultAttributeValues;for(let Q in U){let V=U[Q];if(V.location>=0){let k=Y[Q];if(k===void 0&&(Q==="instanceMatrix"&&I.instanceMatrix&&(k=I.instanceMatrix),Q==="instanceColor"&&I.instanceColor&&(k=I.instanceColor)),k!==void 0){let j=k.normalized,q=k.itemSize,W=t.get(k);if(W===void 0)continue;let he=W.buffer,ie=W.type,K=W.bytesPerElement;if(k.isInterleavedBufferAttribute){let X=k.data,ne=X.stride,ce=k.offset;if(X.isInstancedInterleavedBuffer){for(let oe=0;oe<V.locationSize;oe++)S(V.location+oe,X.meshPerAttribute);I.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let oe=0;oe<V.locationSize;oe++)b(V.location+oe);r.bindBuffer(34962,he);for(let oe=0;oe<V.locationSize;oe++)M(V.location+oe,q/V.locationSize,ie,j,ne*K,(ce+q/V.locationSize*oe)*K)}else{if(k.isInstancedBufferAttribute){for(let X=0;X<V.locationSize;X++)S(V.location+X,k.meshPerAttribute);I.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=k.meshPerAttribute*k.count)}else for(let X=0;X<V.locationSize;X++)b(V.location+X);r.bindBuffer(34962,he);for(let X=0;X<V.locationSize;X++)M(V.location+X,q/V.locationSize,ie,j,q*K,q/V.locationSize*X*K)}}else if(z!==void 0){let j=z[Q];if(j!==void 0)switch(j.length){case 2:r.vertexAttrib2fv(V.location,j);break;case 3:r.vertexAttrib3fv(V.location,j);break;case 4:r.vertexAttrib4fv(V.location,j);break;default:r.vertexAttrib1fv(V.location,j)}}}}_()}function T(){P();for(let I in a){let N=a[I];for(let F in N){let G=N[F];for(let Y in G)m(G[Y].object),delete G[Y];delete N[F]}delete a[I]}}function E(I){if(a[I.id]===void 0)return;let N=a[I.id];for(let F in N){let G=N[F];for(let Y in G)m(G[Y].object),delete G[Y];delete N[F]}delete a[I.id]}function C(I){for(let N in a){let F=a[N];if(F[I.id]===void 0)continue;let G=F[I.id];for(let Y in G)m(G[Y].object),delete G[Y];delete F[I.id]}}function P(){O(),c=!0,u!==l&&(u=l,f(u.object))}function O(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:P,resetDefaultState:O,dispose:T,releaseStatesOfGeometry:E,releaseStatesOfProgram:C,initAttributes:w,enableAttribute:b,disableUnusedAttributes:_}}function RI(r,e,t,n){let i=n.isWebGL2,s;function o(u){s=u}function a(u,c){r.drawArrays(s,u,c),t.update(c,s,1)}function l(u,c,h){if(h===0)return;let d,f;if(i)d=r,f="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,u,c,h),t.update(c,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function NI(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let M=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(M){if(M==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";M="mediump"}return M==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let u=o||e.has("WEBGL_draw_buffers"),c=t.logarithmicDepthBuffer===!0,h=r.getParameter(34930),d=r.getParameter(35660),f=r.getParameter(3379),m=r.getParameter(34076),p=r.getParameter(34921),g=r.getParameter(36347),v=r.getParameter(36348),y=r.getParameter(36349),w=d>0,b=o||e.has("OES_texture_float"),S=w&&b,_=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:g,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:w,floatFragmentTextures:b,floatVertexTextures:S,maxSamples:_}}function BI(r){let e=this,t=null,n=0,i=!1,s=!1,o=new mn,a=new jt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,f){let m=h.length!==0||d||n!==0||i;return i=d,t=c(h,f,0),n=h.length,m},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1,u()},this.setState=function(h,d,f){let m=h.clippingPlanes,p=h.clipIntersection,g=h.clipShadows,v=r.get(h);if(!i||m===null||m.length===0||s&&!g)s?c(null):u();else{let y=s?0:n,w=y*4,b=v.clippingState||null;l.value=b,b=c(m,d,w,f);for(let S=0;S!==w;++S)b[S]=t[S];v.clippingState=b,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=y}};function u(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function c(h,d,f,m){let p=h!==null?h.length:0,g=null;if(p!==0){if(g=l.value,m!==!0||g===null){let v=f+p*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length<v)&&(g=new Float32Array(v));for(let w=0,b=f;w!==p;++w,b+=4)o.copy(h[w]).applyMatrix4(y,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=p,e.numIntersection=0,g}}function FI(r){let e=new WeakMap;function t(o,a){return a===qg?o.mapping=Fs:a===Xg&&(o.mapping=Us),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===qg||a===Xg)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let u=new ey(l.height/2);return u.fromEquirectangularTexture(r,o),e.set(o,u),o.addEventListener("dispose",i),t(u.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var Za=class extends ai{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let u=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,a-=c*this.view.offsetY,l=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Wa=4,Nb=[.125,.215,.35,.446,.526,.582],Ro=20,Bg=new Za,Bb=new Le,Fg=null,Oo=(1+Math.sqrt(5))/2,Va=1/Oo,Fb=[new A(1,1,1),new A(-1,1,1),new A(1,1,-1),new A(-1,1,-1),new A(0,Oo,Va),new A(0,Oo,-Va),new A(Va,0,Oo),new A(-Va,0,Oo),new A(Oo,Va,0),new A(-Oo,Va,0)],$d=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Fg=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zb(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Gb(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Fg),e.scissorTest=!1,Bd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Fs||e.mapping===Us?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fg=this._renderer.getRenderTarget();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:at,minFilter:at,generateMipmaps:!1,type:bu,format:si,encoding:Mr,depthBuffer:!1},i=Ub(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ub(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=UI(s)),this._blurMaterial=GI(s,e,t)}return i}_compileMaterial(e){let t=new rn(this._lodPlanes[0],e);this._renderer.compile(t,Bg)}_sceneToCubeUV(e,t,n,i){let a=new nn(90,1,t,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],c=this._renderer,h=c.autoClear,d=c.toneMapping;c.getClearColor(Bb),c.toneMapping=us,c.autoClear=!1;let f=new Au({name:"PMREM.Background",side:un,depthWrite:!1,depthTest:!1}),m=new rn(new ur,f),p=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,p=!0):(f.color.copy(Bb),p=!0);for(let v=0;v<6;v++){let y=v%3;y===0?(a.up.set(0,l[v],0),a.lookAt(u[v],0,0)):y===1?(a.up.set(0,0,l[v]),a.lookAt(0,u[v],0)):(a.up.set(0,l[v],0),a.lookAt(0,0,u[v]));let w=this._cubeSize;Bd(i,y*w,v>2?w:0,w,w),c.setRenderTarget(i),p&&c.render(m,a),c.render(e,a)}m.geometry.dispose(),m.material.dispose(),c.toneMapping=d,c.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Fs||e.mapping===Us;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=zb()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Gb());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new rn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;Bd(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Bg)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=Fb[(i-1)%Fb.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){let l=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let c=3,h=new rn(this._lodPlanes[i],u),d=u.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Ro-1),p=s/m,g=isFinite(s)?1+Math.floor(c*p):Ro;g>Ro&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ro}`);let v=[],y=0;for(let M=0;M<Ro;++M){let x=M/p,T=Math.exp(-x*x/2);v.push(T),M===0?y+=T:M<g&&(y+=2*T)}for(let M=0;M<v.length;M++)v[M]=v[M]/y;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=v,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:w}=this;d.dTheta.value=m,d.mipInt.value=w-n;let b=this._sizeLods[i],S=3*b*(i>w-Wa?i-w+Wa:0),_=4*(this._cubeSize-b);Bd(t,S,_,3*b,2*b),l.setRenderTarget(t),l.render(h,Bg)}};function UI(r){let e=[],t=[],n=[],i=r,s=r-Wa+1+Nb.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);t.push(a);let l=1/a;o>r-Wa?l=Nb[o-r+Wa-1]:o===0&&(l=0),n.push(l);let u=1/(a-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],f=6,m=6,p=3,g=2,v=1,y=new Float32Array(p*m*f),w=new Float32Array(g*m*f),b=new Float32Array(v*m*f);for(let _=0;_<f;_++){let M=_%3*2/3-1,x=_>2?0:-1,T=[M,x,0,M+2/3,x,0,M+2/3,x+1,0,M,x,0,M+2/3,x+1,0,M,x+1,0];y.set(T,p*m*_),w.set(d,g*m*_);let E=[_,_,_,_,_,_];b.set(E,v*m*_)}let S=new De;S.setAttribute("position",new Ge(y,p)),S.setAttribute("uv",new Ge(w,g)),S.setAttribute("faceIndex",new Ge(b,v)),e.push(S),i>Wa&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Ub(r,e,t){let n=new dt(r,e,t);return n.texture.mapping=dl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Bd(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function GI(r,e,t){let n=new Float32Array(Ro),i=new A(0,1,0);return new mt({name:"SphericalGaussianBlur",defines:{n:Ro,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ry(),fragmentShader:`
2929
+ }`,tt={alphamap_fragment:r2,alphamap_pars_fragment:i2,alphatest_fragment:s2,alphatest_pars_fragment:o2,aomap_fragment:a2,aomap_pars_fragment:l2,begin_vertex:c2,beginnormal_vertex:u2,bsdfs:h2,iridescence_fragment:d2,bumpmap_pars_fragment:f2,clipping_planes_fragment:p2,clipping_planes_pars_fragment:m2,clipping_planes_pars_vertex:g2,clipping_planes_vertex:y2,color_fragment:v2,color_pars_fragment:x2,color_pars_vertex:b2,color_vertex:w2,common:S2,cube_uv_reflection_fragment:A2,defaultnormal_vertex:_2,displacementmap_pars_vertex:T2,displacementmap_vertex:M2,emissivemap_fragment:E2,emissivemap_pars_fragment:C2,encodings_fragment:P2,encodings_pars_fragment:D2,envmap_fragment:I2,envmap_common_pars_fragment:L2,envmap_pars_fragment:O2,envmap_pars_vertex:R2,envmap_physical_pars_fragment:j2,envmap_vertex:N2,fog_vertex:B2,fog_pars_vertex:F2,fog_fragment:U2,fog_pars_fragment:G2,gradientmap_pars_fragment:z2,lightmap_fragment:k2,lightmap_pars_fragment:V2,lights_lambert_vertex:H2,lights_pars_begin:W2,lights_toon_fragment:q2,lights_toon_pars_fragment:X2,lights_phong_fragment:Y2,lights_phong_pars_fragment:Q2,lights_physical_fragment:Z2,lights_physical_pars_fragment:K2,lights_fragment_begin:J2,lights_fragment_maps:$2,lights_fragment_end:eD,logdepthbuf_fragment:tD,logdepthbuf_pars_fragment:nD,logdepthbuf_pars_vertex:rD,logdepthbuf_vertex:iD,map_fragment:sD,map_pars_fragment:oD,map_particle_fragment:aD,map_particle_pars_fragment:lD,metalnessmap_fragment:cD,metalnessmap_pars_fragment:uD,morphcolor_vertex:hD,morphnormal_vertex:dD,morphtarget_pars_vertex:fD,morphtarget_vertex:pD,normal_fragment_begin:mD,normal_fragment_maps:gD,normal_pars_fragment:yD,normal_pars_vertex:vD,normal_vertex:xD,normalmap_pars_fragment:bD,clearcoat_normal_fragment_begin:wD,clearcoat_normal_fragment_maps:SD,clearcoat_pars_fragment:AD,iridescence_pars_fragment:_D,output_fragment:TD,packing:MD,premultiplied_alpha_fragment:ED,project_vertex:CD,dithering_fragment:PD,dithering_pars_fragment:DD,roughnessmap_fragment:ID,roughnessmap_pars_fragment:LD,shadowmap_pars_fragment:OD,shadowmap_pars_vertex:RD,shadowmap_vertex:ND,shadowmask_pars_fragment:BD,skinbase_vertex:FD,skinning_pars_vertex:UD,skinning_vertex:GD,skinnormal_vertex:zD,specularmap_fragment:kD,specularmap_pars_fragment:VD,tonemapping_fragment:HD,tonemapping_pars_fragment:WD,transmission_fragment:jD,transmission_pars_fragment:qD,uv_pars_fragment:XD,uv_pars_vertex:YD,uv_vertex:QD,uv2_pars_fragment:ZD,uv2_pars_vertex:KD,uv2_vertex:JD,worldpos_vertex:$D,background_vert:eI,background_frag:tI,cube_vert:nI,cube_frag:rI,depth_vert:iI,depth_frag:sI,distanceRGBA_vert:oI,distanceRGBA_frag:aI,equirect_vert:lI,equirect_frag:cI,linedashed_vert:uI,linedashed_frag:hI,meshbasic_vert:dI,meshbasic_frag:fI,meshlambert_vert:pI,meshlambert_frag:mI,meshmatcap_vert:gI,meshmatcap_frag:yI,meshnormal_vert:vI,meshnormal_frag:xI,meshphong_vert:bI,meshphong_frag:wI,meshphysical_vert:SI,meshphysical_frag:AI,meshtoon_vert:_I,meshtoon_frag:TI,points_vert:MI,points_frag:EI,shadow_vert:CI,shadow_frag:PI,sprite_vert:DI,sprite_frag:II},pe={common:{diffuse:{value:new Le(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new jt},uv2Transform:{value:new jt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new B(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Le(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Le(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new jt}},sprite:{diffuse:{value:new Le(16777215)},opacity:{value:1},center:{value:new B(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new jt}}},_i={basic:{uniforms:Hn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:tt.meshbasic_vert,fragmentShader:tt.meshbasic_frag},lambert:{uniforms:Hn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.fog,pe.lights,{emissive:{value:new Le(0)}}]),vertexShader:tt.meshlambert_vert,fragmentShader:tt.meshlambert_frag},phong:{uniforms:Hn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new Le(0)},specular:{value:new Le(1118481)},shininess:{value:30}}]),vertexShader:tt.meshphong_vert,fragmentShader:tt.meshphong_frag},standard:{uniforms:Hn([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new Le(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag},toon:{uniforms:Hn([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new Le(0)}}]),vertexShader:tt.meshtoon_vert,fragmentShader:tt.meshtoon_frag},matcap:{uniforms:Hn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:tt.meshmatcap_vert,fragmentShader:tt.meshmatcap_frag},points:{uniforms:Hn([pe.points,pe.fog]),vertexShader:tt.points_vert,fragmentShader:tt.points_frag},dashed:{uniforms:Hn([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tt.linedashed_vert,fragmentShader:tt.linedashed_frag},depth:{uniforms:Hn([pe.common,pe.displacementmap]),vertexShader:tt.depth_vert,fragmentShader:tt.depth_frag},normal:{uniforms:Hn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:tt.meshnormal_vert,fragmentShader:tt.meshnormal_frag},sprite:{uniforms:Hn([pe.sprite,pe.fog]),vertexShader:tt.sprite_vert,fragmentShader:tt.sprite_frag},background:{uniforms:{uvTransform:{value:new jt},t2D:{value:null}},vertexShader:tt.background_vert,fragmentShader:tt.background_frag},cube:{uniforms:Hn([pe.envmap,{opacity:{value:1}}]),vertexShader:tt.cube_vert,fragmentShader:tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tt.equirect_vert,fragmentShader:tt.equirect_frag},distanceRGBA:{uniforms:Hn([pe.common,pe.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tt.distanceRGBA_vert,fragmentShader:tt.distanceRGBA_frag},shadow:{uniforms:Hn([pe.lights,pe.fog,{color:{value:new Le(0)},opacity:{value:1}}]),vertexShader:tt.shadow_vert,fragmentShader:tt.shadow_frag}};_i.physical={uniforms:Hn([_i.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new B(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Le(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new B},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Le(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Le(1,1,1)},specularColorMap:{value:null}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag};function LI(r,e,t,n,i,s){let o=new Le(0),a=i===!0?0:1,l,u,c=null,h=0,d=null;function f(p,g){let v=!1,y=g.isScene===!0?g.background:null;y&&y.isTexture&&(y=e.get(y));let b=r.xr,w=b.getSession&&b.getSession();w&&w.environmentBlendMode==="additive"&&(y=null),y===null?m(o,a):y&&y.isColor&&(m(y,1),v=!0),(r.autoClear||v)&&r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil),y&&(y.isCubeTexture||y.mapping===dl)?(u===void 0&&(u=new rn(new ur(1,1,1),new mt({name:"BackgroundCubeMaterial",uniforms:Ya(_i.cube.uniforms),vertexShader:_i.cube.vertexShader,fragmentShader:_i.cube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(S,_,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(u)),u.material.uniforms.envMap.value=y,u.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,(c!==y||h!==y.version||d!==r.toneMapping)&&(u.material.needsUpdate=!0,c=y,h=y.version,d=r.toneMapping),u.layers.enableAll(),p.unshift(u,u.geometry,u.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new rn(new hs(2,2),new mt({name:"BackgroundMaterial",uniforms:Ya(_i.background.uniforms),vertexShader:_i.background.vertexShader,fragmentShader:_i.background.fragmentShader,side:Gr,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=y,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(c!==y||h!==y.version||d!==r.toneMapping)&&(l.material.needsUpdate=!0,c=y,h=y.version,d=r.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function m(p,g){t.buffers.color.setClear(p.r,p.g,p.b,g,s)}return{getClearColor:function(){return o},setClearColor:function(p,g=1){o.set(p),a=g,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(p){a=p,m(o,a)},render:f}}function OI(r,e,t,n){let i=r.getParameter(34921),s=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||s!==null,a={},l=g(null),u=l,c=!1;function h(D,N,F,z,Y){let U=!1;if(o){let G=p(z,F,N);u!==G&&(u=G,f(u.object)),U=v(D,z,F,Y),U&&y(D,z,F,Y)}else{let G=N.wireframe===!0;(u.geometry!==z.id||u.program!==F.id||u.wireframe!==G)&&(u.geometry=z.id,u.program=F.id,u.wireframe=G,U=!0)}Y!==null&&t.update(Y,34963),(U||c)&&(c=!1,x(D,N,F,z),Y!==null&&r.bindBuffer(34963,t.get(Y).buffer))}function d(){return n.isWebGL2?r.createVertexArray():s.createVertexArrayOES()}function f(D){return n.isWebGL2?r.bindVertexArray(D):s.bindVertexArrayOES(D)}function m(D){return n.isWebGL2?r.deleteVertexArray(D):s.deleteVertexArrayOES(D)}function p(D,N,F){let z=F.wireframe===!0,Y=a[D.id];Y===void 0&&(Y={},a[D.id]=Y);let U=Y[N.id];U===void 0&&(U={},Y[N.id]=U);let G=U[z];return G===void 0&&(G=g(d()),U[z]=G),G}function g(D){let N=[],F=[],z=[];for(let Y=0;Y<i;Y++)N[Y]=0,F[Y]=0,z[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:F,attributeDivisors:z,object:D,attributes:{},index:null}}function v(D,N,F,z){let Y=u.attributes,U=N.attributes,G=0,Q=F.getAttributes();for(let V in Q)if(Q[V].location>=0){let j=Y[V],q=U[V];if(q===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(q=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(q=D.instanceColor)),j===void 0||j.attribute!==q||q&&j.data!==q.data)return!0;G++}return u.attributesNum!==G||u.index!==z}function y(D,N,F,z){let Y={},U=N.attributes,G=0,Q=F.getAttributes();for(let V in Q)if(Q[V].location>=0){let j=U[V];j===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(j=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(j=D.instanceColor));let q={};q.attribute=j,j&&j.data&&(q.data=j.data),Y[V]=q,G++}u.attributes=Y,u.attributesNum=G,u.index=z}function b(){let D=u.newAttributes;for(let N=0,F=D.length;N<F;N++)D[N]=0}function w(D){S(D,0)}function S(D,N){let F=u.newAttributes,z=u.enabledAttributes,Y=u.attributeDivisors;F[D]=1,z[D]===0&&(r.enableVertexAttribArray(D),z[D]=1),Y[D]!==N&&((n.isWebGL2?r:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,N),Y[D]=N)}function _(){let D=u.newAttributes,N=u.enabledAttributes;for(let F=0,z=N.length;F<z;F++)N[F]!==D[F]&&(r.disableVertexAttribArray(F),N[F]=0)}function M(D,N,F,z,Y,U){n.isWebGL2===!0&&(F===5124||F===5125)?r.vertexAttribIPointer(D,N,F,Y,U):r.vertexAttribPointer(D,N,F,z,Y,U)}function x(D,N,F,z){if(n.isWebGL2===!1&&(D.isInstancedMesh||z.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;b();let Y=z.attributes,U=F.getAttributes(),G=N.defaultAttributeValues;for(let Q in U){let V=U[Q];if(V.location>=0){let k=Y[Q];if(k===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(k=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(k=D.instanceColor)),k!==void 0){let j=k.normalized,q=k.itemSize,W=t.get(k);if(W===void 0)continue;let he=W.buffer,ie=W.type,K=W.bytesPerElement;if(k.isInterleavedBufferAttribute){let X=k.data,ne=X.stride,ce=k.offset;if(X.isInstancedInterleavedBuffer){for(let oe=0;oe<V.locationSize;oe++)S(V.location+oe,X.meshPerAttribute);D.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=X.meshPerAttribute*X.count)}else for(let oe=0;oe<V.locationSize;oe++)w(V.location+oe);r.bindBuffer(34962,he);for(let oe=0;oe<V.locationSize;oe++)M(V.location+oe,q/V.locationSize,ie,j,ne*K,(ce+q/V.locationSize*oe)*K)}else{if(k.isInstancedBufferAttribute){for(let X=0;X<V.locationSize;X++)S(V.location+X,k.meshPerAttribute);D.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=k.meshPerAttribute*k.count)}else for(let X=0;X<V.locationSize;X++)w(V.location+X);r.bindBuffer(34962,he);for(let X=0;X<V.locationSize;X++)M(V.location+X,q/V.locationSize,ie,j,q*K,q/V.locationSize*X*K)}}else if(G!==void 0){let j=G[Q];if(j!==void 0)switch(j.length){case 2:r.vertexAttrib2fv(V.location,j);break;case 3:r.vertexAttrib3fv(V.location,j);break;case 4:r.vertexAttrib4fv(V.location,j);break;default:r.vertexAttrib1fv(V.location,j)}}}}_()}function T(){P();for(let D in a){let N=a[D];for(let F in N){let z=N[F];for(let Y in z)m(z[Y].object),delete z[Y];delete N[F]}delete a[D]}}function E(D){if(a[D.id]===void 0)return;let N=a[D.id];for(let F in N){let z=N[F];for(let Y in z)m(z[Y].object),delete z[Y];delete N[F]}delete a[D.id]}function C(D){for(let N in a){let F=a[N];if(F[D.id]===void 0)continue;let z=F[D.id];for(let Y in z)m(z[Y].object),delete z[Y];delete F[D.id]}}function P(){O(),c=!0,u!==l&&(u=l,f(u.object))}function O(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:h,reset:P,resetDefaultState:O,dispose:T,releaseStatesOfGeometry:E,releaseStatesOfProgram:C,initAttributes:b,enableAttribute:w,disableUnusedAttributes:_}}function RI(r,e,t,n){let i=n.isWebGL2,s;function o(u){s=u}function a(u,c){r.drawArrays(s,u,c),t.update(c,s,1)}function l(u,c,h){if(h===0)return;let d,f;if(i)d=r,f="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),f="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[f](s,u,c,h),t.update(c,s,h)}this.setMode=o,this.render=a,this.renderInstances=l}function NI(r,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){let M=e.get("EXT_texture_filter_anisotropic");n=r.getParameter(M.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function s(M){if(M==="highp"){if(r.getShaderPrecisionFormat(35633,36338).precision>0&&r.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";M="mediump"}return M==="mediump"&&r.getShaderPrecisionFormat(35633,36337).precision>0&&r.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let o=typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&r instanceof WebGL2ComputeRenderingContext,a=t.precision!==void 0?t.precision:"highp",l=s(a);l!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",l,"instead."),a=l);let u=o||e.has("WEBGL_draw_buffers"),c=t.logarithmicDepthBuffer===!0,h=r.getParameter(34930),d=r.getParameter(35660),f=r.getParameter(3379),m=r.getParameter(34076),p=r.getParameter(34921),g=r.getParameter(36347),v=r.getParameter(36348),y=r.getParameter(36349),b=d>0,w=o||e.has("OES_texture_float"),S=b&&w,_=o?r.getParameter(36183):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:f,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:g,maxVaryings:v,maxFragmentUniforms:y,vertexTextures:b,floatFragmentTextures:w,floatVertexTextures:S,maxSamples:_}}function BI(r){let e=this,t=null,n=0,i=!1,s=!1,o=new mn,a=new jt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d,f){let m=h.length!==0||d||n!==0||i;return i=d,t=c(h,f,0),n=h.length,m},this.beginShadows=function(){s=!0,c(null)},this.endShadows=function(){s=!1,u()},this.setState=function(h,d,f){let m=h.clippingPlanes,p=h.clipIntersection,g=h.clipShadows,v=r.get(h);if(!i||m===null||m.length===0||s&&!g)s?c(null):u();else{let y=s?0:n,b=y*4,w=v.clippingState||null;l.value=w,w=c(m,d,b,f);for(let S=0;S!==b;++S)w[S]=t[S];v.clippingState=w,this.numIntersection=p?this.numPlanes:0,this.numPlanes+=y}};function u(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function c(h,d,f,m){let p=h!==null?h.length:0,g=null;if(p!==0){if(g=l.value,m!==!0||g===null){let v=f+p*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length<v)&&(g=new Float32Array(v));for(let b=0,w=f;b!==p;++b,w+=4)o.copy(h[b]).applyMatrix4(y,a),o.normal.toArray(g,w),g[w+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=p,e.numIntersection=0,g}}function FI(r){let e=new WeakMap;function t(o,a){return a===qg?o.mapping=Fs:a===Xg&&(o.mapping=Us),o}function n(o){if(o&&o.isTexture&&o.isRenderTargetTexture===!1){let a=o.mapping;if(a===qg||a===Xg)if(e.has(o)){let l=e.get(o).texture;return t(l,o.mapping)}else{let l=o.image;if(l&&l.height>0){let u=new ey(l.height/2);return u.fromEquirectangularTexture(r,o),e.set(o,u),o.addEventListener("dispose",i),t(u.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var Za=class extends ai{constructor(e=-1,t=1,n=1,i=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=n-e,o=n+e,a=i+t,l=i-t;if(this.view!==null&&this.view.enabled){let u=(this.right-this.left)/this.view.fullWidth/this.zoom,c=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=u*this.view.offsetX,o=s+u*this.view.width,a-=c*this.view.offsetY,l=a-c*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Wa=4,Nb=[.125,.215,.35,.446,.526,.582],Ro=20,Bg=new Za,Bb=new Le,Fg=null,Oo=(1+Math.sqrt(5))/2,Va=1/Oo,Fb=[new A(1,1,1),new A(-1,1,1),new A(1,1,-1),new A(-1,1,-1),new A(0,Oo,Va),new A(0,Oo,-Va),new A(Va,0,Oo),new A(-Va,0,Oo),new A(Oo,Va,0),new A(-Oo,Va,0)],$d=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Fg=this._renderer.getRenderTarget(),this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,i,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zb(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Gb(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Fg),e.scissorTest=!1,Bd(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Fs||e.mapping===Us?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fg=this._renderer.getRenderTarget();let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:at,minFilter:at,generateMipmaps:!1,type:bu,format:si,encoding:Mr,depthBuffer:!1},i=Ub(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ub(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=UI(s)),this._blurMaterial=GI(s,e,t)}return i}_compileMaterial(e){let t=new rn(this._lodPlanes[0],e);this._renderer.compile(t,Bg)}_sceneToCubeUV(e,t,n,i){let a=new nn(90,1,t,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],c=this._renderer,h=c.autoClear,d=c.toneMapping;c.getClearColor(Bb),c.toneMapping=us,c.autoClear=!1;let f=new Au({name:"PMREM.Background",side:un,depthWrite:!1,depthTest:!1}),m=new rn(new ur,f),p=!1,g=e.background;g?g.isColor&&(f.color.copy(g),e.background=null,p=!0):(f.color.copy(Bb),p=!0);for(let v=0;v<6;v++){let y=v%3;y===0?(a.up.set(0,l[v],0),a.lookAt(u[v],0,0)):y===1?(a.up.set(0,0,l[v]),a.lookAt(0,u[v],0)):(a.up.set(0,l[v],0),a.lookAt(0,0,u[v]));let b=this._cubeSize;Bd(i,y*b,v>2?b:0,b,b),c.setRenderTarget(i),p&&c.render(m,a),c.render(e,a)}m.geometry.dispose(),m.material.dispose(),c.toneMapping=d,c.autoClear=h,e.background=g}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Fs||e.mapping===Us;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=zb()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Gb());let s=i?this._cubemapMaterial:this._equirectMaterial,o=new rn(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let l=this._cubeSize;Bd(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Bg)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){let s=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=Fb[(i-1)%Fb.length];this._blur(e,i-1,i,s,o)}t.autoClear=n}_blur(e,t,n,i,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",s),this._halfBlur(o,e,n,n,i,"longitudinal",s)}_halfBlur(e,t,n,i,s,o,a){let l=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let c=3,h=new rn(this._lodPlanes[i],u),d=u.uniforms,f=this._sizeLods[n]-1,m=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*Ro-1),p=s/m,g=isFinite(s)?1+Math.floor(c*p):Ro;g>Ro&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ro}`);let v=[],y=0;for(let M=0;M<Ro;++M){let x=M/p,T=Math.exp(-x*x/2);v.push(T),M===0?y+=T:M<g&&(y+=2*T)}for(let M=0;M<v.length;M++)v[M]=v[M]/y;d.envMap.value=e.texture,d.samples.value=g,d.weights.value=v,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:b}=this;d.dTheta.value=m,d.mipInt.value=b-n;let w=this._sizeLods[i],S=3*w*(i>b-Wa?i-b+Wa:0),_=4*(this._cubeSize-w);Bd(t,S,_,3*w,2*w),l.setRenderTarget(t),l.render(h,Bg)}};function UI(r){let e=[],t=[],n=[],i=r,s=r-Wa+1+Nb.length;for(let o=0;o<s;o++){let a=Math.pow(2,i);t.push(a);let l=1/a;o>r-Wa?l=Nb[o-r+Wa-1]:o===0&&(l=0),n.push(l);let u=1/(a-2),c=-u,h=1+u,d=[c,c,h,c,h,h,c,c,h,h,c,h],f=6,m=6,p=3,g=2,v=1,y=new Float32Array(p*m*f),b=new Float32Array(g*m*f),w=new Float32Array(v*m*f);for(let _=0;_<f;_++){let M=_%3*2/3-1,x=_>2?0:-1,T=[M,x,0,M+2/3,x,0,M+2/3,x+1,0,M,x,0,M+2/3,x+1,0,M,x+1,0];y.set(T,p*m*_),b.set(d,g*m*_);let E=[_,_,_,_,_,_];w.set(E,v*m*_)}let S=new De;S.setAttribute("position",new Ge(y,p)),S.setAttribute("uv",new Ge(b,g)),S.setAttribute("faceIndex",new Ge(w,v)),e.push(S),i>Wa&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Ub(r,e,t){let n=new dt(r,e,t);return n.texture.mapping=dl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Bd(r,e,t,n,i){r.viewport.set(e,t,n,i),r.scissor.set(e,t,n,i)}function GI(r,e,t){let n=new Float32Array(Ro),i=new A(0,1,0);return new mt({name:"SphericalGaussianBlur",defines:{n:Ro,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Ry(),fragmentShader:`
2930
2930
 
2931
2931
  precision mediump float;
2932
2932
  precision mediump int;
@@ -3076,7 +3076,7 @@ void main() {
3076
3076
  gl_Position = vec4( position, 1.0 );
3077
3077
 
3078
3078
  }
3079
- `}function zI(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,u=l===qg||l===Xg,c=l===Fs||l===Us;if(u||c)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new $d(r)),h=u?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{let h=a.image;if(u&&h&&h.height>0||c&&h&&i(h)){t===null&&(t=new $d(r));let d=u?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function i(a){let l=0,u=6;for(let c=0;c<u;c++)a[c]!==void 0&&l++;return l===u}function s(a){let l=a.target;l.removeEventListener("dispose",s);let u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function kI(r){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){let i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function VI(r,e,t,n){let i={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&e.remove(d.index);for(let m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete i[d.id];let f=s.get(d);f&&(e.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function l(h){let d=h.attributes;for(let m in d)e.update(d[m],34962);let f=h.morphAttributes;for(let m in f){let p=f[m];for(let g=0,v=p.length;g<v;g++)e.update(p[g],34962)}}function u(h){let d=[],f=h.index,m=h.attributes.position,p=0;if(f!==null){let y=f.array;p=f.version;for(let w=0,b=y.length;w<b;w+=3){let S=y[w+0],_=y[w+1],M=y[w+2];d.push(S,_,_,M,M,S)}}else{let y=m.array;p=m.version;for(let w=0,b=y.length/3-1;w<b;w+=3){let S=w+0,_=w+1,M=w+2;d.push(S,_,_,M,M,S)}}let g=new(Cw(d)?zs:Jd)(d,1);g.version=p;let v=s.get(h);v&&e.remove(v),s.set(h,g)}function c(h){let d=s.get(h);if(d){let f=h.index;f!==null&&d.version<f.version&&u(h)}else u(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:c}}function HI(r,e,t,n){let i=n.isWebGL2,s;function o(d){s=d}let a,l;function u(d){a=d.type,l=d.bytesPerElement}function c(d,f){r.drawElements(s,f,a,d*l),t.update(f,s,1)}function h(d,f,m){if(m===0)return;let p,g;if(i)p=r,g="drawElementsInstanced";else if(p=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",p===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[g](s,f,a,d*l,m),t.update(f,s,m)}this.setMode=o,this.setIndex=u,this.render=c,this.renderInstances=h}function WI(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(s/3);break;case 1:t.lines+=a*(s/2);break;case 3:t.lines+=a*(s-1);break;case 2:t.lines+=a*s;break;case 0:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function jI(r,e){return r[0]-e[0]}function qI(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Ug(r,e){let t=1,n=e.isInterleavedBufferAttribute?e.data.array:e.array;n instanceof Int8Array?t=127:n instanceof Uint8Array?t=255:n instanceof Uint16Array?t=65535:n instanceof Int16Array?t=32767:n instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),r.divideScalar(t)}function XI(r,e,t){let n={},i=new Float32Array(8),s=new WeakMap,o=new He,a=[];for(let u=0;u<8;u++)a[u]=[u,0];function l(u,c,h,d){let f=u.morphTargetInfluences;if(e.isWebGL2===!0){let m=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,p=m!==void 0?m.length:0,g=s.get(c);if(g===void 0||g.count!==p){let N=function(){O.dispose(),s.delete(c),c.removeEventListener("dispose",N)};g!==void 0&&g.texture.dispose();let w=c.morphAttributes.position!==void 0,b=c.morphAttributes.normal!==void 0,S=c.morphAttributes.color!==void 0,_=c.morphAttributes.position||[],M=c.morphAttributes.normal||[],x=c.morphAttributes.color||[],T=0;w===!0&&(T=1),b===!0&&(T=2),S===!0&&(T=3);let E=c.attributes.position.count*T,C=1;E>e.maxTextureSize&&(C=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);let P=new Float32Array(E*C*4*p),O=new Kd(P,E,C,p);O.type=Ti,O.needsUpdate=!0;let I=T*4;for(let F=0;F<p;F++){let G=_[F],Y=M[F],U=x[F],z=E*C*4*F;for(let Q=0;Q<G.count;Q++){let V=Q*I;w===!0&&(o.fromBufferAttribute(G,Q),G.normalized===!0&&Ug(o,G),P[z+V+0]=o.x,P[z+V+1]=o.y,P[z+V+2]=o.z,P[z+V+3]=0),b===!0&&(o.fromBufferAttribute(Y,Q),Y.normalized===!0&&Ug(o,Y),P[z+V+4]=o.x,P[z+V+5]=o.y,P[z+V+6]=o.z,P[z+V+7]=0),S===!0&&(o.fromBufferAttribute(U,Q),U.normalized===!0&&Ug(o,U),P[z+V+8]=o.x,P[z+V+9]=o.y,P[z+V+10]=o.z,P[z+V+11]=U.itemSize===4?o.w:1)}}g={count:p,texture:O,size:new B(E,C)},s.set(c,g),c.addEventListener("dispose",N)}let v=0;for(let w=0;w<f.length;w++)v+=f[w];let y=c.morphTargetsRelative?1:1-v;d.getUniforms().setValue(r,"morphTargetBaseInfluence",y),d.getUniforms().setValue(r,"morphTargetInfluences",f),d.getUniforms().setValue(r,"morphTargetsTexture",g.texture,t),d.getUniforms().setValue(r,"morphTargetsTextureSize",g.size)}else{let m=f===void 0?0:f.length,p=n[c.id];if(p===void 0||p.length!==m){p=[];for(let b=0;b<m;b++)p[b]=[b,0];n[c.id]=p}for(let b=0;b<m;b++){let S=p[b];S[0]=b,S[1]=f[b]}p.sort(qI);for(let b=0;b<8;b++)b<m&&p[b][1]?(a[b][0]=p[b][0],a[b][1]=p[b][1]):(a[b][0]=Number.MAX_SAFE_INTEGER,a[b][1]=0);a.sort(jI);let g=c.morphAttributes.position,v=c.morphAttributes.normal,y=0;for(let b=0;b<8;b++){let S=a[b],_=S[0],M=S[1];_!==Number.MAX_SAFE_INTEGER&&M?(g&&c.getAttribute("morphTarget"+b)!==g[_]&&c.setAttribute("morphTarget"+b,g[_]),v&&c.getAttribute("morphNormal"+b)!==v[_]&&c.setAttribute("morphNormal"+b,v[_]),i[b]=M,y+=M):(g&&c.hasAttribute("morphTarget"+b)===!0&&c.deleteAttribute("morphTarget"+b),v&&c.hasAttribute("morphNormal"+b)===!0&&c.deleteAttribute("morphNormal"+b),i[b]=0)}let w=c.morphTargetsRelative?1:1-y;d.getUniforms().setValue(r,"morphTargetBaseInfluence",w),d.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function YI(r,e,t,n){let i=new WeakMap;function s(l){let u=n.render.frame,c=l.geometry,h=e.get(l,c);return i.get(h)!==u&&(e.update(h),i.set(h,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,34962),l.instanceColor!==null&&t.update(l.instanceColor,34962)),h}function o(){i=new WeakMap}function a(l){let u=l.target;u.removeEventListener("dispose",a),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:s,dispose:o}}var Iw=new Yt,Lw=new Kd,Ow=new Jg,Rw=new Qa,kb=[],Vb=[],Hb=new Float32Array(16),Wb=new Float32Array(9),jb=new Float32Array(4);function pl(r,e,t){let n=r[0];if(n<=0||n>0)return r;let i=e*t,s=kb[i];if(s===void 0&&(s=new Float32Array(i),kb[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function nr(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function rr(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function pf(r,e){let t=Vb[e];t===void 0&&(t=new Int32Array(e),Vb[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function QI(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function ZI(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(nr(t,e))return;r.uniform2fv(this.addr,e),rr(t,e)}}function KI(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(nr(t,e))return;r.uniform3fv(this.addr,e),rr(t,e)}}function JI(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(nr(t,e))return;r.uniform4fv(this.addr,e),rr(t,e)}}function $I(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(nr(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),rr(t,e)}else{if(nr(t,n))return;jb.set(n),r.uniformMatrix2fv(this.addr,!1,jb),rr(t,n)}}function eL(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(nr(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),rr(t,e)}else{if(nr(t,n))return;Wb.set(n),r.uniformMatrix3fv(this.addr,!1,Wb),rr(t,n)}}function tL(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(nr(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),rr(t,e)}else{if(nr(t,n))return;Hb.set(n),r.uniformMatrix4fv(this.addr,!1,Hb),rr(t,n)}}function nL(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function rL(r,e){let t=this.cache;nr(t,e)||(r.uniform2iv(this.addr,e),rr(t,e))}function iL(r,e){let t=this.cache;nr(t,e)||(r.uniform3iv(this.addr,e),rr(t,e))}function sL(r,e){let t=this.cache;nr(t,e)||(r.uniform4iv(this.addr,e),rr(t,e))}function oL(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function aL(r,e){let t=this.cache;nr(t,e)||(r.uniform2uiv(this.addr,e),rr(t,e))}function lL(r,e){let t=this.cache;nr(t,e)||(r.uniform3uiv(this.addr,e),rr(t,e))}function cL(r,e){let t=this.cache;nr(t,e)||(r.uniform4uiv(this.addr,e),rr(t,e))}function uL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||Iw,i)}function hL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Ow,i)}function dL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Rw,i)}function fL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Lw,i)}function pL(r){switch(r){case 5126:return QI;case 35664:return ZI;case 35665:return KI;case 35666:return JI;case 35674:return $I;case 35675:return eL;case 35676:return tL;case 5124:case 35670:return nL;case 35667:case 35671:return rL;case 35668:case 35672:return iL;case 35669:case 35673:return sL;case 5125:return oL;case 36294:return aL;case 36295:return lL;case 36296:return cL;case 35678:case 36198:case 36298:case 36306:case 35682:return uL;case 35679:case 36299:case 36307:return hL;case 35680:case 36300:case 36308:case 36293:return dL;case 36289:case 36303:case 36311:case 36292:return fL}}function mL(r,e){r.uniform1fv(this.addr,e)}function gL(r,e){let t=pl(e,this.size,2);r.uniform2fv(this.addr,t)}function yL(r,e){let t=pl(e,this.size,3);r.uniform3fv(this.addr,t)}function vL(r,e){let t=pl(e,this.size,4);r.uniform4fv(this.addr,t)}function xL(r,e){let t=pl(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function bL(r,e){let t=pl(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function wL(r,e){let t=pl(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function SL(r,e){r.uniform1iv(this.addr,e)}function AL(r,e){r.uniform2iv(this.addr,e)}function _L(r,e){r.uniform3iv(this.addr,e)}function TL(r,e){r.uniform4iv(this.addr,e)}function ML(r,e){r.uniform1uiv(this.addr,e)}function EL(r,e){r.uniform2uiv(this.addr,e)}function CL(r,e){r.uniform3uiv(this.addr,e)}function PL(r,e){r.uniform4uiv(this.addr,e)}function DL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2D(e[s]||Iw,i[s])}function IL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture3D(e[s]||Ow,i[s])}function LL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTextureCube(e[s]||Rw,i[s])}function OL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2DArray(e[s]||Lw,i[s])}function RL(r){switch(r){case 5126:return mL;case 35664:return gL;case 35665:return yL;case 35666:return vL;case 35674:return xL;case 35675:return bL;case 35676:return wL;case 5124:case 35670:return SL;case 35667:case 35671:return AL;case 35668:case 35672:return _L;case 35669:case 35673:return TL;case 5125:return ML;case 36294:return EL;case 36295:return CL;case 36296:return PL;case 35678:case 36198:case 36298:case 36306:case 35682:return DL;case 35679:case 36299:case 36307:return IL;case 35680:case 36300:case 36308:case 36293:return LL;case 36289:case 36303:case 36311:case 36292:return OL}}var ty=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=pL(t.type)}},ny=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=RL(t.type)}},ry=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(e,t[a.id],n)}}},Gg=/(\w+)(\])?(\[|\.)?/g;function qb(r,e){r.seq.push(e),r.map[e.id]=e}function NL(r,e,t){let n=r.name,i=n.length;for(Gg.lastIndex=0;;){let s=Gg.exec(n),o=Gg.lastIndex,a=s[1],l=s[2]==="]",u=s[3];if(l&&(a=a|0),u===void 0||u==="["&&o+2===i){qb(t,u===void 0?new ty(a,r,e):new ny(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new ry(a),qb(t,h)),t=h}}}var qa=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){let s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);NL(s,o,this)}}setValue(e,t,n,i){let s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function Xb(r,e,t){let n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}var BL=0;function FL(r,e){let t=r.split(`
3079
+ `}function zI(r){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let l=a.mapping,u=l===qg||l===Xg,c=l===Fs||l===Us;if(u||c)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new $d(r)),h=u?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{let h=a.image;if(u&&h&&h.height>0||c&&h&&i(h)){t===null&&(t=new $d(r));let d=u?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function i(a){let l=0,u=6;for(let c=0;c<u;c++)a[c]!==void 0&&l++;return l===u}function s(a){let l=a.target;l.removeEventListener("dispose",s);let u=e.get(l);u!==void 0&&(e.delete(l),u.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function kI(r){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=r.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){let i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function VI(r,e,t,n){let i={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&e.remove(d.index);for(let m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete i[d.id];let f=s.get(d);f&&(e.remove(f),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function l(h){let d=h.attributes;for(let m in d)e.update(d[m],34962);let f=h.morphAttributes;for(let m in f){let p=f[m];for(let g=0,v=p.length;g<v;g++)e.update(p[g],34962)}}function u(h){let d=[],f=h.index,m=h.attributes.position,p=0;if(f!==null){let y=f.array;p=f.version;for(let b=0,w=y.length;b<w;b+=3){let S=y[b+0],_=y[b+1],M=y[b+2];d.push(S,_,_,M,M,S)}}else{let y=m.array;p=m.version;for(let b=0,w=y.length/3-1;b<w;b+=3){let S=b+0,_=b+1,M=b+2;d.push(S,_,_,M,M,S)}}let g=new(Cw(d)?zs:Jd)(d,1);g.version=p;let v=s.get(h);v&&e.remove(v),s.set(h,g)}function c(h){let d=s.get(h);if(d){let f=h.index;f!==null&&d.version<f.version&&u(h)}else u(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:c}}function HI(r,e,t,n){let i=n.isWebGL2,s;function o(d){s=d}let a,l;function u(d){a=d.type,l=d.bytesPerElement}function c(d,f){r.drawElements(s,f,a,d*l),t.update(f,s,1)}function h(d,f,m){if(m===0)return;let p,g;if(i)p=r,g="drawElementsInstanced";else if(p=e.get("ANGLE_instanced_arrays"),g="drawElementsInstancedANGLE",p===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}p[g](s,f,a,d*l,m),t.update(f,s,m)}this.setMode=o,this.setIndex=u,this.render=c,this.renderInstances=h}function WI(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case 4:t.triangles+=a*(s/3);break;case 1:t.lines+=a*(s/2);break;case 3:t.lines+=a*(s-1);break;case 2:t.lines+=a*s;break;case 0:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function jI(r,e){return r[0]-e[0]}function qI(r,e){return Math.abs(e[1])-Math.abs(r[1])}function Ug(r,e){let t=1,n=e.isInterleavedBufferAttribute?e.data.array:e.array;n instanceof Int8Array?t=127:n instanceof Uint8Array?t=255:n instanceof Uint16Array?t=65535:n instanceof Int16Array?t=32767:n instanceof Int32Array?t=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",n),r.divideScalar(t)}function XI(r,e,t){let n={},i=new Float32Array(8),s=new WeakMap,o=new He,a=[];for(let u=0;u<8;u++)a[u]=[u,0];function l(u,c,h,d){let f=u.morphTargetInfluences;if(e.isWebGL2===!0){let m=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,p=m!==void 0?m.length:0,g=s.get(c);if(g===void 0||g.count!==p){let N=function(){O.dispose(),s.delete(c),c.removeEventListener("dispose",N)};g!==void 0&&g.texture.dispose();let b=c.morphAttributes.position!==void 0,w=c.morphAttributes.normal!==void 0,S=c.morphAttributes.color!==void 0,_=c.morphAttributes.position||[],M=c.morphAttributes.normal||[],x=c.morphAttributes.color||[],T=0;b===!0&&(T=1),w===!0&&(T=2),S===!0&&(T=3);let E=c.attributes.position.count*T,C=1;E>e.maxTextureSize&&(C=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);let P=new Float32Array(E*C*4*p),O=new Kd(P,E,C,p);O.type=Ti,O.needsUpdate=!0;let D=T*4;for(let F=0;F<p;F++){let z=_[F],Y=M[F],U=x[F],G=E*C*4*F;for(let Q=0;Q<z.count;Q++){let V=Q*D;b===!0&&(o.fromBufferAttribute(z,Q),z.normalized===!0&&Ug(o,z),P[G+V+0]=o.x,P[G+V+1]=o.y,P[G+V+2]=o.z,P[G+V+3]=0),w===!0&&(o.fromBufferAttribute(Y,Q),Y.normalized===!0&&Ug(o,Y),P[G+V+4]=o.x,P[G+V+5]=o.y,P[G+V+6]=o.z,P[G+V+7]=0),S===!0&&(o.fromBufferAttribute(U,Q),U.normalized===!0&&Ug(o,U),P[G+V+8]=o.x,P[G+V+9]=o.y,P[G+V+10]=o.z,P[G+V+11]=U.itemSize===4?o.w:1)}}g={count:p,texture:O,size:new B(E,C)},s.set(c,g),c.addEventListener("dispose",N)}let v=0;for(let b=0;b<f.length;b++)v+=f[b];let y=c.morphTargetsRelative?1:1-v;d.getUniforms().setValue(r,"morphTargetBaseInfluence",y),d.getUniforms().setValue(r,"morphTargetInfluences",f),d.getUniforms().setValue(r,"morphTargetsTexture",g.texture,t),d.getUniforms().setValue(r,"morphTargetsTextureSize",g.size)}else{let m=f===void 0?0:f.length,p=n[c.id];if(p===void 0||p.length!==m){p=[];for(let w=0;w<m;w++)p[w]=[w,0];n[c.id]=p}for(let w=0;w<m;w++){let S=p[w];S[0]=w,S[1]=f[w]}p.sort(qI);for(let w=0;w<8;w++)w<m&&p[w][1]?(a[w][0]=p[w][0],a[w][1]=p[w][1]):(a[w][0]=Number.MAX_SAFE_INTEGER,a[w][1]=0);a.sort(jI);let g=c.morphAttributes.position,v=c.morphAttributes.normal,y=0;for(let w=0;w<8;w++){let S=a[w],_=S[0],M=S[1];_!==Number.MAX_SAFE_INTEGER&&M?(g&&c.getAttribute("morphTarget"+w)!==g[_]&&c.setAttribute("morphTarget"+w,g[_]),v&&c.getAttribute("morphNormal"+w)!==v[_]&&c.setAttribute("morphNormal"+w,v[_]),i[w]=M,y+=M):(g&&c.hasAttribute("morphTarget"+w)===!0&&c.deleteAttribute("morphTarget"+w),v&&c.hasAttribute("morphNormal"+w)===!0&&c.deleteAttribute("morphNormal"+w),i[w]=0)}let b=c.morphTargetsRelative?1:1-y;d.getUniforms().setValue(r,"morphTargetBaseInfluence",b),d.getUniforms().setValue(r,"morphTargetInfluences",i)}}return{update:l}}function YI(r,e,t,n){let i=new WeakMap;function s(l){let u=n.render.frame,c=l.geometry,h=e.get(l,c);return i.get(h)!==u&&(e.update(h),i.set(h,u)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),t.update(l.instanceMatrix,34962),l.instanceColor!==null&&t.update(l.instanceColor,34962)),h}function o(){i=new WeakMap}function a(l){let u=l.target;u.removeEventListener("dispose",a),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:s,dispose:o}}var Iw=new Yt,Lw=new Kd,Ow=new Jg,Rw=new Qa,kb=[],Vb=[],Hb=new Float32Array(16),Wb=new Float32Array(9),jb=new Float32Array(4);function pl(r,e,t){let n=r[0];if(n<=0||n>0)return r;let i=e*t,s=kb[i];if(s===void 0&&(s=new Float32Array(i),kb[i]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,r[o].toArray(s,a)}return s}function nr(r,e){if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function rr(r,e){for(let t=0,n=e.length;t<n;t++)r[t]=e[t]}function pf(r,e){let t=Vb[e];t===void 0&&(t=new Int32Array(e),Vb[e]=t);for(let n=0;n!==e;++n)t[n]=r.allocateTextureUnit();return t}function QI(r,e){let t=this.cache;t[0]!==e&&(r.uniform1f(this.addr,e),t[0]=e)}function ZI(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(r.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(nr(t,e))return;r.uniform2fv(this.addr,e),rr(t,e)}}function KI(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(r.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(r.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(nr(t,e))return;r.uniform3fv(this.addr,e),rr(t,e)}}function JI(r,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(r.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(nr(t,e))return;r.uniform4fv(this.addr,e),rr(t,e)}}function $I(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(nr(t,e))return;r.uniformMatrix2fv(this.addr,!1,e),rr(t,e)}else{if(nr(t,n))return;jb.set(n),r.uniformMatrix2fv(this.addr,!1,jb),rr(t,n)}}function eL(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(nr(t,e))return;r.uniformMatrix3fv(this.addr,!1,e),rr(t,e)}else{if(nr(t,n))return;Wb.set(n),r.uniformMatrix3fv(this.addr,!1,Wb),rr(t,n)}}function tL(r,e){let t=this.cache,n=e.elements;if(n===void 0){if(nr(t,e))return;r.uniformMatrix4fv(this.addr,!1,e),rr(t,e)}else{if(nr(t,n))return;Hb.set(n),r.uniformMatrix4fv(this.addr,!1,Hb),rr(t,n)}}function nL(r,e){let t=this.cache;t[0]!==e&&(r.uniform1i(this.addr,e),t[0]=e)}function rL(r,e){let t=this.cache;nr(t,e)||(r.uniform2iv(this.addr,e),rr(t,e))}function iL(r,e){let t=this.cache;nr(t,e)||(r.uniform3iv(this.addr,e),rr(t,e))}function sL(r,e){let t=this.cache;nr(t,e)||(r.uniform4iv(this.addr,e),rr(t,e))}function oL(r,e){let t=this.cache;t[0]!==e&&(r.uniform1ui(this.addr,e),t[0]=e)}function aL(r,e){let t=this.cache;nr(t,e)||(r.uniform2uiv(this.addr,e),rr(t,e))}function lL(r,e){let t=this.cache;nr(t,e)||(r.uniform3uiv(this.addr,e),rr(t,e))}function cL(r,e){let t=this.cache;nr(t,e)||(r.uniform4uiv(this.addr,e),rr(t,e))}function uL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2D(e||Iw,i)}function hL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Ow,i)}function dL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Rw,i)}function fL(r,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(r.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Lw,i)}function pL(r){switch(r){case 5126:return QI;case 35664:return ZI;case 35665:return KI;case 35666:return JI;case 35674:return $I;case 35675:return eL;case 35676:return tL;case 5124:case 35670:return nL;case 35667:case 35671:return rL;case 35668:case 35672:return iL;case 35669:case 35673:return sL;case 5125:return oL;case 36294:return aL;case 36295:return lL;case 36296:return cL;case 35678:case 36198:case 36298:case 36306:case 35682:return uL;case 35679:case 36299:case 36307:return hL;case 35680:case 36300:case 36308:case 36293:return dL;case 36289:case 36303:case 36311:case 36292:return fL}}function mL(r,e){r.uniform1fv(this.addr,e)}function gL(r,e){let t=pl(e,this.size,2);r.uniform2fv(this.addr,t)}function yL(r,e){let t=pl(e,this.size,3);r.uniform3fv(this.addr,t)}function vL(r,e){let t=pl(e,this.size,4);r.uniform4fv(this.addr,t)}function xL(r,e){let t=pl(e,this.size,4);r.uniformMatrix2fv(this.addr,!1,t)}function bL(r,e){let t=pl(e,this.size,9);r.uniformMatrix3fv(this.addr,!1,t)}function wL(r,e){let t=pl(e,this.size,16);r.uniformMatrix4fv(this.addr,!1,t)}function SL(r,e){r.uniform1iv(this.addr,e)}function AL(r,e){r.uniform2iv(this.addr,e)}function _L(r,e){r.uniform3iv(this.addr,e)}function TL(r,e){r.uniform4iv(this.addr,e)}function ML(r,e){r.uniform1uiv(this.addr,e)}function EL(r,e){r.uniform2uiv(this.addr,e)}function CL(r,e){r.uniform3uiv(this.addr,e)}function PL(r,e){r.uniform4uiv(this.addr,e)}function DL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2D(e[s]||Iw,i[s])}function IL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture3D(e[s]||Ow,i[s])}function LL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTextureCube(e[s]||Rw,i[s])}function OL(r,e,t){let n=e.length,i=pf(t,n);r.uniform1iv(this.addr,i);for(let s=0;s!==n;++s)t.setTexture2DArray(e[s]||Lw,i[s])}function RL(r){switch(r){case 5126:return mL;case 35664:return gL;case 35665:return yL;case 35666:return vL;case 35674:return xL;case 35675:return bL;case 35676:return wL;case 5124:case 35670:return SL;case 35667:case 35671:return AL;case 35668:case 35672:return _L;case 35669:case 35673:return TL;case 5125:return ML;case 36294:return EL;case 36295:return CL;case 36296:return PL;case 35678:case 36198:case 36298:case 36306:case 35682:return DL;case 35679:case 36299:case 36307:return IL;case 35680:case 36300:case 36308:case 36293:return LL;case 36289:case 36303:case 36311:case 36292:return OL}}var ty=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=pL(t.type)}},ny=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=RL(t.type)}},ry=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let s=0,o=i.length;s!==o;++s){let a=i[s];a.setValue(e,t[a.id],n)}}},Gg=/(\w+)(\])?(\[|\.)?/g;function qb(r,e){r.seq.push(e),r.map[e.id]=e}function NL(r,e,t){let n=r.name,i=n.length;for(Gg.lastIndex=0;;){let s=Gg.exec(n),o=Gg.lastIndex,a=s[1],l=s[2]==="]",u=s[3];if(l&&(a=a|0),u===void 0||u==="["&&o+2===i){qb(t,u===void 0?new ty(a,r,e):new ny(a,r,e));break}else{let h=t.map[a];h===void 0&&(h=new ry(a),qb(t,h)),t=h}}}var qa=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){let s=e.getActiveUniform(t,i),o=e.getUniformLocation(t,s.name);NL(s,o,this)}}setValue(e,t,n,i){let s=this.map[t];s!==void 0&&s.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,s=e.length;i!==s;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function Xb(r,e,t){let n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}var BL=0;function FL(r,e){let t=r.split(`
3080
3080
  `),n=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=i;o<s;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
3081
3081
  `)}function UL(r){switch(r){case Mr:return["Linear","( value )"];case Xe:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",r),["Linear","( value )"]}}function Yb(r,e,t){let n=r.getShaderParameter(e,35713),i=r.getShaderInfoLog(e).trim();if(n&&i==="")return"";let s=/ERROR: 0:(\d+)/.exec(i);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`
3082
3082
 
@@ -3102,11 +3102,11 @@ precision `+r.precision+" int;";return r.precision==="highp"?e+=`
3102
3102
  `)+`
3103
3103
  `+g,v=["#define varying in",t.glslVersion===Sb?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Sb?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
3104
3104
  `)+`
3105
- `+v);let w=y+g+o,b=y+v+a,S=Xb(i,35633,w),_=Xb(i,35632,b);if(i.attachShader(p,S),i.attachShader(p,_),t.index0AttributeName!==void 0?i.bindAttribLocation(p,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(p,0,"position"),i.linkProgram(p),r.debug.checkShaderErrors){let T=i.getProgramInfoLog(p).trim(),E=i.getShaderInfoLog(S).trim(),C=i.getShaderInfoLog(_).trim(),P=!0,O=!0;if(i.getProgramParameter(p,35714)===!1){P=!1;let I=Yb(i,S,"vertex"),N=Yb(i,_,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(p,35715)+`
3105
+ `+v);let b=y+g+o,w=y+v+a,S=Xb(i,35633,b),_=Xb(i,35632,w);if(i.attachShader(p,S),i.attachShader(p,_),t.index0AttributeName!==void 0?i.bindAttribLocation(p,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(p,0,"position"),i.linkProgram(p),r.debug.checkShaderErrors){let T=i.getProgramInfoLog(p).trim(),E=i.getShaderInfoLog(S).trim(),C=i.getShaderInfoLog(_).trim(),P=!0,O=!0;if(i.getProgramParameter(p,35714)===!1){P=!1;let D=Yb(i,S,"vertex"),N=Yb(i,_,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(p,35715)+`
3106
3106
 
3107
3107
  Program Info Log: `+T+`
3108
- `+I+`
3109
- `+N)}else T!==""?console.warn("THREE.WebGLProgram: Program Info Log:",T):(E===""||C==="")&&(O=!1);O&&(this.diagnostics={runnable:P,programLog:T,vertexShader:{log:E,prefix:g},fragmentShader:{log:C,prefix:v}})}i.deleteShader(S),i.deleteShader(_);let M;this.getUniforms=function(){return M===void 0&&(M=new qa(i,p)),M};let x;return this.getAttributes=function(){return x===void 0&&(x=HL(i,p)),x},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=BL++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=S,this.fragmentShader=_,this}var tO=0,sy=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){let t=this.shaderCache;if(t.has(e)===!1){let n=new oy(e);t.set(e,n)}return t.get(e)}},oy=class{constructor(e){this.id=tO++,this.code=e,this.usedTimes=0}};function nO(r,e,t,n,i,s,o){let a=new Su,l=new sy,u=[],c=i.isWebGL2,h=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x,T,E,C,P){let O=C.fog,I=P.geometry,N=x.isMeshStandardMaterial?C.environment:null,F=(x.isMeshStandardMaterial?t:e).get(x.envMap||N),G=!!F&&F.mapping===dl?F.image.height:null,Y=m[x.type];x.precision!==null&&(f=i.getMaxPrecision(x.precision),f!==x.precision&&console.warn("THREE.WebGLProgram.getParameters:",x.precision,"not supported, using",f,"instead."));let U=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,z=U!==void 0?U.length:0,Q=0;I.morphAttributes.position!==void 0&&(Q=1),I.morphAttributes.normal!==void 0&&(Q=2),I.morphAttributes.color!==void 0&&(Q=3);let V,k,j,q;if(Y){let ne=_i[Y];V=ne.vertexShader,k=ne.fragmentShader}else V=x.vertexShader,k=x.fragmentShader,l.update(x),j=l.getVertexShaderID(x),q=l.getFragmentShaderID(x);let W=r.getRenderTarget(),he=x.alphaTest>0,ie=x.clearcoat>0,K=x.iridescence>0;return{isWebGL2:c,shaderID:Y,shaderName:x.type,vertexShader:V,fragmentShader:k,defines:x.defines,customVertexShaderID:j,customFragmentShaderID:q,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:f,instancing:P.isInstancedMesh===!0,instancingColor:P.isInstancedMesh===!0&&P.instanceColor!==null,supportsVertexTextures:d,outputEncoding:W===null?r.outputEncoding:W.isXRRenderTarget===!0?W.texture.encoding:Mr,map:!!x.map,matcap:!!x.matcap,envMap:!!F,envMapMode:F&&F.mapping,envMapCubeUVHeight:G,lightMap:!!x.lightMap,aoMap:!!x.aoMap,emissiveMap:!!x.emissiveMap,bumpMap:!!x.bumpMap,normalMap:!!x.normalMap,objectSpaceNormalMap:x.normalMapType===SP,tangentSpaceNormalMap:x.normalMapType===wP,decodeVideoTexture:!!x.map&&x.map.isVideoTexture===!0&&x.map.encoding===Xe,clearcoat:ie,clearcoatMap:ie&&!!x.clearcoatMap,clearcoatRoughnessMap:ie&&!!x.clearcoatRoughnessMap,clearcoatNormalMap:ie&&!!x.clearcoatNormalMap,iridescence:K,iridescenceMap:K&&!!x.iridescenceMap,iridescenceThicknessMap:K&&!!x.iridescenceThicknessMap,displacementMap:!!x.displacementMap,roughnessMap:!!x.roughnessMap,metalnessMap:!!x.metalnessMap,specularMap:!!x.specularMap,specularIntensityMap:!!x.specularIntensityMap,specularColorMap:!!x.specularColorMap,opaque:x.transparent===!1&&x.blending===Ns,alphaMap:!!x.alphaMap,alphaTest:he,gradientMap:!!x.gradientMap,sheen:x.sheen>0,sheenColorMap:!!x.sheenColorMap,sheenRoughnessMap:!!x.sheenRoughnessMap,transmission:x.transmission>0,transmissionMap:!!x.transmissionMap,thicknessMap:!!x.thicknessMap,combine:x.combine,vertexTangents:!!x.normalMap&&!!I.attributes.tangent,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,vertexUvs:!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatMap||!!x.clearcoatRoughnessMap||!!x.clearcoatNormalMap||!!x.iridescenceMap||!!x.iridescenceThicknessMap||!!x.displacementMap||!!x.transmissionMap||!!x.thicknessMap||!!x.specularIntensityMap||!!x.specularColorMap||!!x.sheenColorMap||!!x.sheenRoughnessMap,uvsVertexOnly:!(!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatNormalMap||!!x.iridescenceMap||!!x.iridescenceThicknessMap||x.transmission>0||!!x.transmissionMap||!!x.thicknessMap||!!x.specularIntensityMap||!!x.specularColorMap||x.sheen>0||!!x.sheenColorMap||!!x.sheenRoughnessMap)&&!!x.displacementMap,fog:!!O,useFog:x.fog===!0,fogExp2:O&&O.isFogExp2,flatShading:!!x.flatShading,sizeAttenuation:x.sizeAttenuation,logarithmicDepthBuffer:h,skinning:P.isSkinnedMesh===!0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:z,morphTextureStride:Q,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:r.shadowMap.enabled&&E.length>0,shadowMapType:r.shadowMap.type,toneMapping:x.toneMapped?r.toneMapping:us,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===tr,flipSided:x.side===un,useDepthPacking:!!x.depthPacking,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||n.has("EXT_shader_texture_lod"),customProgramCacheKey:x.customProgramCacheKey()}}function g(x){let T=[];if(x.shaderID?T.push(x.shaderID):(T.push(x.customVertexShaderID),T.push(x.customFragmentShaderID)),x.defines!==void 0)for(let E in x.defines)T.push(E),T.push(x.defines[E]);return x.isRawShaderMaterial===!1&&(v(T,x),y(T,x),T.push(r.outputEncoding)),T.push(x.customProgramCacheKey),T.join()}function v(x,T){x.push(T.precision),x.push(T.outputEncoding),x.push(T.envMapMode),x.push(T.envMapCubeUVHeight),x.push(T.combine),x.push(T.vertexUvs),x.push(T.fogExp2),x.push(T.sizeAttenuation),x.push(T.morphTargetsCount),x.push(T.morphAttributeCount),x.push(T.numDirLights),x.push(T.numPointLights),x.push(T.numSpotLights),x.push(T.numHemiLights),x.push(T.numRectAreaLights),x.push(T.numDirLightShadows),x.push(T.numPointLightShadows),x.push(T.numSpotLightShadows),x.push(T.shadowMapType),x.push(T.toneMapping),x.push(T.numClippingPlanes),x.push(T.numClipIntersection),x.push(T.depthPacking)}function y(x,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.map&&a.enable(4),T.matcap&&a.enable(5),T.envMap&&a.enable(6),T.lightMap&&a.enable(7),T.aoMap&&a.enable(8),T.emissiveMap&&a.enable(9),T.bumpMap&&a.enable(10),T.normalMap&&a.enable(11),T.objectSpaceNormalMap&&a.enable(12),T.tangentSpaceNormalMap&&a.enable(13),T.clearcoat&&a.enable(14),T.clearcoatMap&&a.enable(15),T.clearcoatRoughnessMap&&a.enable(16),T.clearcoatNormalMap&&a.enable(17),T.iridescence&&a.enable(18),T.iridescenceMap&&a.enable(19),T.iridescenceThicknessMap&&a.enable(20),T.displacementMap&&a.enable(21),T.specularMap&&a.enable(22),T.roughnessMap&&a.enable(23),T.metalnessMap&&a.enable(24),T.gradientMap&&a.enable(25),T.alphaMap&&a.enable(26),T.alphaTest&&a.enable(27),T.vertexColors&&a.enable(28),T.vertexAlphas&&a.enable(29),T.vertexUvs&&a.enable(30),T.vertexTangents&&a.enable(31),T.uvsVertexOnly&&a.enable(32),T.fog&&a.enable(33),x.push(a.mask),a.disableAll(),T.useFog&&a.enable(0),T.flatShading&&a.enable(1),T.logarithmicDepthBuffer&&a.enable(2),T.skinning&&a.enable(3),T.morphTargets&&a.enable(4),T.morphNormals&&a.enable(5),T.morphColors&&a.enable(6),T.premultipliedAlpha&&a.enable(7),T.shadowMapEnabled&&a.enable(8),T.physicallyCorrectLights&&a.enable(9),T.doubleSided&&a.enable(10),T.flipSided&&a.enable(11),T.useDepthPacking&&a.enable(12),T.dithering&&a.enable(13),T.specularIntensityMap&&a.enable(14),T.specularColorMap&&a.enable(15),T.transmission&&a.enable(16),T.transmissionMap&&a.enable(17),T.thicknessMap&&a.enable(18),T.sheen&&a.enable(19),T.sheenColorMap&&a.enable(20),T.sheenRoughnessMap&&a.enable(21),T.decodeVideoTexture&&a.enable(22),T.opaque&&a.enable(23),x.push(a.mask)}function w(x){let T=m[x.type],E;if(T){let C=_i[T];E=ci.clone(C.uniforms)}else E=x.uniforms;return E}function b(x,T){let E;for(let C=0,P=u.length;C<P;C++){let O=u[C];if(O.cacheKey===T){E=O,++E.usedTimes;break}}return E===void 0&&(E=new eO(r,T,x,s),u.push(E)),E}function S(x){if(--x.usedTimes===0){let T=u.indexOf(x);u[T]=u[u.length-1],u.pop(),x.destroy()}}function _(x){l.remove(x)}function M(){l.dispose()}return{getParameters:p,getProgramCacheKey:g,getUniforms:w,acquireProgram:b,releaseProgram:S,releaseShaderCache:_,programs:u,dispose:M}}function rO(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function iO(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function $b(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function ew(){let r=[],e=0,t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(h,d,f,m,p,g){let v=r[e];return v===void 0?(v={id:h.id,object:h,geometry:d,material:f,groupOrder:m,renderOrder:h.renderOrder,z:p,group:g},r[e]=v):(v.id=h.id,v.object=h,v.geometry=d,v.material=f,v.groupOrder=m,v.renderOrder=h.renderOrder,v.z=p,v.group=g),e++,v}function a(h,d,f,m,p,g){let v=o(h,d,f,m,p,g);f.transmission>0?n.push(v):f.transparent===!0?i.push(v):t.push(v)}function l(h,d,f,m,p,g){let v=o(h,d,f,m,p,g);f.transmission>0?n.unshift(v):f.transparent===!0?i.unshift(v):t.unshift(v)}function u(h,d){t.length>1&&t.sort(h||iO),n.length>1&&n.sort(d||$b),i.length>1&&i.sort(d||$b)}function c(){for(let h=e,d=r.length;h<d;h++){let f=r[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:c,sort:u}}function sO(){let r=new WeakMap;function e(n,i){let s;return r.has(n)===!1?(s=new ew,r.set(n,[s])):i>=r.get(n).length?(s=new ew,r.get(n).push(s)):s=r.get(n)[i],s}function t(){r=new WeakMap}return{get:e,dispose:t}}function oO(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new A,color:new Le};break;case"SpotLight":t={position:new A,direction:new A,color:new Le,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new A,color:new Le,distance:0,decay:0};break;case"HemisphereLight":t={direction:new A,skyColor:new Le,groundColor:new Le};break;case"RectAreaLight":t={color:new Le,position:new A,halfWidth:new A,halfHeight:new A};break}return r[e.id]=t,t}}}function aO(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var lO=0;function cO(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function uO(r,e){let t=new oO,n=aO(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let c=0;c<9;c++)i.probe.push(new A);let s=new A,o=new be,a=new be;function l(c,h){let d=0,f=0,m=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let p=0,g=0,v=0,y=0,w=0,b=0,S=0,_=0;c.sort(cO);let M=h!==!0?Math.PI:1;for(let T=0,E=c.length;T<E;T++){let C=c[T],P=C.color,O=C.intensity,I=C.distance,N=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)d+=P.r*O*M,f+=P.g*O*M,m+=P.b*O*M;else if(C.isLightProbe)for(let F=0;F<9;F++)i.probe[F].addScaledVector(C.sh.coefficients[F],O);else if(C.isDirectionalLight){let F=t.get(C);if(F.color.copy(C.color).multiplyScalar(C.intensity*M),C.castShadow){let G=C.shadow,Y=n.get(C);Y.shadowBias=G.bias,Y.shadowNormalBias=G.normalBias,Y.shadowRadius=G.radius,Y.shadowMapSize=G.mapSize,i.directionalShadow[p]=Y,i.directionalShadowMap[p]=N,i.directionalShadowMatrix[p]=C.shadow.matrix,b++}i.directional[p]=F,p++}else if(C.isSpotLight){let F=t.get(C);if(F.position.setFromMatrixPosition(C.matrixWorld),F.color.copy(P).multiplyScalar(O*M),F.distance=I,F.coneCos=Math.cos(C.angle),F.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),F.decay=C.decay,C.castShadow){let G=C.shadow,Y=n.get(C);Y.shadowBias=G.bias,Y.shadowNormalBias=G.normalBias,Y.shadowRadius=G.radius,Y.shadowMapSize=G.mapSize,i.spotShadow[v]=Y,i.spotShadowMap[v]=N,i.spotShadowMatrix[v]=C.shadow.matrix,_++}i.spot[v]=F,v++}else if(C.isRectAreaLight){let F=t.get(C);F.color.copy(P).multiplyScalar(O),F.halfWidth.set(C.width*.5,0,0),F.halfHeight.set(0,C.height*.5,0),i.rectArea[y]=F,y++}else if(C.isPointLight){let F=t.get(C);if(F.color.copy(C.color).multiplyScalar(C.intensity*M),F.distance=C.distance,F.decay=C.decay,C.castShadow){let G=C.shadow,Y=n.get(C);Y.shadowBias=G.bias,Y.shadowNormalBias=G.normalBias,Y.shadowRadius=G.radius,Y.shadowMapSize=G.mapSize,Y.shadowCameraNear=G.camera.near,Y.shadowCameraFar=G.camera.far,i.pointShadow[g]=Y,i.pointShadowMap[g]=N,i.pointShadowMatrix[g]=C.shadow.matrix,S++}i.point[g]=F,g++}else if(C.isHemisphereLight){let F=t.get(C);F.skyColor.copy(C.color).multiplyScalar(O*M),F.groundColor.copy(C.groundColor).multiplyScalar(O*M),i.hemi[w]=F,w++}}y>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=m;let x=i.hash;(x.directionalLength!==p||x.pointLength!==g||x.spotLength!==v||x.rectAreaLength!==y||x.hemiLength!==w||x.numDirectionalShadows!==b||x.numPointShadows!==S||x.numSpotShadows!==_)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=y,i.point.length=g,i.hemi.length=w,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=S,i.spotShadowMatrix.length=_,x.directionalLength=p,x.pointLength=g,x.spotLength=v,x.rectAreaLength=y,x.hemiLength=w,x.numDirectionalShadows=b,x.numPointShadows=S,x.numSpotShadows=_,i.version=lO++)}function u(c,h){let d=0,f=0,m=0,p=0,g=0,v=h.matrixWorldInverse;for(let y=0,w=c.length;y<w;y++){let b=c[y];if(b.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(v),d++}else if(b.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(v),S.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(v),m++}else if(b.isRectAreaLight){let S=i.rectArea[p];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(v),a.identity(),o.copy(b.matrixWorld),o.premultiply(v),a.extractRotation(o),S.halfWidth.set(b.width*.5,0,0),S.halfHeight.set(0,b.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),p++}else if(b.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(v),f++}else if(b.isHemisphereLight){let S=i.hemi[g];S.direction.setFromMatrixPosition(b.matrixWorld),S.direction.transformDirection(v),g++}}}return{setup:l,setupView:u,state:i}}function tw(r,e){let t=new uO(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function l(h){t.setup(n,h)}function u(h){t.setupView(n,h)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a}}function hO(r,e){let t=new WeakMap;function n(s,o=0){let a;return t.has(s)===!1?(a=new tw(r,e),t.set(s,[a])):o>=t.get(s).length?(a=new tw(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}var Tu=class extends Uo{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Cn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},ay=class extends Uo{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new A,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},dO=`void main() {
3108
+ `+D+`
3109
+ `+N)}else T!==""?console.warn("THREE.WebGLProgram: Program Info Log:",T):(E===""||C==="")&&(O=!1);O&&(this.diagnostics={runnable:P,programLog:T,vertexShader:{log:E,prefix:g},fragmentShader:{log:C,prefix:v}})}i.deleteShader(S),i.deleteShader(_);let M;this.getUniforms=function(){return M===void 0&&(M=new qa(i,p)),M};let x;return this.getAttributes=function(){return x===void 0&&(x=HL(i,p)),x},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=BL++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=S,this.fragmentShader=_,this}var tO=0,sy=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){let t=this.shaderCache;if(t.has(e)===!1){let n=new oy(e);t.set(e,n)}return t.get(e)}},oy=class{constructor(e){this.id=tO++,this.code=e,this.usedTimes=0}};function nO(r,e,t,n,i,s,o){let a=new Su,l=new sy,u=[],c=i.isWebGL2,h=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x,T,E,C,P){let O=C.fog,D=P.geometry,N=x.isMeshStandardMaterial?C.environment:null,F=(x.isMeshStandardMaterial?t:e).get(x.envMap||N),z=!!F&&F.mapping===dl?F.image.height:null,Y=m[x.type];x.precision!==null&&(f=i.getMaxPrecision(x.precision),f!==x.precision&&console.warn("THREE.WebGLProgram.getParameters:",x.precision,"not supported, using",f,"instead."));let U=D.morphAttributes.position||D.morphAttributes.normal||D.morphAttributes.color,G=U!==void 0?U.length:0,Q=0;D.morphAttributes.position!==void 0&&(Q=1),D.morphAttributes.normal!==void 0&&(Q=2),D.morphAttributes.color!==void 0&&(Q=3);let V,k,j,q;if(Y){let ne=_i[Y];V=ne.vertexShader,k=ne.fragmentShader}else V=x.vertexShader,k=x.fragmentShader,l.update(x),j=l.getVertexShaderID(x),q=l.getFragmentShaderID(x);let W=r.getRenderTarget(),he=x.alphaTest>0,ie=x.clearcoat>0,K=x.iridescence>0;return{isWebGL2:c,shaderID:Y,shaderName:x.type,vertexShader:V,fragmentShader:k,defines:x.defines,customVertexShaderID:j,customFragmentShaderID:q,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:f,instancing:P.isInstancedMesh===!0,instancingColor:P.isInstancedMesh===!0&&P.instanceColor!==null,supportsVertexTextures:d,outputEncoding:W===null?r.outputEncoding:W.isXRRenderTarget===!0?W.texture.encoding:Mr,map:!!x.map,matcap:!!x.matcap,envMap:!!F,envMapMode:F&&F.mapping,envMapCubeUVHeight:z,lightMap:!!x.lightMap,aoMap:!!x.aoMap,emissiveMap:!!x.emissiveMap,bumpMap:!!x.bumpMap,normalMap:!!x.normalMap,objectSpaceNormalMap:x.normalMapType===SP,tangentSpaceNormalMap:x.normalMapType===wP,decodeVideoTexture:!!x.map&&x.map.isVideoTexture===!0&&x.map.encoding===Xe,clearcoat:ie,clearcoatMap:ie&&!!x.clearcoatMap,clearcoatRoughnessMap:ie&&!!x.clearcoatRoughnessMap,clearcoatNormalMap:ie&&!!x.clearcoatNormalMap,iridescence:K,iridescenceMap:K&&!!x.iridescenceMap,iridescenceThicknessMap:K&&!!x.iridescenceThicknessMap,displacementMap:!!x.displacementMap,roughnessMap:!!x.roughnessMap,metalnessMap:!!x.metalnessMap,specularMap:!!x.specularMap,specularIntensityMap:!!x.specularIntensityMap,specularColorMap:!!x.specularColorMap,opaque:x.transparent===!1&&x.blending===Ns,alphaMap:!!x.alphaMap,alphaTest:he,gradientMap:!!x.gradientMap,sheen:x.sheen>0,sheenColorMap:!!x.sheenColorMap,sheenRoughnessMap:!!x.sheenRoughnessMap,transmission:x.transmission>0,transmissionMap:!!x.transmissionMap,thicknessMap:!!x.thicknessMap,combine:x.combine,vertexTangents:!!x.normalMap&&!!D.attributes.tangent,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!D.attributes.color&&D.attributes.color.itemSize===4,vertexUvs:!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatMap||!!x.clearcoatRoughnessMap||!!x.clearcoatNormalMap||!!x.iridescenceMap||!!x.iridescenceThicknessMap||!!x.displacementMap||!!x.transmissionMap||!!x.thicknessMap||!!x.specularIntensityMap||!!x.specularColorMap||!!x.sheenColorMap||!!x.sheenRoughnessMap,uvsVertexOnly:!(!!x.map||!!x.bumpMap||!!x.normalMap||!!x.specularMap||!!x.alphaMap||!!x.emissiveMap||!!x.roughnessMap||!!x.metalnessMap||!!x.clearcoatNormalMap||!!x.iridescenceMap||!!x.iridescenceThicknessMap||x.transmission>0||!!x.transmissionMap||!!x.thicknessMap||!!x.specularIntensityMap||!!x.specularColorMap||x.sheen>0||!!x.sheenColorMap||!!x.sheenRoughnessMap)&&!!x.displacementMap,fog:!!O,useFog:x.fog===!0,fogExp2:O&&O.isFogExp2,flatShading:!!x.flatShading,sizeAttenuation:x.sizeAttenuation,logarithmicDepthBuffer:h,skinning:P.isSkinnedMesh===!0,morphTargets:D.morphAttributes.position!==void 0,morphNormals:D.morphAttributes.normal!==void 0,morphColors:D.morphAttributes.color!==void 0,morphTargetsCount:G,morphTextureStride:Q,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:x.dithering,shadowMapEnabled:r.shadowMap.enabled&&E.length>0,shadowMapType:r.shadowMap.type,toneMapping:x.toneMapped?r.toneMapping:us,physicallyCorrectLights:r.physicallyCorrectLights,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===tr,flipSided:x.side===un,useDepthPacking:!!x.depthPacking,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionDerivatives:x.extensions&&x.extensions.derivatives,extensionFragDepth:x.extensions&&x.extensions.fragDepth,extensionDrawBuffers:x.extensions&&x.extensions.drawBuffers,extensionShaderTextureLOD:x.extensions&&x.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||n.has("EXT_shader_texture_lod"),customProgramCacheKey:x.customProgramCacheKey()}}function g(x){let T=[];if(x.shaderID?T.push(x.shaderID):(T.push(x.customVertexShaderID),T.push(x.customFragmentShaderID)),x.defines!==void 0)for(let E in x.defines)T.push(E),T.push(x.defines[E]);return x.isRawShaderMaterial===!1&&(v(T,x),y(T,x),T.push(r.outputEncoding)),T.push(x.customProgramCacheKey),T.join()}function v(x,T){x.push(T.precision),x.push(T.outputEncoding),x.push(T.envMapMode),x.push(T.envMapCubeUVHeight),x.push(T.combine),x.push(T.vertexUvs),x.push(T.fogExp2),x.push(T.sizeAttenuation),x.push(T.morphTargetsCount),x.push(T.morphAttributeCount),x.push(T.numDirLights),x.push(T.numPointLights),x.push(T.numSpotLights),x.push(T.numHemiLights),x.push(T.numRectAreaLights),x.push(T.numDirLightShadows),x.push(T.numPointLightShadows),x.push(T.numSpotLightShadows),x.push(T.shadowMapType),x.push(T.toneMapping),x.push(T.numClippingPlanes),x.push(T.numClipIntersection),x.push(T.depthPacking)}function y(x,T){a.disableAll(),T.isWebGL2&&a.enable(0),T.supportsVertexTextures&&a.enable(1),T.instancing&&a.enable(2),T.instancingColor&&a.enable(3),T.map&&a.enable(4),T.matcap&&a.enable(5),T.envMap&&a.enable(6),T.lightMap&&a.enable(7),T.aoMap&&a.enable(8),T.emissiveMap&&a.enable(9),T.bumpMap&&a.enable(10),T.normalMap&&a.enable(11),T.objectSpaceNormalMap&&a.enable(12),T.tangentSpaceNormalMap&&a.enable(13),T.clearcoat&&a.enable(14),T.clearcoatMap&&a.enable(15),T.clearcoatRoughnessMap&&a.enable(16),T.clearcoatNormalMap&&a.enable(17),T.iridescence&&a.enable(18),T.iridescenceMap&&a.enable(19),T.iridescenceThicknessMap&&a.enable(20),T.displacementMap&&a.enable(21),T.specularMap&&a.enable(22),T.roughnessMap&&a.enable(23),T.metalnessMap&&a.enable(24),T.gradientMap&&a.enable(25),T.alphaMap&&a.enable(26),T.alphaTest&&a.enable(27),T.vertexColors&&a.enable(28),T.vertexAlphas&&a.enable(29),T.vertexUvs&&a.enable(30),T.vertexTangents&&a.enable(31),T.uvsVertexOnly&&a.enable(32),T.fog&&a.enable(33),x.push(a.mask),a.disableAll(),T.useFog&&a.enable(0),T.flatShading&&a.enable(1),T.logarithmicDepthBuffer&&a.enable(2),T.skinning&&a.enable(3),T.morphTargets&&a.enable(4),T.morphNormals&&a.enable(5),T.morphColors&&a.enable(6),T.premultipliedAlpha&&a.enable(7),T.shadowMapEnabled&&a.enable(8),T.physicallyCorrectLights&&a.enable(9),T.doubleSided&&a.enable(10),T.flipSided&&a.enable(11),T.useDepthPacking&&a.enable(12),T.dithering&&a.enable(13),T.specularIntensityMap&&a.enable(14),T.specularColorMap&&a.enable(15),T.transmission&&a.enable(16),T.transmissionMap&&a.enable(17),T.thicknessMap&&a.enable(18),T.sheen&&a.enable(19),T.sheenColorMap&&a.enable(20),T.sheenRoughnessMap&&a.enable(21),T.decodeVideoTexture&&a.enable(22),T.opaque&&a.enable(23),x.push(a.mask)}function b(x){let T=m[x.type],E;if(T){let C=_i[T];E=ci.clone(C.uniforms)}else E=x.uniforms;return E}function w(x,T){let E;for(let C=0,P=u.length;C<P;C++){let O=u[C];if(O.cacheKey===T){E=O,++E.usedTimes;break}}return E===void 0&&(E=new eO(r,T,x,s),u.push(E)),E}function S(x){if(--x.usedTimes===0){let T=u.indexOf(x);u[T]=u[u.length-1],u.pop(),x.destroy()}}function _(x){l.remove(x)}function M(){l.dispose()}return{getParameters:p,getProgramCacheKey:g,getUniforms:b,acquireProgram:w,releaseProgram:S,releaseShaderCache:_,programs:u,dispose:M}}function rO(){let r=new WeakMap;function e(s){let o=r.get(s);return o===void 0&&(o={},r.set(s,o)),o}function t(s){r.delete(s)}function n(s,o,a){r.get(s)[o]=a}function i(){r=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function iO(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.material.id!==e.material.id?r.material.id-e.material.id:r.z!==e.z?r.z-e.z:r.id-e.id}function $b(r,e){return r.groupOrder!==e.groupOrder?r.groupOrder-e.groupOrder:r.renderOrder!==e.renderOrder?r.renderOrder-e.renderOrder:r.z!==e.z?e.z-r.z:r.id-e.id}function ew(){let r=[],e=0,t=[],n=[],i=[];function s(){e=0,t.length=0,n.length=0,i.length=0}function o(h,d,f,m,p,g){let v=r[e];return v===void 0?(v={id:h.id,object:h,geometry:d,material:f,groupOrder:m,renderOrder:h.renderOrder,z:p,group:g},r[e]=v):(v.id=h.id,v.object=h,v.geometry=d,v.material=f,v.groupOrder=m,v.renderOrder=h.renderOrder,v.z=p,v.group=g),e++,v}function a(h,d,f,m,p,g){let v=o(h,d,f,m,p,g);f.transmission>0?n.push(v):f.transparent===!0?i.push(v):t.push(v)}function l(h,d,f,m,p,g){let v=o(h,d,f,m,p,g);f.transmission>0?n.unshift(v):f.transparent===!0?i.unshift(v):t.unshift(v)}function u(h,d){t.length>1&&t.sort(h||iO),n.length>1&&n.sort(d||$b),i.length>1&&i.sort(d||$b)}function c(){for(let h=e,d=r.length;h<d;h++){let f=r[h];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:t,transmissive:n,transparent:i,init:s,push:a,unshift:l,finish:c,sort:u}}function sO(){let r=new WeakMap;function e(n,i){let s;return r.has(n)===!1?(s=new ew,r.set(n,[s])):i>=r.get(n).length?(s=new ew,r.get(n).push(s)):s=r.get(n)[i],s}function t(){r=new WeakMap}return{get:e,dispose:t}}function oO(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new A,color:new Le};break;case"SpotLight":t={position:new A,direction:new A,color:new Le,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new A,color:new Le,distance:0,decay:0};break;case"HemisphereLight":t={direction:new A,skyColor:new Le,groundColor:new Le};break;case"RectAreaLight":t={color:new Le,position:new A,halfWidth:new A,halfHeight:new A};break}return r[e.id]=t,t}}}function aO(){let r={};return{get:function(e){if(r[e.id]!==void 0)return r[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new B,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[e.id]=t,t}}}var lO=0;function cO(r,e){return(e.castShadow?1:0)-(r.castShadow?1:0)}function uO(r,e){let t=new oO,n=aO(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let c=0;c<9;c++)i.probe.push(new A);let s=new A,o=new be,a=new be;function l(c,h){let d=0,f=0,m=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let p=0,g=0,v=0,y=0,b=0,w=0,S=0,_=0;c.sort(cO);let M=h!==!0?Math.PI:1;for(let T=0,E=c.length;T<E;T++){let C=c[T],P=C.color,O=C.intensity,D=C.distance,N=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)d+=P.r*O*M,f+=P.g*O*M,m+=P.b*O*M;else if(C.isLightProbe)for(let F=0;F<9;F++)i.probe[F].addScaledVector(C.sh.coefficients[F],O);else if(C.isDirectionalLight){let F=t.get(C);if(F.color.copy(C.color).multiplyScalar(C.intensity*M),C.castShadow){let z=C.shadow,Y=n.get(C);Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,i.directionalShadow[p]=Y,i.directionalShadowMap[p]=N,i.directionalShadowMatrix[p]=C.shadow.matrix,w++}i.directional[p]=F,p++}else if(C.isSpotLight){let F=t.get(C);if(F.position.setFromMatrixPosition(C.matrixWorld),F.color.copy(P).multiplyScalar(O*M),F.distance=D,F.coneCos=Math.cos(C.angle),F.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),F.decay=C.decay,C.castShadow){let z=C.shadow,Y=n.get(C);Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,i.spotShadow[v]=Y,i.spotShadowMap[v]=N,i.spotShadowMatrix[v]=C.shadow.matrix,_++}i.spot[v]=F,v++}else if(C.isRectAreaLight){let F=t.get(C);F.color.copy(P).multiplyScalar(O),F.halfWidth.set(C.width*.5,0,0),F.halfHeight.set(0,C.height*.5,0),i.rectArea[y]=F,y++}else if(C.isPointLight){let F=t.get(C);if(F.color.copy(C.color).multiplyScalar(C.intensity*M),F.distance=C.distance,F.decay=C.decay,C.castShadow){let z=C.shadow,Y=n.get(C);Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,Y.shadowCameraNear=z.camera.near,Y.shadowCameraFar=z.camera.far,i.pointShadow[g]=Y,i.pointShadowMap[g]=N,i.pointShadowMatrix[g]=C.shadow.matrix,S++}i.point[g]=F,g++}else if(C.isHemisphereLight){let F=t.get(C);F.skyColor.copy(C.color).multiplyScalar(O*M),F.groundColor.copy(C.groundColor).multiplyScalar(O*M),i.hemi[b]=F,b++}}y>0&&(e.isWebGL2||r.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_FLOAT_1,i.rectAreaLTC2=pe.LTC_FLOAT_2):r.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=pe.LTC_HALF_1,i.rectAreaLTC2=pe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=d,i.ambient[1]=f,i.ambient[2]=m;let x=i.hash;(x.directionalLength!==p||x.pointLength!==g||x.spotLength!==v||x.rectAreaLength!==y||x.hemiLength!==b||x.numDirectionalShadows!==w||x.numPointShadows!==S||x.numSpotShadows!==_)&&(i.directional.length=p,i.spot.length=v,i.rectArea.length=y,i.point.length=g,i.hemi.length=b,i.directionalShadow.length=w,i.directionalShadowMap.length=w,i.pointShadow.length=S,i.pointShadowMap.length=S,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=w,i.pointShadowMatrix.length=S,i.spotShadowMatrix.length=_,x.directionalLength=p,x.pointLength=g,x.spotLength=v,x.rectAreaLength=y,x.hemiLength=b,x.numDirectionalShadows=w,x.numPointShadows=S,x.numSpotShadows=_,i.version=lO++)}function u(c,h){let d=0,f=0,m=0,p=0,g=0,v=h.matrixWorldInverse;for(let y=0,b=c.length;y<b;y++){let w=c[y];if(w.isDirectionalLight){let S=i.directional[d];S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(v),d++}else if(w.isSpotLight){let S=i.spot[m];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(v),S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(v),m++}else if(w.isRectAreaLight){let S=i.rectArea[p];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(v),a.identity(),o.copy(w.matrixWorld),o.premultiply(v),a.extractRotation(o),S.halfWidth.set(w.width*.5,0,0),S.halfHeight.set(0,w.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),p++}else if(w.isPointLight){let S=i.point[f];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(v),f++}else if(w.isHemisphereLight){let S=i.hemi[g];S.direction.setFromMatrixPosition(w.matrixWorld),S.direction.transformDirection(v),g++}}}return{setup:l,setupView:u,state:i}}function tw(r,e){let t=new uO(r,e),n=[],i=[];function s(){n.length=0,i.length=0}function o(h){n.push(h)}function a(h){i.push(h)}function l(h){t.setup(n,h)}function u(h){t.setupView(n,h)}return{init:s,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:l,setupLightsView:u,pushLight:o,pushShadow:a}}function hO(r,e){let t=new WeakMap;function n(s,o=0){let a;return t.has(s)===!1?(a=new tw(r,e),t.set(s,[a])):o>=t.get(s).length?(a=new tw(r,e),t.get(s).push(a)):a=t.get(s)[o],a}function i(){t=new WeakMap}return{get:n,dispose:i}}var Tu=class extends Uo{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Cn,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},ay=class extends Uo{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new A,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},dO=`void main() {
3110
3110
  gl_Position = vec4( position, 1.0 );
3111
3111
  }`,fO=`uniform sampler2D shadow_pass;
3112
3112
  uniform vec2 resolution;
@@ -3134,9 +3134,9 @@ void main() {
3134
3134
  squared_mean = squared_mean / samples;
3135
3135
  float std_dev = sqrt( squared_mean - mean * mean );
3136
3136
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3137
- }`;function pO(r,e,t){let n=new _u,i=new B,s=new B,o=new He,a=new Tu({depthPacking:Ly}),l=new ay,u={},c=t.maxTextureSize,h={0:un,1:Gr,2:tr},d=new mt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:dO,fragmentShader:fO}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new De;m.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new rn(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ff,this.render=function(b,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;let M=r.getRenderTarget(),x=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Rt),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,P=b.length;C<P;C++){let O=b[C],I=O.shadow;if(I===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(I.autoUpdate===!1&&I.needsUpdate===!1)continue;i.copy(I.mapSize);let N=I.getFrameExtents();if(i.multiply(N),s.copy(I.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/N.x),i.x=s.x*N.x,I.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/N.y),i.y=s.y*N.y,I.mapSize.y=s.y)),I.map===null){let G=this.type!==fu?{minFilter:Ft,magFilter:Ft}:{};I.map=new dt(i.x,i.y,G),I.map.texture.name=O.name+".shadowMap",I.camera.updateProjectionMatrix()}r.setRenderTarget(I.map),r.clear();let F=I.getViewportCount();for(let G=0;G<F;G++){let Y=I.getViewport(G);o.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),E.viewport(o),I.updateMatrices(O,G),n=I.getFrustum(),w(S,_,I.camera,O,this.type)}I.isPointLightShadow!==!0&&this.type===fu&&v(I,_),I.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(M,x,T)};function v(b,S){let _=e.update(p);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new dt(i.x,i.y)),d.uniforms.shadow_pass.value=b.map.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,r.setRenderTarget(b.mapPass),r.clear(),r.renderBufferDirect(S,null,_,d,p,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,r.setRenderTarget(b.map),r.clear(),r.renderBufferDirect(S,null,_,f,p,null)}function y(b,S,_,M,x,T){let E=null,C=_.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0?E=C:E=_.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let P=E.uuid,O=S.uuid,I=u[P];I===void 0&&(I={},u[P]=I);let N=I[O];N===void 0&&(N=E.clone(),I[O]=N),E=N}return E.visible=S.visible,E.wireframe=S.wireframe,T===fu?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:h[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,_.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(_.matrixWorld),E.nearDistance=M,E.farDistance=x),E}function w(b,S,_,M,x){if(b.visible===!1)return;if(b.layers.test(S.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&x===fu)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,b.matrixWorld);let C=e.update(b),P=b.material;if(Array.isArray(P)){let O=C.groups;for(let I=0,N=O.length;I<N;I++){let F=O[I],G=P[F.materialIndex];if(G&&G.visible){let Y=y(b,G,M,_.near,_.far,x);r.renderBufferDirect(_,null,C,Y,b,F)}}}else if(P.visible){let O=y(b,P,M,_.near,_.far,x);r.renderBufferDirect(_,null,C,O,b,null)}}let E=b.children;for(let C=0,P=E.length;C<P;C++)w(E[C],S,_,M,x)}}function mO(r,e,t){let n=t.isWebGL2;function i(){let H=!1,xe=new He,_e=null,Qe=new He(0,0,0,0);return{setMask:function(Re){_e!==Re&&!H&&(r.colorMask(Re,Re,Re,Re),_e=Re)},setLocked:function(Re){H=Re},setClear:function(Re,Ke,we,Je,it){it===!0&&(Re*=Je,Ke*=Je,we*=Je),xe.set(Re,Ke,we,Je),Qe.equals(xe)===!1&&(r.clearColor(Re,Ke,we,Je),Qe.copy(xe))},reset:function(){H=!1,_e=null,Qe.set(-1,0,0,0)}}}function s(){let H=!1,xe=null,_e=null,Qe=null;return{setTest:function(Re){Re?q(2929):W(2929)},setMask:function(Re){xe!==Re&&!H&&(r.depthMask(Re),xe=Re)},setFunc:function(Re){if(_e!==Re){if(Re)switch(Re){case WC:r.depthFunc(512);break;case jC:r.depthFunc(519);break;case qC:r.depthFunc(513);break;case jg:r.depthFunc(515);break;case XC:r.depthFunc(514);break;case YC:r.depthFunc(518);break;case QC:r.depthFunc(516);break;case ZC:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);_e=Re}},setLocked:function(Re){H=Re},setClear:function(Re){Qe!==Re&&(r.clearDepth(Re),Qe=Re)},reset:function(){H=!1,xe=null,_e=null,Qe=null}}}function o(){let H=!1,xe=null,_e=null,Qe=null,Re=null,Ke=null,we=null,Je=null,it=null;return{setTest:function(yt){H||(yt?q(2960):W(2960))},setMask:function(yt){xe!==yt&&!H&&(r.stencilMask(yt),xe=yt)},setFunc:function(yt,At,cr){(_e!==yt||Qe!==At||Re!==cr)&&(r.stencilFunc(yt,At,cr),_e=yt,Qe=At,Re=cr)},setOp:function(yt,At,cr){(Ke!==yt||we!==At||Je!==cr)&&(r.stencilOp(yt,At,cr),Ke=yt,we=At,Je=cr)},setLocked:function(yt){H=yt},setClear:function(yt){it!==yt&&(r.clearStencil(yt),it=yt)},reset:function(){H=!1,xe=null,_e=null,Qe=null,Re=null,Ke=null,we=null,Je=null,it=null}}}let a=new i,l=new s,u=new o,c={},h={},d=new WeakMap,f=[],m=null,p=!1,g=null,v=null,y=null,w=null,b=null,S=null,_=null,M=!1,x=null,T=null,E=null,C=null,P=null,O=r.getParameter(35661),I=!1,N=0,F=r.getParameter(7938);F.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(F)[1]),I=N>=1):F.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),I=N>=2);let G=null,Y={},U=r.getParameter(3088),z=r.getParameter(2978),Q=new He().fromArray(U),V=new He().fromArray(z);function k(H,xe,_e){let Qe=new Uint8Array(4),Re=r.createTexture();r.bindTexture(H,Re),r.texParameteri(H,10241,9728),r.texParameteri(H,10240,9728);for(let Ke=0;Ke<_e;Ke++)r.texImage2D(xe+Ke,0,6408,1,1,0,6408,5121,Qe);return Re}let j={};j[3553]=k(3553,3553,1),j[34067]=k(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),q(2929),l.setFunc(jg),Te(!1),me(Wx),q(2884),ce(Rt);function q(H){c[H]!==!0&&(r.enable(H),c[H]=!0)}function W(H){c[H]!==!1&&(r.disable(H),c[H]=!1)}function he(H,xe){return h[H]!==xe?(r.bindFramebuffer(H,xe),h[H]=xe,n&&(H===36009&&(h[36160]=xe),H===36160&&(h[36009]=xe)),!0):!1}function ie(H,xe){let _e=f,Qe=!1;if(H)if(_e=d.get(xe),_e===void 0&&(_e=[],d.set(xe,_e)),H.isWebGLMultipleRenderTargets){let Re=H.texture;if(_e.length!==Re.length||_e[0]!==36064){for(let Ke=0,we=Re.length;Ke<we;Ke++)_e[Ke]=36064+Ke;_e.length=Re.length,Qe=!0}}else _e[0]!==36064&&(_e[0]=36064,Qe=!0);else _e[0]!==1029&&(_e[0]=1029,Qe=!0);Qe&&(t.isWebGL2?r.drawBuffers(_e):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(_e))}function K(H){return m!==H?(r.useProgram(H),m=H,!0):!1}let X={[Ha]:32774,[OC]:32778,[RC]:32779};if(n)X[Yx]=32775,X[Qx]=32776;else{let H=e.get("EXT_blend_minmax");H!==null&&(X[Yx]=H.MIN_EXT,X[Qx]=H.MAX_EXT)}let ne={[NC]:0,[BC]:1,[FC]:768,[Aw]:770,[HC]:776,[kC]:774,[GC]:772,[UC]:769,[_w]:771,[VC]:775,[zC]:773};function ce(H,xe,_e,Qe,Re,Ke,we,Je){if(H===Rt){p===!0&&(W(3042),p=!1);return}if(p===!1&&(q(3042),p=!0),H!==LC){if(H!==g||Je!==M){if((v!==Ha||b!==Ha)&&(r.blendEquation(32774),v=Ha,b=Ha),Je)switch(H){case Ns:r.blendFuncSeparate(1,771,1,771);break;case jx:r.blendFunc(1,1);break;case qx:r.blendFuncSeparate(0,769,0,1);break;case Xx:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",H);break}else switch(H){case Ns:r.blendFuncSeparate(770,771,1,771);break;case jx:r.blendFunc(770,1);break;case qx:r.blendFuncSeparate(0,769,0,1);break;case Xx:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",H);break}y=null,w=null,S=null,_=null,g=H,M=Je}return}Re=Re||xe,Ke=Ke||_e,we=we||Qe,(xe!==v||Re!==b)&&(r.blendEquationSeparate(X[xe],X[Re]),v=xe,b=Re),(_e!==y||Qe!==w||Ke!==S||we!==_)&&(r.blendFuncSeparate(ne[_e],ne[Qe],ne[Ke],ne[we]),y=_e,w=Qe,S=Ke,_=we),g=H,M=null}function oe(H,xe){H.side===tr?W(2884):q(2884);let _e=H.side===un;xe&&(_e=!_e),Te(_e),H.blending===Ns&&H.transparent===!1?ce(Rt):ce(H.blending,H.blendEquation,H.blendSrc,H.blendDst,H.blendEquationAlpha,H.blendSrcAlpha,H.blendDstAlpha,H.premultipliedAlpha),l.setFunc(H.depthFunc),l.setTest(H.depthTest),l.setMask(H.depthWrite),a.setMask(H.colorWrite);let Qe=H.stencilWrite;u.setTest(Qe),Qe&&(u.setMask(H.stencilWriteMask),u.setFunc(H.stencilFunc,H.stencilRef,H.stencilFuncMask),u.setOp(H.stencilFail,H.stencilZFail,H.stencilZPass)),ye(H.polygonOffset,H.polygonOffsetFactor,H.polygonOffsetUnits),H.alphaToCoverage===!0?q(32926):W(32926)}function Te(H){x!==H&&(H?r.frontFace(2304):r.frontFace(2305),x=H)}function me(H){H!==PC?(q(2884),H!==T&&(H===Wx?r.cullFace(1029):H===DC?r.cullFace(1028):r.cullFace(1032))):W(2884),T=H}function ge(H){H!==E&&(I&&r.lineWidth(H),E=H)}function ye(H,xe,_e){H?(q(32823),(C!==xe||P!==_e)&&(r.polygonOffset(xe,_e),C=xe,P=_e)):W(32823)}function de(H){H?q(3089):W(3089)}function Pe(H){H===void 0&&(H=33984+O-1),G!==H&&(r.activeTexture(H),G=H)}function Ne(H,xe){G===null&&Pe();let _e=Y[G];_e===void 0&&(_e={type:void 0,texture:void 0},Y[G]=_e),(_e.type!==H||_e.texture!==xe)&&(r.bindTexture(H,xe||j[H]),_e.type=H,_e.texture=xe)}function Ze(){let H=Y[G];H!==void 0&&H.type!==void 0&&(r.bindTexture(H.type,null),H.type=void 0,H.texture=void 0)}function R(){try{r.compressedTexImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function D(){try{r.texSubImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function le(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function fe(){try{r.texStorage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Ee(){try{r.texStorage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Ue(){try{r.texImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function re(){try{r.texImage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Fe(H){Q.equals(H)===!1&&(r.scissor(H.x,H.y,H.z,H.w),Q.copy(H))}function Oe(H){V.equals(H)===!1&&(r.viewport(H.x,H.y,H.z,H.w),V.copy(H))}function ve(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),c={},G=null,Y={},h={},d=new WeakMap,f=[],m=null,p=!1,g=null,v=null,y=null,w=null,b=null,S=null,_=null,M=!1,x=null,T=null,E=null,C=null,P=null,Q.set(0,0,r.canvas.width,r.canvas.height),V.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:q,disable:W,bindFramebuffer:he,drawBuffers:ie,useProgram:K,setBlending:ce,setMaterial:oe,setFlipSided:Te,setCullFace:me,setLineWidth:ge,setPolygonOffset:ye,setScissorTest:de,activeTexture:Pe,bindTexture:Ne,unbindTexture:Ze,compressedTexImage2D:R,texImage2D:Ue,texImage3D:re,texStorage2D:fe,texStorage3D:Ee,texSubImage2D:D,texSubImage3D:J,compressedTexSubImage2D:le,scissor:Fe,viewport:Oe,reset:ve}}function gO(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,h=i.maxSamples,d=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,D){return v?new OffscreenCanvas(R,D):Yd("canvas")}function w(R,D,J,le){let fe=1;if((R.width>le||R.height>le)&&(fe=le/Math.max(R.width,R.height)),fe<1||D===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ee=D?Xd:Math.floor,Ue=Ee(fe*R.width),re=Ee(fe*R.height);p===void 0&&(p=y(Ue,re));let Fe=J?y(Ue,re):p;return Fe.width=Ue,Fe.height=re,Fe.getContext("2d").drawImage(R,0,0,Ue,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ue+"x"+re+")."),Fe}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Kg(R.width)&&Kg(R.height)}function S(R){return a?!1:R.wrapS!==er||R.wrapT!==er||R.minFilter!==Ft&&R.minFilter!==at}function _(R,D){return R.generateMipmaps&&D&&R.minFilter!==Ft&&R.minFilter!==at}function M(R){r.generateMipmap(R)}function x(R,D,J,le,fe=!1){if(a===!1)return D;if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ee=D;return D===6403&&(J===5126&&(Ee=33326),J===5131&&(Ee=33325),J===5121&&(Ee=33321)),D===33319&&(J===5126&&(Ee=33328),J===5131&&(Ee=33327),J===5121&&(Ee=33323)),D===6408&&(J===5126&&(Ee=34836),J===5131&&(Ee=34842),J===5121&&(Ee=le===Xe&&fe===!1?35907:32856),J===32819&&(Ee=32854),J===32820&&(Ee=32855)),(Ee===33325||Ee===33326||Ee===33327||Ee===33328||Ee===34842||Ee===34836)&&e.get("EXT_color_buffer_float"),Ee}function T(R,D,J){return _(R,J)===!0||R.isFramebufferTexture&&R.minFilter!==Ft&&R.minFilter!==at?Math.log2(Math.max(D.width,D.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?D.mipmaps.length:1}function E(R){return R===Ft||R===Zx||R===Kx?9728:9729}function C(R){let D=R.target;D.removeEventListener("dispose",C),O(D),D.isVideoTexture&&m.delete(D)}function P(R){let D=R.target;D.removeEventListener("dispose",P),N(D)}function O(R){let D=n.get(R);if(D.__webglInit===void 0)return;let J=R.source,le=g.get(J);if(le){let fe=le[D.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&I(R),Object.keys(le).length===0&&g.delete(J)}n.remove(R)}function I(R){let D=n.get(R);r.deleteTexture(D.__webglTexture);let J=R.source,le=g.get(J);delete le[D.__cacheKey],o.memory.textures--}function N(R){let D=R.texture,J=n.get(R),le=n.get(D);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let fe=0;fe<6;fe++)r.deleteFramebuffer(J.__webglFramebuffer[fe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[fe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let fe=0;fe<J.__webglColorRenderbuffer.length;fe++)J.__webglColorRenderbuffer[fe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[fe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let fe=0,Ee=D.length;fe<Ee;fe++){let Ue=n.get(D[fe]);Ue.__webglTexture&&(r.deleteTexture(Ue.__webglTexture),o.memory.textures--),n.remove(D[fe])}n.remove(D),n.remove(R)}let F=0;function G(){F=0}function Y(){let R=F;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),F+=1,R}function U(R){let D=[];return D.push(R.wrapS),D.push(R.wrapT),D.push(R.magFilter),D.push(R.minFilter),D.push(R.anisotropy),D.push(R.internalFormat),D.push(R.format),D.push(R.type),D.push(R.generateMipmaps),D.push(R.premultiplyAlpha),D.push(R.flipY),D.push(R.unpackAlignment),D.push(R.encoding),D.join()}function z(R,D){let J=n.get(R);if(R.isVideoTexture&&Ne(R),R.isRenderTargetTexture===!1&&R.version>0&&J.__version!==R.version){let le=R.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(J,R,D);return}}t.activeTexture(33984+D),t.bindTexture(3553,J.__webglTexture)}function Q(R,D){let J=n.get(R);if(R.version>0&&J.__version!==R.version){ie(J,R,D);return}t.activeTexture(33984+D),t.bindTexture(35866,J.__webglTexture)}function V(R,D){let J=n.get(R);if(R.version>0&&J.__version!==R.version){ie(J,R,D);return}t.activeTexture(33984+D),t.bindTexture(32879,J.__webglTexture)}function k(R,D){let J=n.get(R);if(R.version>0&&J.__version!==R.version){K(J,R,D);return}t.activeTexture(33984+D),t.bindTexture(34067,J.__webglTexture)}let j={[Xa]:10497,[er]:33071,[Yg]:33648},q={[Ft]:9728,[Zx]:9984,[Kx]:9986,[at]:9729,[iP]:9985,[fl]:9987};function W(R,D,J){if(J?(r.texParameteri(R,10242,j[D.wrapS]),r.texParameteri(R,10243,j[D.wrapT]),(R===32879||R===35866)&&r.texParameteri(R,32882,j[D.wrapR]),r.texParameteri(R,10240,q[D.magFilter]),r.texParameteri(R,10241,q[D.minFilter])):(r.texParameteri(R,10242,33071),r.texParameteri(R,10243,33071),(R===32879||R===35866)&&r.texParameteri(R,32882,33071),(D.wrapS!==er||D.wrapT!==er)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(R,10240,E(D.magFilter)),r.texParameteri(R,10241,E(D.minFilter)),D.minFilter!==Ft&&D.minFilter!==at&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let le=e.get("EXT_texture_filter_anisotropic");if(D.type===Ti&&e.has("OES_texture_float_linear")===!1||a===!1&&D.type===bu&&e.has("OES_texture_half_float_linear")===!1)return;(D.anisotropy>1||n.get(D).__currentAnisotropy)&&(r.texParameterf(R,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(D.anisotropy,i.getMaxAnisotropy())),n.get(D).__currentAnisotropy=D.anisotropy)}}function he(R,D){let J=!1;R.__webglInit===void 0&&(R.__webglInit=!0,D.addEventListener("dispose",C));let le=D.source,fe=g.get(le);fe===void 0&&(fe={},g.set(le,fe));let Ee=U(D);if(Ee!==R.__cacheKey){fe[Ee]===void 0&&(fe[Ee]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),fe[Ee].usedTimes++;let Ue=fe[R.__cacheKey];Ue!==void 0&&(fe[R.__cacheKey].usedTimes--,Ue.usedTimes===0&&I(D)),R.__cacheKey=Ee,R.__webglTexture=fe[Ee].texture}return J}function ie(R,D,J){let le=3553;D.isDataArrayTexture&&(le=35866),D.isData3DTexture&&(le=32879);let fe=he(R,D),Ee=D.source;if(t.activeTexture(33984+J),t.bindTexture(le,R.__webglTexture),Ee.version!==Ee.__currentVersion||fe===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Ue=S(D)&&b(D.image)===!1,re=w(D.image,Ue,!1,c);re=Ze(D,re);let Fe=b(re)||a,Oe=s.convert(D.format,D.encoding),ve=s.convert(D.type),H=x(D.internalFormat,Oe,ve,D.encoding,D.isVideoTexture);W(le,D,Fe);let xe,_e=D.mipmaps,Qe=a&&D.isVideoTexture!==!0,Re=Ee.__currentVersion===void 0||fe===!0,Ke=T(D,re,Fe);if(D.isDepthTexture)H=6402,a?D.type===Ti?H=36012:D.type===cs?H=33190:D.type===Bs?H=35056:H=33189:D.type===Ti&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),D.format===Bo&&H===6402&&D.type!==Ew&&D.type!==cs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),D.type=cs,ve=s.convert(D.type)),D.format===Gs&&H===6402&&(H=34041,D.type!==Bs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),D.type=Bs,ve=s.convert(D.type))),Re&&(Qe?t.texStorage2D(3553,1,H,re.width,re.height):t.texImage2D(3553,0,H,re.width,re.height,0,Oe,ve,null));else if(D.isDataTexture)if(_e.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],Qe?t.texSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,ve,xe.data):t.texImage2D(3553,we,H,xe.width,xe.height,0,Oe,ve,xe.data);D.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Ke,H,re.width,re.height),t.texSubImage2D(3553,0,0,0,re.width,re.height,Oe,ve,re.data)):t.texImage2D(3553,0,H,re.width,re.height,0,Oe,ve,re.data);else if(D.isCompressedTexture){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],D.format!==si?Oe!==null?Qe?t.compressedTexSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,xe.data):t.compressedTexImage2D(3553,we,H,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?t.texSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,ve,xe.data):t.texImage2D(3553,we,H,xe.width,xe.height,0,Oe,ve,xe.data)}else if(D.isDataArrayTexture)Qe?(Re&&t.texStorage3D(35866,Ke,H,re.width,re.height,re.depth),t.texSubImage3D(35866,0,0,0,0,re.width,re.height,re.depth,Oe,ve,re.data)):t.texImage3D(35866,0,H,re.width,re.height,re.depth,0,Oe,ve,re.data);else if(D.isData3DTexture)Qe?(Re&&t.texStorage3D(32879,Ke,H,re.width,re.height,re.depth),t.texSubImage3D(32879,0,0,0,0,re.width,re.height,re.depth,Oe,ve,re.data)):t.texImage3D(32879,0,H,re.width,re.height,re.depth,0,Oe,ve,re.data);else if(D.isFramebufferTexture){if(Re)if(Qe)t.texStorage2D(3553,Ke,H,re.width,re.height);else{let we=re.width,Je=re.height;for(let it=0;it<Ke;it++)t.texImage2D(3553,it,H,we,Je,0,Oe,ve,null),we>>=1,Je>>=1}}else if(_e.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],Qe?t.texSubImage2D(3553,we,0,0,Oe,ve,xe):t.texImage2D(3553,we,H,Oe,ve,xe);D.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Ke,H,re.width,re.height),t.texSubImage2D(3553,0,0,0,Oe,ve,re)):t.texImage2D(3553,0,H,Oe,ve,re);_(D,Fe)&&M(le),Ee.__currentVersion=Ee.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function K(R,D,J){if(D.image.length!==6)return;let le=he(R,D),fe=D.source;if(t.activeTexture(33984+J),t.bindTexture(34067,R.__webglTexture),fe.version!==fe.__currentVersion||le===!0){r.pixelStorei(37440,D.flipY),r.pixelStorei(37441,D.premultiplyAlpha),r.pixelStorei(3317,D.unpackAlignment),r.pixelStorei(37443,0);let Ee=D.isCompressedTexture||D.image[0].isCompressedTexture,Ue=D.image[0]&&D.image[0].isDataTexture,re=[];for(let we=0;we<6;we++)!Ee&&!Ue?re[we]=w(D.image[we],!1,!0,u):re[we]=Ue?D.image[we].image:D.image[we],re[we]=Ze(D,re[we]);let Fe=re[0],Oe=b(Fe)||a,ve=s.convert(D.format,D.encoding),H=s.convert(D.type),xe=x(D.internalFormat,ve,H,D.encoding),_e=a&&D.isVideoTexture!==!0,Qe=fe.__currentVersion===void 0||le===!0,Re=T(D,Fe,Oe);W(34067,D,Oe);let Ke;if(Ee){_e&&Qe&&t.texStorage2D(34067,Re,xe,Fe.width,Fe.height);for(let we=0;we<6;we++){Ke=re[we].mipmaps;for(let Je=0;Je<Ke.length;Je++){let it=Ke[Je];D.format!==si?ve!==null?_e?t.compressedTexSubImage2D(34069+we,Je,0,0,it.width,it.height,ve,it.data):t.compressedTexImage2D(34069+we,Je,xe,it.width,it.height,0,it.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?t.texSubImage2D(34069+we,Je,0,0,it.width,it.height,ve,H,it.data):t.texImage2D(34069+we,Je,xe,it.width,it.height,0,ve,H,it.data)}}}else{Ke=D.mipmaps,_e&&Qe&&(Ke.length>0&&Re++,t.texStorage2D(34067,Re,xe,re[0].width,re[0].height));for(let we=0;we<6;we++)if(Ue){_e?t.texSubImage2D(34069+we,0,0,0,re[we].width,re[we].height,ve,H,re[we].data):t.texImage2D(34069+we,0,xe,re[we].width,re[we].height,0,ve,H,re[we].data);for(let Je=0;Je<Ke.length;Je++){let yt=Ke[Je].image[we].image;_e?t.texSubImage2D(34069+we,Je+1,0,0,yt.width,yt.height,ve,H,yt.data):t.texImage2D(34069+we,Je+1,xe,yt.width,yt.height,0,ve,H,yt.data)}}else{_e?t.texSubImage2D(34069+we,0,0,0,ve,H,re[we]):t.texImage2D(34069+we,0,xe,ve,H,re[we]);for(let Je=0;Je<Ke.length;Je++){let it=Ke[Je];_e?t.texSubImage2D(34069+we,Je+1,0,0,ve,H,it.image[we]):t.texImage2D(34069+we,Je+1,xe,ve,H,it.image[we])}}}_(D,Oe)&&M(34067),fe.__currentVersion=fe.version,D.onUpdate&&D.onUpdate(D)}R.__version=D.version}function X(R,D,J,le,fe){let Ee=s.convert(J.format,J.encoding),Ue=s.convert(J.type),re=x(J.internalFormat,Ee,Ue,J.encoding);n.get(D).__hasExternalTextures||(fe===32879||fe===35866?t.texImage3D(fe,0,re,D.width,D.height,D.depth,0,Ee,Ue,null):t.texImage2D(fe,0,re,D.width,D.height,0,Ee,Ue,null)),t.bindFramebuffer(36160,R),Pe(D)?d.framebufferTexture2DMultisampleEXT(36160,le,fe,n.get(J).__webglTexture,0,de(D)):r.framebufferTexture2D(36160,le,fe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function ne(R,D,J){if(r.bindRenderbuffer(36161,R),D.depthBuffer&&!D.stencilBuffer){let le=33189;if(J||Pe(D)){let fe=D.depthTexture;fe&&fe.isDepthTexture&&(fe.type===Ti?le=36012:fe.type===cs&&(le=33190));let Ee=de(D);Pe(D)?d.renderbufferStorageMultisampleEXT(36161,Ee,le,D.width,D.height):r.renderbufferStorageMultisample(36161,Ee,le,D.width,D.height)}else r.renderbufferStorage(36161,le,D.width,D.height);r.framebufferRenderbuffer(36160,36096,36161,R)}else if(D.depthBuffer&&D.stencilBuffer){let le=de(D);J&&Pe(D)===!1?r.renderbufferStorageMultisample(36161,le,35056,D.width,D.height):Pe(D)?d.renderbufferStorageMultisampleEXT(36161,le,35056,D.width,D.height):r.renderbufferStorage(36161,34041,D.width,D.height),r.framebufferRenderbuffer(36160,33306,36161,R)}else{let le=D.isWebGLMultipleRenderTargets===!0?D.texture:[D.texture];for(let fe=0;fe<le.length;fe++){let Ee=le[fe],Ue=s.convert(Ee.format,Ee.encoding),re=s.convert(Ee.type),Fe=x(Ee.internalFormat,Ue,re,Ee.encoding),Oe=de(D);J&&Pe(D)===!1?r.renderbufferStorageMultisample(36161,Oe,Fe,D.width,D.height):Pe(D)?d.renderbufferStorageMultisampleEXT(36161,Oe,Fe,D.width,D.height):r.renderbufferStorage(36161,Fe,D.width,D.height)}}r.bindRenderbuffer(36161,null)}function ce(R,D){if(D&&D.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,R),!(D.depthTexture&&D.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(D.depthTexture).__webglTexture||D.depthTexture.image.width!==D.width||D.depthTexture.image.height!==D.height)&&(D.depthTexture.image.width=D.width,D.depthTexture.image.height=D.height,D.depthTexture.needsUpdate=!0),z(D.depthTexture,0);let le=n.get(D.depthTexture).__webglTexture,fe=de(D);if(D.depthTexture.format===Bo)Pe(D)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,le,0,fe):r.framebufferTexture2D(36160,36096,3553,le,0);else if(D.depthTexture.format===Gs)Pe(D)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,le,0,fe):r.framebufferTexture2D(36160,33306,3553,le,0);else throw new Error("Unknown depthTexture format")}function oe(R){let D=n.get(R),J=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!D.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");ce(D.__webglFramebuffer,R)}else if(J){D.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(36160,D.__webglFramebuffer[le]),D.__webglDepthbuffer[le]=r.createRenderbuffer(),ne(D.__webglDepthbuffer[le],R,!1)}else t.bindFramebuffer(36160,D.__webglFramebuffer),D.__webglDepthbuffer=r.createRenderbuffer(),ne(D.__webglDepthbuffer,R,!1);t.bindFramebuffer(36160,null)}function Te(R,D,J){let le=n.get(R);D!==void 0&&X(le.__webglFramebuffer,R,R.texture,36064,3553),J!==void 0&&oe(R)}function me(R){let D=R.texture,J=n.get(R),le=n.get(D);R.addEventListener("dispose",P),R.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=r.createTexture()),le.__version=D.version,o.memory.textures++);let fe=R.isWebGLCubeRenderTarget===!0,Ee=R.isWebGLMultipleRenderTargets===!0,Ue=b(R)||a;if(fe){J.__webglFramebuffer=[];for(let re=0;re<6;re++)J.__webglFramebuffer[re]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Ee)if(i.drawBuffers){let re=R.texture;for(let Fe=0,Oe=re.length;Fe<Oe;Fe++){let ve=n.get(re[Fe]);ve.__webglTexture===void 0&&(ve.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&Pe(R)===!1){let re=Ee?D:[D];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Fe=0;Fe<re.length;Fe++){let Oe=re[Fe];J.__webglColorRenderbuffer[Fe]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Fe]);let ve=s.convert(Oe.format,Oe.encoding),H=s.convert(Oe.type),xe=x(Oe.internalFormat,ve,H,Oe.encoding),_e=de(R);r.renderbufferStorageMultisample(36161,_e,xe,R.width,R.height),r.framebufferRenderbuffer(36160,36064+Fe,36161,J.__webglColorRenderbuffer[Fe])}r.bindRenderbuffer(36161,null),R.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),ne(J.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(36160,null)}}if(fe){t.bindTexture(34067,le.__webglTexture),W(34067,D,Ue);for(let re=0;re<6;re++)X(J.__webglFramebuffer[re],R,D,36064,34069+re);_(D,Ue)&&M(34067),t.unbindTexture()}else if(Ee){let re=R.texture;for(let Fe=0,Oe=re.length;Fe<Oe;Fe++){let ve=re[Fe],H=n.get(ve);t.bindTexture(3553,H.__webglTexture),W(3553,ve,Ue),X(J.__webglFramebuffer,R,ve,36064+Fe,3553),_(ve,Ue)&&M(3553)}t.unbindTexture()}else{let re=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?re=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(re,le.__webglTexture),W(re,D,Ue),X(J.__webglFramebuffer,R,D,36064,re),_(D,Ue)&&M(re),t.unbindTexture()}R.depthBuffer&&oe(R)}function ge(R){let D=b(R)||a,J=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let le=0,fe=J.length;le<fe;le++){let Ee=J[le];if(_(Ee,D)){let Ue=R.isWebGLCubeRenderTarget?34067:3553,re=n.get(Ee).__webglTexture;t.bindTexture(Ue,re),M(Ue),t.unbindTexture()}}}function ye(R){if(a&&R.samples>0&&Pe(R)===!1){let D=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],J=R.width,le=R.height,fe=16384,Ee=[],Ue=R.stencilBuffer?33306:36096,re=n.get(R),Fe=R.isWebGLMultipleRenderTargets===!0;if(Fe)for(let Oe=0;Oe<D.length;Oe++)t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Oe,36161,null),t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Oe,3553,null,0);t.bindFramebuffer(36008,re.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,re.__webglFramebuffer);for(let Oe=0;Oe<D.length;Oe++){Ee.push(36064+Oe),R.depthBuffer&&Ee.push(Ue);let ve=re.__ignoreDepthValues!==void 0?re.__ignoreDepthValues:!1;if(ve===!1&&(R.depthBuffer&&(fe|=256),R.stencilBuffer&&(fe|=1024)),Fe&&r.framebufferRenderbuffer(36008,36064,36161,re.__webglColorRenderbuffer[Oe]),ve===!0&&(r.invalidateFramebuffer(36008,[Ue]),r.invalidateFramebuffer(36009,[Ue])),Fe){let H=n.get(D[Oe]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,H,0)}r.blitFramebuffer(0,0,J,le,0,0,J,le,fe,9728),f&&r.invalidateFramebuffer(36008,Ee)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Fe)for(let Oe=0;Oe<D.length;Oe++){t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Oe,36161,re.__webglColorRenderbuffer[Oe]);let ve=n.get(D[Oe]).__webglTexture;t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Oe,3553,ve,0)}t.bindFramebuffer(36009,re.__webglMultisampledFramebuffer)}}function de(R){return Math.min(h,R.samples)}function Pe(R){let D=n.get(R);return a&&R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&D.__useRenderToTexture!==!1}function Ne(R){let D=o.render.frame;m.get(R)!==D&&(m.set(R,D),R.update())}function Ze(R,D){let J=R.encoding,le=R.format,fe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Zg||J!==Mr&&(J===Xe?a===!1?e.has("EXT_sRGB")===!0&&le===si?(R.format=Zg,R.minFilter=at,R.generateMipmaps=!1):D=Qd.sRGBToLinear(D):(le!==si||fe!==Ut)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),D}this.allocateTextureUnit=Y,this.resetTextureUnits=G,this.setTexture2D=z,this.setTexture2DArray=Q,this.setTexture3D=V,this.setTextureCube=k,this.rebindTextures=Te,this.setupRenderTarget=me,this.updateRenderTargetMipmap=ge,this.updateMultisampleRenderTarget=ye,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=X,this.useMultisampledRTT=Pe}function yO(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===Ut)return 5121;if(s===lP)return 32819;if(s===cP)return 32820;if(s===sP)return 5120;if(s===oP)return 5122;if(s===Ew)return 5123;if(s===aP)return 5124;if(s===cs)return 5125;if(s===Ti)return 5126;if(s===bu)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===uP)return 6406;if(s===si)return 6408;if(s===dP)return 6409;if(s===fP)return 6410;if(s===Bo)return 6402;if(s===Gs)return 34041;if(s===pP)return 6403;if(s===hP)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Zg)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===mP)return 36244;if(s===gP)return 33319;if(s===yP)return 33320;if(s===vP)return 36249;if(s===cg||s===ug||s===hg||s===dg)if(o===Xe)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===cg)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ug)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===dg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===cg)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ug)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hg)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===dg)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Jx||s===$x||s===eb||s===tb)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Jx)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===$x)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===eb)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===tb)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===xP)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===nb||s===rb)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===nb)return o===Xe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===rb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===ib||s===sb||s===ob||s===ab||s===lb||s===cb||s===ub||s===hb||s===db||s===fb||s===pb||s===mb||s===gb||s===yb)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===ib)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===sb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===ob)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ab)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===lb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===cb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ub)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===hb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===db)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===fb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===pb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===mb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===gb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===yb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===vb)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===vb)return o===Xe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Bs?n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var ly=class extends nn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Rs=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},vO={type:"move"},yu=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Rs,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Rs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Rs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,n);if(u.joints[p.jointName]===void 0){let y=new Rs;y.matrixAutoUpdate=!1,y.visible=!1,u.joints[p.jointName]=y,u.add(y)}let v=u.joints[p.jointName];g!==null&&(v.matrix.fromArray(g.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=g.radius),v.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,m=.005;u.inputState.pinching&&d>f+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&d<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(vO)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}},ks=class extends Yt{constructor(e,t,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Bo,c!==Bo&&c!==Gs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Bo&&(n=cs),n===void 0&&c===Gs&&(n=Bs),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ft,this.minFilter=l!==void 0?l:Ft,this.flipY=!1,this.generateMipmaps=!1}},cy=class extends Lt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,u=null,c=null,h=null,d=null,f=null,m=t.getContextAttributes(),p=null,g=null,v=[],y=[],w=new nn;w.layers.enable(1),w.viewport=new He;let b=new nn;b.layers.enable(2),b.viewport=new He;let S=[w,b],_=new ly;_.layers.enable(1),_.layers.enable(2);let M=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let z=v[U];return z===void 0&&(z=new yu,v[U]=z),z.getTargetRaySpace()},this.getControllerGrip=function(U){let z=v[U];return z===void 0&&(z=new yu,v[U]=z),z.getGripSpace()},this.getHand=function(U){let z=v[U];return z===void 0&&(z=new yu,v[U]=z),z.getHandSpace()};function T(U){let z=y.indexOf(U.inputSource);if(z===-1)return;let Q=v[z];Q!==void 0&&Q.dispatchEvent({type:U.type,data:U.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C);for(let U=0;U<v.length;U++){let z=y[U];z!==null&&(y[U]=null,v[U].disconnect(z))}M=null,x=null,e.setRenderTarget(p),d=null,h=null,c=null,i=null,g=null,Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(U){l=U},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(U){if(i=U,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let z={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,z),i.updateRenderState({baseLayer:d}),g=new dt(d.framebufferWidth,d.framebufferHeight,{format:si,type:Ut,encoding:e.outputEncoding})}else{let z=null,Q=null,V=null;m.depth&&(V=m.stencil?35056:33190,z=m.stencil?Gs:Bo,Q=m.stencil?Bs:cs);let k={colorFormat:32856,depthFormat:V,scaleFactor:s};c=new XRWebGLBinding(i,t),h=c.createProjectionLayer(k),i.updateRenderState({layers:[h]}),g=new dt(h.textureWidth,h.textureHeight,{format:si,type:Ut,depthTexture:new ks(h.textureWidth,h.textureHeight,Q,void 0,void 0,void 0,void 0,void 0,void 0,z),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let j=e.properties.get(g);j.__ignoreDepthValues=h.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),Y.setContext(i),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(U){for(let z=0;z<U.removed.length;z++){let Q=U.removed[z],V=y.indexOf(Q);V>=0&&(y[V]=null,v[V].dispatchEvent({type:"disconnected",data:Q}))}for(let z=0;z<U.added.length;z++){let Q=U.added[z],V=y.indexOf(Q);if(V===-1){for(let j=0;j<v.length;j++)if(j>=y.length){y.push(Q),V=j;break}else if(y[j]===null){y[j]=Q,V=j;break}if(V===-1)break}let k=v[V];k&&k.dispatchEvent({type:"connected",data:Q})}}let P=new A,O=new A;function I(U,z,Q){P.setFromMatrixPosition(z.matrixWorld),O.setFromMatrixPosition(Q.matrixWorld);let V=P.distanceTo(O),k=z.projectionMatrix.elements,j=Q.projectionMatrix.elements,q=k[14]/(k[10]-1),W=k[14]/(k[10]+1),he=(k[9]+1)/k[5],ie=(k[9]-1)/k[5],K=(k[8]-1)/k[0],X=(j[8]+1)/j[0],ne=q*K,ce=q*X,oe=V/(-K+X),Te=oe*-K;z.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(Te),U.translateZ(oe),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let me=q+oe,ge=W+oe,ye=ne-Te,de=ce+(V-Te),Pe=he*W/ge*me,Ne=ie*W/ge*me;U.projectionMatrix.makePerspective(ye,de,Pe,Ne,me,ge)}function N(U,z){z===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(z.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(i===null)return;_.near=b.near=w.near=U.near,_.far=b.far=w.far=U.far,(M!==_.near||x!==_.far)&&(i.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,x=_.far);let z=U.parent,Q=_.cameras;N(_,z);for(let k=0;k<Q.length;k++)N(Q[k],z);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),U.position.copy(_.position),U.quaternion.copy(_.quaternion),U.scale.copy(_.scale),U.matrix.copy(_.matrix),U.matrixWorld.copy(_.matrixWorld);let V=U.children;for(let k=0,j=V.length;k<j;k++)V[k].updateMatrixWorld(!0);Q.length===2?I(_,w,b):_.projectionMatrix.copy(w.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(h!==null)return h.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(U){h!==null&&(h.fixedFoveation=U),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=U)};let F=null;function G(U,z){if(u=z.getViewerPose(l||o),f=z,u!==null){let Q=u.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let V=!1;Q.length!==_.cameras.length&&(_.cameras.length=0,V=!0);for(let k=0;k<Q.length;k++){let j=Q[k],q=null;if(d!==null)q=d.getViewport(j);else{let he=c.getViewSubImage(h,j);q=he.viewport,k===0&&(e.setRenderTargetTextures(g,he.colorTexture,h.ignoreDepthValues?void 0:he.depthStencilTexture),e.setRenderTarget(g))}let W=S[k];W===void 0&&(W=new nn,W.layers.enable(k),W.viewport=new He,S[k]=W),W.matrix.fromArray(j.transform.matrix),W.projectionMatrix.fromArray(j.projectionMatrix),W.viewport.set(q.x,q.y,q.width,q.height),k===0&&_.matrix.copy(W.matrix),V===!0&&_.cameras.push(W)}}for(let Q=0;Q<v.length;Q++){let V=y[Q],k=v[Q];V!==null&&k!==void 0&&k.update(V,z,l||o)}F&&F(U,z),f=null}let Y=new Dw;Y.setAnimationLoop(G),this.setAnimationLoop=function(U){F=U},this.dispose=function(){}}};function xO(r,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,v,y,w){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),c(p,g)):g.isMeshPhongMaterial?(i(p,g),u(p,g)):g.isMeshStandardMaterial?(i(p,g),h(p,g),g.isMeshPhysicalMaterial&&d(p,g,w)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,v,y):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===un&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===un&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v=e.get(g).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let b=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*b}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix));let w;g.aoMap?w=g.aoMap:g.lightMap&&(w=g.lightMap),w!==void 0&&(w.isWebGLRenderTarget&&(w=w.texture),w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uv2Transform.value.copy(w.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,v,y){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*v,p.scale.value=y*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let w;g.map?w=g.map:g.alphaMap&&(w=g.alphaMap),w!==void 0&&(w.matrixAutoUpdate===!0&&w.updateMatrix(),p.uvTransform.value.copy(w.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function h(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function d(p,g,v){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===un&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function bO(){let r=Yd("canvas");return r.style.display="block",r}function Ny(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:bO(),t=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;t!==null?c=t.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let h=null,d=null,f=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Mr,this.physicallyCorrectLights=!1,this.toneMapping=us,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,v=0,y=0,w=null,b=-1,S=null,_=new He,M=new He,x=null,T=e.width,E=e.height,C=1,P=null,O=null,I=new He(0,0,T,E),N=new He(0,0,T,E),F=!1,G=new _u,Y=!1,U=!1,z=null,Q=new be,V=new B,k=new A,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return w===null?C:1}let W=t;function he(L,$){for(let se=0;se<L.length;se++){let te=L[se],ue=e.getContext(te,$);if(ue!==null)return ue}return null}try{let L={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Qo}`),e.addEventListener("webglcontextlost",H,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",_e,!1),W===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),W=he($,L),W===null)throw he($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let ie,K,X,ne,ce,oe,Te,me,ge,ye,de,Pe,Ne,Ze,R,D,J,le,fe,Ee,Ue,re,Fe;function Oe(){ie=new kI(W),K=new NI(W,ie,r),ie.init(K),re=new yO(W,ie,K),X=new mO(W,ie,K),ne=new WI,ce=new rO,oe=new gO(W,ie,X,ce,K,re,ne),Te=new FI(p),me=new zI(p),ge=new n2(W,K),Fe=new OI(W,ie,ge,K),ye=new VI(W,ge,ne,Fe),de=new YI(W,ye,ge,ne),fe=new XI(W,K,oe),D=new BI(ce),Pe=new nO(p,Te,me,ie,K,Fe,D),Ne=new xO(p,ce),Ze=new sO,R=new hO(ie,K),le=new LI(p,Te,X,de,c,o),J=new pO(p,de,K),Ee=new RI(W,ie,ne,K),Ue=new HI(W,ie,ne,K),ne.programs=Pe.programs,p.capabilities=K,p.extensions=ie,p.properties=ce,p.renderLists=Ze,p.shadowMap=J,p.state=X,p.info=ne}Oe();let ve=new cy(p,W);this.xr=ve,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let L=ie.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=ie.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(T,E,!1))},this.getSize=function(L){return L.set(T,E)},this.setSize=function(L,$,se){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),se!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,se){T=L,E=$,C=se,e.width=Math.floor(L*se),e.height=Math.floor($*se),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(_)},this.getViewport=function(L){return L.copy(I)},this.setViewport=function(L,$,se,te){L.isVector4?I.set(L.x,L.y,L.z,L.w):I.set(L,$,se,te),X.viewport(_.copy(I).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(N)},this.setScissor=function(L,$,se,te){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,se,te),X.scissor(M.copy(N).multiplyScalar(C).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(L){X.setScissorTest(F=L)},this.setOpaqueSort=function(L){P=L},this.setTransparentSort=function(L){O=L},this.getClearColor=function(L){return L.copy(le.getClearColor())},this.setClearColor=function(){le.setClearColor.apply(le,arguments)},this.getClearAlpha=function(){return le.getClearAlpha()},this.setClearAlpha=function(){le.setClearAlpha.apply(le,arguments)},this.clear=function(L=!0,$=!0,se=!0){let te=0;L&&(te|=16384),$&&(te|=256),se&&(te|=1024),W.clear(te)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",H,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",_e,!1),Ze.dispose(),R.dispose(),ce.dispose(),Te.dispose(),me.dispose(),de.dispose(),Fe.dispose(),Pe.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",it),ve.removeEventListener("sessionend",yt),z&&(z.dispose(),z=null),At.stop()};function H(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=ne.autoReset,$=J.enabled,se=J.autoUpdate,te=J.needsUpdate,ue=J.type;Oe(),ne.autoReset=L,J.enabled=$,J.autoUpdate=se,J.needsUpdate=te,J.type=ue}function _e(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function Qe(L){let $=L.target;$.removeEventListener("dispose",Qe),Re($)}function Re(L){Ke(L),ce.remove(L)}function Ke(L){let $=ce.get(L).programs;$!==void 0&&($.forEach(function(se){Pe.releaseProgram(se)}),L.isShaderMaterial&&Pe.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,se,te,ue,et){$===null&&($=j);let rt=ue.isMesh&&ue.matrixWorld.determinant()<0,ot=xC(L,$,se,te,ue);X.setMaterial(te,rt);let st=se.index,Dt=se.attributes.position;if(st===null){if(Dt===void 0||Dt.count===0)return}else if(st.count===0)return;let pt=1;te.wireframe===!0&&(st=ye.getWireframeAttribute(se),pt=2),Fe.setup(ue,te,ot,se,st);let vt,qt=Ee;st!==null&&(vt=ge.get(st),qt=Ue,qt.setIndex(vt));let Po=st!==null?st.count:Dt.count,Ma=se.drawRange.start*pt,Ea=se.drawRange.count*pt,wi=et!==null?et.start*pt:0,_t=et!==null?et.count*pt:1/0,Ca=Math.max(Ma,wi),ln=Math.min(Po,Ma+Ea,wi+_t)-1,Si=Math.max(0,ln-Ca+1);if(Si!==0){if(ue.isMesh)te.wireframe===!0?(X.setLineWidth(te.wireframeLinewidth*q()),qt.setMode(1)):qt.setMode(4);else if(ue.isLine){let Ms=te.linewidth;Ms===void 0&&(Ms=1),X.setLineWidth(Ms*q()),ue.isLineSegments?qt.setMode(1):ue.isLineLoop?qt.setMode(2):qt.setMode(3)}else ue.isPoints?qt.setMode(0):ue.isSprite&&qt.setMode(4);if(ue.isInstancedMesh)qt.renderInstances(Ca,Si,ue.count);else if(se.isInstancedBufferGeometry){let Ms=Math.min(se.instanceCount,se._maxInstanceCount);qt.renderInstances(Ca,Si,Ms)}else qt.render(Ca,Si)}},this.compile=function(L,$){d=R.get(L),d.init(),m.push(d),L.traverseVisible(function(se){se.isLight&&se.layers.test($.layers)&&(d.pushLight(se),se.castShadow&&d.pushShadow(se))}),d.setupLights(p.physicallyCorrectLights),L.traverse(function(se){let te=se.material;if(te)if(Array.isArray(te))for(let ue=0;ue<te.length;ue++){let et=te[ue];sg(et,L,se)}else sg(te,L,se)}),m.pop(),d=null};let we=null;function Je(L){we&&we(L)}function it(){At.stop()}function yt(){At.start()}let At=new Dw;At.setAnimationLoop(Je),typeof self<"u"&&At.setContext(self),this.setAnimationLoop=function(L){we=L,ve.setAnimationLoop(L),L===null?At.stop():At.start()},ve.addEventListener("sessionstart",it),ve.addEventListener("sessionend",yt),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,w),d=R.get(L,m.length),d.init(),m.push(d),Q.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),G.setFromProjectionMatrix(Q),U=this.localClippingEnabled,Y=D.init(this.clippingPlanes,U,$),h=Ze.get(L,f.length),h.init(),f.push(h),cr(L,$,0,p.sortObjects),h.finish(),p.sortObjects===!0&&h.sort(P,O),Y===!0&&D.beginShadows();let se=d.state.shadowsArray;if(J.render(se,L,$),Y===!0&&D.endShadows(),this.info.autoReset===!0&&this.info.reset(),le.render(h,L),d.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let te=$.cameras;for(let ue=0,et=te.length;ue<et;ue++){let rt=te[ue];pd(h,L,rt,rt.viewport)}}else pd(h,L,$);w!==null&&(oe.updateMultisampleRenderTarget(w),oe.updateRenderTargetMipmap(w)),L.isScene===!0&&L.onAfterRender(p,L,$),Fe.resetDefaultState(),b=-1,S=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function cr(L,$,se,te){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)se=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)d.pushLight(L),L.castShadow&&d.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||G.intersectsSprite(L)){te&&k.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let rt=de.update(L),ot=L.material;ot.visible&&h.push(L,rt,ot,se,k.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==ne.render.frame&&(L.skeleton.update(),L.skeleton.frame=ne.render.frame),!L.frustumCulled||G.intersectsObject(L))){te&&k.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let rt=de.update(L),ot=L.material;if(Array.isArray(ot)){let st=rt.groups;for(let Dt=0,pt=st.length;Dt<pt;Dt++){let vt=st[Dt],qt=ot[vt.materialIndex];qt&&qt.visible&&h.push(L,rt,qt,se,k.z,vt)}}else ot.visible&&h.push(L,rt,ot,se,k.z,null)}}let et=L.children;for(let rt=0,ot=et.length;rt<ot;rt++)cr(et[rt],$,se,te)}function pd(L,$,se,te){let ue=L.opaque,et=L.transmissive,rt=L.transparent;d.setupLightsView(se),et.length>0&&Ta(ue,$,se),te&&X.viewport(_.copy(te)),ue.length>0&&md(ue,$,se),et.length>0&&md(et,$,se),rt.length>0&&md(rt,$,se),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function Ta(L,$,se){let te=K.isWebGL2;z===null&&(z=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?bu:Ut,minFilter:fl,samples:te&&s===!0?4:0})),p.getDrawingBufferSize(V),te?z.setSize(V.x,V.y):z.setSize(Xd(V.x),Xd(V.y));let ue=p.getRenderTarget();p.setRenderTarget(z),p.clear();let et=p.toneMapping;p.toneMapping=us,md(L,$,se),p.toneMapping=et,oe.updateMultisampleRenderTarget(z),oe.updateRenderTargetMipmap(z),p.setRenderTarget(ue)}function md(L,$,se){let te=$.isScene===!0?$.overrideMaterial:null;for(let ue=0,et=L.length;ue<et;ue++){let rt=L[ue],ot=rt.object,st=rt.geometry,Dt=te===null?rt.material:te,pt=rt.group;ot.layers.test(se.layers)&&vC(ot,$,se,st,Dt,pt)}}function vC(L,$,se,te,ue,et){L.onBeforeRender(p,$,se,te,ue,et),L.modelViewMatrix.multiplyMatrices(se.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),ue.onBeforeRender(p,$,se,te,L,et),ue.transparent===!0&&ue.side===tr?(ue.side=un,ue.needsUpdate=!0,p.renderBufferDirect(se,$,te,ue,L,et),ue.side=Gr,ue.needsUpdate=!0,p.renderBufferDirect(se,$,te,ue,L,et),ue.side=tr):p.renderBufferDirect(se,$,te,ue,L,et),L.onAfterRender(p,$,se,te,ue,et)}function sg(L,$,se){$.isScene!==!0&&($=j);let te=ce.get(L),ue=d.state.lights,et=d.state.shadowsArray,rt=ue.state.version,ot=Pe.getParameters(L,ue.state,et,$,se),st=Pe.getProgramCacheKey(ot),Dt=te.programs;te.environment=L.isMeshStandardMaterial?$.environment:null,te.fog=$.fog,te.envMap=(L.isMeshStandardMaterial?me:Te).get(L.envMap||te.environment),Dt===void 0&&(L.addEventListener("dispose",Qe),Dt=new Map,te.programs=Dt);let pt=Dt.get(st);if(pt!==void 0){if(te.currentProgram===pt&&te.lightsStateVersion===rt)return kx(L,ot),pt}else ot.uniforms=Pe.getUniforms(L),L.onBuild(se,ot,p),L.onBeforeCompile(ot,p),pt=Pe.acquireProgram(ot,st),Dt.set(st,pt),te.uniforms=ot.uniforms;let vt=te.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(vt.clippingPlanes=D.uniform),kx(L,ot),te.needsLights=wC(L),te.lightsStateVersion=rt,te.needsLights&&(vt.ambientLightColor.value=ue.state.ambient,vt.lightProbe.value=ue.state.probe,vt.directionalLights.value=ue.state.directional,vt.directionalLightShadows.value=ue.state.directionalShadow,vt.spotLights.value=ue.state.spot,vt.spotLightShadows.value=ue.state.spotShadow,vt.rectAreaLights.value=ue.state.rectArea,vt.ltc_1.value=ue.state.rectAreaLTC1,vt.ltc_2.value=ue.state.rectAreaLTC2,vt.pointLights.value=ue.state.point,vt.pointLightShadows.value=ue.state.pointShadow,vt.hemisphereLights.value=ue.state.hemi,vt.directionalShadowMap.value=ue.state.directionalShadowMap,vt.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,vt.spotShadowMap.value=ue.state.spotShadowMap,vt.spotShadowMatrix.value=ue.state.spotShadowMatrix,vt.pointShadowMap.value=ue.state.pointShadowMap,vt.pointShadowMatrix.value=ue.state.pointShadowMatrix);let qt=pt.getUniforms(),Po=qa.seqWithValue(qt.seq,vt);return te.currentProgram=pt,te.uniformsList=Po,pt}function kx(L,$){let se=ce.get(L);se.outputEncoding=$.outputEncoding,se.instancing=$.instancing,se.skinning=$.skinning,se.morphTargets=$.morphTargets,se.morphNormals=$.morphNormals,se.morphColors=$.morphColors,se.morphTargetsCount=$.morphTargetsCount,se.numClippingPlanes=$.numClippingPlanes,se.numIntersection=$.numClipIntersection,se.vertexAlphas=$.vertexAlphas,se.vertexTangents=$.vertexTangents,se.toneMapping=$.toneMapping}function xC(L,$,se,te,ue){$.isScene!==!0&&($=j),oe.resetTextureUnits();let et=$.fog,rt=te.isMeshStandardMaterial?$.environment:null,ot=w===null?p.outputEncoding:w.isXRRenderTarget===!0?w.texture.encoding:Mr,st=(te.isMeshStandardMaterial?me:Te).get(te.envMap||rt),Dt=te.vertexColors===!0&&!!se.attributes.color&&se.attributes.color.itemSize===4,pt=!!te.normalMap&&!!se.attributes.tangent,vt=!!se.morphAttributes.position,qt=!!se.morphAttributes.normal,Po=!!se.morphAttributes.color,Ma=te.toneMapped?p.toneMapping:us,Ea=se.morphAttributes.position||se.morphAttributes.normal||se.morphAttributes.color,wi=Ea!==void 0?Ea.length:0,_t=ce.get(te),Ca=d.state.lights;if(Y===!0&&(U===!0||L!==S)){let Ai=L===S&&te.id===b;D.setState(te,L,Ai)}let ln=!1;te.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Ca.state.version||_t.outputEncoding!==ot||ue.isInstancedMesh&&_t.instancing===!1||!ue.isInstancedMesh&&_t.instancing===!0||ue.isSkinnedMesh&&_t.skinning===!1||!ue.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==st||te.fog===!0&&_t.fog!==et||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==D.numPlanes||_t.numIntersection!==D.numIntersection)||_t.vertexAlphas!==Dt||_t.vertexTangents!==pt||_t.morphTargets!==vt||_t.morphNormals!==qt||_t.morphColors!==Po||_t.toneMapping!==Ma||K.isWebGL2===!0&&_t.morphTargetsCount!==wi)&&(ln=!0):(ln=!0,_t.__version=te.version);let Si=_t.currentProgram;ln===!0&&(Si=sg(te,$,ue));let Ms=!1,au=!1,og=!1,Jn=Si.getUniforms(),lu=_t.uniforms;if(X.useProgram(Si.program)&&(Ms=!0,au=!0,og=!0),te.id!==b&&(b=te.id,au=!0),Ms||S!==L){if(Jn.setValue(W,"projectionMatrix",L.projectionMatrix),K.logarithmicDepthBuffer&&Jn.setValue(W,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,au=!0,og=!0),te.isShaderMaterial||te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshStandardMaterial||te.envMap){let Ai=Jn.map.cameraPosition;Ai!==void 0&&Ai.setValue(W,k.setFromMatrixPosition(L.matrixWorld))}(te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshLambertMaterial||te.isMeshBasicMaterial||te.isMeshStandardMaterial||te.isShaderMaterial)&&Jn.setValue(W,"isOrthographic",L.isOrthographicCamera===!0),(te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshLambertMaterial||te.isMeshBasicMaterial||te.isMeshStandardMaterial||te.isShaderMaterial||te.isShadowMaterial||ue.isSkinnedMesh)&&Jn.setValue(W,"viewMatrix",L.matrixWorldInverse)}if(ue.isSkinnedMesh){Jn.setOptional(W,ue,"bindMatrix"),Jn.setOptional(W,ue,"bindMatrixInverse");let Ai=ue.skeleton;Ai&&(K.floatVertexTextures?(Ai.boneTexture===null&&Ai.computeBoneTexture(),Jn.setValue(W,"boneTexture",Ai.boneTexture,oe),Jn.setValue(W,"boneTextureSize",Ai.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let ag=se.morphAttributes;return(ag.position!==void 0||ag.normal!==void 0||ag.color!==void 0&&K.isWebGL2===!0)&&fe.update(ue,se,te,Si),(au||_t.receiveShadow!==ue.receiveShadow)&&(_t.receiveShadow=ue.receiveShadow,Jn.setValue(W,"receiveShadow",ue.receiveShadow)),au&&(Jn.setValue(W,"toneMappingExposure",p.toneMappingExposure),_t.needsLights&&bC(lu,og),et&&te.fog===!0&&Ne.refreshFogUniforms(lu,et),Ne.refreshMaterialUniforms(lu,te,C,E,z),qa.upload(W,_t.uniformsList,lu,oe)),te.isShaderMaterial&&te.uniformsNeedUpdate===!0&&(qa.upload(W,_t.uniformsList,lu,oe),te.uniformsNeedUpdate=!1),te.isSpriteMaterial&&Jn.setValue(W,"center",ue.center),Jn.setValue(W,"modelViewMatrix",ue.modelViewMatrix),Jn.setValue(W,"normalMatrix",ue.normalMatrix),Jn.setValue(W,"modelMatrix",ue.matrixWorld),Si}function bC(L,$){L.ambientLightColor.needsUpdate=$,L.lightProbe.needsUpdate=$,L.directionalLights.needsUpdate=$,L.directionalLightShadows.needsUpdate=$,L.pointLights.needsUpdate=$,L.pointLightShadows.needsUpdate=$,L.spotLights.needsUpdate=$,L.spotLightShadows.needsUpdate=$,L.rectAreaLights.needsUpdate=$,L.hemisphereLights.needsUpdate=$}function wC(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(L,$,se){ce.get(L.texture).__webglTexture=$,ce.get(L.depthTexture).__webglTexture=se;let te=ce.get(L);te.__hasExternalTextures=!0,te.__hasExternalTextures&&(te.__autoAllocateDepthBuffer=se===void 0,te.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),te.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let se=ce.get(L);se.__webglFramebuffer=$,se.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,se=0){w=L,v=$,y=se;let te=!0;if(L){let st=ce.get(L);st.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(36160,null),te=!1):st.__webglFramebuffer===void 0?oe.setupRenderTarget(L):st.__hasExternalTextures&&oe.rebindTextures(L,ce.get(L.texture).__webglTexture,ce.get(L.depthTexture).__webglTexture)}let ue=null,et=!1,rt=!1;if(L){let st=L.texture;(st.isData3DTexture||st.isDataArrayTexture)&&(rt=!0);let Dt=ce.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(ue=Dt[$],et=!0):K.isWebGL2&&L.samples>0&&oe.useMultisampledRTT(L)===!1?ue=ce.get(L).__webglMultisampledFramebuffer:ue=Dt,_.copy(L.viewport),M.copy(L.scissor),x=L.scissorTest}else _.copy(I).multiplyScalar(C).floor(),M.copy(N).multiplyScalar(C).floor(),x=F;if(X.bindFramebuffer(36160,ue)&&K.drawBuffers&&te&&X.drawBuffers(L,ue),X.viewport(_),X.scissor(M),X.setScissorTest(x),et){let st=ce.get(L.texture);W.framebufferTexture2D(36160,36064,34069+$,st.__webglTexture,se)}else if(rt){let st=ce.get(L.texture),Dt=$||0;W.framebufferTextureLayer(36160,36064,st.__webglTexture,se||0,Dt)}b=-1},this.readRenderTargetPixels=function(L,$,se,te,ue,et,rt){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=ce.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){X.bindFramebuffer(36160,ot);try{let st=L.texture,Dt=st.format,pt=st.type;if(Dt!==si&&re.convert(Dt)!==W.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let vt=pt===bu&&(ie.has("EXT_color_buffer_half_float")||K.isWebGL2&&ie.has("EXT_color_buffer_float"));if(pt!==Ut&&re.convert(pt)!==W.getParameter(35738)&&!(pt===Ti&&(K.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!vt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-te&&se>=0&&se<=L.height-ue&&W.readPixels($,se,te,ue,re.convert(Dt),re.convert(pt),et)}finally{let st=w!==null?ce.get(w).__webglFramebuffer:null;X.bindFramebuffer(36160,st)}}},this.copyFramebufferToTexture=function(L,$,se=0){let te=Math.pow(2,-se),ue=Math.floor($.image.width*te),et=Math.floor($.image.height*te);oe.setTexture2D($,0),W.copyTexSubImage2D(3553,se,0,0,L.x,L.y,ue,et),X.unbindTexture()},this.copyTextureToTexture=function(L,$,se,te=0){let ue=$.image.width,et=$.image.height,rt=re.convert(se.format),ot=re.convert(se.type);oe.setTexture2D(se,0),W.pixelStorei(37440,se.flipY),W.pixelStorei(37441,se.premultiplyAlpha),W.pixelStorei(3317,se.unpackAlignment),$.isDataTexture?W.texSubImage2D(3553,te,L.x,L.y,ue,et,rt,ot,$.image.data):$.isCompressedTexture?W.compressedTexSubImage2D(3553,te,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,rt,$.mipmaps[0].data):W.texSubImage2D(3553,te,L.x,L.y,rt,ot,$.image),te===0&&se.generateMipmaps&&W.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(L,$,se,te,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let et=L.max.x-L.min.x+1,rt=L.max.y-L.min.y+1,ot=L.max.z-L.min.z+1,st=re.convert(te.format),Dt=re.convert(te.type),pt;if(te.isData3DTexture)oe.setTexture3D(te,0),pt=32879;else if(te.isDataArrayTexture)oe.setTexture2DArray(te,0),pt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(37440,te.flipY),W.pixelStorei(37441,te.premultiplyAlpha),W.pixelStorei(3317,te.unpackAlignment);let vt=W.getParameter(3314),qt=W.getParameter(32878),Po=W.getParameter(3316),Ma=W.getParameter(3315),Ea=W.getParameter(32877),wi=se.isCompressedTexture?se.mipmaps[0]:se.image;W.pixelStorei(3314,wi.width),W.pixelStorei(32878,wi.height),W.pixelStorei(3316,L.min.x),W.pixelStorei(3315,L.min.y),W.pixelStorei(32877,L.min.z),se.isDataTexture||se.isData3DTexture?W.texSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Dt,wi.data):se.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),W.compressedTexSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,wi.data)):W.texSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Dt,wi),W.pixelStorei(3314,vt),W.pixelStorei(32878,qt),W.pixelStorei(3316,Po),W.pixelStorei(3315,Ma),W.pixelStorei(32877,Ea),ue===0&&te.generateMipmaps&&W.generateMipmap(pt),X.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?oe.setTextureCube(L,0):L.isData3DTexture?oe.setTexture3D(L,0):L.isDataArrayTexture?oe.setTexture2DArray(L,0):oe.setTexture2D(L,0),X.unbindTexture()},this.resetState=function(){v=0,y=0,w=null,X.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var uy=class extends Ny{};uy.prototype.isWebGL1Renderer=!0;var Ka=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Le(e),this.near=t,this.far=n}clone(){return new Ka(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ir=class extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},ef=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Qg,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Mi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},$n=new A,Go=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.applyMatrix4(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.applyNormalMatrix(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.transformDirection(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Ge(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Go(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var tf=class extends Ge{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};var zr=class extends Uo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},nw=new A,rw=new A,iw=new be,zg=new oi,Fd=new En,zo=class extends ht{constructor(e=new De,t=new zr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)nw.fromBufferAttribute(t,i-1),rw.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=nw.distanceTo(rw);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Fd.copy(n.boundingSphere),Fd.applyMatrix4(i),Fd.radius+=s,e.ray.intersectsSphere(Fd)===!1)return;iw.copy(i).invert(),zg.copy(e.ray).applyMatrix4(iw);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,h=new A,d=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let v=Math.max(0,o.start),y=Math.min(m.count,o.start+o.count);for(let w=v,b=y-1;w<b;w+=f){let S=m.getX(w),_=m.getX(w+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),zg.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(d);x<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}else{let v=Math.max(0,o.start),y=Math.min(g.count,o.start+o.count);for(let w=v,b=y-1;w<b;w+=f){if(u.fromBufferAttribute(g,w),c.fromBufferAttribute(g,w+1),zg.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(d);_<e.near||_>e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:w,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},sw=new A,ow=new A,Vs=class extends zo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)sw.fromBufferAttribute(t,i),ow.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+sw.distanceTo(ow);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var kr=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],d=n[i+1]-c,f=(o-c)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new A,i=[],s=[],o=[],a=new A,l=new be;for(let f=0;f<=e;f++){let m=f/e;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),h<=u&&(u=h,n.set(0,1,0)),d<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(pn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(pn(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ko=class extends kr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new B,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return n.set(l,u)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},hy=class extends ko{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function By(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var Ud=new A,kg=new By,Vg=new By,Hg=new By,dy=class extends kr{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new A){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=i[(a-1)%s]:(Ud.subVectors(i[0],i[1]).add(i[0]),u=Ud);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Ud.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Ud),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(h),f),p=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),kg.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,m,p,g),Vg.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,m,p,g),Hg.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(kg.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),Vg.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),Hg.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return n.set(kg.calc(l),Vg.calc(l),Hg.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function aw(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function wO(r,e){let t=1-r;return t*t*e}function SO(r,e){return 2*(1-r)*r*e}function AO(r,e){return r*r*e}function vu(r,e,t,n){return wO(r,e)+SO(r,t)+AO(r,n)}function _O(r,e){let t=1-r;return t*t*t*e}function TO(r,e){let t=1-r;return 3*t*t*r*e}function MO(r,e){return 3*(1-r)*r*r*e}function EO(r,e){return r*r*r*e}function xu(r,e,t,n,i){return _O(r,e)+TO(r,t)+MO(r,n)+EO(r,i)}var Wn=class extends kr{constructor(e=new B,t=new B,n=new B,i=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(xu(e,i.x,s.x,o.x,a.x),xu(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},fy=class extends kr{constructor(e=new A,t=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(xu(e,i.x,s.x,o.x,a.x),xu(e,i.y,s.y,o.y,a.y),xu(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},jn=class extends kr{constructor(e=new B,t=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new B){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let n=t||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Mu=class extends kr{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Er=class extends kr{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(vu(e,i.x,s.x,o.x),vu(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},py=class extends kr{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(vu(e,i.x,s.x,o.x),vu(e,i.y,s.y,o.y),vu(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ja=class extends kr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new B){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(aw(a,l.x,u.x,c.x,h.x),aw(a,l.y,u.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new B().fromArray(i))}return this}},CO=Object.freeze({__proto__:null,ArcCurve:hy,CatmullRomCurve3:dy,CubicBezierCurve:Wn,CubicBezierCurve3:fy,EllipseCurve:ko,LineCurve:jn,LineCurve3:Mu,QuadraticBezierCurve:Er,QuadraticBezierCurve3:py,SplineCurve:Ja}),my=class extends kr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new jn(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(t.push(c),n=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new CO[i.type]().fromJSON(i))}return this}},Vo=class extends my{constructor(e){super(),this.type="Path",this.currentPoint=new B,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new jn(this.currentPoint.clone(),new B(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Er(this.currentPoint.clone(),new B(e,t),new B(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new Wn(this.currentPoint.clone(),new B(e,t),new B(n,i),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new Ja(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+u,t+c,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let u=new ko(e,t,n,i,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},$a=class extends De{constructor(e=[new B(0,.5),new B(.5,0),new B(0,-.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=pn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/t,h=new A,d=new B,f=new A,m=new A,p=new A,g=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,f.x=v*1,f.y=-g,f.z=v*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,f.x=v*1,f.y=-g,f.z=v*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let y=0;y<=t;y++){let w=n+y*c*i,b=Math.sin(w),S=Math.cos(w);for(let _=0;_<=e.length-1;_++){h.x=e[_].x*b,h.y=e[_].y,h.z=e[_].x*S,o.push(h.x,h.y,h.z),d.x=y/t,d.y=_/(e.length-1),a.push(d.x,d.y);let M=l[3*_+0]*b,x=l[3*_+1],T=l[3*_+0]*S;u.push(M,x,T)}}for(let y=0;y<t;y++)for(let w=0;w<e.length-1;w++){let b=w+y*e.length,S=b,_=b+e.length,M=b+e.length+1,x=b+1;s.push(S,_,x),s.push(M,x,_)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(u,3))}static fromJSON(e){return new $a(e.points,e.segments,e.phiStart,e.phiLength)}};var Ho=class extends De{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],h=[],d=[],f=[],m=0,p=[],g=n/2,v=0;y(),o===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(c),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(d,3)),this.setAttribute("uv",new Ae(f,2));function y(){let b=new A,S=new A,_=0,M=(t-e)/n;for(let x=0;x<=s;x++){let T=[],E=x/s,C=E*(t-e)+e;for(let P=0;P<=i;P++){let O=P/i,I=O*l+a,N=Math.sin(I),F=Math.cos(I);S.x=C*N,S.y=-E*n+g,S.z=C*F,h.push(S.x,S.y,S.z),b.set(N,M,F).normalize(),d.push(b.x,b.y,b.z),f.push(O,1-E),T.push(m++)}p.push(T)}for(let x=0;x<i;x++)for(let T=0;T<s;T++){let E=p[T][x],C=p[T+1][x],P=p[T+1][x+1],O=p[T][x+1];c.push(E,C,O),c.push(C,P,O),_+=6}u.addGroup(v,_,0),v+=_}function w(b){let S=m,_=new B,M=new A,x=0,T=b===!0?e:t,E=b===!0?1:-1;for(let P=1;P<=i;P++)h.push(0,g*E,0),d.push(0,E,0),f.push(.5,.5),m++;let C=m;for(let P=0;P<=i;P++){let I=P/i*l+a,N=Math.cos(I),F=Math.sin(I);M.x=T*F,M.y=g*E,M.z=T*N,h.push(M.x,M.y,M.z),d.push(0,E,0),_.x=N*.5+.5,_.y=F*.5*E+.5,f.push(_.x,_.y),m++}for(let P=0;P<i;P++){let O=S+P,I=C+P;b===!0?c.push(I,I+1,O):c.push(I+1,I,O),x+=3}u.addGroup(v,x,b===!0?1:2),v+=x}}static fromJSON(e){return new Ho(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},el=class extends Ho{constructor(e=1,t=1,n=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new el(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},tl=class extends De{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){let w=new A,b=new A,S=new A;for(let _=0;_<t.length;_+=3)f(t[_+0],w),f(t[_+1],b),f(t[_+2],S),l(w,b,S,y)}function l(y,w,b,S){let _=S+1,M=[];for(let x=0;x<=_;x++){M[x]=[];let T=y.clone().lerp(b,x/_),E=w.clone().lerp(b,x/_),C=_-x;for(let P=0;P<=C;P++)P===0&&x===_?M[x][P]=T:M[x][P]=T.clone().lerp(E,P/C)}for(let x=0;x<_;x++)for(let T=0;T<2*(_-x)-1;T++){let E=Math.floor(T/2);T%2===0?(d(M[x][E+1]),d(M[x+1][E]),d(M[x][E])):(d(M[x][E+1]),d(M[x+1][E+1]),d(M[x+1][E]))}}function u(y){let w=new A;for(let b=0;b<s.length;b+=3)w.x=s[b+0],w.y=s[b+1],w.z=s[b+2],w.normalize().multiplyScalar(y),s[b+0]=w.x,s[b+1]=w.y,s[b+2]=w.z}function c(){let y=new A;for(let w=0;w<s.length;w+=3){y.x=s[w+0],y.y=s[w+1],y.z=s[w+2];let b=g(y)/2/Math.PI+.5,S=v(y)/Math.PI+.5;o.push(b,1-S)}m(),h()}function h(){for(let y=0;y<o.length;y+=6){let w=o[y+0],b=o[y+2],S=o[y+4],_=Math.max(w,b,S),M=Math.min(w,b,S);_>.9&&M<.1&&(w<.2&&(o[y+0]+=1),b<.2&&(o[y+2]+=1),S<.2&&(o[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,w){let b=y*3;w.x=e[b+0],w.y=e[b+1],w.z=e[b+2]}function m(){let y=new A,w=new A,b=new A,S=new A,_=new B,M=new B,x=new B;for(let T=0,E=0;T<s.length;T+=9,E+=6){y.set(s[T+0],s[T+1],s[T+2]),w.set(s[T+3],s[T+4],s[T+5]),b.set(s[T+6],s[T+7],s[T+8]),_.set(o[E+0],o[E+1]),M.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),S.copy(y).add(w).add(b).divideScalar(3);let C=g(S);p(_,E+0,y,C),p(M,E+2,w,C),p(x,E+4,b,C)}}function p(y,w,b,S){S<0&&y.x===1&&(o[w]=y.x-1),b.x===0&&b.z===0&&(o[w]=S/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new tl(e.vertices,e.indices,e.radius,e.details)}},nl=class extends tl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n,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,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[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];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nl(e.radius,e.detail)}};var ds=class extends Vo{constructor(e){super(e),this.uuid=Mi(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new Vo().fromJSON(i))}return this}},PO={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=Bw(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(n&&(s=RO(r,e,s,t)),r.length>80*t){a=u=r[0],l=c=r[1];for(let m=t;m<i;m+=t)h=r[m],d=r[m+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?1/f:0}return Eu(s,o,t,a,l,f),o}};function Bw(r,e,t,n,i){let s,o;if(i===jO(r,e,t,n)>0)for(s=e;s<t;s+=n)o=lw(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=lw(s,r[s],r[s+1],o);return o&&mf(o,o.next)&&(Pu(o),o=o.next),o}function Hs(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(mf(t,t.next)||Wt(t.prev,t,t.next)===0)){if(Pu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Eu(r,e,t,n,i,s,o){if(!r)return;!o&&s&&GO(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?IO(r,n,i,s):DO(r)){e.push(l.i/t),e.push(r.i/t),e.push(u.i/t),Pu(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=LO(Hs(r),e,t),Eu(r,e,t,n,i,s,2)):o===2&&OO(r,e,t,n,i,s):Eu(Hs(r),e,t,n,i,s,1);break}}}function DO(r){let e=r.prev,t=r,n=r.next;if(Wt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if(ja(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Wt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function IO(r,e,t,n){let i=r.prev,s=r,o=r.next;if(Wt(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,u=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,c=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,h=gy(a,l,e,t,n),d=gy(u,c,e,t,n),f=r.prevZ,m=r.nextZ;for(;f&&f.z>=h&&m&&m.z<=d;){if(f!==r.prev&&f!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Wt(f.prev,f,f.next)>=0||(f=f.prevZ,m!==r.prev&&m!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Wt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=h;){if(f!==r.prev&&f!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Wt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=d;){if(m!==r.prev&&m!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Wt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function LO(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!mf(i,s)&&Fw(i,n,n.next,s)&&Cu(i,s)&&Cu(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Pu(n),Pu(n.next),n=r=s),n=n.next}while(n!==r);return Hs(n)}function OO(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&VO(o,a)){let l=Uw(o,a);o=Hs(o,o.next),l=Hs(l,l.next),Eu(o,e,t,n,i,s),Eu(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function RO(r,e,t,n){let i=[],s,o,a,l,u;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,u=Bw(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(kO(u));for(i.sort(NO),s=0;s<i.length;s++)BO(i[s],t),t=Hs(t,t.next);return t}function NO(r,e){return r.x-e.x}function BO(r,e){if(e=FO(r,e),e){let t=Uw(e,r);Hs(e,e.next),Hs(t,t.next)}}function FO(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;let a=o,l=o.x,u=o.y,c=1/0,h;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&ja(i<u?n:s,i,l,u,i<u?s:n,i,t.x,t.y)&&(h=Math.abs(i-t.y)/(n-t.x),Cu(t,r)&&(h<c||h===c&&(t.x>o.x||t.x===o.x&&UO(o,t)))&&(o=t,c=h)),t=t.next;while(t!==a);return o}function UO(r,e){return Wt(r.prev,r,e.prev)<0&&Wt(e.next,r,r.next)<0}function GO(r,e,t,n){let i=r;do i.z===null&&(i.z=gy(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,zO(i)}function zO(r){let e,t,n,i,s,o,a,l,u=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<u&&(a++,n=n.nextZ,!!n);e++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,u*=2}while(o>1);return r}function gy(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function kO(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function ja(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function VO(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!HO(r,e)&&(Cu(r,e)&&Cu(e,r)&&WO(r,e)&&(Wt(r.prev,r,e.prev)||Wt(r,e.prev,e))||mf(r,e)&&Wt(r.prev,r,r.next)>0&&Wt(e.prev,e,e.next)>0)}function Wt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function mf(r,e){return r.x===e.x&&r.y===e.y}function Fw(r,e,t,n){let i=zd(Wt(r,e,t)),s=zd(Wt(r,e,n)),o=zd(Wt(t,n,r)),a=zd(Wt(t,n,e));return!!(i!==s&&o!==a||i===0&&Gd(r,t,e)||s===0&&Gd(r,n,e)||o===0&&Gd(t,r,n)||a===0&&Gd(t,e,n))}function Gd(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function zd(r){return r>0?1:r<0?-1:0}function HO(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Fw(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Cu(r,e){return Wt(r.prev,r,r.next)<0?Wt(r,e,r.next)>=0&&Wt(r,r.prev,e)>=0:Wt(r,e,r.prev)<0||Wt(r,r.next,e)<0}function WO(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Uw(r,e){let t=new yy(r.i,r.x,r.y),n=new yy(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function lw(r,e,t,n){let i=new yy(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Pu(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function yy(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function jO(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var rl=class{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return rl.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];cw(e),uw(n,e);let o=e.length;t.forEach(cw);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,uw(n,t[l]);let a=PO.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function cw(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function uw(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var il=class extends tl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,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];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new il(e.radius,e.detail)}};var Wo=class extends De{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new A,d=new A,f=[],m=[],p=[],g=[];for(let v=0;v<=n;v++){let y=[],w=v/n,b=0;v==0&&o==0?b=.5/t:v==n&&l==Math.PI&&(b=-.5/t);for(let S=0;S<=t;S++){let _=S/t;h.x=-e*Math.cos(i+_*s)*Math.sin(o+w*a),h.y=e*Math.cos(o+w*a),h.z=e*Math.sin(i+_*s)*Math.sin(o+w*a),m.push(h.x,h.y,h.z),d.copy(h).normalize(),p.push(d.x,d.y,d.z),g.push(_+b,1-w),y.push(u++)}c.push(y)}for(let v=0;v<n;v++)for(let y=0;y<t;y++){let w=c[v][y+1],b=c[v][y],S=c[v+1][y],_=c[v+1][y+1];(v!==0||o>0)&&f.push(w,b,_),(v!==n-1||l<Math.PI)&&f.push(b,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(e){return new Wo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var sl=class extends De{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],h=new A,d=new A,f=new A,m=new A,p=new A,g=new A,v=new A;for(let w=0;w<=n;++w){let b=w/n*s*Math.PI*2;y(b,s,o,e,f),y(b+.01,s,o,e,m),g.subVectors(m,f),v.addVectors(m,f),p.crossVectors(g,v),v.crossVectors(p,g),p.normalize(),v.normalize();for(let S=0;S<=i;++S){let _=S/i*Math.PI*2,M=-t*Math.cos(_),x=t*Math.sin(_);h.x=f.x+(M*v.x+x*p.x),h.y=f.y+(M*v.y+x*p.y),h.z=f.z+(M*v.z+x*p.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(w/n),c.push(S/i)}}for(let w=1;w<=n;w++)for(let b=1;b<=i;b++){let S=(i+1)*(w-1)+(b-1),_=(i+1)*w+(b-1),M=(i+1)*w+b,x=(i+1)*(w-1)+b;a.push(S,_,x),a.push(_,M,x)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(c,2));function y(w,b,S,_,M){let x=Math.cos(w),T=Math.sin(w),E=S/b*w,C=Math.cos(E);M.x=_*(2+C)*.5*x,M.y=_*(2+C)*T*.5,M.z=_*Math.sin(E)*.5}}static fromJSON(e){return new sl(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var fn={arraySlice:function(r,e,t){return fn.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let u=s.tracks[l],c=u.getValueSize(),h=[],d=[];for(let f=0;f<u.times.length;++f){let m=u.times[f]*i;if(!(m<t||m>=n)){h.push(u.times[f]);for(let p=0;p<c;++p)d.push(u.values[f*c+p])}}h.length!==0&&(u.times=fn.convertArray(h,u.times.constructor),u.values=fn.convertArray(d,u.values.constructor),o.push(u))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);let i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let u=r.tracks.find(function(v){return v.name===a.name&&v.ValueTypeName===l});if(u===void 0)continue;let c=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);let d=0,f=u.getValueSize();u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let m=a.times.length-1,p;if(s<=a.times[0]){let v=c,y=h-c;p=fn.arraySlice(a.values,v,y)}else if(s>=a.times[m]){let v=m*h+c,y=v+h-c;p=fn.arraySlice(a.values,v,y)}else{let v=a.createInterpolant(),y=c,w=h-c;v.evaluate(s),p=fn.arraySlice(v.resultBuffer,y,w)}l==="quaternion"&&new nt().fromArray(p).normalize().conjugate().toArray(p);let g=u.times.length;for(let v=0;v<g;++v){let y=v*f+d;if(l==="quaternion")nt.multiplyQuaternionsFlat(u.values,y,p,0,u.values,y);else{let w=f-d*2;for(let b=0;b<w;++b)u.values[y+b]-=p[b]}}}return r.blendMode=bP,r}},ol=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{r:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},vy=class extends ol{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xb,endingEnd:xb}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case bb:s=e,a=2*t-n;break;case wb:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case bb:o=e,l=2*n-t;break;case wb:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let u=(n-t)*.5,c=this.valueSize;this._weightPrev=u/(t-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),p=m*m,g=p*m,v=-d*g+2*d*p-d*m,y=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*m+1,w=(-1-f)*g+(1.5+f)*p+.5*m,b=f*g-f*p;for(let S=0;S!==a;++S)s[S]=v*o[c+S]+y*o[u+S]+w*o[l+S]+b*o[h+S];return s}},xy=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=(n-t)/(i-t),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},by=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},li=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fn.convertArray(t,this.TimeBufferType),this.values=fn.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:fn.convertArray(e.times,Array),values:fn.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new by(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case jd:t=this.InterpolantFactoryMethodDiscrete;break;case qd:t=this.InterpolantFactoryMethodLinear;break;case fg:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return jd;case this.InterpolantFactoryMethodLinear:return qd;case this.InterpolantFactoryMethodSmooth:return fg}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=fn.arraySlice(n,s,o),this.values=fn.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&fn.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),e=!1;break}}return e}optimize(){let e=fn.arraySlice(this.times),t=fn.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===fg,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=e[a],c=e[a+1];if(u!==c&&(a!==1||u!==e[0]))if(i)l=!0;else{let h=a*n,d=h-n,f=h+n;for(let m=0;m!==n;++m){let p=t[h+m];if(p!==t[d+m]||p!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)t[l+u]=t[a+u];++o}return o!==e.length?(this.times=fn.arraySlice(e,0,o),this.values=fn.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=fn.arraySlice(this.times,0),t=fn.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};li.prototype.TimeBufferType=Float32Array;li.prototype.ValueBufferType=Float32Array;li.prototype.DefaultInterpolation=qd;var jo=class extends li{};jo.prototype.ValueTypeName="bool";jo.prototype.ValueBufferType=Array;jo.prototype.DefaultInterpolation=jd;jo.prototype.InterpolantFactoryMethodLinear=void 0;jo.prototype.InterpolantFactoryMethodSmooth=void 0;var wy=class extends li{};wy.prototype.ValueTypeName="color";var Sy=class extends li{};Sy.prototype.ValueTypeName="number";var Ay=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),u=e*a;for(let c=u+a;u!==c;u+=4)nt.slerpFlat(s,0,o,u-a,o,u,l);return s}},Du=class extends li{InterpolantFactoryMethodLinear(e){return new Ay(this.times,this.values,this.getValueSize(),e)}};Du.prototype.ValueTypeName="quaternion";Du.prototype.DefaultInterpolation=qd;Du.prototype.InterpolantFactoryMethodSmooth=void 0;var qo=class extends li{};qo.prototype.ValueTypeName="string";qo.prototype.ValueBufferType=Array;qo.prototype.DefaultInterpolation=jd;qo.prototype.InterpolantFactoryMethodLinear=void 0;qo.prototype.InterpolantFactoryMethodSmooth=void 0;var _y=class extends li{};_y.prototype.ValueTypeName="vector";var hw={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Iu=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],m=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return m}return null}}},qO=new Iu,al=class{constructor(e){this.manager=e!==void 0?e:qO,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},as={},ll=class extends al{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=hw.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(as[e]!==void 0){as[e].push({onLoad:t,onProgress:n,onError:i});return}as[e]=[],as[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=as[e],h=u.body.getReader(),d=u.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0,p=0,g=new ReadableStream({start(v){y();function y(){h.read().then(({done:w,value:b})=>{if(w)v.close();else{p+=b.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let x=c[_];x.onProgress&&x.onProgress(S)}v.enqueue(b),y()}})}}});return new Response(g)}else throw Error(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(m=>f.decode(m))}}}).then(u=>{hw.add(e,u);let c=as[e];delete as[e];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=as[e];if(c===void 0)throw this.manager.itemError(e),u;delete as[e];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var cl=class extends ht{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},Xo=class extends cl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.groundColor=new Le(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},dw=new be,fw=new A,pw=new A,Lu=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _u,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new He(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;fw.setFromMatrixPosition(e.matrixWorld),t.position.copy(fw),pw.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(pw),t.updateMatrixWorld(),dw.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dw),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Ty=class extends Lu{constructor(){super(new nn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=wu*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},nf=class extends cl{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Ty}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},mw=new be,du=new A,Wg=new A,My=class extends Lu{constructor(){super(new nn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new He(2,1,1,1),new He(0,1,1,1),new He(3,1,1,1),new He(1,1,1,1),new He(3,0,1,1),new He(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),du.setFromMatrixPosition(e.matrixWorld),n.position.copy(du),Wg.copy(n.position),Wg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Wg),n.updateMatrixWorld(),i.makeTranslation(-du.x,-du.y,-du.z),mw.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mw)}},rf=class extends cl{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new My}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Ey=class extends Lu{constructor(){super(new Za(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},sf=class extends cl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.target=new ht,this.shadow=new Ey}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var Cy=class extends De{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},ul=class extends al{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new ll(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(f,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],v=s(f,g.buffer),y=gd(g.type,v),w=new ef(y,g.stride);return w.uuid=g.uuid,t[m]=w,w}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],v=new Uint32Array(g).buffer;return n[m]=v,v}let o=e.isInstancedBufferGeometry?new Cy:new De,a=e.data.index;if(a!==void 0){let f=gd(a.type,a.array);o.setIndex(new Ge(f,1))}let l=e.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new Go(g,m.itemSize,m.offset,m.normalized)}else{let g=gd(m.type,m.array),v=m.isInstancedBufferAttribute?tf:Ge;p=new v(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let u=e.data.morphAttributes;if(u)for(let f in u){let m=u[f],p=[];for(let g=0,v=m.length;g<v;g++){let y=m[g],w;if(y.isInterleavedBufferAttribute){let b=i(e.data,y.data);w=new Go(b,y.itemSize,y.offset,y.normalized)}else{let b=gd(y.type,y.array);w=new Ge(b,y.itemSize,y.normalized)}y.name!==void 0&&(w.name=y.name),p.push(w)}o.morphAttributes[f]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let f=0,m=h.length;f!==m;++f){let p=h[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new En(f,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var of=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gw(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=gw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function gw(){return(typeof performance>"u"?Date:performance).now()}var Fy="\\[\\]\\.:\\/",XO=new RegExp("["+Fy+"]","g"),Uy="[^"+Fy+"]",YO="[^"+Fy.replace("\\.","")+"]",QO=/((?:WC+[\/:])*)/.source.replace("WC",Uy),ZO=/(WCOD+)?/.source.replace("WCOD",YO),KO=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Uy),JO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Uy),$O=new RegExp("^"+QO+ZO+KO+JO+"$"),eR=["material","materials","bones"],Py=class{constructor(e,t,n){let i=n||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Tt=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,n):new Tt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(XO,"")}static parseTrackName(e){let t=$O.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);eR.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===u){u=c;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(u!==void 0){if(e[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[u]}}let o=e[i];if(o===void 0){let u=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Tt.Composite=Py;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Se=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Se(this.value.clone===void 0?this.value:this.value.clone())}};var hl=class{constructor(e,t,n=0,i=1/0){this.ray=new oi(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Su,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Dy(e,this,n,t),n.sort(yw),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Dy(e[i],this,n,t);return n.sort(yw),n}};function yw(r,e){return r.distance-e.distance}function Dy(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Dy(i[s],e,t,!0)}}var Ou=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(pn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var vw=new B,af=class{constructor(e=new B(1/0,1/0),t=new B(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=vw.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return vw.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},xw=new A,kd=new A,gn=class{constructor(e=new A,t=new A){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){xw.subVectors(e,this.start),kd.subVectors(this.end,this.start);let n=kd.dot(kd),s=kd.dot(xw)/n;return t&&(s=pn(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},bw=new A,lf=class extends ht{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new De,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(i,3));let s=new zr({fog:!1,toneMapped:!1});this.cone=new Vs(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),bw.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(bw),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var cf=class extends rn{constructor(e,t,n){let i=new Wo(t,4,2),s=new Au({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var ww=new A,Vd=new A,Sw=new A,uf=class extends ht{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,t===void 0&&(t=1);let i=new De;i.setAttribute("position",new Ae([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zr({fog:!1,toneMapped:!1});this.lightPlane=new zo(i,s),this.add(this.lightPlane),i=new De,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new zo(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ww.setFromMatrixPosition(this.light.matrixWorld),Vd.setFromMatrixPosition(this.light.target.matrixWorld),Sw.subVectors(Vd,ww),this.lightPlane.lookAt(Vd),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Vd),this.targetLine.scale.z=Sw.length()}},Hd=new A,Xt=new ai,Vr=class extends Vs{constructor(e){let t=new De,n=new zr({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Ae(i,3)),t.setAttribute("color",new Ae(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Le(16755200),c=new Le(16711680),h=new Le(43775),d=new Le(16777215),f=new Le(3355443);this.setColors(u,c,h,d,f)}setColors(e,t,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,n=1,i=1;Xt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),tn("c",t,e,Xt,0,0,-1),tn("t",t,e,Xt,0,0,1),tn("n1",t,e,Xt,-n,-i,-1),tn("n2",t,e,Xt,n,-i,-1),tn("n3",t,e,Xt,-n,i,-1),tn("n4",t,e,Xt,n,i,-1),tn("f1",t,e,Xt,-n,-i,1),tn("f2",t,e,Xt,n,-i,1),tn("f3",t,e,Xt,-n,i,1),tn("f4",t,e,Xt,n,i,1),tn("u1",t,e,Xt,n*.7,i*1.1,-1),tn("u2",t,e,Xt,-n*.7,i*1.1,-1),tn("u3",t,e,Xt,0,i*2,-1),tn("cf1",t,e,Xt,-n,0,1),tn("cf2",t,e,Xt,n,0,1),tn("cf3",t,e,Xt,0,-i,1),tn("cf4",t,e,Xt,0,i,1),tn("cn1",t,e,Xt,-n,0,-1),tn("cn2",t,e,Xt,n,0,-1),tn("cn3",t,e,Xt,0,-i,-1),tn("cn4",t,e,Xt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function tn(r,e,t,n,i,s,o){Hd.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Hd.x,Hd.y,Hd.z)}}var Yo=class extends Vs{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new De;s.setIndex(new Ge(n,1)),s.setAttribute("position",new Ae(i,3)),super(s,new zr({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}};var hf=class extends Vs{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new De;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(n,3));let s=new zr({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Le,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var{floatView:TH,uint32View:MH,baseTable:EH,shiftTable:CH,mantissaTable:PH,exponentTable:DH,offsetTable:IH}=tR();function tR(){let r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):u<-14?(n[l]=1024>>-u-14,n[l|256]=1024>>-u-14|32768,i[l]=-u-1,i[l|256]=-u-1):u<=15?(n[l]=u+15<<10,n[l|256]=u+15<<10|32768,i[l]=13,i[l|256]=13):u<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}var df=class extends dt{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Qo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Qo);var ml=".",Ru=Symbol("target"),Gy=Symbol("unsubscribe");function Nu(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function Gw(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Pr=Array.isArray;function Zo(r){return typeof r=="symbol"}var nR={after:(r,e)=>Pr(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>Pr(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=ml),Zo(e)?r+e.toString():r+e):r,initial:r=>{if(Pr(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(ml);return e===-1?"":r.slice(0,e)},last:r=>{if(Pr(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(ml);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(Pr(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(ml);if(n===-1)e(r);else for(;t<r.length;)n===-1&&(n=r.length),e(r.slice(t,n)),t=n+1,n=r.indexOf(ml,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},sr=nR;function zy(r){return typeof r=="object"&&typeof r.next=="function"}function ky(r,e,t,n,i){let s=r.next;if(e.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],n),o.value[1]=i(o.value[1],e,o.value[0],n)),o};else if(e.name==="values"){let o=t[Ru].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,n)),o};return r}function gf(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&Zo(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Bu=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),n=t.get(e);return n===void 0&&(n={},t.set(e,n)),n}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let n=this._getProperties(e),i=n[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),n[t]=i),i}getProxy(e,t,n,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,n):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,sr.get(t,this.getPath(e)))}defineProperty(e,t,n){return Reflect.defineProperty(e,t,n)?(this.isUnsubscribed||(this._getProperties(e)[t]=n),!0):!1}setProperty(e,t,n,i,s){if(!this._equals(s,n)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,n,i):Reflect.set(e,t,n)}return!0}deleteProperty(e,t,n){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(e,t,n){let i=this._getOwnPropertyDescriptor(t,n);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function gl(r){return toString.call(r)==="[object Object]"}function yl(){return!0}function Ws(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var yf=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var rR=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Vy={push:yl,pop:yl,shift:yl,unshift:yl,copyWithin:Ws,reverse:Ws,sort:Ws,splice:Ws,flat:Ws,fill:Ws},zw=new Set([...yf,...rR,...Object.keys(Vy)]);function vl(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var Hy=["keys","values","entries"],Wy=new Set(["has","toString"]),jy={add:vl,clear:vl,delete:vl,forEach:vl},kw=new Set([...Wy,...Object.keys(jy),...Hy]);function xl(r,e){if(r.size!==e.size)return!0;let t;for(let[n,i]of r)if(t=e.get(n),t!==i||t===void 0&&!e.has(n))return!0;return!1}var iR=new Set([...Wy,"get"]),qy={set:xl,clear:xl,delete:xl,forEach:xl},Vw=new Set([...iR,...Object.keys(qy),...Hy]);var Pn=class{constructor(e,t,n,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return yf.has(e)}_shallowClone(e){let t=e;if(gl(e))t={...e};else if(Pr(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(n=>this._shallowClone(n)));else if(e instanceof Map){t=new Map;for(let[n,i]of e.entries())t.set(n,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,n,i){return e?(Pr(i)?this._onIsChanged=Vy[t]:i instanceof Set?this._onIsChanged=jy[t]:i instanceof Map&&(this._onIsChanged=qy[t]),i):n}update(e,t,n){let i=sr.after(e,this._path);if(t!=="length"){let s=this.clone;sr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:n}),s&&s[t]&&(s[t]=n)}this._isChanged=!0}undo(e){let t;for(let n=this._changes.length-1;n!==-1;n--)t=this._changes[n],sr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var bl=class extends Pn{static isHandledMethod(e){return zw.has(e)}};var Fu=class extends Pn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var wl=class extends Pn{static isHandledMethod(e){return kw.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var Sl=class extends Pn{static isHandledMethod(e){return Vw.has(e)}undo(e){for(let[t,n]of this.clone.entries())e.set(t,n);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Uu=class extends Pn{constructor(e,t,n,i){super(void 0,t,n,i),this._arg1=n[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Gu=class extends Pn{constructor(e,t,n,i){super(void 0,t,n,i),this._weakKey=n[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var ui=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gl(e)||Pr(e)||Nu(e)}static isHandledMethod(e,t){return gl(e)?Pn.isHandledMethod(t):Pr(e)?bl.isHandledMethod(t):e instanceof Set?wl.isHandledMethod(t):e instanceof Map?Sl.isHandledMethod(t):Nu(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=Pn;Pr(e)?i=bl:e instanceof Date?i=Fu:e instanceof Set?i=wl:e instanceof Map?i=Sl:e instanceof WeakSet?i=Uu:e instanceof WeakMap&&(i=Gu),this._stack.push(new i(e,t,n,this._hasOnValidate))}update(e,t,n){this._stack[this._stack.length-1].update(e,t,n)}preferredThisArg(e,t,n){let{name:i}=e,s=ui.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,n)}isChanged(e,t,n){return this._stack[this._stack.length-1].isChanged(e,t,n)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var sR={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Xy=(r,e,t={})=>{t={...sR,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Bu(i),u=typeof t.onValidate=="function",c=new ui(u),h=(y,w,b,S,_)=>!u||c.isCloning||t.onValidate(sr.concat(l.getPath(y),w),b,S,_)===!0,d=(y,w,b,S)=>{!gf(l,t,w)&&!(o&&l.isDetached(y,r))&&f(l.getPath(y),w,b,S)},f=(y,w,b,S,_)=>{c.isCloning?c.update(y,w,S):e(sr.concat(y,w),b,S,_)},m=y=>y&&(y[n]||y),p=(y,w,b,S)=>Gw(y)||b==="constructor"||s&&!ui.isHandledMethod(w,b)||gf(l,t,b)||l.isGetInvariant(w,b)||o&&l.isDetached(w,r)?y:(S===void 0&&(S=l.getPath(w)),l.getProxy(y,sr.concat(S,b),g,n)),g={get(y,w,b){if(Zo(w)){if(w===n||w===Ru)return y;if(w===Gy&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let S=Nu(y)?Reflect.get(y,w):Reflect.get(y,w,b);return p(S,y,w)},set(y,w,b,S){b=m(b);let _=y[n]||y,M=_[w];if(i(M,b)&&w in y)return!0;let x=h(y,w,b,M);return x&&l.setProperty(_,w,b,S,M)?(d(y,w,y[w],M),!0):!x},defineProperty(y,w,b){if(!l.isSameDescriptor(b,y,w)){let S=y[w];h(y,w,b.value,S)&&l.defineProperty(y,w,b,S)&&d(y,w,b.value,S)}return!0},deleteProperty(y,w){if(!Reflect.has(y,w))return!0;let b=Reflect.get(y,w),S=h(y,w,void 0,b);return S&&l.deleteProperty(y,w,b)?(d(y,w,void 0,b),!0):!S},apply(y,w,b){let S=w[n]||w;if(l.isUnsubscribed)return Reflect.apply(y,S,b);if((a===!1||a!==!0&&!a.includes(y.name))&&ui.isHandledType(S)){let _=sr.initial(l.getPath(y)),M=ui.isHandledMethod(S,y.name);c.start(S,_,b);let x=Reflect.apply(y,c.preferredThisArg(y,w,S),M?b.map(C=>m(C)):b),T=c.isChanged(S,i),E=c.stop();if(ui.isHandledType(x)&&M&&(w instanceof Map&&y.name==="get"&&(_=sr.concat(_,b[0])),x=l.getProxy(x,_,g)),T){let C={name:y.name,args:b,result:x},P=c.isCloning?sr.initial(_):_,O=c.isCloning?sr.last(_):"";h(sr.get(r,P),O,S,E,C)?f(P,O,S,E,C):c.undo(S)}return(w instanceof Map||w instanceof Set)&&zy(x)?ky(x,y,w,_,p):x}return Reflect.apply(y,w,b)}},v=l.getProxy(r,t.pathAsArray?[]:"",g);return e=e.bind(v),u&&(t.onValidate=t.onValidate.bind(v)),v};Xy.target=r=>r&&r[Ru]||r;Xy.unsubscribe=r=>r[Gy]||r;var Yy=Xy;var oR=typeof global=="object"&&global&&global.Object===Object&&global,vf=oR;var aR=typeof self=="object"&&self&&self.Object===Object&&self,lR=vf||aR||Function("return this")(),Zt=lR;var cR=Zt.Symbol,or=cR;var Hw=Object.prototype,uR=Hw.hasOwnProperty,hR=Hw.toString,zu=or?or.toStringTag:void 0;function dR(r){var e=uR.call(r,zu),t=r[zu];try{r[zu]=void 0;var n=!0}catch{}var i=hR.call(r);return n&&(e?r[zu]=t:delete r[zu]),i}var Ww=dR;var fR=Object.prototype,pR=fR.toString;function mR(r){return pR.call(r)}var jw=mR;var gR="[object Null]",yR="[object Undefined]",qw=or?or.toStringTag:void 0;function vR(r){return r==null?r===void 0?yR:gR:qw&&qw in Object(r)?Ww(r):jw(r)}var Dr=vR;function xR(r){return r!=null&&typeof r=="object"}var qn=xR;var bR="[object Symbol]";function wR(r){return typeof r=="symbol"||qn(r)&&Dr(r)==bR}var js=wR;function SR(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var xf=SR;var AR=Array.isArray,yn=AR;var _R=1/0,Xw=or?or.prototype:void 0,Yw=Xw?Xw.toString:void 0;function Qw(r){if(typeof r=="string")return r;if(yn(r))return xf(r,Qw)+"";if(js(r))return Yw?Yw.call(r):"";var e=r+"";return e=="0"&&1/r==-_R?"-0":e}var Zw=Qw;var TR=/\s/;function MR(r){for(var e=r.length;e--&&TR.test(r.charAt(e)););return e}var Kw=MR;var ER=/^\s+/;function CR(r){return r&&r.slice(0,Kw(r)+1).replace(ER,"")}var Jw=CR;function PR(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Ht=PR;var $w=0/0,DR=/^[-+]0x[0-9a-f]+$/i,IR=/^0b[01]+$/i,LR=/^0o[0-7]+$/i,OR=parseInt;function RR(r){if(typeof r=="number")return r;if(js(r))return $w;if(Ht(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Ht(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=Jw(r);var t=IR.test(r);return t||LR.test(r)?OR(r.slice(2),t?2:8):DR.test(r)?$w:+r}var Qy=RR;function NR(r){return r}var bf=NR;var BR="[object AsyncFunction]",FR="[object Function]",UR="[object GeneratorFunction]",GR="[object Proxy]";function zR(r){if(!Ht(r))return!1;var e=Dr(r);return e==FR||e==UR||e==BR||e==GR}var Al=zR;var kR=Zt["__core-js_shared__"],wf=kR;var eS=function(){var r=/[^.]+$/.exec(wf&&wf.keys&&wf.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function VR(r){return!!eS&&eS in r}var tS=VR;var HR=Function.prototype,WR=HR.toString;function jR(r){if(r!=null){try{return WR.call(r)}catch{}try{return r+""}catch{}}return""}var fs=jR;var qR=/[\\^$.*+?()[\]{}|]/g,XR=/^\[object .+?Constructor\]$/,YR=Function.prototype,QR=Object.prototype,ZR=YR.toString,KR=QR.hasOwnProperty,JR=RegExp("^"+ZR.call(KR).replace(qR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $R(r){if(!Ht(r)||tS(r))return!1;var e=Al(r)?JR:XR;return e.test(fs(r))}var nS=$R;function e3(r,e){return r?.[e]}var rS=e3;function t3(r,e){var t=rS(r,e);return nS(t)?t:void 0}var hr=t3;var n3=hr(Zt,"WeakMap"),Sf=n3;var iS=Object.create,r3=function(){function r(){}return function(e){if(!Ht(e))return{};if(iS)return iS(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),sS=r3;function i3(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var oS=i3;function s3(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var Af=s3;var o3=800,a3=16,l3=Date.now;function c3(r){var e=0,t=0;return function(){var n=l3(),i=a3-(n-t);if(t=n,i>0){if(++e>=o3)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var aS=c3;function u3(r){return function(){return r}}var lS=u3;var h3=function(){try{var r=hr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),_l=h3;var d3=_l?function(r,e){return _l(r,"toString",{configurable:!0,enumerable:!1,value:lS(e),writable:!0})}:bf,cS=d3;var f3=aS(cS),_f=f3;function p3(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var uS=p3;var m3=9007199254740991,g3=/^(?:0|[1-9]\d*)$/;function y3(r,e){var t=typeof r;return e=e??m3,!!e&&(t=="number"||t!="symbol"&&g3.test(r))&&r>-1&&r%1==0&&r<e}var qs=y3;function v3(r,e,t){e=="__proto__"&&_l?_l(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Tl=v3;function x3(r,e){return r===e||r!==r&&e!==e}var Xs=x3;var b3=Object.prototype,w3=b3.hasOwnProperty;function S3(r,e,t){var n=r[e];(!(w3.call(r,e)&&Xs(n,t))||t===void 0&&!(e in r))&&Tl(r,e,t)}var Ml=S3;function A3(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(t[a],r[a],a,t,r):void 0;l===void 0&&(l=r[a]),i?Tl(t,a,l):Ml(t,a,l)}return t}var Hr=A3;var hS=Math.max;function _3(r,e,t){return e=hS(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=hS(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=t(o),oS(r,this,a)}}var Tf=_3;function T3(r,e){return _f(Tf(r,e,bf),r+"")}var dS=T3;var M3=9007199254740991;function E3(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=M3}var El=E3;function C3(r){return r!=null&&El(r.length)&&!Al(r)}var Ys=C3;function P3(r,e,t){if(!Ht(t))return!1;var n=typeof e;return(n=="number"?Ys(t)&&qs(e,t.length):n=="string"&&e in t)?Xs(t[e],r):!1}var fS=P3;function D3(r){return dS(function(e,t){var n=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=r.length>3&&typeof s=="function"?(i--,s):void 0,o&&fS(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++n<i;){var a=t[n];a&&r(e,a,n,s)}return e})}var pS=D3;var I3=Object.prototype;function L3(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||I3;return r===t}var Cl=L3;function O3(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var mS=O3;var R3="[object Arguments]";function N3(r){return qn(r)&&Dr(r)==R3}var Zy=N3;var gS=Object.prototype,B3=gS.hasOwnProperty,F3=gS.propertyIsEnumerable,U3=Zy(function(){return arguments}())?Zy:function(r){return qn(r)&&B3.call(r,"callee")&&!F3.call(r,"callee")},ps=U3;function G3(){return!1}var yS=G3;var bS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vS=bS&&typeof module=="object"&&module&&!module.nodeType&&module,z3=vS&&vS.exports===bS,xS=z3?Zt.Buffer:void 0,k3=xS?xS.isBuffer:void 0,V3=k3||yS,Pl=V3;var H3="[object Arguments]",W3="[object Array]",j3="[object Boolean]",q3="[object Date]",X3="[object Error]",Y3="[object Function]",Q3="[object Map]",Z3="[object Number]",K3="[object Object]",J3="[object RegExp]",$3="[object Set]",eN="[object String]",tN="[object WeakMap]",nN="[object ArrayBuffer]",rN="[object DataView]",iN="[object Float32Array]",sN="[object Float64Array]",oN="[object Int8Array]",aN="[object Int16Array]",lN="[object Int32Array]",cN="[object Uint8Array]",uN="[object Uint8ClampedArray]",hN="[object Uint16Array]",dN="[object Uint32Array]",Gt={};Gt[iN]=Gt[sN]=Gt[oN]=Gt[aN]=Gt[lN]=Gt[cN]=Gt[uN]=Gt[hN]=Gt[dN]=!0;Gt[H3]=Gt[W3]=Gt[nN]=Gt[j3]=Gt[rN]=Gt[q3]=Gt[X3]=Gt[Y3]=Gt[Q3]=Gt[Z3]=Gt[K3]=Gt[J3]=Gt[$3]=Gt[eN]=Gt[tN]=!1;function fN(r){return qn(r)&&El(r.length)&&!!Gt[Dr(r)]}var wS=fN;function pN(r){return function(e){return r(e)}}var Dl=pN;var SS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ku=SS&&typeof module=="object"&&module&&!module.nodeType&&module,mN=ku&&ku.exports===SS,Ky=mN&&vf.process,gN=function(){try{var r=ku&&ku.require&&ku.require("util").types;return r||Ky&&Ky.binding&&Ky.binding("util")}catch{}}(),ms=gN;var AS=ms&&ms.isTypedArray,yN=AS?Dl(AS):wS,Mf=yN;var vN=Object.prototype,xN=vN.hasOwnProperty;function bN(r,e){var t=yn(r),n=!t&&ps(r),i=!t&&!n&&Pl(r),s=!t&&!n&&!i&&Mf(r),o=t||n||i||s,a=o?mS(r.length,String):[],l=a.length;for(var u in r)(e||xN.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||qs(u,l)))&&a.push(u);return a}var Ef=bN;function wN(r,e){return function(t){return r(e(t))}}var Cf=wN;var SN=Cf(Object.keys,Object),_S=SN;var AN=Object.prototype,_N=AN.hasOwnProperty;function TN(r){if(!Cl(r))return _S(r);var e=[];for(var t in Object(r))_N.call(r,t)&&t!="constructor"&&e.push(t);return e}var TS=TN;function MN(r){return Ys(r)?Ef(r):TS(r)}var Il=MN;function EN(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var MS=EN;var CN=Object.prototype,PN=CN.hasOwnProperty;function DN(r){if(!Ht(r))return MS(r);var e=Cl(r),t=[];for(var n in r)n=="constructor"&&(e||!PN.call(r,n))||t.push(n);return t}var ES=DN;function IN(r){return Ys(r)?Ef(r,!0):ES(r)}var Ei=IN;var LN=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ON=/^\w*$/;function RN(r,e){if(yn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||js(r)?!0:ON.test(r)||!LN.test(r)||e!=null&&r in Object(e)}var CS=RN;var NN=hr(Object,"create"),gs=NN;function BN(){this.__data__=gs?gs(null):{},this.size=0}var PS=BN;function FN(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var DS=FN;var UN="__lodash_hash_undefined__",GN=Object.prototype,zN=GN.hasOwnProperty;function kN(r){var e=this.__data__;if(gs){var t=e[r];return t===UN?void 0:t}return zN.call(e,r)?e[r]:void 0}var IS=kN;var VN=Object.prototype,HN=VN.hasOwnProperty;function WN(r){var e=this.__data__;return gs?e[r]!==void 0:HN.call(e,r)}var LS=WN;var jN="__lodash_hash_undefined__";function qN(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=gs&&e===void 0?jN:e,this}var OS=qN;function Ll(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ll.prototype.clear=PS;Ll.prototype.delete=DS;Ll.prototype.get=IS;Ll.prototype.has=LS;Ll.prototype.set=OS;var Jy=Ll;function XN(){this.__data__=[],this.size=0}var RS=XN;function YN(r,e){for(var t=r.length;t--;)if(Xs(r[t][0],e))return t;return-1}var Qs=YN;var QN=Array.prototype,ZN=QN.splice;function KN(r){var e=this.__data__,t=Qs(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():ZN.call(e,t,1),--this.size,!0}var NS=KN;function JN(r){var e=this.__data__,t=Qs(e,r);return t<0?void 0:e[t][1]}var BS=JN;function $N(r){return Qs(this.__data__,r)>-1}var FS=$N;function eB(r,e){var t=this.__data__,n=Qs(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var US=eB;function Ol(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ol.prototype.clear=RS;Ol.prototype.delete=NS;Ol.prototype.get=BS;Ol.prototype.has=FS;Ol.prototype.set=US;var Zs=Ol;var tB=hr(Zt,"Map"),Ks=tB;function nB(){this.size=0,this.__data__={hash:new Jy,map:new(Ks||Zs),string:new Jy}}var GS=nB;function rB(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var zS=rB;function iB(r,e){var t=r.__data__;return zS(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Js=iB;function sB(r){var e=Js(this,r).delete(r);return this.size-=e?1:0,e}var kS=sB;function oB(r){return Js(this,r).get(r)}var VS=oB;function aB(r){return Js(this,r).has(r)}var HS=aB;function lB(r,e){var t=Js(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var WS=lB;function Rl(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Rl.prototype.clear=GS;Rl.prototype.delete=kS;Rl.prototype.get=VS;Rl.prototype.has=HS;Rl.prototype.set=WS;var Vu=Rl;var cB="Expected a function";function $y(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(cB);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new($y.Cache||Vu),t}$y.Cache=Vu;var jS=$y;var uB=500;function hB(r){var e=jS(r,function(n){return t.size===uB&&t.clear(),n}),t=e.cache;return e}var qS=hB;var dB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fB=/\\(\\)?/g,pB=qS(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(dB,function(t,n,i,s){e.push(i?s.replace(fB,"$1"):n||t)}),e}),XS=pB;function mB(r){return r==null?"":Zw(r)}var YS=mB;function gB(r,e){return yn(r)?r:CS(r,e)?[r]:XS(YS(r))}var Wr=gB;var yB=1/0;function vB(r){if(typeof r=="string"||js(r))return r;var e=r+"";return e=="0"&&1/r==-yB?"-0":e}var $s=vB;function xB(r,e){e=Wr(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[$s(e[t++])];return t&&t==n?r:void 0}var Pf=xB;function bB(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Nl=bB;var QS=or?or.isConcatSpreadable:void 0;function wB(r){return yn(r)||ps(r)||!!(QS&&r&&r[QS])}var ZS=wB;function KS(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=ZS),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?KS(a,e-1,t,n,i):Nl(i,a):n||(i[i.length]=a)}return i}var JS=KS;function SB(r){var e=r==null?0:r.length;return e?JS(r,1):[]}var $S=SB;function AB(r){return _f(Tf(r,void 0,$S),r+"")}var Df=AB;var _B=Cf(Object.getPrototypeOf,Object),Bl=_B;var TB="[object Object]",MB=Function.prototype,EB=Object.prototype,eA=MB.toString,CB=EB.hasOwnProperty,PB=eA.call(Object);function DB(r){if(!qn(r)||Dr(r)!=TB)return!1;var e=Bl(r);if(e===null)return!0;var t=CB.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&eA.call(t)==PB}var If=DB;function IB(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+e];return s}var tA=IB;function LB(){this.__data__=new Zs,this.size=0}var nA=LB;function OB(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var rA=OB;function RB(r){return this.__data__.get(r)}var iA=RB;function NB(r){return this.__data__.has(r)}var sA=NB;var BB=200;function FB(r,e){var t=this.__data__;if(t instanceof Zs){var n=t.__data__;if(!Ks||n.length<BB-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Vu(n)}return t.set(r,e),this.size=t.size,this}var oA=FB;function Fl(r){var e=this.__data__=new Zs(r);this.size=e.size}Fl.prototype.clear=nA;Fl.prototype.delete=rA;Fl.prototype.get=iA;Fl.prototype.has=sA;Fl.prototype.set=oA;var Lf=Fl;function UB(r,e){return r&&Hr(e,Il(e),r)}var aA=UB;function GB(r,e){return r&&Hr(e,Ei(e),r)}var lA=GB;var dA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,cA=dA&&typeof module=="object"&&module&&!module.nodeType&&module,zB=cA&&cA.exports===dA,uA=zB?Zt.Buffer:void 0,hA=uA?uA.allocUnsafe:void 0;function kB(r,e){if(e)return r.slice();var t=r.length,n=hA?hA(t):new r.constructor(t);return r.copy(n),n}var Of=kB;function VB(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var fA=VB;function HB(){return[]}var Rf=HB;var WB=Object.prototype,jB=WB.propertyIsEnumerable,pA=Object.getOwnPropertySymbols,qB=pA?function(r){return r==null?[]:(r=Object(r),fA(pA(r),function(e){return jB.call(r,e)}))}:Rf,Ul=qB;function XB(r,e){return Hr(r,Ul(r),e)}var mA=XB;var YB=Object.getOwnPropertySymbols,QB=YB?function(r){for(var e=[];r;)Nl(e,Ul(r)),r=Bl(r);return e}:Rf,Nf=QB;function ZB(r,e){return Hr(r,Nf(r),e)}var gA=ZB;function KB(r,e,t){var n=e(r);return yn(r)?n:Nl(n,t(r))}var Bf=KB;function JB(r){return Bf(r,Il,Ul)}var yA=JB;function $B(r){return Bf(r,Ei,Nf)}var Ff=$B;var eF=hr(Zt,"DataView"),Uf=eF;var tF=hr(Zt,"Promise"),Gf=tF;var nF=hr(Zt,"Set"),zf=nF;var vA="[object Map]",rF="[object Object]",xA="[object Promise]",bA="[object Set]",wA="[object WeakMap]",SA="[object DataView]",iF=fs(Uf),sF=fs(Ks),oF=fs(Gf),aF=fs(zf),lF=fs(Sf),Ko=Dr;(Uf&&Ko(new Uf(new ArrayBuffer(1)))!=SA||Ks&&Ko(new Ks)!=vA||Gf&&Ko(Gf.resolve())!=xA||zf&&Ko(new zf)!=bA||Sf&&Ko(new Sf)!=wA)&&(Ko=function(r){var e=Dr(r),t=e==rF?r.constructor:void 0,n=t?fs(t):"";if(n)switch(n){case iF:return SA;case sF:return vA;case oF:return xA;case aF:return bA;case lF:return wA}return e});var Gl=Ko;var cF=Object.prototype,uF=cF.hasOwnProperty;function hF(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&uF.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var AA=hF;var dF=Zt.Uint8Array,ev=dF;function fF(r){var e=new r.constructor(r.byteLength);return new ev(e).set(new ev(r)),e}var zl=fF;function pF(r,e){var t=e?zl(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var _A=pF;var mF=/\w*$/;function gF(r){var e=new r.constructor(r.source,mF.exec(r));return e.lastIndex=r.lastIndex,e}var TA=gF;var MA=or?or.prototype:void 0,EA=MA?MA.valueOf:void 0;function yF(r){return EA?Object(EA.call(r)):{}}var CA=yF;function vF(r,e){var t=e?zl(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var kf=vF;var xF="[object Boolean]",bF="[object Date]",wF="[object Map]",SF="[object Number]",AF="[object RegExp]",_F="[object Set]",TF="[object String]",MF="[object Symbol]",EF="[object ArrayBuffer]",CF="[object DataView]",PF="[object Float32Array]",DF="[object Float64Array]",IF="[object Int8Array]",LF="[object Int16Array]",OF="[object Int32Array]",RF="[object Uint8Array]",NF="[object Uint8ClampedArray]",BF="[object Uint16Array]",FF="[object Uint32Array]";function UF(r,e,t){var n=r.constructor;switch(e){case EF:return zl(r);case xF:case bF:return new n(+r);case CF:return _A(r,t);case PF:case DF:case IF:case LF:case OF:case RF:case NF:case BF:case FF:return kf(r,t);case wF:return new n;case SF:case TF:return new n(r);case AF:return TA(r);case _F:return new n;case MF:return CA(r)}}var PA=UF;function GF(r){return typeof r.constructor=="function"&&!Cl(r)?sS(Bl(r)):{}}var Vf=GF;var zF="[object Map]";function kF(r){return qn(r)&&Gl(r)==zF}var DA=kF;var IA=ms&&ms.isMap,VF=IA?Dl(IA):DA,LA=VF;var HF="[object Set]";function WF(r){return qn(r)&&Gl(r)==HF}var OA=WF;var RA=ms&&ms.isSet,jF=RA?Dl(RA):OA,NA=jF;var qF=1,XF=2,YF=4,BA="[object Arguments]",QF="[object Array]",ZF="[object Boolean]",KF="[object Date]",JF="[object Error]",FA="[object Function]",$F="[object GeneratorFunction]",eU="[object Map]",tU="[object Number]",UA="[object Object]",nU="[object RegExp]",rU="[object Set]",iU="[object String]",sU="[object Symbol]",oU="[object WeakMap]",aU="[object ArrayBuffer]",lU="[object DataView]",cU="[object Float32Array]",uU="[object Float64Array]",hU="[object Int8Array]",dU="[object Int16Array]",fU="[object Int32Array]",pU="[object Uint8Array]",mU="[object Uint8ClampedArray]",gU="[object Uint16Array]",yU="[object Uint32Array]",Nt={};Nt[BA]=Nt[QF]=Nt[aU]=Nt[lU]=Nt[ZF]=Nt[KF]=Nt[cU]=Nt[uU]=Nt[hU]=Nt[dU]=Nt[fU]=Nt[eU]=Nt[tU]=Nt[UA]=Nt[nU]=Nt[rU]=Nt[iU]=Nt[sU]=Nt[pU]=Nt[mU]=Nt[gU]=Nt[yU]=!0;Nt[JF]=Nt[FA]=Nt[oU]=!1;function Hf(r,e,t,n,i,s){var o,a=e&qF,l=e&XF,u=e&YF;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Ht(r))return r;var c=yn(r);if(c){if(o=AA(r),!a)return Af(r,o)}else{var h=Gl(r),d=h==FA||h==$F;if(Pl(r))return Of(r,a);if(h==UA||h==BA||d&&!i){if(o=l||d?{}:Vf(r),!a)return l?gA(r,lA(o,r)):mA(r,aA(o,r))}else{if(!Nt[h])return i?r:{};o=PA(r,h,a)}}s||(s=new Lf);var f=s.get(r);if(f)return f;s.set(r,o),NA(r)?r.forEach(function(g){o.add(Hf(g,e,t,g,r,s))}):LA(r)&&r.forEach(function(g,v){o.set(v,Hf(g,e,t,v,r,s))});var m=u?l?Ff:yA:l?Ei:Il,p=c?void 0:m(r);return uS(p||r,function(g,v){p&&(v=g,g=r[v]),Ml(o,v,Hf(g,e,t,v,r,s))}),o}var Wf=Hf;var vU=1,xU=4;function bU(r){return Wf(r,vU|xU)}var Hu=bU;function wU(r,e){return r!=null&&e in Object(r)}var GA=wU;function SU(r,e,t){e=Wr(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=$s(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&El(i)&&qs(o,i)&&(yn(r)||ps(r)))}var zA=SU;function AU(r,e){return r!=null&&zA(r,e,GA)}var kA=AU;function _U(r){return function(e,t,n){for(var i=-1,s=Object(e),o=n(e),a=o.length;a--;){var l=o[r?a:++i];if(t(s[l],l,s)===!1)break}return e}}var VA=_U;var TU=VA(),HA=TU;var MU=function(){return Zt.Date.now()},jf=MU;var EU="Expected a function",CU=Math.max,PU=Math.min;function DU(r,e,t){var n,i,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof r!="function")throw new TypeError(EU);e=Qy(e)||0,Ht(t)&&(c=!!t.leading,h="maxWait"in t,s=h?CU(Qy(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function f(_){var M=n,x=i;return n=i=void 0,u=_,o=r.apply(x,M),o}function m(_){return u=_,a=setTimeout(v,e),c?f(_):o}function p(_){var M=_-l,x=_-u,T=e-M;return h?PU(T,s-x):T}function g(_){var M=_-l,x=_-u;return l===void 0||M>=e||M<0||h&&x>=s}function v(){var _=jf();if(g(_))return y(_);a=setTimeout(v,p(_))}function y(_){return a=void 0,d&&n?f(_):(n=i=void 0,o)}function w(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function b(){return a===void 0?o:y(jf())}function S(){var _=jf(),M=g(_);if(n=arguments,i=this,l=_,M){if(a===void 0)return m(l);if(h)return clearTimeout(a),a=setTimeout(v,e),f(l)}return a===void 0&&(a=setTimeout(v,e)),o}return S.cancel=w,S.flush=b,S}var Wu=DU;function IU(r,e,t){(t!==void 0&&!Xs(r[e],t)||t===void 0&&!(e in r))&&Tl(r,e,t)}var ju=IU;function LU(r){return qn(r)&&Ys(r)}var WA=LU;function OU(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var qu=OU;function RU(r){return Hr(r,Ei(r))}var jA=RU;function NU(r,e,t,n,i,s,o){var a=qu(r,t),l=qu(e,t),u=o.get(l);if(u){ju(r,t,u);return}var c=s?s(a,l,t+"",r,e,o):void 0,h=c===void 0;if(h){var d=yn(l),f=!d&&Pl(l),m=!d&&!f&&Mf(l);c=l,d||f||m?yn(a)?c=a:WA(a)?c=Af(a):f?(h=!1,c=Of(l,!0)):m?(h=!1,c=kf(l,!0)):c=[]:If(l)||ps(l)?(c=a,ps(a)?c=jA(a):(!Ht(a)||Al(a))&&(c=Vf(l))):h=!1}h&&(o.set(l,c),i(c,l,n,s,o),o.delete(l)),ju(r,t,c)}var qA=NU;function XA(r,e,t,n,i){r!==e&&HA(e,function(s,o){if(i||(i=new Lf),Ht(s))qA(r,e,o,t,XA,n,i);else{var a=n?n(qu(r,o),s,o+"",r,e,i):void 0;a===void 0&&(a=s),ju(r,o,a)}},Ei)}var YA=XA;function BU(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var QA=BU;function FU(r,e){return e.length<2?r:Pf(r,tA(e,0,-1))}var ZA=FU;var UU=pS(function(r,e,t){YA(r,e,t)}),Jo=UU;function GU(r,e){return e=Wr(e,r),r=ZA(r,e),r==null||delete r[$s(QA(e))]}var KA=GU;function zU(r){return If(r)?void 0:r}var JA=zU;var kU=1,VU=2,HU=4,WU=Df(function(r,e){var t={};if(r==null)return t;var n=!1;e=xf(e,function(s){return s=Wr(s,r),n||(n=s.length>1),s}),Hr(r,Ff(r),t),n&&(t=Wf(t,kU|VU|HU,JA));for(var i=e.length;i--;)KA(t,e[i]);return t}),kl=WU;function jU(r,e,t,n){if(!Ht(r))return r;e=Wr(e,r);for(var i=-1,s=e.length,o=s-1,a=r;a!=null&&++i<s;){var l=$s(e[i]),u=t;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Ht(c)?c:qs(e[i+1])?[]:{})}Ml(a,l,u),a=a[l]}return r}var $A=jU;function qU(r,e,t){for(var n=-1,i=e.length,s={};++n<i;){var o=e[n],a=Pf(r,o);t(a,o)&&$A(s,Wr(o,r),a)}return s}var e1=qU;function XU(r,e){return e1(r,e,function(t,n){return kA(r,n)})}var t1=XU;var YU=Df(function(r,e){return r==null?{}:t1(r,e)}),Vl=YU;var r1,i1=new Promise(r=>{r1=r}),n1=!1;async function s1(){if(n1)return;let r=await import("./physics.js");await r.init(),r1(r),n1=!0}var zt=class{modifyById(e,t){let n=this;if(n[e]===void 0)throw new Error("not expected");{let s={...n,[e]:t};return Object.setPrototypeOf(s,zt.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let n=t[e.id],i;n===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:n};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,zt.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:n}=e,i=t[n];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,zt.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}throw new Error("illegal arg")}};function Xu(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let e=Object.getOwnPropertyNames(r);for(let t of e){let n=r[t];n&&typeof n=="object"&&Xu(n)}return Object.freeze(r)}function o1(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}var Hl=class extends Error{};function Ci(r,e,t){if(r===void 0?e===void 0?(r=0,e=10):r=e-10:e===void 0&&(e=r+10),r>e){let s=r;r=e,e=s}let n=[],i=1/(t+1);for(let s=0;s<t;s++){let o=r+(e-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function $o(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function a1(){return typeof process<"u"}function l1(r,e){for(let t of r)e(t.id,t.data),l1(t.children,e)}function c1(r,e){e(r.id,r.data);for(let t of r.children)c1(t,e)}var Bt=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Bt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Xu(this[t]),t++}fillCaches0(t,n){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,n);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,n){for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,n){if(t===null)this.traverse(n);else{let i=this.get(t);i&&c1(i,n)}}traverse(t){l1(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(c=>c.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(t,n){let i=t,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,Bt.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:n}){if(this.get(t)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:n,fi:i,id:s,data:o,children:a}=t;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),t.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:n}=t;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:n,fi:i,id:s}=t;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Hl("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=n,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),t.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:t,reverse:{type:9,parent:a,fi:d,id:s}}}previous(t,n){if(n===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(t){let n=this.childrenArray(t);return n.length>0?n[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let n=this.childrenArray(t);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):t}sortPrevious(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>o1(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(t){var n=t;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(t,n,i){return this.insertAfterHelper(t,this.previous(t,n),i)}insertAfterHelper(t,n,i){let s=this.childrenArray(t);if(n===null){if(s.length===0)return Ci(0,i,i);{let o=s[0].fi;return Ci(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ci(l,l+i,i)}else return Ci(o.fi,a.fi,i)}}};var Wl;(e=>{function r(t,n){if(Array.isArray(t)){let i=n.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}e.runOp=r})(Wl||(Wl={}));var Ve=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Ve.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Xu(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,Ve.prototype);let n=t;return a1()||n.fillCaches(),n}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:n,id:i,data:s}=t,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:n}=t,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:n,id:i}=t,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===t)return n;n=i.id}return null}insertBeforeHelper(t,n){return this.insertAfterHelper(this.previous(t),n)}insertAfterHelper(t,n){let i=this;if(t===null){if(i.length===0)return Ci(0,n,n);{let s=i[0].fi;return Ci(s-n,s,n)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return Ci(a,a+n,n)}else return Ci(s.fi,o.fi,n)}}};var Ir=class{unusedFun(e){}runOp(e){let t=[],n=this,i=0,s={};for(;i<e.path.length;){if(t.push(n),n=n===void 0?void 0:n[e.path[i]],n instanceof Bt||n instanceof Ve)return null;i+=1}n={...n};for(let[l,u]of Object.entries(e.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;)Object.keys(n).length===0?(n={...t[i-1]},delete n[e.path[i-1]]):n={...t[i-1],[e.path[i-1]]:n},i-=1;let o=Object.setPrototypeOf(n,Ir.prototype),a={...e,props:s};return{data:o,actual:e,reverse:a}}},u1;(t=>{function r(n,i){return Yu(n,i)??n}t.apply=r;function e(n,i){if(i.type===0){let s=0,o=i.path,a=n;for(;s<o.length&&a!==void 0;){if(a=Pi.zoomOnce(a,o[s]),a instanceof Bt||a instanceof Ve)return;s+=1}if(a===void 0)return i;if(typeof a=="string"||typeof a=="number"||$o(a))return;if(a&&typeof a=="object"){let l={...i.props};for(let u of Object.keys(a))delete l[u];return{...i,props:l}}else return}else if(i.type===1||i.type===4||i.type===7){let s=Pi.zoom(n,[...i.path,i.id]);if(s===void 0)return i;if(typeof s=="string"||typeof s=="number"||$o(s))return;if(s&&typeof s=="object"){let o={...i.data,...s};return{...i,data:o}}else return}else return i}t.filterOp=e})(u1||(u1={}));function h1(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Yu(i.data,e[s]);t=t||o!==void 0,o===void 0&&(o=i.data);let a=h1(i.children,e);return a!==void 0?t=!0:a=i.children,{...i,id:s,data:o,children:a}});if(t)return n}function QU(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Yu(i.data,e[s]);return t=t||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(t)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function Yu(r,e){if(e!==void 0){if(e instanceof Ve||e instanceof Bt||typeof e=="string"||typeof e=="number"||e===null)return e;if(r instanceof Bt){let t=h1(r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else{if(r instanceof Ve)return QU(r,e);if(Array.isArray(r)){let t=!1,n=r.map((i,s)=>{let o=Yu(i,e[s]);return t=t||o!==void 0,o===void 0&&(o=i),o});return t?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(r&&typeof r=="object"){let t={},n=!1;for(let[i,s]of Object.entries(r)){let o=Yu(s,e[i]);n=n||o!==void 0,o===void 0&&(o=s),t[i]=o}return n?(Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t):void 0}else return e??r}}}function d1(r,e){let t={cur:[],result:[],len:0};return r=Qu(r,e,t)??r,[r,t.result]}function qf(r,e){return r===null?null:(r.cur[r.len]=e,r.len+=1,r)}function Xf(r){r&&(r.len-=1)}function ZU(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function f1(r,e,t){let n=!1,i=r.map(s=>{let o=s.id,a=e[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,t!==null))throw new Error("not supported");let l=Qu(s.data,e,qf(t,o));Xf(t),n=n||l!==void 0,l===void 0&&(l=s.data);let u=f1(s.children,e,t);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function KU(r,e,t){let n=!1,i=r.map(s=>{let o=s.id,a=e[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,t!==null))throw new Error("not supported");let l=Qu(s.data,e,qf(t,o));return Xf(t),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function Qu(r,e,t){if(r instanceof Bt){let n=f1(r,e,t);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof Ve)return KU(r,e,t);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Qu(s,e,qf(t,o));return Xf(t),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=e[s];if(typeof a=="string"){if(t!==null)throw new Error("not supported");i=!0,s=a}let l=Qu(o,e,qf(t,s));Xf(t),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=e[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");ZU(t)}return n}else return}}var p1;(e=>{function r(t,n){let i=Pi.zoom(n,t.path);if(typeof i=="object"){let s={};for(let o of Object.keys(t.props))s[o]=i[o];return{...t,props:s}}else return{...t,props:{}}}e.replaceProps=r})(p1||(p1={}));var eo;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function e(l,u){return t(l,u)?.data??l}a.applySimple=e;function t(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Ir&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),h.length===c.length&&(l instanceof Bt||l instanceof Ve||l instanceof zt?d=l.runOp(u):d=Wl.runOp(l,u)),d!==void 0)if(d!==null){let p=d.data;for(let g=h.length-1;g>=0;g--){let v=c[g],y=h[g];if(y instanceof Bt){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof Ve){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof zt){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof Ir){let w={...y,[v]:p};p=Object.setPrototypeOf(w,Ir.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let w=p;p=[...y],p[v]=w}else p={...y,[v]:p};else return null}return{data:p,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],m;if(l instanceof Bt){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof Ve){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)h.push(l),l=m;else return null}}a.apply=t;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(eo||(eo={}));var m1;(l=>{function r(){return[]}l.empty=r;function e(u,c){let h=[];for(let d of u){let[f,...m]=d.path;f===c&&h.push({...d,path:m})}return h}l.removePrefix=e;function t(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=t;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(d=>!c.some(f=>eo.subsumed(d,f))),...c]}l.compress=i;function s(u,c){return u.every(h=>c.every(d=>eo.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let m of c)try{if(m.type===3){let p=Pi.zoom(h,[...m.path,m.id]),g=eo.apply(h,{...m,type:2});if(g!==null){h=g.data;let[v,y]=d1(h,{[m.id]:p});h=v;for(let w of y){let b=w[w.length-1];w.splice(w.length-1,1),d.push({type:0,path:w,props:{[b]:p}}),f.push({type:0,path:w,props:{[b]:m.id}})}f.push(g.reverse),d.push(g.actual)}}else{let p=eo.apply(h,m);p!==null&&(d.push(p.actual),h=p.data,f.push(p.reverse))}}catch(p){if(p instanceof Hl)return null;throw p}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(m1||(m1={}));var g1=Symbol(),Zu=Symbol(),ea=class{reportOp(e,t,n=[]){let i=this;if(t===null)return;i._current=t.data;let s=n;for(;!(i instanceof Qf);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let n=t[Zu];n&&n(),delete this._children[e]}}}},nv=class extends ea{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Wl.runOp(this._current,e),e.path)}},rv=class extends ea{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,zt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},y1={get(r,e){if(e===Zu)return()=>{r._parent=null};if(e===g1)return r._current;let{_current:t,_children:n}=r;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t[e],o=Zf(r,e,s);return o!==s?(n===void 0&&(n={},r._children=n),n[e]=o,o):s},has(r,e){return e in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,e){let t=r._current,n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:t[e]}}},JU={...y1,set(r,e,t){let n={type:0,props:{[e]:dr(t)??t}};return r.deleteChildren(e),r.runOp(n),!0},deleteProperty(r,e){let t={type:0,props:{[e]:void 0}};return r.deleteChildren(e),r.runOp(t),!0}},$U={...y1,set(r,e,t){return t===void 0?this.deleteProperty(r,e):(r.deleteChildren(e),r.runOp({type:1,id:e,data:t})),!0},deleteProperty(r,e){return r.runOp({type:2,id:e}),!0}},jl=class extends ea{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Zu]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,n)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Zf(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}add(e,t,n,i,s){this.runOp({type:7,parent:e,fi:t,id:n,data:i,children:s})}move(e,t,n){this.runOp({type:9,parent:e,fi:t,id:n})}insertAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}moveBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Yf=class extends ea{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n,this[Zu]=()=>{this._parent=null}}feedOp(e){let{path:t,...n}=e;this.reportOp(n,eo.apply(this._current,e),t)}},ql=class extends ea{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Zu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id,s=this._current[n].fi;e(this.data(this._current[n].id),i,s)}}find(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id;if(e(this.data(i),i))return this.get(i)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Zf(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,n){this.runOp({type:4,fi:e,id:t,data:n})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}insertBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}moveAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}moveBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function tv(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&Pi.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var Qf=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,n,i){tv(this.ts,t,e),tv(this.actual,n,e),tv(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Zf(r,e,t){return t instanceof Bt?new jl(r,e,t):t instanceof Ve?new ql(r,e,t):t instanceof Ir?new Yf(r,e,t):t instanceof zt?new Proxy(new rv(r,e,t),$U):t!==null&&typeof t=="object"?$o(t)?t:new Proxy(new nv(r,e,t),JU):t}function iv(r){let e=new Qf(r);return[Zf(e,"",r),e]}function sv(r,e){let[t,n]=iv(r);return e(t),n.result()}function dr(r){return r instanceof jl||r instanceof ql||r instanceof Yf?r._current:r!==null&&typeof r=="object"?r[g1]:r}var Pi;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function e(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}i.removeOverridden=e;function t(s,o){if((s instanceof Bt||s instanceof jl)&&typeof o=="string")return s.data(o);if((s instanceof Ve||s instanceof ql)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object")return s[o]}i.zoomOnce=t;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=t(s,o[a]),a+=1;return s}i.zoom=n})(Pi||(Pi={}));var Kf=class{},Ku=class extends Kf{constructor(t){super();this.id=t}},Ju=class extends Kf{constructor(t){super();this.data=t}};var av;try{av=new TextDecoder}catch{}var Ie,no,Z=0;var T1=[],lv=T1,cv=0,fr={},xt,to,jr=0,Di=0,Lr,ys,ar=[],Et,v1={useRecords:!1,mapsAsObjects:!0},$u=class{},hv=new $u;hv.name="MessagePack 0xC1";var Xl=!1,Ii=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ie)return D1(()=>($f(),this?this.unpack(e,t):Ii.prototype.unpack.call(v1,e,t)));no=t>-1?t:e.length,Z=0,cv=0,Di=0,to=null,lv=T1,Lr=null,Ie=e;try{Et=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Ie=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Ii){if(fr=this,this.structures)return xt=this.structures,Jf();(!xt||xt.length>0)&&(xt=[])}else fr=v1,(!xt||xt.length>0)&&(xt=[]);return Jf()}unpackMultiple(e,t){let n,i=0;try{Xl=!0;let s=e.length,o=this?this.unpack(e,s):np.unpack(e,s);if(t){for(t(o);Z<s;)if(i=Z,t(Jf())===!1)return}else{for(n=[o];Z<s;)i=Z,n.push(Jf());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Xl=!1,$f()}}_mergeStructures(e,t){e=e||[];for(let n=0,i=e.length;n<i;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let i=e[n],s=t[n];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[n]=i),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Jf(){try{if(!fr.trusted&&!Xl){let e=xt.sharedLength||0;e<xt.length&&(xt.length=e)}let r=Kt();if(Z==no)xt.restoreStructures&&x1(),xt=null,Ie=null,ys&&(ys=null);else if(Z>no){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Xl)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw xt.restoreStructures&&x1(),$f(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function x1(){for(let r in xt.restoreStructures)xt[r]=xt.restoreStructures[r];xt.restoreStructures=null}function Kt(){let r=Ie[Z++];if(r<160)if(r<128){if(r<64)return r;{let e=xt[r&63]||fr.getStructures&&M1()[r&63];return e?(e.read||(e.read=dv(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,fr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[C1()]=Kt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Kt(),Kt());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Kt();return e}else if(r<192){let e=r-160;if(Di>=Z)return to.slice(Z-jr,(Z+=e)-jr);if(Di==0&&no<140){let t=e<16?fv(e):E1(e);if(t!=null)return t}return uv(e)}else{let e;switch(r){case 192:return null;case 193:return Lr?(e=Kt(),e>0?Lr[1].slice(Lr.position1,Lr.position1+=e):Lr[0].slice(Lr.position0,Lr.position0-=e)):hv;case 194:return!1;case 195:return!0;case 196:return ov(Ie[Z++]);case 197:return e=Et.getUint16(Z),Z+=2,ov(e);case 198:return e=Et.getUint32(Z),Z+=4,ov(e);case 199:return ta(Ie[Z++]);case 200:return e=Et.getUint16(Z),Z+=2,ta(e);case 201:return e=Et.getUint32(Z),Z+=4,ta(e);case 202:if(e=Et.getFloat32(Z),fr.useFloat32>2){let t=tp[(Ie[Z]&127)<<1|Ie[Z+1]>>7];return Z+=4,(t*e+(e>0?.5:-.5)>>0)/t}return Z+=4,e;case 203:return e=Et.getFloat64(Z),Z+=8,e;case 204:return Ie[Z++];case 205:return e=Et.getUint16(Z),Z+=2,e;case 206:return e=Et.getUint32(Z),Z+=4,e;case 207:return fr.int64AsNumber?(e=Et.getUint32(Z)*4294967296,e+=Et.getUint32(Z+4)):e=Et.getBigUint64(Z),Z+=8,e;case 208:return Et.getInt8(Z++);case 209:return e=Et.getInt16(Z),Z+=2,e;case 210:return e=Et.getInt32(Z),Z+=4,e;case 211:return fr.int64AsNumber?(e=Et.getInt32(Z)*4294967296,e+=Et.getUint32(Z+4)):e=Et.getBigInt64(Z),Z+=8,e;case 212:if(e=Ie[Z++],e==114)return _1(Ie[Z++]&63);{let t=ar[e];if(t)return t.read?(Z++,t.read(Kt())):t.noBuffer?(Z++,t()):t(Ie.subarray(Z,++Z));throw new Error("Unknown extension "+e)}case 213:return e=Ie[Z],e==114?(Z++,_1(Ie[Z++]&63,Ie[Z++])):ta(2);case 214:return ta(4);case 215:return ta(8);case 216:return ta(16);case 217:return e=Ie[Z++],Di>=Z?to.slice(Z-jr,(Z+=e)-jr):tG(e);case 218:return e=Et.getUint16(Z),Z+=2,Di>=Z?to.slice(Z-jr,(Z+=e)-jr):nG(e);case 219:return e=Et.getUint32(Z),Z+=4,Di>=Z?to.slice(Z-jr,(Z+=e)-jr):rG(e);case 220:return e=Et.getUint16(Z),Z+=2,w1(e);case 221:return e=Et.getUint32(Z),Z+=4,w1(e);case 222:return e=Et.getUint16(Z),Z+=2,S1(e);case 223:return e=Et.getUint32(Z),Z+=4,S1(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}var eG=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function dv(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>eG.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Kt);return r.highByte===0&&(r.read=b1(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=Kt()}return n}return t.count=0,r.highByte===0?b1(e,t):t}var b1=(r,e)=>function(){let t=Ie[Z++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=xt[n]||M1()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=dv(i,r)),i.read()};function M1(){let r=D1(()=>(Ie=null,fr.getStructures()));return xt=fr._mergeStructures(r,xt)}var uv=ep,tG=ep,nG=ep,rG=ep;function ep(r){let e;if(r<16&&(e=fv(r)))return e;if(r>64&&av)return av.decode(Ie.subarray(Z,Z+=r));let t=Z+r,n=[];for(e="";Z<t;){let i=Ie[Z++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Ie[Z++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Ie[Z++]&63,o=Ie[Z++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ie[Z++]&63,o=Ie[Z++]&63,a=Ie[Z++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(e+=Dn.apply(String,n),n.length=0)}return n.length>0&&(e+=Dn.apply(String,n)),e}function w1(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Kt();return e}function S1(r){if(fr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[C1()]=Kt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Kt(),Kt());return e}}var Dn=String.fromCharCode;function E1(r){let e=Z,t=new Array(r);for(let n=0;n<r;n++){let i=Ie[Z++];if((i&128)>0){Z=e;return}t[n]=i}return Dn.apply(String,t)}function fv(r){if(r<4)if(r<2){if(r===0)return"";{let e=Ie[Z++];if((e&128)>1){Z-=1;return}return Dn(e)}}else{let e=Ie[Z++],t=Ie[Z++];if((e&128)>0||(t&128)>0){Z-=2;return}if(r<3)return Dn(e,t);let n=Ie[Z++];if((n&128)>0){Z-=3;return}return Dn(e,t,n)}else{let e=Ie[Z++],t=Ie[Z++],n=Ie[Z++],i=Ie[Z++];if((e&128)>0||(t&128)>0||(n&128)>0||(i&128)>0){Z-=4;return}if(r<6){if(r===4)return Dn(e,t,n,i);{let s=Ie[Z++];if((s&128)>0){Z-=5;return}return Dn(e,t,n,i,s)}}else if(r<8){let s=Ie[Z++],o=Ie[Z++];if((s&128)>0||(o&128)>0){Z-=6;return}if(r<7)return Dn(e,t,n,i,s,o);let a=Ie[Z++];if((a&128)>0){Z-=7;return}return Dn(e,t,n,i,s,o,a)}else{let s=Ie[Z++],o=Ie[Z++],a=Ie[Z++],l=Ie[Z++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Z-=8;return}if(r<10){if(r===8)return Dn(e,t,n,i,s,o,a,l);{let u=Ie[Z++];if((u&128)>0){Z-=9;return}return Dn(e,t,n,i,s,o,a,l,u)}}else if(r<12){let u=Ie[Z++],c=Ie[Z++];if((u&128)>0||(c&128)>0){Z-=10;return}if(r<11)return Dn(e,t,n,i,s,o,a,l,u,c);let h=Ie[Z++];if((h&128)>0){Z-=11;return}return Dn(e,t,n,i,s,o,a,l,u,c,h)}else{let u=Ie[Z++],c=Ie[Z++],h=Ie[Z++],d=Ie[Z++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){Z-=12;return}if(r<14){if(r===12)return Dn(e,t,n,i,s,o,a,l,u,c,h,d);{let f=Ie[Z++];if((f&128)>0){Z-=13;return}return Dn(e,t,n,i,s,o,a,l,u,c,h,d,f)}}else{let f=Ie[Z++],m=Ie[Z++];if((f&128)>0||(m&128)>0){Z-=14;return}if(r<15)return Dn(e,t,n,i,s,o,a,l,u,c,h,d,f,m);let p=Ie[Z++];if((p&128)>0){Z-=15;return}return Dn(e,t,n,i,s,o,a,l,u,c,h,d,f,m,p)}}}}}function ov(r){return fr.copyBuffers?Uint8Array.prototype.slice.call(Ie,Z,Z+=r):Ie.subarray(Z,Z+=r)}function ta(r){let e=Ie[Z++];if(ar[e])return ar[e](Ie.subarray(Z,Z+=r));throw new Error("Unknown extension type "+e)}var A1=new Array(4096);function C1(){let r=Ie[Z++];if(r>=160&&r<192){if(r=r-160,Di>=Z)return to.slice(Z-jr,(Z+=r)-jr);if(!(Di==0&&no<180))return uv(r)}else return Z--,Kt();let e=(r<<5^(r>1?Et.getUint16(Z):r>0?Ie[Z]:0))&4095,t=A1[e],n=Z,i=Z+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Et.getUint32(n),s!=t[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Ie[n++],s!=t[o++]){n=1879048192;break}if(n===i)return Z=n,t.string;i-=3,n=Z}for(t=[],A1[e]=t,t.bytes=r;n<i;)s=Et.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],t.push(s);let a=r<16?fv(r):E1(r);return a!=null?t.string=a:t.string=uv(r)}var _1=(r,e)=>{var t=Kt();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=xt[r];return i&&i.isShared&&((xt.restoreStructures||(xt.restoreStructures=[]))[r]=i),xt[r]=t,t.read=dv(t,n),t.read()},P1=typeof self=="object"?self:global;ar[0]=()=>{};ar[0].noBuffer=!0;ar[101]=()=>{let r=Kt();return(P1[r[0]]||Error)(r[1])};ar[105]=r=>{let e=Et.getUint32(Z-4);ys||(ys=new Map);let t=Ie[Z],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};ys.set(e,i);let s=Kt();return i.used?Object.assign(n,s):(i.target=s,s)};ar[112]=r=>{let e=Et.getUint32(Z-4),t=ys.get(e);return t.used=!0,t.target};ar[115]=()=>new Set(Kt());var pv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");ar[116]=r=>{let e=r[0],t=pv[e];if(!t)throw new Error("Could not find typed array for code "+e);return new P1[t](Uint8Array.prototype.slice.call(r,1).buffer)};ar[120]=()=>{let r=Kt();return new RegExp(r[0],r[1])};ar[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Z;Z+=e-4,Lr=[Kt(),Kt()],Lr.position0=0,Lr.position1=0;let n=Z;Z=t;try{return Kt()}finally{Z=n}};ar[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function D1(r){let e=no,t=Z,n=cv,i=jr,s=Di,o=to,a=lv,l=ys,u=Lr,c=new Uint8Array(Ie.slice(0,no)),h=xt,d=xt.slice(0,xt.length),f=fr,m=Xl,p=r();return no=e,Z=t,cv=n,jr=i,Di=s,to=o,lv=a,ys=l,Lr=u,Ie=c,Xl=m,xt=h,xt.splice(0,xt.length,...d),fr=f,Et=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function $f(){Ie=null,ys=null,xt=null}function I1(r){r.unpack?ar[r.type]=r.unpack:ar[r.type]=r}var tp=new Array(147);for(let r=0;r<256;r++)tp[r]=+("1e"+Math.floor(45.15-r*.30103));var np=new Ii({useRecords:!1}),iG=np.unpack,sG=np.unpackMultiple,oG=np.unpack,rp={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},aG=new Float32Array(1),VQ=new Uint8Array(aG.buffer,0,4);var ip;try{ip=new TextEncoder}catch{}var sp,gv,op=typeof Buffer<"u",mv=op?Buffer.allocUnsafeSlow:Uint8Array,N1=op?Buffer:Uint8Array,L1=op?4294967296:2144337920,ae,sn,ee=0,Li,Oi=null,lG=/[\u0080-\uFFFF]/,eh=Symbol("record-id"),na=class extends Ii{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,u=N1.prototype.utf8Write?function(x,T,E){return ae.utf8Write(x,T,E)}:ip&&ip.encodeInto?function(x,T){return ip.encodeInto(x,ae.subarray(T)).written}:!1,c=this;e||(e={});let h=e&&e.sequential,d=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=d?32:64),h&&!e.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,v=f+m+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],w=0,b=0;this.pack=this.encode=function(x,T){if(ae||(ae=new mv(8192),sn=new DataView(ae.buffer,0,8192),ee=0),Li=ae.length-10,Li-ee<2048?(ae=new mv(ae.length),sn=new DataView(ae.buffer,0,ae.length),Li=ae.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=c.structuredClone?new Map:null,c.bundleStrings?(Oi=["",""],ae[ee++]=214,ae[ee++]=98,Oi.position=ee-n,ee+=4):Oi=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let E=i.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let P=i[C];if(!P)continue;let O,I=i.transitions;for(let N=0,F=P.length;N<F;N++){let G=P[N];O=I[G],O||(O=I[G]=Object.create(null)),I=O}I[eh]=C+64}l=E}h||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(x),Oi){sn.setUint32(Oi.position+n,ee-Oi.position-n);let E=Oi;Oi=null,S(E[0]),S(E[1])}if(c.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>Li&&M(ee),c.offset=ee;let E=uG(ae.subarray(n,ee),a.idsToInsert);return a=null,E}return T&F1?(ae.start=n,ae.end=ee,ae):ae.subarray(n,ee)}finally{if(i){if(b<10&&b++,w>1e4)i.transitions=null,b=0,w=0,y.length>0&&(y=[]);else if(y.length>0&&!h){for(let E=0,C=y.length;E<C;E++)y[E][eh]=0;y=[]}if(s&&c.saveStructures){let E=i.sharedLength||f;i.length>E&&(i=i.slice(0,E));let C=ae.subarray(n,ee);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=E,C)}}T&yG&&(ee=n)}};let S=x=>{ee>Li&&(ae=M(ee));var T=typeof x,E;if(T==="string"){let C=x.length;if(Oi&&C>=8&&C<4096){let I=lG.test(x);Oi[I?0:1]+=x,ae[ee++]=193,S(I?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let O=C*3;if(ee+O>Li&&(ae=M(ee+O)),C<64||!u){let I,N,F,G=ee+P;for(I=0;I<C;I++)N=x.charCodeAt(I),N<128?ae[G++]=N:N<2048?(ae[G++]=N>>6|192,ae[G++]=N&63|128):(N&64512)===55296&&((F=x.charCodeAt(I+1))&64512)===56320?(N=65536+((N&1023)<<10)+(F&1023),I++,ae[G++]=N>>18|240,ae[G++]=N>>12&63|128,ae[G++]=N>>6&63|128,ae[G++]=N&63|128):(ae[G++]=N>>12|224,ae[G++]=N>>6&63|128,ae[G++]=N&63|128);E=G-ee-P}else E=u(x,ee+P,O);E<32?ae[ee++]=160|E:E<256?(P<2&&ae.copyWithin(ee+2,ee+1,ee+1+E),ae[ee++]=217,ae[ee++]=E):E<65536?(P<3&&ae.copyWithin(ee+3,ee+2,ee+2+E),ae[ee++]=218,ae[ee++]=E>>8,ae[ee++]=E&255):(P<5&&ae.copyWithin(ee+5,ee+3,ee+3+E),ae[ee++]=219,sn.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(x>>>0===x)x<64?ae[ee++]=x:x<256?(ae[ee++]=204,ae[ee++]=x):x<65536?(ae[ee++]=205,ae[ee++]=x>>8,ae[ee++]=x&255):(ae[ee++]=206,sn.setUint32(ee,x),ee+=4);else if(x>>0===x)x>=-32?ae[ee++]=256+x:x>=-128?(ae[ee++]=208,ae[ee++]=x+256):x>=-32768?(ae[ee++]=209,sn.setInt16(ee,x),ee+=2):(ae[ee++]=210,sn.setInt32(ee,x),ee+=4);else{let C;if((C=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){ae[ee++]=202,sn.setFloat32(ee,x);let P;if(C<4||(P=x*tp[(ae[ee]&127)<<1|ae[ee+1]>>7])>>0===P){ee+=4;return}else ee--}ae[ee++]=203,sn.setFloat64(ee,x),ee+=8}else if(T==="object")if(!x)ae[ee++]=192;else{if(a){let P=a.get(x);if(P){if(!P.id){let O=a.idsToInsert||(a.idsToInsert=[]);P.id=O.push(P)}ae[ee++]=214,ae[ee++]=112,sn.setUint32(ee,P.id),ee+=4;return}else a.set(x,{offset:ee-n})}let C=x.constructor;if(C===Object)_(x,!0);else if(C===Array){E=x.length,E<16?ae[ee++]=144|E:E<65536?(ae[ee++]=220,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=221,sn.setUint32(ee,E),ee+=4);for(let P=0;P<E;P++)S(x[P])}else if(C===Map){E=x.size,E<16?ae[ee++]=128|E:E<65536?(ae[ee++]=222,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=223,sn.setUint32(ee,E),ee+=4);for(let[P,O]of x)S(P),S(O)}else{for(let P=0,O=sp.length;P<O;P++){let I=gv[P];if(x instanceof I){let N=sp[P];if(N.write){N.type&&(ae[ee++]=212,ae[ee++]=N.type,ae[ee++]=0),S(N.write.call(this,x));return}let F=ae,G=sn,Y=ee;ae=null;let U;try{U=N.pack.call(this,x,z=>(ae=F,F=null,ee+=z,ee>Li&&M(ee),{target:ae,targetView:sn,position:ee-z}),S)}finally{F&&(ae=F,sn=G,ee=Y,Li=ae.length-10)}U&&(U.length+ee>Li&&M(U.length+ee),ee=cG(U,ae,ee,N.type));return}}_(x,!x.hasOwnProperty)}}else if(T==="boolean")ae[ee++]=x?195:194;else if(T==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))ae[ee++]=211,sn.setBigInt64(ee,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)ae[ee++]=207,sn.setBigUint64(ee,x);else if(this.largeBigIntToFloat)ae[ee++]=203,sn.setFloat64(ee,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");ee+=8}else if(T==="undefined")this.encodeUndefinedAsNil?ae[ee++]=192:(ae[ee++]=212,ae[ee++]=0,ae[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},_=this.useRecords===!1?this.variableMapSize?x=>{let T=Object.keys(x),E=T.length;E<16?ae[ee++]=128|E:E<65536?(ae[ee++]=222,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=223,sn.setUint32(ee,E),ee+=4);let C;for(let P=0;P<E;P++)S(C=T[P]),S(x[C])}:(x,T)=>{ae[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let P in x)(T||x.hasOwnProperty(P))&&(S(P),S(x[P]),C++);ae[E+++n]=C>>8,ae[E+n]=C&255}:x=>{let T=Object.keys(x),E,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let I=0,N=T.length;I<N;I++){let F=T[I];E=C[F],E||(E=C[F]=Object.create(null),P++),C=E}let O=C[eh];if(O)O>=96&&p?(ae[ee++]=((O-=96)&31)+96,ae[ee++]=O>>5):ae[ee++]=O;else{O=o.nextId,O||(O=64),O<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(O=o.nextOwnId,O<v||(O=g),o.nextOwnId=O+1):(O>=v&&(O=g),o.nextId=O+1);let I=T.highByte=O>=96&&p?O-96>>5:-1;C[eh]=O,o[O-64]=T,O<g?(T.isShared=!0,o.sharedLength=O-63,s=!0,I>=0?(ae[ee++]=(O&31)+96,ae[ee++]=I):ae[ee++]=O):(I>=0?(ae[ee++]=213,ae[ee++]=114,ae[ee++]=(O&31)+96,ae[ee++]=I):(ae[ee++]=212,ae[ee++]=114,ae[ee++]=O),P&&(w+=b*P),y.length>=m&&(y.shift()[eh]=0),y.push(C),S(T))}for(let I=0,N=T.length;I<N;I++)S(x[T[I]])},M=x=>{let T;if(x>16777216){if(x-n>L1)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(L1,Math.round(Math.max((x-n)*(x>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(x-n<<2,ae.length-1)>>12)+1<<12;let E=new mv(T);return sn=new DataView(E.buffer,0,T),ae.copy?ae.copy(E,0,n,x):E.set(ae.slice(n,x)),ee-=n,n=0,Li=E.length-10,ae=E}}useBuffer(e){ae=e,sn=new DataView(ae.buffer,ae.byteOffset,ae.byteLength),ee=0}};gv=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,$u];sp=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){let n=Array.from(r),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(n)}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),t([r.source,r.flags])}},{pack(r,e){this.structuredClone?O1(r,16,e):R1(op?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==N1&&this.structuredClone?O1(r,pv.indexOf(t.name),e):R1(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function O1(r,e,t,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function R1(r,e){let t=r.byteLength;var n,i;if(t<256){var{target:n,position:i}=e(t+2);n[i++]=196,n[i++]=t}else if(t<65536){var{target:n,position:i}=e(t+3);n[i++]=197,n[i++]=t>>8,n[i++]=t&255}else{var{target:n,position:i,targetView:s}=e(t+5);n[i++]=198,s.setUint32(i,t),i+=4}n.set(r,i)}function cG(r,e,t,n){let i=r.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=n,e.set(r,t),t+=i,t}function uG(r,e){let t,n=e.length*6,i=r.length-n;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function ro(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");gv.unshift(r.Class),sp.unshift(r)}I1(r)}var B1=new na({useRecords:!1}),hG=B1.pack,dG=B1.pack;var{NEVER:fG,ALWAYS:pG,DECIMAL_ROUND:mG,DECIMAL_FIT:gG}=rp,F1=512,yG=1024;var U1=new na({structuredClone:!0});ro({Class:zt.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,zt.prototype),r}});ro({Class:Ve.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Ve.prototype),r}});ro({Class:Bt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Bt.prototype),r}});ro({Class:Ku.prototype.constructor,type:4,write(r){return r.id},read(r){return new Ku(r)}});ro({Class:Ju.prototype.constructor,type:5,write(r){return r.data},read(r){return new Ju(r)}});ro({Class:Ir.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ir.prototype),r}});function vG(r){var e=0;if(r.length===0)return e;for(let t=0;t<r.length;t++){let n=r[t];e=(e<<5)-e+n,e=e&e}return e}function yv(r){if($o(r))return r;if(Array.isArray(r))return r.map(yv);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=yv(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var ap;(n=>{function r(i){return U1.pack(i)}n.serialize=r;function e(i){return U1.unpack(i)}n.deserialize=e;function t(i){return vG(r(yv(i))).toString()}n.checksum=t})(ap||(ap={}));var cp={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio"],["Conditional"]:["Transition","Audio"],["MouseDown"]:["Transition","Audio","Link"],["MouseUp"]:["Transition","Audio","Link"],["KeyDown"]:["Transition","Audio","Link"],["KeyUp"]:["Transition","Audio","Link"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},G1;(t=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"}t.is=r;function e(n){return n==="MouseDown"||n==="MouseUp"?{type:n,toggle:!1,actions:new Ve}:{type:n,key:void 0,toggle:!1,actions:new Ve}}t.defaultData=e})(G1||(G1={}));var lp;(t=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}t.propertyDefaultData=r,t.valueDefaultData={type:"Literal",value:0}})(lp||(lp={}));var vv;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:lp.propertyDefaultData(i),rOperand:{...lp.valueDefaultData}}}n.comparisonDefaultData=r;function e(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=e;function t(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=t})(vv||(vv={}));var z1;(t=>{function r(n){return n.type==="Conditional"}t.is=r;function e(n){return{type:"Conditional",inActions:new Ve,outActions:new Ve,condition:vv.distanceDefaultData(n)}}t.defaultData=e})(z1||(z1={}));var k1;(e=>e.defaultData={type:"Follow"})(k1||(k1={}));var V1;(e=>{function r(){return{type:"LookAt",distance:1e3}}e.defaultData=r})(V1||(V1={}));var H1;(t=>{function r(n){return n.type==="MouseHover"}t.is=r;function e(){return{type:"MouseHover",actions:new Ve}}t.defaultData=e})(H1||(H1={}));var W1;(t=>{function r(n){return n.type==="Scroll"}t.is=r;function e(){return{type:"Scroll",steps:100,actions:new Ve}}t.defaultData=e})(W1||(W1={}));var j1;(t=>{function r(n){return n.type==="Start"}t.is=r;function e(){return{type:"Start",actions:new Ve}}t.defaultData=e})(j1||(j1={}));var q1;(t=>{function r(n){return n.type==="Collision"}t.is=r;function e(){return{type:"Collision",toggle:!1,target:"character",actions:new Ve}}t.defaultData=e})(q1||(q1={}));var ra;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}t.lerp=e})(ra||(ra={}));var Yl;(i=>{function r(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=r;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function n(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=n})(Yl||(Yl={}));var th;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}t.lerp=e})(th||(th={}));var io;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}i.applyMatrix4=n})(io||(io={}));var Xn;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function n(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}l.toRgb255a1=n;function i(u){return{r:u.r,g:u.g,b:u.b}}l.clone=i;function s(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}l.fromHex=s;function o(u,c){return u.r===c.r&&u.g===c.g&&u.b===c.b}l.equals=o;function a(u,c,h){return{r:u.r+(c.r-u.r)*h,g:u.g+(c.g-u.g)*h,b:u.b+(c.b-u.b)*h}}l.lerp=a})(Xn||(Xn={}));var pr;(a=>{a.white={...Xn.white,a:1},a.transparent={...Xn.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=t;function n(l,u){return{...Xn.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return Xn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(pr||(pr={}));var up;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(up||(up={}));var X1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(X1||(X1={}));var Y1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(Y1||(Y1={}));var Ri;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(Ri||(Ri={}));var ia;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(ia||(ia={}));var hp;(e=>{function r(t,n=.1){return{type:"radial",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]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*n,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+n)),useCenter:!0}}}e.defaultData=r})(hp||(hp={}));var sa;(t=>{let r={opacity:1,blendFunction:13,enabled:!1};t.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(sa||(sa={}));var dp;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(dp||(dp={}));var fp;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:pr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:pr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:pr.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(fp||(fp={}));var xv;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(xv||(xv={}));var bv;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}t.equals=e})(bv||(bv={}));var pp;(e=>e.defaultData={...bv.defaultData,...xv.defaultData,cloner:null,booleanExclude:null})(pp||(pp={}));var mp=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Q1=["wrapping","image"],so;(n=>{function r(i,s){return i==="light"&&s?e(s):t(i)}n.defaultData=r;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Xn.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Xn.fromHex(6710886),a:1},colorB:{...Xn.fromHex(6710886),a:1},colorC:{...Xn.fromHex(16777215),a:1},colorD:{...Xn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:pr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:pr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:pr.fromHexAndA(0,1),contourColor:pr.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(so||(so={}));var Fn;(a=>{function r(l){return!l.layers.some(c=>{if(c.data.type==="texture"&&c.data.projection!==0||c.data.type==="depth"&&!c.data.isWorldSpace||c.data.type==="noise"||c.data.type==="displace")return!0})&&!t(l)}a.isMergable=r;function e(l){let u="";return l.layers.forEach(c=>{Object.entries(c.data).forEach(([h,d])=>{u+=`${h}${d}`,Array.isArray(d)?d.forEach(f=>u+=`${f}`):typeof d=="object"?Object.values(d).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${d}`})}),u}a.getHash=e;function t(l){let u=0;for(let c of l.layers)"alpha"in c.data&&c.data.type!=="light"&&c.data.type!=="fresnel"&&(u+=(1-u)*c.data.alpha);return u<1}a.isTransparent=t;function n(){return{layers:new Ve}}a.defaultEmptyData=n;function i(l="layer1",u="layer2"){return s("phong",l,u)}a.defaultData=i;function s(l,u="layer1",c="layer2"){let h=new Ve;return h.push({fi:0,data:so.defaultData("light",l),id:u}),h.push({fi:1,data:so.defaultData("color"),id:c}),{layers:h}}a.defaultTwoLayerData=s;function o(l,u="basic",c="layer1",h="layer2"){let d=so.defaultData("texture");Object.assign(d.texture,{image:l});let f=new Ve;return f.push({fi:0,data:d,id:c}),f.push({fi:1,data:so.defaultData("light",u),id:h}),{layers:f}}a.defaultTwoLayerTextureData=o})(Fn||(Fn={}));var Ql;(e=>{function r(){return{points:new Ve,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Ql||(Ql={}));var gp;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(gp||(gp={}));var oo;(e=>{function r(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Ql.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};if(t==="TextGeometry")return{type:t,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};throw new Error("not implemented")}e.defaultData=r})(oo||(oo={}));var nh;(i=>{i.identity={...up.identity,hiddenMatrix:io.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function n(s,o){return{position:Yl.isEqual(s.position,o.position)?null:o.position,rotation:Yl.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:Yl.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:io.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(nh||(nh={}));var wv;(e=>e.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]})(wv||(wv={}));var hi;(e=>e.defaultData={states:new Ve,events:new Ve,visible:!0,raycastLock:!1,physics:null,...nh.identity})(hi||(hi={}));var Z1;(e=>e.defaultData={type:"Empty",...hi.defaultData})(Z1||(Z1={}));var oa;(e=>e.defaultData={type:"Mesh",...hi.defaultData,...pp.defaultData})(oa||(oa={}));var yp;(e=>e.defaultData={...hi.defaultData,...nh.identity,...ia.defaultData})(yp||(yp={}));var vp;(e=>{function r(t){return{...hi.defaultData,...fp.defaultData(t)}}e.defaultData=r})(vp||(vp={}));var xp;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:io.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wv.defaultData,states:new Ve,events:new Ve,...ia.defaultData},i.defaultMeshObject={name:"Rectangle",...hi.defaultData,...oa.defaultData,geometry:oo.defaultData("RectangleGeometry"),material:Fn.defaultTwoLayerData("basic","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...hi.defaultData,...oa.defaultData,geometry:oo.defaultData("BooleanGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...hi.defaultData,...oa.defaultData,geometry:oo.defaultData("TextGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")}))(xp||(xp={}));var rh;(t=>{function r(n,i){if(i===void 0)return n;let s={...n};return"material"in s&&"material"in i&&i.material&&(s.material=sv(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let u=o.layers.data(a);u&&Jo(u,l)}}).data),s.materials&&i.materials&&(s.materials=sv(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[u,c]of Object.entries(l.layers)){let h=o[a]?.layers?.data(u);h&&Jo(h,c)}}}).data),s}t.patchMaterialState=r;function e(n,i){if(i===void 0)return n;let s={...n};if(Object.assign(s,nh.merge(s,i)),Ri.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(n.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=r(s,i);else if(dp.is(n.type)){let o=i;o.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=Xn.clone(o.color))}return s}t.patch=e})(rh||(rh={}));var ih;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Xn.white,near:.1,far:2e3})(ih||(ih={}));var Zl;(e=>e.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})(Zl||(Zl={}));var vs;(e=>e.defaultData={orbitControls:Zl.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:1,stopMode:"manual",duration:5e3},web:{compress:!0,preset:1,preload:!0}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null})(vs||(vs={}));var qr;(e=>e.defaultData={ambientLight:{enabled:!0,type:"HemisphereLight",color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!1,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200})(qr||(qr={}));var bp;(n=>{function r(){let i=new Bt,s=xp.defaultMeshObject;return i.push({fi:-1,data:{...vp.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),i.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:s,children:[]}),i}n.defaultData={backgroundColor:pr.fromHexAndA(1184534,1),postprocessing:sa.defaultData,fog:ih.defaultData,objects:r(),environment:qr.defaultData,publish:vs.defaultData},n.emptyData=function(){return{backgroundColor:pr.fromHexAndA(1184534,1),postprocessing:sa.defaultData,fog:ih.defaultData,objects:new Bt,environment:qr.defaultData,publish:vs.defaultData}}})(bp||(bp={}));function aa(r,e){return Object.setPrototypeOf(r,e),r}var xG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),bG=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),wG=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||la&&"ontouchend"in document,SG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,AG=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,_G=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},TG=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},bK=xG(),la=bG(),sh=wG(),K1=SG(),vn=AG(),Kl=_G(),Jl=Number(TG());function J1(r){return Array.isArray(r)?r:[r]}function oh(r){return la?r.metaKey:r.ctrlKey}var $e=[],Sp={},ah={},wp={};function $1(r){$e.includes(r)||$e.push(r)}function $l(r){delete Sp[r.pointerId];for(let e=0;e<$e.length;e++)if($e[e].pointerId===r.pointerId){$e.splice(e,1);break}}function Ap(r){if(r.pointerType!=="touch")return;let e=Sp[r.pointerId];e===void 0&&(e={x:0,y:0},Sp[r.pointerId]=e),e.x=r.pageX,e.y=r.pageY}function _p(r){let e=r.pointerId===$e[0].pointerId?$e[1]:$e[0];return Sp[e.pointerId]}function e_(r){ah[r.key]=!0,wp[r.key]=wp[r.key]===void 0?1:wp[r.key]+1}function t_(r){if(la&&ah.Meta)for(let e in ah)ah[e]=!1;else ah[r.key]=!1;wp={}}function n_(r){r.addEventListener("pointerdown",$1,!0),r.addEventListener("pointerdown",Ap,!0),r.addEventListener("pointermove",Ap,!0),r.addEventListener("pointerup",$l,!0),r.addEventListener("pointercancel",$l,!0),r.addEventListener("pointerleave",$l,!0),window.addEventListener("keydown",e_,!0),window.addEventListener("keyup",t_,!0)}function r_(r){r.removeEventListener("pointerdown",$1,!0),r.removeEventListener("pointerdown",Ap,!0),r.removeEventListener("pointermove",Ap,!0),r.removeEventListener("pointerup",$l,!0),r.removeEventListener("pointercancel",$l,!0),r.removeEventListener("pointerleave",$l,!0),window.removeEventListener("keydown",e_,!0),window.removeEventListener("keyup",t_,!0)}var ec;(t=>{function r(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},aa(n,zt.prototype)}t.defaultColors=r;function e(){return{materials:new zt,images:new zt,colors:new zt,audios:new zt,fonts:new zt,penumbraSize:[.5,.5,.5]}}t.emptyData=e})(ec||(ec={}));function i_(r){r.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let t=e.colorA,n=e.colorB,i=[[t.r,t.g,t.b,t.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Vl(dr(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,o)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let t={...dr(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,t)}})}function Sv(r,e){Object.values(r.shared.materials).forEach(t=>e(t))}function Av(r,e){r.scene.objects.traverse((t,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&e(i)}):"material"in n&&typeof n.material!="string"&&e(n.material)})}function MG(r){Object.assign(r.scene.publish,{orbitControls:{...Zl.defaultData,...dr(r.scene.publish.orbitControls)}})}function EG(r){Object.assign(r.scene.publish.settings,{video:{...vs.defaultData.settings.video,...dr(r.scene.publish.settings.video)}})}function CG(r){function e(t){if(t.layers){for(let n of Object.values(t.layers))if(n){for(let[i,s]of Object.entries(n))if((mp.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(Q1.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((t,n)=>{n.states.forEach(i=>{let s=i;s.material?e(s.material):s.materials&&s.materials.forEach(o=>{e(o)})})})}function PG(r){r.scene.publish.withBackground=!0}function DG(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function IG(r){r.scene.objects.traverse((e,t)=>{let n=t.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function LG(r){r.scene.objects.traverse((e,t)=>{let n=t.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function OG(r){r.scene.objects.traverse((e,t)=>{let n=r.scene.objects.parent(e);t.type==="Mesh"&&(!n||r.scene.objects.data(n).geometry?.type!=="BooleanGeometry")&&(t.booleanExclude=null)})}function s_(r){r.layers===void 0&&Object.assign(r,Fn.defaultTwoLayerData("lambert"))}function _v(r){!r.layers||r.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let t=[...e.colors];t.push(e.colors[9]);let n=[...e.steps];n.push(e.steps[9]);let i={...dr(e),colors:t,steps:n};Object.assign(e,i)}})}function RG(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="BooleanGeometry"||t.geometry.type==="SubdivGeometry")&&(t.geometry.phongAngle=35)})}function o_(r){r.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(n=>{typeof n!="string"&&_v(n)}):"material"in t&&typeof t.material!="string"&&_v(t.material)}),Object.values(r.shared.materials).forEach(e=>_v(e))}function NG(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((e,t)=>{(t.type==="DirectionalLight"||t.type==="SpotLight")&&(t.shadowResolution=1024,t.shadowRadius=1,t.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function BG(r){r.shared.audios=aa({},zt.prototype)}function FG(r){let e=r.shared.materials;Object.entries(e).forEach(([t,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"basic",alpha:1,visible:!0,mode:0},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(e,{[t]:i})}})}function UG(r){Object.entries(dr(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(dr(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function GG(r){r.scene.publish.settings.web.preload=!1}function a_(r){r.layers&&r.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function zG(r){r.shared.fonts=aa({},zt.prototype)}function kG(r){return r.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(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function VG(r){let e=[];r.scene.objects.traverse((t,n)=>{let i=n;if(i.type==="TextFrame"){let s=Fn.defaultTwoLayerData("basic"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=kG(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...hi.defaultData,...oa.defaultData,flatShading:!1,wireframe:!1,geometry:{...oo.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:dr(i.states),events:dr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=dr(r.scene.objects).parent(t);r.scene.objects.insertAfter(u??null,t,[{id:t+"new",data:l,children:[]}]),e.push(t)}}),e.forEach(t=>{r.scene.objects.delete(t)})}function HG(r){let e={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((t,n)=>{n.events.forEach(i=>{if(!!e[Number(i.type)])if(Object.assign(i,{type:e[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new Ve,move:new Ve,jump:new Ve}});else{let s=new Ve;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Be.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Vl(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Ve({fi:0,id:Be.generateUUID(),data:u},{fi:1,id:Be.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function WG(r){r.scene.objects.traverse((e,t)=>{function n(i,s){let o=new Ve,a=[];if(t.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Vl(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Vl(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>t.events.delete(l)),o.length){let l=t.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):t.events.insertBefore(null,[{id:Be.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}var l_=21;function c_(r){let e=r.schema??0;e!==l_&&(console.warn("updating from ",e,"to ",l_),e<1&&(Av(r,i_),Sv(r,i_),r.schema=1),e<2&&(MG(r),r.schema=2),e<3&&(CG(r),r.schema=3),e<4&&(PG(r),r.schema=4),e<5&&(DG(r),r.schema=5),e<6&&(IG(r),r.schema=6),e<7&&(LG(r),r.schema=7),e<8&&(OG(r),r.schema=8),e<9&&(o_(r),r.schema=9),e<10&&(RG(r),r.schema=10),e<11&&(NG(r),r.schema=11),e<12&&(o_(r),r.schema=12),e<13&&(BG(r),r.schema=13),e<14&&(FG(r),r.schema=14),e<15&&(UG(r),r.schema=15),e<16&&(GG(r),r.schema=16),e<17&&(Av(r,a_),Sv(r,a_),r.schema=17),e<18&&(Av(r,s_),Sv(r,s_),r.schema=18),e<19&&(EG(r),r.schema=19),e<20&&(zG(r),VG(r),r.schema=20),e<21&&(HG(r),WG(r),r.schema=21))}var Tp;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Tp||(Tp={}));function xs(r,e=!1){let t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new De,u=0;for(let c=0;c<r.length;++c){let h=r[c],d=0;if(t!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(h.userData),e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(t){let c=0,h=[];for(let d=0;d<r.length;++d){let f=r[d].index;for(let m=0;m<f.count;++m)h.push(f.getX(m)+c);c+=r[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=u_(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][d]);let m=u_(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function u_(r){let e,t,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Ge(s,t,n)}var Mp;(t=>(t.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.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:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:-3e3,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 Ve,move:new Ve,jump:new Ve}}))(Mp||(Mp={}));var h_=Math.pow(2,-24);var ca=class{constructor(){}};function Xr(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Tv(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Mv(r,e){e.set(r)}function Ev(r,e,t){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function lh(r,e,t){for(let n=0;n<3;n++){let i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function nc(r){let e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function XG(r,e){if(!r.index){let t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;t>65535?i=new Uint32Array(new n(4*t)):i=new Uint16Array(new n(2*t)),r.setIndex(new Ge(i,1));for(let s=0;s<t;s++)i[s]=s}}function YG(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let e=[],t=new Set;for(let i of r.groups)t.add(i.start),t.add(i.start+i.count);let n=Array.from(t.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];e.push({offset:s/3,count:(o-s)/3})}return e}function Pv(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,v=i!==null;for(let y=e*6,w=(e+t)*6;y<w;y+=6){let b=r[y+0],S=r[y+1],_=b-S,M=b+S;_<s&&(s=_),M>l&&(l=M),v&&b<h&&(h=b),v&&b>m&&(m=b);let x=r[y+2],T=r[y+3],E=x-T,C=x+T;E<o&&(o=E),C>u&&(u=C),v&&x<d&&(d=x),v&&x>p&&(p=x);let P=r[y+4],O=r[y+5],I=P-O,N=P+O;I<a&&(a=I),N>c&&(c=N),v&&P<f&&(f=P),v&&P>g&&(g=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,v&&(i[0]=h,i[1]=d,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function QG(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=e*6,h=(e+t)*6;c<h;c+=6){let d=r[c+0];d<i&&(i=d),d>a&&(a=d);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let m=r[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function ZG(r,e,t,n,i){let s=t,o=t+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&e[s*6+l]<a;)s++;for(;s<=o&&e[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let h=e[s*6+u*2+0];e[s*6+u*2+0]=e[o*6+u*2+0],e[o*6+u*2+0]=h;let d=e[s*6+u*2+1];e[s*6+u*2+1]=e[o*6+u*2+1],e[o*6+u*2+1]=d}s++,o--}else return s}}var bs=32,KG=(r,e)=>r.candidate-e.candidate,ao=new Array(bs).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ep=new Float32Array(6);function JG(r,e,t,n,i,s){let o=-1,a=0;if(s===0)o=Tv(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===1)o=Tv(r),o!==-1&&(a=$G(t,n,i,o));else if(s===2){let l=nc(r),u=1.25*i,c=n*6,h=(n+i)*6;for(let d=0;d<3;d++){let f=e[d],g=(e[d+3]-f)/bs;if(i<bs/4){let v=[...ao];v.length=i;let y=0;for(let b=c;b<h;b+=6,y++){let S=v[y];S.candidate=t[b+2*d],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:x}=S;for(let T=0;T<3;T++)x[T]=1/0,x[T+3]=-1/0,M[T]=1/0,M[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0;lh(b,t,_)}v.sort(KG);let w=i;for(let b=0;b<w;b++){let S=v[b];for(;b+1<w&&v[b+1].candidate===S.candidate;)v.splice(b+1,1),w--}for(let b=c;b<h;b+=6){let S=t[b+2*d];for(let _=0;_<w;_++){let M=v[_];S>=M.candidate?lh(b,t,M.rightCacheBounds):(lh(b,t,M.leftCacheBounds),M.count++)}}for(let b=0;b<w;b++){let S=v[b],_=S.count,M=i-S.count,x=S.leftCacheBounds,T=S.rightCacheBounds,E=0;_!==0&&(E=nc(x)/l);let C=0;M!==0&&(C=nc(T)/l);let P=1+1.25*(E*_+C*M);P<u&&(o=d,u=P,a=S.candidate)}}else{for(let w=0;w<bs;w++){let b=ao[w];b.count=0,b.candidate=f+g+w*g;let S=b.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let w=c;w<h;w+=6){let _=~~((t[w+2*d]-f)/g);_>=bs&&(_=bs-1);let M=ao[_];M.count++,lh(w,t,M.bounds)}let v=ao[bs-1];Mv(v.bounds,v.rightCacheBounds);for(let w=bs-2;w>=0;w--){let b=ao[w],S=ao[w+1];Ev(b.bounds,S.rightCacheBounds,b.rightCacheBounds)}let y=0;for(let w=0;w<bs-1;w++){let b=ao[w],S=b.count,_=b.bounds,x=ao[w+1].rightCacheBounds;S!==0&&(y===0?Mv(_,Ep):Ev(_,Ep,Ep)),y+=S;let T=0,E=0;y!==0&&(T=nc(Ep)/l);let C=i-y;C!==0&&(E=nc(x)/l);let P=1+1.25*(T*y+E*C);P<u&&(o=d,u=P,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function $G(r,e,t,n){let i=0;for(let s=e,o=e+t;s<o;s++)i+=r[s*6+n*2];return i/t}function ez(r,e){let t=r.attributes.position,n=t.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=t.offset||0,l=3;t.isInterleavedBufferAttribute&&(l=t.data.stride);for(let u=0;u<s;u++){let c=u*3,h=u*6,d=i[c+0]*l+a,f=i[c+1]*l+a,m=i[c+2]*l+a;for(let p=0;p<3;p++){let g=n[d+p],v=n[f+p],y=n[m+p],w=g;v<w&&(w=v),y<w&&(w=y);let b=g;v>b&&(b=v),y>b&&(b=y);let S=(b-w)/2,_=p*2;o[h+_+0]=w+S,o[h+_+1]=S+(Math.abs(w)+S)*h_,w<e[p]&&(e[p]=w),b>e[p+3]&&(e[p+3]=b)}}return o}function tz(r,e){function t(v){d&&d(v/f)}function n(v,y,w,b=null,S=0){if(!m&&S>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),w<=c||S>=l)return t(y+w),v.offset=y,v.count=w,v;let _=JG(v.boundingData,b,o,y,w,h);if(_.axis===-1)return t(y+w),v.offset=y,v.count=w,v;let M=ZG(a,o,y,w,_);if(M===y||M===y+w)t(y+w),v.offset=y,v.count=w;else{v.splitAxis=_.axis;let x=new ca,T=y,E=M-y;v.left=x,x.boundingData=new Float32Array(6),Pv(o,T,E,x.boundingData,s),n(x,T,E,s,S+1);let C=new ca,P=M,O=w-E;v.right=C,C.boundingData=new Float32Array(6),Pv(o,P,O,C.boundingData,s),n(C,P,O,s,S+1)}return v}XG(r,e);let i=new Float32Array(6),s=new Float32Array(6),o=ez(r,i),a=r.index.array,l=e.maxDepth,u=e.verbose,c=e.maxLeafTris,h=e.strategy,d=e.onProgress,f=r.index.count/3,m=!1,p=[],g=YG(r);if(g.length===1){let v=g[0],y=new ca;y.boundingData=i,QG(o,v.offset,v.count,s),n(y,v.offset,v.count,s),p.push(y)}else for(let v of g){let y=new ca;y.boundingData=new Float32Array(6),Pv(o,v.offset,v.count,y.boundingData,s),n(y,v.offset,v.count,s),p.push(y)}return p}function p_(r,e){let t=tz(r,e),n,i,s,o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<t.length;c++){let h=t[c],d=l(h),f=new a(32*d);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,m=!!h.count,p=h.boundingData;for(let g=0;g<6;g++)n[d+g]=p[g];if(m){let g=h.offset,v=h.count;return i[d+6]=g,s[f+14]=v,s[f+15]=65535,c+32}else{let g=h.left,v=h.right,y=h.splitAxis,w;if(w=u(c+32,g),w/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=w/4,w=u(w,v),i[d+7]=y,w}}}var mr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};mr.prototype.setFromBox=function(){let r=new A;return function(t,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let h=t.dot(r);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var mJ=function(){let r=new mr;return function(t,n){let i=t.points,s=t.satAxes,o=t.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(r.setFromPoints(d,a),h.isSeparated(r))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(r.setFromPoints(d,i),h.isSeparated(r))return!1}}}();var nz=function(){let r=new A,e=new A,t=new A;return function(i,s,o){let a=i.start,l=r,u=s.start,c=e;t.subVectors(a,u),r.subVectors(i.end,s.start),e.subVectors(s.end,s.start);let h=t.dot(c),d=c.dot(l),f=c.dot(c),m=t.dot(l),g=l.dot(l)*f-d*d,v,y;g!==0?v=(h*d-m*f)/g:v=0,y=(h+v*d)/f,o.x=v,o.y=y}}(),ch=function(){let r=new B,e=new A,t=new A;return function(i,s,o,a){nz(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let h;u<0?h=s.start:h=s.end;let d=e,f=t;if(i.closestPointToPoint(h,!0,e),s.closestPointToPoint(c,!0,t),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),m_=function(){let r=new A,e=new A,t=new mn,n=new gn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){let v=p.projectPoint(l,e);if(o.containsPoint(v))return!0}return!1}}();var rz=1e-15;function rc(r){return Math.abs(r)<rz}var gr=class extends Mn{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new mr),this.points=[this.a,this.b,this.c],this.sphere=new En,this.plane=new mn,this.needsUpdate=!0}intersectsSphere(e){return m_(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(e,t),c.setFromPoints(u,i);let h=s[2],d=o[2];h.subVectors(t,n),d.setFromPoints(h,i);let f=s[3],m=o[3];f.subVectors(n,e),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};gr.prototype.closestPointToSegment=function(){let r=new A,e=new A,t=new gn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;t.start.copy(u[d]),t.end.copy(u[f]),ch(t,i,r,e),c=r.distanceToSquared(e),c<h&&(h=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(h)}}();gr.prototype.intersectsTriangle=function(){let r=new gr,e=new Array(3),t=new Array(3),n=new mr,i=new mr,s=new A,o=new A,a=new A,l=new A,u=new gn,c=new gn,h=new gn;return function(f,m=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,g=f.plane;if(Math.abs(p.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;t[0]=f.a,t[1]=f.b,t[2]=f.c;for(let S=0;S<4;S++){let _=v[S],M=y[S];if(n.setFromPoints(M,t),_.isSeparated(n))return!1}let w=f.satBounds,b=f.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){let _=w[S],M=b[S];if(n.setFromPoints(M,e),_.isSeparated(n))return!1}for(let S=0;S<4;S++){let _=y[S];for(let M=0;M<4;M++){let x=b[M];if(s.crossVectors(_,x),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return m&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let v=this.points,y=!1,w=0;for(let O=0;O<3;O++){let I=v[O],N=v[(O+1)%3];u.start.copy(I),u.end.copy(N),u.delta(o);let F=y?c.start:c.end,G=rc(g.distanceToPoint(I));if(rc(g.normal.dot(o))&&G){c.copy(u),w=2;break}if((g.intersectLine(u,F)||G)&&!rc(F.distanceTo(N))){if(w++,y)break;y=!0}}if(w===1&&this.containsPoint(c.start))return m&&(m.start.copy(c.start),m.end.copy(c.start)),!0;if(w!==2)return!1;let b=f.points,S=!1,_=0;for(let O=0;O<3;O++){let I=b[O],N=b[(O+1)%3];u.start.copy(I),u.end.copy(N),u.delta(a);let F=S?h.start:h.end,G=rc(p.distanceToPoint(I));if(rc(p.normal.dot(a))&&G){h.copy(u),_=2;break}if((p.intersectLine(u,F)||G)&&!rc(F.distanceTo(N))){if(_++,S)break;S=!0}}if(_===1&&this.containsPoint(h.start))return m&&(m.start.copy(h.start),m.end.copy(h.start)),!0;if(_!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let O=h.start;h.start=h.end,h.end=O}let M=c.start.dot(o),x=c.end.dot(o),T=h.start.dot(o),E=h.end.dot(o),C=x<T,P=M<E;return M!==E&&T!==x&&C===P?!1:(m&&(l.subVectors(c.start,h.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(h.end)),!0)}}}();gr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();gr.prototype.distanceToTriangle=function(){let r=new A,e=new A,t=["a","b","c"],n=new gn,i=new gn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=t[h],m=o[f];this.closestPointToPoint(m,r),d=m.distanceToSquared(r),d<c&&(c=d,a&&a.copy(r),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,r),d=p.distanceToSquared(r),d<c&&(c=d,a&&a.copy(p),l&&l.copy(r))}for(let h=0;h<3;h++){let d=t[h],f=t[(h+1)%3];n.set(this[d],this[f]);for(let m=0;m<3;m++){let p=t[m],g=t[(m+1)%3];i.set(o[p],o[g]),ch(n,i,r,e);let v=r.distanceToSquared(e);v<c&&(c=v,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}}();var yr=class extends Mt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new be,this.invMatrix=new be,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new mr),this.alignedSatBounds=new Array(3).fill().map(()=>new mr),this.needsUpdate=!1}set(e,t,n){super.set(e,t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};yr.prototype.update=function(){return function(){let e=this.matrix,t=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=i[d];f.x=u?n.x:t.x,f.y=c?n.y:t.y,f.z=h?n.z:t.z,f.applyMatrix4(e)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=i[d];c.subVectors(a,f),h.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();yr.prototype.intersectsBox=function(){let r=new mr;return function(t){this.needsUpdate&&this.update();let n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,t),c.isSeparated(r))return!1}return!0}}();yr.prototype.intersectsTriangle=function(){let r=new gr,e=new Array(3),t=new mr,n=new mr,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let d=0;d<3;d++){let f=a[d],m=l[d];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],m=c[d];if(t.setFromPoints(m,h),f.isSeparated(t))return!1}for(let d=0;d<3;d++){let f=l[d];for(let m=0;m<4;m++){let p=c[m];if(i.crossVectors(f,p),t.setFromPoints(i,e),n.setFromPoints(i,h),t.isSeparated(n))return!1}}return!0}}();yr.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();yr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();yr.prototype.distanceToBox=function(){let r=["x","y","z"],e=new Array(12).fill().map(()=>new gn),t=new Array(12).fill().map(()=>new gn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,h=o.min,d=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let v=f[g];i.copy(v).clamp(h,d);let y=v.distanceToSquared(i);if(y<m&&(m=y,l&&l.copy(v),u&&u.copy(i),y<c))return Math.sqrt(y)}let p=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){let w=(g+1)%3,b=(g+2)%3,S=v<<w|y<<b,_=1<<g|v<<w|y<<b,M=f[S],x=f[_];e[p].set(M,x);let E=r[g],C=r[w],P=r[b],O=t[p],I=O.start,N=O.end;I[E]=h[E],I[C]=v?h[C]:d[C],I[P]=y?h[P]:d[C],N[E]=d[E],N[C]=v?h[C]:d[C],N[P]=y?h[P]:d[C],p++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){i.x=g?d.x:h.x,i.y=v?d.y:h.y,i.z=y?d.z:h.z,this.closestPointToPoint(i,n);let w=i.distanceToSquared(n);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(i),w<c))return Math.sqrt(w)}for(let g=0;g<12;g++){let v=e[g];for(let y=0;y<12;y++){let w=t[y];ch(v,w,n,i);let b=n.distanceToSquared(i);if(b<m&&(m=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}}return Math.sqrt(m)}}();var Pp=new A,Dp=new A,Ip=new A,g_=new B,y_=new B,v_=new B,x_=new A;function iz(r,e,t,n,i,s){let o;return s===un?o=r.intersectTriangle(n,t,e,!0,i):o=r.intersectTriangle(e,t,n,s!==tr,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function sz(r,e,t,n,i,s,o){Pp.fromBufferAttribute(e,n),Dp.fromBufferAttribute(e,i),Ip.fromBufferAttribute(e,s);let a=iz(r,Pp,Dp,Ip,x_,o);if(a){t&&(g_.fromBufferAttribute(t,n),y_.fromBufferAttribute(t,i),v_.fromBufferAttribute(t,s),a.uv=Mn.getUV(x_,Pp,Dp,Ip,g_,y_,v_,new B));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};Mn.getNormal(Pp,Dp,Ip,l.normal),a.face=l,a.faceIndex=n}return a}function Iv(r,e,t,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=sz(t,r.attributes.position,r.attributes.uv,o,a,l,e);return u?(u.faceIndex=n,i&&i.push(u),u):null}function b_(r,e,t,n,i,s){for(let o=n,a=n+i;o<a;o++)Iv(r,e,t,o,s)}function w_(r,e,t,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Iv(r,e,t,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Lv(r,e,t){return r===null||(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r.distance<t.near||r.distance>t.far)?null:r}function Yr(r,e,t,n){let i=r.a,s=r.b,o=r.c,a=e,l=e+1,u=e+2;t&&(a=t.getX(e),l=t.getX(e+1),u=t.getX(e+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function Ov(r,e,t,n,i,s,o){let a=t.index,l=t.attributes.position;for(let u=r,c=e+r;u<c;u++)if(Yr(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var ic=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function ws(r,e){return e[r+15]===65535}function ua(r,e){return e[r+6]}function sc(r,e){return e[r+14]}function oc(r){return r+8}function ac(r,e){return e[r+6]}function S_(r,e){return e[r+7]}var lc=new Mt,Op=new A,az=["x","y","z"];function Rp(r,e,t,n,i){let s=r*2,o=cc,a=lo,l=co;if(ws(s,a)){let c=ua(r,l),h=sc(s,a);b_(e,t,n,c,h,i)}else{let c=oc(r);Bp(c,o,n,Op)&&Rp(c,e,t,n,i);let h=ac(r,l);Bp(h,o,n,Op)&&Rp(h,e,t,n,i)}}function Np(r,e,t,n){let i=r*2,s=cc,o=lo,a=co;if(ws(i,o)){let u=ua(r,a),c=sc(i,o);return w_(e,t,n,u,c)}else{let u=S_(r,a),c=az[u],d=n.direction[c]>=0,f,m;d?(f=oc(r),m=ac(r,a)):(f=ac(r,a),m=oc(r));let g=Bp(f,s,n,Op)?Np(f,e,t,n):null;if(g){let w=g.point[c];if(d?w<=s[m+u]:w>=s[m+u+3])return g}let y=Bp(m,s,n,Op)?Np(m,e,t,n):null;return g&&y?g.distance<=y.distance?g:y:g||y||null}}var A_=function(){let r,e,t=[],n=new ic(()=>new Mt);return function(...o){r=n.getPrimitive(),e=n.getPrimitive(),t.push(r,e);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(e),t.pop(),t.pop();let l=t.length;return l>0&&(e=t[l-1],r=t[l-2]),a};function i(s,o,a,l,u=null,c=0,h=0){function d(w){let b=w*2,S=lo,_=co;for(;!ws(b,S);)w=oc(w),b=w*2;return ua(w,_)}function f(w){let b=w*2,S=lo,_=co;for(;!ws(b,S);)w=ac(w,_),b=w*2;return ua(w,_)+sc(b,S)}let m=s*2,p=cc,g=lo,v=co;if(ws(m,g)){let w=ua(s,v),b=sc(m,g);return Xr(s,p,r),l(w,b,!1,h,c+s,r)}else{let w=oc(s),b=ac(s,v),S=w,_=b,M,x,T,E;if(u&&(T=r,E=e,Xr(S,p,T),Xr(_,p,E),M=u(T),x=u(E),x<M)){S=b,_=w;let G=M;M=x,x=G,T=E}T||(T=r,Xr(S,p,T));let C=ws(S*2,g),P=a(T,C,M,h+1,c+S),O;if(P===2){let G=d(S),U=f(S)-G;O=l(G,U,!0,h+1,c+S,T)}else O=P&&i(S,o,a,l,u,c,h+1);if(O)return!0;E=e,Xr(_,p,E);let I=ws(_*2,g),N=a(E,I,x,h+1,c+_),F;if(N===2){let G=d(_),U=f(_)-G;F=l(G,U,!0,h+1,c+_,E)}else F=N&&i(_,o,a,l,u,c,h+1);return!!F}}}(),__=function(){let r=new gr,e=new gr,t=new be,n=new yr,i=new yr;return function s(o,a,l,u,c=null){let h=o*2,d=cc,f=lo,m=co;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),ws(h,f)){let g=a,v=g.index,y=g.attributes.position,w=l.index,b=l.attributes.position,S=ua(o,m),_=sc(h,f);if(t.copy(u).invert(),l.boundsTree)return Xr(o,d,i),i.matrix.copy(t),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:x=>i.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(u),x.b.applyMatrix4(u),x.c.applyMatrix4(u),x.needsUpdate=!0;for(let T=S*3,E=(_+S)*3;T<E;T+=3)if(Yr(e,T,v,y),e.needsUpdate=!0,x.intersectsTriangle(e))return!0;return!1}});for(let M=S*3,x=_+S*3;M<x;M+=3){Yr(r,M,v,y),r.a.applyMatrix4(t),r.b.applyMatrix4(t),r.c.applyMatrix4(t),r.needsUpdate=!0;for(let T=0,E=w.count;T<E;T+=3)if(Yr(e,T,w,b),e.needsUpdate=!0,r.intersectsTriangle(e))return!0}}else{let g=o+8,v=m[o+6];return Xr(g,d,lc),!!(c.intersectsBox(lc)&&s(g,a,l,u,c)||(Xr(v,d,lc),c.intersectsBox(lc)&&s(v,a,l,u,c)))}}}();function Bp(r,e,t,n){return Xr(r,e,lc),t.intersectBox(lc,n)}var Rv=[],Lp,cc,lo,co;function uc(r){Lp&&Rv.push(Lp),Lp=r,cc=new Float32Array(r),lo=new Uint16Array(r),co=new Uint32Array(r)}function uh(){Lp=null,cc=null,lo=null,co=null,Rv.length&&uc(Rv.pop())}var Nv=Symbol("skip tree generation"),Bv=new Mt,Fv=new Mt,hc=new be,ha=new yr,hh=new yr,dh=new A,Fp=new A,lz=new A,cz=new A,uz=new A,T_=new Mt,Ni=new ic(()=>new gr),Jt=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Jt.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let n=e.geometry,i=e._roots,s=n.getIndex(),o;return t.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(e,t,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Jt.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=e,o=new Jt(t,{...n,[Nv]:!0});if(o._roots=s,n.setIndex){let a=t.getIndex();if(a===null){let l=new Ge(e.index,1,!1);t.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Nv]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Nv]||(this._roots=p_(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Mt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,n=t.index.array,i=t.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,h,d=0,f=this._roots;for(let p=0,g=f.length;p<g;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),h=new Float32Array(l),m(0,d),d+=l.byteLength;function m(p,g,v=!1){let y=p*2;if(c[y+15]===65535){let b=u[p+6],S=c[y+14],_=1/0,M=1/0,x=1/0,T=-1/0,E=-1/0,C=-1/0;for(let P=3*b,O=3*(b+S);P<O;P++){let I=n[P]*a+o,N=s[I+0],F=s[I+1],G=s[I+2];N<_&&(_=N),N>T&&(T=N),F<M&&(M=F),F>E&&(E=F),G<x&&(x=G),G>C&&(C=G)}return h[p+0]!==_||h[p+1]!==M||h[p+2]!==x||h[p+3]!==T||h[p+4]!==E||h[p+5]!==C?(h[p+0]=_,h[p+1]=M,h[p+2]=x,h[p+3]=T,h[p+4]=E,h[p+5]=C,!0):!1}else{let b=p+8,S=u[p+6],_=b+g,M=S+g,x=v,T=!1,E=!1;e?x||(T=e.has(_),E=e.has(M),x=!T&&!E):(T=!0,E=!0);let C=x||T,P=x||E,O=!1;C&&(O=m(b,g,x));let I=!1;P&&(I=m(S,g,x));let N=O||I;if(N)for(let F=0;F<3;F++){let G=b+F,Y=S+F,U=h[G],z=h[G+3],Q=h[Y],V=h[Y+3];h[p+F]=U<Q?U:Q,h[p+F+3]=z>V?z:V}return N}}}traverse(e,t=0){let n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=i[a+6],d=s[u+14];e(l,c,new Float32Array(n,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];e(l,c,new Float32Array(n,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(e,t=Gr){let n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,u=o?t.side:t;for(let c=0,h=n.length;c<h;c++){let d=a?t[l[c].materialIndex].side:u,f=s.length;if(uc(n[c]),Rp(0,i,d,e,s),uh(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(e,t=Gr){let n=this._roots,i=this.geometry,s=t.isMaterial,o=Array.isArray(t),a=null,l=i.groups,u=s?t.side:t;for(let c=0,h=n.length;c<h;c++){let d=o?t[l[c].materialIndex].side:u;uc(n[c]);let f=Np(0,i,d,e);uh(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(e,t){let n=this.geometry,i=!1;for(let s of this._roots)if(uc(s),i=__(0,n,e,t),uh(),i)break;return i}shapecast(e,t,n){let i=this.geometry;if(e instanceof Function){if(t){let d=t;t=(f,m,p,g)=>{let v=m*3;return d(f,v,v+1,v+2,p,g)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Ni.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=e;if(l&&u){let d=l;l=(f,m,p,g,v)=>d(f,m,p,g,v)?!0:Ov(f,m,i,u,p,g,s)}else l||(u?l=(d,f,m,p)=>Ov(d,f,i,u,m,p,s):l=(d,f,m)=>m);let c=!1,h=0;for(let d of this._roots){if(uc(d),c=A_(0,i,a,l,o,h),uh(),c)break;h+=d.byteLength}return Ni.releasePrimitive(s),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=e.geometry.index,u=e.geometry.attributes.position;hc.copy(t).invert();let c=Ni.getPrimitive(),h=Ni.getPrimitive();if(s){let f=function(m,p,g,v,y,w,b,S){for(let _=g,M=g+v;_<M;_++){Yr(h,_*3,l,u),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let x=m,T=m+p;x<T;x++)if(Yr(c,x*3,o,a),c.needsUpdate=!0,s(c,h,x,_,y,w,b,S))return!0}return!1};if(i){let m=i;i=function(p,g,v,y,w,b,S,_){return m(p,g,v,y,w,b,S,_)?!0:f(p,g,v,y,w,b,S,_)}}else i=f}e.getBoundingBox(Fv),Fv.applyMatrix4(t);let d=this.shapecast({intersectsBounds:f=>Fv.intersectsBox(f),intersectsRange:(f,m,p,g,v,y)=>(Bv.copy(y),Bv.applyMatrix4(hc),e.shapecast({intersectsBounds:w=>Bv.intersectsBox(w),intersectsRange:(w,b,S,_,M)=>i(f,m,w,b,g,v,_,M)}))});return Ni.releasePrimitive(c),Ni.releasePrimitive(h),d}intersectsBox(e,t){return ha.set(e.min,e.max,t),ha.needsUpdate=!0,this.shapecast({intersectsBounds:n=>ha.intersectsBox(n),intersectsTriangle:n=>ha.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),ha.set(e.boundingBox.min,e.boundingBox.max,t),ha.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=e.attributes.position,h=e.index,d=Ni.getPrimitive(),f=Ni.getPrimitive(),m=Fp,p=lz,g=null,v=null;i&&(g=cz,v=uz);let y=1/0,w=null,b=null;return hc.copy(t).invert(),hh.matrix.copy(hc),this.shapecast({boundsTraverseOrder:S=>ha.distanceToBox(S),intersectsBounds:(S,_,M)=>M<y&&M<o?(_&&(hh.min.copy(S.min),hh.max.copy(S.max),hh.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>hh.distanceToBox(M),intersectsBounds:(M,x,T)=>T<y&&T<o,intersectsRange:(M,x)=>{for(let T=M*3,E=(M+x)*3;T<E;T+=3){Yr(f,T,h,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let C=S*3,P=(S+_)*3;C<P;C+=3){Yr(d,C,u,l),d.needsUpdate=!0;let O=d.distanceToTriangle(f,m,g);if(O<y&&(p.copy(m),v&&v.copy(g),y=O,w=C/3,b=T/3),O<s)return!0}}}});{let M=h?h.count:c.count;for(let x=0,T=M;x<T;x+=3){Yr(f,x,h,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let E=S*3,C=(S+_)*3;E<C;E+=3){Yr(d,E,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,m,g);if(P<y&&(p.copy(m),v&&v.copy(g),y=P,w=E/3,b=x/3),P<s)return!0}}}}}),Ni.releasePrimitive(d),Ni.releasePrimitive(f),y===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=y,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(hc),p.applyMatrix4(hc),i.distance=p.sub(i.point).length(),i.faceIndex=b),n)}closestPointToPoint(e,t={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(dh.copy(e).clamp(c.min,c.max),dh.distanceToSquared(e)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(e,dh);let d=e.distanceToSquared(dh);return d<a&&(Fp.copy(dh),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return t.point?t.point.copy(Fp):t.point=Fp.clone(),t.distance=u,t.faceIndex=l,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Xr(0,new Float32Array(n),T_),e.union(T_)}),e}},M_=Jt.prototype.raycast;Jt.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[e,t,n,i]=r;return M_.call(this,n,e.material).forEach(o=>{o=Lv(o,e,t),o&&i.push(o)}),i}else return M_.apply(this,r)};var E_=Jt.prototype.raycastFirst;Jt.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[e,t,n]=r;return Lv(E_.call(this,n,e.material),e,t)}else return E_.apply(this,r)};var C_=Jt.prototype.closestPointToPoint;Jt.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let e=r[1],t={};return r[1]=t,C_.apply(this,r),e&&e.copy(t.point),t.distance}else return C_.apply(this,r)};var P_=Jt.prototype.closestPointToGeometry;Jt.prototype.closestPointToGeometry=function(...r){let e=r[2],t=r[3];if(e&&e.isVector3||t&&t.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,P_.apply(this,r),e&&e.copy(n.point),t&&t.copy(i.point).applyMatrix4(s),n.distance}else return P_.apply(this,r)};var D_=Jt.prototype.refit;Jt.prototype.refit=function(...r){let e=r[0],t=r[1];if(t&&(t instanceof Set||Array.isArray(t))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;t.forEach(i=>n.add(i)),e&&e.forEach(i=>n.add(i)),D_.call(this,n)}else D_.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let e=Jt.prototype[r];Jt.prototype[r]=function(...t){return(t[0]===null||t[0].isMesh)&&(t.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),e.apply(this,t)}});var Uv=class extends ht{},Up=class extends Uv{constructor(t){super();this.object=t;this.matrixAutoUpdate=!0}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return!0}get isLight(){return!1}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){return this.object.geometry}get material(){return this.object.material}};var fh=class extends ht{constructor(t,n={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=hp.defaultData(i.toArray(),s),Jo(this.parameters,n),this.update(),this.setHideBase(this.parameters.hideBase)}setHideBase(t){this.parameters.hideBase=t}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)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let n=0,i=t-this.children.length;n<i;++n){let s=new Up(this.object);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let n=0,i=this.children.length-t;n<i;++n)this.remove(this.children[0])}_updateRadial(t){let n=t.radial,i=n.start*Be.DEG2RAD,s=n.end*Be.DEG2RAD,o=i-s,a=new Qt(n.rotation[0]*Be.DEG2RAD,n.rotation[1]*Be.DEG2RAD,n.rotation[2]*Be.DEG2RAD),l;switch(n.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[u,c]of this.children.entries()){c.scale.x=n.scale[0],c.scale.y=n.scale[1],c.scale.z=n.scale[2],c.position.setScalar(0);let h=o/t.count*u-i;switch(n.axis){case"x":c.rotation.set(0,h,0);break;case"y":c.rotation.set(0,0,h);break;case"z":c.rotation.set(h,0,0);break}c.translateOnAxis(l,n.radius),c.position.x+=n.position[0],c.position.y+=n.position[1],c.position.z+=n.position[2],n.alignment===!0?(c.rotation.x+=a.x,c.rotation.y+=a.y,c.rotation.z+=a.z):c.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let n=t.linear,i=new Qt(n.rotation[0]*Be.DEG2RAD,n.rotation[1]*Be.DEG2RAD,n.rotation[2]*Be.DEG2RAD);for(let[s,o]of this.children.entries())o.scale.x=1+(n.scale[0]-1)*s,o.scale.y=1+(n.scale[1]-1)*s,o.scale.z=1+(n.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=n.position[0]*s,o.position.y=n.position[1]*s,o.position.z=n.position[2]*s}_updateGrid(t){let n=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let u=0;u<i.count[2];u++){let c=this.children[n++];c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=i.size[0]*a-o.x,c.position.y=i.size[1]*l-o.y,c.position.z=i.size[2]*u-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[n++];l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),Jo(this.parameters,t),this.update(),this}};var Bi=r=>{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new ur(30,30,30),e};var Gp=new oi,Gv=new En,I_=new be,Fi=(r,e,t,n,i=!1)=>{let s=e,o=r.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Gv.copy(s.boundingSphere),Gv.applyMatrix4(o),t.ray.intersectsSphere(Gv)===!1||(I_.copy(o).invert(),Gp.copy(t.ray).applyMatrix4(I_),s.boundingBox!==null&&Gp.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,m,p;if(i===!1){let v=Math.max(0,f.start),y=Math.min(h.count,f.start+f.count);for(m=v,p=y;m<p;m+=3)if(l=h.getX(m),u=h.getX(m+1),c=h.getX(m+2),a=g(r,t,Gp,d,l,u,c),a){a.faceIndex=Math.floor(m/3),n.push(a);return}}else{let y=s.attributes.position,w=new A,b=new A,S=new A,_=new A,M=2,T=1/((r.scale.x+r.scale.y+r.scale.z)/3),E=T*T,C=Math.max(0,f.start),P=Math.min(y.count,f.start+f.count);for(let O=C,I=P-1;O<I;O+=M){if(w.fromBufferAttribute(y,O),b.fromBufferAttribute(y,O+1),Gp.distanceSqToSegment(w,b,_,S)>E)continue;_.applyMatrix4(r.matrixWorld);let F=t.ray.origin.distanceTo(_);F<t.near||F>t.far||n.push({distance:F,point:S.clone().applyMatrix4(r.matrixWorld),object:r})}}function g(v,y,w,b,S,_,M){let x=new A,T=new A,E=new A,C=new A,P=new A;if(x.fromBufferAttribute(b,S),T.fromBufferAttribute(b,_),E.fromBufferAttribute(b,M),w.intersectTriangle(x,T,E,!1,C)===null)return null;P.copy(C),P.applyMatrix4(v.matrixWorld);let I=y.ray.origin.distanceTo(P);return I<y.near||I>y.far?null:{faceIndex:1,distance:I,point:P.clone(),object:v}}};var zp=new A,Qr=new ai,zv=class extends Vs{constructor(t){let n=new De,i=new zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Le(15711266),u=new Le(15711266),c=new Le(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(f,m,p){d(f,p),d(m,p)}function d(f,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}n.setAttribute("position",new Ae(s,3)),n.setAttribute("color",new Ae(o,3));super(n,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,n=this.pointMap,i=!0;Qr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;di("n1",n,t,Qr,-s,-o,a),di("n2",n,t,Qr,s,-o,a),di("n3",n,t,Qr,-s,o,a),di("n4",n,t,Qr,s,o,a);let l=a;di("f1",n,t,Qr,-s,-o,l),di("f2",n,t,Qr,s,-o,l),di("f3",n,t,Qr,-s,o,l),di("f4",n,t,Qr,s,o,l);let u=l,c=.5;di("u1",n,t,Qr,s*.7*c,o*1.1,u),di("u2",n,t,Qr,-s*.7*c,o*1.1,u),di("u3",n,t,Qr,0,o*(1.1+.9*c),u),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function di(r,e,t,n,i,s,o){zp.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],zp.x,zp.y,zp.z)}}var kp=class extends Bi(zv){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,n){Fi(this.object,this.geometry,t,n,!0)}};var dc=class extends Bi(uf){constructor(t,n=15,i=10066329){super(t,n,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,n){Fi(this.object,dc.geometryHelper,t,n)}};var fc=class extends Bi(hf){constructor(t,n=15){super(n);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,n){Fi(this.object,fc.geometryHelper,t,n)}update(){}};var pc=class extends Bi(cf){constructor(t,n=15,i=6710886){super(t,n,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,n){Fi(this.object,pc.geometryHelper,t,n)}};var Vp=class extends Bi(lf){constructor(t,n=6710886){super(t,n);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,n){Fi(this.object,Vp.geometryHelper,t,n)}update(){if(this.object!==void 0){let t=Vp._vector,n=this.object.distance?this.object.distance:1e3,i=n*Math.tan(this.object.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},ph=Vp;ph._vector=new A;var mh=1e-12,mc=class{constructor(e){this.position=new B;this.startPosition=new B;this.uuid=Be.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new mc(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},gc=class extends mc{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new gc(this.parent).copy(this)}},fi=class extends mc{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new gc(this),new gc(this))}static create(t,n){let i=new fi(t,new B(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(t){let n=this.controls.indexOf(t);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(t,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new fi(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[t,n]}computeNormals(t=new B,n=new B){let[i,s]=this.computeTangents();return i&&s&&(L_(i,t),L_(s,n)),[t,n]}computeTangent(t=new B){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new B){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function L_(r,e=new B){let t=r.length();return e.set(-r.y/t,r.x/t)}var Vv=r=>r,yc=new B,Hp=new B,dz=new B,fz=new B,pz=new B,mz=new B,R_=new A,N_=new A;function B_(r){let e=new B;e.addVectors(r.v0,yc.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new B;return t.addVectors(r.v2,Hp.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new Wn(r.v0,e,t,r.v2)}function gh(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function gz(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function yz(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function Hv(r,e,t){let n=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function F_(r,e,t){return O_(r,e)&&O_(e,t)&&kv(r.position,e.position,t.position)}function kv(r,e,t){return yc.copy(e).sub(r).cross(Hp.copy(t).sub(r))===0}function U_(r,e,t,n,i){let s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),o=(r.y+e.y)/2,a=(r.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(r.y-e.y)/s,u=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function G_(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function z_(r,e,t,n,i,s){let o=e.x-r.x,a=e.y-r.y,l=t.x-r.x,u=t.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return Hv(e,r,t)>Math.PI&&(c*=-1),gh(u,a)?h=(a+u)*(n/c-.5)*8/3/(o-l):h=(o+l)*(n/c-.5)*8/3/(u-a),i.set(e.x-h*a,e.y+h*o),s.set(t.x+h*u,t.y-h*l),[i,s]}function Wv(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function O_(r,e){return kv(r.position,r.controls[1].position,e.position)&&kv(r.position,e.controls[0].position,e.position)}function k_(r,e,t,n,i=.5){let s=yc.subVectors(e,r).multiplyScalar(i).add(r),o=Hp.subVectors(t,e).multiplyScalar(i).add(e),a=dz.subVectors(n,t).multiplyScalar(i).add(t),l=s,u=fz.subVectors(o,s).multiplyScalar(i).add(s),c=pz.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=mz.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,n.x,n.y]}function V_(r,e,t=12,n=!0){let i=N_.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let u=Vv(e[l]),c=yc,h=uo(u,t);a.push(h);for(let d=0;d<=h;d++)if(u instanceof Wn||u instanceof Er||u instanceof jn){if(u.getPoint(d/h,c),i.set(c.x,c.y,0),s!==void 0&&yz(s,i))continue;s===void 0&&(s=R_),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function H_(r,e,t,n=12,i=!0){let s=N_.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let u,c=Vv(e[l]),h=yc,d=uo(c,n);a.push(d);for(let f=0;f<=d;f++)if(c instanceof Wn||c instanceof Er||c instanceof jn){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=R_:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function jv(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=uo(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=uo(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=uo(r[0].roundedCurveCorner,e)*.5),n}function uo(r,e=12){return r&&r instanceof ko?e*2:r&&(r instanceof jn||r instanceof Mu)?1:r&&r instanceof Ja?e*r.points.length:e}function W_(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Vv(e[o]),l=uo(a,t),u=yc;for(let c=0;c<=l;c++)if(a instanceof Wn||a instanceof Er||a instanceof jn){if(a.getPoint(c/l,u),i!==void 0&&gz(i,u,mh))continue;i===void 0&&(i=Hp),i.copy(u),r.push(u.x,u.y),s++}}return gh(r[0],r[r.length-2],mh)&&gh(r[1],r[r.length-1],mh)&&(r.pop(),r.pop()),n&&s>1&&!(gh(r[s-1],r[1],mh)&&gh(r[s-2],r[0],mh))&&(r.push(r[0],r[1]),s++),r}var qv=new B,vz=new B,xz=new B,bz=new B,wz=new B,Sz=new B,gt=class extends ds{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Lt;this.plane=new mn(new A(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=Be.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new gt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>fi.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>gt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(t){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(t);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=t-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let n=this.points.indexOf(t);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...t]}applySize(t,n){t===0&&(t=.001),n===0&&(n=.001),this._width=t,this._height=n}applyScale(t,n){let i=qv.set(t,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,n);this._update(!1)}createPoint(t,n=0,i=Be.generateUUID()){let s;t instanceof B?s=t:s=new B(t,n);let o=new fi(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,n){this.points.splice(n,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===t)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let n=this.points.indexOf(t);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(t){let n=this.points.find(i=>i.uuid===t);n&&this.removePoint(n)}update(t=!0){for(let n=0,i=this.shapeHoles.length;n<i;n++)this.shapeHoles[n].update(!1);this._update(t)}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return V_(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=jv(this.points,t,!1),this.roundedCurveDivisions=jv(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return H_(t,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),W_(t,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(t,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=uo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(t,n,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(Wv(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(qv.set(i.x,i.y))/h}let u=0;for(let h=0;h<t;h++)u+=a[h];return(n-u)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,n){Wv(n,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,n.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,n.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let n=this.getLastPoint();if(n?.curveAfter&&(n.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],u=this.points[s+1]??this.points[0],c=a.roundness,h=l&&u&&F_(l,a,u);if(!a.controlsMoved()&&c>0&&!h){let d=a.curveBefore,f=a.curveAfter;if(d===void 0||f===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=d.getLength(),v=f.getLength(),y=Math.min(c,g*.499),w=Math.min(c,v*.499),b=Math.min(y,w),S=1-b/g,_=b/v,M=d.getPointAt(S,qv),x=f.getPointAt(_,vz);this._subSplitCurve(d,m,S,M,void 0),this._subSplitCurve(f,p,_,void 0,x);let T;if(this.useCubicForRoundedCorners){let E=Hv(M,a.position,x)/2,C=Math.tan(E)*M.distanceTo(a.position),[P,O]=U_(M,x,C,xz,bz),I=G_(P,O,a.position),[N,F]=z_(I,M,x,C,wz,Sz);T=new Wn(M.clone(),N.clone(),F.clone(),x.clone())}else T=new Er(M.clone(),a.position.clone(),x.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,n,i,s,o){if(t instanceof jn)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=t,l=n,u=a.getUtoTmapping(i,0),c=k_(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let t=new gt(this._width,this._height);return t.points=this.points.map(n=>n.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(n=>n.clone()),t}toJSON(){return{points:this.points.reduce((t,n)=>t.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let n=t.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],u=t.points[s+3],c=t.points[s+4],h=t.points[s+5],d=t.points[s+6],f=new fi(Be.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new gt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof Wn&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof Er&&(s[a]=B_(s[a]));for(a=0,l=s.length;a<l;a++){let h=s[a],d=a>0?s[a-1]:null,f;h instanceof Wn?(f=this.createPoint(h.v0),f.controls[1].position.copy(h.v1)):h instanceof jn&&(f=this.createPoint(h.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Wn?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof jn&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(t.curves),t instanceof ds&&(this.shapeHoles=t.holes.map(s=>{let o=new gt;return o.fromShape(s),o})),this.update(),this}};var It;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(It||(It={}));var xn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(xn||(xn={}));function We(r,e){if(!r)throw e||"Assertion Failed!"}var ze=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},r.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},r.edgeGoesLeft=function(e){return r.vertLeq(e.Dst,e.Org)},r.edgeGoesRight=function(e){return r.vertLeq(e.Org,e.Dst)},r.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},r.edgeEval=function(e,t,n){We(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-n.t)*(i/(i+s)):t.t-n.t+(n.t-e.t)*(s/(i+s)):0},r.edgeSign=function(e,t,n){We(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){We(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-n.s)*(i/(i+s)):t.s-n.s+(n.s-e.s)*(s/(i+s)):0},r.transSign=function(e,t,n){We(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),yh=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Wp=function(){function r(e){this.side=e,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(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),vc=function(){function r(){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 r}(),j_=function(){function r(){var e=new vc,t=new yh,n=new Wp(0),i=new Wp(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Wp(0),n=new Wp(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},r.prototype.splice_=function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},r.prototype.makeVertex_=function(e,t,n){var i=e;We(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},r.prototype.makeFace_=function(e,t,n){var i=e;We(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=n.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},r.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,n=e.Sym.next;t.Sym.next=n,n.Sym.next=t},r.prototype.killVertex_=function(e,t){var n=e.anEdge,i=n;do i.Org=t,i=i.Onext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.killFace_=function(e,t){var n=e.anEdge,i=n;do i.Lface=t,i=i.Lnext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var e=new vc,t=new vc,n=new yh,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(e,t){var n=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new vc;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new yh;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},r.prototype.delete=function(e){var t=e.Sym,n=!1;if(e.Lface!==e.Rface&&(n=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!n){var i=new yh;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},r.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),n=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new vc;return this.makeVertex_(i,n,t.Org),t.Lface=n.Lface=e.Lface,t},r.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),n=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,n),e.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=e.Rface,n.winding=e.winding,n.Sym.winding=e.Sym.winding,n.idx=e.idx,n.Sym.idx=e.Sym.idx,n},r.prototype.connect=function(e,t){var n=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!n){var o=new yh;this.makeFace_(o,i,e.Lface)}return i},r.prototype.zapFace=function(e){var t=e.anEdge,n,i,s,o,a;i=t.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(e){var t=e.anEdge,n=0;do n++,t=t.Lnext;while(t!==e.anEdge);return n},r.prototype.mergeConvexFaces=function(e){var t,n,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(n=t.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&ze.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&ze.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var e=this.fHead,t=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=e,s=e;(i=s.next)!==e;s=i){We(i.prev===s),l=i.anEdge;do We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l),We(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(We(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){We(o.prev===a),l=o.anEdge;do We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l),We(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(We(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)We(l.Sym.next===u.Sym),We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Org!==null),We(l.Dst!==null),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l);We(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),q_=function(){function r(){this.handle=null}return r}(),X_=function(){function r(){this.key=null,this.node=0}return r}(),Az=function(){function r(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var n=0;n<e+1;n++)this.nodes[n]=new q_,this.handles[n]=new X_;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(n[t[o+1].handle].key,n[t[o].handle].key)&&++o,We(o<=this.max),s=t[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new q_;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new X_}return this.freeList===0?n=t:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[t].handle=n,this.handles[n].node=t,this.handles[n].key=e,this.initialized&&this.floatUp_(t),n},r.prototype.extractMin=function(){var e=this.nodes,t=this.handles,n=e[1].handle,i=t[n].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;We(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),Xv=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),Y_=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),_z=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new Y_,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new Y_;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),Tz=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?ze.vertLeq(s.Org,o.Org)?ze.edgeSign(o.Dst,s.Org,o.Org)<=0:ze.edgeSign(s.Dst,o.Org,s.Org)>=0:ze.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ze.edgeSign(s.Dst,i,s.Org)>=0;var a=ze.edgeEval(s.Dst,i,s.Org),l=ze.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&We(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){We(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new Xv;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case It.ODD:return(t&1)!==0;case It.NONZERO:return t!==0;case It.POSITIVE:return t>0;case It.NEGATIVE:return t<0;case It.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,u,c,h=!0;u=n;do We(ze.vertLeq(u.Org,u.Dst)),r.addRegionBelow(e,t,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(e.mesh.splice(u.Oprev,u),e.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!h&&r.checkForRightSplice(e,l)&&(r.addWinding(u,c),r.deleteRegion(e,l),e.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,We(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=ze.vertL1dist(t,e),s=ze.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(ze.vertLeq(i.Org,s.Org)){if(ze.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ze.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(ze.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(We(!ze.vertEq(i.Dst,s.Dst)),ze.vertLeq(i.Dst,s.Dst)){if(ze.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(ze.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,h,d=new vc,f,m;if(We(!ze.vertEq(u,l)),We(ze.edgeSign(l,e.event,o)<=0),We(ze.edgeSign(u,e.event,a)>=0),We(o!==e.event&&a!==e.event),We(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(ze.vertLeq(o,a)){if(ze.edgeSign(u,o,a)>0)return!1}else if(ze.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),ze.intersect(l,o,u,a,d),We(Math.min(o.t,l.t)<=d.t),We(d.t<=Math.max(a.t,u.t)),We(Math.min(u.s,l.s)<=d.s),We(d.s<=Math.max(a.s,o.s)),ze.vertLeq(d,e.event)&&(d.s=e.event.s,d.t=e.event.t),f=ze.vertLeq(o,a)?o:a,ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ze.vertEq(d,o)||ze.vertEq(d,a)?(r.checkForRightSplice(e,t),!1):!ze.vertEq(l,e.event)&&ze.edgeSign(l,e.event,d)>=0||!ze.vertEq(u,e.event)&&ze.edgeSign(u,e.event,d)<=0?u===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),m=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(ze.edgeSign(l,e.event,d)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),ze.edgeSign(u,e.event,d)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,u),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),ze.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),u=!0),ze.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),u=!0),u){r.addRightEdges(e,t,n.Onext,s,s,!0);return}ze.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,ze.vertEq(i.Org,n)){We(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!ze.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}We(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(We(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),ze.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,u=new Xv;if(u.eUp=t.anEdge.Sym,n=e.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,ze.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=ze.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var c=e.mesh.connect(a.Dnext,t.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);We(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new Xv,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new _z(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(We(t.fixUpperEdge),We(++n===1)),We(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,ze.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new Az(s,ze.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,We(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!ze.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),Mz=function(){function r(){this.mesh=new j_,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=It.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 r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],u[g]=s,m[g]=t,l[g]=s,f[g]=t;for(t=p.next;t!==p;t=t.next)for(var v=0;v<3;++v)s=t.coords[v],s<u[v]&&(u[v]=s,m[v]=t),s>l[v]&&(l[v]=s,f[v]=t);var y=0;if(l[1]-u[1]>l[0]-u[0]&&(y=1),l[2]-u[2]>l[y]-u[y]&&(y=2),u[y]>=l[y]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=m[y],i=f[y],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)h[0]=t.coords[0]-i.coords[0],h[1]=t.coords[1]-i.coords[1],h[2]=t.coords[2]-i.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,e[0]=d[0],e[1]=d[1],e[2]=d[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=e.next;u!==e;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;ze.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;ze.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(ze.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(ze.edgeGoesLeft(i.Lnext)||ze.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(ze.edgeGoesRight(n.Lprev)||ze.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var u=e.vHead.next;u!==e.vHead;u=u.next)u.n=-1;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,t===xn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=e.vHead.next;u!==e.vHead;u=u.next)if(u.n!==-1){var h=u.n*i;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],i>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(t===xn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[d++]=-1}}},r.prototype.outputContours_=function(e,t){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],t>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new j_),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i<t.length;i+=e)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=t[i+0],n.Org.coords[1]=t[i+1],e>2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=It.ODD),t===void 0&&(t=xn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),Tz.computeInterior(this,o);var a=this.mesh;return t===xn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===xn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function da(r){var e=r.windingRule,t=e===void 0?It.ODD:e,n=r.elementType,i=n===void 0?xn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,h=r.contours,d=h===void 0?[]:h,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!d&&m)throw new Error("Contours can't be empty");if(!!d){var v=new Mz;r.edgeCreateCallback&&(v.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(v.vertexIdCallback=r.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(t,i,o,l,c,m),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var Eee=It.ODD,Cee=It.NONZERO,Pee=It.POSITIVE,Dee=It.NEGATIVE,Iee=It.ABS_GEQ_TWO,Lee=xn.POLYGONS,Oee=xn.CONNECTED_POLYGONS,Ree=xn.BOUNDARY_CONTOURS;var xc=class extends De{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=It.ODD;this.elementType=xn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:It.ODD,elementType:xn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,v=s[g+0],y=s[g+1];if(c!==void 0&&v!==c&&(l=!1),h!==void 0&&y!==h&&(u=!1),c=v,h=y,!l&&!u)break}!l&&!u&&(a=da({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,v=-1/0;for(let b=0,S=d;b<S;b++){let _=b*2,M=a.vertices[_+0],x=a.vertices[_+1];M<m&&(m=M),M>p&&(p=M),x<g&&(g=x),x>v&&(v=x)}let y=p-m,w=v-g;for(let b=0,S=d;b<S;b++){let _=b*2,M=a.vertices[_+0],x=a.vertices[_+1],T=(M-m)/y,E=(x-g)/w;this._positionAttribute.setXYZ(b,M,x,0),this._normalAttribute.setXYZ(b,0,0,1),this._uvAttribute.setXY(b,T,E)}for(let b=0,S=f;b<S;b++){let _=b*3,M=a.elements[_+0],x=a.elements[_+1],T=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,x),this._indexAttribute.setX(_+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new xc(this._shape,this._curveSegments);return t.userData=Hu(this.userData),t}};var jp=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*jp.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let n=e*jp.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let u=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},vh=jp;vh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Yv=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),bc=class extends De{constructor(t,n,i=0,s=12,o=3,a=It.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(x=>{let T=x.extractShapePointsToFlatArray([],s),E=[];for(let C=T.length-1;C>=1;C-=2){let P=T[C-1],O=T[C-0];E.push(P,O)}return E}),c=da({windingRule:a,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=da({windingRule:It.ODD,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!c)throw new Error("error generating geometry");let d=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let x=0;x<h.elements.length;x++){let T=h.elements[x],E=x%2===0?c.vertexCount:0;c.elements.push(T+E)}for(let x=0;x<h.vertexIndices.length;x++){let T=h.vertexIndices[x],E=c.vertexCount;c.vertexIndices.push(T+E)}for(let x=0;x<h.vertices.length;x++){let T=h.vertices[x];c.vertices.push(T)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let x=0,T=c.vertexCount;x<T;x++){let E=x*2,C=c.vertices[E+0],P=c.vertices[E+1];C<f&&(f=C),C>m&&(m=C),P<p&&(p=P),P>g&&(g=P)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p;let v=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new vh(v);let y=[],w=[];for(let x=c.elementCount-1;x>=0;x--){let T=x>=d,E=x*2,C=c.elements[E+0],P=c.elements[E+1],O=C+P,I={start:C,count:P,normals:[],continuous:[],concave:[]},N=C,F=O-1,G=C+1,Y=this._shape.roundedCurves.length;do{let V=N-C,k=c.vertices[F*2+0],j=c.vertices[F*2+1],q=c.vertices[N*2+0],W=c.vertices[N*2+1],he=c.vertices[G*2+0],ie=c.vertices[G*2+1],K=q-k,X=W-j,ne=Math.sqrt(K*K+X*X);K/=ne,X/=ne;let ce=q-he,oe=W-ie,Te=Math.sqrt(ce*ce+oe*oe);ce/=Te,oe/=Te,I.normals[V*2+0]=-oe,I.normals[V*2+1]=ce,I.concave[V]=K*oe-X*ce>0;let me=c.vertexIndices[N];if(Array.isArray(me))I.continuous[V]=!1;else{let[ge,ye]=this._shape.getCurveIndexFromVertexId(me-1,!0);if(ye>0&&ye<1)I.continuous[V]=!0;else{let de=ye===1?ge+1:ge-1;de=(de+Y)%Y;let Pe=ye===1?0:1,Ne=this._shape.roundedCurves[ge].getTangent(ye),Ze=this._shape.roundedCurves[de].getTangent(Pe);I.continuous[V]=Ne.dot(Ze)>.95}}T&&(I.normals[V*2+0]*=-1,I.normals[V*2+1]*=-1),[F,N,G]=[N,G,G+1],G>=O&&(G-=P)}while(G!==C+1);let U=[];U.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(C*2,O*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((V,k)=>[k,k]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(C*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let k=V/this._bevelSegments*Math.PI/2,j=(1-Math.cos(k))*this._bevelSize,q=[],W=[],he=[],ie=[],K=0;for(let ne=0;ne<P;ne++){let ce=ne*2,oe=(ne-1+P)%P*2,Te=c.vertices[I.start*2+ce+0],me=c.vertices[I.start*2+ce+1],ge=-I.normals[oe+0]*j,ye=-I.normals[oe+1]*j,de=-I.normals[ce+0]*j,Pe=-I.normals[ce+1]*j;if(I.concave[ne]||!I.concave[ne]&&T){let Ne=Math.atan2(ye,ge),Ze=Math.atan2(Pe,de);Ze>Ne&&(Ze-=Math.PI*2);let R=Ze-Ne;if(I.continuous[ne]||T){let D=Ne+R/2,J=Math.cos(D)*j,le=Math.sin(D)*j;q[2*K+0]=Te+J*(T?-1:1),q[2*K+1]=me+le*(T?-1:1),ie[K]=ne,K++}else{let D=Math.max(1,Math.floor(s/4*Math.abs(R)/Math.PI));for(let J=0;J<=D;J++){let le=Ne+R*(J/D),fe=Math.cos(le)*j,Ee=Math.sin(le)*j;q[2*K+0]=Te+fe,q[2*K+1]=me+Ee,ie[K]=ne,K++}}}else q[2*K+0]=Te+ge,q[2*K+1]=me+ye,ie[K]=ne,W[ne]=K,K++,q[2*K+0]=Te,q[2*K+1]=me,ie[K]=ne,K++,q[2*K+0]=Te+de,q[2*K+1]=me+Pe,ie[K]=ne,he[ne]=K,K++}let X=da({windingRule:It.POSITIVE,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[q],edgeCreateCallback:ne=>{let oe=ne.Org.idx,Te=ie[oe],me=ie[(oe+1)%ie.length];ne.idx=[Te,me],ne.Sym.idx=[me,Te]},vertexIdCallback:ne=>{let ce=ne.Lprev.idx;return[ce?ce[1]:0,ne.idx[0]]}});if(!X)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!X.vertexCount)break;for(let ne=0;ne<X.vertexIndices.length;ne++){let[ce,oe]=X.vertexIndices[ne];if(ce===oe)continue;let Te=oe;oe<ce&&(Te+=P);for(let me=ce;me<Te;me++){let ge=me%P,ye=(me+1)%P;if(!I.continuous[ge]||!I.continuous[ye]){X.vertexIndices[ne]=[ce,ge],X.vertexIndices.splice(ne+1,0,[ye,oe]),X.vertices.splice((ne+1)*2,0,X.vertices[ne*2],X.vertices[ne*2+1]);break}}}U.push({bevelI:V,angle:k,size:j,boundary:X,reverseMap:ie,insetPoints:q})}let z=(V,k,j)=>{let q=0,W=V.boundary.vertexIndices.length;for(;q<W&&j(V.boundary.vertexIndices[k]);)k=(k+1)%W,q++;return q},Q=y.length;for(let V=1;V<U.length;V++){let k=U[V-1],j=U[V],q=k.boundary.vertexIndices.length,W=j.boundary.vertexIndices.length;if(!q||!W)break;let he=I.concave.length,ie=0,K=Yv(ie,P);for(;!k.boundary.vertexIndices.filter(K).length||!j.boundary.vertexIndices.filter(K).length;)ie++,K=Yv(ie,P);let X=k.boundary.vertexIndices.findIndex(K),ne=j.boundary.vertexIndices.findIndex(K);do X=(X+1)%q;while(K(k.boundary.vertexIndices[X]));do ne=(ne+1)%W;while(K(j.boundary.vertexIndices[ne]));ie=(ie+1)%P;let ce=ie,oe=this.buildBevelVert(I,k,(X-1+q)%q),Te=this.buildBevelVert(I,j,(ne-1+W)%W),me=oe,ge=Te,ye,de,Pe=!1;do{K=Yv(ie,P);let Ne=z(k,X,K),Ze=z(j,ne,K),R=Pe;if(Pe=!1,Ne&&!Ze){for(let D=0;D<Ne;D++)ye=this.buildBevelVert(I,k,(X+D)%q,D/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye;Pe=!0}else if(!Ne&&Ze)for(let D=0;D<Ze;D++)de=this.buildBevelVert(I,j,(ne+D)%W,D/(Ze-1)),y.push(ge.topN,me.topP,de.topP),y.push(me.bottomP,ge.bottomN,de.bottomP),ge=de;else if(Ne&&Ze)if(ye=this.buildBevelVert(I,k,X,0),de=this.buildBevelVert(I,j,ne,0),R?(y.push(me.topN,de.topP,ge.topN),y.push(me.topN,ye.topP,de.topP),y.push(de.bottomP,me.bottomN,ge.bottomN),y.push(de.bottomP,ye.bottomP,me.bottomN)):(y.push(ge.topN,me.topN,ye.topP),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,me.bottomN,ge.bottomN),y.push(ye.bottomP,ge.bottomN,de.bottomP)),me=ye,ge=de,Ne===Ze)for(let D=1;D<Ne;D++)ye=this.buildBevelVert(I,k,(X+D)%q,D/(Ne-1)),de=this.buildBevelVert(I,j,(ne+D)%W,D/(Ze-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,me.bottomN,ge.bottomN),y.push(ye.bottomP,ge.bottomN,de.bottomP),me=ye,ge=de;else if(Ne>Ze){let D=Ne/Ze,J=0;for(let le=1;le<Ne;le++)ye=this.buildBevelVert(I,k,(X+le)%q,le/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye,le>(J+1)*D&&(J++,de=this.buildBevelVert(I,j,(ne+J)%W,J/(Ze-1)),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,de.bottomP),ge=de)}else{let D=Ze/Ne,J=0;for(let le=1;le<Ze;le++)de=this.buildBevelVert(I,j,(ne+le)%W,le/(Ze-1)),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,de.bottomP),ge=de,le>(J+1)*D&&(J++,ye=this.buildBevelVert(I,k,(X+J)%q,J/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye)}X=(X+Ne)%q,ne=(ne+Ze)%W,ie=(ie+1)%he}while(ie!==ce)}{let V=U[0];for(let k=0,j=V.boundary.vertexCount;k<j;k++){let q=this.buildBevelVert(I,V,k),W=this.buildBevelVert(I,V,(k+1)%j);y.push(W.topP,q.topN,q.bottomN),y.push(W.topP,q.bottomN,W.bottomP)}}if(T){let V=[];for(let k=y.length-1;k>=Q+2;k-=3){let j=y[k-2],q=y[k-1],W=y[k-0];V.push(W,q,j)}y.splice(Q,y.length-Q,...V)}if(T){let V=[];for(let k=U[U.length-1].boundary.vertices.length-1;k>=1;k-=2){let j=U[U.length-1].boundary.vertices[k-1],q=U[U.length-1].boundary.vertices[k-0];V.push(j,q)}w.push(V)}if(!T){let V=U[U.length-1],k=da({windingRule:U.length>1?It.POSITIVE:It.ODD,elementType:xn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...w]});if(!k)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let j=0;j<k.elementCount*3;j+=3){let q=this.buildSurfaceVert(k,k.elements[j+0]),W=this.buildSurfaceVert(k,k.elements[j+1]),he=this.buildSurfaceVert(k,k.elements[j+2]);y.push(q.top,W.top,he.top),y.push(he.bottom,W.bottom,q.bottom)}}this.vertexCache={}}this._buffer.shrink();let b=new Ge(Uint32Array.from(y),1),S=new Ge(this._buffer.positions,3),_=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,_.needsUpdate=!0,M.needsUpdate=!0,b.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",_),this.setAttribute("uv",M),this.setIndex(b)}buildSurfaceVert(t,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[n*2+0],o=t.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,h=u*2,d={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[h+0]=a,this._buffer.uvs[h+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[h+2]=a,this._buffer.uvs[h+3]=l,this.vertexCache[i]=d,d}buildBevelVert(t,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,h,d;a!==l?(c=a,u=l,d=!1,h=t.continuous[c]&&t.continuous[u]):(u=a,c=(u-1+t.count)%t.count,d=t.concave[u]&&n.bevelI>0,h=t.continuous[u]||d);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=u*2,v=c*2,y=n.boundary.vertices[p+0],w=n.boundary.vertices[p+1],b=(1-m)*this._bevelSize,S=(y-this._minX)/this._width,_=(w-this._minY)/this._height,M=t.normals[g+0],x=t.normals[g+1],T=t.normals[v+0],E=t.normals[v+1];if(d){let N=T-M,F=E-x;M=M+N*(1-s),x=x+F*(1-s);let G=Math.sqrt(M*M+x*x);M/=G,x/=G}let C=this._buffer.get(h?2:4),P=C*3,O=C*2,I={i,fi:u,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=w,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=M*f,this._buffer.normals[P+1]=x*f,this._buffer.normals[P+2]=m,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=w,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=M*f,this._buffer.normals[P+4]=x*f,this._buffer.normals[P+5]=-m,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S,h||(C+=2,P+=6,O+=4,I.topP=C+0,I.bottomP=C+1,this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=w,this._buffer.positions[P+2]=this._depth-b,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=E*f,this._buffer.normals[P+2]=m,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=w,this._buffer.positions[P+5]=b,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=E*f,this._buffer.normals[P+5]=-m,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S),this.vertexCache[o]=I,I}clone(){let t=new bc(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Hu(this.userData),t}};var Un=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:It.ODD},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=r.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof gt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new gt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update(!1));let l=o??new gt(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return e<=0?a=new xc(r.shape,i,{windingRule:o}):a=new bc(r.shape,e,t,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var Z_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=t.radiusTop??n,s=t.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=r.parameters,m;return h||f?m=new xh(u,c,n,i,s,o,a,l*Math.PI/180,h,h,d,f):m=new Ho(u,c,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function ho(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function Q_(r){return new B(r.y,-r.x)}var xh=class extends De{constructor(e,t,n,i,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],v=[],y=0,w=n/2,b=new A,S=new A;f&&e==0&&(e=u),f&&t==0&&(t=c);let _=new B(e,w),M=new B(t,-w),x=null,T=null,E=null,C=null,P=_.clone().sub(M),O=0,I=0,N=0;d>0&&(O=Math.min(e,t)*(1-d),I=e-O,N=t-O);let F=_.clone();F.x-=O;let G=Math.PI-P.angle(),Y=P.angle(),U=Math.tan(Y/2),z=Math.tan(G/2),Q=U+z,V=d?Q:z,k=d?Q:U;if(u=Math.min(u,(e-I)/V,P.length()/Q),c=Math.min(c,(t-N)/k,P.length()/Q),u>0){let K=u/U;x=_.clone().sub(new B(K,u)),d&&(E=x.clone(),E.x-=O-Q*u),_.sub(P.clone().setLength(K))}if(c>0){let K=c/z;T=M.clone().sub(new B(K,-c)),M.add(P.clone().setLength(K)),d&&(C=T.clone(),C.x-=O-Q*c,F.sub(P.clone().setLength(K)))}P=_.clone().sub(M);let j=P.length()<.5,q=[];for(let K=0;K<=i;K++){let X=[],ne=K/i,ce=ne*l+a,oe=new B(Math.sin(ce),Math.cos(ce));C&&T?(W(X,ne,oe,G,c,C,-1,!0),W(X,ne,oe,Y,c,T,-1,!1)):T?(he(X,oe,T.x,0,-1),W(X,ne,oe,Y,c,T,-1,!1)):o||he(X,oe,t,N,-1);let Te=Q_(P).normalize();if(ho(Te,oe,b),!j)for(let me=0;me<=s;me++){let ge=me/s,ye=P.clone().multiplyScalar(ge).add(M);ho(ye,oe,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),v.push(ne,.5+S.y/n),X.push(y++)}if(E&&x?(W(X,ne,oe,G,u,x,1,!1),W(X,ne,oe,Y,u,E,1,!0)):x?(W(X,ne,oe,G,u,x,1,!1),he(X,oe,x.x,0,1)):o||he(X,oe,e,I,1),d&&!j){let me=Q_(P).multiplyScalar(-1).normalize();ho(me,oe,b);for(let ge=0;ge<=s;ge++){let ye=ge/s,de=P.clone().multiplyScalar(-ye).add(F);ho(de,oe,S),p.push(S.x,S.y,S.z),g.push(b.x,b.y,b.z),v.push(ne,.5+S.y/n),X.push(y++)}}d&&!o&&X.push(X[0]),q.push(X)}for(let K=0;K<q.length-1;K++)for(let X=0;X<q[0].length-1;X++){if(o&&d&&X==s)continue;let ne=q[K][X],ce=q[K+1][X],oe=q[K+1][X+1],Te=q[K][X+1],me=p[oe*3+0],ge=p[oe*3+2];m.push(ne,ce,Te),(me!=0||ge!=0)&&m.push(ce,oe,Te)}l<Math.PI*2&&(ie(-1,q[0],a),ie(1,q[q.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(v,2));function W(K,X,ne,ce,oe,Te,me,ge){for(let ye=0;ye<h+1;ye++){let de=ye/h,Pe=me<0?de:1-de;ge&&(Pe-=1),Pe*=ce;let Ne=new B(Math.sin(Pe),Math.cos(Pe)*me),Ze=Ne.clone().multiplyScalar(oe).add(Te);ho(Ze,ne,S),p.push(S.x,S.y,S.z),ho(Ne,ne,b),g.push(b.x,b.y,b.z),v.push(X,.5+S.y/n),K.push(y++)}}function he(K,X,ne,ce,oe){let Te=new A,me=new B,ge=[ne,ce];oe<0&&ge.reverse();for(let ye of ge)me.set(ye,w*oe),ho(me,X,Te),p.push(Te.x,Te.y,Te.z),g.push(0,oe,0),v.push(.5,.5),K.push(y++)}function ie(K,X,ne){let ce=new B(Math.sin(ne),Math.cos(ne)),oe=new B(-Math.cos(ne),Math.sin(ne)),Te=new A,me=K<0?(de,Pe,Ne)=>m.push(de,Pe,Ne):(de,Pe,Ne)=>m.push(de,Ne,Pe),ge=new B((e+t+I+N)/4,0);ho(ge,ce,Te),p.push(Te.x,Te.y,Te.z),g.push(oe.x,0,oe.y),v.push(.5,.5);let ye=y++;for(let de of X){let Pe=p.slice(de*3,de*3+3);p.push(...Pe),g.push(oe.x,0,oe.y);let Ne=v.slice(de*2,de*2+2);v.push(...Ne),y++}for(let de=ye+1;de<y-1;de++)me(ye,de,de+1);me(ye,y-1,ye+1)}}};var K_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=r.parameters,d;return u>0||c>0||l<360?d=new xh(0,e/2,n,i,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new el(e/2,n,i,s,o),d.scale(1,1,t/e),Object.assign(d,{userData:{...r,type:"ConeGeometry"}})}};var J_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new ur(e,t,n,i,s,o):u=new Zv(e,t,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},Qv=Math.PI/2,Zv=class extends De{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let c=[],h=[],d=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(v("z","y","x",-1,-1,1,n,t,e,o,0),v("z","y","x",1,-1,-1,n,t,e,o,1),v("z","y","x",-1,1,-1,n,t,e,o,1),v("z","y","x",1,1,1,n,t,e,o,0),v("x","y","z",-1,-1,-1,e,t,n,i,0),v("x","y","z",1,-1,1,e,t,n,i,1),v("x","y","z",-1,1,1,e,t,n,i,0),v("x","y","z",1,1,-1,e,t,n,i,1),v("y","x","z",-1,-1,1,t,e,n,s,0),v("y","x","z",1,-1,-1,t,e,n,s,1),v("y","x","z",1,1,1,t,e,n,s,1),v("y","x","z",-1,1,-1,t,e,n,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(d,3)),this.setAttribute("uv",new Ae(f,2));function g(w,b,S,_,M,x,T,E,C,P,O){let I=(x-2*a)/C,N=(T-2*a)/P,F=x/2-a,G=T/2-a,Y=E/2,U=C+1,z=P+1,Q=0,V=0,k=new A;for(let j=0;j<z;j++){let q=j*N-G;for(let W=0;W<U;W++){let he=W*I-F;k[w]=he*_,k[b]=q*M,k[S]=Y,h.push(k.x,k.y,k.z),k[w]=0,k[b]=0,k[S]=E>0?1:-1,d.push(k.x,k.y,k.z),f.push(W/C),f.push(1-j/P),Q+=1}}for(let j=0;j<P;j++)for(let q=0;q<C;q++){let W=m+q+U*j,he=m+q+U*(j+1),ie=m+(q+1)+U*(j+1),K=m+(q+1)+U*j;c.push(W,he,K),c.push(he,ie,K),V+=6}u.addGroup(p,V,O),p+=V,m+=Q}function v(w,b,S,_,M,x,T,E,C,P,O){let I=(T-2*a)/P,N=T/2-a,F=E/2-a,G=C/2,Y=P+1,U=0,z=0,Q=new A,V=new A;for(let k=0;k<l+1;k++){let j=k/l*Qv,q=Math.sin(j)*a,W=(1-Math.cos(j))*a,he=Math.sin(j),ie=Math.cos(j);Q[b]=(F+q)*M,Q[S]=(G-W)*x,V[w]=0,V[b]=he*Math.sign(Q[b]),V[S]=ie*Math.sign(Q[S]);for(let K=0;K<Y;K++){let X=K*I-N;Q[w]=X*_,h.push(Q.x,Q.y,Q.z),d.push(V.x,V.y,V.z),f.push(K/P),f.push(0),U+=1}}for(let k=0;k<l;k++)for(let j=0;j<P;j++){let q=m+j+Y*k,W=m+j+Y*(k+1),he=m+(j+1)+Y*(k+1),ie=m+(j+1)+Y*k;c.push(q,W,ie),c.push(W,he,ie),z+=6}u.addGroup(p,z,O),p+=z,m+=U}function y(w,b,S){let _=new A,M=new A(e/2,t/2,n/2);M.subScalar(a);let x=[],T=w*b*S>0?(C,P,O)=>c.push(C,P,O):(C,P,O)=>c.push(C,O,P);for(let C=0;C<=l;C++){let P=[],O=Qv*(1-C/l),I=Math.cos(O),N=Math.sin(O),F=0;for(let G=0;G<=C;G++){let Y=Math.cos(F),U=Math.sin(F);_.x=I*Y,_.y=N,_.z=I*U;let z=M.clone().addScaledVector(_,a);h.push(w*z.x,b*z.y,S*z.z),d.push(w*_.x,b*_.y,S*_.z),f.push(0,0),P.push(m++),F+=Qv/C}x.push(P)}let E=x.length-1;for(let C=0;C<E;C++){let P=x[C],O=x[C+1],I=P.length-1;T(P[0],O[1],O[0]);for(let N=1;N<=I;N++)T(P[N-1],P[N],O[N]),T(P[N],O[N+1],O[N])}}}};var fo=class extends De{constructor(e=[],t=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new Mn,v=s*i,y=i-v,w=o+1,b=new A,S=(U,z)=>b.subVectors(U,z).normalize(),_=(U,z)=>Array(U).fill(void 0).map(z),M=_(e.length/3,(U,z)=>new A().fromArray(e,z*3).setLength(i)),x=[],T=1e6;for(let U=0;U<M.length;U++){let z=M[U],Q=[],V,k,j,q=1e10,W=-1;for(;(W=t.indexOf(U,W+1))!=-1;){let X=W-W%3;V=t[X+(W+1)%3],k=t[X+(W+2)%3],j=z.distanceToSquared(M[V]),q=Math.min(q,j),Q.push([V,k,j])}q+=1e-6;let he=[],ie=0,K=Q.length;for(let X=0;X<K;X++){[V,k,j]=Q[ie];let ne=x[V]?.includes(U)==!0;j<=q&&he.push(V+ +ne*T),ie=Q.findIndex(ce=>ce[0]==k)}x.push(he)}let E=[];{let U=0,z=0,Q,V,k=f==3;for(let j=0;j<=o;j++){Q=j*(j+1)/2,V=(j+1)*(j+2)/2;for(let q=0;q<o-j;q++)[U,z]=[Q+q+j+2,V+q+j+3],E.push(Q,V,...k?[z,Q]:[U,V],z,U),[Q,V]=[U,z];E.push(Q,V,Q+o+2)}}let C=m.clone(),P=m.clone(),O=m.clone(),I=m.clone(),N=m.clone(),F=[],G=_(M.length,()=>_(f,()=>m.clone()));for(let U=0;U<M.length;U++){m.copy(M[U]).normalize(),C.copy(m).multiplyScalar(y);let z=x[U];for(let he=0;he<z.length;he++){let ie=z[he],K=z[(he+1)%f];g.setFromPointsAndIndices(M,U,ie%T,K%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,G[U][he])}let Q=[],V=[],k=[],j=new A;o==0&&[...G[U]].reduce((he,ie)=>he.add(ie),j).multiplyScalar(1/f);for(let he=0;he<f;he++){let ie=[],K=(he-1+f)%f,X=G[U][K],ne=G[U][he];m.copy(X).sub(C),p.copy(ne).sub(C);let ce=C.angleTo(m),oe=m.angleTo(p),Te=Math.cos(ce)*v;o==0?P.copy(j):P.copy(C).setLength(y+Te),V.push(Te);let me=[P,X,ne];for(let ge=0;ge<2;ge++){let ye=me[ge],de=me[ge+1];I.subVectors(ye,C),N.subVectors(de,C),O.crossVectors(I,N).normalize();for(let Pe=0;Pe<w;Pe++){let Ne=[ce,oe][ge]*Pe/w;m.copy(I).applyAxisAngle(O,Ne).add(C),Q.push(m.clone()),ge&&(S(m,C),ie.push([Pe==0?ye:m.clone(),b.clone()]))}ge&&(S(de,C),ie.push([de,b.clone()]))}k.push(ie)}F.push(k);let q=2*w,W=2;for(let he=0;he<f;he++){let ie=q*he,K=q*((he+1)%f),X=[Q[ie]];for(let ce=1;ce<w;ce++){I=Q[ie+ce],N=Q[K+ce],X.push(I);for(let oe=1,Te=ce-W+1;oe<=Te;oe++)m.lerpVectors(I,N,oe/(Te+1)),m.sub(C).setLength(V[he]).add(C),X.push(m.clone());X.push(N)}for(let ce=0;ce<w;ce++)X.push(Q[ce+w+ie]);X.push(Q[K+w]);let ne=E.map(ce=>X[ce]);a.push(...ne.map(ce=>[ce.x,ce.y,ce.z]).flat()),u.push(...ne.map(ce=>(S(ce,C),[b.x,b.y,b.z])).flat())}}let Y=[];for(let U=0;U<x.length;U++)for(let z=0;z<f;z++){let Q=x[U][z];if(Q<T){let V=x[Q].findIndex(q=>q%T==U),k=F[U][z],j=F[Q][V];for(let q=0;q<w;q++){let W=k[q],he=j[w-q],ie=k[q+1],K=j[w-(q+1)];[W,he,ie,ie,he,K].forEach(X=>{a.push(X[0].x,X[0].y,X[0].z),u.push(X[1].x,X[1].y,X[1].z)})}Y.push(k[0][0],j[w][0],k[w][0],j[0][0])}}for(;Y.length;){let U,z,Q,V;[U,z]=Y.splice(0,2);let k=[U];for(;U!=z;)k.push(z),Q=Y.indexOf(z),V=Q%2,z=Y.splice(Q-V,2)[1-V];b.subVectors(k[0],k[1]).cross(m.subVectors(k[0],k[2])).normalize();let j=b.dot(k[0])<0;j&&b.negate();for(let q=1;q<=k.length-2;q++)[k[q+ +j],k[q+1-+j],k[0]].forEach(W=>{a.push(W.x,W.y,W.z),u.push(b.x,b.y,b.z)})}}function h(){let d=new A;for(let M=0;M<a.length;M+=3){d.x=a[M+0],d.y=a[M+1],d.z=a[M+2];let x=S(d)/2/Math.PI+.5,T=_(d)/Math.PI+.5;l.push(x,1-T)}let f=new A,m=new A,p=new A,g=new A,v=new B,y=new B,w=new B,b=(M,x,T,E)=>{E<0&&M.x===1&&(l[x]=M.x-1),T.x===0&&T.z===0&&(l[x]=E/2/Math.PI+.5)};for(let M=0,x=0;M<a.length;M+=9,x+=6){f.set(a[M+0],a[M+1],a[M+2]),m.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),v.set(l[x+0],l[x+1]),y.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),g.copy(f).add(m).add(p).divideScalar(3);let T=S(g);b(v,x+0,f,T),b(y,x+2,m,T),b(w,x+4,p,T)}for(let M=0;M<l.length;M+=6){let x=l[M+0],T=l[M+2],E=l[M+4],C=Math.max(x,T,E),P=Math.min(x,T,E);C>.9&&P<.1&&(x<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(e){return new fo(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var $_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new bh(e*.5,s,o):new nl(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},bh=class extends fo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-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,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n),this.type=l}static fromJSON(e){return new bh(e.radius,e.corner,e.cornerSides)}};var Jv=Math.PI*2;function Kv({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function Ez(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function eT(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function Cz(r,e,t,n,i,s,o,a,l,u){let c=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),m=c*h-c*f-h*d;m<0&&(m=0),m/=c*f+h*d,m=Math.sqrt(m)*(l===u?-1:1);let p=m*i/s*a,g=m*-s/i*o,v=p+(r+t)/2,y=g+(e+n)/2,w=(o-p)/i,b=(a-g)/s,S=(-o-p)/i,_=(-a-g)/s,M=eT(1,0,w,b),x=eT(w,b,S,_);return!u&&x>0&&(x-=Jv),u&&x<0&&(x+=Jv),{centerx:v,centery:y,ang1:M,ang2:x}}function tT({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-t)/2,c=(e-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=Cz(r,e,t,n,i,s,u,c,o,a),{ang1:f,ang2:m}=d,{centerx:p,centery:g}=d,v=Math.abs(m)/(Jv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);m/=y;for(let w=0;w<y;w++)l.push(Ez(f,m)),f+=m;return l.map(w=>{let{x:b,y:S}=Kv(w[0],i,s,p,g),{x:_,y:M}=Kv(w[1],i,s,p,g),{x,y:T}=Kv(w[2],i,s,p,g);return{x1:b,y1:S,x2:_,y2:M,x,y:T}})}var rT=Math.PI*2,iT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=e*.5,h=t*.5,d=Pz(u,c,h,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Un.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function Pz(r,e,t,n,i,s){if(n>=rT)return i>30||i%4===0?(Iz(r,e,t,s),Math.round(i/4)):nT(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},u=tT({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?Dz(r,o.x,o.y,u,i,e,t,s):nT(r,n,i,e,t,s)}function Dz(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(wc(e,t));for(let u=0,c=n.length;u<c;u++){let h=n[u],d=r.points[u],f=wc(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),r.addPoint(f)}return a>0?sT(r,s,o,a):r.addPoint(wc(0,0)),l}function nT(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(wc(u,c))}return e<rT?s>0?sT(r,n,i,s):r.addPoint(wc(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&oT(r,n,i,s)),1}function Iz(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(qp(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(qp(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(qp(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(qp(i,s-t,i+a,s-t,i-a,s-t)),n>0&&oT(r,e,t,n)}function wc(r,e){return new fi(Be.generateUUID(),new B(r,e))}function qp(r,e,t,n,i,s){let o=wc(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function sT(r,e,t,n){aT(r,e,t,n).forEach(s=>r.addPoint(s))}function oT(r,e,t,n){let i=aT(r,e,t,n),s=new gt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function aT(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new B(i/e,s/t),a=r.points.map(l=>{let u=l.clone();return u.uuid=Be.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var lT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??n),s=Math.abs(t.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=r.parameters,d=new wh(!1,e,t,n,i,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...r,type:"HelixGeometry"}})}},wh=class extends De{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){super();let f=e&&o===1;f&&(d=0),h>100&&(h=100);let m=()=>new A,p=new A,g=m(),v=m(),y=m(),w,b,S,_,M,x,T,E,C=m(),P=m(),O=m(),I=m(),N=m(),F=m(),G=m(),Y=m(),U=n-2*l+.001,z=U/o,Q=Math.ceil(a*o),V=Q+1,k=U/Q,j=-U/2,q=c+1,W=2*Math.PI/c,he=Math.PI/2/d,ie=.01,K=Math.min((1-h/100)*l,l-ie),X=l-K,ne=0,ce=2,oe=d*ce+ce,Te=q*oe/ce,me=Te+q*V,ge=q*(V+oe),[ye,de,Pe]=[3,3,2].map(ve=>Array(ge*ve).fill(0)),Ne=[],Ze=s-l;function R(ve,H){let xe=Math.PI/2;x=H*k,E=2*Math.PI*(x%z)/z+xe,x+=j,T=Math.sin(E)*Ze,M=Math.cos(E)*Ze,e?ve.set(M,T,x):ve.set(M,x,T)}R(p,-1e-10),R(g,0),C.copy(p),R(p,1);let D=p.distanceTo(g),J=X+K,le=D*Q+2*J,fe=K,Ee=le-J;for(let ve=0;ve<=Q;ve++){R(v,ve),Y.subVectors(v,C).normalize(),C.copy(v),F.copy(v).setComponent(+e+1,0).normalize(),G.crossVectors(Y,F).normalize();let H=ve===0,xe=ve===Q,_e=H?3*Math.PI/2:he,Qe=H?fe:Ee,Re=H?q:me,Ke=H?0:ge-q,we=Y.clone().multiplyScalar(H?-X:X).add(v),Je=Y.clone().multiplyScalar(H?-1:1).normalize();for(let it=0;it<q;it++){let yt=it*W;if(P.addVectors(p.copy(F).multiplyScalar(l*Math.cos(yt)),g.copy(G).multiplyScalar(l*Math.sin(yt))),O.copy(P).normalize(),H||xe){f||(ne=Ke+it,[0,1,2].forEach(At=>{ye[ne*3+At]=we.getComponent(At),de[ne*3+At]=Je.getComponent(At)}),Pe[ne*2]=+xe,Pe[ne*2+1]=it/c),g.copy(O).multiplyScalar(K),y.addVectors(v,g);for(let At=0;At<d;At++){let cr=At*he+_e;I.addVectors(p.copy(Y).multiplyScalar(X*Math.sin(cr)),g.copy(O).multiplyScalar(X*Math.cos(cr))),N.copy(I).normalize(),g.addVectors(y,I),I.normalize(),ne=Re+At*q+it,[0,1,2].forEach(Ta=>{ye[ne*3+Ta]=g.getComponent(Ta),de[ne*3+Ta]=N.getComponent(Ta)});let pd=+H+Math.sin(cr);Pe[ne*2]=(Qe+X*pd)/le,Pe[ne*2+1]=it/c}}g.addVectors(v,P),ne=Te+ve*q+it,[0,1,2].forEach(At=>{ye[ne*3+At]=g.getComponent(At),de[ne*3+At]=O.getComponent(At)}),Pe[ne*2]=(J+ve*D)/le,Pe[ne*2+1]=it/c}}let Ue=V+2*d+ce,re=1,[Fe,Oe]=f?[re,re+V-1]:[0,Ue-1];for(let ve=Fe;ve<=Oe-1;ve++){let H=f&&ve===Oe-1;for(let xe=0;xe<q-1;xe++)w=ve*q+xe,b=w+1,S=(H?xe:w)+q,_=(H?xe+1:b)+q,ve===0?Ne.push(b,_,S):ve===Ue-2?Ne.push(w,b,S):Ne.push(w,b,S,b,_,S)}this.setIndex(Ne),this.setAttribute("position",new Ae(ye,3)),this.setAttribute("normal",new Ae(de,3)),this.setAttribute("uv",new Ae(Pe,2))}};var cT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Sh(e*.5,s,o):new il(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},Sh=class extends fo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,n),this.type=a}static fromJSON(e){return new Sh(e.radius,e.corner,e.cornerSides)}};var uT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let t=Object.assign({},e?.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}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new ds;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new $a(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var Ui=new be,$v=new ht,Xp=new A,po=class extends Lt{constructor(){super(),this.uuid=Be.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(e){let t=new jt().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(e);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return Ui.makeRotationX(e),this.applyMatrix4(Ui),this}rotateY(e){return Ui.makeRotationY(e),this.applyMatrix4(Ui),this}rotateZ(e){return Ui.makeRotationZ(e),this.applyMatrix4(Ui),this}translate(e,t,n){return Ui.makeTranslation(e,t,n),this.applyMatrix4(Ui),this}scale(e,t,n){return Ui.makeScale(e,t,n),this.applyMatrix4(Ui),this}lookAt(e){return $v.lookAt(e),$v.updateMatrix(),this.applyMatrix4($v.matrix),this}fromBufferGeometry(e){let t=this,n=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)t.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&t.colors.push(new Le().fromBufferAttribute(a,d));function c(d,f,m,p){let g=a===void 0?[]:[t.colors[d].clone(),t.colors[f].clone(),t.colors[m].clone()],v=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],y=new Sc(d,f,m,v,g,p);t.faces.push(y),l!==void 0&&t.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,m)]),u!==void 0&&t.faceVertexUvs[1].push([new B().fromBufferAttribute(u,d),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,m)])}let h=e.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],m=f.start,p=f.count;for(let g=m,v=m+p;g<v;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)c(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xp).negate(),this.translate(Xp.x,Xp.y,Xp.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new be;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)t[n]=new A;if(e){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),t[a.a].add(n),t[a.b].add(n),t[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)t[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let n=this.faces[e],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new po;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new En),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,n=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,u=e.faces,c=this.colors,h=e.colors;t!==void 0&&(i=new jt().getNormalMatrix(t));for(let d=0,f=a.length;d<f;d++){let p=a[d].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let m=u[d],p,g,v=m.vertexNormals,y=m.vertexColors,w=new Sc(m.a+s,m.b+s,m.c+s);w.normal.copy(m.normal),i!==void 0&&w.normal.applyMatrix3(i).normalize();for(let b=0,S=v.length;b<S;b++)p=v[b].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),w.vertexNormals.push(p);w.color.copy(m.color);for(let b=0,S=y.length;b<S;b++)g=y[b],w.vertexColors.push(g.clone());w.materialIndex=m.materialIndex+n,l.push(w)}for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let v=m[p],y=[];for(let w=0,b=v.length;w<b;w++)y.push(v[w].clone());this.faceVertexUvs[d].push(y)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);t[h]===void 0?(t[h]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}e.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let u=e[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,v=!1,y=this.faceVertexUvs[0][m]!==void 0,w=p.normal.length()>0,b=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,g),M=c(M,2,v),M=c(M,3,y),M=c(M,4,w),M=c(M,5,b),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),y){let x=this.faceVertexUvs[0][m];n.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&n.push(h(p.normal)),b){let x=p.vertexNormals;n.push(h(x[0]),h(x[1]),h(x[2]))}if(S&&n.push(d(p.color)),_){let x=p.vertexColors;n.push(d(x[0]),d(x[1]),d(x[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function h(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function d(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new po().copy(this)}copy(e){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=e.name;let t=e.vertices;for(let d=0,f=t.length;d<f;d++)this.vertices.push(t[d].clone());let n=e.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let i=e.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let v=m[p],y=[];for(let w=0,b=v.length;w<b;w++){let S=v[w];y.push(S.clone())}this.faceVertexUvs[d].push(y)}}let s=e.morphTargets;for(let d=0,f=s.length;d<f;d++){let m={};if(m.name=s[d].name,s[d].vertices!==void 0){m.vertices=[];for(let p=0,g=s[d].vertices.length;p<g;p++)m.vertices.push(s[d].vertices[p].clone())}if(s[d].normals!==void 0){m.normals=[];for(let p=0,g=s[d].normals.length;p<g;p++)m.normals.push(s[d].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let d=0,f=o.length;d<f;d++){let m={};if(o[d].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[d].vertexNormals.length;p<g;p++){let v=o[d].vertexNormals[p],y={};y.a=v.a.clone(),y.b=v.b.clone(),y.c=v.c.clone(),m.vertexNormals.push(y)}}if(o[d].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[d].faceNormals.length;p<g;p++)m.faceNormals.push(o[d].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=e.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=e.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new e0().fromGeometry(this),t=new De,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Ge(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Ge(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Ge(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Ge(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Ge(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Ae(u.data.length*3,3);c.name=u.name,s.push(c.copyVector3sArray(u.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Ae(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Ae(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new De,n=e.geometry;if(e.isPoints||e.isLine){let i=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};po.prototype.isGeometry=!0;var e0=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(e){let t=[],n,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,u;if(l>0){u=[];for(let v=0;v<l;v++)u[v]={name:a[v].name,data:[]};this.morphTargets.position=u}let c=e.morphNormals,h=c.length,d;if(h>0){d=[];for(let v=0;v<h;v++)d[v]={name:c[v].name,data:[]};this.morphTargets.normal=d}let f=e.skinIndices,m=e.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let v=0;v<t.length;v++){let y=t[v];this.vertices.push(n[y.a],n[y.b],n[y.c]);let w=y.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=y.normal;this.normals.push(S,S,S)}let b=y.vertexColors;if(b.length===3)this.colors.push(b[0],b[1],b[2]);else{let S=y.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][v];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new B,new B,new B))}if(o===!0){let S=i[1][v];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new B,new B,new B))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[y.a],_[y.b],_[y.c])}for(let S=0;S<h;S++){let _=c[S].vertexNormals[v];d[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[y.a],f[y.b],f[y.c]),g&&this.skinWeights.push(m[y.a],m[y.b],m[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Sc=class{constructor(e,t,n,i,s,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Le,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var Lz=["a","b","c"];function Oz(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function t0(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function n0(r,e,t,n,i,s){let o=Math.min(r,e),a=Math.max(r,e),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=t[o],h=t[a];u={a:c,b:h,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[e].edges.push(u)}function Rz(r,e,t,n){let i,s,o;for(i=0,s=r.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],n0(o.a,o.b,r,n,o,t),n0(o.b,o.c,r,n,o,t),n0(o.c,o.a,r,n,o,t)}function Yp(r,e,t,n,i){r.push(new Sc(e,t,n,void 0,void 0,i))}function Ac(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function Qp(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var Zp=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof De?e=new po().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new A,n,i,s,o,a,l=e.vertices,u=e.faces,c=e.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;Rz(l,u,d,f);let m=[],p,g,v,y,w,b,S;for(let ie of Array.from(f.keys())){for(g=f.get(ie),v=new A,w=3/8,b=1/8,S=g.faces.length,S!=2&&(w=.5,b=0,S!=1),v.addVectors(g.a,g.b).multiplyScalar(w),t.set(0,0,0),o=0;o<S;o++){for(y=g.faces[o],a=0;a<3&&(p=l[Oz(y,Lz[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(b),v.add(t),g.newEdge=m.length,m.push(v)}let _,M,x,T,E,C,P,O=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=d[i].edges,n=E.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),x=_,n<=2&&(n==2?(M=3/4,x=1/8):n==1||n==0),P=C.clone().multiplyScalar(M),t.set(0,0,0),o=0;o<n;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(x)),P.add(t),O.push(P)}let I=O.concat(m),N=O.length,F,G,Y,U=[],z=[],Q,V,k,j,q=new B,W=new B,he=new B;for(i=0,s=u.length;i<s;i++)y=u[i],F=Number(t0(y.a,y.b,f).newEdge)+N,G=Number(t0(y.b,y.c,f).newEdge)+N,Y=Number(t0(y.c,y.a,f).newEdge)+N,Yp(U,F,G,Y,y.materialIndex),Yp(U,y.a,F,Y,y.materialIndex),Yp(U,y.b,G,F,y.materialIndex),Yp(U,y.c,Y,G,y.materialIndex),h&&(Q=c[i],V=Q[0],k=Q[1],j=Q[2],q.set(Ac(V.x,k.x),Ac(V.y,k.y)),W.set(Ac(k.x,j.x),Ac(k.y,j.y)),he.set(Ac(V.x,j.x),Ac(V.y,j.y)),Qp(z,q,W,he),Qp(z,V,q,he),Qp(z,k,W,q),Qp(z,j,he,W));e.vertices=I,e.faces=U,h&&(e.faceVertexUvs[0]=z)}};var bn=new A,hT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new De().copy(new ur(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(bn),n={width:bn.x,height:bn.y,depth:bn.z,subdivisions:0}):n=e.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(r){let{width:e,height:t,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new De().copy(new ur(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(bn)):bn.set(o.width,o.height,o.depth),(e!==bn.x||t!==bn.y||n!==bn.z)&&s.scale(bn.x===0?1:e/bn.x,bn.y===0?1:t/bn.y,bn.z===0?1:n/bn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Zp(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,e,t){new ul(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(bn);let o=100/bn.x;Object.assign(s.parameters,{width:100,height:bn.y*o,depth:bn.z*o}),e(this.build(s))})}};var dT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=e*.5,c=t*.5,h=0,d=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,v=h+Math.sin(g)*u,y=d+Math.cos(g)*c;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Un.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var fT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new i0(e*.5,t,i,s,o,a,l);return u.scale(1,1,n/e),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function Ah(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function r0(r,e,t,n,i,s){let o=e.clone().sub(r),a=t.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function Nz(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var i0=class extends De{constructor(e=.5,t=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=t/2,m=Math.PI/n,p=e*Math.cos(Math.PI/n),g=2*Math.PI/n,v=(n-2)*Math.PI/n,y=Math.PI-v,w=new A(0,-f,0),b=new A(0,f,0),S=new B(e,-f),_=new B(p,-f),M=new B(0,b.y).sub(_),x=new B(0,b.y).sub(S),T=new B(M.y,-M.x).normalize(),E=new B(x.y,-x.x).normalize(),P=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,P);let O;{let z=new A(T.x,T.y,0),Q=new A(Math.cos(g)*z.x,z.y,Math.sin(g)*z.x);O=z.angleTo(Q)}let I=o/Math.tan((Math.PI-M.angle())/2),N=o/Math.tan((Math.PI-O)/2),F=new A;if(!s){u.push(w.x,w.y,w.z),c.push(0,-1,0),h.push(0,0);let z=d++,Q=[],V=S.clone(),k=I/Math.cos(Math.PI/n);V.x-=k;for(let j=0;j<n;j++){let q=j/n*Math.PI*2+m,W=new B(Math.sin(q),Math.cos(q));Ah(V,W,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),h.push(0,0),Q.push(d++)}for(let j=0;j<Q.length;j++)l.push(Q[j],z,Q[(j+1)%Q.length])}let G=[];{let z=new A,Q=new A,V=new A,k=new A,j=new A,q=new A;for(let W=0;W<n;W++){let he=W/n*Math.PI*2+m,ie=(W+.5)/n*Math.PI*2+m,K=(W+1)/n*Math.PI*2+m,X=new B(Math.sin(he),Math.cos(he)),ne=new B(Math.sin(ie),Math.cos(ie)),ce=new B(Math.sin(K),Math.cos(K));Ah(S,X,Q),Ah(S,ce,V),Ah(T,ne,z),r0(b,Q,V,N,N,k),u.push(k.x,k.y,k.z),r0(Q,b,V,N,I,j),u.push(j.x,j.y,j.z),r0(V,Q,b,I,N,q),u.push(q.x,q.y,q.z),c.push(z.x,z.y,z.z),c.push(z.x,z.y,z.z),c.push(z.x,z.y,z.z),h.push(0,0),h.push(0,0),h.push(0,0);let oe=d++,Te=d++,me=d++;if(l.push(oe,Te,me),o>0){{let de=Q.clone().add(V).multiplyScalar(.5),Pe=b.clone().sub(de).normalize(),Ze=w.clone().sub(de).normalize().add(Pe).normalize().multiplyScalar(-1),R=q.clone().sub(j);Y(de,R,Ze,M.angle())}let ge,ye;{let de=new A;Ah(E,ce,de);let Pe=q.clone().add(k).multiplyScalar(.5);Pe=Nz(Pe,V,b);let Ne=q.clone().sub(k);[ge,ye]=Y(Pe,Ne,de,O,k.y)}{let de=ge,Pe=de.clone().setY(0).normalize(),Ne=new A(0,-1,0),Ze=Pe.clone().cross(Ne);U(de,Pe,Ne,Ze)}G.concat(ye);{let de=M.angle(),Pe=Math.PI-de,Ne=b.clone();Ne.y-=o/Math.sin(de-Math.PI/2);let Ze=new A,R=[];for(let J=0;J<a;J++){let le=[],fe=Math.PI/2-Pe*J/a,Ee=Math.cos(fe),Ue=Math.sin(fe),re=ie;for(let Fe=0;Fe<=J;Fe++){let Oe=Math.cos(re),ve=Math.sin(re);z.x=Ee*ve,z.y=Ue,z.z=Ee*Oe,Ze.copy(Ne).addScaledVector(z,o),u.push(Ze.x,Ze.y,Ze.z),c.push(z.x,z.y,z.z),h.push(0,0),le.push(d++),re+=Math.PI*2/J/n}R.push(le)}ye.reverse(),R.push(ye);let D=R.length-1;for(let J=0;J<D;J++){let le=R[J],fe=R[J+1],Ee=le.length-1;l.push(fe[1],le[0],fe[0]);for(let Ue=1;Ue<=Ee;Ue++)l.push(le[Ue],le[Ue-1],fe[Ue]),l.push(fe[Ue+1],le[Ue],fe[Ue])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function Y(z,Q,V,k,j){let q=-k/2,W=(Math.PI-k)/2,he=Q.clone().normalize().cross(V);z.addScaledVector(V,-o/Math.sin(W));let ie=new A,K=new A,X=1,ne=d,ce=[];for(let oe=0;oe<=a;oe++){let Te=q+oe/a*k;K.set(0,0,0),K.addScaledVector(he,Math.sin(Te)),K.addScaledVector(V,Math.cos(Te));for(let me=0;me<=X;me++){let ge=me/X-.5;if(ie.copy(z),ie.addScaledVector(Q,ge),ie.addScaledVector(K,o),j!=null){let ye=Math.max(0,ie.y-j);ie.addScaledVector(Q,-ye/Q.y)}u.push(ie.x,ie.y,ie.z),c.push(K.x,K.y,K.z),h.push(0,0),me===0&&ce.push(d),d++}}for(let oe=0;oe<a;oe++)for(let Te=0;Te<X;Te++){let me=ne+Te+(X+1)*oe,ge=me+(X+1),ye=ge+1,de=me+1;l.push(me,ge,de),l.push(ge,ye,de)}return[z.clone().addScaledVector(Q,.5),ce]}function U(z,Q,V,k){let j=Math.PI/2,q=x.angle()-j,W=[],he=new A,ie=new A;for(let X=0;X<=a;X++){let ne=[],ce=X/a;for(let oe=0;oe<=X;oe++){let me=((X?oe/X:0)-.5)*y,ge=Math.cos(me),ye=Math.sin(me),de=Math.atan(Math.tan(q)*ge),Pe=(j+de)*ce,Ne=Math.cos(Pe),Ze=Math.sin(Pe);he.set(0,0,0),he.addScaledVector(Q,Ze*ge),he.addScaledVector(V,Ne),he.addScaledVector(k,Ze*ye),ie.copy(z).addScaledVector(he,o),u.push(ie.x,ie.y,ie.z),c.push(he.x,he.y,he.z),h.push(0,0),ne.push(d++)}W.push(ne)}let K=W.length-1;for(let X=0;X<K;X++){let ne=W[X],ce=W[X+1],oe=ne.length-1;l.push(ne[0],ce[1],ce[0]);for(let Te=1;Te<=oe;Te++)l.push(ne[Te-1],ne[Te],ce[Te]),l.push(ne[Te],ce[Te+1],ce[Te])}}}};var pT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:t*.5,y:n*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(b,S,_){return S>t&&_>n?Math.min(b*t/S,b*n/_):S>t?b*t/S:_>n?b*n/_:b}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let m=c.x,p=h.x,g=h.y,v=c.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,v)),e.addPoint(e.createPoint(m,v)),e.isClosed=!0;let y=!0;for(let b=0,S=e.points.length;b<S;b++)e.points[b].roundness=f[b],b>0&&f[b]!==f[b-1]&&(y=!1);y&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let w=Un.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...r,type:"RectangleGeometry"}})}};var mT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new Wo(.5*e,i,s,o,a,l,u);return c.scale(1,t/e,n/e),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var gT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(r){let{width:e=100,height:t=e,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new hs(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var yT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new s0(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},s0=class extends De{constructor(e=1,t=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let h=[],d=Math.PI/2,f=(ie=0,K=0,X=0)=>new A(ie,K,X),m=f(),p=f(),[g,v,y]=[t/2,e/2,n/2],w=-v,b=+v,[S,_,M]=[f(w,-g,+y),f(w,-g,-y),f(w,+g,-y)],x=(ie,K=!1)=>Math.sin(ie-Math.PI/(1+ +K)),T=(ie,K=!1)=>Math.cos(ie-Math.PI/(1+ +K));M.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-y,C=S.z-c;i<=d?(M.z=Math.min(E,C),M.z==C&&(M.y-=(E-C)/Math.tan(d-i))):_.z=Math.min(_.z-E-y,S.z-c),m.subVectors(S,_),p.subVectors(M,_);let P=Math.min(m.length(),p.length())*s/100,O=P*Math.tan(i/2),I=P/Math.cos(i/2),N=m.clone().normalize().add(p.normalize()).setLength(I).add(_);m.set(0,x(i,!0),T(i,!0)),h.push([M,m.clone()]);let F=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let K=d+i+ie*F;m.set(0,Math.sin(K)*O,Math.cos(K)*O),m.add(N),p.set(0,x(K),T(K)),h.push([m.clone(),p.clone()])}h.push([S,f(0,1,0)]);let G=Math.sin(F/2)*O*2,Y=h.length-1,U=h[0][0].distanceTo(h[1][0]),z=h[Y-1][0].distanceTo(h[Y][0]),Q=U+G*o+z;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(U+ie*G)/Q);h[Y].push(0);let[V,k,j]=h[0],q,W,he;for(let ie=1;ie<h.length;ie++)[q,W,he]=h[ie],a.push(w,V.y,V.z,w,q.y,q.z,b,V.y,V.z,b,V.y,V.z,w,q.y,q.z,b,q.y,q.z),l.push(0,k.y,k.z,0,W.y,W.z,0,k.y,k.z,0,k.y,k.z,0,W.y,W.z,0,W.y,W.z),u.push(0,j,0,he,1,j,1,j,0,he,1,he),[V,k,j]=[q,W,he];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var vT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,h=e*.5,d=t*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,v=h*n/100,y=d*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let b=0;b<i;b++){let S=p*b,_=f+Math.sin(S)*h,M=m+Math.cos(S)*d;c.addPoint(c.createPoint(_,M))}}else for(let b=0;b<i;b++){let S=f+Math.cos(g)*h,_=m+Math.sin(g)*d;c.addPoint(c.createPoint(S,_)),g+=p,S=f+Math.cos(g)*v,_=m+Math.sin(g)*y,b<=i,c.addPoint(c.createPoint(S,_)),g+=p}c.isClosed=!0;for(let b=0,S=c.points.length;b<S;b++)c.points[b].roundness=s;c.roundness=s,c.update();let w=Un.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...r,type:"StarGeometry"}})}};var xT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t}=r.parameters,n=new hs(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var bT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:n,height:i,depth:s})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=Bz(e,t,n,e*.5,o,s,0,0,i,a,l);return u.scale(1,t/e,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function Bz(r,e,t,n,i,s,o,a,l,u,c){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(u=0),new wh(!0,r,e,t,n,i,s,o,a,l,u,c)}var wT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(r){let{width:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=e*.5;a!==t&&(a-=t);let l=new sl(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var ST=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=e*.5,c=t*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let h=Un.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...r,type:"TriangleGeometry"}})}};function AT(){let r=new De;return r.setAttribute("position",new Ge(new Float32Array([]),3)),r.setIndex(new Ge(new Uint16Array([]),1)),r}var Fz=12;var _c=class extends De{constructor(t,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.vectorShapes=[];let i=AT();Object.entries(i.attributes).forEach(([s,o])=>{this.setAttribute(s,o)}),this.setIndex(i.index),this.updateFont(t.font,n),this.update(t)}async updateFont(t,n){let i=n.getFont(t);i&&(this.font=i,await i.loadingPromise)}async update(t){let n=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!n||!n.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c,subdivisions:h}=t;await n.loadingPromise;let d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,f=Uz(t,n,d),{shapes:m,charWidths:p,charCoords:g}=await n.generateShapes(f,t),v=i*.5,y=s*.5,w=m.map(_=>new gt().fromShape(_));this.vectorShapes=w;let b=w.map(_=>Un.create({shape:_,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?It.NONZERO:It.ODD,subdivisions:h??Fz}})),S=b.length?xs(b):AT();S.translate(-v,y,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=p,Object.entries(S.attributes).forEach(([_,M])=>{this.setAttribute(_,M)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let t=aa(new De,_c.prototype);return t.copy(this),t}copy(t){return Object.entries(t.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:t})}get text(){return this.userData.parameters.text??""}};function Uz(r,e,t){t=t??r.text;let n=[""],i="";for(let s of t)i+=s,s===" "||s===`
3137
+ }`;function pO(r,e,t){let n=new _u,i=new B,s=new B,o=new He,a=new Tu({depthPacking:Ly}),l=new ay,u={},c=t.maxTextureSize,h={0:un,1:Gr,2:tr},d=new mt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new B},radius:{value:4}},vertexShader:dO,fragmentShader:fO}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new De;m.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let p=new rn(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ff,this.render=function(w,S,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;let M=r.getRenderTarget(),x=r.getActiveCubeFace(),T=r.getActiveMipmapLevel(),E=r.state;E.setBlending(Rt),E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);for(let C=0,P=w.length;C<P;C++){let O=w[C],D=O.shadow;if(D===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(D.autoUpdate===!1&&D.needsUpdate===!1)continue;i.copy(D.mapSize);let N=D.getFrameExtents();if(i.multiply(N),s.copy(D.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(s.x=Math.floor(c/N.x),i.x=s.x*N.x,D.mapSize.x=s.x),i.y>c&&(s.y=Math.floor(c/N.y),i.y=s.y*N.y,D.mapSize.y=s.y)),D.map===null){let z=this.type!==fu?{minFilter:Ft,magFilter:Ft}:{};D.map=new dt(i.x,i.y,z),D.map.texture.name=O.name+".shadowMap",D.camera.updateProjectionMatrix()}r.setRenderTarget(D.map),r.clear();let F=D.getViewportCount();for(let z=0;z<F;z++){let Y=D.getViewport(z);o.set(s.x*Y.x,s.y*Y.y,s.x*Y.z,s.y*Y.w),E.viewport(o),D.updateMatrices(O,z),n=D.getFrustum(),b(S,_,D.camera,O,this.type)}D.isPointLightShadow!==!0&&this.type===fu&&v(D,_),D.needsUpdate=!1}g.needsUpdate=!1,r.setRenderTarget(M,x,T)};function v(w,S){let _=e.update(p);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new dt(i.x,i.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(S,null,_,d,p,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(S,null,_,f,p,null)}function y(w,S,_,M,x,T){let E=null,C=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(C!==void 0?E=C:E=_.isPointLight===!0?l:a,r.localClippingEnabled&&S.clipShadows===!0&&Array.isArray(S.clippingPlanes)&&S.clippingPlanes.length!==0||S.displacementMap&&S.displacementScale!==0||S.alphaMap&&S.alphaTest>0){let P=E.uuid,O=S.uuid,D=u[P];D===void 0&&(D={},u[P]=D);let N=D[O];N===void 0&&(N=E.clone(),D[O]=N),E=N}return E.visible=S.visible,E.wireframe=S.wireframe,T===fu?E.side=S.shadowSide!==null?S.shadowSide:S.side:E.side=S.shadowSide!==null?S.shadowSide:h[S.side],E.alphaMap=S.alphaMap,E.alphaTest=S.alphaTest,E.clipShadows=S.clipShadows,E.clippingPlanes=S.clippingPlanes,E.clipIntersection=S.clipIntersection,E.displacementMap=S.displacementMap,E.displacementScale=S.displacementScale,E.displacementBias=S.displacementBias,E.wireframeLinewidth=S.wireframeLinewidth,E.linewidth=S.linewidth,_.isPointLight===!0&&E.isMeshDistanceMaterial===!0&&(E.referencePosition.setFromMatrixPosition(_.matrixWorld),E.nearDistance=M,E.farDistance=x),E}function b(w,S,_,M,x){if(w.visible===!1)return;if(w.layers.test(S.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&x===fu)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let C=e.update(w),P=w.material;if(Array.isArray(P)){let O=C.groups;for(let D=0,N=O.length;D<N;D++){let F=O[D],z=P[F.materialIndex];if(z&&z.visible){let Y=y(w,z,M,_.near,_.far,x);r.renderBufferDirect(_,null,C,Y,w,F)}}}else if(P.visible){let O=y(w,P,M,_.near,_.far,x);r.renderBufferDirect(_,null,C,O,w,null)}}let E=w.children;for(let C=0,P=E.length;C<P;C++)b(E[C],S,_,M,x)}}function mO(r,e,t){let n=t.isWebGL2;function i(){let H=!1,xe=new He,_e=null,Qe=new He(0,0,0,0);return{setMask:function(Re){_e!==Re&&!H&&(r.colorMask(Re,Re,Re,Re),_e=Re)},setLocked:function(Re){H=Re},setClear:function(Re,Ke,we,Je,it){it===!0&&(Re*=Je,Ke*=Je,we*=Je),xe.set(Re,Ke,we,Je),Qe.equals(xe)===!1&&(r.clearColor(Re,Ke,we,Je),Qe.copy(xe))},reset:function(){H=!1,_e=null,Qe.set(-1,0,0,0)}}}function s(){let H=!1,xe=null,_e=null,Qe=null;return{setTest:function(Re){Re?q(2929):W(2929)},setMask:function(Re){xe!==Re&&!H&&(r.depthMask(Re),xe=Re)},setFunc:function(Re){if(_e!==Re){if(Re)switch(Re){case WC:r.depthFunc(512);break;case jC:r.depthFunc(519);break;case qC:r.depthFunc(513);break;case jg:r.depthFunc(515);break;case XC:r.depthFunc(514);break;case YC:r.depthFunc(518);break;case QC:r.depthFunc(516);break;case ZC:r.depthFunc(517);break;default:r.depthFunc(515)}else r.depthFunc(515);_e=Re}},setLocked:function(Re){H=Re},setClear:function(Re){Qe!==Re&&(r.clearDepth(Re),Qe=Re)},reset:function(){H=!1,xe=null,_e=null,Qe=null}}}function o(){let H=!1,xe=null,_e=null,Qe=null,Re=null,Ke=null,we=null,Je=null,it=null;return{setTest:function(yt){H||(yt?q(2960):W(2960))},setMask:function(yt){xe!==yt&&!H&&(r.stencilMask(yt),xe=yt)},setFunc:function(yt,At,cr){(_e!==yt||Qe!==At||Re!==cr)&&(r.stencilFunc(yt,At,cr),_e=yt,Qe=At,Re=cr)},setOp:function(yt,At,cr){(Ke!==yt||we!==At||Je!==cr)&&(r.stencilOp(yt,At,cr),Ke=yt,we=At,Je=cr)},setLocked:function(yt){H=yt},setClear:function(yt){it!==yt&&(r.clearStencil(yt),it=yt)},reset:function(){H=!1,xe=null,_e=null,Qe=null,Re=null,Ke=null,we=null,Je=null,it=null}}}let a=new i,l=new s,u=new o,c={},h={},d=new WeakMap,f=[],m=null,p=!1,g=null,v=null,y=null,b=null,w=null,S=null,_=null,M=!1,x=null,T=null,E=null,C=null,P=null,O=r.getParameter(35661),D=!1,N=0,F=r.getParameter(7938);F.indexOf("WebGL")!==-1?(N=parseFloat(/^WebGL (\d)/.exec(F)[1]),D=N>=1):F.indexOf("OpenGL ES")!==-1&&(N=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),D=N>=2);let z=null,Y={},U=r.getParameter(3088),G=r.getParameter(2978),Q=new He().fromArray(U),V=new He().fromArray(G);function k(H,xe,_e){let Qe=new Uint8Array(4),Re=r.createTexture();r.bindTexture(H,Re),r.texParameteri(H,10241,9728),r.texParameteri(H,10240,9728);for(let Ke=0;Ke<_e;Ke++)r.texImage2D(xe+Ke,0,6408,1,1,0,6408,5121,Qe);return Re}let j={};j[3553]=k(3553,3553,1),j[34067]=k(34067,34069,6),a.setClear(0,0,0,1),l.setClear(1),u.setClear(0),q(2929),l.setFunc(jg),Te(!1),me(Wx),q(2884),ce(Rt);function q(H){c[H]!==!0&&(r.enable(H),c[H]=!0)}function W(H){c[H]!==!1&&(r.disable(H),c[H]=!1)}function he(H,xe){return h[H]!==xe?(r.bindFramebuffer(H,xe),h[H]=xe,n&&(H===36009&&(h[36160]=xe),H===36160&&(h[36009]=xe)),!0):!1}function ie(H,xe){let _e=f,Qe=!1;if(H)if(_e=d.get(xe),_e===void 0&&(_e=[],d.set(xe,_e)),H.isWebGLMultipleRenderTargets){let Re=H.texture;if(_e.length!==Re.length||_e[0]!==36064){for(let Ke=0,we=Re.length;Ke<we;Ke++)_e[Ke]=36064+Ke;_e.length=Re.length,Qe=!0}}else _e[0]!==36064&&(_e[0]=36064,Qe=!0);else _e[0]!==1029&&(_e[0]=1029,Qe=!0);Qe&&(t.isWebGL2?r.drawBuffers(_e):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(_e))}function K(H){return m!==H?(r.useProgram(H),m=H,!0):!1}let X={[Ha]:32774,[OC]:32778,[RC]:32779};if(n)X[Yx]=32775,X[Qx]=32776;else{let H=e.get("EXT_blend_minmax");H!==null&&(X[Yx]=H.MIN_EXT,X[Qx]=H.MAX_EXT)}let ne={[NC]:0,[BC]:1,[FC]:768,[Aw]:770,[HC]:776,[kC]:774,[GC]:772,[UC]:769,[_w]:771,[VC]:775,[zC]:773};function ce(H,xe,_e,Qe,Re,Ke,we,Je){if(H===Rt){p===!0&&(W(3042),p=!1);return}if(p===!1&&(q(3042),p=!0),H!==LC){if(H!==g||Je!==M){if((v!==Ha||w!==Ha)&&(r.blendEquation(32774),v=Ha,w=Ha),Je)switch(H){case Ns:r.blendFuncSeparate(1,771,1,771);break;case jx:r.blendFunc(1,1);break;case qx:r.blendFuncSeparate(0,769,0,1);break;case Xx:r.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",H);break}else switch(H){case Ns:r.blendFuncSeparate(770,771,1,771);break;case jx:r.blendFunc(770,1);break;case qx:r.blendFuncSeparate(0,769,0,1);break;case Xx:r.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",H);break}y=null,b=null,S=null,_=null,g=H,M=Je}return}Re=Re||xe,Ke=Ke||_e,we=we||Qe,(xe!==v||Re!==w)&&(r.blendEquationSeparate(X[xe],X[Re]),v=xe,w=Re),(_e!==y||Qe!==b||Ke!==S||we!==_)&&(r.blendFuncSeparate(ne[_e],ne[Qe],ne[Ke],ne[we]),y=_e,b=Qe,S=Ke,_=we),g=H,M=null}function oe(H,xe){H.side===tr?W(2884):q(2884);let _e=H.side===un;xe&&(_e=!_e),Te(_e),H.blending===Ns&&H.transparent===!1?ce(Rt):ce(H.blending,H.blendEquation,H.blendSrc,H.blendDst,H.blendEquationAlpha,H.blendSrcAlpha,H.blendDstAlpha,H.premultipliedAlpha),l.setFunc(H.depthFunc),l.setTest(H.depthTest),l.setMask(H.depthWrite),a.setMask(H.colorWrite);let Qe=H.stencilWrite;u.setTest(Qe),Qe&&(u.setMask(H.stencilWriteMask),u.setFunc(H.stencilFunc,H.stencilRef,H.stencilFuncMask),u.setOp(H.stencilFail,H.stencilZFail,H.stencilZPass)),ye(H.polygonOffset,H.polygonOffsetFactor,H.polygonOffsetUnits),H.alphaToCoverage===!0?q(32926):W(32926)}function Te(H){x!==H&&(H?r.frontFace(2304):r.frontFace(2305),x=H)}function me(H){H!==PC?(q(2884),H!==T&&(H===Wx?r.cullFace(1029):H===DC?r.cullFace(1028):r.cullFace(1032))):W(2884),T=H}function ge(H){H!==E&&(D&&r.lineWidth(H),E=H)}function ye(H,xe,_e){H?(q(32823),(C!==xe||P!==_e)&&(r.polygonOffset(xe,_e),C=xe,P=_e)):W(32823)}function de(H){H?q(3089):W(3089)}function Pe(H){H===void 0&&(H=33984+O-1),z!==H&&(r.activeTexture(H),z=H)}function Ne(H,xe){z===null&&Pe();let _e=Y[z];_e===void 0&&(_e={type:void 0,texture:void 0},Y[z]=_e),(_e.type!==H||_e.texture!==xe)&&(r.bindTexture(H,xe||j[H]),_e.type=H,_e.texture=xe)}function Ze(){let H=Y[z];H!==void 0&&H.type!==void 0&&(r.bindTexture(H.type,null),H.type=void 0,H.texture=void 0)}function R(){try{r.compressedTexImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function I(){try{r.texSubImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function J(){try{r.texSubImage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function le(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function fe(){try{r.texStorage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Ee(){try{r.texStorage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Ue(){try{r.texImage2D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function re(){try{r.texImage3D.apply(r,arguments)}catch(H){console.error("THREE.WebGLState:",H)}}function Fe(H){Q.equals(H)===!1&&(r.scissor(H.x,H.y,H.z,H.w),Q.copy(H))}function Oe(H){V.equals(H)===!1&&(r.viewport(H.x,H.y,H.z,H.w),V.copy(H))}function ve(){r.disable(3042),r.disable(2884),r.disable(2929),r.disable(32823),r.disable(3089),r.disable(2960),r.disable(32926),r.blendEquation(32774),r.blendFunc(1,0),r.blendFuncSeparate(1,0,1,0),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(513),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(519,0,4294967295),r.stencilOp(7680,7680,7680),r.clearStencil(0),r.cullFace(1029),r.frontFace(2305),r.polygonOffset(0,0),r.activeTexture(33984),r.bindFramebuffer(36160,null),n===!0&&(r.bindFramebuffer(36009,null),r.bindFramebuffer(36008,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),c={},z=null,Y={},h={},d=new WeakMap,f=[],m=null,p=!1,g=null,v=null,y=null,b=null,w=null,S=null,_=null,M=!1,x=null,T=null,E=null,C=null,P=null,Q.set(0,0,r.canvas.width,r.canvas.height),V.set(0,0,r.canvas.width,r.canvas.height),a.reset(),l.reset(),u.reset()}return{buffers:{color:a,depth:l,stencil:u},enable:q,disable:W,bindFramebuffer:he,drawBuffers:ie,useProgram:K,setBlending:ce,setMaterial:oe,setFlipSided:Te,setCullFace:me,setLineWidth:ge,setPolygonOffset:ye,setScissorTest:de,activeTexture:Pe,bindTexture:Ne,unbindTexture:Ze,compressedTexImage2D:R,texImage2D:Ue,texImage3D:re,texStorage2D:fe,texStorage3D:Ee,texSubImage2D:I,texSubImage3D:J,compressedTexSubImage2D:le,scissor:Fe,viewport:Oe,reset:ve}}function gO(r,e,t,n,i,s,o){let a=i.isWebGL2,l=i.maxTextures,u=i.maxCubemapSize,c=i.maxTextureSize,h=i.maxSamples,d=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,p,g=new WeakMap,v=!1;try{v=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(R,I){return v?new OffscreenCanvas(R,I):Yd("canvas")}function b(R,I,J,le){let fe=1;if((R.width>le||R.height>le)&&(fe=le/Math.max(R.width,R.height)),fe<1||I===!0)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap){let Ee=I?Xd:Math.floor,Ue=Ee(fe*R.width),re=Ee(fe*R.height);p===void 0&&(p=y(Ue,re));let Fe=J?y(Ue,re):p;return Fe.width=Ue,Fe.height=re,Fe.getContext("2d").drawImage(R,0,0,Ue,re),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+Ue+"x"+re+")."),Fe}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function w(R){return Kg(R.width)&&Kg(R.height)}function S(R){return a?!1:R.wrapS!==er||R.wrapT!==er||R.minFilter!==Ft&&R.minFilter!==at}function _(R,I){return R.generateMipmaps&&I&&R.minFilter!==Ft&&R.minFilter!==at}function M(R){r.generateMipmap(R)}function x(R,I,J,le,fe=!1){if(a===!1)return I;if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let Ee=I;return I===6403&&(J===5126&&(Ee=33326),J===5131&&(Ee=33325),J===5121&&(Ee=33321)),I===33319&&(J===5126&&(Ee=33328),J===5131&&(Ee=33327),J===5121&&(Ee=33323)),I===6408&&(J===5126&&(Ee=34836),J===5131&&(Ee=34842),J===5121&&(Ee=le===Xe&&fe===!1?35907:32856),J===32819&&(Ee=32854),J===32820&&(Ee=32855)),(Ee===33325||Ee===33326||Ee===33327||Ee===33328||Ee===34842||Ee===34836)&&e.get("EXT_color_buffer_float"),Ee}function T(R,I,J){return _(R,J)===!0||R.isFramebufferTexture&&R.minFilter!==Ft&&R.minFilter!==at?Math.log2(Math.max(I.width,I.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?I.mipmaps.length:1}function E(R){return R===Ft||R===Zx||R===Kx?9728:9729}function C(R){let I=R.target;I.removeEventListener("dispose",C),O(I),I.isVideoTexture&&m.delete(I)}function P(R){let I=R.target;I.removeEventListener("dispose",P),N(I)}function O(R){let I=n.get(R);if(I.__webglInit===void 0)return;let J=R.source,le=g.get(J);if(le){let fe=le[I.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&D(R),Object.keys(le).length===0&&g.delete(J)}n.remove(R)}function D(R){let I=n.get(R);r.deleteTexture(I.__webglTexture);let J=R.source,le=g.get(J);delete le[I.__cacheKey],o.memory.textures--}function N(R){let I=R.texture,J=n.get(R),le=n.get(I);if(le.__webglTexture!==void 0&&(r.deleteTexture(le.__webglTexture),o.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let fe=0;fe<6;fe++)r.deleteFramebuffer(J.__webglFramebuffer[fe]),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer[fe]);else{if(r.deleteFramebuffer(J.__webglFramebuffer),J.__webglDepthbuffer&&r.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&r.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let fe=0;fe<J.__webglColorRenderbuffer.length;fe++)J.__webglColorRenderbuffer[fe]&&r.deleteRenderbuffer(J.__webglColorRenderbuffer[fe]);J.__webglDepthRenderbuffer&&r.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let fe=0,Ee=I.length;fe<Ee;fe++){let Ue=n.get(I[fe]);Ue.__webglTexture&&(r.deleteTexture(Ue.__webglTexture),o.memory.textures--),n.remove(I[fe])}n.remove(I),n.remove(R)}let F=0;function z(){F=0}function Y(){let R=F;return R>=l&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+l),F+=1,R}function U(R){let I=[];return I.push(R.wrapS),I.push(R.wrapT),I.push(R.magFilter),I.push(R.minFilter),I.push(R.anisotropy),I.push(R.internalFormat),I.push(R.format),I.push(R.type),I.push(R.generateMipmaps),I.push(R.premultiplyAlpha),I.push(R.flipY),I.push(R.unpackAlignment),I.push(R.encoding),I.join()}function G(R,I){let J=n.get(R);if(R.isVideoTexture&&Ne(R),R.isRenderTargetTexture===!1&&R.version>0&&J.__version!==R.version){let le=R.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(J,R,I);return}}t.activeTexture(33984+I),t.bindTexture(3553,J.__webglTexture)}function Q(R,I){let J=n.get(R);if(R.version>0&&J.__version!==R.version){ie(J,R,I);return}t.activeTexture(33984+I),t.bindTexture(35866,J.__webglTexture)}function V(R,I){let J=n.get(R);if(R.version>0&&J.__version!==R.version){ie(J,R,I);return}t.activeTexture(33984+I),t.bindTexture(32879,J.__webglTexture)}function k(R,I){let J=n.get(R);if(R.version>0&&J.__version!==R.version){K(J,R,I);return}t.activeTexture(33984+I),t.bindTexture(34067,J.__webglTexture)}let j={[Xa]:10497,[er]:33071,[Yg]:33648},q={[Ft]:9728,[Zx]:9984,[Kx]:9986,[at]:9729,[iP]:9985,[fl]:9987};function W(R,I,J){if(J?(r.texParameteri(R,10242,j[I.wrapS]),r.texParameteri(R,10243,j[I.wrapT]),(R===32879||R===35866)&&r.texParameteri(R,32882,j[I.wrapR]),r.texParameteri(R,10240,q[I.magFilter]),r.texParameteri(R,10241,q[I.minFilter])):(r.texParameteri(R,10242,33071),r.texParameteri(R,10243,33071),(R===32879||R===35866)&&r.texParameteri(R,32882,33071),(I.wrapS!==er||I.wrapT!==er)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(R,10240,E(I.magFilter)),r.texParameteri(R,10241,E(I.minFilter)),I.minFilter!==Ft&&I.minFilter!==at&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){let le=e.get("EXT_texture_filter_anisotropic");if(I.type===Ti&&e.has("OES_texture_float_linear")===!1||a===!1&&I.type===bu&&e.has("OES_texture_half_float_linear")===!1)return;(I.anisotropy>1||n.get(I).__currentAnisotropy)&&(r.texParameterf(R,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(I.anisotropy,i.getMaxAnisotropy())),n.get(I).__currentAnisotropy=I.anisotropy)}}function he(R,I){let J=!1;R.__webglInit===void 0&&(R.__webglInit=!0,I.addEventListener("dispose",C));let le=I.source,fe=g.get(le);fe===void 0&&(fe={},g.set(le,fe));let Ee=U(I);if(Ee!==R.__cacheKey){fe[Ee]===void 0&&(fe[Ee]={texture:r.createTexture(),usedTimes:0},o.memory.textures++,J=!0),fe[Ee].usedTimes++;let Ue=fe[R.__cacheKey];Ue!==void 0&&(fe[R.__cacheKey].usedTimes--,Ue.usedTimes===0&&D(I)),R.__cacheKey=Ee,R.__webglTexture=fe[Ee].texture}return J}function ie(R,I,J){let le=3553;I.isDataArrayTexture&&(le=35866),I.isData3DTexture&&(le=32879);let fe=he(R,I),Ee=I.source;if(t.activeTexture(33984+J),t.bindTexture(le,R.__webglTexture),Ee.version!==Ee.__currentVersion||fe===!0){r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ue=S(I)&&w(I.image)===!1,re=b(I.image,Ue,!1,c);re=Ze(I,re);let Fe=w(re)||a,Oe=s.convert(I.format,I.encoding),ve=s.convert(I.type),H=x(I.internalFormat,Oe,ve,I.encoding,I.isVideoTexture);W(le,I,Fe);let xe,_e=I.mipmaps,Qe=a&&I.isVideoTexture!==!0,Re=Ee.__currentVersion===void 0||fe===!0,Ke=T(I,re,Fe);if(I.isDepthTexture)H=6402,a?I.type===Ti?H=36012:I.type===cs?H=33190:I.type===Bs?H=35056:H=33189:I.type===Ti&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),I.format===Bo&&H===6402&&I.type!==Ew&&I.type!==cs&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),I.type=cs,ve=s.convert(I.type)),I.format===Gs&&H===6402&&(H=34041,I.type!==Bs&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),I.type=Bs,ve=s.convert(I.type))),Re&&(Qe?t.texStorage2D(3553,1,H,re.width,re.height):t.texImage2D(3553,0,H,re.width,re.height,0,Oe,ve,null));else if(I.isDataTexture)if(_e.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],Qe?t.texSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,ve,xe.data):t.texImage2D(3553,we,H,xe.width,xe.height,0,Oe,ve,xe.data);I.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Ke,H,re.width,re.height),t.texSubImage2D(3553,0,0,0,re.width,re.height,Oe,ve,re.data)):t.texImage2D(3553,0,H,re.width,re.height,0,Oe,ve,re.data);else if(I.isCompressedTexture){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],I.format!==si?Oe!==null?Qe?t.compressedTexSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,xe.data):t.compressedTexImage2D(3553,we,H,xe.width,xe.height,0,xe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Qe?t.texSubImage2D(3553,we,0,0,xe.width,xe.height,Oe,ve,xe.data):t.texImage2D(3553,we,H,xe.width,xe.height,0,Oe,ve,xe.data)}else if(I.isDataArrayTexture)Qe?(Re&&t.texStorage3D(35866,Ke,H,re.width,re.height,re.depth),t.texSubImage3D(35866,0,0,0,0,re.width,re.height,re.depth,Oe,ve,re.data)):t.texImage3D(35866,0,H,re.width,re.height,re.depth,0,Oe,ve,re.data);else if(I.isData3DTexture)Qe?(Re&&t.texStorage3D(32879,Ke,H,re.width,re.height,re.depth),t.texSubImage3D(32879,0,0,0,0,re.width,re.height,re.depth,Oe,ve,re.data)):t.texImage3D(32879,0,H,re.width,re.height,re.depth,0,Oe,ve,re.data);else if(I.isFramebufferTexture){if(Re)if(Qe)t.texStorage2D(3553,Ke,H,re.width,re.height);else{let we=re.width,Je=re.height;for(let it=0;it<Ke;it++)t.texImage2D(3553,it,H,we,Je,0,Oe,ve,null),we>>=1,Je>>=1}}else if(_e.length>0&&Fe){Qe&&Re&&t.texStorage2D(3553,Ke,H,_e[0].width,_e[0].height);for(let we=0,Je=_e.length;we<Je;we++)xe=_e[we],Qe?t.texSubImage2D(3553,we,0,0,Oe,ve,xe):t.texImage2D(3553,we,H,Oe,ve,xe);I.generateMipmaps=!1}else Qe?(Re&&t.texStorage2D(3553,Ke,H,re.width,re.height),t.texSubImage2D(3553,0,0,0,Oe,ve,re)):t.texImage2D(3553,0,H,Oe,ve,re);_(I,Fe)&&M(le),Ee.__currentVersion=Ee.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function K(R,I,J){if(I.image.length!==6)return;let le=he(R,I),fe=I.source;if(t.activeTexture(33984+J),t.bindTexture(34067,R.__webglTexture),fe.version!==fe.__currentVersion||le===!0){r.pixelStorei(37440,I.flipY),r.pixelStorei(37441,I.premultiplyAlpha),r.pixelStorei(3317,I.unpackAlignment),r.pixelStorei(37443,0);let Ee=I.isCompressedTexture||I.image[0].isCompressedTexture,Ue=I.image[0]&&I.image[0].isDataTexture,re=[];for(let we=0;we<6;we++)!Ee&&!Ue?re[we]=b(I.image[we],!1,!0,u):re[we]=Ue?I.image[we].image:I.image[we],re[we]=Ze(I,re[we]);let Fe=re[0],Oe=w(Fe)||a,ve=s.convert(I.format,I.encoding),H=s.convert(I.type),xe=x(I.internalFormat,ve,H,I.encoding),_e=a&&I.isVideoTexture!==!0,Qe=fe.__currentVersion===void 0||le===!0,Re=T(I,Fe,Oe);W(34067,I,Oe);let Ke;if(Ee){_e&&Qe&&t.texStorage2D(34067,Re,xe,Fe.width,Fe.height);for(let we=0;we<6;we++){Ke=re[we].mipmaps;for(let Je=0;Je<Ke.length;Je++){let it=Ke[Je];I.format!==si?ve!==null?_e?t.compressedTexSubImage2D(34069+we,Je,0,0,it.width,it.height,ve,it.data):t.compressedTexImage2D(34069+we,Je,xe,it.width,it.height,0,it.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):_e?t.texSubImage2D(34069+we,Je,0,0,it.width,it.height,ve,H,it.data):t.texImage2D(34069+we,Je,xe,it.width,it.height,0,ve,H,it.data)}}}else{Ke=I.mipmaps,_e&&Qe&&(Ke.length>0&&Re++,t.texStorage2D(34067,Re,xe,re[0].width,re[0].height));for(let we=0;we<6;we++)if(Ue){_e?t.texSubImage2D(34069+we,0,0,0,re[we].width,re[we].height,ve,H,re[we].data):t.texImage2D(34069+we,0,xe,re[we].width,re[we].height,0,ve,H,re[we].data);for(let Je=0;Je<Ke.length;Je++){let yt=Ke[Je].image[we].image;_e?t.texSubImage2D(34069+we,Je+1,0,0,yt.width,yt.height,ve,H,yt.data):t.texImage2D(34069+we,Je+1,xe,yt.width,yt.height,0,ve,H,yt.data)}}else{_e?t.texSubImage2D(34069+we,0,0,0,ve,H,re[we]):t.texImage2D(34069+we,0,xe,ve,H,re[we]);for(let Je=0;Je<Ke.length;Je++){let it=Ke[Je];_e?t.texSubImage2D(34069+we,Je+1,0,0,ve,H,it.image[we]):t.texImage2D(34069+we,Je+1,xe,ve,H,it.image[we])}}}_(I,Oe)&&M(34067),fe.__currentVersion=fe.version,I.onUpdate&&I.onUpdate(I)}R.__version=I.version}function X(R,I,J,le,fe){let Ee=s.convert(J.format,J.encoding),Ue=s.convert(J.type),re=x(J.internalFormat,Ee,Ue,J.encoding);n.get(I).__hasExternalTextures||(fe===32879||fe===35866?t.texImage3D(fe,0,re,I.width,I.height,I.depth,0,Ee,Ue,null):t.texImage2D(fe,0,re,I.width,I.height,0,Ee,Ue,null)),t.bindFramebuffer(36160,R),Pe(I)?d.framebufferTexture2DMultisampleEXT(36160,le,fe,n.get(J).__webglTexture,0,de(I)):r.framebufferTexture2D(36160,le,fe,n.get(J).__webglTexture,0),t.bindFramebuffer(36160,null)}function ne(R,I,J){if(r.bindRenderbuffer(36161,R),I.depthBuffer&&!I.stencilBuffer){let le=33189;if(J||Pe(I)){let fe=I.depthTexture;fe&&fe.isDepthTexture&&(fe.type===Ti?le=36012:fe.type===cs&&(le=33190));let Ee=de(I);Pe(I)?d.renderbufferStorageMultisampleEXT(36161,Ee,le,I.width,I.height):r.renderbufferStorageMultisample(36161,Ee,le,I.width,I.height)}else r.renderbufferStorage(36161,le,I.width,I.height);r.framebufferRenderbuffer(36160,36096,36161,R)}else if(I.depthBuffer&&I.stencilBuffer){let le=de(I);J&&Pe(I)===!1?r.renderbufferStorageMultisample(36161,le,35056,I.width,I.height):Pe(I)?d.renderbufferStorageMultisampleEXT(36161,le,35056,I.width,I.height):r.renderbufferStorage(36161,34041,I.width,I.height),r.framebufferRenderbuffer(36160,33306,36161,R)}else{let le=I.isWebGLMultipleRenderTargets===!0?I.texture:[I.texture];for(let fe=0;fe<le.length;fe++){let Ee=le[fe],Ue=s.convert(Ee.format,Ee.encoding),re=s.convert(Ee.type),Fe=x(Ee.internalFormat,Ue,re,Ee.encoding),Oe=de(I);J&&Pe(I)===!1?r.renderbufferStorageMultisample(36161,Oe,Fe,I.width,I.height):Pe(I)?d.renderbufferStorageMultisampleEXT(36161,Oe,Fe,I.width,I.height):r.renderbufferStorage(36161,Fe,I.width,I.height)}}r.bindRenderbuffer(36161,null)}function ce(R,I){if(I&&I.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,R),!(I.depthTexture&&I.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(I.depthTexture).__webglTexture||I.depthTexture.image.width!==I.width||I.depthTexture.image.height!==I.height)&&(I.depthTexture.image.width=I.width,I.depthTexture.image.height=I.height,I.depthTexture.needsUpdate=!0),G(I.depthTexture,0);let le=n.get(I.depthTexture).__webglTexture,fe=de(I);if(I.depthTexture.format===Bo)Pe(I)?d.framebufferTexture2DMultisampleEXT(36160,36096,3553,le,0,fe):r.framebufferTexture2D(36160,36096,3553,le,0);else if(I.depthTexture.format===Gs)Pe(I)?d.framebufferTexture2DMultisampleEXT(36160,33306,3553,le,0,fe):r.framebufferTexture2D(36160,33306,3553,le,0);else throw new Error("Unknown depthTexture format")}function oe(R){let I=n.get(R),J=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!I.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");ce(I.__webglFramebuffer,R)}else if(J){I.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(36160,I.__webglFramebuffer[le]),I.__webglDepthbuffer[le]=r.createRenderbuffer(),ne(I.__webglDepthbuffer[le],R,!1)}else t.bindFramebuffer(36160,I.__webglFramebuffer),I.__webglDepthbuffer=r.createRenderbuffer(),ne(I.__webglDepthbuffer,R,!1);t.bindFramebuffer(36160,null)}function Te(R,I,J){let le=n.get(R);I!==void 0&&X(le.__webglFramebuffer,R,R.texture,36064,3553),J!==void 0&&oe(R)}function me(R){let I=R.texture,J=n.get(R),le=n.get(I);R.addEventListener("dispose",P),R.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=r.createTexture()),le.__version=I.version,o.memory.textures++);let fe=R.isWebGLCubeRenderTarget===!0,Ee=R.isWebGLMultipleRenderTargets===!0,Ue=w(R)||a;if(fe){J.__webglFramebuffer=[];for(let re=0;re<6;re++)J.__webglFramebuffer[re]=r.createFramebuffer()}else{if(J.__webglFramebuffer=r.createFramebuffer(),Ee)if(i.drawBuffers){let re=R.texture;for(let Fe=0,Oe=re.length;Fe<Oe;Fe++){let ve=n.get(re[Fe]);ve.__webglTexture===void 0&&(ve.__webglTexture=r.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&R.samples>0&&Pe(R)===!1){let re=Ee?I:[I];J.__webglMultisampledFramebuffer=r.createFramebuffer(),J.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,J.__webglMultisampledFramebuffer);for(let Fe=0;Fe<re.length;Fe++){let Oe=re[Fe];J.__webglColorRenderbuffer[Fe]=r.createRenderbuffer(),r.bindRenderbuffer(36161,J.__webglColorRenderbuffer[Fe]);let ve=s.convert(Oe.format,Oe.encoding),H=s.convert(Oe.type),xe=x(Oe.internalFormat,ve,H,Oe.encoding),_e=de(R);r.renderbufferStorageMultisample(36161,_e,xe,R.width,R.height),r.framebufferRenderbuffer(36160,36064+Fe,36161,J.__webglColorRenderbuffer[Fe])}r.bindRenderbuffer(36161,null),R.depthBuffer&&(J.__webglDepthRenderbuffer=r.createRenderbuffer(),ne(J.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(36160,null)}}if(fe){t.bindTexture(34067,le.__webglTexture),W(34067,I,Ue);for(let re=0;re<6;re++)X(J.__webglFramebuffer[re],R,I,36064,34069+re);_(I,Ue)&&M(34067),t.unbindTexture()}else if(Ee){let re=R.texture;for(let Fe=0,Oe=re.length;Fe<Oe;Fe++){let ve=re[Fe],H=n.get(ve);t.bindTexture(3553,H.__webglTexture),W(3553,ve,Ue),X(J.__webglFramebuffer,R,ve,36064+Fe,3553),_(ve,Ue)&&M(3553)}t.unbindTexture()}else{let re=3553;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(a?re=R.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(re,le.__webglTexture),W(re,I,Ue),X(J.__webglFramebuffer,R,I,36064,re),_(I,Ue)&&M(re),t.unbindTexture()}R.depthBuffer&&oe(R)}function ge(R){let I=w(R)||a,J=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let le=0,fe=J.length;le<fe;le++){let Ee=J[le];if(_(Ee,I)){let Ue=R.isWebGLCubeRenderTarget?34067:3553,re=n.get(Ee).__webglTexture;t.bindTexture(Ue,re),M(Ue),t.unbindTexture()}}}function ye(R){if(a&&R.samples>0&&Pe(R)===!1){let I=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],J=R.width,le=R.height,fe=16384,Ee=[],Ue=R.stencilBuffer?33306:36096,re=n.get(R),Fe=R.isWebGLMultipleRenderTargets===!0;if(Fe)for(let Oe=0;Oe<I.length;Oe++)t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Oe,36161,null),t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Oe,3553,null,0);t.bindFramebuffer(36008,re.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,re.__webglFramebuffer);for(let Oe=0;Oe<I.length;Oe++){Ee.push(36064+Oe),R.depthBuffer&&Ee.push(Ue);let ve=re.__ignoreDepthValues!==void 0?re.__ignoreDepthValues:!1;if(ve===!1&&(R.depthBuffer&&(fe|=256),R.stencilBuffer&&(fe|=1024)),Fe&&r.framebufferRenderbuffer(36008,36064,36161,re.__webglColorRenderbuffer[Oe]),ve===!0&&(r.invalidateFramebuffer(36008,[Ue]),r.invalidateFramebuffer(36009,[Ue])),Fe){let H=n.get(I[Oe]).__webglTexture;r.framebufferTexture2D(36009,36064,3553,H,0)}r.blitFramebuffer(0,0,J,le,0,0,J,le,fe,9728),f&&r.invalidateFramebuffer(36008,Ee)}if(t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,null),Fe)for(let Oe=0;Oe<I.length;Oe++){t.bindFramebuffer(36160,re.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(36160,36064+Oe,36161,re.__webglColorRenderbuffer[Oe]);let ve=n.get(I[Oe]).__webglTexture;t.bindFramebuffer(36160,re.__webglFramebuffer),r.framebufferTexture2D(36009,36064+Oe,3553,ve,0)}t.bindFramebuffer(36009,re.__webglMultisampledFramebuffer)}}function de(R){return Math.min(h,R.samples)}function Pe(R){let I=n.get(R);return a&&R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&I.__useRenderToTexture!==!1}function Ne(R){let I=o.render.frame;m.get(R)!==I&&(m.set(R,I),R.update())}function Ze(R,I){let J=R.encoding,le=R.format,fe=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||R.format===Zg||J!==Mr&&(J===Xe?a===!1?e.has("EXT_sRGB")===!0&&le===si?(R.format=Zg,R.minFilter=at,R.generateMipmaps=!1):I=Qd.sRGBToLinear(I):(le!==si||fe!==Ut)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",J)),I}this.allocateTextureUnit=Y,this.resetTextureUnits=z,this.setTexture2D=G,this.setTexture2DArray=Q,this.setTexture3D=V,this.setTextureCube=k,this.rebindTextures=Te,this.setupRenderTarget=me,this.updateRenderTargetMipmap=ge,this.updateMultisampleRenderTarget=ye,this.setupDepthRenderbuffer=oe,this.setupFrameBufferTexture=X,this.useMultisampledRTT=Pe}function yO(r,e,t){let n=t.isWebGL2;function i(s,o=null){let a;if(s===Ut)return 5121;if(s===lP)return 32819;if(s===cP)return 32820;if(s===sP)return 5120;if(s===oP)return 5122;if(s===Ew)return 5123;if(s===aP)return 5124;if(s===cs)return 5125;if(s===Ti)return 5126;if(s===bu)return n?5131:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===uP)return 6406;if(s===si)return 6408;if(s===dP)return 6409;if(s===fP)return 6410;if(s===Bo)return 6402;if(s===Gs)return 34041;if(s===pP)return 6403;if(s===hP)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(s===Zg)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===mP)return 36244;if(s===gP)return 33319;if(s===yP)return 33320;if(s===vP)return 36249;if(s===cg||s===ug||s===hg||s===dg)if(o===Xe)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===cg)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===ug)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===hg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===dg)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===cg)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===ug)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===hg)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===dg)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Jx||s===$x||s===eb||s===tb)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Jx)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===$x)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===eb)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===tb)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===xP)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===nb||s===rb)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===nb)return o===Xe?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===rb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===ib||s===sb||s===ob||s===ab||s===lb||s===cb||s===ub||s===hb||s===db||s===fb||s===pb||s===mb||s===gb||s===yb)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===ib)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===sb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===ob)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===ab)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===lb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===cb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===ub)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===hb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===db)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===fb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===pb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===mb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===gb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===yb)return o===Xe?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===vb)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===vb)return o===Xe?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return s===Bs?n?34042:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):r[s]!==void 0?r[s]:null}return{convert:i}}var ly=class extends nn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Rs=class extends ht{constructor(){super(),this.isGroup=!0,this.type="Group"}},vO={type:"move"},yu=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Rs,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Rs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Rs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,s=null,o=null,a=this._targetRay,l=this._grip,u=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(u&&e.hand){o=!0;for(let p of e.hand.values()){let g=t.getJointPose(p,n);if(u.joints[p.jointName]===void 0){let y=new Rs;y.matrixAutoUpdate=!1,y.visible=!1,u.joints[p.jointName]=y,u.add(y)}let v=u.joints[p.jointName];g!==null&&(v.matrix.fromArray(g.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=g.radius),v.visible=g!==null}let c=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],d=c.position.distanceTo(h.position),f=.02,m=.005;u.inputState.pinching&&d>f+m?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&d<=f-m&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(vO)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=s!==null),u!==null&&(u.visible=o!==null),this}},ks=class extends Yt{constructor(e,t,n,i,s,o,a,l,u,c){if(c=c!==void 0?c:Bo,c!==Bo&&c!==Gs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&c===Bo&&(n=cs),n===void 0&&c===Gs&&(n=Bs),super(null,i,s,o,a,l,c,n,u),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Ft,this.minFilter=l!==void 0?l:Ft,this.flipY=!1,this.generateMipmaps=!1}},cy=class extends Lt{constructor(e,t){super();let n=this,i=null,s=1,o=null,a="local-floor",l=null,u=null,c=null,h=null,d=null,f=null,m=t.getContextAttributes(),p=null,g=null,v=[],y=[],b=new nn;b.layers.enable(1),b.viewport=new He;let w=new nn;w.layers.enable(2),w.viewport=new He;let S=[b,w],_=new ly;_.layers.enable(1),_.layers.enable(2);let M=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(U){let G=v[U];return G===void 0&&(G=new yu,v[U]=G),G.getTargetRaySpace()},this.getControllerGrip=function(U){let G=v[U];return G===void 0&&(G=new yu,v[U]=G),G.getGripSpace()},this.getHand=function(U){let G=v[U];return G===void 0&&(G=new yu,v[U]=G),G.getHandSpace()};function T(U){let G=y.indexOf(U.inputSource);if(G===-1)return;let Q=v[G];Q!==void 0&&Q.dispatchEvent({type:U.type,data:U.inputSource})}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",C);for(let U=0;U<v.length;U++){let G=y[U];G!==null&&(y[U]=null,v[U].disconnect(G))}M=null,x=null,e.setRenderTarget(p),d=null,h=null,c=null,i=null,g=null,Y.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(U){s=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(U){a=U,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(U){l=U},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(U){if(i=U,i!==null){if(p=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",C),m.xrCompatible!==!0&&await t.makeXRCompatible(),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let G={antialias:i.renderState.layers===void 0?m.antialias:!0,alpha:m.alpha,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(i,t,G),i.updateRenderState({baseLayer:d}),g=new dt(d.framebufferWidth,d.framebufferHeight,{format:si,type:Ut,encoding:e.outputEncoding})}else{let G=null,Q=null,V=null;m.depth&&(V=m.stencil?35056:33190,G=m.stencil?Gs:Bo,Q=m.stencil?Bs:cs);let k={colorFormat:32856,depthFormat:V,scaleFactor:s};c=new XRWebGLBinding(i,t),h=c.createProjectionLayer(k),i.updateRenderState({layers:[h]}),g=new dt(h.textureWidth,h.textureHeight,{format:si,type:Ut,depthTexture:new ks(h.textureWidth,h.textureHeight,Q,void 0,void 0,void 0,void 0,void 0,void 0,G),stencilBuffer:m.stencil,encoding:e.outputEncoding,samples:m.antialias?4:0});let j=e.properties.get(g);j.__ignoreDepthValues=h.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(1),l=null,o=await i.requestReferenceSpace(a),Y.setContext(i),Y.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};function C(U){for(let G=0;G<U.removed.length;G++){let Q=U.removed[G],V=y.indexOf(Q);V>=0&&(y[V]=null,v[V].dispatchEvent({type:"disconnected",data:Q}))}for(let G=0;G<U.added.length;G++){let Q=U.added[G],V=y.indexOf(Q);if(V===-1){for(let j=0;j<v.length;j++)if(j>=y.length){y.push(Q),V=j;break}else if(y[j]===null){y[j]=Q,V=j;break}if(V===-1)break}let k=v[V];k&&k.dispatchEvent({type:"connected",data:Q})}}let P=new A,O=new A;function D(U,G,Q){P.setFromMatrixPosition(G.matrixWorld),O.setFromMatrixPosition(Q.matrixWorld);let V=P.distanceTo(O),k=G.projectionMatrix.elements,j=Q.projectionMatrix.elements,q=k[14]/(k[10]-1),W=k[14]/(k[10]+1),he=(k[9]+1)/k[5],ie=(k[9]-1)/k[5],K=(k[8]-1)/k[0],X=(j[8]+1)/j[0],ne=q*K,ce=q*X,oe=V/(-K+X),Te=oe*-K;G.matrixWorld.decompose(U.position,U.quaternion,U.scale),U.translateX(Te),U.translateZ(oe),U.matrixWorld.compose(U.position,U.quaternion,U.scale),U.matrixWorldInverse.copy(U.matrixWorld).invert();let me=q+oe,ge=W+oe,ye=ne-Te,de=ce+(V-Te),Pe=he*W/ge*me,Ne=ie*W/ge*me;U.projectionMatrix.makePerspective(ye,de,Pe,Ne,me,ge)}function N(U,G){G===null?U.matrixWorld.copy(U.matrix):U.matrixWorld.multiplyMatrices(G.matrixWorld,U.matrix),U.matrixWorldInverse.copy(U.matrixWorld).invert()}this.updateCamera=function(U){if(i===null)return;_.near=w.near=b.near=U.near,_.far=w.far=b.far=U.far,(M!==_.near||x!==_.far)&&(i.updateRenderState({depthNear:_.near,depthFar:_.far}),M=_.near,x=_.far);let G=U.parent,Q=_.cameras;N(_,G);for(let k=0;k<Q.length;k++)N(Q[k],G);_.matrixWorld.decompose(_.position,_.quaternion,_.scale),U.position.copy(_.position),U.quaternion.copy(_.quaternion),U.scale.copy(_.scale),U.matrix.copy(_.matrix),U.matrixWorld.copy(_.matrixWorld);let V=U.children;for(let k=0,j=V.length;k<j;k++)V[k].updateMatrixWorld(!0);Q.length===2?D(_,b,w):_.projectionMatrix.copy(b.projectionMatrix)},this.getCamera=function(){return _},this.getFoveation=function(){if(h!==null)return h.fixedFoveation;if(d!==null)return d.fixedFoveation},this.setFoveation=function(U){h!==null&&(h.fixedFoveation=U),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=U)};let F=null;function z(U,G){if(u=G.getViewerPose(l||o),f=G,u!==null){let Q=u.views;d!==null&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let V=!1;Q.length!==_.cameras.length&&(_.cameras.length=0,V=!0);for(let k=0;k<Q.length;k++){let j=Q[k],q=null;if(d!==null)q=d.getViewport(j);else{let he=c.getViewSubImage(h,j);q=he.viewport,k===0&&(e.setRenderTargetTextures(g,he.colorTexture,h.ignoreDepthValues?void 0:he.depthStencilTexture),e.setRenderTarget(g))}let W=S[k];W===void 0&&(W=new nn,W.layers.enable(k),W.viewport=new He,S[k]=W),W.matrix.fromArray(j.transform.matrix),W.projectionMatrix.fromArray(j.projectionMatrix),W.viewport.set(q.x,q.y,q.width,q.height),k===0&&_.matrix.copy(W.matrix),V===!0&&_.cameras.push(W)}}for(let Q=0;Q<v.length;Q++){let V=y[Q],k=v[Q];V!==null&&k!==void 0&&k.update(V,G,l||o)}F&&F(U,G),f=null}let Y=new Dw;Y.setAnimationLoop(z),this.setAnimationLoop=function(U){F=U},this.dispose=function(){}}};function xO(r,e){function t(p,g){p.fogColor.value.copy(g.color),g.isFog?(p.fogNear.value=g.near,p.fogFar.value=g.far):g.isFogExp2&&(p.fogDensity.value=g.density)}function n(p,g,v,y,b){g.isMeshBasicMaterial||g.isMeshLambertMaterial?i(p,g):g.isMeshToonMaterial?(i(p,g),c(p,g)):g.isMeshPhongMaterial?(i(p,g),u(p,g)):g.isMeshStandardMaterial?(i(p,g),h(p,g),g.isMeshPhysicalMaterial&&d(p,g,b)):g.isMeshMatcapMaterial?(i(p,g),f(p,g)):g.isMeshDepthMaterial?i(p,g):g.isMeshDistanceMaterial?(i(p,g),m(p,g)):g.isMeshNormalMaterial?i(p,g):g.isLineBasicMaterial?(s(p,g),g.isLineDashedMaterial&&o(p,g)):g.isPointsMaterial?a(p,g,v,y):g.isSpriteMaterial?l(p,g):g.isShadowMaterial?(p.color.value.copy(g.color),p.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(p,g){p.opacity.value=g.opacity,g.color&&p.diffuse.value.copy(g.color),g.emissive&&p.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.bumpMap&&(p.bumpMap.value=g.bumpMap,p.bumpScale.value=g.bumpScale,g.side===un&&(p.bumpScale.value*=-1)),g.displacementMap&&(p.displacementMap.value=g.displacementMap,p.displacementScale.value=g.displacementScale,p.displacementBias.value=g.displacementBias),g.emissiveMap&&(p.emissiveMap.value=g.emissiveMap),g.normalMap&&(p.normalMap.value=g.normalMap,p.normalScale.value.copy(g.normalScale),g.side===un&&p.normalScale.value.negate()),g.specularMap&&(p.specularMap.value=g.specularMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v=e.get(g).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=g.reflectivity,p.ior.value=g.ior,p.refractionRatio.value=g.refractionRatio),g.lightMap){p.lightMap.value=g.lightMap;let w=r.physicallyCorrectLights!==!0?Math.PI:1;p.lightMapIntensity.value=g.lightMapIntensity*w}g.aoMap&&(p.aoMap.value=g.aoMap,p.aoMapIntensity.value=g.aoMapIntensity);let y;g.map?y=g.map:g.specularMap?y=g.specularMap:g.displacementMap?y=g.displacementMap:g.normalMap?y=g.normalMap:g.bumpMap?y=g.bumpMap:g.roughnessMap?y=g.roughnessMap:g.metalnessMap?y=g.metalnessMap:g.alphaMap?y=g.alphaMap:g.emissiveMap?y=g.emissiveMap:g.clearcoatMap?y=g.clearcoatMap:g.clearcoatNormalMap?y=g.clearcoatNormalMap:g.clearcoatRoughnessMap?y=g.clearcoatRoughnessMap:g.iridescenceMap?y=g.iridescenceMap:g.iridescenceThicknessMap?y=g.iridescenceThicknessMap:g.specularIntensityMap?y=g.specularIntensityMap:g.specularColorMap?y=g.specularColorMap:g.transmissionMap?y=g.transmissionMap:g.thicknessMap?y=g.thicknessMap:g.sheenColorMap?y=g.sheenColorMap:g.sheenRoughnessMap&&(y=g.sheenRoughnessMap),y!==void 0&&(y.isWebGLRenderTarget&&(y=y.texture),y.matrixAutoUpdate===!0&&y.updateMatrix(),p.uvTransform.value.copy(y.matrix));let b;g.aoMap?b=g.aoMap:g.lightMap&&(b=g.lightMap),b!==void 0&&(b.isWebGLRenderTarget&&(b=b.texture),b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uv2Transform.value.copy(b.matrix))}function s(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity}function o(p,g){p.dashSize.value=g.dashSize,p.totalSize.value=g.dashSize+g.gapSize,p.scale.value=g.scale}function a(p,g,v,y){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.size.value=g.size*v,p.scale.value=y*.5,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let b;g.map?b=g.map:g.alphaMap&&(b=g.alphaMap),b!==void 0&&(b.matrixAutoUpdate===!0&&b.updateMatrix(),p.uvTransform.value.copy(b.matrix))}function l(p,g){p.diffuse.value.copy(g.color),p.opacity.value=g.opacity,p.rotation.value=g.rotation,g.map&&(p.map.value=g.map),g.alphaMap&&(p.alphaMap.value=g.alphaMap),g.alphaTest>0&&(p.alphaTest.value=g.alphaTest);let v;g.map?v=g.map:g.alphaMap&&(v=g.alphaMap),v!==void 0&&(v.matrixAutoUpdate===!0&&v.updateMatrix(),p.uvTransform.value.copy(v.matrix))}function u(p,g){p.specular.value.copy(g.specular),p.shininess.value=Math.max(g.shininess,1e-4)}function c(p,g){g.gradientMap&&(p.gradientMap.value=g.gradientMap)}function h(p,g){p.roughness.value=g.roughness,p.metalness.value=g.metalness,g.roughnessMap&&(p.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(p.metalnessMap.value=g.metalnessMap),e.get(g).envMap&&(p.envMapIntensity.value=g.envMapIntensity)}function d(p,g,v){p.ior.value=g.ior,g.sheen>0&&(p.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),p.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(p.sheenColorMap.value=g.sheenColorMap),g.sheenRoughnessMap&&(p.sheenRoughnessMap.value=g.sheenRoughnessMap)),g.clearcoat>0&&(p.clearcoat.value=g.clearcoat,p.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(p.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(p.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),p.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===un&&p.clearcoatNormalScale.value.negate())),g.iridescence>0&&(p.iridescence.value=g.iridescence,p.iridescenceIOR.value=g.iridescenceIOR,p.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(p.iridescenceMap.value=g.iridescenceMap),g.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=g.iridescenceThicknessMap)),g.transmission>0&&(p.transmission.value=g.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),g.transmissionMap&&(p.transmissionMap.value=g.transmissionMap),p.thickness.value=g.thickness,g.thicknessMap&&(p.thicknessMap.value=g.thicknessMap),p.attenuationDistance.value=g.attenuationDistance,p.attenuationColor.value.copy(g.attenuationColor)),p.specularIntensity.value=g.specularIntensity,p.specularColor.value.copy(g.specularColor),g.specularIntensityMap&&(p.specularIntensityMap.value=g.specularIntensityMap),g.specularColorMap&&(p.specularColorMap.value=g.specularColorMap)}function f(p,g){g.matcap&&(p.matcap.value=g.matcap)}function m(p,g){p.referencePosition.value.copy(g.referencePosition),p.nearDistance.value=g.nearDistance,p.farDistance.value=g.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:n}}function bO(){let r=Yd("canvas");return r.style.display="block",r}function Ny(r={}){this.isWebGLRenderer=!0;let e=r.canvas!==void 0?r.canvas:bO(),t=r.context!==void 0?r.context:null,n=r.depth!==void 0?r.depth:!0,i=r.stencil!==void 0?r.stencil:!0,s=r.antialias!==void 0?r.antialias:!1,o=r.premultipliedAlpha!==void 0?r.premultipliedAlpha:!0,a=r.preserveDrawingBuffer!==void 0?r.preserveDrawingBuffer:!1,l=r.powerPreference!==void 0?r.powerPreference:"default",u=r.failIfMajorPerformanceCaveat!==void 0?r.failIfMajorPerformanceCaveat:!1,c;t!==null?c=t.getContextAttributes().alpha:c=r.alpha!==void 0?r.alpha:!1;let h=null,d=null,f=[],m=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Mr,this.physicallyCorrectLights=!1,this.toneMapping=us,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});let p=this,g=!1,v=0,y=0,b=null,w=-1,S=null,_=new He,M=new He,x=null,T=e.width,E=e.height,C=1,P=null,O=null,D=new He(0,0,T,E),N=new He(0,0,T,E),F=!1,z=new _u,Y=!1,U=!1,G=null,Q=new be,V=new B,k=new A,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function q(){return b===null?C:1}let W=t;function he(L,$){for(let se=0;se<L.length;se++){let te=L[se],ue=e.getContext(te,$);if(ue!==null)return ue}return null}try{let L={alpha:!0,depth:n,stencil:i,antialias:s,premultipliedAlpha:o,preserveDrawingBuffer:a,powerPreference:l,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Qo}`),e.addEventListener("webglcontextlost",H,!1),e.addEventListener("webglcontextrestored",xe,!1),e.addEventListener("webglcontextcreationerror",_e,!1),W===null){let $=["webgl2","webgl","experimental-webgl"];if(p.isWebGL1Renderer===!0&&$.shift(),W=he($,L),W===null)throw he($)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}W.getShaderPrecisionFormat===void 0&&(W.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let ie,K,X,ne,ce,oe,Te,me,ge,ye,de,Pe,Ne,Ze,R,I,J,le,fe,Ee,Ue,re,Fe;function Oe(){ie=new kI(W),K=new NI(W,ie,r),ie.init(K),re=new yO(W,ie,K),X=new mO(W,ie,K),ne=new WI,ce=new rO,oe=new gO(W,ie,X,ce,K,re,ne),Te=new FI(p),me=new zI(p),ge=new n2(W,K),Fe=new OI(W,ie,ge,K),ye=new VI(W,ge,ne,Fe),de=new YI(W,ye,ge,ne),fe=new XI(W,K,oe),I=new BI(ce),Pe=new nO(p,Te,me,ie,K,Fe,I),Ne=new xO(p,ce),Ze=new sO,R=new hO(ie,K),le=new LI(p,Te,X,de,c,o),J=new pO(p,de,K),Ee=new RI(W,ie,ne,K),Ue=new HI(W,ie,ne,K),ne.programs=Pe.programs,p.capabilities=K,p.extensions=ie,p.properties=ce,p.renderLists=Ze,p.shadowMap=J,p.state=X,p.info=ne}Oe();let ve=new cy(p,W);this.xr=ve,this.getContext=function(){return W},this.getContextAttributes=function(){return W.getContextAttributes()},this.forceContextLoss=function(){let L=ie.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=ie.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return C},this.setPixelRatio=function(L){L!==void 0&&(C=L,this.setSize(T,E,!1))},this.getSize=function(L){return L.set(T,E)},this.setSize=function(L,$,se){if(ve.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=L,E=$,e.width=Math.floor(L*C),e.height=Math.floor($*C),se!==!1&&(e.style.width=L+"px",e.style.height=$+"px"),this.setViewport(0,0,L,$)},this.getDrawingBufferSize=function(L){return L.set(T*C,E*C).floor()},this.setDrawingBufferSize=function(L,$,se){T=L,E=$,C=se,e.width=Math.floor(L*se),e.height=Math.floor($*se),this.setViewport(0,0,L,$)},this.getCurrentViewport=function(L){return L.copy(_)},this.getViewport=function(L){return L.copy(D)},this.setViewport=function(L,$,se,te){L.isVector4?D.set(L.x,L.y,L.z,L.w):D.set(L,$,se,te),X.viewport(_.copy(D).multiplyScalar(C).floor())},this.getScissor=function(L){return L.copy(N)},this.setScissor=function(L,$,se,te){L.isVector4?N.set(L.x,L.y,L.z,L.w):N.set(L,$,se,te),X.scissor(M.copy(N).multiplyScalar(C).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(L){X.setScissorTest(F=L)},this.setOpaqueSort=function(L){P=L},this.setTransparentSort=function(L){O=L},this.getClearColor=function(L){return L.copy(le.getClearColor())},this.setClearColor=function(){le.setClearColor.apply(le,arguments)},this.getClearAlpha=function(){return le.getClearAlpha()},this.setClearAlpha=function(){le.setClearAlpha.apply(le,arguments)},this.clear=function(L=!0,$=!0,se=!0){let te=0;L&&(te|=16384),$&&(te|=256),se&&(te|=1024),W.clear(te)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",H,!1),e.removeEventListener("webglcontextrestored",xe,!1),e.removeEventListener("webglcontextcreationerror",_e,!1),Ze.dispose(),R.dispose(),ce.dispose(),Te.dispose(),me.dispose(),de.dispose(),Fe.dispose(),Pe.dispose(),ve.dispose(),ve.removeEventListener("sessionstart",it),ve.removeEventListener("sessionend",yt),G&&(G.dispose(),G=null),At.stop()};function H(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),g=!0}function xe(){console.log("THREE.WebGLRenderer: Context Restored."),g=!1;let L=ne.autoReset,$=J.enabled,se=J.autoUpdate,te=J.needsUpdate,ue=J.type;Oe(),ne.autoReset=L,J.enabled=$,J.autoUpdate=se,J.needsUpdate=te,J.type=ue}function _e(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function Qe(L){let $=L.target;$.removeEventListener("dispose",Qe),Re($)}function Re(L){Ke(L),ce.remove(L)}function Ke(L){let $=ce.get(L).programs;$!==void 0&&($.forEach(function(se){Pe.releaseProgram(se)}),L.isShaderMaterial&&Pe.releaseShaderCache(L))}this.renderBufferDirect=function(L,$,se,te,ue,et){$===null&&($=j);let rt=ue.isMesh&&ue.matrixWorld.determinant()<0,ot=xC(L,$,se,te,ue);X.setMaterial(te,rt);let st=se.index,Dt=se.attributes.position;if(st===null){if(Dt===void 0||Dt.count===0)return}else if(st.count===0)return;let pt=1;te.wireframe===!0&&(st=ye.getWireframeAttribute(se),pt=2),Fe.setup(ue,te,ot,se,st);let vt,qt=Ee;st!==null&&(vt=ge.get(st),qt=Ue,qt.setIndex(vt));let Po=st!==null?st.count:Dt.count,Ma=se.drawRange.start*pt,Ea=se.drawRange.count*pt,wi=et!==null?et.start*pt:0,_t=et!==null?et.count*pt:1/0,Ca=Math.max(Ma,wi),ln=Math.min(Po,Ma+Ea,wi+_t)-1,Si=Math.max(0,ln-Ca+1);if(Si!==0){if(ue.isMesh)te.wireframe===!0?(X.setLineWidth(te.wireframeLinewidth*q()),qt.setMode(1)):qt.setMode(4);else if(ue.isLine){let Ms=te.linewidth;Ms===void 0&&(Ms=1),X.setLineWidth(Ms*q()),ue.isLineSegments?qt.setMode(1):ue.isLineLoop?qt.setMode(2):qt.setMode(3)}else ue.isPoints?qt.setMode(0):ue.isSprite&&qt.setMode(4);if(ue.isInstancedMesh)qt.renderInstances(Ca,Si,ue.count);else if(se.isInstancedBufferGeometry){let Ms=Math.min(se.instanceCount,se._maxInstanceCount);qt.renderInstances(Ca,Si,Ms)}else qt.render(Ca,Si)}},this.compile=function(L,$){d=R.get(L),d.init(),m.push(d),L.traverseVisible(function(se){se.isLight&&se.layers.test($.layers)&&(d.pushLight(se),se.castShadow&&d.pushShadow(se))}),d.setupLights(p.physicallyCorrectLights),L.traverse(function(se){let te=se.material;if(te)if(Array.isArray(te))for(let ue=0;ue<te.length;ue++){let et=te[ue];sg(et,L,se)}else sg(te,L,se)}),m.pop(),d=null};let we=null;function Je(L){we&&we(L)}function it(){At.stop()}function yt(){At.start()}let At=new Dw;At.setAnimationLoop(Je),typeof self<"u"&&At.setContext(self),this.setAnimationLoop=function(L){we=L,ve.setAnimationLoop(L),L===null?At.stop():At.start()},ve.addEventListener("sessionstart",it),ve.addEventListener("sessionend",yt),this.render=function(L,$){if($!==void 0&&$.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(g===!0)return;L.autoUpdate===!0&&L.updateMatrixWorld(),$.parent===null&&$.updateMatrixWorld(),ve.enabled===!0&&ve.isPresenting===!0&&(ve.cameraAutoUpdate===!0&&ve.updateCamera($),$=ve.getCamera()),L.isScene===!0&&L.onBeforeRender(p,L,$,b),d=R.get(L,m.length),d.init(),m.push(d),Q.multiplyMatrices($.projectionMatrix,$.matrixWorldInverse),z.setFromProjectionMatrix(Q),U=this.localClippingEnabled,Y=I.init(this.clippingPlanes,U,$),h=Ze.get(L,f.length),h.init(),f.push(h),cr(L,$,0,p.sortObjects),h.finish(),p.sortObjects===!0&&h.sort(P,O),Y===!0&&I.beginShadows();let se=d.state.shadowsArray;if(J.render(se,L,$),Y===!0&&I.endShadows(),this.info.autoReset===!0&&this.info.reset(),le.render(h,L),d.setupLights(p.physicallyCorrectLights),$.isArrayCamera){let te=$.cameras;for(let ue=0,et=te.length;ue<et;ue++){let rt=te[ue];pd(h,L,rt,rt.viewport)}}else pd(h,L,$);b!==null&&(oe.updateMultisampleRenderTarget(b),oe.updateRenderTargetMipmap(b)),L.isScene===!0&&L.onAfterRender(p,L,$),Fe.resetDefaultState(),w=-1,S=null,m.pop(),m.length>0?d=m[m.length-1]:d=null,f.pop(),f.length>0?h=f[f.length-1]:h=null};function cr(L,$,se,te){if(L.visible===!1)return;if(L.layers.test($.layers)){if(L.isGroup)se=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update($);else if(L.isLight)d.pushLight(L),L.castShadow&&d.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||z.intersectsSprite(L)){te&&k.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let rt=de.update(L),ot=L.material;ot.visible&&h.push(L,rt,ot,se,k.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(L.isSkinnedMesh&&L.skeleton.frame!==ne.render.frame&&(L.skeleton.update(),L.skeleton.frame=ne.render.frame),!L.frustumCulled||z.intersectsObject(L))){te&&k.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let rt=de.update(L),ot=L.material;if(Array.isArray(ot)){let st=rt.groups;for(let Dt=0,pt=st.length;Dt<pt;Dt++){let vt=st[Dt],qt=ot[vt.materialIndex];qt&&qt.visible&&h.push(L,rt,qt,se,k.z,vt)}}else ot.visible&&h.push(L,rt,ot,se,k.z,null)}}let et=L.children;for(let rt=0,ot=et.length;rt<ot;rt++)cr(et[rt],$,se,te)}function pd(L,$,se,te){let ue=L.opaque,et=L.transmissive,rt=L.transparent;d.setupLightsView(se),et.length>0&&Ta(ue,$,se),te&&X.viewport(_.copy(te)),ue.length>0&&md(ue,$,se),et.length>0&&md(et,$,se),rt.length>0&&md(rt,$,se),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function Ta(L,$,se){let te=K.isWebGL2;G===null&&(G=new dt(1,1,{generateMipmaps:!0,type:ie.has("EXT_color_buffer_half_float")?bu:Ut,minFilter:fl,samples:te&&s===!0?4:0})),p.getDrawingBufferSize(V),te?G.setSize(V.x,V.y):G.setSize(Xd(V.x),Xd(V.y));let ue=p.getRenderTarget();p.setRenderTarget(G),p.clear();let et=p.toneMapping;p.toneMapping=us,md(L,$,se),p.toneMapping=et,oe.updateMultisampleRenderTarget(G),oe.updateRenderTargetMipmap(G),p.setRenderTarget(ue)}function md(L,$,se){let te=$.isScene===!0?$.overrideMaterial:null;for(let ue=0,et=L.length;ue<et;ue++){let rt=L[ue],ot=rt.object,st=rt.geometry,Dt=te===null?rt.material:te,pt=rt.group;ot.layers.test(se.layers)&&vC(ot,$,se,st,Dt,pt)}}function vC(L,$,se,te,ue,et){L.onBeforeRender(p,$,se,te,ue,et),L.modelViewMatrix.multiplyMatrices(se.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),ue.onBeforeRender(p,$,se,te,L,et),ue.transparent===!0&&ue.side===tr?(ue.side=un,ue.needsUpdate=!0,p.renderBufferDirect(se,$,te,ue,L,et),ue.side=Gr,ue.needsUpdate=!0,p.renderBufferDirect(se,$,te,ue,L,et),ue.side=tr):p.renderBufferDirect(se,$,te,ue,L,et),L.onAfterRender(p,$,se,te,ue,et)}function sg(L,$,se){$.isScene!==!0&&($=j);let te=ce.get(L),ue=d.state.lights,et=d.state.shadowsArray,rt=ue.state.version,ot=Pe.getParameters(L,ue.state,et,$,se),st=Pe.getProgramCacheKey(ot),Dt=te.programs;te.environment=L.isMeshStandardMaterial?$.environment:null,te.fog=$.fog,te.envMap=(L.isMeshStandardMaterial?me:Te).get(L.envMap||te.environment),Dt===void 0&&(L.addEventListener("dispose",Qe),Dt=new Map,te.programs=Dt);let pt=Dt.get(st);if(pt!==void 0){if(te.currentProgram===pt&&te.lightsStateVersion===rt)return kx(L,ot),pt}else ot.uniforms=Pe.getUniforms(L),L.onBuild(se,ot,p),L.onBeforeCompile(ot,p),pt=Pe.acquireProgram(ot,st),Dt.set(st,pt),te.uniforms=ot.uniforms;let vt=te.uniforms;(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(vt.clippingPlanes=I.uniform),kx(L,ot),te.needsLights=wC(L),te.lightsStateVersion=rt,te.needsLights&&(vt.ambientLightColor.value=ue.state.ambient,vt.lightProbe.value=ue.state.probe,vt.directionalLights.value=ue.state.directional,vt.directionalLightShadows.value=ue.state.directionalShadow,vt.spotLights.value=ue.state.spot,vt.spotLightShadows.value=ue.state.spotShadow,vt.rectAreaLights.value=ue.state.rectArea,vt.ltc_1.value=ue.state.rectAreaLTC1,vt.ltc_2.value=ue.state.rectAreaLTC2,vt.pointLights.value=ue.state.point,vt.pointLightShadows.value=ue.state.pointShadow,vt.hemisphereLights.value=ue.state.hemi,vt.directionalShadowMap.value=ue.state.directionalShadowMap,vt.directionalShadowMatrix.value=ue.state.directionalShadowMatrix,vt.spotShadowMap.value=ue.state.spotShadowMap,vt.spotShadowMatrix.value=ue.state.spotShadowMatrix,vt.pointShadowMap.value=ue.state.pointShadowMap,vt.pointShadowMatrix.value=ue.state.pointShadowMatrix);let qt=pt.getUniforms(),Po=qa.seqWithValue(qt.seq,vt);return te.currentProgram=pt,te.uniformsList=Po,pt}function kx(L,$){let se=ce.get(L);se.outputEncoding=$.outputEncoding,se.instancing=$.instancing,se.skinning=$.skinning,se.morphTargets=$.morphTargets,se.morphNormals=$.morphNormals,se.morphColors=$.morphColors,se.morphTargetsCount=$.morphTargetsCount,se.numClippingPlanes=$.numClippingPlanes,se.numIntersection=$.numClipIntersection,se.vertexAlphas=$.vertexAlphas,se.vertexTangents=$.vertexTangents,se.toneMapping=$.toneMapping}function xC(L,$,se,te,ue){$.isScene!==!0&&($=j),oe.resetTextureUnits();let et=$.fog,rt=te.isMeshStandardMaterial?$.environment:null,ot=b===null?p.outputEncoding:b.isXRRenderTarget===!0?b.texture.encoding:Mr,st=(te.isMeshStandardMaterial?me:Te).get(te.envMap||rt),Dt=te.vertexColors===!0&&!!se.attributes.color&&se.attributes.color.itemSize===4,pt=!!te.normalMap&&!!se.attributes.tangent,vt=!!se.morphAttributes.position,qt=!!se.morphAttributes.normal,Po=!!se.morphAttributes.color,Ma=te.toneMapped?p.toneMapping:us,Ea=se.morphAttributes.position||se.morphAttributes.normal||se.morphAttributes.color,wi=Ea!==void 0?Ea.length:0,_t=ce.get(te),Ca=d.state.lights;if(Y===!0&&(U===!0||L!==S)){let Ai=L===S&&te.id===w;I.setState(te,L,Ai)}let ln=!1;te.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==Ca.state.version||_t.outputEncoding!==ot||ue.isInstancedMesh&&_t.instancing===!1||!ue.isInstancedMesh&&_t.instancing===!0||ue.isSkinnedMesh&&_t.skinning===!1||!ue.isSkinnedMesh&&_t.skinning===!0||_t.envMap!==st||te.fog===!0&&_t.fog!==et||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==I.numPlanes||_t.numIntersection!==I.numIntersection)||_t.vertexAlphas!==Dt||_t.vertexTangents!==pt||_t.morphTargets!==vt||_t.morphNormals!==qt||_t.morphColors!==Po||_t.toneMapping!==Ma||K.isWebGL2===!0&&_t.morphTargetsCount!==wi)&&(ln=!0):(ln=!0,_t.__version=te.version);let Si=_t.currentProgram;ln===!0&&(Si=sg(te,$,ue));let Ms=!1,au=!1,og=!1,Jn=Si.getUniforms(),lu=_t.uniforms;if(X.useProgram(Si.program)&&(Ms=!0,au=!0,og=!0),te.id!==w&&(w=te.id,au=!0),Ms||S!==L){if(Jn.setValue(W,"projectionMatrix",L.projectionMatrix),K.logarithmicDepthBuffer&&Jn.setValue(W,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),S!==L&&(S=L,au=!0,og=!0),te.isShaderMaterial||te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshStandardMaterial||te.envMap){let Ai=Jn.map.cameraPosition;Ai!==void 0&&Ai.setValue(W,k.setFromMatrixPosition(L.matrixWorld))}(te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshLambertMaterial||te.isMeshBasicMaterial||te.isMeshStandardMaterial||te.isShaderMaterial)&&Jn.setValue(W,"isOrthographic",L.isOrthographicCamera===!0),(te.isMeshPhongMaterial||te.isMeshToonMaterial||te.isMeshLambertMaterial||te.isMeshBasicMaterial||te.isMeshStandardMaterial||te.isShaderMaterial||te.isShadowMaterial||ue.isSkinnedMesh)&&Jn.setValue(W,"viewMatrix",L.matrixWorldInverse)}if(ue.isSkinnedMesh){Jn.setOptional(W,ue,"bindMatrix"),Jn.setOptional(W,ue,"bindMatrixInverse");let Ai=ue.skeleton;Ai&&(K.floatVertexTextures?(Ai.boneTexture===null&&Ai.computeBoneTexture(),Jn.setValue(W,"boneTexture",Ai.boneTexture,oe),Jn.setValue(W,"boneTextureSize",Ai.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let ag=se.morphAttributes;return(ag.position!==void 0||ag.normal!==void 0||ag.color!==void 0&&K.isWebGL2===!0)&&fe.update(ue,se,te,Si),(au||_t.receiveShadow!==ue.receiveShadow)&&(_t.receiveShadow=ue.receiveShadow,Jn.setValue(W,"receiveShadow",ue.receiveShadow)),au&&(Jn.setValue(W,"toneMappingExposure",p.toneMappingExposure),_t.needsLights&&bC(lu,og),et&&te.fog===!0&&Ne.refreshFogUniforms(lu,et),Ne.refreshMaterialUniforms(lu,te,C,E,G),qa.upload(W,_t.uniformsList,lu,oe)),te.isShaderMaterial&&te.uniformsNeedUpdate===!0&&(qa.upload(W,_t.uniformsList,lu,oe),te.uniformsNeedUpdate=!1),te.isSpriteMaterial&&Jn.setValue(W,"center",ue.center),Jn.setValue(W,"modelViewMatrix",ue.modelViewMatrix),Jn.setValue(W,"normalMatrix",ue.normalMatrix),Jn.setValue(W,"modelMatrix",ue.matrixWorld),Si}function bC(L,$){L.ambientLightColor.needsUpdate=$,L.lightProbe.needsUpdate=$,L.directionalLights.needsUpdate=$,L.directionalLightShadows.needsUpdate=$,L.pointLights.needsUpdate=$,L.pointLightShadows.needsUpdate=$,L.spotLights.needsUpdate=$,L.spotLightShadows.needsUpdate=$,L.rectAreaLights.needsUpdate=$,L.hemisphereLights.needsUpdate=$}function wC(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTargetTextures=function(L,$,se){ce.get(L.texture).__webglTexture=$,ce.get(L.depthTexture).__webglTexture=se;let te=ce.get(L);te.__hasExternalTextures=!0,te.__hasExternalTextures&&(te.__autoAllocateDepthBuffer=se===void 0,te.__autoAllocateDepthBuffer||ie.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),te.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(L,$){let se=ce.get(L);se.__webglFramebuffer=$,se.__useDefaultFramebuffer=$===void 0},this.setRenderTarget=function(L,$=0,se=0){b=L,v=$,y=se;let te=!0;if(L){let st=ce.get(L);st.__useDefaultFramebuffer!==void 0?(X.bindFramebuffer(36160,null),te=!1):st.__webglFramebuffer===void 0?oe.setupRenderTarget(L):st.__hasExternalTextures&&oe.rebindTextures(L,ce.get(L.texture).__webglTexture,ce.get(L.depthTexture).__webglTexture)}let ue=null,et=!1,rt=!1;if(L){let st=L.texture;(st.isData3DTexture||st.isDataArrayTexture)&&(rt=!0);let Dt=ce.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(ue=Dt[$],et=!0):K.isWebGL2&&L.samples>0&&oe.useMultisampledRTT(L)===!1?ue=ce.get(L).__webglMultisampledFramebuffer:ue=Dt,_.copy(L.viewport),M.copy(L.scissor),x=L.scissorTest}else _.copy(D).multiplyScalar(C).floor(),M.copy(N).multiplyScalar(C).floor(),x=F;if(X.bindFramebuffer(36160,ue)&&K.drawBuffers&&te&&X.drawBuffers(L,ue),X.viewport(_),X.scissor(M),X.setScissorTest(x),et){let st=ce.get(L.texture);W.framebufferTexture2D(36160,36064,34069+$,st.__webglTexture,se)}else if(rt){let st=ce.get(L.texture),Dt=$||0;W.framebufferTextureLayer(36160,36064,st.__webglTexture,se||0,Dt)}w=-1},this.readRenderTargetPixels=function(L,$,se,te,ue,et,rt){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=ce.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&rt!==void 0&&(ot=ot[rt]),ot){X.bindFramebuffer(36160,ot);try{let st=L.texture,Dt=st.format,pt=st.type;if(Dt!==si&&re.convert(Dt)!==W.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let vt=pt===bu&&(ie.has("EXT_color_buffer_half_float")||K.isWebGL2&&ie.has("EXT_color_buffer_float"));if(pt!==Ut&&re.convert(pt)!==W.getParameter(35738)&&!(pt===Ti&&(K.isWebGL2||ie.has("OES_texture_float")||ie.has("WEBGL_color_buffer_float")))&&!vt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}$>=0&&$<=L.width-te&&se>=0&&se<=L.height-ue&&W.readPixels($,se,te,ue,re.convert(Dt),re.convert(pt),et)}finally{let st=b!==null?ce.get(b).__webglFramebuffer:null;X.bindFramebuffer(36160,st)}}},this.copyFramebufferToTexture=function(L,$,se=0){let te=Math.pow(2,-se),ue=Math.floor($.image.width*te),et=Math.floor($.image.height*te);oe.setTexture2D($,0),W.copyTexSubImage2D(3553,se,0,0,L.x,L.y,ue,et),X.unbindTexture()},this.copyTextureToTexture=function(L,$,se,te=0){let ue=$.image.width,et=$.image.height,rt=re.convert(se.format),ot=re.convert(se.type);oe.setTexture2D(se,0),W.pixelStorei(37440,se.flipY),W.pixelStorei(37441,se.premultiplyAlpha),W.pixelStorei(3317,se.unpackAlignment),$.isDataTexture?W.texSubImage2D(3553,te,L.x,L.y,ue,et,rt,ot,$.image.data):$.isCompressedTexture?W.compressedTexSubImage2D(3553,te,L.x,L.y,$.mipmaps[0].width,$.mipmaps[0].height,rt,$.mipmaps[0].data):W.texSubImage2D(3553,te,L.x,L.y,rt,ot,$.image),te===0&&se.generateMipmaps&&W.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(L,$,se,te,ue=0){if(p.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let et=L.max.x-L.min.x+1,rt=L.max.y-L.min.y+1,ot=L.max.z-L.min.z+1,st=re.convert(te.format),Dt=re.convert(te.type),pt;if(te.isData3DTexture)oe.setTexture3D(te,0),pt=32879;else if(te.isDataArrayTexture)oe.setTexture2DArray(te,0),pt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}W.pixelStorei(37440,te.flipY),W.pixelStorei(37441,te.premultiplyAlpha),W.pixelStorei(3317,te.unpackAlignment);let vt=W.getParameter(3314),qt=W.getParameter(32878),Po=W.getParameter(3316),Ma=W.getParameter(3315),Ea=W.getParameter(32877),wi=se.isCompressedTexture?se.mipmaps[0]:se.image;W.pixelStorei(3314,wi.width),W.pixelStorei(32878,wi.height),W.pixelStorei(3316,L.min.x),W.pixelStorei(3315,L.min.y),W.pixelStorei(32877,L.min.z),se.isDataTexture||se.isData3DTexture?W.texSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Dt,wi.data):se.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),W.compressedTexSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,wi.data)):W.texSubImage3D(pt,ue,$.x,$.y,$.z,et,rt,ot,st,Dt,wi),W.pixelStorei(3314,vt),W.pixelStorei(32878,qt),W.pixelStorei(3316,Po),W.pixelStorei(3315,Ma),W.pixelStorei(32877,Ea),ue===0&&te.generateMipmaps&&W.generateMipmap(pt),X.unbindTexture()},this.initTexture=function(L){L.isCubeTexture?oe.setTextureCube(L,0):L.isData3DTexture?oe.setTexture3D(L,0):L.isDataArrayTexture?oe.setTexture2DArray(L,0):oe.setTexture2D(L,0),X.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,X.reset(),Fe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var uy=class extends Ny{};uy.prototype.isWebGL1Renderer=!0;var Ka=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Le(e),this.near=t,this.far=n}clone(){return new Ka(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ir=class extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}},ef=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Qg,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Mi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},$n=new A,Go=class{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.applyMatrix4(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.applyNormalMatrix(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)$n.fromBufferAttribute(this,t),$n.transformDirection(e),this.setXYZ(t,$n.x,$n.y,$n.z);return this}setX(e,t){return this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return new Ge(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Go(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[i+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var tf=class extends Ge{constructor(e,t,n,i=1){typeof n=="number"&&(i=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};var zr=class extends Uo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Le(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},nw=new A,rw=new A,iw=new be,zg=new oi,Fd=new En,zo=class extends ht{constructor(e=new De,t=new zr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,s=t.count;i<s;i++)nw.fromBufferAttribute(t,i-1),rw.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=nw.distanceTo(rw);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Fd.copy(n.boundingSphere),Fd.applyMatrix4(i),Fd.radius+=s,e.ray.intersectsSphere(Fd)===!1)return;iw.copy(i).invert(),zg.copy(e.ray).applyMatrix4(iw);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,u=new A,c=new A,h=new A,d=new A,f=this.isLineSegments?2:1,m=n.index,g=n.attributes.position;if(m!==null){let v=Math.max(0,o.start),y=Math.min(m.count,o.start+o.count);for(let b=v,w=y-1;b<w;b+=f){let S=m.getX(b),_=m.getX(b+1);if(u.fromBufferAttribute(g,S),c.fromBufferAttribute(g,_),zg.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let x=e.ray.origin.distanceTo(d);x<e.near||x>e.far||t.push({distance:x,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}else{let v=Math.max(0,o.start),y=Math.min(g.count,o.start+o.count);for(let b=v,w=y-1;b<w;b+=f){if(u.fromBufferAttribute(g,b),c.fromBufferAttribute(g,b+1),zg.distanceSqToSegment(u,c,d,h)>l)continue;d.applyMatrix4(this.matrixWorld);let _=e.ray.origin.distanceTo(d);_<e.near||_>e.far||t.push({distance:_,point:h.clone().applyMatrix4(this.matrixWorld),index:b,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){let a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}},sw=new A,ow=new A,Vs=class extends zo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,s=t.count;i<s;i+=2)sw.fromBufferAttribute(t,i),ow.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+sw.distanceTo(ow);e.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var kr=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,i=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(i),t.push(s),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),i=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,l=s-1,u;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),u=n[i]-o,u<0)a=i+1;else if(u>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(s-1);let c=n[i],d=n[i+1]-c,f=(o-c)/d;return(i+f)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);let o=this.getPoint(i),a=this.getPoint(s),l=t||(o.isVector2?new B:new A);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new A,i=[],s=[],o=[],a=new A,l=new be;for(let f=0;f<=e;f++){let m=f/e;i[f]=this.getTangentAt(m,new A)}s[0]=new A,o[0]=new A;let u=Number.MAX_VALUE,c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=u&&(u=c,n.set(1,0,0)),h<=u&&(u=h,n.set(0,1,0)),d<=u&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let f=1;f<=e;f++){if(s[f]=s[f-1].clone(),o[f]=o[f-1].clone(),a.crossVectors(i[f-1],i[f]),a.length()>Number.EPSILON){a.normalize();let m=Math.acos(pn(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(a,m))}o[f].crossVectors(i[f],s[f])}if(t===!0){let f=Math.acos(pn(s[0].dot(s[e]),-1,1));f/=e,i[0].dot(a.crossVectors(s[0],s[e]))>0&&(f=-f);for(let m=1;m<=e;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ko=class extends kr{constructor(e=0,t=0,n=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t){let n=t||new B,i=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);let a=this.aStartAngle+e*s,l=this.aX+this.xRadius*Math.cos(a),u=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let c=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=l-this.aX,f=u-this.aY;l=d*c-f*h+this.aX,u=d*h+f*c+this.aY}return n.set(l,u)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},hy=class extends ko{constructor(e,t,n,i,s,o){super(e,t,n,n,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function By(){let r=0,e=0,t=0,n=0;function i(s,o,a,l){r=s,e=a,t=-3*s+3*o-2*a-l,n=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,u){i(o,a,u*(a-s),u*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,u,c,h){let d=(o-s)/u-(a-s)/(u+c)+(a-o)/c,f=(a-o)/c-(l-o)/(c+h)+(l-a)/h;d*=c,f*=c,i(o,a,d,f)},calc:function(s){let o=s*s,a=o*s;return r+e*s+t*o+n*a}}}var Ud=new A,kg=new By,Vg=new By,Hg=new By,dy=class extends kr{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new A){let n=t,i=this.points,s=i.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let u,c;this.closed||a>0?u=i[(a-1)%s]:(Ud.subVectors(i[0],i[1]).add(i[0]),u=Ud);let h=i[a%s],d=i[(a+1)%s];if(this.closed||a+2<s?c=i[(a+2)%s]:(Ud.subVectors(i[s-1],i[s-2]).add(i[s-1]),c=Ud),this.curveType==="centripetal"||this.curveType==="chordal"){let f=this.curveType==="chordal"?.5:.25,m=Math.pow(u.distanceToSquared(h),f),p=Math.pow(h.distanceToSquared(d),f),g=Math.pow(d.distanceToSquared(c),f);p<1e-4&&(p=1),m<1e-4&&(m=p),g<1e-4&&(g=p),kg.initNonuniformCatmullRom(u.x,h.x,d.x,c.x,m,p,g),Vg.initNonuniformCatmullRom(u.y,h.y,d.y,c.y,m,p,g),Hg.initNonuniformCatmullRom(u.z,h.z,d.z,c.z,m,p,g)}else this.curveType==="catmullrom"&&(kg.initCatmullRom(u.x,h.x,d.x,c.x,this.tension),Vg.initCatmullRom(u.y,h.y,d.y,c.y,this.tension),Hg.initCatmullRom(u.z,h.z,d.z,c.z,this.tension));return n.set(kg.calc(l),Vg.calc(l),Hg.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new A().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function aw(r,e,t,n,i){let s=(n-e)*.5,o=(i-t)*.5,a=r*r,l=r*a;return(2*t-2*n+s+o)*l+(-3*t+3*n-2*s-o)*a+s*r+t}function wO(r,e){let t=1-r;return t*t*e}function SO(r,e){return 2*(1-r)*r*e}function AO(r,e){return r*r*e}function vu(r,e,t,n){return wO(r,e)+SO(r,t)+AO(r,n)}function _O(r,e){let t=1-r;return t*t*t*e}function TO(r,e){let t=1-r;return 3*t*t*r*e}function MO(r,e){return 3*(1-r)*r*r*e}function EO(r,e){return r*r*r*e}function xu(r,e,t,n,i){return _O(r,e)+TO(r,t)+MO(r,n)+EO(r,i)}var Wn=class extends kr{constructor(e=new B,t=new B,n=new B,i=new B){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(xu(e,i.x,s.x,o.x,a.x),xu(e,i.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},fy=class extends kr{constructor(e=new A,t=new A,n=new A,i=new A){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(xu(e,i.x,s.x,o.x,a.x),xu(e,i.y,s.y,o.y,a.y),xu(e,i.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},jn=class extends kr{constructor(e=new B,t=new B){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new B){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){let n=t||new B;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Mu=class extends kr{constructor(e=new A,t=new A){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new A){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Er=class extends kr{constructor(e=new B,t=new B,n=new B){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new B){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(vu(e,i.x,s.x,o.x),vu(e,i.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},py=class extends kr{constructor(e=new A,t=new A,n=new A){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new A){let n=t,i=this.v0,s=this.v1,o=this.v2;return n.set(vu(e,i.x,s.x,o.x),vu(e,i.y,s.y,o.y),vu(e,i.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Ja=class extends kr{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new B){let n=t,i=this.points,s=(i.length-1)*e,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],u=i[o],c=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(aw(a,l.x,u.x,c.x,h.x),aw(a,l.y,u.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let i=e.points[t];this.points.push(new B().fromArray(i))}return this}},CO=Object.freeze({__proto__:null,ArcCurve:hy,CatmullRomCurve3:dy,CubicBezierCurve:Wn,CubicBezierCurve3:fy,EllipseCurve:ko,LineCurve:jn,LineCurve3:Mu,QuadraticBezierCurve:Er,QuadraticBezierCurve3:py,SplineCurve:Ja}),my=class extends kr{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new jn(t,e))}getPoint(e,t){let n=e*this.getLength(),i=this.getCurveLengths(),s=0;for(;s<i.length;){if(i[s]>=n){let o=i[s]-n,a=this.curves[s],l=a.getLength(),u=l===0?0:1-o/l;return a.getPointAt(u,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let i=0,s=this.curves;i<s.length;i++){let o=s[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,l=o.getPoints(a);for(let u=0;u<l.length;u++){let c=l[u];n&&n.equals(c)||(t.push(c),n=c)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let i=e.curves[t];this.curves.push(new CO[i.type]().fromJSON(i))}return this}},Vo=class extends my{constructor(e){super(),this.type="Path",this.currentPoint=new B,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new jn(this.currentPoint.clone(),new B(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let s=new Er(this.currentPoint.clone(),new B(e,t),new B(n,i));return this.curves.push(s),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,s,o){let a=new Wn(this.currentPoint.clone(),new B(e,t),new B(n,i),new B(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new Ja(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,s,o){let a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(e+a,t+l,n,i,s,o),this}absarc(e,t,n,i,s,o){return this.absellipse(e,t,n,n,i,s,o),this}ellipse(e,t,n,i,s,o,a,l){let u=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+u,t+c,n,i,s,o,a,l),this}absellipse(e,t,n,i,s,o,a,l){let u=new ko(e,t,n,i,s,o,a,l);if(this.curves.length>0){let h=u.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(u);let c=u.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},$a=class extends De{constructor(e=[new B(0,.5),new B(.5,0),new B(0,-.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=pn(i,0,Math.PI*2);let s=[],o=[],a=[],l=[],u=[],c=1/t,h=new A,d=new B,f=new A,m=new A,p=new A,g=0,v=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,f.x=v*1,f.y=-g,f.z=v*0,p.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case e.length-1:l.push(p.x,p.y,p.z);break;default:g=e[y+1].x-e[y].x,v=e[y+1].y-e[y].y,f.x=v*1,f.y=-g,f.z=v*0,m.copy(f),f.x+=p.x,f.y+=p.y,f.z+=p.z,f.normalize(),l.push(f.x,f.y,f.z),p.copy(m)}for(let y=0;y<=t;y++){let b=n+y*c*i,w=Math.sin(b),S=Math.cos(b);for(let _=0;_<=e.length-1;_++){h.x=e[_].x*w,h.y=e[_].y,h.z=e[_].x*S,o.push(h.x,h.y,h.z),d.x=y/t,d.y=_/(e.length-1),a.push(d.x,d.y);let M=l[3*_+0]*w,x=l[3*_+1],T=l[3*_+0]*S;u.push(M,x,T)}}for(let y=0;y<t;y++)for(let b=0;b<e.length-1;b++){let w=b+y*e.length,S=w,_=w+e.length,M=w+e.length+1,x=w+1;s.push(S,_,x),s.push(M,x,_)}this.setIndex(s),this.setAttribute("position",new Ae(o,3)),this.setAttribute("uv",new Ae(a,2)),this.setAttribute("normal",new Ae(u,3))}static fromJSON(e){return new $a(e.points,e.segments,e.phiStart,e.phiLength)}};var Ho=class extends De{constructor(e=1,t=1,n=1,i=8,s=1,o=!1,a=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l};let u=this;i=Math.floor(i),s=Math.floor(s);let c=[],h=[],d=[],f=[],m=0,p=[],g=n/2,v=0;y(),o===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(c),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(d,3)),this.setAttribute("uv",new Ae(f,2));function y(){let w=new A,S=new A,_=0,M=(t-e)/n;for(let x=0;x<=s;x++){let T=[],E=x/s,C=E*(t-e)+e;for(let P=0;P<=i;P++){let O=P/i,D=O*l+a,N=Math.sin(D),F=Math.cos(D);S.x=C*N,S.y=-E*n+g,S.z=C*F,h.push(S.x,S.y,S.z),w.set(N,M,F).normalize(),d.push(w.x,w.y,w.z),f.push(O,1-E),T.push(m++)}p.push(T)}for(let x=0;x<i;x++)for(let T=0;T<s;T++){let E=p[T][x],C=p[T+1][x],P=p[T+1][x+1],O=p[T][x+1];c.push(E,C,O),c.push(C,P,O),_+=6}u.addGroup(v,_,0),v+=_}function b(w){let S=m,_=new B,M=new A,x=0,T=w===!0?e:t,E=w===!0?1:-1;for(let P=1;P<=i;P++)h.push(0,g*E,0),d.push(0,E,0),f.push(.5,.5),m++;let C=m;for(let P=0;P<=i;P++){let D=P/i*l+a,N=Math.cos(D),F=Math.sin(D);M.x=T*F,M.y=g*E,M.z=T*N,h.push(M.x,M.y,M.z),d.push(0,E,0),_.x=N*.5+.5,_.y=F*.5*E+.5,f.push(_.x,_.y),m++}for(let P=0;P<i;P++){let O=S+P,D=C+P;w===!0?c.push(D,D+1,O):c.push(D+1,D,O),x+=3}u.addGroup(v,x,w===!0?1:2),v+=x}}static fromJSON(e){return new Ho(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},el=class extends Ho{constructor(e=1,t=1,n=8,i=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new el(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},tl=class extends De{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let s=[],o=[];a(i),u(n),c(),this.setAttribute("position",new Ae(s,3)),this.setAttribute("normal",new Ae(s.slice(),3)),this.setAttribute("uv",new Ae(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){let b=new A,w=new A,S=new A;for(let _=0;_<t.length;_+=3)f(t[_+0],b),f(t[_+1],w),f(t[_+2],S),l(b,w,S,y)}function l(y,b,w,S){let _=S+1,M=[];for(let x=0;x<=_;x++){M[x]=[];let T=y.clone().lerp(w,x/_),E=b.clone().lerp(w,x/_),C=_-x;for(let P=0;P<=C;P++)P===0&&x===_?M[x][P]=T:M[x][P]=T.clone().lerp(E,P/C)}for(let x=0;x<_;x++)for(let T=0;T<2*(_-x)-1;T++){let E=Math.floor(T/2);T%2===0?(d(M[x][E+1]),d(M[x+1][E]),d(M[x][E])):(d(M[x][E+1]),d(M[x+1][E+1]),d(M[x+1][E]))}}function u(y){let b=new A;for(let w=0;w<s.length;w+=3)b.x=s[w+0],b.y=s[w+1],b.z=s[w+2],b.normalize().multiplyScalar(y),s[w+0]=b.x,s[w+1]=b.y,s[w+2]=b.z}function c(){let y=new A;for(let b=0;b<s.length;b+=3){y.x=s[b+0],y.y=s[b+1],y.z=s[b+2];let w=g(y)/2/Math.PI+.5,S=v(y)/Math.PI+.5;o.push(w,1-S)}m(),h()}function h(){for(let y=0;y<o.length;y+=6){let b=o[y+0],w=o[y+2],S=o[y+4],_=Math.max(b,w,S),M=Math.min(b,w,S);_>.9&&M<.1&&(b<.2&&(o[y+0]+=1),w<.2&&(o[y+2]+=1),S<.2&&(o[y+4]+=1))}}function d(y){s.push(y.x,y.y,y.z)}function f(y,b){let w=y*3;b.x=e[w+0],b.y=e[w+1],b.z=e[w+2]}function m(){let y=new A,b=new A,w=new A,S=new A,_=new B,M=new B,x=new B;for(let T=0,E=0;T<s.length;T+=9,E+=6){y.set(s[T+0],s[T+1],s[T+2]),b.set(s[T+3],s[T+4],s[T+5]),w.set(s[T+6],s[T+7],s[T+8]),_.set(o[E+0],o[E+1]),M.set(o[E+2],o[E+3]),x.set(o[E+4],o[E+5]),S.copy(y).add(b).add(w).divideScalar(3);let C=g(S);p(_,E+0,y,C),p(M,E+2,b,C),p(x,E+4,w,C)}}function p(y,b,w,S){S<0&&y.x===1&&(o[b]=y.x-1),w.x===0&&w.z===0&&(o[b]=S/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function v(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}static fromJSON(e){return new tl(e.vertices,e.indices,e.radius,e.details)}},nl=class extends tl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n,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,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[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];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nl(e.radius,e.detail)}};var ds=class extends Vo{constructor(e){super(e),this.uuid=Mi(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let i=e.holes[t];this.holes.push(new Vo().fromJSON(i))}return this}},PO={triangulate:function(r,e,t=2){let n=e&&e.length,i=n?e[0]*t:r.length,s=Bw(r,0,i,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,l,u,c,h,d,f;if(n&&(s=RO(r,e,s,t)),r.length>80*t){a=u=r[0],l=c=r[1];for(let m=t;m<i;m+=t)h=r[m],d=r[m+1],h<a&&(a=h),d<l&&(l=d),h>u&&(u=h),d>c&&(c=d);f=Math.max(u-a,c-l),f=f!==0?1/f:0}return Eu(s,o,t,a,l,f),o}};function Bw(r,e,t,n,i){let s,o;if(i===jO(r,e,t,n)>0)for(s=e;s<t;s+=n)o=lw(s,r[s],r[s+1],o);else for(s=t-n;s>=e;s-=n)o=lw(s,r[s],r[s+1],o);return o&&mf(o,o.next)&&(Pu(o),o=o.next),o}function Hs(r,e){if(!r)return r;e||(e=r);let t=r,n;do if(n=!1,!t.steiner&&(mf(t,t.next)||Wt(t.prev,t,t.next)===0)){if(Pu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Eu(r,e,t,n,i,s,o){if(!r)return;!o&&s&&GO(r,n,i,s);let a=r,l,u;for(;r.prev!==r.next;){if(l=r.prev,u=r.next,s?IO(r,n,i,s):DO(r)){e.push(l.i/t),e.push(r.i/t),e.push(u.i/t),Pu(r),r=u.next,a=u.next;continue}if(r=u,r===a){o?o===1?(r=LO(Hs(r),e,t),Eu(r,e,t,n,i,s,2)):o===2&&OO(r,e,t,n,i,s):Eu(Hs(r),e,t,n,i,s,1);break}}}function DO(r){let e=r.prev,t=r,n=r.next;if(Wt(e,t,n)>=0)return!1;let i=r.next.next;for(;i!==r.prev;){if(ja(e.x,e.y,t.x,t.y,n.x,n.y,i.x,i.y)&&Wt(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function IO(r,e,t,n){let i=r.prev,s=r,o=r.next;if(Wt(i,s,o)>=0)return!1;let a=i.x<s.x?i.x<o.x?i.x:o.x:s.x<o.x?s.x:o.x,l=i.y<s.y?i.y<o.y?i.y:o.y:s.y<o.y?s.y:o.y,u=i.x>s.x?i.x>o.x?i.x:o.x:s.x>o.x?s.x:o.x,c=i.y>s.y?i.y>o.y?i.y:o.y:s.y>o.y?s.y:o.y,h=gy(a,l,e,t,n),d=gy(u,c,e,t,n),f=r.prevZ,m=r.nextZ;for(;f&&f.z>=h&&m&&m.z<=d;){if(f!==r.prev&&f!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Wt(f.prev,f,f.next)>=0||(f=f.prevZ,m!==r.prev&&m!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Wt(m.prev,m,m.next)>=0))return!1;m=m.nextZ}for(;f&&f.z>=h;){if(f!==r.prev&&f!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,f.x,f.y)&&Wt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;m&&m.z<=d;){if(m!==r.prev&&m!==r.next&&ja(i.x,i.y,s.x,s.y,o.x,o.y,m.x,m.y)&&Wt(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function LO(r,e,t){let n=r;do{let i=n.prev,s=n.next.next;!mf(i,s)&&Fw(i,n,n.next,s)&&Cu(i,s)&&Cu(s,i)&&(e.push(i.i/t),e.push(n.i/t),e.push(s.i/t),Pu(n),Pu(n.next),n=r=s),n=n.next}while(n!==r);return Hs(n)}function OO(r,e,t,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&VO(o,a)){let l=Uw(o,a);o=Hs(o,o.next),l=Hs(l,l.next),Eu(o,e,t,n,i,s),Eu(l,e,t,n,i,s);return}a=a.next}o=o.next}while(o!==r)}function RO(r,e,t,n){let i=[],s,o,a,l,u;for(s=0,o=e.length;s<o;s++)a=e[s]*n,l=s<o-1?e[s+1]*n:r.length,u=Bw(r,a,l,n,!1),u===u.next&&(u.steiner=!0),i.push(kO(u));for(i.sort(NO),s=0;s<i.length;s++)BO(i[s],t),t=Hs(t,t.next);return t}function NO(r,e){return r.x-e.x}function BO(r,e){if(e=FO(r,e),e){let t=Uw(e,r);Hs(e,e.next),Hs(t,t.next)}}function FO(r,e){let t=e,n=r.x,i=r.y,s=-1/0,o;do{if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){let d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=n&&d>s){if(s=d,d===n){if(i===t.y)return t;if(i===t.next.y)return t.next}o=t.x<t.next.x?t:t.next}}t=t.next}while(t!==e);if(!o)return null;if(n===s)return o;let a=o,l=o.x,u=o.y,c=1/0,h;t=o;do n>=t.x&&t.x>=l&&n!==t.x&&ja(i<u?n:s,i,l,u,i<u?s:n,i,t.x,t.y)&&(h=Math.abs(i-t.y)/(n-t.x),Cu(t,r)&&(h<c||h===c&&(t.x>o.x||t.x===o.x&&UO(o,t)))&&(o=t,c=h)),t=t.next;while(t!==a);return o}function UO(r,e){return Wt(r.prev,r,e.prev)<0&&Wt(e.next,r,r.next)<0}function GO(r,e,t,n){let i=r;do i.z===null&&(i.z=gy(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,zO(i)}function zO(r){let e,t,n,i,s,o,a,l,u=1;do{for(t=r,r=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<u&&(a++,n=n.nextZ,!!n);e++);for(l=u;a>0||l>0&&n;)a!==0&&(l===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;t=n}s.nextZ=null,u*=2}while(o>1);return r}function gy(r,e,t,n,i){return r=32767*(r-t)*i,e=32767*(e-n)*i,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,r|e<<1}function kO(r){let e=r,t=r;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==r);return t}function ja(r,e,t,n,i,s,o,a){return(i-o)*(e-a)-(r-o)*(s-a)>=0&&(r-o)*(n-a)-(t-o)*(e-a)>=0&&(t-o)*(s-a)-(i-o)*(n-a)>=0}function VO(r,e){return r.next.i!==e.i&&r.prev.i!==e.i&&!HO(r,e)&&(Cu(r,e)&&Cu(e,r)&&WO(r,e)&&(Wt(r.prev,r,e.prev)||Wt(r,e.prev,e))||mf(r,e)&&Wt(r.prev,r,r.next)>0&&Wt(e.prev,e,e.next)>0)}function Wt(r,e,t){return(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y)}function mf(r,e){return r.x===e.x&&r.y===e.y}function Fw(r,e,t,n){let i=zd(Wt(r,e,t)),s=zd(Wt(r,e,n)),o=zd(Wt(t,n,r)),a=zd(Wt(t,n,e));return!!(i!==s&&o!==a||i===0&&Gd(r,t,e)||s===0&&Gd(r,n,e)||o===0&&Gd(t,r,n)||a===0&&Gd(t,e,n))}function Gd(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function zd(r){return r>0?1:r<0?-1:0}function HO(r,e){let t=r;do{if(t.i!==r.i&&t.next.i!==r.i&&t.i!==e.i&&t.next.i!==e.i&&Fw(t,t.next,r,e))return!0;t=t.next}while(t!==r);return!1}function Cu(r,e){return Wt(r.prev,r,r.next)<0?Wt(r,e,r.next)>=0&&Wt(r,r.prev,e)>=0:Wt(r,e,r.prev)<0||Wt(r,r.next,e)<0}function WO(r,e){let t=r,n=!1,i=(r.x+e.x)/2,s=(r.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==r);return n}function Uw(r,e){let t=new yy(r.i,r.x,r.y),n=new yy(e.i,e.x,e.y),i=r.next,s=e.prev;return r.next=e,e.prev=r,t.next=i,i.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function lw(r,e,t,n){let i=new yy(r,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Pu(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function yy(r,e,t){this.i=r,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function jO(r,e,t,n){let i=0;for(let s=e,o=t-n;s<t;s+=n)i+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return i}var rl=class{static area(e){let t=e.length,n=0;for(let i=t-1,s=0;s<t;i=s++)n+=e[i].x*e[s].y-e[s].x*e[i].y;return n*.5}static isClockWise(e){return rl.area(e)<0}static triangulateShape(e,t){let n=[],i=[],s=[];cw(e),uw(n,e);let o=e.length;t.forEach(cw);for(let l=0;l<t.length;l++)i.push(o),o+=t[l].length,uw(n,t[l]);let a=PO.triangulate(n,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}};function cw(r){let e=r.length;e>2&&r[e-1].equals(r[0])&&r.pop()}function uw(r,e){for(let t=0;t<e.length;t++)r.push(e[t].x),r.push(e[t].y)}var il=class extends tl{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,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];super(i,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new il(e.radius,e.detail)}};var Wo=class extends De{constructor(e=1,t=32,n=16,i=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let l=Math.min(o+a,Math.PI),u=0,c=[],h=new A,d=new A,f=[],m=[],p=[],g=[];for(let v=0;v<=n;v++){let y=[],b=v/n,w=0;v==0&&o==0?w=.5/t:v==n&&l==Math.PI&&(w=-.5/t);for(let S=0;S<=t;S++){let _=S/t;h.x=-e*Math.cos(i+_*s)*Math.sin(o+b*a),h.y=e*Math.cos(o+b*a),h.z=e*Math.sin(i+_*s)*Math.sin(o+b*a),m.push(h.x,h.y,h.z),d.copy(h).normalize(),p.push(d.x,d.y,d.z),g.push(_+w,1-b),y.push(u++)}c.push(y)}for(let v=0;v<n;v++)for(let y=0;y<t;y++){let b=c[v][y+1],w=c[v][y],S=c[v+1][y],_=c[v+1][y+1];(v!==0||o>0)&&f.push(b,w,_),(v!==n-1||l<Math.PI)&&f.push(w,S,_)}this.setIndex(f),this.setAttribute("position",new Ae(m,3)),this.setAttribute("normal",new Ae(p,3)),this.setAttribute("uv",new Ae(g,2))}static fromJSON(e){return new Wo(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}};var sl=class extends De{constructor(e=1,t=.4,n=64,i=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],l=[],u=[],c=[],h=new A,d=new A,f=new A,m=new A,p=new A,g=new A,v=new A;for(let b=0;b<=n;++b){let w=b/n*s*Math.PI*2;y(w,s,o,e,f),y(w+.01,s,o,e,m),g.subVectors(m,f),v.addVectors(m,f),p.crossVectors(g,v),v.crossVectors(p,g),p.normalize(),v.normalize();for(let S=0;S<=i;++S){let _=S/i*Math.PI*2,M=-t*Math.cos(_),x=t*Math.sin(_);h.x=f.x+(M*v.x+x*p.x),h.y=f.y+(M*v.y+x*p.y),h.z=f.z+(M*v.z+x*p.z),l.push(h.x,h.y,h.z),d.subVectors(h,f).normalize(),u.push(d.x,d.y,d.z),c.push(b/n),c.push(S/i)}}for(let b=1;b<=n;b++)for(let w=1;w<=i;w++){let S=(i+1)*(b-1)+(w-1),_=(i+1)*b+(w-1),M=(i+1)*b+w,x=(i+1)*(b-1)+w;a.push(S,_,x),a.push(_,M,x)}this.setIndex(a),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(c,2));function y(b,w,S,_,M){let x=Math.cos(b),T=Math.sin(b),E=S/w*b,C=Math.cos(E);M.x=_*(2+C)*.5*x,M.y=_*(2+C)*T*.5,M.z=_*Math.sin(E)*.5}}static fromJSON(e){return new sl(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}};var fn={arraySlice:function(r,e,t){return fn.isTypedArray(r)?new r.constructor(r.subarray(e,t!==void 0?t:r.length)):r.slice(e,t)},convertArray:function(r,e,t){return!r||!t&&r.constructor===e?r:typeof e.BYTES_PER_ELEMENT=="number"?new e(r):Array.prototype.slice.call(r)},isTypedArray:function(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)},getKeyframeOrder:function(r){function e(i,s){return r[i]-r[s]}let t=r.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n},sortedArray:function(r,e,t){let n=r.length,i=new r.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)i[o++]=r[a+l]}return i},flattenJSON:function(r,e,t,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=r[i++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=r[i++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=r[i++];while(s!==void 0)},subclip:function(r,e,t,n,i=30){let s=r.clone();s.name=e;let o=[];for(let l=0;l<s.tracks.length;++l){let u=s.tracks[l],c=u.getValueSize(),h=[],d=[];for(let f=0;f<u.times.length;++f){let m=u.times[f]*i;if(!(m<t||m>=n)){h.push(u.times[f]);for(let p=0;p<c;++p)d.push(u.values[f*c+p])}}h.length!==0&&(u.times=fn.convertArray(h,u.times.constructor),u.values=fn.convertArray(d,u.values.constructor),o.push(u))}s.tracks=o;let a=1/0;for(let l=0;l<s.tracks.length;++l)a>s.tracks[l].times[0]&&(a=s.tracks[l].times[0]);for(let l=0;l<s.tracks.length;++l)s.tracks[l].shift(-1*a);return s.resetDuration(),s},makeClipAdditive:function(r,e=0,t=r,n=30){n<=0&&(n=30);let i=t.tracks.length,s=e/n;for(let o=0;o<i;++o){let a=t.tracks[o],l=a.ValueTypeName;if(l==="bool"||l==="string")continue;let u=r.tracks.find(function(v){return v.name===a.name&&v.ValueTypeName===l});if(u===void 0)continue;let c=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=h/3);let d=0,f=u.getValueSize();u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=f/3);let m=a.times.length-1,p;if(s<=a.times[0]){let v=c,y=h-c;p=fn.arraySlice(a.values,v,y)}else if(s>=a.times[m]){let v=m*h+c,y=v+h-c;p=fn.arraySlice(a.values,v,y)}else{let v=a.createInterpolant(),y=c,b=h-c;v.evaluate(s),p=fn.arraySlice(v.resultBuffer,y,b)}l==="quaternion"&&new nt().fromArray(p).normalize().conjugate().toArray(p);let g=u.times.length;for(let v=0;v<g;++v){let y=v*f+d;if(l==="quaternion")nt.multiplyQuaternionsFlat(u.values,y,p,0,u.values,y);else{let b=f-d*2;for(let w=0;w<b;++w)u.values[y+w]-=p[w]}}}return r.blendMode=bP,r}},ol=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],s=t[n-1];n:{e:{let o;t:{r:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<s)break r;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=i,i=t[++n],e<i)break e}o=t.length;break t}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=s,s=t[--n-1],e>=s)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,i)}return this.interpolate_(n,s,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i;for(let o=0;o!==i;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},vy=class extends ol{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xb,endingEnd:xb}}intervalChanged_(e,t,n){let i=this.parameterPositions,s=e-2,o=e+1,a=i[s],l=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case bb:s=e,a=2*t-n;break;case wb:s=i.length-2,a=t+i[s]-i[s+1];break;default:s=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case bb:o=e,l=2*n-t;break;case wb:o=1,l=n+i[1]-i[0];break;default:o=e-1,l=t}let u=(n-t)*.5,c=this.valueSize;this._weightPrev=u/(t-a),this._weightNext=u/(l-n),this._offsetPrev=s*c,this._offsetNext=o*c}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,m=(n-t)/(i-t),p=m*m,g=p*m,v=-d*g+2*d*p-d*m,y=(1+d)*g+(-1.5-2*d)*p+(-.5+d)*m+1,b=(-1-f)*g+(1.5+f)*p+.5*m,w=f*g-f*p;for(let S=0;S!==a;++S)s[S]=v*o[c+S]+y*o[u+S]+b*o[l+S]+w*o[h+S];return s}},xy=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,u=l-a,c=(n-t)/(i-t),h=1-c;for(let d=0;d!==a;++d)s[d]=o[u+d]*h+o[l+d]*c;return s}},by=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},li=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fn.convertArray(t,this.TimeBufferType),this.values=fn.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:fn.convertArray(e.times,Array),values:fn.convertArray(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new by(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new xy(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new vy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case jd:t=this.InterpolantFactoryMethodDiscrete;break;case qd:t=this.InterpolantFactoryMethodLinear;break;case fg:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return jd;case this.InterpolantFactoryMethodLinear:return qd;case this.InterpolantFactoryMethodSmooth:return fg}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,s=0,o=i-1;for(;s!==i&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==i){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=fn.arraySlice(n,s,o),this.values=fn.arraySlice(this.values,s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&fn.isTypedArray(i))for(let a=0,l=i.length;a!==l;++a){let u=i[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),e=!1;break}}return e}optimize(){let e=fn.arraySlice(this.times),t=fn.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===fg,s=e.length-1,o=1;for(let a=1;a<s;++a){let l=!1,u=e[a],c=e[a+1];if(u!==c&&(a!==1||u!==e[0]))if(i)l=!0;else{let h=a*n,d=h-n,f=h+n;for(let m=0;m!==n;++m){let p=t[h+m];if(p!==t[d+m]||p!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let h=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,l=o*n,u=0;u!==n;++u)t[l+u]=t[a+u];++o}return o!==e.length?(this.times=fn.arraySlice(e,0,o),this.values=fn.arraySlice(t,0,o*n)):(this.times=e,this.values=t),this}clone(){let e=fn.arraySlice(this.times,0),t=fn.arraySlice(this.values,0),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};li.prototype.TimeBufferType=Float32Array;li.prototype.ValueBufferType=Float32Array;li.prototype.DefaultInterpolation=qd;var jo=class extends li{};jo.prototype.ValueTypeName="bool";jo.prototype.ValueBufferType=Array;jo.prototype.DefaultInterpolation=jd;jo.prototype.InterpolantFactoryMethodLinear=void 0;jo.prototype.InterpolantFactoryMethodSmooth=void 0;var wy=class extends li{};wy.prototype.ValueTypeName="color";var Sy=class extends li{};Sy.prototype.ValueTypeName="number";var Ay=class extends ol{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t),u=e*a;for(let c=u+a;u!==c;u+=4)nt.slerpFlat(s,0,o,u-a,o,u,l);return s}},Du=class extends li{InterpolantFactoryMethodLinear(e){return new Ay(this.times,this.values,this.getValueSize(),e)}};Du.prototype.ValueTypeName="quaternion";Du.prototype.DefaultInterpolation=qd;Du.prototype.InterpolantFactoryMethodSmooth=void 0;var qo=class extends li{};qo.prototype.ValueTypeName="string";qo.prototype.ValueBufferType=Array;qo.prototype.DefaultInterpolation=jd;qo.prototype.InterpolantFactoryMethodLinear=void 0;qo.prototype.InterpolantFactoryMethodSmooth=void 0;var _y=class extends li{};_y.prototype.ValueTypeName="vector";var hw={enabled:!1,files:{},add:function(r,e){this.enabled!==!1&&(this.files[r]=e)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}},Iu=class{constructor(e,t,n){let i=this,s=!1,o=0,a=0,l,u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(c){a++,s===!1&&i.onStart!==void 0&&i.onStart(c,o,a),s=!0},this.itemEnd=function(c){o++,i.onProgress!==void 0&&i.onProgress(c,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(c){i.onError!==void 0&&i.onError(c)},this.resolveURL=function(c){return l?l(c):c},this.setURLModifier=function(c){return l=c,this},this.addHandler=function(c,h){return u.push(c,h),this},this.removeHandler=function(c){let h=u.indexOf(c);return h!==-1&&u.splice(h,2),this},this.getHandler=function(c){for(let h=0,d=u.length;h<d;h+=2){let f=u[h],m=u[h+1];if(f.global&&(f.lastIndex=0),f.test(c))return m}return null}}},qO=new Iu,al=class{constructor(e){this.manager=e!==void 0?e:qO,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,s){n.load(e,i,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}},as={},ll=class extends al{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=hw.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(as[e]!==void 0){as[e].push({onLoad:t,onProgress:n,onError:i});return}as[e]=[],as[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;let c=as[e],h=u.body.getReader(),d=u.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0,p=0,g=new ReadableStream({start(v){y();function y(){h.read().then(({done:b,value:w})=>{if(b)v.close();else{p+=w.byteLength;let S=new ProgressEvent("progress",{lengthComputable:m,loaded:p,total:f});for(let _=0,M=c.length;_<M;_++){let x=c[_];x.onProgress&&x.onProgress(S)}v.enqueue(w),y()}})}}});return new Response(g)}else throw Error(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`)}).then(u=>{switch(l){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(c=>new DOMParser().parseFromString(c,a));case"json":return u.json();default:if(a===void 0)return u.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return u.arrayBuffer().then(m=>f.decode(m))}}}).then(u=>{hw.add(e,u);let c=as[e];delete as[e];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onLoad&&f.onLoad(u)}}).catch(u=>{let c=as[e];if(c===void 0)throw this.manager.itemError(e),u;delete as[e];for(let h=0,d=c.length;h<d;h++){let f=c[h];f.onError&&f.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var cl=class extends ht{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Le(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}},Xo=class extends cl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.groundColor=new Le(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},dw=new be,fw=new A,pw=new A,Lu=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new B(512,512),this.map=null,this.mapPass=null,this.matrix=new be,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _u,this._frameExtents=new B(1,1),this._viewportCount=1,this._viewports=[new He(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;fw.setFromMatrixPosition(e.matrixWorld),t.position.copy(fw),pw.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(pw),t.updateMatrixWorld(),dw.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dw),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Ty=class extends Lu{constructor(){super(new nn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=wu*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},nf=class extends cl{constructor(e,t,n=0,i=Math.PI/3,s=0,o=1){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.target=new ht,this.distance=n,this.angle=i,this.penumbra=s,this.decay=o,this.shadow=new Ty}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},mw=new be,du=new A,Wg=new A,My=class extends Lu{constructor(){super(new nn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new B(4,2),this._viewportCount=6,this._viewports=[new He(2,1,1,1),new He(0,1,1,1),new He(3,1,1,1),new He(1,1,1,1),new He(3,0,1,1),new He(1,0,1,1)],this._cubeDirections=[new A(1,0,0),new A(-1,0,0),new A(0,0,1),new A(0,0,-1),new A(0,1,0),new A(0,-1,0)],this._cubeUps=[new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,1,0),new A(0,0,1),new A(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),du.setFromMatrixPosition(e.matrixWorld),n.position.copy(du),Wg.copy(n.position),Wg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Wg),n.updateMatrixWorld(),i.makeTranslation(-du.x,-du.y,-du.z),mw.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mw)}},rf=class extends cl{constructor(e,t,n=0,i=1){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new My}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Ey=class extends Lu{constructor(){super(new Za(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},sf=class extends cl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ht.DefaultUp),this.updateMatrix(),this.target=new ht,this.shadow=new Ey}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}};var Cy=class extends De{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){let e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},ul=class extends al{constructor(e){super(e)}load(e,t,n,i){let s=this,o=new ll(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),s.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(f,m){if(t[m]!==void 0)return t[m];let g=f.interleavedBuffers[m],v=s(f,g.buffer),y=gd(g.type,v),b=new ef(y,g.stride);return b.uuid=g.uuid,t[m]=b,b}function s(f,m){if(n[m]!==void 0)return n[m];let g=f.arrayBuffers[m],v=new Uint32Array(g).buffer;return n[m]=v,v}let o=e.isInstancedBufferGeometry?new Cy:new De,a=e.data.index;if(a!==void 0){let f=gd(a.type,a.array);o.setIndex(new Ge(f,1))}let l=e.data.attributes;for(let f in l){let m=l[f],p;if(m.isInterleavedBufferAttribute){let g=i(e.data,m.data);p=new Go(g,m.itemSize,m.offset,m.normalized)}else{let g=gd(m.type,m.array),v=m.isInstancedBufferAttribute?tf:Ge;p=new v(g,m.itemSize,m.normalized)}m.name!==void 0&&(p.name=m.name),m.usage!==void 0&&p.setUsage(m.usage),m.updateRange!==void 0&&(p.updateRange.offset=m.updateRange.offset,p.updateRange.count=m.updateRange.count),o.setAttribute(f,p)}let u=e.data.morphAttributes;if(u)for(let f in u){let m=u[f],p=[];for(let g=0,v=m.length;g<v;g++){let y=m[g],b;if(y.isInterleavedBufferAttribute){let w=i(e.data,y.data);b=new Go(w,y.itemSize,y.offset,y.normalized)}else{let w=gd(y.type,y.array);b=new Ge(w,y.itemSize,y.normalized)}y.name!==void 0&&(b.name=y.name),p.push(b)}o.morphAttributes[f]=p}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let f=0,m=h.length;f!==m;++f){let p=h[f];o.addGroup(p.start,p.count,p.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let f=new A;d.center!==void 0&&f.fromArray(d.center),o.boundingSphere=new En(f,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}};var of=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=gw(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=gw();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function gw(){return(typeof performance>"u"?Date:performance).now()}var Fy="\\[\\]\\.:\\/",XO=new RegExp("["+Fy+"]","g"),Uy="[^"+Fy+"]",YO="[^"+Fy.replace("\\.","")+"]",QO=/((?:WC+[\/:])*)/.source.replace("WC",Uy),ZO=/(WCOD+)?/.source.replace("WCOD",YO),KO=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Uy),JO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Uy),$O=new RegExp("^"+QO+ZO+KO+JO+"$"),eR=["material","materials","bones"],Py=class{constructor(e,t,n){let i=n||Tt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Tt=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Tt.parseTrackName(t),this.node=Tt.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Tt.Composite(e,t,n):new Tt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(XO,"")}static parseTrackName(e){let t=$O.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let s=n.nodeName.substring(i+1);eR.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,s=n.length;i!==s;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,s=t.propertyIndex;if(e||(e=Tt.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(n){let u=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let c=0;c<e.length;c++)if(e[c].name===u){u=c;break}break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(u!==void 0){if(e[u]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[u]}}let o=e[i];if(o===void 0){let u=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+u+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Tt.Composite=Py;Tt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Tt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Tt.prototype.GetterByBindingType=[Tt.prototype._getValue_direct,Tt.prototype._getValue_array,Tt.prototype._getValue_arrayElement,Tt.prototype._getValue_toArray];Tt.prototype.SetterByBindingTypeAndVersioning=[[Tt.prototype._setValue_direct,Tt.prototype._setValue_direct_setNeedsUpdate,Tt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_array,Tt.prototype._setValue_array_setNeedsUpdate,Tt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_arrayElement,Tt.prototype._setValue_arrayElement_setNeedsUpdate,Tt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Tt.prototype._setValue_fromArray,Tt.prototype._setValue_fromArray_setNeedsUpdate,Tt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Se=class{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Se(this.value.clone===void 0?this.value:this.value.clone())}};var hl=class{constructor(e,t,n=0,i=1/0){this.ray=new oi(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Su,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return Dy(e,this,n,t),n.sort(yw),n}intersectObjects(e,t=!0,n=[]){for(let i=0,s=e.length;i<s;i++)Dy(e[i],this,n,t);return n.sort(yw),n}};function yw(r,e){return r.distance-e.distance}function Dy(r,e,t,n){if(r.layers.test(e.layers)&&r.raycast(e,t),n===!0){let i=r.children;for(let s=0,o=i.length;s<o;s++)Dy(i[s],e,t,!0)}}var Ou=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(pn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var vw=new B,af=class{constructor(e=new B(1/0,1/0),t=new B(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=vw.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return vw.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},xw=new A,kd=new A,gn=class{constructor(e=new A,t=new A){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){xw.subVectors(e,this.start),kd.subVectors(this.end,this.start);let n=kd.dot(kd),s=kd.dot(xw)/n;return t&&(s=pn(s,0,1)),s}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},bw=new A,lf=class extends ht{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;let n=new De,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o<l;o++,a++){let u=o/l*Math.PI*2,c=a/l*Math.PI*2;i.push(Math.cos(u),Math.sin(u),1,Math.cos(c),Math.sin(c),1)}n.setAttribute("position",new Ae(i,3));let s=new zr({fog:!1,toneMapped:!1});this.cone=new Vs(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),bw.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(bw),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}};var cf=class extends rn{constructor(e,t,n){let i=new Wo(t,4,2),s=new Au({wireframe:!0,fog:!1,toneMapped:!1});super(i,s),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}};var ww=new A,Vd=new A,Sw=new A,uf=class extends ht{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,t===void 0&&(t=1);let i=new De;i.setAttribute("position",new Ae([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new zr({fog:!1,toneMapped:!1});this.lightPlane=new zo(i,s),this.add(this.lightPlane),i=new De,i.setAttribute("position",new Ae([0,0,0,0,0,1],3)),this.targetLine=new zo(i,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ww.setFromMatrixPosition(this.light.matrixWorld),Vd.setFromMatrixPosition(this.light.target.matrixWorld),Sw.subVectors(Vd,ww),this.lightPlane.lookAt(Vd),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Vd),this.targetLine.scale.z=Sw.length()}},Hd=new A,Xt=new ai,Vr=class extends Vs{constructor(e){let t=new De,n=new zr({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(m,p){l(m),l(p)}function l(m){i.push(0,0,0),s.push(0,0,0),o[m]===void 0&&(o[m]=[]),o[m].push(i.length/3-1)}t.setAttribute("position",new Ae(i,3)),t.setAttribute("color",new Ae(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let u=new Le(16755200),c=new Le(16711680),h=new Le(43775),d=new Le(16777215),f=new Le(3355443);this.setColors(u,c,h,d,f)}setColors(e,t,n,i,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,n=1,i=1;Xt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),tn("c",t,e,Xt,0,0,-1),tn("t",t,e,Xt,0,0,1),tn("n1",t,e,Xt,-n,-i,-1),tn("n2",t,e,Xt,n,-i,-1),tn("n3",t,e,Xt,-n,i,-1),tn("n4",t,e,Xt,n,i,-1),tn("f1",t,e,Xt,-n,-i,1),tn("f2",t,e,Xt,n,-i,1),tn("f3",t,e,Xt,-n,i,1),tn("f4",t,e,Xt,n,i,1),tn("u1",t,e,Xt,n*.7,i*1.1,-1),tn("u2",t,e,Xt,-n*.7,i*1.1,-1),tn("u3",t,e,Xt,0,i*2,-1),tn("cf1",t,e,Xt,-n,0,1),tn("cf2",t,e,Xt,n,0,1),tn("cf3",t,e,Xt,0,-i,1),tn("cf4",t,e,Xt,0,i,1),tn("cn1",t,e,Xt,-n,0,-1),tn("cn2",t,e,Xt,n,0,-1),tn("cn3",t,e,Xt,0,-i,-1),tn("cn4",t,e,Xt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function tn(r,e,t,n,i,s,o){Hd.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],Hd.x,Hd.y,Hd.z)}}var Yo=class extends Vs{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new De;s.setIndex(new Ge(n,1)),s.setAttribute("position",new Ae(i,3)),super(s,new zr({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}};var hf=class extends Vs{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new De;i.setAttribute("position",new Ae(t,3)),i.setAttribute("color",new Ae(n,3));let s=new zr({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,n){let i=new Le,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};var{floatView:TH,uint32View:MH,baseTable:EH,shiftTable:CH,mantissaTable:PH,exponentTable:DH,offsetTable:IH}=tR();function tR(){let r=new ArrayBuffer(4),e=new Float32Array(r),t=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){let u=l-127;u<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):u<-14?(n[l]=1024>>-u-14,n[l|256]=1024>>-u-14|32768,i[l]=-u-1,i[l|256]=-u-1):u<=15?(n[l]=u+15<<10,n[l|256]=u+15<<10|32768,i[l]=13,i[l|256]=13):u<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let u=l<<13,c=0;for(;(u&8388608)===0;)u<<=1,c-=8388608;u&=-8388609,c+=947912704,s[l]=u|c}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:o,offsetTable:a}}var df=class extends dt{constructor(e,t,n){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Qo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Qo);var ml=".",Ru=Symbol("target"),Gy=Symbol("unsubscribe");function Nu(r){return r instanceof Date||r instanceof Set||r instanceof Map||r instanceof WeakSet||r instanceof WeakMap||ArrayBuffer.isView(r)}function Gw(r){return(typeof r=="object"?r===null:typeof r!="function")||r instanceof RegExp}var Pr=Array.isArray;function Zo(r){return typeof r=="symbol"}var nR={after:(r,e)=>Pr(r)?r.slice(e.length):e===""?r:r.slice(e.length+1),concat:(r,e)=>Pr(r)?(r=[...r],e&&r.push(e),r):e&&e.toString!==void 0?(r!==""&&(r+=ml),Zo(e)?r+e.toString():r+e):r,initial:r=>{if(Pr(r))return r.slice(0,-1);if(r==="")return r;let e=r.lastIndexOf(ml);return e===-1?"":r.slice(0,e)},last:r=>{if(Pr(r))return r[r.length-1]||"";if(r==="")return r;let e=r.lastIndexOf(ml);return e===-1?r:r.slice(e+1)},walk:(r,e)=>{if(Pr(r))for(let t of r)e(t);else if(r!==""){let t=0,n=r.indexOf(ml);if(n===-1)e(r);else for(;t<r.length;)n===-1&&(n=r.length),e(r.slice(t,n)),t=n+1,n=r.indexOf(ml,t)}},get(r,e){return this.walk(e,t=>{r&&(r=r[t])}),r}},sr=nR;function zy(r){return typeof r=="object"&&typeof r.next=="function"}function ky(r,e,t,n,i){let s=r.next;if(e.name==="entries")r.next=function(){let o=s.call(this);return o.done===!1&&(o.value[0]=i(o.value[0],e,o.value[0],n),o.value[1]=i(o.value[1],e,o.value[0],n)),o};else if(e.name==="values"){let o=t[Ru].keys();r.next=function(){let a=s.call(this);return a.done===!1&&(a.value=i(a.value,e,o.next().value,n)),a}}else r.next=function(){let o=s.call(this);return o.done===!1&&(o.value=i(o.value,e,o.value,n)),o};return r}function gf(r,e,t){return r.isUnsubscribed||e.ignoreSymbols&&Zo(t)||e.ignoreUnderscores&&t.charAt(0)==="_"||"ignoreKeys"in e&&e.ignoreKeys.includes(t)}var Bu=class{constructor(e){this._equals=e,this._proxyCache=new WeakMap,this._pathCache=new WeakMap,this.isUnsubscribed=!1}_getDescriptorCache(){return this._descriptorCache===void 0&&(this._descriptorCache=new WeakMap),this._descriptorCache}_getProperties(e){let t=this._getDescriptorCache(),n=t.get(e);return n===void 0&&(n={},t.set(e,n)),n}_getOwnPropertyDescriptor(e,t){if(this.isUnsubscribed)return Reflect.getOwnPropertyDescriptor(e,t);let n=this._getProperties(e),i=n[t];return i===void 0&&(i=Reflect.getOwnPropertyDescriptor(e,t),n[t]=i),i}getProxy(e,t,n,i){if(this.isUnsubscribed)return e;let s=e[i],o=s||e;this._pathCache.set(o,t);let a=this._proxyCache.get(o);return a===void 0&&(a=s===void 0?new Proxy(e,n):e,this._proxyCache.set(o,a)),a}getPath(e){return this.isUnsubscribed?void 0:this._pathCache.get(e)}isDetached(e,t){return!Object.is(e,sr.get(t,this.getPath(e)))}defineProperty(e,t,n){return Reflect.defineProperty(e,t,n)?(this.isUnsubscribed||(this._getProperties(e)[t]=n),!0):!1}setProperty(e,t,n,i,s){if(!this._equals(s,n)||!(t in e)){let o=this._getOwnPropertyDescriptor(e,t);return o!==void 0&&"set"in o?Reflect.set(e,t,n,i):Reflect.set(e,t,n)}return!0}deleteProperty(e,t,n){if(Reflect.deleteProperty(e,t)){if(!this.isUnsubscribed){let i=this._getDescriptorCache().get(e);i&&(delete i[t],this._pathCache.delete(n))}return!0}return!1}isSameDescriptor(e,t,n){let i=this._getOwnPropertyDescriptor(t,n);return e!==void 0&&i!==void 0&&Object.is(e.value,i.value)&&(e.writable||!1)===(i.writable||!1)&&(e.enumerable||!1)===(i.enumerable||!1)&&(e.configurable||!1)===(i.configurable||!1)&&e.get===i.get&&e.set===i.set}isGetInvariant(e,t){let n=this._getOwnPropertyDescriptor(e,t);return n!==void 0&&n.configurable!==!0&&n.writable!==!0}unsubscribe(){this._descriptorCache=null,this._pathCache=null,this._proxyCache=null,this.isUnsubscribed=!0}};function gl(r){return toString.call(r)==="[object Object]"}function yl(){return!0}function Ws(r,e){return r.length!==e.length||r.some((t,n)=>e[n]!==t)}var yf=new Set(["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);var rR=new Set(["concat","includes","indexOf","join","keys","lastIndexOf"]),Vy={push:yl,pop:yl,shift:yl,unshift:yl,copyWithin:Ws,reverse:Ws,sort:Ws,splice:Ws,flat:Ws,fill:Ws},zw=new Set([...yf,...rR,...Object.keys(Vy)]);function vl(r,e){if(r.size!==e.size)return!0;for(let t of r)if(!e.has(t))return!0;return!1}var Hy=["keys","values","entries"],Wy=new Set(["has","toString"]),jy={add:vl,clear:vl,delete:vl,forEach:vl},kw=new Set([...Wy,...Object.keys(jy),...Hy]);function xl(r,e){if(r.size!==e.size)return!0;let t;for(let[n,i]of r)if(t=e.get(n),t!==i||t===void 0&&!e.has(n))return!0;return!1}var iR=new Set([...Wy,"get"]),qy={set:xl,clear:xl,delete:xl,forEach:xl},Vw=new Set([...iR,...Object.keys(qy),...Hy]);var Pn=class{constructor(e,t,n,i){this._path=t,this._isChanged=!1,this._clonedCache=new Set,this._hasOnValidate=i,this._changes=i?[]:null,this.clone=t===void 0?e:this._shallowClone(e)}static isHandledMethod(e){return yf.has(e)}_shallowClone(e){let t=e;if(gl(e))t={...e};else if(Pr(e))t=[...e];else if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set([...e].map(n=>this._shallowClone(n)));else if(e instanceof Map){t=new Map;for(let[n,i]of e.entries())t.set(n,this._shallowClone(i))}return this._clonedCache.add(t),t}preferredThisArg(e,t,n,i){return e?(Pr(i)?this._onIsChanged=Vy[t]:i instanceof Set?this._onIsChanged=jy[t]:i instanceof Map&&(this._onIsChanged=qy[t]),i):n}update(e,t,n){let i=sr.after(e,this._path);if(t!=="length"){let s=this.clone;sr.walk(i,o=>{s&&s[o]&&(this._clonedCache.has(s[o])||(s[o]=this._shallowClone(s[o])),s=s[o])}),this._hasOnValidate&&this._changes.push({path:i,property:t,previous:n}),s&&s[t]&&(s[t]=n)}this._isChanged=!0}undo(e){let t;for(let n=this._changes.length-1;n!==-1;n--)t=this._changes[n],sr.get(e,t.path)[t.property]=t.previous}isChanged(e){return this._onIsChanged===void 0?this._isChanged:this._onIsChanged(this.clone,e)}};var bl=class extends Pn{static isHandledMethod(e){return zw.has(e)}};var Fu=class extends Pn{undo(e){e.setTime(this.clone.getTime())}isChanged(e,t){return!t(this.clone.valueOf(),e.valueOf())}};var wl=class extends Pn{static isHandledMethod(e){return kw.has(e)}undo(e){for(let t of this.clone)e.add(t);for(let t of e)this.clone.has(t)||e.delete(t)}};var Sl=class extends Pn{static isHandledMethod(e){return Vw.has(e)}undo(e){for(let[t,n]of this.clone.entries())e.set(t,n);for(let t of e.keys())this.clone.has(t)||e.delete(t)}};var Uu=class extends Pn{constructor(e,t,n,i){super(void 0,t,n,i),this._arg1=n[0],this._weakValue=e.has(this._arg1)}isChanged(e){return this._weakValue!==e.has(this._arg1)}undo(e){this._weakValue&&!e.has(this._arg1)?e.add(this._arg1):e.delete(this._arg1)}};var Gu=class extends Pn{constructor(e,t,n,i){super(void 0,t,n,i),this._weakKey=n[0],this._weakHas=e.has(this._weakKey),this._weakValue=e.get(this._weakKey)}isChanged(e){return this._weakValue!==e.get(this._weakKey)}undo(e){let t=e.has(this._weakKey);this._weakHas&&!t?e.set(this._weakKey,this._weakValue):!this._weakHas&&t?e.delete(this._weakKey):this._weakValue!==e.get(this._weakKey)&&e.set(this._weakKey,this._weakValue)}};var ui=class{constructor(e){this._stack=[],this._hasOnValidate=e}static isHandledType(e){return gl(e)||Pr(e)||Nu(e)}static isHandledMethod(e,t){return gl(e)?Pn.isHandledMethod(t):Pr(e)?bl.isHandledMethod(t):e instanceof Set?wl.isHandledMethod(t):e instanceof Map?Sl.isHandledMethod(t):Nu(e)}get isCloning(){return this._stack.length>0}start(e,t,n){let i=Pn;Pr(e)?i=bl:e instanceof Date?i=Fu:e instanceof Set?i=wl:e instanceof Map?i=Sl:e instanceof WeakSet?i=Uu:e instanceof WeakMap&&(i=Gu),this._stack.push(new i(e,t,n,this._hasOnValidate))}update(e,t,n){this._stack[this._stack.length-1].update(e,t,n)}preferredThisArg(e,t,n){let{name:i}=e,s=ui.isHandledMethod(n,i);return this._stack[this._stack.length-1].preferredThisArg(s,i,t,n)}isChanged(e,t,n){return this._stack[this._stack.length-1].isChanged(e,t,n)}undo(e){this._previousClone!==void 0&&this._previousClone.undo(e)}stop(){return this._previousClone=this._stack.pop(),this._previousClone.clone}};var sR={equals:Object.is,isShallow:!1,pathAsArray:!1,ignoreSymbols:!1,ignoreUnderscores:!1,ignoreDetached:!1,details:!1},Xy=(r,e,t={})=>{t={...sR,...t};let n=Symbol("ProxyTarget"),{equals:i,isShallow:s,ignoreDetached:o,details:a}=t,l=new Bu(i),u=typeof t.onValidate=="function",c=new ui(u),h=(y,b,w,S,_)=>!u||c.isCloning||t.onValidate(sr.concat(l.getPath(y),b),w,S,_)===!0,d=(y,b,w,S)=>{!gf(l,t,b)&&!(o&&l.isDetached(y,r))&&f(l.getPath(y),b,w,S)},f=(y,b,w,S,_)=>{c.isCloning?c.update(y,b,S):e(sr.concat(y,b),w,S,_)},m=y=>y&&(y[n]||y),p=(y,b,w,S)=>Gw(y)||w==="constructor"||s&&!ui.isHandledMethod(b,w)||gf(l,t,w)||l.isGetInvariant(b,w)||o&&l.isDetached(b,r)?y:(S===void 0&&(S=l.getPath(b)),l.getProxy(y,sr.concat(S,w),g,n)),g={get(y,b,w){if(Zo(b)){if(b===n||b===Ru)return y;if(b===Gy&&!l.isUnsubscribed&&l.getPath(y).length===0)return l.unsubscribe(),y}let S=Nu(y)?Reflect.get(y,b):Reflect.get(y,b,w);return p(S,y,b)},set(y,b,w,S){w=m(w);let _=y[n]||y,M=_[b];if(i(M,w)&&b in y)return!0;let x=h(y,b,w,M);return x&&l.setProperty(_,b,w,S,M)?(d(y,b,y[b],M),!0):!x},defineProperty(y,b,w){if(!l.isSameDescriptor(w,y,b)){let S=y[b];h(y,b,w.value,S)&&l.defineProperty(y,b,w,S)&&d(y,b,w.value,S)}return!0},deleteProperty(y,b){if(!Reflect.has(y,b))return!0;let w=Reflect.get(y,b),S=h(y,b,void 0,w);return S&&l.deleteProperty(y,b,w)?(d(y,b,void 0,w),!0):!S},apply(y,b,w){let S=b[n]||b;if(l.isUnsubscribed)return Reflect.apply(y,S,w);if((a===!1||a!==!0&&!a.includes(y.name))&&ui.isHandledType(S)){let _=sr.initial(l.getPath(y)),M=ui.isHandledMethod(S,y.name);c.start(S,_,w);let x=Reflect.apply(y,c.preferredThisArg(y,b,S),M?w.map(C=>m(C)):w),T=c.isChanged(S,i),E=c.stop();if(ui.isHandledType(x)&&M&&(b instanceof Map&&y.name==="get"&&(_=sr.concat(_,w[0])),x=l.getProxy(x,_,g)),T){let C={name:y.name,args:w,result:x},P=c.isCloning?sr.initial(_):_,O=c.isCloning?sr.last(_):"";h(sr.get(r,P),O,S,E,C)?f(P,O,S,E,C):c.undo(S)}return(b instanceof Map||b instanceof Set)&&zy(x)?ky(x,y,b,_,p):x}return Reflect.apply(y,b,w)}},v=l.getProxy(r,t.pathAsArray?[]:"",g);return e=e.bind(v),u&&(t.onValidate=t.onValidate.bind(v)),v};Xy.target=r=>r&&r[Ru]||r;Xy.unsubscribe=r=>r[Gy]||r;var Yy=Xy;var oR=typeof global=="object"&&global&&global.Object===Object&&global,vf=oR;var aR=typeof self=="object"&&self&&self.Object===Object&&self,lR=vf||aR||Function("return this")(),Zt=lR;var cR=Zt.Symbol,or=cR;var Hw=Object.prototype,uR=Hw.hasOwnProperty,hR=Hw.toString,zu=or?or.toStringTag:void 0;function dR(r){var e=uR.call(r,zu),t=r[zu];try{r[zu]=void 0;var n=!0}catch{}var i=hR.call(r);return n&&(e?r[zu]=t:delete r[zu]),i}var Ww=dR;var fR=Object.prototype,pR=fR.toString;function mR(r){return pR.call(r)}var jw=mR;var gR="[object Null]",yR="[object Undefined]",qw=or?or.toStringTag:void 0;function vR(r){return r==null?r===void 0?yR:gR:qw&&qw in Object(r)?Ww(r):jw(r)}var Dr=vR;function xR(r){return r!=null&&typeof r=="object"}var qn=xR;var bR="[object Symbol]";function wR(r){return typeof r=="symbol"||qn(r)&&Dr(r)==bR}var js=wR;function SR(r,e){for(var t=-1,n=r==null?0:r.length,i=Array(n);++t<n;)i[t]=e(r[t],t,r);return i}var xf=SR;var AR=Array.isArray,yn=AR;var _R=1/0,Xw=or?or.prototype:void 0,Yw=Xw?Xw.toString:void 0;function Qw(r){if(typeof r=="string")return r;if(yn(r))return xf(r,Qw)+"";if(js(r))return Yw?Yw.call(r):"";var e=r+"";return e=="0"&&1/r==-_R?"-0":e}var Zw=Qw;var TR=/\s/;function MR(r){for(var e=r.length;e--&&TR.test(r.charAt(e)););return e}var Kw=MR;var ER=/^\s+/;function CR(r){return r&&r.slice(0,Kw(r)+1).replace(ER,"")}var Jw=CR;function PR(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}var Ht=PR;var $w=0/0,DR=/^[-+]0x[0-9a-f]+$/i,IR=/^0b[01]+$/i,LR=/^0o[0-7]+$/i,OR=parseInt;function RR(r){if(typeof r=="number")return r;if(js(r))return $w;if(Ht(r)){var e=typeof r.valueOf=="function"?r.valueOf():r;r=Ht(e)?e+"":e}if(typeof r!="string")return r===0?r:+r;r=Jw(r);var t=IR.test(r);return t||LR.test(r)?OR(r.slice(2),t?2:8):DR.test(r)?$w:+r}var Qy=RR;function NR(r){return r}var bf=NR;var BR="[object AsyncFunction]",FR="[object Function]",UR="[object GeneratorFunction]",GR="[object Proxy]";function zR(r){if(!Ht(r))return!1;var e=Dr(r);return e==FR||e==UR||e==BR||e==GR}var Al=zR;var kR=Zt["__core-js_shared__"],wf=kR;var eS=function(){var r=/[^.]+$/.exec(wf&&wf.keys&&wf.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function VR(r){return!!eS&&eS in r}var tS=VR;var HR=Function.prototype,WR=HR.toString;function jR(r){if(r!=null){try{return WR.call(r)}catch{}try{return r+""}catch{}}return""}var fs=jR;var qR=/[\\^$.*+?()[\]{}|]/g,XR=/^\[object .+?Constructor\]$/,YR=Function.prototype,QR=Object.prototype,ZR=YR.toString,KR=QR.hasOwnProperty,JR=RegExp("^"+ZR.call(KR).replace(qR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $R(r){if(!Ht(r)||tS(r))return!1;var e=Al(r)?JR:XR;return e.test(fs(r))}var nS=$R;function e3(r,e){return r?.[e]}var rS=e3;function t3(r,e){var t=rS(r,e);return nS(t)?t:void 0}var hr=t3;var n3=hr(Zt,"WeakMap"),Sf=n3;var iS=Object.create,r3=function(){function r(){}return function(e){if(!Ht(e))return{};if(iS)return iS(e);r.prototype=e;var t=new r;return r.prototype=void 0,t}}(),sS=r3;function i3(r,e,t){switch(t.length){case 0:return r.call(e);case 1:return r.call(e,t[0]);case 2:return r.call(e,t[0],t[1]);case 3:return r.call(e,t[0],t[1],t[2])}return r.apply(e,t)}var oS=i3;function s3(r,e){var t=-1,n=r.length;for(e||(e=Array(n));++t<n;)e[t]=r[t];return e}var Af=s3;var o3=800,a3=16,l3=Date.now;function c3(r){var e=0,t=0;return function(){var n=l3(),i=a3-(n-t);if(t=n,i>0){if(++e>=o3)return arguments[0]}else e=0;return r.apply(void 0,arguments)}}var aS=c3;function u3(r){return function(){return r}}var lS=u3;var h3=function(){try{var r=hr(Object,"defineProperty");return r({},"",{}),r}catch{}}(),_l=h3;var d3=_l?function(r,e){return _l(r,"toString",{configurable:!0,enumerable:!1,value:lS(e),writable:!0})}:bf,cS=d3;var f3=aS(cS),_f=f3;function p3(r,e){for(var t=-1,n=r==null?0:r.length;++t<n&&e(r[t],t,r)!==!1;);return r}var uS=p3;var m3=9007199254740991,g3=/^(?:0|[1-9]\d*)$/;function y3(r,e){var t=typeof r;return e=e??m3,!!e&&(t=="number"||t!="symbol"&&g3.test(r))&&r>-1&&r%1==0&&r<e}var qs=y3;function v3(r,e,t){e=="__proto__"&&_l?_l(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t}var Tl=v3;function x3(r,e){return r===e||r!==r&&e!==e}var Xs=x3;var b3=Object.prototype,w3=b3.hasOwnProperty;function S3(r,e,t){var n=r[e];(!(w3.call(r,e)&&Xs(n,t))||t===void 0&&!(e in r))&&Tl(r,e,t)}var Ml=S3;function A3(r,e,t,n){var i=!t;t||(t={});for(var s=-1,o=e.length;++s<o;){var a=e[s],l=n?n(t[a],r[a],a,t,r):void 0;l===void 0&&(l=r[a]),i?Tl(t,a,l):Ml(t,a,l)}return t}var Hr=A3;var hS=Math.max;function _3(r,e,t){return e=hS(e===void 0?r.length-1:e,0),function(){for(var n=arguments,i=-1,s=hS(n.length-e,0),o=Array(s);++i<s;)o[i]=n[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=n[i];return a[e]=t(o),oS(r,this,a)}}var Tf=_3;function T3(r,e){return _f(Tf(r,e,bf),r+"")}var dS=T3;var M3=9007199254740991;function E3(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=M3}var El=E3;function C3(r){return r!=null&&El(r.length)&&!Al(r)}var Ys=C3;function P3(r,e,t){if(!Ht(t))return!1;var n=typeof e;return(n=="number"?Ys(t)&&qs(e,t.length):n=="string"&&e in t)?Xs(t[e],r):!1}var fS=P3;function D3(r){return dS(function(e,t){var n=-1,i=t.length,s=i>1?t[i-1]:void 0,o=i>2?t[2]:void 0;for(s=r.length>3&&typeof s=="function"?(i--,s):void 0,o&&fS(t[0],t[1],o)&&(s=i<3?void 0:s,i=1),e=Object(e);++n<i;){var a=t[n];a&&r(e,a,n,s)}return e})}var pS=D3;var I3=Object.prototype;function L3(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||I3;return r===t}var Cl=L3;function O3(r,e){for(var t=-1,n=Array(r);++t<r;)n[t]=e(t);return n}var mS=O3;var R3="[object Arguments]";function N3(r){return qn(r)&&Dr(r)==R3}var Zy=N3;var gS=Object.prototype,B3=gS.hasOwnProperty,F3=gS.propertyIsEnumerable,U3=Zy(function(){return arguments}())?Zy:function(r){return qn(r)&&B3.call(r,"callee")&&!F3.call(r,"callee")},ps=U3;function G3(){return!1}var yS=G3;var bS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vS=bS&&typeof module=="object"&&module&&!module.nodeType&&module,z3=vS&&vS.exports===bS,xS=z3?Zt.Buffer:void 0,k3=xS?xS.isBuffer:void 0,V3=k3||yS,Pl=V3;var H3="[object Arguments]",W3="[object Array]",j3="[object Boolean]",q3="[object Date]",X3="[object Error]",Y3="[object Function]",Q3="[object Map]",Z3="[object Number]",K3="[object Object]",J3="[object RegExp]",$3="[object Set]",eN="[object String]",tN="[object WeakMap]",nN="[object ArrayBuffer]",rN="[object DataView]",iN="[object Float32Array]",sN="[object Float64Array]",oN="[object Int8Array]",aN="[object Int16Array]",lN="[object Int32Array]",cN="[object Uint8Array]",uN="[object Uint8ClampedArray]",hN="[object Uint16Array]",dN="[object Uint32Array]",Gt={};Gt[iN]=Gt[sN]=Gt[oN]=Gt[aN]=Gt[lN]=Gt[cN]=Gt[uN]=Gt[hN]=Gt[dN]=!0;Gt[H3]=Gt[W3]=Gt[nN]=Gt[j3]=Gt[rN]=Gt[q3]=Gt[X3]=Gt[Y3]=Gt[Q3]=Gt[Z3]=Gt[K3]=Gt[J3]=Gt[$3]=Gt[eN]=Gt[tN]=!1;function fN(r){return qn(r)&&El(r.length)&&!!Gt[Dr(r)]}var wS=fN;function pN(r){return function(e){return r(e)}}var Dl=pN;var SS=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ku=SS&&typeof module=="object"&&module&&!module.nodeType&&module,mN=ku&&ku.exports===SS,Ky=mN&&vf.process,gN=function(){try{var r=ku&&ku.require&&ku.require("util").types;return r||Ky&&Ky.binding&&Ky.binding("util")}catch{}}(),ms=gN;var AS=ms&&ms.isTypedArray,yN=AS?Dl(AS):wS,Mf=yN;var vN=Object.prototype,xN=vN.hasOwnProperty;function bN(r,e){var t=yn(r),n=!t&&ps(r),i=!t&&!n&&Pl(r),s=!t&&!n&&!i&&Mf(r),o=t||n||i||s,a=o?mS(r.length,String):[],l=a.length;for(var u in r)(e||xN.call(r,u))&&!(o&&(u=="length"||i&&(u=="offset"||u=="parent")||s&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||qs(u,l)))&&a.push(u);return a}var Ef=bN;function wN(r,e){return function(t){return r(e(t))}}var Cf=wN;var SN=Cf(Object.keys,Object),_S=SN;var AN=Object.prototype,_N=AN.hasOwnProperty;function TN(r){if(!Cl(r))return _S(r);var e=[];for(var t in Object(r))_N.call(r,t)&&t!="constructor"&&e.push(t);return e}var TS=TN;function MN(r){return Ys(r)?Ef(r):TS(r)}var Il=MN;function EN(r){var e=[];if(r!=null)for(var t in Object(r))e.push(t);return e}var MS=EN;var CN=Object.prototype,PN=CN.hasOwnProperty;function DN(r){if(!Ht(r))return MS(r);var e=Cl(r),t=[];for(var n in r)n=="constructor"&&(e||!PN.call(r,n))||t.push(n);return t}var ES=DN;function IN(r){return Ys(r)?Ef(r,!0):ES(r)}var Ei=IN;var LN=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ON=/^\w*$/;function RN(r,e){if(yn(r))return!1;var t=typeof r;return t=="number"||t=="symbol"||t=="boolean"||r==null||js(r)?!0:ON.test(r)||!LN.test(r)||e!=null&&r in Object(e)}var CS=RN;var NN=hr(Object,"create"),gs=NN;function BN(){this.__data__=gs?gs(null):{},this.size=0}var PS=BN;function FN(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}var DS=FN;var UN="__lodash_hash_undefined__",GN=Object.prototype,zN=GN.hasOwnProperty;function kN(r){var e=this.__data__;if(gs){var t=e[r];return t===UN?void 0:t}return zN.call(e,r)?e[r]:void 0}var IS=kN;var VN=Object.prototype,HN=VN.hasOwnProperty;function WN(r){var e=this.__data__;return gs?e[r]!==void 0:HN.call(e,r)}var LS=WN;var jN="__lodash_hash_undefined__";function qN(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=gs&&e===void 0?jN:e,this}var OS=qN;function Ll(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ll.prototype.clear=PS;Ll.prototype.delete=DS;Ll.prototype.get=IS;Ll.prototype.has=LS;Ll.prototype.set=OS;var Jy=Ll;function XN(){this.__data__=[],this.size=0}var RS=XN;function YN(r,e){for(var t=r.length;t--;)if(Xs(r[t][0],e))return t;return-1}var Qs=YN;var QN=Array.prototype,ZN=QN.splice;function KN(r){var e=this.__data__,t=Qs(e,r);if(t<0)return!1;var n=e.length-1;return t==n?e.pop():ZN.call(e,t,1),--this.size,!0}var NS=KN;function JN(r){var e=this.__data__,t=Qs(e,r);return t<0?void 0:e[t][1]}var BS=JN;function $N(r){return Qs(this.__data__,r)>-1}var FS=$N;function eB(r,e){var t=this.__data__,n=Qs(t,r);return n<0?(++this.size,t.push([r,e])):t[n][1]=e,this}var US=eB;function Ol(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Ol.prototype.clear=RS;Ol.prototype.delete=NS;Ol.prototype.get=BS;Ol.prototype.has=FS;Ol.prototype.set=US;var Zs=Ol;var tB=hr(Zt,"Map"),Ks=tB;function nB(){this.size=0,this.__data__={hash:new Jy,map:new(Ks||Zs),string:new Jy}}var GS=nB;function rB(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}var zS=rB;function iB(r,e){var t=r.__data__;return zS(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Js=iB;function sB(r){var e=Js(this,r).delete(r);return this.size-=e?1:0,e}var kS=sB;function oB(r){return Js(this,r).get(r)}var VS=oB;function aB(r){return Js(this,r).has(r)}var HS=aB;function lB(r,e){var t=Js(this,r),n=t.size;return t.set(r,e),this.size+=t.size==n?0:1,this}var WS=lB;function Rl(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var n=r[e];this.set(n[0],n[1])}}Rl.prototype.clear=GS;Rl.prototype.delete=kS;Rl.prototype.get=VS;Rl.prototype.has=HS;Rl.prototype.set=WS;var Vu=Rl;var cB="Expected a function";function $y(r,e){if(typeof r!="function"||e!=null&&typeof e!="function")throw new TypeError(cB);var t=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=t.cache;if(s.has(i))return s.get(i);var o=r.apply(this,n);return t.cache=s.set(i,o)||s,o};return t.cache=new($y.Cache||Vu),t}$y.Cache=Vu;var jS=$y;var uB=500;function hB(r){var e=jS(r,function(n){return t.size===uB&&t.clear(),n}),t=e.cache;return e}var qS=hB;var dB=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fB=/\\(\\)?/g,pB=qS(function(r){var e=[];return r.charCodeAt(0)===46&&e.push(""),r.replace(dB,function(t,n,i,s){e.push(i?s.replace(fB,"$1"):n||t)}),e}),XS=pB;function mB(r){return r==null?"":Zw(r)}var YS=mB;function gB(r,e){return yn(r)?r:CS(r,e)?[r]:XS(YS(r))}var Wr=gB;var yB=1/0;function vB(r){if(typeof r=="string"||js(r))return r;var e=r+"";return e=="0"&&1/r==-yB?"-0":e}var $s=vB;function xB(r,e){e=Wr(e,r);for(var t=0,n=e.length;r!=null&&t<n;)r=r[$s(e[t++])];return t&&t==n?r:void 0}var Pf=xB;function bB(r,e){for(var t=-1,n=e.length,i=r.length;++t<n;)r[i+t]=e[t];return r}var Nl=bB;var QS=or?or.isConcatSpreadable:void 0;function wB(r){return yn(r)||ps(r)||!!(QS&&r&&r[QS])}var ZS=wB;function KS(r,e,t,n,i){var s=-1,o=r.length;for(t||(t=ZS),i||(i=[]);++s<o;){var a=r[s];e>0&&t(a)?e>1?KS(a,e-1,t,n,i):Nl(i,a):n||(i[i.length]=a)}return i}var JS=KS;function SB(r){var e=r==null?0:r.length;return e?JS(r,1):[]}var $S=SB;function AB(r){return _f(Tf(r,void 0,$S),r+"")}var Df=AB;var _B=Cf(Object.getPrototypeOf,Object),Bl=_B;var TB="[object Object]",MB=Function.prototype,EB=Object.prototype,eA=MB.toString,CB=EB.hasOwnProperty,PB=eA.call(Object);function DB(r){if(!qn(r)||Dr(r)!=TB)return!1;var e=Bl(r);if(e===null)return!0;var t=CB.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&eA.call(t)==PB}var If=DB;function IB(r,e,t){var n=-1,i=r.length;e<0&&(e=-e>i?0:i+e),t=t>i?i:t,t<0&&(t+=i),i=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(i);++n<i;)s[n]=r[n+e];return s}var tA=IB;function LB(){this.__data__=new Zs,this.size=0}var nA=LB;function OB(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}var rA=OB;function RB(r){return this.__data__.get(r)}var iA=RB;function NB(r){return this.__data__.has(r)}var sA=NB;var BB=200;function FB(r,e){var t=this.__data__;if(t instanceof Zs){var n=t.__data__;if(!Ks||n.length<BB-1)return n.push([r,e]),this.size=++t.size,this;t=this.__data__=new Vu(n)}return t.set(r,e),this.size=t.size,this}var oA=FB;function Fl(r){var e=this.__data__=new Zs(r);this.size=e.size}Fl.prototype.clear=nA;Fl.prototype.delete=rA;Fl.prototype.get=iA;Fl.prototype.has=sA;Fl.prototype.set=oA;var Lf=Fl;function UB(r,e){return r&&Hr(e,Il(e),r)}var aA=UB;function GB(r,e){return r&&Hr(e,Ei(e),r)}var lA=GB;var dA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,cA=dA&&typeof module=="object"&&module&&!module.nodeType&&module,zB=cA&&cA.exports===dA,uA=zB?Zt.Buffer:void 0,hA=uA?uA.allocUnsafe:void 0;function kB(r,e){if(e)return r.slice();var t=r.length,n=hA?hA(t):new r.constructor(t);return r.copy(n),n}var Of=kB;function VB(r,e){for(var t=-1,n=r==null?0:r.length,i=0,s=[];++t<n;){var o=r[t];e(o,t,r)&&(s[i++]=o)}return s}var fA=VB;function HB(){return[]}var Rf=HB;var WB=Object.prototype,jB=WB.propertyIsEnumerable,pA=Object.getOwnPropertySymbols,qB=pA?function(r){return r==null?[]:(r=Object(r),fA(pA(r),function(e){return jB.call(r,e)}))}:Rf,Ul=qB;function XB(r,e){return Hr(r,Ul(r),e)}var mA=XB;var YB=Object.getOwnPropertySymbols,QB=YB?function(r){for(var e=[];r;)Nl(e,Ul(r)),r=Bl(r);return e}:Rf,Nf=QB;function ZB(r,e){return Hr(r,Nf(r),e)}var gA=ZB;function KB(r,e,t){var n=e(r);return yn(r)?n:Nl(n,t(r))}var Bf=KB;function JB(r){return Bf(r,Il,Ul)}var yA=JB;function $B(r){return Bf(r,Ei,Nf)}var Ff=$B;var eF=hr(Zt,"DataView"),Uf=eF;var tF=hr(Zt,"Promise"),Gf=tF;var nF=hr(Zt,"Set"),zf=nF;var vA="[object Map]",rF="[object Object]",xA="[object Promise]",bA="[object Set]",wA="[object WeakMap]",SA="[object DataView]",iF=fs(Uf),sF=fs(Ks),oF=fs(Gf),aF=fs(zf),lF=fs(Sf),Ko=Dr;(Uf&&Ko(new Uf(new ArrayBuffer(1)))!=SA||Ks&&Ko(new Ks)!=vA||Gf&&Ko(Gf.resolve())!=xA||zf&&Ko(new zf)!=bA||Sf&&Ko(new Sf)!=wA)&&(Ko=function(r){var e=Dr(r),t=e==rF?r.constructor:void 0,n=t?fs(t):"";if(n)switch(n){case iF:return SA;case sF:return vA;case oF:return xA;case aF:return bA;case lF:return wA}return e});var Gl=Ko;var cF=Object.prototype,uF=cF.hasOwnProperty;function hF(r){var e=r.length,t=new r.constructor(e);return e&&typeof r[0]=="string"&&uF.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var AA=hF;var dF=Zt.Uint8Array,ev=dF;function fF(r){var e=new r.constructor(r.byteLength);return new ev(e).set(new ev(r)),e}var zl=fF;function pF(r,e){var t=e?zl(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var _A=pF;var mF=/\w*$/;function gF(r){var e=new r.constructor(r.source,mF.exec(r));return e.lastIndex=r.lastIndex,e}var TA=gF;var MA=or?or.prototype:void 0,EA=MA?MA.valueOf:void 0;function yF(r){return EA?Object(EA.call(r)):{}}var CA=yF;function vF(r,e){var t=e?zl(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var kf=vF;var xF="[object Boolean]",bF="[object Date]",wF="[object Map]",SF="[object Number]",AF="[object RegExp]",_F="[object Set]",TF="[object String]",MF="[object Symbol]",EF="[object ArrayBuffer]",CF="[object DataView]",PF="[object Float32Array]",DF="[object Float64Array]",IF="[object Int8Array]",LF="[object Int16Array]",OF="[object Int32Array]",RF="[object Uint8Array]",NF="[object Uint8ClampedArray]",BF="[object Uint16Array]",FF="[object Uint32Array]";function UF(r,e,t){var n=r.constructor;switch(e){case EF:return zl(r);case xF:case bF:return new n(+r);case CF:return _A(r,t);case PF:case DF:case IF:case LF:case OF:case RF:case NF:case BF:case FF:return kf(r,t);case wF:return new n;case SF:case TF:return new n(r);case AF:return TA(r);case _F:return new n;case MF:return CA(r)}}var PA=UF;function GF(r){return typeof r.constructor=="function"&&!Cl(r)?sS(Bl(r)):{}}var Vf=GF;var zF="[object Map]";function kF(r){return qn(r)&&Gl(r)==zF}var DA=kF;var IA=ms&&ms.isMap,VF=IA?Dl(IA):DA,LA=VF;var HF="[object Set]";function WF(r){return qn(r)&&Gl(r)==HF}var OA=WF;var RA=ms&&ms.isSet,jF=RA?Dl(RA):OA,NA=jF;var qF=1,XF=2,YF=4,BA="[object Arguments]",QF="[object Array]",ZF="[object Boolean]",KF="[object Date]",JF="[object Error]",FA="[object Function]",$F="[object GeneratorFunction]",eU="[object Map]",tU="[object Number]",UA="[object Object]",nU="[object RegExp]",rU="[object Set]",iU="[object String]",sU="[object Symbol]",oU="[object WeakMap]",aU="[object ArrayBuffer]",lU="[object DataView]",cU="[object Float32Array]",uU="[object Float64Array]",hU="[object Int8Array]",dU="[object Int16Array]",fU="[object Int32Array]",pU="[object Uint8Array]",mU="[object Uint8ClampedArray]",gU="[object Uint16Array]",yU="[object Uint32Array]",Nt={};Nt[BA]=Nt[QF]=Nt[aU]=Nt[lU]=Nt[ZF]=Nt[KF]=Nt[cU]=Nt[uU]=Nt[hU]=Nt[dU]=Nt[fU]=Nt[eU]=Nt[tU]=Nt[UA]=Nt[nU]=Nt[rU]=Nt[iU]=Nt[sU]=Nt[pU]=Nt[mU]=Nt[gU]=Nt[yU]=!0;Nt[JF]=Nt[FA]=Nt[oU]=!1;function Hf(r,e,t,n,i,s){var o,a=e&qF,l=e&XF,u=e&YF;if(t&&(o=i?t(r,n,i,s):t(r)),o!==void 0)return o;if(!Ht(r))return r;var c=yn(r);if(c){if(o=AA(r),!a)return Af(r,o)}else{var h=Gl(r),d=h==FA||h==$F;if(Pl(r))return Of(r,a);if(h==UA||h==BA||d&&!i){if(o=l||d?{}:Vf(r),!a)return l?gA(r,lA(o,r)):mA(r,aA(o,r))}else{if(!Nt[h])return i?r:{};o=PA(r,h,a)}}s||(s=new Lf);var f=s.get(r);if(f)return f;s.set(r,o),NA(r)?r.forEach(function(g){o.add(Hf(g,e,t,g,r,s))}):LA(r)&&r.forEach(function(g,v){o.set(v,Hf(g,e,t,v,r,s))});var m=u?l?Ff:yA:l?Ei:Il,p=c?void 0:m(r);return uS(p||r,function(g,v){p&&(v=g,g=r[v]),Ml(o,v,Hf(g,e,t,v,r,s))}),o}var Wf=Hf;var vU=1,xU=4;function bU(r){return Wf(r,vU|xU)}var Hu=bU;function wU(r,e){return r!=null&&e in Object(r)}var GA=wU;function SU(r,e,t){e=Wr(e,r);for(var n=-1,i=e.length,s=!1;++n<i;){var o=$s(e[n]);if(!(s=r!=null&&t(r,o)))break;r=r[o]}return s||++n!=i?s:(i=r==null?0:r.length,!!i&&El(i)&&qs(o,i)&&(yn(r)||ps(r)))}var zA=SU;function AU(r,e){return r!=null&&zA(r,e,GA)}var kA=AU;function _U(r){return function(e,t,n){for(var i=-1,s=Object(e),o=n(e),a=o.length;a--;){var l=o[r?a:++i];if(t(s[l],l,s)===!1)break}return e}}var VA=_U;var TU=VA(),HA=TU;var MU=function(){return Zt.Date.now()},jf=MU;var EU="Expected a function",CU=Math.max,PU=Math.min;function DU(r,e,t){var n,i,s,o,a,l,u=0,c=!1,h=!1,d=!0;if(typeof r!="function")throw new TypeError(EU);e=Qy(e)||0,Ht(t)&&(c=!!t.leading,h="maxWait"in t,s=h?CU(Qy(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function f(_){var M=n,x=i;return n=i=void 0,u=_,o=r.apply(x,M),o}function m(_){return u=_,a=setTimeout(v,e),c?f(_):o}function p(_){var M=_-l,x=_-u,T=e-M;return h?PU(T,s-x):T}function g(_){var M=_-l,x=_-u;return l===void 0||M>=e||M<0||h&&x>=s}function v(){var _=jf();if(g(_))return y(_);a=setTimeout(v,p(_))}function y(_){return a=void 0,d&&n?f(_):(n=i=void 0,o)}function b(){a!==void 0&&clearTimeout(a),u=0,n=l=i=a=void 0}function w(){return a===void 0?o:y(jf())}function S(){var _=jf(),M=g(_);if(n=arguments,i=this,l=_,M){if(a===void 0)return m(l);if(h)return clearTimeout(a),a=setTimeout(v,e),f(l)}return a===void 0&&(a=setTimeout(v,e)),o}return S.cancel=b,S.flush=w,S}var Wu=DU;function IU(r,e,t){(t!==void 0&&!Xs(r[e],t)||t===void 0&&!(e in r))&&Tl(r,e,t)}var ju=IU;function LU(r){return qn(r)&&Ys(r)}var WA=LU;function OU(r,e){if(!(e==="constructor"&&typeof r[e]=="function")&&e!="__proto__")return r[e]}var qu=OU;function RU(r){return Hr(r,Ei(r))}var jA=RU;function NU(r,e,t,n,i,s,o){var a=qu(r,t),l=qu(e,t),u=o.get(l);if(u){ju(r,t,u);return}var c=s?s(a,l,t+"",r,e,o):void 0,h=c===void 0;if(h){var d=yn(l),f=!d&&Pl(l),m=!d&&!f&&Mf(l);c=l,d||f||m?yn(a)?c=a:WA(a)?c=Af(a):f?(h=!1,c=Of(l,!0)):m?(h=!1,c=kf(l,!0)):c=[]:If(l)||ps(l)?(c=a,ps(a)?c=jA(a):(!Ht(a)||Al(a))&&(c=Vf(l))):h=!1}h&&(o.set(l,c),i(c,l,n,s,o),o.delete(l)),ju(r,t,c)}var qA=NU;function XA(r,e,t,n,i){r!==e&&HA(e,function(s,o){if(i||(i=new Lf),Ht(s))qA(r,e,o,t,XA,n,i);else{var a=n?n(qu(r,o),s,o+"",r,e,i):void 0;a===void 0&&(a=s),ju(r,o,a)}},Ei)}var YA=XA;function BU(r){var e=r==null?0:r.length;return e?r[e-1]:void 0}var QA=BU;function FU(r,e){return e.length<2?r:Pf(r,tA(e,0,-1))}var ZA=FU;var UU=pS(function(r,e,t){YA(r,e,t)}),Jo=UU;function GU(r,e){return e=Wr(e,r),r=ZA(r,e),r==null||delete r[$s(QA(e))]}var KA=GU;function zU(r){return If(r)?void 0:r}var JA=zU;var kU=1,VU=2,HU=4,WU=Df(function(r,e){var t={};if(r==null)return t;var n=!1;e=xf(e,function(s){return s=Wr(s,r),n||(n=s.length>1),s}),Hr(r,Ff(r),t),n&&(t=Wf(t,kU|VU|HU,JA));for(var i=e.length;i--;)KA(t,e[i]);return t}),kl=WU;function jU(r,e,t,n){if(!Ht(r))return r;e=Wr(e,r);for(var i=-1,s=e.length,o=s-1,a=r;a!=null&&++i<s;){var l=$s(e[i]),u=t;if(l==="__proto__"||l==="constructor"||l==="prototype")return r;if(i!=o){var c=a[l];u=n?n(c,l,a):void 0,u===void 0&&(u=Ht(c)?c:qs(e[i+1])?[]:{})}Ml(a,l,u),a=a[l]}return r}var $A=jU;function qU(r,e,t){for(var n=-1,i=e.length,s={};++n<i;){var o=e[n],a=Pf(r,o);t(a,o)&&$A(s,Wr(o,r),a)}return s}var e1=qU;function XU(r,e){return e1(r,e,function(t,n){return kA(r,n)})}var t1=XU;var YU=Df(function(r,e){return r==null?{}:t1(r,e)}),Vl=YU;var r1,i1=new Promise(r=>{r1=r}),n1=!1;async function s1(){if(n1)return;let r=await import("./physics.js");await r.init(),r1(r),n1=!0}var zt=class{modifyById(e,t){let n=this;if(n[e]===void 0)throw new Error("not expected");{let s={...n,[e]:t};return Object.setPrototypeOf(s,zt.prototype),s}}add(e,t){return this.runOp({type:1,id:e,data:t})?.data??this}runOp(e){let t=this;if(e.type===1){let n=t[e.id],i;n===void 0?i={type:2,id:e.id}:i={type:1,id:e.id,data:n};let{id:s,data:o}=e,a={...t,[s]:o};return Object.setPrototypeOf(a,zt.prototype),{data:a,actual:e,reverse:i}}else if(e.type===2){let{id:n}=e,i=t[n];if(i===void 0)return null;{let s={...t};return Object.setPrototypeOf(s,zt.prototype),delete s[n],{data:s,actual:e,reverse:{type:1,id:n,data:i}}}}throw new Error("illegal arg")}};function Xu(r){if(r.deepFreeze!==void 0){r.deepFreeze(r);return}let e=Object.getOwnPropertyNames(r);for(let t of e){let n=r[t];n&&typeof n=="object"&&Xu(n)}return Object.freeze(r)}function o1(r,e){let t=0;for(;t<r.length&&t<e.length;){if(r[t]<e[t])return-1;if(r[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==r.length?1:0}var Hl=class extends Error{};function Ci(r,e,t){if(r===void 0?e===void 0?(r=0,e=10):r=e-10:e===void 0&&(e=r+10),r>e){let s=r;r=e,e=s}let n=[],i=1/(t+1);for(let s=0;s<t;s++){let o=r+(e-r)*(s+.75+Math.random()*.5)*i;n.push(o)}return n}function $o(r){return r instanceof Uint8Array||r instanceof Uint16Array||r instanceof Uint32Array||r instanceof Int8Array||r instanceof Int16Array||r instanceof Int32Array||r instanceof Float32Array||r instanceof Float64Array}function a1(){return typeof process<"u"}function l1(r,e){for(let t of r)e(t.id,t.data),l1(t.children,e)}function c1(r,e){e(r.id,r.data);for(let t of r.children)c1(t,e)}var Bt=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Bt.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Xu(this[t]),t++}fillCaches0(t,n){this.objCaches.set(t.id,t),this.parentCaches.set(t.id,n);for(let i of t.children)this.fillCaches0(i,t.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let t of this)this.fillCaches0(t,null)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}isDescendantOf(t,n){for(;t;){let i=this.parent(t);if(i===n)return!0;t=i}return!1}data(t){return this.get(t)?.data}has(t){return this.childrenOf(t)!==void 0}get(t){return this.fillCaches(),this.objCaches.get(t)}childrenOf(t){return t===null?this:this.get(t)?.children}traverseFrom(t,n){if(t===null)this.traverse(n);else{let i=this.get(t);i&&c1(i,n)}}traverse(t){l1(this,t)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(t){return this.fillCaches(),this.parentCaches.get(t)}childrenArray(t){return t===null?this:this.get(t).children}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this.parent(t),o=this.childrenArray(s),a=o.findIndex(c=>c.id===t);if(a<0)throw new Error("not expected");let l=o[a];return o=[...o],o[a]={...l,data:n},this.modifyArrayBy(s,o)}}modifyArrayBy(t,n){let i=t,s=n;for(;i!==null;){let a=s,l=i;if(i=this.parent(i),i===void 0)throw new Error;s=this.childrenArray(i);let u=s.findIndex(c=>c.id===l);if(u<0)throw new Error;s=[...s],s[u]={...s[u],children:a}}Object.setPrototypeOf(s,Bt.prototype);let o=s;return o.fillCaches(),o}runOp(t){switch(t.type){case 7:return this.addOp(t);case 8:return this.deleteOp(t);case 9:return this.moveOp(t)}}checkDuplicatedIdRec({id:t,children:n}){if(this.get(t)!==void 0)return!0;for(let i of n)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(t){let{parent:n,fi:i,id:s,data:o,children:a}=t;if(n!==null&&this.get(n)===void 0)return null;if(this.checkDuplicatedIdRec(t))return null;{let l=n,u=this.childrenArray(l),c={fi:i,id:s,data:o,children:a};return u=[...u,c],u.sort((d,f)=>d.fi-f.fi),t.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:t,reverse:{type:8,id:s}}}}deleteOp(t){let{id:n}=t;if(this.get(n)===null)return null;{let i=this.parent(n);if(i===void 0)return null;let s=this.childrenArray(i),o=s.findIndex(u=>u.id===n);t.localIndex=o,s=[...s];let a=s.splice(o,1)[0];return{data:this.modifyArrayBy(i,s),actual:t,reverse:{type:7,...a,parent:i}}}}moveOp(t){let{parent:n,fi:i,id:s}=t;if(n!==null&&this.get(n)===void 0)return this.deleteOp({type:8,id:s});if(n!==null){let f=n;for(;f!==null;){if(f===void 0)throw new Error;if(f===s)throw new Hl("cyclic tree");f=this.parent(f)}}let o=this.parent(s);if(o===void 0)return null;let a=o,l=this.childrenArray(o),u=l.findIndex(f=>f.id===s);l=[...l];let c=l.splice(u,1)[0],h=this.modifyArrayBy(o,l);o=n,l=h.childrenArray(o);let d=c.fi;return c={...c,fi:i},l=[...l,c],l.sort((f,m)=>f.fi-m.fi),t.localIndex=l.indexOf(c),h=h.modifyArrayBy(o,l),{data:h,actual:t,reverse:{type:9,parent:a,fi:d,id:s}}}previous(t,n){if(n===null){let s=this.childrenArray(t);return s.length===0?null:s[s.length-1].id}let i=null;for(let s of this.childrenArray(t)){if(s.id===n)return i;i=s.id}return null}traverseSortNext(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)+1;if(s<i.length)return i[s].id;if(n)return this.traverseSortNext(n)}}sortNext(t){let n=this.childrenArray(t);return n.length>0?n[0].id:this.traverseSortNext(t)}traverseSortPrevious(t){let n=this.childrenArray(t);return n.length>0?this.traverseSortPrevious(n[n.length-1].id):t}sortPrevious(t){let n=this.parent(t);if(n!==void 0){let i=this.childrenArray(n),s=i.findIndex(o=>o.id===t)-1;return s>=0?this.traverseSortPrevious(i[s].id):n}}getAllSorted(t){let n=[];for(let i of t){let s=this.getWithSortKey(i.id);s!==void 0&&n.push({...i,...s})}n.sort((i,s)=>o1(i.sortKey,s.sortKey));for(let i of n)delete i.sortKey;return n}getWithSortKey(t){var n=t;let i=[],s=this.get(n),o=s;if(s!==void 0){for(;n;)i.splice(0,0,s.fi),n=this.parent(n),n!==null&&(s=this.get(n));return{...o,sortKey:i}}}insertBeforeHelper(t,n,i){return this.insertAfterHelper(t,this.previous(t,n),i)}insertAfterHelper(t,n,i){let s=this.childrenArray(t);if(n===null){if(s.length===0)return Ci(0,i,i);{let o=s[0].fi;return Ci(o-i,o,i)}}else{let o=this.get(n);if(o===void 0||this.parent(n)!==t)throw new Error("illegal args");let a=s.find(l=>l.fi>o.fi);if(a===void 0){let l=s[s.length-1].fi;return Ci(l,l+i,i)}else return Ci(o.fi,a.fi,i)}}};var Wl;(e=>{function r(t,n){if(Array.isArray(t)){let i=n.props,s={},o=[...t],a=!1;if(i)for(let l of Object.keys(i)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");s[l]=o[u],o[u]=i[l],a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}else{let i=n.props,s={},o={...t},a=!1;if(i)for(let l of Object.keys(i)){s[l]=o[l];let u=i[l];u===void 0?delete o[l]:o[l]=u,a=!0}return a?{data:o,actual:n,reverse:{type:0,props:s}}:null}}e.runOp=r})(Wl||(Wl={}));var Ve=class extends Array{constructor(...t){super(...t);Object.setPrototypeOf(this,Ve.prototype)}deepFreeze(){let t=0;for(;t<this.length;)Xu(this[t]),t++}fillCaches0(t){this.objCaches.set(t.id,t)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let t of this)this.fillCaches0(t)}}randomId(){this.fillCaches();let t=Array.from(this.objCaches.keys());if(t.length!==0)return t[Math.max(0,Math.floor(Math.random()*t.length)-1)]}data(t){return this.get(t)?.data}get(t){return this.fillCaches(),this.objCaches.get(t)}modifyById(t,n){if(this.get(t)===void 0)throw new Error("not expected");{let s=this,o=s.findIndex(u=>u.id===t);if(o<0)throw new Error("not expected");let a=s[o];return s=[...s],s[o]={...a,data:n},this.modifyArrayBy(s)}}modifyArrayBy(t){Object.setPrototypeOf(t,Ve.prototype);let n=t;return a1()||n.fillCaches(),n}runOp(t){switch(t.type){case 4:return this.addOp(t);case 5:return this.deleteOp(t);case 6:return this.moveOp(t)}}addOp(t){let{fi:n,id:i,data:s}=t,o=this,a={fi:n,id:i,data:s};return o=[...o,a],o.sort((u,c)=>u.fi-c.fi),t.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:t,reverse:{type:5,id:i}}}deleteOp(t){let{id:n}=t,i=this,s=i.findIndex(l=>l.id===n);if(s===-1)return null;t.localIndex=s,i=[...i];let o=i.splice(s,1)[0];return{data:this.modifyArrayBy(i),actual:t,reverse:{type:4,...o}}}moveOp(t){let{fi:n,id:i}=t,s=this;s=[...s];let o=s.findIndex(c=>c.id===i);if(o===-1)return null;let a=s[o].fi,l={...s[o],fi:n};return s[o]=l,s.sort((c,h)=>c.fi-h.fi),t.localIndex=s.indexOf(l),{data:this.modifyArrayBy(s),actual:t,reverse:{type:6,fi:a,id:i}}}previous(t){if(t===null)return this.length===0?null:this[this.length-1].id;let n=null;for(let i of this){if(i.id===t)return n;n=i.id}return null}insertBeforeHelper(t,n){return this.insertAfterHelper(this.previous(t),n)}insertAfterHelper(t,n){let i=this;if(t===null){if(i.length===0)return Ci(0,n,n);{let s=i[0].fi;return Ci(s-n,s,n)}}else{let s=this.get(t);if(s===void 0)throw new Error("illegal args");let o=i.find(a=>a.fi>s.fi);if(o===void 0){let a=i[i.length-1].fi;return Ci(a,a+n,n)}else return Ci(s.fi,o.fi,n)}}};var Ir=class{unusedFun(e){}runOp(e){let t=[],n=this,i=0,s={};for(;i<e.path.length;){if(t.push(n),n=n===void 0?void 0:n[e.path[i]],n instanceof Bt||n instanceof Ve)return null;i+=1}n={...n};for(let[l,u]of Object.entries(e.props)){let c=n[l];s[l]=c,u===void 0?delete n[l]:n[l]=u}for(;i>0;)Object.keys(n).length===0?(n={...t[i-1]},delete n[e.path[i-1]]):n={...t[i-1],[e.path[i-1]]:n},i-=1;let o=Object.setPrototypeOf(n,Ir.prototype),a={...e,props:s};return{data:o,actual:e,reverse:a}}},u1;(t=>{function r(n,i){return Yu(n,i)??n}t.apply=r;function e(n,i){if(i.type===0){let s=0,o=i.path,a=n;for(;s<o.length&&a!==void 0;){if(a=Pi.zoomOnce(a,o[s]),a instanceof Bt||a instanceof Ve)return;s+=1}if(a===void 0)return i;if(typeof a=="string"||typeof a=="number"||$o(a))return;if(a&&typeof a=="object"){let l={...i.props};for(let u of Object.keys(a))delete l[u];return{...i,props:l}}else return}else if(i.type===1||i.type===4||i.type===7){let s=Pi.zoom(n,[...i.path,i.id]);if(s===void 0)return i;if(typeof s=="string"||typeof s=="number"||$o(s))return;if(s&&typeof s=="object"){let o={...i.data,...s};return{...i,data:o}}else return}else return i}t.filterOp=e})(u1||(u1={}));function h1(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Yu(i.data,e[s]);t=t||o!==void 0,o===void 0&&(o=i.data);let a=h1(i.children,e);return a!==void 0?t=!0:a=i.children,{...i,id:s,data:o,children:a}});if(t)return n}function QU(r,e){if(e===void 0)return;let t=!1,n=r.map(i=>{let s=i.id,o=Yu(i.data,e[s]);return t=t||o!==void 0,o===void 0&&(o=i.data),{...i,id:s,data:o}});if(t)return Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}function Yu(r,e){if(e!==void 0){if(e instanceof Ve||e instanceof Bt||typeof e=="string"||typeof e=="number"||e===null)return e;if(r instanceof Bt){let t=h1(r,e);return t!==void 0&&Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t}else{if(r instanceof Ve)return QU(r,e);if(Array.isArray(r)){let t=!1,n=r.map((i,s)=>{let o=Yu(i,e[s]);return t=t||o!==void 0,o===void 0&&(o=i),o});return t?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(r&&typeof r=="object"){let t={},n=!1;for(let[i,s]of Object.entries(r)){let o=Yu(s,e[i]);n=n||o!==void 0,o===void 0&&(o=s),t[i]=o}return n?(Object.setPrototypeOf(t,Object.getPrototypeOf(r)),t):void 0}else return e??r}}}function d1(r,e){let t={cur:[],result:[],len:0};return r=Qu(r,e,t)??r,[r,t.result]}function qf(r,e){return r===null?null:(r.cur[r.len]=e,r.len+=1,r)}function Xf(r){r&&(r.len-=1)}function ZU(r){if(r===null)return null;r.result.push(r.cur.slice(0,r.len))}function f1(r,e,t){let n=!1,i=r.map(s=>{let o=s.id,a=e[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,t!==null))throw new Error("not supported");let l=Qu(s.data,e,qf(t,o));Xf(t),n=n||l!==void 0,l===void 0&&(l=s.data);let u=f1(s.children,e,t);return u!==void 0?n=!0:u=s.children,{...s,id:o,data:l,children:u}});if(n)return i}function KU(r,e,t){let n=!1,i=r.map(s=>{let o=s.id,a=e[o];if(a!==void 0&&typeof a=="string"&&(n=!0,o=a,t!==null))throw new Error("not supported");let l=Qu(s.data,e,qf(t,o));return Xf(t),n=n||l!==void 0,l===void 0&&(l=s.data),{...s,id:o,data:l}});if(n)return Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i}function Qu(r,e,t){if(r instanceof Bt){let n=f1(r,e,t);return n!==void 0&&Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n}else{if(r instanceof Ve)return KU(r,e,t);if(Array.isArray(r)){let n=!1,i=r.map((s,o)=>{let a=Qu(s,e,qf(t,o));return Xf(t),n=n||a!==void 0,a===void 0&&(a=s),a});return n?(Object.setPrototypeOf(i,Object.getPrototypeOf(r)),i):void 0}else if(r&&typeof r=="object"){let n={},i=!1;for(let[s,o]of Object.entries(r))if(s!=="name"&&s!=="text"){let a=e[s];if(typeof a=="string"){if(t!==null)throw new Error("not supported");i=!0,s=a}let l=Qu(o,e,qf(t,s));Xf(t),i=i||l!==void 0,l===void 0&&(l=o),n[s]=l}else n[s]=o;return i?(Object.setPrototypeOf(n,Object.getPrototypeOf(r)),n):void 0}else if(typeof r=="string"){let n=e[r];if(n!==void 0){if(r.length!==36)throw new Error("for now you should only call this method when the key is a uuid");ZU(t)}return n}else return}}var p1;(e=>{function r(t,n){let i=Pi.zoom(n,t.path);if(typeof i=="object"){let s={};for(let o of Object.keys(t.props))s[o]=i[o];return{...t,props:s}}else return{...t,props:{}}}e.replaceProps=r})(p1||(p1={}));var eo;(a=>{function r(l,u){return{...l,path:l.path.slice(u)}}a.drop=r;function e(l,u){return t(l,u)?.data??l}a.applySimple=e;function t(l,u){let c=u.path;for(var h=[];;){let d;if(l instanceof Ir&&u.type===0&&(d=l.runOp({...u,path:c.slice(h.length)}),d===null&&(d=void 0)),h.length===c.length&&(l instanceof Bt||l instanceof Ve||l instanceof zt?d=l.runOp(u):d=Wl.runOp(l,u)),d!==void 0)if(d!==null){let p=d.data;for(let g=h.length-1;g>=0;g--){let v=c[g],y=h[g];if(y instanceof Bt){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof Ve){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof zt){if(typeof v=="number")throw new Error("illegal arg");p=y.modifyById(v,p)}else if(y instanceof Ir){let b={...y,[v]:p};p=Object.setPrototypeOf(b,Ir.prototype)}else if(typeof y=="object")if(Array.isArray(y)){if(typeof v=="string"&&(v=parseInt(v),isNaN(v)))throw new Error("Invalid path");let b=p;p=[...y],p[v]=b}else p={...y,[v]:p};else return null}return{data:p,actual:{...d.actual,path:c},reverse:{...d.reverse,path:c}}}else return null;let f=c[h.length],m;if(l instanceof Bt){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else if(l instanceof Ve){if(typeof f=="number")throw new Error("");m=l.get(f)?.data}else l!==null&&(m=l[f]);if(m!==void 0)h.push(l),l=m;else return null}}a.apply=t;function n(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}a.pathDisjoint=n;function i(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}a.pathEq=i;function s(l,u){return n(l.path,u.path)}a.commutative=s;function o(l,u){return l.type===0&&u.type===0&&i(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}a.subsumed=o})(eo||(eo={}));var m1;(l=>{function r(){return[]}l.empty=r;function e(u,c){let h=[];for(let d of u){let[f,...m]=d.path;f===c&&h.push({...d,path:m})}return h}l.removePrefix=e;function t(u,c){return u.map(h=>({...h,path:[c,...h.path]}))}l.addPrefix=t;function n(u,c){return[...u,...c]}l.concat=n;function i(u,c){return[...u.filter(d=>!c.some(f=>eo.subsumed(d,f))),...c]}l.compress=i;function s(u,c){return u.every(h=>c.every(d=>eo.commutative(h,d)))}l.commutative=s;function o(u,c){for(let h of c){let d=a(u,h);d!==null&&(u=d.data)}return u}l.applyAll=o;function a(u,c){var h=u;let d=[],f=[];for(let m of c)try{if(m.type===3){let p=Pi.zoom(h,[...m.path,m.id]),g=eo.apply(h,{...m,type:2});if(g!==null){h=g.data;let[v,y]=d1(h,{[m.id]:p});h=v;for(let b of y){let w=b[b.length-1];b.splice(b.length-1,1),d.push({type:0,path:b,props:{[w]:p}}),f.push({type:0,path:b,props:{[w]:m.id}})}f.push(g.reverse),d.push(g.actual)}}else{let p=eo.apply(h,m);p!==null&&(d.push(p.actual),h=p.data,f.push(p.reverse))}}catch(p){if(p instanceof Hl)return null;throw p}return{data:h,actual:d,reverse:f.reverse()}}l.apply=a})(m1||(m1={}));var g1=Symbol(),Zu=Symbol(),ea=class{reportOp(e,t,n=[]){let i=this;if(t===null)return;i._current=t.data;let s=n;for(;!(i instanceof Qf);){let o=i._path,a=i._current;if(o!==""&&s.splice(0,0,o),i=i._parent,i===null)return;i.update(o,a)}i.push(s,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let n=t[Zu];n&&n(),delete this._children[e]}}}},nv=class extends ea{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current={...this._current,[e]:t}}runOp(e){this.reportOp(e,Wl.runOp(this._current,e),e.path)}},rv=class extends ea{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n}update(e,t){this._current={...this._current,[e]:t},Object.setPrototypeOf(this._current,zt.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},y1={get(r,e){if(e===Zu)return()=>{r._parent=null};if(e===g1)return r._current;let{_current:t,_children:n}=r;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t[e],o=Zf(r,e,s);return o!==s?(n===void 0&&(n={},r._children=n),n[e]=o,o):s},has(r,e){return e in r._current},ownKeys(r){return Reflect.ownKeys(r._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(r){return Object.getPrototypeOf(r._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(r,e){let t=r._current,n=Reflect.getOwnPropertyDescriptor(t,e);return n&&{writable:!0,configurable:!0,enumerable:n.enumerable,value:t[e]}}},JU={...y1,set(r,e,t){let n={type:0,props:{[e]:dr(t)??t}};return r.deleteChildren(e),r.runOp(n),!0},deleteProperty(r,e){let t={type:0,props:{[e]:void 0}};return r.deleteChildren(e),r.runOp(t),!0}},$U={...y1,set(r,e,t){return t===void 0?this.deleteProperty(r,e):(r.deleteChildren(e),r.runOp({type:1,id:e,data:t})),!0},deleteProperty(r,e){return r.runOp({type:2,id:e}),!0}},jl=class extends ea{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Zu]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}traverse(e){this._current.traverse((t,n)=>{e(t,this.data(t))})}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Zf(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}add(e,t,n,i,s){this.runOp({type:7,parent:e,fi:t,id:n,data:i,children:s})}move(e,t,n){this.runOp({type:9,parent:e,fi:t,id:n})}insertAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}insertBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.add(e,i[s],o.id,o.data,o.children)}}moveAfter(e,t,n){let i=this._current.insertAfterHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}moveBefore(e,t,n){let i=this._current.insertBeforeHelper(e,t,n.length);for(let s=0;s<n.length;s++){let o=n[s];this.move(e,i[s],o)}}delete(e){this.deleteChildren(e),this.runOp({type:8,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Yf=class extends ea{constructor(e,t,n){super(),this._parent=e,this._path=t,this._current=n,this[Zu]=()=>{this._parent=null}}feedOp(e){let{path:t,...n}=e;this.reportOp(n,eo.apply(this._current,e),t)}},ql=class extends ea{constructor(e,t,n){super(),this._children={},this._parent=e,this._path=t,this._current=n,this[Zu]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id,s=this._current[n].fi;e(this.data(this._current[n].id),i,s)}}find(e){let t=this.length;for(let n=0;n<t;n++){let i=this._current[n].id;if(e(this.data(i),i))return this.get(i)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return{...this._current.get(e),data:this.data(e)}}data(e){let{_current:t,_children:n}=this,i=n===void 0?void 0:n[e];if(i!==void 0)return i;let s=t.get(e)?.data,o=Zf(this,e,s);return o!==s?(n===void 0&&(n={},this._children=n),n[e]=o,o):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,n){this.runOp({type:4,fi:e,id:t,data:n})}move(e,t){this.runOp({type:6,fi:e,id:t})}insertAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}insertBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.add(n[i],s.id,s.data)}}moveAfter(e,t){let n=this._current.insertAfterHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}moveBefore(e,t){let n=this._current.insertBeforeHelper(e,t.length);for(let i=0;i<t.length;i++){let s=t[i];this.move(n[i],s)}}delete(e){this.deleteChildren(e),this.runOp({type:5,id:e})}};function tv(r,e,t){if(r.length>0){let n=r[r.length-1];if(n.type===0&&e.type===0&&Pi.equal(n.path,t)){Object.assign(n.props,e.props);return}}r.push({...e,path:t})}var Qf=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,n,i){tv(this.ts,t,e),tv(this.actual,n,e),tv(this.reverse,i,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Zf(r,e,t){return t instanceof Bt?new jl(r,e,t):t instanceof Ve?new ql(r,e,t):t instanceof Ir?new Yf(r,e,t):t instanceof zt?new Proxy(new rv(r,e,t),$U):t!==null&&typeof t=="object"?$o(t)?t:new Proxy(new nv(r,e,t),JU):t}function iv(r){let e=new Qf(r);return[Zf(e,"",r),e]}function sv(r,e){let[t,n]=iv(r);return e(t),n.result()}function dr(r){return r instanceof jl||r instanceof ql||r instanceof Yf?r._current:r!==null&&typeof r=="object"?r[g1]:r}var Pi;(i=>{function r(s,o){if(o.length===s.length)for(var a=0;a<s.length;){if(s[a]!==o[a])return!1;a+=1}else return!1;return!0}i.equal=r;function e(s,o,a){let l=n(a,s);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...o};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return o}i.removeOverridden=e;function t(s,o){if((s instanceof Bt||s instanceof jl)&&typeof o=="string")return s.data(o);if((s instanceof Ve||s instanceof ql)&&typeof o=="string")return s.data(o);if(typeof o=="number"&&Array.isArray(s))return s[o];if(typeof o=="string"&&typeof s=="object")return s[o]}i.zoomOnce=t;function n(s,o,a=0){for(;a<o.length&&s!==void 0;)s=t(s,o[a]),a+=1;return s}i.zoom=n})(Pi||(Pi={}));var Kf=class{},Ku=class extends Kf{constructor(t){super();this.id=t}},Ju=class extends Kf{constructor(t){super();this.data=t}};var av;try{av=new TextDecoder}catch{}var Ie,no,Z=0;var T1=[],lv=T1,cv=0,fr={},xt,to,jr=0,Di=0,Lr,ys,ar=[],Et,v1={useRecords:!1,mapsAsObjects:!0},$u=class{},hv=new $u;hv.name="MessagePack 0xC1";var Xl=!1,Ii=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Ie)return D1(()=>($f(),this?this.unpack(e,t):Ii.prototype.unpack.call(v1,e,t)));no=t>-1?t:e.length,Z=0,cv=0,Di=0,to=null,lv=T1,Lr=null,Ie=e;try{Et=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw Ie=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Ii){if(fr=this,this.structures)return xt=this.structures,Jf();(!xt||xt.length>0)&&(xt=[])}else fr=v1,(!xt||xt.length>0)&&(xt=[]);return Jf()}unpackMultiple(e,t){let n,i=0;try{Xl=!0;let s=e.length,o=this?this.unpack(e,s):np.unpack(e,s);if(t){for(t(o);Z<s;)if(i=Z,t(Jf())===!1)return}else{for(n=[o];Z<s;)i=Z,n.push(Jf());return n}}catch(s){throw s.lastPosition=i,s.values=n,s}finally{Xl=!1,$f()}}_mergeStructures(e,t){e=e||[];for(let n=0,i=e.length;n<i;n++){let s=e[n];s&&(s.isShared=!0,n>=32&&(s.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let i=e[n],s=t[n];s&&(i&&((e.restoreStructures||(e.restoreStructures=[]))[n]=i),e[n]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function Jf(){try{if(!fr.trusted&&!Xl){let e=xt.sharedLength||0;e<xt.length&&(xt.length=e)}let r=Kt();if(Z==no)xt.restoreStructures&&x1(),xt=null,Ie=null,ys&&(ys=null);else if(Z>no){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!Xl)throw new Error("Data read, but end of buffer not reached");return r}catch(r){throw xt.restoreStructures&&x1(),$f(),(r instanceof RangeError||r.message.startsWith("Unexpected end of buffer"))&&(r.incomplete=!0),r}}function x1(){for(let r in xt.restoreStructures)xt[r]=xt.restoreStructures[r];xt.restoreStructures=null}function Kt(){let r=Ie[Z++];if(r<160)if(r<128){if(r<64)return r;{let e=xt[r&63]||fr.getStructures&&M1()[r&63];return e?(e.read||(e.read=dv(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,fr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[C1()]=Kt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Kt(),Kt());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Kt();return e}else if(r<192){let e=r-160;if(Di>=Z)return to.slice(Z-jr,(Z+=e)-jr);if(Di==0&&no<140){let t=e<16?fv(e):E1(e);if(t!=null)return t}return uv(e)}else{let e;switch(r){case 192:return null;case 193:return Lr?(e=Kt(),e>0?Lr[1].slice(Lr.position1,Lr.position1+=e):Lr[0].slice(Lr.position0,Lr.position0-=e)):hv;case 194:return!1;case 195:return!0;case 196:return ov(Ie[Z++]);case 197:return e=Et.getUint16(Z),Z+=2,ov(e);case 198:return e=Et.getUint32(Z),Z+=4,ov(e);case 199:return ta(Ie[Z++]);case 200:return e=Et.getUint16(Z),Z+=2,ta(e);case 201:return e=Et.getUint32(Z),Z+=4,ta(e);case 202:if(e=Et.getFloat32(Z),fr.useFloat32>2){let t=tp[(Ie[Z]&127)<<1|Ie[Z+1]>>7];return Z+=4,(t*e+(e>0?.5:-.5)>>0)/t}return Z+=4,e;case 203:return e=Et.getFloat64(Z),Z+=8,e;case 204:return Ie[Z++];case 205:return e=Et.getUint16(Z),Z+=2,e;case 206:return e=Et.getUint32(Z),Z+=4,e;case 207:return fr.int64AsNumber?(e=Et.getUint32(Z)*4294967296,e+=Et.getUint32(Z+4)):e=Et.getBigUint64(Z),Z+=8,e;case 208:return Et.getInt8(Z++);case 209:return e=Et.getInt16(Z),Z+=2,e;case 210:return e=Et.getInt32(Z),Z+=4,e;case 211:return fr.int64AsNumber?(e=Et.getInt32(Z)*4294967296,e+=Et.getUint32(Z+4)):e=Et.getBigInt64(Z),Z+=8,e;case 212:if(e=Ie[Z++],e==114)return _1(Ie[Z++]&63);{let t=ar[e];if(t)return t.read?(Z++,t.read(Kt())):t.noBuffer?(Z++,t()):t(Ie.subarray(Z,++Z));throw new Error("Unknown extension "+e)}case 213:return e=Ie[Z],e==114?(Z++,_1(Ie[Z++]&63,Ie[Z++])):ta(2);case 214:return ta(4);case 215:return ta(8);case 216:return ta(16);case 217:return e=Ie[Z++],Di>=Z?to.slice(Z-jr,(Z+=e)-jr):tG(e);case 218:return e=Et.getUint16(Z),Z+=2,Di>=Z?to.slice(Z-jr,(Z+=e)-jr):nG(e);case 219:return e=Et.getUint32(Z),Z+=4,Di>=Z?to.slice(Z-jr,(Z+=e)-jr):rG(e);case 220:return e=Et.getUint16(Z),Z+=2,w1(e);case 221:return e=Et.getUint32(Z),Z+=4,w1(e);case 222:return e=Et.getUint16(Z),Z+=2,S1(e);case 223:return e=Et.getUint32(Z),Z+=4,S1(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}var eG=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function dv(r,e){function t(){if(t.count++>2){let i=r.read=new Function("r","return function(){return {"+r.map(s=>eG.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Kt);return r.highByte===0&&(r.read=b1(e,r.read)),i()}let n={};for(let i=0,s=r.length;i<s;i++){let o=r[i];n[o]=Kt()}return n}return t.count=0,r.highByte===0?b1(e,t):t}var b1=(r,e)=>function(){let t=Ie[Z++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),i=xt[n]||M1()[n];if(!i)throw new Error("Record id is not defined for "+n);return i.read||(i.read=dv(i,r)),i.read()};function M1(){let r=D1(()=>(Ie=null,fr.getStructures()));return xt=fr._mergeStructures(r,xt)}var uv=ep,tG=ep,nG=ep,rG=ep;function ep(r){let e;if(r<16&&(e=fv(r)))return e;if(r>64&&av)return av.decode(Ie.subarray(Z,Z+=r));let t=Z+r,n=[];for(e="";Z<t;){let i=Ie[Z++];if((i&128)===0)n.push(i);else if((i&224)===192){let s=Ie[Z++]&63;n.push((i&31)<<6|s)}else if((i&240)===224){let s=Ie[Z++]&63,o=Ie[Z++]&63;n.push((i&31)<<12|s<<6|o)}else if((i&248)===240){let s=Ie[Z++]&63,o=Ie[Z++]&63,a=Ie[Z++]&63,l=(i&7)<<18|s<<12|o<<6|a;l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|l&1023),n.push(l)}else n.push(i);n.length>=4096&&(e+=Dn.apply(String,n),n.length=0)}return n.length>0&&(e+=Dn.apply(String,n)),e}function w1(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Kt();return e}function S1(r){if(fr.mapsAsObjects){let e={};for(let t=0;t<r;t++)e[C1()]=Kt();return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Kt(),Kt());return e}}var Dn=String.fromCharCode;function E1(r){let e=Z,t=new Array(r);for(let n=0;n<r;n++){let i=Ie[Z++];if((i&128)>0){Z=e;return}t[n]=i}return Dn.apply(String,t)}function fv(r){if(r<4)if(r<2){if(r===0)return"";{let e=Ie[Z++];if((e&128)>1){Z-=1;return}return Dn(e)}}else{let e=Ie[Z++],t=Ie[Z++];if((e&128)>0||(t&128)>0){Z-=2;return}if(r<3)return Dn(e,t);let n=Ie[Z++];if((n&128)>0){Z-=3;return}return Dn(e,t,n)}else{let e=Ie[Z++],t=Ie[Z++],n=Ie[Z++],i=Ie[Z++];if((e&128)>0||(t&128)>0||(n&128)>0||(i&128)>0){Z-=4;return}if(r<6){if(r===4)return Dn(e,t,n,i);{let s=Ie[Z++];if((s&128)>0){Z-=5;return}return Dn(e,t,n,i,s)}}else if(r<8){let s=Ie[Z++],o=Ie[Z++];if((s&128)>0||(o&128)>0){Z-=6;return}if(r<7)return Dn(e,t,n,i,s,o);let a=Ie[Z++];if((a&128)>0){Z-=7;return}return Dn(e,t,n,i,s,o,a)}else{let s=Ie[Z++],o=Ie[Z++],a=Ie[Z++],l=Ie[Z++];if((s&128)>0||(o&128)>0||(a&128)>0||(l&128)>0){Z-=8;return}if(r<10){if(r===8)return Dn(e,t,n,i,s,o,a,l);{let u=Ie[Z++];if((u&128)>0){Z-=9;return}return Dn(e,t,n,i,s,o,a,l,u)}}else if(r<12){let u=Ie[Z++],c=Ie[Z++];if((u&128)>0||(c&128)>0){Z-=10;return}if(r<11)return Dn(e,t,n,i,s,o,a,l,u,c);let h=Ie[Z++];if((h&128)>0){Z-=11;return}return Dn(e,t,n,i,s,o,a,l,u,c,h)}else{let u=Ie[Z++],c=Ie[Z++],h=Ie[Z++],d=Ie[Z++];if((u&128)>0||(c&128)>0||(h&128)>0||(d&128)>0){Z-=12;return}if(r<14){if(r===12)return Dn(e,t,n,i,s,o,a,l,u,c,h,d);{let f=Ie[Z++];if((f&128)>0){Z-=13;return}return Dn(e,t,n,i,s,o,a,l,u,c,h,d,f)}}else{let f=Ie[Z++],m=Ie[Z++];if((f&128)>0||(m&128)>0){Z-=14;return}if(r<15)return Dn(e,t,n,i,s,o,a,l,u,c,h,d,f,m);let p=Ie[Z++];if((p&128)>0){Z-=15;return}return Dn(e,t,n,i,s,o,a,l,u,c,h,d,f,m,p)}}}}}function ov(r){return fr.copyBuffers?Uint8Array.prototype.slice.call(Ie,Z,Z+=r):Ie.subarray(Z,Z+=r)}function ta(r){let e=Ie[Z++];if(ar[e])return ar[e](Ie.subarray(Z,Z+=r));throw new Error("Unknown extension type "+e)}var A1=new Array(4096);function C1(){let r=Ie[Z++];if(r>=160&&r<192){if(r=r-160,Di>=Z)return to.slice(Z-jr,(Z+=r)-jr);if(!(Di==0&&no<180))return uv(r)}else return Z--,Kt();let e=(r<<5^(r>1?Et.getUint16(Z):r>0?Ie[Z]:0))&4095,t=A1[e],n=Z,i=Z+r-3,s,o=0;if(t&&t.bytes==r){for(;n<i;){if(s=Et.getUint32(n),s!=t[o++]){n=1879048192;break}n+=4}for(i+=3;n<i;)if(s=Ie[n++],s!=t[o++]){n=1879048192;break}if(n===i)return Z=n,t.string;i-=3,n=Z}for(t=[],A1[e]=t,t.bytes=r;n<i;)s=Et.getUint32(n),t.push(s),n+=4;for(i+=3;n<i;)s=Ie[n++],t.push(s);let a=r<16?fv(r):E1(r);return a!=null?t.string=a:t.string=uv(r)}var _1=(r,e)=>{var t=Kt();let n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let i=xt[r];return i&&i.isShared&&((xt.restoreStructures||(xt.restoreStructures=[]))[r]=i),xt[r]=t,t.read=dv(t,n),t.read()},P1=typeof self=="object"?self:global;ar[0]=()=>{};ar[0].noBuffer=!0;ar[101]=()=>{let r=Kt();return(P1[r[0]]||Error)(r[1])};ar[105]=r=>{let e=Et.getUint32(Z-4);ys||(ys=new Map);let t=Ie[Z],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let i={target:n};ys.set(e,i);let s=Kt();return i.used?Object.assign(n,s):(i.target=s,s)};ar[112]=r=>{let e=Et.getUint32(Z-4),t=ys.get(e);return t.used=!0,t.target};ar[115]=()=>new Set(Kt());var pv=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");ar[116]=r=>{let e=r[0],t=pv[e];if(!t)throw new Error("Could not find typed array for code "+e);return new P1[t](Uint8Array.prototype.slice.call(r,1).buffer)};ar[120]=()=>{let r=Kt();return new RegExp(r[0],r[1])};ar[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=Z;Z+=e-4,Lr=[Kt(),Kt()],Lr.position0=0,Lr.position1=0;let n=Z;Z=t;try{return Kt()}finally{Z=n}};ar[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function D1(r){let e=no,t=Z,n=cv,i=jr,s=Di,o=to,a=lv,l=ys,u=Lr,c=new Uint8Array(Ie.slice(0,no)),h=xt,d=xt.slice(0,xt.length),f=fr,m=Xl,p=r();return no=e,Z=t,cv=n,jr=i,Di=s,to=o,lv=a,ys=l,Lr=u,Ie=c,Xl=m,xt=h,xt.splice(0,xt.length,...d),fr=f,Et=new DataView(Ie.buffer,Ie.byteOffset,Ie.byteLength),p}function $f(){Ie=null,ys=null,xt=null}function I1(r){r.unpack?ar[r.type]=r.unpack:ar[r.type]=r}var tp=new Array(147);for(let r=0;r<256;r++)tp[r]=+("1e"+Math.floor(45.15-r*.30103));var np=new Ii({useRecords:!1}),iG=np.unpack,sG=np.unpackMultiple,oG=np.unpack,rp={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},aG=new Float32Array(1),VQ=new Uint8Array(aG.buffer,0,4);var ip;try{ip=new TextEncoder}catch{}var sp,gv,op=typeof Buffer<"u",mv=op?Buffer.allocUnsafeSlow:Uint8Array,N1=op?Buffer:Uint8Array,L1=op?4294967296:2144337920,ae,sn,ee=0,Li,Oi=null,lG=/[\u0080-\uFFFF]/,eh=Symbol("record-id"),na=class extends Ii{constructor(e){super(e),this.offset=0;let t,n,i,s,o,a,l=0,u=N1.prototype.utf8Write?function(x,T,E){return ae.utf8Write(x,T,E)}:ip&&ip.encodeInto?function(x,T){return ip.encodeInto(x,ae.subarray(T)).written}:!1,c=this;e||(e={});let h=e&&e.sequential,d=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=d?32:64),h&&!e.saveStructures&&(this.structures=[]);let p=f>32||m+f>64,g=f+64,v=f+m+64;if(v>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let y=[],b=0,w=0;this.pack=this.encode=function(x,T){if(ae||(ae=new mv(8192),sn=new DataView(ae.buffer,0,8192),ee=0),Li=ae.length-10,Li-ee<2048?(ae=new mv(ae.length),sn=new DataView(ae.buffer,0,ae.length),Li=ae.length-10,ee=0):ee=ee+7&2147483640,n=ee,a=c.structuredClone?new Map:null,c.bundleStrings?(Oi=["",""],ae[ee++]=214,ae[ee++]=98,Oi.position=ee-n,ee+=4):Oi=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let E=i.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let C=0;C<E;C++){let P=i[C];if(!P)continue;let O,D=i.transitions;for(let N=0,F=P.length;N<F;N++){let z=P[N];O=D[z],O||(O=D[z]=Object.create(null)),D=O}D[eh]=C+64}l=E}h||(i.nextId=E+64)}s&&(s=!1),o=i||[];try{if(S(x),Oi){sn.setUint32(Oi.position+n,ee-Oi.position-n);let E=Oi;Oi=null,S(E[0]),S(E[1])}if(c.offset=ee,a&&a.idsToInsert){ee+=a.idsToInsert.length*6,ee>Li&&M(ee),c.offset=ee;let E=uG(ae.subarray(n,ee),a.idsToInsert);return a=null,E}return T&F1?(ae.start=n,ae.end=ee,ae):ae.subarray(n,ee)}finally{if(i){if(w<10&&w++,b>1e4)i.transitions=null,w=0,b=0,y.length>0&&(y=[]);else if(y.length>0&&!h){for(let E=0,C=y.length;E<C;E++)y[E][eh]=0;y=[]}if(s&&c.saveStructures){let E=i.sharedLength||f;i.length>E&&(i=i.slice(0,E));let C=ae.subarray(n,ee);return c.saveStructures(i,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=E,C)}}T&yG&&(ee=n)}};let S=x=>{ee>Li&&(ae=M(ee));var T=typeof x,E;if(T==="string"){let C=x.length;if(Oi&&C>=8&&C<4096){let D=lG.test(x);Oi[D?0:1]+=x,ae[ee++]=193,S(D?-C:C);return}let P;C<32?P=1:C<256?P=2:C<65536?P=3:P=5;let O=C*3;if(ee+O>Li&&(ae=M(ee+O)),C<64||!u){let D,N,F,z=ee+P;for(D=0;D<C;D++)N=x.charCodeAt(D),N<128?ae[z++]=N:N<2048?(ae[z++]=N>>6|192,ae[z++]=N&63|128):(N&64512)===55296&&((F=x.charCodeAt(D+1))&64512)===56320?(N=65536+((N&1023)<<10)+(F&1023),D++,ae[z++]=N>>18|240,ae[z++]=N>>12&63|128,ae[z++]=N>>6&63|128,ae[z++]=N&63|128):(ae[z++]=N>>12|224,ae[z++]=N>>6&63|128,ae[z++]=N&63|128);E=z-ee-P}else E=u(x,ee+P,O);E<32?ae[ee++]=160|E:E<256?(P<2&&ae.copyWithin(ee+2,ee+1,ee+1+E),ae[ee++]=217,ae[ee++]=E):E<65536?(P<3&&ae.copyWithin(ee+3,ee+2,ee+2+E),ae[ee++]=218,ae[ee++]=E>>8,ae[ee++]=E&255):(P<5&&ae.copyWithin(ee+5,ee+3,ee+3+E),ae[ee++]=219,sn.setUint32(ee,E),ee+=4),ee+=E}else if(T==="number")if(x>>>0===x)x<64?ae[ee++]=x:x<256?(ae[ee++]=204,ae[ee++]=x):x<65536?(ae[ee++]=205,ae[ee++]=x>>8,ae[ee++]=x&255):(ae[ee++]=206,sn.setUint32(ee,x),ee+=4);else if(x>>0===x)x>=-32?ae[ee++]=256+x:x>=-128?(ae[ee++]=208,ae[ee++]=x+256):x>=-32768?(ae[ee++]=209,sn.setInt16(ee,x),ee+=2):(ae[ee++]=210,sn.setInt32(ee,x),ee+=4);else{let C;if((C=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){ae[ee++]=202,sn.setFloat32(ee,x);let P;if(C<4||(P=x*tp[(ae[ee]&127)<<1|ae[ee+1]>>7])>>0===P){ee+=4;return}else ee--}ae[ee++]=203,sn.setFloat64(ee,x),ee+=8}else if(T==="object")if(!x)ae[ee++]=192;else{if(a){let P=a.get(x);if(P){if(!P.id){let O=a.idsToInsert||(a.idsToInsert=[]);P.id=O.push(P)}ae[ee++]=214,ae[ee++]=112,sn.setUint32(ee,P.id),ee+=4;return}else a.set(x,{offset:ee-n})}let C=x.constructor;if(C===Object)_(x,!0);else if(C===Array){E=x.length,E<16?ae[ee++]=144|E:E<65536?(ae[ee++]=220,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=221,sn.setUint32(ee,E),ee+=4);for(let P=0;P<E;P++)S(x[P])}else if(C===Map){E=x.size,E<16?ae[ee++]=128|E:E<65536?(ae[ee++]=222,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=223,sn.setUint32(ee,E),ee+=4);for(let[P,O]of x)S(P),S(O)}else{for(let P=0,O=sp.length;P<O;P++){let D=gv[P];if(x instanceof D){let N=sp[P];if(N.write){N.type&&(ae[ee++]=212,ae[ee++]=N.type,ae[ee++]=0),S(N.write.call(this,x));return}let F=ae,z=sn,Y=ee;ae=null;let U;try{U=N.pack.call(this,x,G=>(ae=F,F=null,ee+=G,ee>Li&&M(ee),{target:ae,targetView:sn,position:ee-G}),S)}finally{F&&(ae=F,sn=z,ee=Y,Li=ae.length-10)}U&&(U.length+ee>Li&&M(U.length+ee),ee=cG(U,ae,ee,N.type));return}}_(x,!x.hasOwnProperty)}}else if(T==="boolean")ae[ee++]=x?195:194;else if(T==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))ae[ee++]=211,sn.setBigInt64(ee,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)ae[ee++]=207,sn.setBigUint64(ee,x);else if(this.largeBigIntToFloat)ae[ee++]=203,sn.setFloat64(ee,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");ee+=8}else if(T==="undefined")this.encodeUndefinedAsNil?ae[ee++]=192:(ae[ee++]=212,ae[ee++]=0,ae[ee++]=0);else if(T==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+T)},_=this.useRecords===!1?this.variableMapSize?x=>{let T=Object.keys(x),E=T.length;E<16?ae[ee++]=128|E:E<65536?(ae[ee++]=222,ae[ee++]=E>>8,ae[ee++]=E&255):(ae[ee++]=223,sn.setUint32(ee,E),ee+=4);let C;for(let P=0;P<E;P++)S(C=T[P]),S(x[C])}:(x,T)=>{ae[ee++]=222;let E=ee-n;ee+=2;let C=0;for(let P in x)(T||x.hasOwnProperty(P))&&(S(P),S(x[P]),C++);ae[E+++n]=C>>8,ae[E+n]=C&255}:x=>{let T=Object.keys(x),E,C=o.transitions||(o.transitions=Object.create(null)),P=0;for(let D=0,N=T.length;D<N;D++){let F=T[D];E=C[F],E||(E=C[F]=Object.create(null),P++),C=E}let O=C[eh];if(O)O>=96&&p?(ae[ee++]=((O-=96)&31)+96,ae[ee++]=O>>5):ae[ee++]=O;else{O=o.nextId,O||(O=64),O<g&&this.shouldShareStructure&&!this.shouldShareStructure(T)?(O=o.nextOwnId,O<v||(O=g),o.nextOwnId=O+1):(O>=v&&(O=g),o.nextId=O+1);let D=T.highByte=O>=96&&p?O-96>>5:-1;C[eh]=O,o[O-64]=T,O<g?(T.isShared=!0,o.sharedLength=O-63,s=!0,D>=0?(ae[ee++]=(O&31)+96,ae[ee++]=D):ae[ee++]=O):(D>=0?(ae[ee++]=213,ae[ee++]=114,ae[ee++]=(O&31)+96,ae[ee++]=D):(ae[ee++]=212,ae[ee++]=114,ae[ee++]=O),P&&(b+=w*P),y.length>=m&&(y.shift()[eh]=0),y.push(C),S(T))}for(let D=0,N=T.length;D<N;D++)S(x[T[D]])},M=x=>{let T;if(x>16777216){if(x-n>L1)throw new Error("Packed buffer would be larger than maximum buffer size");T=Math.min(L1,Math.round(Math.max((x-n)*(x>67108864?1.25:2),4194304)/4096)*4096)}else T=(Math.max(x-n<<2,ae.length-1)>>12)+1<<12;let E=new mv(T);return sn=new DataView(E.buffer,0,T),ae.copy?ae.copy(E,0,n,x):E.set(ae.slice(n,x)),ee-=n,n=0,Li=E.length-10,ae=E}}useBuffer(e){ae=e,sn=new DataView(ae.buffer,ae.byteOffset,ae.byteLength),ee=0}};gv=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,$u];sp=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:i,targetView:s,position:o}=e(6);i[o++]=214,i[o++]=255,s.setUint32(o,n)}else if(n>0&&n<17179869184){let{target:i,targetView:s,position:o}=e(10);i[o++]=215,i[o++]=255,s.setUint32(o,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),s.setUint32(o+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:i,targetView:s,position:o}=e(3);i[o++]=212,i[o++]=255,i[o++]=255}else{let{target:i,targetView:s,position:o}=e(15);i[o++]=199,i[o++]=12,i[o++]=255,s.setUint32(o,r.getMilliseconds()*1e6),s.setBigInt64(o+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){let n=Array.from(r),{target:i,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(i[s++]=212,i[s++]=115,i[s++]=0),t(n)}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=101,n[i++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:i}=e(this.structuredClone?3:0);this.structuredClone&&(n[i++]=212,n[i++]=120,n[i++]=0),t([r.source,r.flags])}},{pack(r,e){this.structuredClone?O1(r,16,e):R1(op?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==N1&&this.structuredClone?O1(r,pv.indexOf(t.name),e):R1(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function O1(r,e,t,n){let i=r.byteLength;if(i+1<256){var{target:s,position:o}=t(4+i);s[o++]=199,s[o++]=i+1}else if(i+1<65536){var{target:s,position:o}=t(5+i);s[o++]=200,s[o++]=i+1>>8,s[o++]=i+1&255}else{var{target:s,position:o,targetView:a}=t(7+i);s[o++]=201,a.setUint32(o,i+1),o+=4}s[o++]=116,s[o++]=e,s.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),o)}function R1(r,e){let t=r.byteLength;var n,i;if(t<256){var{target:n,position:i}=e(t+2);n[i++]=196,n[i++]=t}else if(t<65536){var{target:n,position:i}=e(t+3);n[i++]=197,n[i++]=t>>8,n[i++]=t&255}else{var{target:n,position:i,targetView:s}=e(t+5);n[i++]=198,s.setUint32(i,t),i+=4}n.set(r,i)}function cG(r,e,t,n){let i=r.length;switch(i){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:i<256?(e[t++]=199,e[t++]=i):i<65536?(e[t++]=200,e[t++]=i>>8,e[t++]=i&255):(e[t++]=201,e[t++]=i>>24,e[t++]=i>>16&255,e[t++]=i>>8&255,e[t++]=i&255)}return e[t++]=n,e.set(r,t),t+=i,t}function uG(r,e){let t,n=e.length*6,i=r.length-n;for(e.sort((s,o)=>s.offset>o.offset?1:-1);t=e.pop();){let s=t.offset,o=t.id;r.copyWithin(s+n,s,i),n-=6;let a=s+n;r[a++]=214,r[a++]=105,r[a++]=o>>24,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=o&255,i=s}return r}function ro(r){if(r.Class){if(!r.pack&&!r.write)throw new Error("Extension has no pack or write function");if(r.pack&&!r.type)throw new Error("Extension has no type (numeric code to identify the extension)");gv.unshift(r.Class),sp.unshift(r)}I1(r)}var B1=new na({useRecords:!1}),hG=B1.pack,dG=B1.pack;var{NEVER:fG,ALWAYS:pG,DECIMAL_ROUND:mG,DECIMAL_FIT:gG}=rp,F1=512,yG=1024;var U1=new na({structuredClone:!0});ro({Class:zt.prototype.constructor,type:1,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,zt.prototype),r}});ro({Class:Ve.prototype.constructor,type:2,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Ve.prototype),r}});ro({Class:Bt.prototype.constructor,type:3,write(r){return[...r]},read(r){return Object.setPrototypeOf(r,Bt.prototype),r}});ro({Class:Ku.prototype.constructor,type:4,write(r){return r.id},read(r){return new Ku(r)}});ro({Class:Ju.prototype.constructor,type:5,write(r){return r.data},read(r){return new Ju(r)}});ro({Class:Ir.prototype.constructor,type:6,write(r){return{...r}},read(r){return Object.setPrototypeOf(r,Ir.prototype),r}});function vG(r){var e=0;if(r.length===0)return e;for(let t=0;t<r.length;t++){let n=r[t];e=(e<<5)-e+n,e=e&e}return e}function yv(r){if($o(r))return r;if(Array.isArray(r))return r.map(yv);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=yv(r[t]);return Object.setPrototypeOf(e,Object.getPrototypeOf(r)),e}else return r}var ap;(n=>{function r(i){return U1.pack(i)}n.serialize=r;function e(i){return U1.unpack(i)}n.deserialize=e;function t(i){return vG(r(yv(i))).toString()}n.checksum=t})(ap||(ap={}));var cp={["LookAt"]:[],["Follow"]:[],["MouseHover"]:["Transition"],["Scroll"]:["Transition"],["Start"]:["Transition","Audio"],["Conditional"]:["Transition","Audio"],["MouseDown"]:["Transition","Audio","Link"],["MouseUp"]:["Transition","Audio","Link"],["KeyDown"]:["Transition","Audio","Link"],["KeyUp"]:["Transition","Audio","Link"],["GameControl"]:["Transition","Audio"],["Collision"]:["Transition","Audio"]},G1;(t=>{function r(n){return n.type==="MouseDown"||n.type==="MouseUp"||n.type==="KeyDown"||n.type==="KeyUp"}t.is=r;function e(n){return n==="MouseDown"||n==="MouseUp"?{type:n,toggle:!1,actions:new Ve}:{type:n,key:void 0,toggle:!1,actions:new Ve}}t.defaultData=e})(G1||(G1={}));var lp;(t=>{function r(n){return{type:"Property",value:[n??null,"position","x"]}}t.propertyDefaultData=r,t.valueDefaultData={type:"Literal",value:0}})(lp||(lp={}));var vv;(n=>{function r(i){return{type:"Comparison",operator:"==",lOperand:lp.propertyDefaultData(i),rOperand:{...lp.valueDefaultData}}}n.comparisonDefaultData=r;function e(i){return{type:"Distance",toObject:i??null,fromObject:i??null,distance:200}}n.distanceDefaultData=e;function t(i,s){return{type:"State",object:i??null,state:s??null}}n.stateDefaultData=t})(vv||(vv={}));var z1;(t=>{function r(n){return n.type==="Conditional"}t.is=r;function e(n){return{type:"Conditional",inActions:new Ve,outActions:new Ve,condition:vv.distanceDefaultData(n)}}t.defaultData=e})(z1||(z1={}));var k1;(e=>e.defaultData={type:"Follow"})(k1||(k1={}));var V1;(e=>{function r(){return{type:"LookAt",distance:1e3}}e.defaultData=r})(V1||(V1={}));var H1;(t=>{function r(n){return n.type==="MouseHover"}t.is=r;function e(){return{type:"MouseHover",actions:new Ve}}t.defaultData=e})(H1||(H1={}));var W1;(t=>{function r(n){return n.type==="Scroll"}t.is=r;function e(){return{type:"Scroll",steps:100,actions:new Ve}}t.defaultData=e})(W1||(W1={}));var j1;(t=>{function r(n){return n.type==="Start"}t.is=r;function e(){return{type:"Start",actions:new Ve}}t.defaultData=e})(j1||(j1={}));var q1;(t=>{function r(n){return n.type==="Collision"}t.is=r;function e(){return{type:"Collision",toggle:!1,target:"character",actions:new Ve}}t.defaultData=e})(q1||(q1={}));var ra;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s]}t.lerp=e})(ra||(ra={}));var Yl;(i=>{function r(s,o){return s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]}i.isEqual=r;function e(s,o){return[s[0]+o[0],s[1]+o[1],s[2]+o[2]]}i.add=e;function t(s,o){return[s[0]-o[0],s[1]-o[1],s[2]-o[2]]}i.sub=t;function n(s,o,a){return[s[0]+(o[0]-s[0])*a,s[1]+(o[1]-s[1])*a,s[2]+(o[2]-s[2])*a]}i.lerp=n})(Yl||(Yl={}));var th;(t=>{function r(n,i){return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]}t.isEqual=r;function e(n,i,s){return[n[0]+(i[0]-n[0])*s,n[1]+(i[1]-n[1])*s,n[2]+(i[2]-n[2])*s,n[3]+(i[3]-n[3])*s]}t.lerp=e})(th||(th={}));var io;(i=>{i.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,o){for(let a=0;a<16;a++)if(s[a]!==o[a])return!1;return!0}i.isEqual=e;function t(s){return s??i.identity}i.simplify=t;function n(s,o){let a=o.slice(0);for(var l=0,u=o.length;l<u;l+=3){let c=s[3]*o[l]+s[7]*o[l+1]+s[11]*o[l+2]+s[15];a[l]=(s[0]*o[l]+s[4]*o[l+1]+s[8]*o[l+2]+s[12])/c,a[l+1]=(s[1]*o[l]+s[5]*o[l+1]+s[9]*o[l+2]+s[13])/c,a[l+2]=(s[2]*o[l]+s[6]*o[l+1]+s[10]*o[l+2]+s[14])/c}return a}i.applyMatrix4=n})(io||(io={}));var Xn;(l=>{l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function n(u){return{r:Math.round(u.r*255),g:Math.round(u.g*255),b:Math.round(u.b*255),a:1}}l.toRgb255a1=n;function i(u){return{r:u.r,g:u.g,b:u.b}}l.clone=i;function s(u){return u=Math.floor(u),{r:(u>>16&255)/255,g:(u>>8&255)/255,b:(u&255)/255}}l.fromHex=s;function o(u,c){return u.r===c.r&&u.g===c.g&&u.b===c.b}l.equals=o;function a(u,c,h){return{r:u.r+(c.r-u.r)*h,g:u.g+(c.g-u.g)*h,b:u.b+(c.b-u.b)*h}}l.lerp=a})(Xn||(Xn={}));var pr;(a=>{a.white={...Xn.white,a:1},a.transparent={...Xn.white,a:0};function t(l){return{r:l[0],g:l[1],b:l[2],a:l[3]}}a.from0to1=t;function n(l,u){return{...Xn.fromHex(l),a:u}}a.fromHexAndA=n;function i(l){return{r:Math.round(l.r*255),g:Math.round(l.g*255),b:Math.round(l.b*255),a:l.a}}a.toRgb255a1=i;function s(l,u){return Xn.equals(l,u)&&l.a===u.a}a.equals=s;function o(l,u,c){return{r:l.r+(u.r-l.r)*c,g:l.g+(u.g-l.g)*c,b:l.b+(u.b-l.b)*c,a:l.a+(u.a-l.a)*c}}a.lerp=o})(pr||(pr={}));var up;(e=>e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(up||(up={}));var X1;(e=>e.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(X1||(X1={}));var Y1;(e=>e.defaultData={control1:[.5,.05],control2:[.1,.3]})(Y1||(Y1={}));var Ri;(t=>{t.all=["PerspectiveCamera","OrthographicCamera"];function e(n){return t.all.includes(n)}t.is=e})(Ri||(Ri={}));var ia;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function n(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}i.getZoom=n})(ia||(ia={}));var hp;(e=>{function r(t,n=.1){return{type:"radial",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]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[t[0]+t[0]*n,0,0]},grid:{count:[2,2,2],size:t.map(i=>i*(1+n)),useCenter:!0}}}e.defaultData=r})(hp||(hp={}));var sa;(t=>{let r={opacity:1,blendFunction:13,enabled:!1};t.defaultData={enabled:!1,pixelation:{...r,blendFunction:16,granularity:15},bloom:{...r,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...r,offset:[2,2]},vignette:{...r,darkness:1,offset:0},hueSaturation:{...r,hue:3,saturation:0},brightnessContrast:{...r,brightness:.25,contrast:0},depthOfField:{...r,focalLength:2,focusDistance:2,bokehScale:2},noise:{...r,blendFunction:16}}})(sa||(sa={}));var dp;(t=>{t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(n){return t.all.includes(n)}t.is=e})(dp||(dp={}));var fp;(t=>{function r(n){return e(n)}t.defaultData=r;function e(n){if(n==="PointLight")return{type:n,color:pr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:1e5};if(n==="SpotLight")return{type:n,color:pr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,shadowResolution:1024,shadowRadius:1};if(n==="DirectionalLight")return{type:n,color:pr.white,intensity:1,shadows:!0,size:1e3,depth:1e5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(fp||(fp={}));var xv;(t=>{t.defaultData={castShadow:!0,receiveShadow:!0};function e(n,i){return n.castShadow===i.castShadow&&n.receiveShadow===i.receiveShadow}t.equals=e})(xv||(xv={}));var bv;(t=>{t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(n,i){return n.flatShading===i.flatShading&&n.side===i.side&&n.wireframe===i.wireframe}t.equals=e})(bv||(bv={}));var pp;(e=>e.defaultData={...bv.defaultData,...xv.defaultData,cloner:null,booleanExclude:null})(pp||(pp={}));var mp=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],Q1=["wrapping","image"],so;(n=>{function r(i,s){return i==="light"&&s?e(s):t(i)}n.defaultData=r;function e(i){switch(i){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"x",side:2,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Xn.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,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{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,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{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Xn.fromHex(6710886),a:1},colorB:{...Xn.fromHex(6710886),a:1},colorC:{...Xn.fromHex(16777215),a:1},colorD:{...Xn.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:pr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{type:"toon",alpha:1,visible:!0,mode:0,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:pr.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{type:"outline",alpha:1,visible:!0,mode:0,outlineColor:pr.fromHexAndA(0,1),contourColor:pr.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{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(so||(so={}));var Fn;(a=>{function r(l){return!l.layers.some(c=>{if(c.data.type==="texture"&&c.data.projection!==0||c.data.type==="depth"&&!c.data.isWorldSpace||c.data.type==="noise"||c.data.type==="displace")return!0})&&!t(l)}a.isMergable=r;function e(l){let u="";return l.layers.forEach(c=>{Object.entries(c.data).forEach(([h,d])=>{u+=`${h}${d}`,Array.isArray(d)?d.forEach(f=>u+=`${f}`):typeof d=="object"?Object.values(d).forEach(f=>{typeof f=="number"?u+=`${f.toFixed(4)}`:u+=`${f}`}):u+=`${d}`})}),u}a.getHash=e;function t(l){let u=0;for(let c of l.layers)"alpha"in c.data&&c.data.type!=="light"&&c.data.type!=="fresnel"&&(u+=(1-u)*c.data.alpha);return u<1}a.isTransparent=t;function n(){return{layers:new Ve}}a.defaultEmptyData=n;function i(l="layer1",u="layer2"){return s("phong",l,u)}a.defaultData=i;function s(l,u="layer1",c="layer2"){let h=new Ve;return h.push({fi:0,data:so.defaultData("light",l),id:u}),h.push({fi:1,data:so.defaultData("color"),id:c}),{layers:h}}a.defaultTwoLayerData=s;function o(l,u="basic",c="layer1",h="layer2"){let d=so.defaultData("texture");Object.assign(d.texture,{image:l});let f=new Ve;return f.push({fi:0,data:d,id:c}),f.push({fi:1,data:so.defaultData("light",u),id:h}),{layers:f}}a.defaultTwoLayerTextureData=o})(Fn||(Fn={}));var Ql;(e=>{function r(){return{points:new Ve,roundness:0,shapeHoles:[],isClosed:!1}}e.defaultData=r})(Ql||(Ql={}));var gp;(e=>{function r(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=r})(gp||(gp={}));var oo;(e=>{function r(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="VectorGeometry")return{width:1,height:1,type:t,subdivisions:12,shape:Ql.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(t==="BooleanGeometry")return{type:t,operation:2,width:0,height:0,depth:0,phongAngle:35};if(t==="TextGeometry")return{type:t,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};throw new Error("not implemented")}e.defaultData=r})(oo||(oo={}));var nh;(i=>{i.identity={...up.identity,hiddenMatrix:io.identity};function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}i.fromObject=e;function t(s,o){return{position:o?.position||s.position,rotation:o?.rotation||s.rotation,scale:o?.scale||s.scale,hiddenMatrix:o?.hiddenMatrix||s.hiddenMatrix}}i.merge=t;function n(s,o){return{position:Yl.isEqual(s.position,o.position)?null:o.position,rotation:Yl.isEqual(s.rotation,o.rotation)?null:o.rotation,scale:Yl.isEqual(s.scale,o.scale)?null:o.scale,hiddenMatrix:io.isEqual(s.hiddenMatrix,o.hiddenMatrix)?null:o.hiddenMatrix}}i.diff=n})(nh||(nh={}));var wv;(e=>e.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]})(wv||(wv={}));var hi;(e=>e.defaultData={states:new Ve,events:new Ve,visible:!0,raycastLock:!1,physics:null,...nh.identity})(hi||(hi={}));var Z1;(e=>e.defaultData={type:"Empty",...hi.defaultData})(Z1||(Z1={}));var oa;(e=>e.defaultData={type:"Mesh",...hi.defaultData,...pp.defaultData})(oa||(oa={}));var yp;(e=>e.defaultData={...hi.defaultData,...nh.identity,...ia.defaultData})(yp||(yp={}));var vp;(e=>{function r(t){return{...hi.defaultData,...fp.defaultData(t)}}e.defaultData=r})(vp||(vp={}));var xp;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:io.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wv.defaultData,states:new Ve,events:new Ve,...ia.defaultData},i.defaultMeshObject={name:"Rectangle",...hi.defaultData,...oa.defaultData,geometry:oo.defaultData("RectangleGeometry"),material:Fn.defaultTwoLayerData("basic","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...hi.defaultData,...oa.defaultData,geometry:oo.defaultData("BooleanGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...hi.defaultData,...oa.defaultData,geometry:oo.defaultData("TextGeometry"),material:Fn.defaultTwoLayerData("phong","layer1","layer2")}))(xp||(xp={}));var rh;(t=>{function r(n,i){if(i===void 0)return n;let s={...n};return"material"in s&&"material"in i&&i.material&&(s.material=sv(s.material,o=>{if(typeof o!="string")for(let[a,l]of Object.entries(i.material.layers)){let u=o.layers.data(a);u&&Jo(u,l)}}).data),s.materials&&i.materials&&(s.materials=sv(s.materials,o=>{for(let a=0;a<s.materials.length;a++){let l=i.materials[a];if(typeof l!="string")for(let[u,c]of Object.entries(l.layers)){let h=o[a]?.layers?.data(u);h&&Jo(h,c)}}}).data),s}t.patchMaterialState=r;function e(n,i){if(i===void 0)return n;let s={...n};if(Object.assign(s,nh.merge(s,i)),Ri.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let o=i;o.orthographic?.zoom!==void 0&&(s.orthographic.zoom=o.orthographic.zoom),o.perspective?.zoom!==void 0&&(s.perspective.zoom=o.perspective.zoom),o.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=o.isUpVectorFlipped),o.targetOffset!==void 0&&(s.targetOffset=o.targetOffset)}else if(n.type==="Mesh")s.geometry={...s.geometry},Object.assign(s.geometry,i.geometry),s=r(s,i);else if(dp.is(n.type)){let o=i;o.intensity!==void 0&&(s.intensity=o.intensity),o.color!==void 0&&(typeof o.color=="string"?s.color=o.color:s.color=Xn.clone(o.color))}return s}t.patch=e})(rh||(rh={}));var ih;(e=>e.defaultData={enabled:!1,useBackgroundColor:!1,color:Xn.white,near:.1,far:2e3})(ih||(ih={}));var Zl;(e=>e.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})(Zl||(Zl={}));var vs;(e=>e.defaultData={orbitControls:Zl.defaultData,playCamera:null,withBackground:!0,preventScroll:!1,settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:1,stopMode:"manual",duration:5e3},web:{compress:!0,preset:1,preload:!0}},stopRaycast:!0,joystickSizeAndXYOffset:Array(12).fill(0).map((t,n)=>{let i=0,s=0;return n<5?s=-30:n<10&&(s=30),n===0||n===10||n===5?i=30:(n===4||n===11||n===9)&&(i=-30),[120,[i,s],"show"]}),gameControlObject:null})(vs||(vs={}));var qr;(e=>e.defaultData={ambientLight:{enabled:!0,type:"HemisphereLight",color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75,depth:100,groundColor:{r:.5098039215686274,g:.5098039215686274,b:.5098039215686274},softShadows:!1,softShadowQuality:"low"},usePhysics:!1,gravity:-10,pixelsPerMeter:200})(qr||(qr={}));var bp;(n=>{function r(){let i=new Bt,s=xp.defaultMeshObject;return i.push({fi:-1,data:{...vp.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7},id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),i.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:s,children:[]}),i}n.defaultData={backgroundColor:pr.fromHexAndA(1184534,1),postprocessing:sa.defaultData,fog:ih.defaultData,objects:r(),environment:qr.defaultData,publish:vs.defaultData},n.emptyData=function(){return{backgroundColor:pr.fromHexAndA(1184534,1),postprocessing:sa.defaultData,fog:ih.defaultData,objects:new Bt,environment:qr.defaultData,publish:vs.defaultData}}})(bp||(bp={}));function aa(r,e){return Object.setPrototypeOf(r,e),r}var xG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().includes(" electron/"),bG=()=>typeof window>"u"?!1:window.navigator.platform.toUpperCase().includes("MAC"),wG=()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(window.navigator.userAgent)||la&&"ontouchend"in document,SG=()=>typeof window>"u"?!1:window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1,AG=()=>typeof window>"u"?!1:"ontouchstart"in window||navigator.maxTouchPoints>0,_G=()=>{if(typeof window>"u")return!1;let r=navigator.userAgent,e=navigator.vendor;return/Safari/i.test(r)&&/Apple Computer/.test(e)},TG=()=>{if(typeof window>"u")return null;let e=navigator.userAgent.match(/Version\/(\d+\.\d)/);return e&&e[1]},bK=xG(),la=bG(),sh=wG(),K1=SG(),vn=AG(),Kl=_G(),Jl=Number(TG());function J1(r){return Array.isArray(r)?r:[r]}function oh(r){return la?r.metaKey:r.ctrlKey}var $e=[],Sp={},ah={},wp={};function $1(r){$e.includes(r)||$e.push(r)}function $l(r){delete Sp[r.pointerId];for(let e=0;e<$e.length;e++)if($e[e].pointerId===r.pointerId){$e.splice(e,1);break}}function Ap(r){if(r.pointerType!=="touch")return;let e=Sp[r.pointerId];e===void 0&&(e={x:0,y:0},Sp[r.pointerId]=e),e.x=r.pageX,e.y=r.pageY}function _p(r){let e=r.pointerId===$e[0].pointerId?$e[1]:$e[0];return Sp[e.pointerId]}function e_(r){ah[r.key]=!0,wp[r.key]=wp[r.key]===void 0?1:wp[r.key]+1}function t_(r){if(la&&ah.Meta)for(let e in ah)ah[e]=!1;else ah[r.key]=!1;wp={}}function n_(r){r.addEventListener("pointerdown",$1,!0),r.addEventListener("pointerdown",Ap,!0),r.addEventListener("pointermove",Ap,!0),r.addEventListener("pointerup",$l,!0),r.addEventListener("pointercancel",$l,!0),r.addEventListener("pointerleave",$l,!0),window.addEventListener("keydown",e_,!0),window.addEventListener("keyup",t_,!0)}function r_(r){r.removeEventListener("pointerdown",$1,!0),r.removeEventListener("pointerdown",Ap,!0),r.removeEventListener("pointermove",Ap,!0),r.removeEventListener("pointerup",$l,!0),r.removeEventListener("pointercancel",$l,!0),r.removeEventListener("pointerleave",$l,!0),window.removeEventListener("keydown",e_,!0),window.removeEventListener("keyup",t_,!0)}var ec;(t=>{function r(){let n={};return n["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},aa(n,zt.prototype)}t.defaultColors=r;function e(){return{materials:new zt,images:new zt,colors:new zt,audios:new zt,fonts:new zt,penumbraSize:[.5,.5,.5]}}t.emptyData=e})(ec||(ec={}));function i_(r){r.layers.forEach(e=>{if(e.type==="depth"&&e.colorA!==void 0){let t=e.colorA,n=e.colorB,i=[[t.r,t.g,t.b,t.a],[n.r,n.g,n.b,n.a]],s=[0,1];for(let a=2;a<10;a++)i.push(i[1]),s.push(1);let o={...Vl(dr(e),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,e.near),far:Math.max(0,e.far),colors:i,steps:s,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(e,o)}else if(e.type==="depth"&&e.gradientType===1&&(e.near<0||e.far<0)){let t={...dr(e),near:Math.max(e.near,0),far:Math.max(e.far,0)};Object.assign(e,t)}})}function Sv(r,e){Object.values(r.shared.materials).forEach(t=>e(t))}function Av(r,e){r.scene.objects.traverse((t,n)=>{"materials"in n?n.materials.forEach(i=>{typeof i!="string"&&e(i)}):"material"in n&&typeof n.material!="string"&&e(n.material)})}function MG(r){Object.assign(r.scene.publish,{orbitControls:{...Zl.defaultData,...dr(r.scene.publish.orbitControls)}})}function EG(r){Object.assign(r.scene.publish.settings,{video:{...vs.defaultData.settings.video,...dr(r.scene.publish.settings.video)}})}function CG(r){function e(t){if(t.layers){for(let n of Object.values(t.layers))if(n){for(let[i,s]of Object.entries(n))if((mp.includes(i)||typeof s=="boolean")&&delete n[i],i==="texture")for(let[o,a]of Object.entries(s))(Q1.includes(o)||typeof a=="boolean")&&delete s[o]}}}r.scene.objects.traverse((t,n)=>{n.states.forEach(i=>{let s=i;s.material?e(s.material):s.materials&&s.materials.forEach(o=>{e(o)})})})}function PG(r){r.scene.publish.withBackground=!0}function DG(r){r.scene.publish.settings.web={compress:!0,preload:!0,preset:1}}function IG(r){r.scene.objects.traverse((e,t)=>{let n=t.cloner;n&&(n.radial.scale=n.radial.scale.map(i=>i+1),n.linear.scale=n.linear.scale.map(i=>i+1))})}function LG(r){r.scene.objects.traverse((e,t)=>{let n=t.geometry;n&&(n.type==="DodecahedronGeometry"||n.type==="IcosahedronGeometry")&&(n.detail=Math.round(n.detail))})}function OG(r){r.scene.objects.traverse((e,t)=>{let n=r.scene.objects.parent(e);t.type==="Mesh"&&(!n||r.scene.objects.data(n).geometry?.type!=="BooleanGeometry")&&(t.booleanExclude=null)})}function s_(r){r.layers===void 0&&Object.assign(r,Fn.defaultTwoLayerData("lambert"))}function _v(r){!r.layers||r.layers.forEach(e=>{if(e.type==="depth"&&e.colors.length===10){let t=[...e.colors];t.push(e.colors[9]);let n=[...e.steps];n.push(e.steps[9]);let i={...dr(e),colors:t,steps:n};Object.assign(e,i)}})}function RG(r){r.scene.objects.traverse((e,t)=>{t.type==="Mesh"&&(t.geometry.type==="BooleanGeometry"||t.geometry.type==="SubdivGeometry")&&(t.geometry.phongAngle=35)})}function o_(r){r.scene.objects.traverse((e,t)=>{"materials"in t?t.materials.forEach(n=>{typeof n!="string"&&_v(n)}):"material"in t&&typeof t.material!="string"&&_v(t.material)}),Object.values(r.shared.materials).forEach(e=>_v(e))}function NG(r){r.scene.environment.ambientLight.softShadows=!1,r.scene.environment.ambientLight.softShadowQuality="low",r.scene.objects.traverse((e,t)=>{(t.type==="DirectionalLight"||t.type==="SpotLight")&&(t.shadowResolution=1024,t.shadowRadius=1,t.depth=1e5)}),r.shared.penumbraSize=new Array(5).fill(.5)}function BG(r){r.shared.audios=aa({},zt.prototype)}function FG(r){let e=r.shared.materials;Object.entries(e).forEach(([t,n])=>{if(!n.layers){let i={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"basic",alpha:1,visible:!0,mode:0},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(e,{[t]:i})}})}function UG(r){Object.entries(dr(r.shared.images)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.images[n]}),Object.entries(dr(r.shared.audios)).filter(n=>n[1].asset===!1).map(n=>n[0]).forEach(n=>{delete r.shared.audios[n]})}function GG(r){r.scene.publish.settings.web.preload=!1}function a_(r){r.layers&&r.layers.forEach(e=>{e.type==="depth"&&e.num!==void 0&&(e.colors=e.colors.slice(0,e.num),e.steps=e.steps.slice(0,e.num),delete e.num)})}function zG(r){r.shared.fonts=aa({},zt.prototype)}function kG(r){return r.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(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function VG(r){let e=[];r.scene.objects.traverse((t,n)=>{let i=n;if(i.type==="TextFrame"){let s=Fn.defaultTwoLayerData("basic"),o=typeof i.color=="string"?r.shared.colors[i.color]:i.color;s.layers[1].data.color={r:o.r,g:o.g,b:o.b},s.layers[1].data.alpha=i.alpha;let a=kG(i.font);r.shared.fonts[a]===void 0&&(r.shared.fonts[a]={name:a});let l={name:i.name,...hi.defaultData,...oa.defaultData,flatShading:!1,wireframe:!1,geometry:{...oo.defaultData("TextGeometry"),width:i.width,height:i.height,font:a,depth:0,horizontalAlign:i.horizontalAlign,verticalAlign:i.verticalAlign,fontSize:i.fontSize*1.40625,lineHeight:i.lineHeight/1.40625,letterSpacing:i.letterSpacing-1,text:i.text,textTransform:i.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:s,states:dr(i.states),events:dr(i.events),visible:i.visible,raycastLock:i.raycastLock,position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix},u=dr(r.scene.objects).parent(t);r.scene.objects.insertAfter(u??null,t,[{id:t+"new",data:l,children:[]}]),e.push(t)}}),e.forEach(t=>{r.scene.objects.delete(t)})}function HG(r){let e={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};r.scene.objects.traverse((t,n)=>{n.events.forEach(i=>{if(!!e[Number(i.type)])if(Object.assign(i,{type:e[Number(i.type)]}),i.type==="Audio"&&"audioEvent"in i&&(Object.assign(i,{playAudio:i.audioEvent}),delete i.audioEvent),i.type==="GameControl")Object.assign(i,{gameActions:{idle:new Ve,move:new Ve,jump:new Ve}});else{let s=new Ve;Object.assign(i,{actions:s}),(i.type==="MouseDown"||i.type==="MouseUp"||i.type==="KeyDown"||i.type==="KeyUp")&&"url"in i&&s.push({fi:0,id:Be.generateUUID(),data:{type:"Link",url:i.url,delay:0}}),"targets"in i&&(i.targets.forEach((o,a,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:o.easing,duration:o.duration};o.easing===6?Object.assign(c,Vl(o,"mass","stiffness","damping","velocity")):o.easing===5&&Object.assign(c,{control1:{...o.control1},control2:{...o.control2}});let h={repeat:o.repeat?-1:0,delay:o.delay,delayDirection:o.delayDirection,direction:o.cycle&&o.rewind?"pingpong-rewind":o.cycle?"pingpong":"normal"},d={state:o.state,...h,...c},f={allowSlerp:!0,type:"Transition",object:o.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Ve({fi:0,id:Be.generateUUID(),data:u},{fi:1,id:Be.generateUUID(),data:d})};s.push({fi:l,id:a,data:f})}),delete i.targets)}})})}function WG(r){r.scene.objects.traverse((e,t)=>{function n(i,s){let o=new Ve,a=[];if(t.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===s){let h;a.push(u),l.interaction==="play"?h={...Vl(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(h={...Vl(l,"interaction","delay","object","playAudio"),type:"Audio"}),h&&o.push({fi:c,id:u,data:h})}}),a.forEach(l=>t.events.delete(l)),o.length){let l=t.events.find(u=>u.type===i)?.data;l?"actions"in l&&l.actions.insertBefore(null,o):t.events.insertBefore(null,[{id:Be.generateUUID(),data:{type:i,actions:o}}])}}n("Start","start"),n("MouseDown","mouseDown"),n("MouseUp","mouseUp"),n("KeyDown","keyDown"),n("KeyUp","keyUp")})}var l_=21;function c_(r){let e=r.schema??0;e!==l_&&(console.warn("updating from ",e,"to ",l_),e<1&&(Av(r,i_),Sv(r,i_),r.schema=1),e<2&&(MG(r),r.schema=2),e<3&&(CG(r),r.schema=3),e<4&&(PG(r),r.schema=4),e<5&&(DG(r),r.schema=5),e<6&&(IG(r),r.schema=6),e<7&&(LG(r),r.schema=7),e<8&&(OG(r),r.schema=8),e<9&&(o_(r),r.schema=9),e<10&&(RG(r),r.schema=10),e<11&&(NG(r),r.schema=11),e<12&&(o_(r),r.schema=12),e<13&&(BG(r),r.schema=13),e<14&&(FG(r),r.schema=14),e<15&&(UG(r),r.schema=15),e<16&&(GG(r),r.schema=16),e<17&&(Av(r,a_),Sv(r,a_),r.schema=17),e<18&&(Av(r,s_),Sv(r,s_),r.schema=18),e<19&&(EG(r),r.schema=19),e<20&&(zG(r),VG(r),r.schema=20),e<21&&(HG(r),WG(r),r.schema=21))}var Tp;(e=>e.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="})(Tp||(Tp={}));function xs(r,e=!1){let t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new De,u=0;for(let c=0;c<r.length;++c){let h=r[c],d=0;if(t!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let f in h.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(h.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let f in h.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(h.morphAttributes[f])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(h.userData),e){let f;if(t)f=h.index.count;else if(h.attributes.position!==void 0)f=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(u,f,c),u+=f}}if(t){let c=0,h=[];for(let d=0;d<r.length;++d){let f=r[d].index;for(let m=0;m<f.count;++m)h.push(f.getX(m)+c);c+=r[d].attributes.position.count}l.setIndex(h)}for(let c in s){let h=u_(s[c]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,h)}for(let c in o){let h=o[c][0].length;if(h===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let d=0;d<h;++d){let f=[];for(let p=0;p<o[c].length;++p)f.push(o[c][p][d]);let m=u_(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(m)}}return l}function u_(r){let e,t,n,i=0;for(let a=0;a<r.length;++a){let l=r[a];if(l.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=l.array.constructor),e!==l.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=l.normalized),n!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=l.array.length}let s=new e(i),o=0;for(let a=0;a<r.length;++a)s.set(r[a].array,o),o+=r[a].array.length;return new Ge(s,t,n)}var Mp;(t=>(t.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},t.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:t.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:-3e3,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 Ve,move:new Ve,jump:new Ve}}))(Mp||(Mp={}));var h_=Math.pow(2,-24);var ca=class{constructor(){}};function Xr(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Tv(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){let i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Mv(r,e){e.set(r)}function Ev(r,e,t){let n,i;for(let s=0;s<3;s++){let o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function lh(r,e,t){for(let n=0;n<3;n++){let i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function nc(r){let e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}function XG(r,e){if(!r.index){let t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i;t>65535?i=new Uint32Array(new n(4*t)):i=new Uint16Array(new n(2*t)),r.setIndex(new Ge(i,1));for(let s=0;s<t;s++)i[s]=s}}function YG(r){if(!r.groups||!r.groups.length)return[{offset:0,count:r.index.count/3}];let e=[],t=new Set;for(let i of r.groups)t.add(i.start),t.add(i.start+i.count);let n=Array.from(t.values()).sort((i,s)=>i-s);for(let i=0;i<n.length-1;i++){let s=n[i],o=n[i+1];e.push({offset:s/3,count:(o-s)/3})}return e}function Pv(r,e,t,n,i=null){let s=1/0,o=1/0,a=1/0,l=-1/0,u=-1/0,c=-1/0,h=1/0,d=1/0,f=1/0,m=-1/0,p=-1/0,g=-1/0,v=i!==null;for(let y=e*6,b=(e+t)*6;y<b;y+=6){let w=r[y+0],S=r[y+1],_=w-S,M=w+S;_<s&&(s=_),M>l&&(l=M),v&&w<h&&(h=w),v&&w>m&&(m=w);let x=r[y+2],T=r[y+3],E=x-T,C=x+T;E<o&&(o=E),C>u&&(u=C),v&&x<d&&(d=x),v&&x>p&&(p=x);let P=r[y+4],O=r[y+5],D=P-O,N=P+O;D<a&&(a=D),N>c&&(c=N),v&&P<f&&(f=P),v&&P>g&&(g=P)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=u,n[5]=c,v&&(i[0]=h,i[1]=d,i[2]=f,i[3]=m,i[4]=p,i[5]=g)}function QG(r,e,t,n){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=e*6,h=(e+t)*6;c<h;c+=6){let d=r[c+0];d<i&&(i=d),d>a&&(a=d);let f=r[c+2];f<s&&(s=f),f>l&&(l=f);let m=r[c+4];m<o&&(o=m),m>u&&(u=m)}n[0]=i,n[1]=s,n[2]=o,n[3]=a,n[4]=l,n[5]=u}function ZG(r,e,t,n,i){let s=t,o=t+n-1,a=i.pos,l=i.axis*2;for(;;){for(;s<=o&&e[s*6+l]<a;)s++;for(;s<=o&&e[o*6+l]>=a;)o--;if(s<o){for(let u=0;u<3;u++){let c=r[s*3+u];r[s*3+u]=r[o*3+u],r[o*3+u]=c;let h=e[s*6+u*2+0];e[s*6+u*2+0]=e[o*6+u*2+0],e[o*6+u*2+0]=h;let d=e[s*6+u*2+1];e[s*6+u*2+1]=e[o*6+u*2+1],e[o*6+u*2+1]=d}s++,o--}else return s}}var bs=32,KG=(r,e)=>r.candidate-e.candidate,ao=new Array(bs).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ep=new Float32Array(6);function JG(r,e,t,n,i,s){let o=-1,a=0;if(s===0)o=Tv(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===1)o=Tv(r),o!==-1&&(a=$G(t,n,i,o));else if(s===2){let l=nc(r),u=1.25*i,c=n*6,h=(n+i)*6;for(let d=0;d<3;d++){let f=e[d],g=(e[d+3]-f)/bs;if(i<bs/4){let v=[...ao];v.length=i;let y=0;for(let w=c;w<h;w+=6,y++){let S=v[y];S.candidate=t[w+2*d],S.count=0;let{bounds:_,leftCacheBounds:M,rightCacheBounds:x}=S;for(let T=0;T<3;T++)x[T]=1/0,x[T+3]=-1/0,M[T]=1/0,M[T+3]=-1/0,_[T]=1/0,_[T+3]=-1/0;lh(w,t,_)}v.sort(KG);let b=i;for(let w=0;w<b;w++){let S=v[w];for(;w+1<b&&v[w+1].candidate===S.candidate;)v.splice(w+1,1),b--}for(let w=c;w<h;w+=6){let S=t[w+2*d];for(let _=0;_<b;_++){let M=v[_];S>=M.candidate?lh(w,t,M.rightCacheBounds):(lh(w,t,M.leftCacheBounds),M.count++)}}for(let w=0;w<b;w++){let S=v[w],_=S.count,M=i-S.count,x=S.leftCacheBounds,T=S.rightCacheBounds,E=0;_!==0&&(E=nc(x)/l);let C=0;M!==0&&(C=nc(T)/l);let P=1+1.25*(E*_+C*M);P<u&&(o=d,u=P,a=S.candidate)}}else{for(let b=0;b<bs;b++){let w=ao[b];w.count=0,w.candidate=f+g+b*g;let S=w.bounds;for(let _=0;_<3;_++)S[_]=1/0,S[_+3]=-1/0}for(let b=c;b<h;b+=6){let _=~~((t[b+2*d]-f)/g);_>=bs&&(_=bs-1);let M=ao[_];M.count++,lh(b,t,M.bounds)}let v=ao[bs-1];Mv(v.bounds,v.rightCacheBounds);for(let b=bs-2;b>=0;b--){let w=ao[b],S=ao[b+1];Ev(w.bounds,S.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let b=0;b<bs-1;b++){let w=ao[b],S=w.count,_=w.bounds,x=ao[b+1].rightCacheBounds;S!==0&&(y===0?Mv(_,Ep):Ev(_,Ep,Ep)),y+=S;let T=0,E=0;y!==0&&(T=nc(Ep)/l);let C=i-y;C!==0&&(E=nc(x)/l);let P=1+1.25*(T*y+E*C);P<u&&(o=d,u=P,a=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function $G(r,e,t,n){let i=0;for(let s=e,o=e+t;s<o;s++)i+=r[s*6+n*2];return i/t}function ez(r,e){let t=r.attributes.position,n=t.array,i=r.index.array,s=i.length/3,o=new Float32Array(s*6),a=t.offset||0,l=3;t.isInterleavedBufferAttribute&&(l=t.data.stride);for(let u=0;u<s;u++){let c=u*3,h=u*6,d=i[c+0]*l+a,f=i[c+1]*l+a,m=i[c+2]*l+a;for(let p=0;p<3;p++){let g=n[d+p],v=n[f+p],y=n[m+p],b=g;v<b&&(b=v),y<b&&(b=y);let w=g;v>w&&(w=v),y>w&&(w=y);let S=(w-b)/2,_=p*2;o[h+_+0]=b+S,o[h+_+1]=S+(Math.abs(b)+S)*h_,b<e[p]&&(e[p]=b),w>e[p+3]&&(e[p+3]=w)}}return o}function tz(r,e){function t(v){d&&d(v/f)}function n(v,y,b,w=null,S=0){if(!m&&S>=l&&(m=!0,u&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(r))),b<=c||S>=l)return t(y+b),v.offset=y,v.count=b,v;let _=JG(v.boundingData,w,o,y,b,h);if(_.axis===-1)return t(y+b),v.offset=y,v.count=b,v;let M=ZG(a,o,y,b,_);if(M===y||M===y+b)t(y+b),v.offset=y,v.count=b;else{v.splitAxis=_.axis;let x=new ca,T=y,E=M-y;v.left=x,x.boundingData=new Float32Array(6),Pv(o,T,E,x.boundingData,s),n(x,T,E,s,S+1);let C=new ca,P=M,O=b-E;v.right=C,C.boundingData=new Float32Array(6),Pv(o,P,O,C.boundingData,s),n(C,P,O,s,S+1)}return v}XG(r,e);let i=new Float32Array(6),s=new Float32Array(6),o=ez(r,i),a=r.index.array,l=e.maxDepth,u=e.verbose,c=e.maxLeafTris,h=e.strategy,d=e.onProgress,f=r.index.count/3,m=!1,p=[],g=YG(r);if(g.length===1){let v=g[0],y=new ca;y.boundingData=i,QG(o,v.offset,v.count,s),n(y,v.offset,v.count,s),p.push(y)}else for(let v of g){let y=new ca;y.boundingData=new Float32Array(6),Pv(o,v.offset,v.count,y.boundingData,s),n(y,v.offset,v.count,s),p.push(y)}return p}function p_(r,e){let t=tz(r,e),n,i,s,o=[],a=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<t.length;c++){let h=t[c],d=l(h),f=new a(32*d);n=new Float32Array(f),i=new Uint32Array(f),s=new Uint16Array(f),u(0,h),o.push(f)}return o;function l(c){return c.count?1:1+l(c.left)+l(c.right)}function u(c,h){let d=c/4,f=c/2,m=!!h.count,p=h.boundingData;for(let g=0;g<6;g++)n[d+g]=p[g];if(m){let g=h.offset,v=h.count;return i[d+6]=g,s[f+14]=v,s[f+15]=65535,c+32}else{let g=h.left,v=h.right,y=h.splitAxis,b;if(b=u(c+32,g),b/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[d+6]=b/4,b=u(b,v),i[d+7]=y,b}}}var mr=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){let l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){let a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};mr.prototype.setFromBox=function(){let r=new A;return function(t,n){let i=n.min,s=n.max,o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*u+s.y*(1-u),r.z=i.z*c+s.z*(1-c);let h=t.dot(r);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var mJ=function(){let r=new mr;return function(t,n){let i=t.points,s=t.satAxes,o=t.satBounds,a=n.points,l=n.satAxes,u=n.satBounds;for(let c=0;c<3;c++){let h=o[c],d=s[c];if(r.setFromPoints(d,a),h.isSeparated(r))return!1}for(let c=0;c<3;c++){let h=u[c],d=l[c];if(r.setFromPoints(d,i),h.isSeparated(r))return!1}}}();var nz=function(){let r=new A,e=new A,t=new A;return function(i,s,o){let a=i.start,l=r,u=s.start,c=e;t.subVectors(a,u),r.subVectors(i.end,s.start),e.subVectors(s.end,s.start);let h=t.dot(c),d=c.dot(l),f=c.dot(c),m=t.dot(l),g=l.dot(l)*f-d*d,v,y;g!==0?v=(h*d-m*f)/g:v=0,y=(h+v*d)/f,o.x=v,o.y=y}}(),ch=function(){let r=new B,e=new A,t=new A;return function(i,s,o,a){nz(i,s,r);let l=r.x,u=r.y;if(l>=0&&l<=1&&u>=0&&u<=1){i.at(l,o),s.at(u,a);return}else if(l>=0&&l<=1){u<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(u>=0&&u<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let h;u<0?h=s.start:h=s.end;let d=e,f=t;if(i.closestPointToPoint(h,!0,e),s.closestPointToPoint(c,!0,t),d.distanceToSquared(h)<=f.distanceToSquared(c)){o.copy(d),a.copy(h);return}else{o.copy(c),a.copy(f);return}}}}(),m_=function(){let r=new A,e=new A,t=new mn,n=new gn;return function(s,o){let{radius:a,center:l}=s,{a:u,b:c,c:h}=o;if(n.start=u,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=u,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;let p=o.getPlane(t);if(Math.abs(p.distanceToPoint(l))<=a){let v=p.projectPoint(l,e);if(o.containsPoint(v))return!0}return!1}}();var rz=1e-15;function rc(r){return Math.abs(r)<rz}var gr=class extends Mn{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new A),this.satBounds=new Array(4).fill().map(()=>new mr),this.points=[this.a,this.b,this.c],this.sphere=new En,this.plane=new mn,this.needsUpdate=!0}intersectsSphere(e){return m_(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);let u=s[1],c=o[1];u.subVectors(e,t),c.setFromPoints(u,i);let h=s[2],d=o[2];h.subVectors(t,n),d.setFromPoints(h,i);let f=s[3],m=o[3];f.subVectors(n,e),m.setFromPoints(f,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}};gr.prototype.closestPointToSegment=function(){let r=new A,e=new A,t=new gn;return function(i,s=null,o=null){let{start:a,end:l}=i,u=this.points,c,h=1/0;for(let d=0;d<3;d++){let f=(d+1)%3;t.start.copy(u[d]),t.end.copy(u[f]),ch(t,i,r,e),c=r.distanceToSquared(e),c<h&&(h=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<h&&(h=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(h)}}();gr.prototype.intersectsTriangle=function(){let r=new gr,e=new Array(3),t=new Array(3),n=new mr,i=new mr,s=new A,o=new A,a=new A,l=new A,u=new gn,c=new gn,h=new gn;return function(f,m=null){this.needsUpdate&&this.update(),f.isExtendedTriangle?f.needsUpdate&&f.update():(r.copy(f),r.update(),f=r);let p=this.plane,g=f.plane;if(Math.abs(p.normal.dot(g.normal))>1-1e-10){let v=this.satBounds,y=this.satAxes;t[0]=f.a,t[1]=f.b,t[2]=f.c;for(let S=0;S<4;S++){let _=v[S],M=y[S];if(n.setFromPoints(M,t),_.isSeparated(n))return!1}let b=f.satBounds,w=f.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let S=0;S<4;S++){let _=b[S],M=w[S];if(n.setFromPoints(M,e),_.isSeparated(n))return!1}for(let S=0;S<4;S++){let _=y[S];for(let M=0;M<4;M++){let x=w[M];if(s.crossVectors(_,x),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return m&&(console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{let v=this.points,y=!1,b=0;for(let O=0;O<3;O++){let D=v[O],N=v[(O+1)%3];u.start.copy(D),u.end.copy(N),u.delta(o);let F=y?c.start:c.end,z=rc(g.distanceToPoint(D));if(rc(g.normal.dot(o))&&z){c.copy(u),b=2;break}if((g.intersectLine(u,F)||z)&&!rc(F.distanceTo(N))){if(b++,y)break;y=!0}}if(b===1&&this.containsPoint(c.start))return m&&(m.start.copy(c.start),m.end.copy(c.start)),!0;if(b!==2)return!1;let w=f.points,S=!1,_=0;for(let O=0;O<3;O++){let D=w[O],N=w[(O+1)%3];u.start.copy(D),u.end.copy(N),u.delta(a);let F=S?h.start:h.end,z=rc(p.distanceToPoint(D));if(rc(p.normal.dot(a))&&z){h.copy(u),_=2;break}if((p.intersectLine(u,F)||z)&&!rc(F.distanceTo(N))){if(_++,S)break;S=!0}}if(_===1&&this.containsPoint(h.start))return m&&(m.start.copy(h.start),m.end.copy(h.start)),!0;if(_!==2)return!1;if(c.delta(o),h.delta(a),o.dot(a)<0){let O=h.start;h.start=h.end,h.end=O}let M=c.start.dot(o),x=c.end.dot(o),T=h.start.dot(o),E=h.end.dot(o),C=x<T,P=M<E;return M!==E&&T!==x&&C===P?!1:(m&&(l.subVectors(c.start,h.start),l.dot(o)>0?m.start.copy(c.start):m.start.copy(h.start),l.subVectors(c.end,h.end),l.dot(o)<0?m.end.copy(c.end):m.end.copy(h.end)),!0)}}}();gr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();gr.prototype.distanceToTriangle=function(){let r=new A,e=new A,t=["a","b","c"],n=new gn,i=new gn;return function(o,a=null,l=null){let u=a||l?n:null;if(this.intersectsTriangle(o,u))return(a||l)&&(a&&u.getCenter(a),l&&u.getCenter(l)),0;let c=1/0;for(let h=0;h<3;h++){let d,f=t[h],m=o[f];this.closestPointToPoint(m,r),d=m.distanceToSquared(r),d<c&&(c=d,a&&a.copy(r),l&&l.copy(m));let p=this[f];o.closestPointToPoint(p,r),d=p.distanceToSquared(r),d<c&&(c=d,a&&a.copy(p),l&&l.copy(r))}for(let h=0;h<3;h++){let d=t[h],f=t[(h+1)%3];n.set(this[d],this[f]);for(let m=0;m<3;m++){let p=t[m],g=t[(m+1)%3];i.set(o[p],o[g]),ch(n,i,r,e);let v=r.distanceToSquared(e);v<c&&(c=v,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}}();var yr=class extends Mt{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new be,this.invMatrix=new be,this.points=new Array(8).fill().map(()=>new A),this.satAxes=new Array(3).fill().map(()=>new A),this.satBounds=new Array(3).fill().map(()=>new mr),this.alignedSatBounds=new Array(3).fill().map(()=>new mr),this.needsUpdate=!1}set(e,t,n){super.set(e,t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){super.copy(e),this.matrix.copy(e.matrix),this.needsUpdate=!0}};yr.prototype.update=function(){return function(){let e=this.matrix,t=this.min,n=this.max,i=this.points;for(let u=0;u<=1;u++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){let d=1*u|2*c|4*h,f=i[d];f.x=u?n.x:t.x,f.y=c?n.y:t.y,f.z=h?n.z:t.z,f.applyMatrix4(e)}let s=this.satBounds,o=this.satAxes,a=i[0];for(let u=0;u<3;u++){let c=o[u],h=s[u],d=1<<u,f=i[d];c.subVectors(a,f),h.setFromPoints(c,i)}let l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();yr.prototype.intersectsBox=function(){let r=new mr;return function(t){this.needsUpdate&&this.update();let n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){let u=o[l],c=s[l];if(r.setFromBox(u,t),c.isSeparated(r))return!1}return!0}}();yr.prototype.intersectsTriangle=function(){let r=new gr,e=new Array(3),t=new mr,n=new mr,i=new A;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);let a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let d=0;d<3;d++){let f=a[d],m=l[d];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}let u=o.satBounds,c=o.satAxes,h=this.points;for(let d=0;d<3;d++){let f=u[d],m=c[d];if(t.setFromPoints(m,h),f.isSeparated(t))return!1}for(let d=0;d<3;d++){let f=l[d];for(let m=0;m<4;m++){let p=c[m];if(i.crossVectors(f,p),t.setFromPoints(i,e),n.setFromPoints(i,h),t.isSeparated(n))return!1}}return!0}}();yr.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();yr.prototype.distanceToPoint=function(){let r=new A;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}}();yr.prototype.distanceToBox=function(){let r=["x","y","z"],e=new Array(12).fill().map(()=>new gn),t=new Array(12).fill().map(()=>new gn),n=new A,i=new A;return function(o,a=0,l=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||u)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),u&&u.copy(i)),0;let c=a*a,h=o.min,d=o.max,f=this.points,m=1/0;for(let g=0;g<8;g++){let v=f[g];i.copy(v).clamp(h,d);let y=v.distanceToSquared(i);if(y<m&&(m=y,l&&l.copy(v),u&&u.copy(i),y<c))return Math.sqrt(y)}let p=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){let b=(g+1)%3,w=(g+2)%3,S=v<<b|y<<w,_=1<<g|v<<b|y<<w,M=f[S],x=f[_];e[p].set(M,x);let E=r[g],C=r[b],P=r[w],O=t[p],D=O.start,N=O.end;D[E]=h[E],D[C]=v?h[C]:d[C],D[P]=y?h[P]:d[C],N[E]=d[E],N[C]=v?h[C]:d[C],N[P]=y?h[P]:d[C],p++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){i.x=g?d.x:h.x,i.y=v?d.y:h.y,i.z=y?d.z:h.z,this.closestPointToPoint(i,n);let b=i.distanceToSquared(n);if(b<m&&(m=b,l&&l.copy(n),u&&u.copy(i),b<c))return Math.sqrt(b)}for(let g=0;g<12;g++){let v=e[g];for(let y=0;y<12;y++){let b=t[y];ch(v,b,n,i);let w=n.distanceToSquared(i);if(w<m&&(m=w,l&&l.copy(n),u&&u.copy(i),w<c))return Math.sqrt(w)}}return Math.sqrt(m)}}();var Pp=new A,Dp=new A,Ip=new A,g_=new B,y_=new B,v_=new B,x_=new A;function iz(r,e,t,n,i,s){let o;return s===un?o=r.intersectTriangle(n,t,e,!0,i):o=r.intersectTriangle(e,t,n,s!==tr,i),o===null?null:{distance:r.origin.distanceTo(i),point:i.clone()}}function sz(r,e,t,n,i,s,o){Pp.fromBufferAttribute(e,n),Dp.fromBufferAttribute(e,i),Ip.fromBufferAttribute(e,s);let a=iz(r,Pp,Dp,Ip,x_,o);if(a){t&&(g_.fromBufferAttribute(t,n),y_.fromBufferAttribute(t,i),v_.fromBufferAttribute(t,s),a.uv=Mn.getUV(x_,Pp,Dp,Ip,g_,y_,v_,new B));let l={a:n,b:i,c:s,normal:new A,materialIndex:0};Mn.getNormal(Pp,Dp,Ip,l.normal),a.face=l,a.faceIndex=n}return a}function Iv(r,e,t,n,i){let s=n*3,o=r.index.getX(s),a=r.index.getX(s+1),l=r.index.getX(s+2),u=sz(t,r.attributes.position,r.attributes.uv,o,a,l,e);return u?(u.faceIndex=n,i&&i.push(u),u):null}function b_(r,e,t,n,i,s){for(let o=n,a=n+i;o<a;o++)Iv(r,e,t,o,s)}function w_(r,e,t,n,i){let s=1/0,o=null;for(let a=n,l=n+i;a<l;a++){let u=Iv(r,e,t,a);u&&u.distance<s&&(o=u,s=u.distance)}return o}function Lv(r,e,t){return r===null||(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r.distance<t.near||r.distance>t.far)?null:r}function Yr(r,e,t,n){let i=r.a,s=r.b,o=r.c,a=e,l=e+1,u=e+2;t&&(a=t.getX(e),l=t.getX(e+1),u=t.getX(e+2)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(u),o.y=n.getY(u),o.z=n.getZ(u)}function Ov(r,e,t,n,i,s,o){let a=t.index,l=t.attributes.position;for(let u=r,c=e+r;u<c;u++)if(Yr(o,u*3,a,l),o.needsUpdate=!0,n(o,u,i,s))return!0;return!1}var ic=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}};function ws(r,e){return e[r+15]===65535}function ua(r,e){return e[r+6]}function sc(r,e){return e[r+14]}function oc(r){return r+8}function ac(r,e){return e[r+6]}function S_(r,e){return e[r+7]}var lc=new Mt,Op=new A,az=["x","y","z"];function Rp(r,e,t,n,i){let s=r*2,o=cc,a=lo,l=co;if(ws(s,a)){let c=ua(r,l),h=sc(s,a);b_(e,t,n,c,h,i)}else{let c=oc(r);Bp(c,o,n,Op)&&Rp(c,e,t,n,i);let h=ac(r,l);Bp(h,o,n,Op)&&Rp(h,e,t,n,i)}}function Np(r,e,t,n){let i=r*2,s=cc,o=lo,a=co;if(ws(i,o)){let u=ua(r,a),c=sc(i,o);return w_(e,t,n,u,c)}else{let u=S_(r,a),c=az[u],d=n.direction[c]>=0,f,m;d?(f=oc(r),m=ac(r,a)):(f=ac(r,a),m=oc(r));let g=Bp(f,s,n,Op)?Np(f,e,t,n):null;if(g){let b=g.point[c];if(d?b<=s[m+u]:b>=s[m+u+3])return g}let y=Bp(m,s,n,Op)?Np(m,e,t,n):null;return g&&y?g.distance<=y.distance?g:y:g||y||null}}var A_=function(){let r,e,t=[],n=new ic(()=>new Mt);return function(...o){r=n.getPrimitive(),e=n.getPrimitive(),t.push(r,e);let a=i(...o);n.releasePrimitive(r),n.releasePrimitive(e),t.pop(),t.pop();let l=t.length;return l>0&&(e=t[l-1],r=t[l-2]),a};function i(s,o,a,l,u=null,c=0,h=0){function d(b){let w=b*2,S=lo,_=co;for(;!ws(w,S);)b=oc(b),w=b*2;return ua(b,_)}function f(b){let w=b*2,S=lo,_=co;for(;!ws(w,S);)b=ac(b,_),w=b*2;return ua(b,_)+sc(w,S)}let m=s*2,p=cc,g=lo,v=co;if(ws(m,g)){let b=ua(s,v),w=sc(m,g);return Xr(s,p,r),l(b,w,!1,h,c+s,r)}else{let b=oc(s),w=ac(s,v),S=b,_=w,M,x,T,E;if(u&&(T=r,E=e,Xr(S,p,T),Xr(_,p,E),M=u(T),x=u(E),x<M)){S=w,_=b;let z=M;M=x,x=z,T=E}T||(T=r,Xr(S,p,T));let C=ws(S*2,g),P=a(T,C,M,h+1,c+S),O;if(P===2){let z=d(S),U=f(S)-z;O=l(z,U,!0,h+1,c+S,T)}else O=P&&i(S,o,a,l,u,c,h+1);if(O)return!0;E=e,Xr(_,p,E);let D=ws(_*2,g),N=a(E,D,x,h+1,c+_),F;if(N===2){let z=d(_),U=f(_)-z;F=l(z,U,!0,h+1,c+_,E)}else F=N&&i(_,o,a,l,u,c,h+1);return!!F}}}(),__=function(){let r=new gr,e=new gr,t=new be,n=new yr,i=new yr;return function s(o,a,l,u,c=null){let h=o*2,d=cc,f=lo,m=co;if(c===null&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,u),c=n),ws(h,f)){let g=a,v=g.index,y=g.attributes.position,b=l.index,w=l.attributes.position,S=ua(o,m),_=sc(h,f);if(t.copy(u).invert(),l.boundsTree)return Xr(o,d,i),i.matrix.copy(t),i.needsUpdate=!0,l.boundsTree.shapecast({intersectsBounds:x=>i.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(u),x.b.applyMatrix4(u),x.c.applyMatrix4(u),x.needsUpdate=!0;for(let T=S*3,E=(_+S)*3;T<E;T+=3)if(Yr(e,T,v,y),e.needsUpdate=!0,x.intersectsTriangle(e))return!0;return!1}});for(let M=S*3,x=_+S*3;M<x;M+=3){Yr(r,M,v,y),r.a.applyMatrix4(t),r.b.applyMatrix4(t),r.c.applyMatrix4(t),r.needsUpdate=!0;for(let T=0,E=b.count;T<E;T+=3)if(Yr(e,T,b,w),e.needsUpdate=!0,r.intersectsTriangle(e))return!0}}else{let g=o+8,v=m[o+6];return Xr(g,d,lc),!!(c.intersectsBox(lc)&&s(g,a,l,u,c)||(Xr(v,d,lc),c.intersectsBox(lc)&&s(v,a,l,u,c)))}}}();function Bp(r,e,t,n){return Xr(r,e,lc),t.intersectBox(lc,n)}var Rv=[],Lp,cc,lo,co;function uc(r){Lp&&Rv.push(Lp),Lp=r,cc=new Float32Array(r),lo=new Uint16Array(r),co=new Uint32Array(r)}function uh(){Lp=null,cc=null,lo=null,co=null,Rv.length&&uc(Rv.pop())}var Nv=Symbol("skip tree generation"),Bv=new Mt,Fv=new Mt,hc=new be,ha=new yr,hh=new yr,dh=new A,Fp=new A,lz=new A,cz=new A,uz=new A,T_=new Mt,Ni=new ic(()=>new gr),Jt=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Jt.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});t={cloneBuffers:!0,...t};let n=e.geometry,i=e._roots,s=n.getIndex(),o;return t.cloneBuffers?o={roots:i.map(a=>a.slice()),index:s.array.slice()}:o={roots:i,index:s.array},o}static deserialize(e,t,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Jt.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n={setIndex:!0,...n};let{index:i,roots:s}=e,o=new Jt(t,{...n,[Nv]:!0});if(o._roots=s,n.setIndex){let a=t.getIndex();if(a===null){let l=new Ge(e.index,1,!1);t.setIndex(l)}else a.array!==i&&(a.array.set(i),a.needsUpdate=!0)}return o}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Nv]:!1},t),t.useSharedArrayBuffer&&typeof SharedArrayBuffer>"u")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[Nv]||(this._roots=p_(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Mt))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t=this.geometry,n=t.index.array,i=t.attributes.position,s=i.array,o=i.offset||0,a=3;i.isInterleavedBufferAttribute&&(a=i.data.stride);let l,u,c,h,d=0,f=this._roots;for(let p=0,g=f.length;p<g;p++)l=f[p],u=new Uint32Array(l),c=new Uint16Array(l),h=new Float32Array(l),m(0,d),d+=l.byteLength;function m(p,g,v=!1){let y=p*2;if(c[y+15]===65535){let w=u[p+6],S=c[y+14],_=1/0,M=1/0,x=1/0,T=-1/0,E=-1/0,C=-1/0;for(let P=3*w,O=3*(w+S);P<O;P++){let D=n[P]*a+o,N=s[D+0],F=s[D+1],z=s[D+2];N<_&&(_=N),N>T&&(T=N),F<M&&(M=F),F>E&&(E=F),z<x&&(x=z),z>C&&(C=z)}return h[p+0]!==_||h[p+1]!==M||h[p+2]!==x||h[p+3]!==T||h[p+4]!==E||h[p+5]!==C?(h[p+0]=_,h[p+1]=M,h[p+2]=x,h[p+3]=T,h[p+4]=E,h[p+5]=C,!0):!1}else{let w=p+8,S=u[p+6],_=w+g,M=S+g,x=v,T=!1,E=!1;e?x||(T=e.has(_),E=e.has(M),x=!T&&!E):(T=!0,E=!0);let C=x||T,P=x||E,O=!1;C&&(O=m(w,g,x));let D=!1;P&&(D=m(S,g,x));let N=O||D;if(N)for(let F=0;F<3;F++){let z=w+F,Y=S+F,U=h[z],G=h[z+3],Q=h[Y],V=h[Y+3];h[p+F]=U<Q?U:Q,h[p+F+3]=G>V?G:V}return N}}}traverse(e,t=0){let n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){let u=a*2,c=s[u+15]===65535;if(c){let h=i[a+6],d=s[u+14];e(l,c,new Float32Array(n,a*4,6),h,d)}else{let h=a+32/4,d=i[a+6],f=i[a+7];e(l,c,new Float32Array(n,a*4,6),f)||(o(h,l+1),o(d,l+1))}}}raycast(e,t=Gr){let n=this._roots,i=this.geometry,s=[],o=t.isMaterial,a=Array.isArray(t),l=i.groups,u=o?t.side:t;for(let c=0,h=n.length;c<h;c++){let d=a?t[l[c].materialIndex].side:u,f=s.length;if(uc(n[c]),Rp(0,i,d,e,s),uh(),a){let m=l[c].materialIndex;for(let p=f,g=s.length;p<g;p++)s[p].face.materialIndex=m}}return s}raycastFirst(e,t=Gr){let n=this._roots,i=this.geometry,s=t.isMaterial,o=Array.isArray(t),a=null,l=i.groups,u=s?t.side:t;for(let c=0,h=n.length;c<h;c++){let d=o?t[l[c].materialIndex].side:u;uc(n[c]);let f=Np(0,i,d,e);uh(),f!=null&&(a==null||f.distance<a.distance)&&(a=f,o&&(f.face.materialIndex=l[c].materialIndex))}return a}intersectsGeometry(e,t){let n=this.geometry,i=!1;for(let s of this._roots)if(uc(s),i=__(0,n,e,t),uh(),i)break;return i}shapecast(e,t,n){let i=this.geometry;if(e instanceof Function){if(t){let d=t;t=(f,m,p,g)=>{let v=m*3;return d(f,v,v+1,v+2,p,g)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let s=Ni.getPrimitive(),{boundsTraverseOrder:o,intersectsBounds:a,intersectsRange:l,intersectsTriangle:u}=e;if(l&&u){let d=l;l=(f,m,p,g,v)=>d(f,m,p,g,v)?!0:Ov(f,m,i,u,p,g,s)}else l||(u?l=(d,f,m,p)=>Ov(d,f,i,u,m,p,s):l=(d,f,m)=>m);let c=!1,h=0;for(let d of this._roots){if(uc(d),c=A_(0,i,a,l,o,h),uh(),c)break;h+=d.byteLength}return Ni.releasePrimitive(s),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n,o=this.geometry.index,a=this.geometry.attributes.position,l=e.geometry.index,u=e.geometry.attributes.position;hc.copy(t).invert();let c=Ni.getPrimitive(),h=Ni.getPrimitive();if(s){let f=function(m,p,g,v,y,b,w,S){for(let _=g,M=g+v;_<M;_++){Yr(h,_*3,l,u),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let x=m,T=m+p;x<T;x++)if(Yr(c,x*3,o,a),c.needsUpdate=!0,s(c,h,x,_,y,b,w,S))return!0}return!1};if(i){let m=i;i=function(p,g,v,y,b,w,S,_){return m(p,g,v,y,b,w,S,_)?!0:f(p,g,v,y,b,w,S,_)}}else i=f}e.getBoundingBox(Fv),Fv.applyMatrix4(t);let d=this.shapecast({intersectsBounds:f=>Fv.intersectsBox(f),intersectsRange:(f,m,p,g,v,y)=>(Bv.copy(y),Bv.applyMatrix4(hc),e.shapecast({intersectsBounds:b=>Bv.intersectsBox(b),intersectsRange:(b,w,S,_,M)=>i(f,m,b,w,g,v,_,M)}))});return Ni.releasePrimitive(c),Ni.releasePrimitive(h),d}intersectsBox(e,t){return ha.set(e.min,e.max,t),ha.needsUpdate=!0,this.shapecast({intersectsBounds:n=>ha.intersectsBox(n),intersectsTriangle:n=>ha.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),ha.set(e.boundingBox.min,e.boundingBox.max,t),ha.needsUpdate=!0;let a=this.geometry,l=a.attributes.position,u=a.index,c=e.attributes.position,h=e.index,d=Ni.getPrimitive(),f=Ni.getPrimitive(),m=Fp,p=lz,g=null,v=null;i&&(g=cz,v=uz);let y=1/0,b=null,w=null;return hc.copy(t).invert(),hh.matrix.copy(hc),this.shapecast({boundsTraverseOrder:S=>ha.distanceToBox(S),intersectsBounds:(S,_,M)=>M<y&&M<o?(_&&(hh.min.copy(S.min),hh.max.copy(S.max),hh.needsUpdate=!0),!0):!1,intersectsRange:(S,_)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:M=>hh.distanceToBox(M),intersectsBounds:(M,x,T)=>T<y&&T<o,intersectsRange:(M,x)=>{for(let T=M*3,E=(M+x)*3;T<E;T+=3){Yr(f,T,h,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let C=S*3,P=(S+_)*3;C<P;C+=3){Yr(d,C,u,l),d.needsUpdate=!0;let O=d.distanceToTriangle(f,m,g);if(O<y&&(p.copy(m),v&&v.copy(g),y=O,b=C/3,w=T/3),O<s)return!0}}}});{let M=h?h.count:c.count;for(let x=0,T=M;x<T;x+=3){Yr(f,x,h,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let E=S*3,C=(S+_)*3;E<C;E+=3){Yr(d,E,u,l),d.needsUpdate=!0;let P=d.distanceToTriangle(f,m,g);if(P<y&&(p.copy(m),v&&v.copy(g),y=P,b=E/3,w=x/3),P<s)return!0}}}}}),Ni.releasePrimitive(d),Ni.releasePrimitive(f),y===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=y,n.faceIndex=b,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(hc),p.applyMatrix4(hc),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(e,t={},n=0,i=1/0){let s=n*n,o=i*i,a=1/0,l=null;if(this.shapecast({boundsTraverseOrder:c=>(dh.copy(e).clamp(c.min,c.max),dh.distanceToSquared(e)),intersectsBounds:(c,h,d)=>d<a&&d<o,intersectsTriangle:(c,h)=>{c.closestPointToPoint(e,dh);let d=e.distanceToSquared(dh);return d<a&&(Fp.copy(dh),a=d,l=h),d<s}}),a===1/0)return null;let u=Math.sqrt(a);return t.point?t.point.copy(Fp):t.point=Fp.clone(),t.distance=u,t.faceIndex=l,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{Xr(0,new Float32Array(n),T_),e.union(T_)}),e}},M_=Jt.prototype.raycast;Jt.prototype.raycast=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycast" has changed. See docs for new signature.');let[e,t,n,i]=r;return M_.call(this,n,e.material).forEach(o=>{o=Lv(o,e,t),o&&i.push(o)}),i}else return M_.apply(this,r)};var E_=Jt.prototype.raycastFirst;Jt.prototype.raycastFirst=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "raycastFirst" has changed. See docs for new signature.');let[e,t,n]=r;return Lv(E_.call(this,n,e.material),e,t)}else return E_.apply(this,r)};var C_=Jt.prototype.closestPointToPoint;Jt.prototype.closestPointToPoint=function(...r){if(r[0].isMesh){console.warn('MeshBVH: The function signature and results frame for "closestPointToPoint" has changed. See docs for new signature.'),r.unshift();let e=r[1],t={};return r[1]=t,C_.apply(this,r),e&&e.copy(t.point),t.distance}else return C_.apply(this,r)};var P_=Jt.prototype.closestPointToGeometry;Jt.prototype.closestPointToGeometry=function(...r){let e=r[2],t=r[3];if(e&&e.isVector3||t&&t.isVector3){console.warn('MeshBVH: The function signature and results frame for "closestPointToGeometry" has changed. See docs for new signature.');let n={},i={},s=r[1];return r[2]=n,r[3]=i,P_.apply(this,r),e&&e.copy(n.point),t&&t.copy(i.point).applyMatrix4(s),n.distance}else return P_.apply(this,r)};var D_=Jt.prototype.refit;Jt.prototype.refit=function(...r){let e=r[0],t=r[1];if(t&&(t instanceof Set||Array.isArray(t))){console.warn('MeshBVH: The function signature for "refit" has changed. See docs for new signature.');let n=new Set;t.forEach(i=>n.add(i)),e&&e.forEach(i=>n.add(i)),D_.call(this,n)}else D_.apply(this,r)};["intersectsGeometry","shapecast","intersectsBox","intersectsSphere"].forEach(r=>{let e=Jt.prototype[r];Jt.prototype[r]=function(...t){return(t[0]===null||t[0].isMesh)&&(t.shift(),console.warn(`MeshBVH: The function signature for "${r}" has changed and no longer takes Mesh. See docs for new signature.`)),e.apply(this,t)}});var Uv=class extends ht{},Up=class extends Uv{constructor(t){super();this.object=t;this.matrixAutoUpdate=!0}get castShadow(){return this.object.castShadow}set castShadow(t){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(t){}get isMesh(){return!0}get isLight(){return!1}get layers(){return this.object.layers}set layers(t){}get isCamera(){return!1}get geometry(){return this.object.geometry}get material(){return this.object.material}};var fh=class extends ht{constructor(t,n={}){super();this.object=t;let i=t.recursiveBBox.getSize(new A),s=.1;this.parameters=hp.defaultData(i.toArray(),s),Jo(this.parameters,n),this.update(),this.setHideBase(this.parameters.hideBase)}setHideBase(t){this.parameters.hideBase=t}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)}this.children.forEach(t=>t.updateMatrix())}_updateCount(){let t=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==t)if(this.children.length<t)for(let n=0,i=t-this.children.length;n<i;++n){let s=new Up(this.object);s.visible=!0,this.add(s),this.parameters.hideBase&&this.setHideBase(!0)}else for(let n=0,i=this.children.length-t;n<i;++n)this.remove(this.children[0])}_updateRadial(t){let n=t.radial,i=n.start*Be.DEG2RAD,s=n.end*Be.DEG2RAD,o=i-s,a=new Qt(n.rotation[0]*Be.DEG2RAD,n.rotation[1]*Be.DEG2RAD,n.rotation[2]*Be.DEG2RAD),l;switch(n.axis){case"z":l=new A(0,0,1);break;case"y":l=new A(0,1,0);break;default:case"x":l=new A(1,0,0);break}for(let[u,c]of this.children.entries()){c.scale.x=n.scale[0],c.scale.y=n.scale[1],c.scale.z=n.scale[2],c.position.setScalar(0);let h=o/t.count*u-i;switch(n.axis){case"x":c.rotation.set(0,h,0);break;case"y":c.rotation.set(0,0,h);break;case"z":c.rotation.set(h,0,0);break}c.translateOnAxis(l,n.radius),c.position.x+=n.position[0],c.position.y+=n.position[1],c.position.z+=n.position[2],n.alignment===!0?(c.rotation.x+=a.x,c.rotation.y+=a.y,c.rotation.z+=a.z):c.rotation.copy(a)}}_updateLinear(t){if(t.type!=="linear")throw new Error;let n=t.linear,i=new Qt(n.rotation[0]*Be.DEG2RAD,n.rotation[1]*Be.DEG2RAD,n.rotation[2]*Be.DEG2RAD);for(let[s,o]of this.children.entries())o.scale.x=1+(n.scale[0]-1)*s,o.scale.y=1+(n.scale[1]-1)*s,o.scale.z=1+(n.scale[2]-1)*s,o.rotation.x=i.x*s,o.rotation.y=i.y*s,o.rotation.z=i.z*s,o.position.x=n.position[0]*s,o.position.y=n.position[1]*s,o.position.z=n.position[2]*s}_updateGrid(t){let n=0,i=t.grid;if(i.useCenter===!0){let s={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},o=new A(i.size[0]*(i.count[0]-s.x)*.5,i.size[1]*(i.count[1]-s.y)*.5,i.size[2]*(i.count[2]-s.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let u=0;u<i.count[2];u++){let c=this.children[n++];c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=i.size[0]*a-o.x,c.position.y=i.size[1]*l-o.y,c.position.z=i.size[2]*u-o.z}}else for(let s=0;s<i.count[0];s++)for(let o=0;o<i.count[1];o++)for(let a=0;a<i.count[2];a++){let l=this.children[n++];l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*s,l.position.y=-i.size[1]*o,l.position.z=-i.size[2]*a}}fromClonerState(t){return t.hideBase!==void 0&&this.setHideBase(t.hideBase),Jo(this.parameters,t),this.update(),this}};var Bi=r=>{var e;return e=class extends r{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new ur(30,30,30),e};var Gp=new oi,Gv=new En,I_=new be,Fi=(r,e,t,n,i=!1)=>{let s=e,o=r.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Gv.copy(s.boundingSphere),Gv.applyMatrix4(o),t.ray.intersectsSphere(Gv)===!1||(I_.copy(o).invert(),Gp.copy(t.ray).applyMatrix4(I_),s.boundingBox!==null&&Gp.intersectsBox(s.boundingBox)===!1))return;let a,l,u,c,h=s.index,d=s.attributes.position,f=s.drawRange,m,p;if(i===!1){let v=Math.max(0,f.start),y=Math.min(h.count,f.start+f.count);for(m=v,p=y;m<p;m+=3)if(l=h.getX(m),u=h.getX(m+1),c=h.getX(m+2),a=g(r,t,Gp,d,l,u,c),a){a.faceIndex=Math.floor(m/3),n.push(a);return}}else{let y=s.attributes.position,b=new A,w=new A,S=new A,_=new A,M=2,T=1/((r.scale.x+r.scale.y+r.scale.z)/3),E=T*T,C=Math.max(0,f.start),P=Math.min(y.count,f.start+f.count);for(let O=C,D=P-1;O<D;O+=M){if(b.fromBufferAttribute(y,O),w.fromBufferAttribute(y,O+1),Gp.distanceSqToSegment(b,w,_,S)>E)continue;_.applyMatrix4(r.matrixWorld);let F=t.ray.origin.distanceTo(_);F<t.near||F>t.far||n.push({distance:F,point:S.clone().applyMatrix4(r.matrixWorld),object:r})}}function g(v,y,b,w,S,_,M){let x=new A,T=new A,E=new A,C=new A,P=new A;if(x.fromBufferAttribute(w,S),T.fromBufferAttribute(w,_),E.fromBufferAttribute(w,M),b.intersectTriangle(x,T,E,!1,C)===null)return null;P.copy(C),P.applyMatrix4(v.matrixWorld);let D=y.ray.origin.distanceTo(P);return D<y.near||D>y.far?null:{faceIndex:1,distance:D,point:P.clone(),object:v}}};var zp=new A,Qr=new ai,zv=class extends Vs{constructor(t){let n=new De,i=new zr({color:16777215,vertexColors:!0,toneMapped:!1}),s=[],o=[],a={},l=new Le(15711266),u=new Le(15711266),c=new Le(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",u),h("p","n2",u),h("p","n3",u),h("p","n4",u),h("u1","u2",c),h("u2","u3",c),h("u3","u1",c);function h(f,m,p){d(f,p),d(m,p)}function d(f,m){s.push(0,0,0),o.push(m.r,m.g,m.b),a[f]===void 0&&(a[f]=[]),a[f].push(s.length/3-1)}n.setAttribute("position",new Ae(s,3)),n.setAttribute("color",new Ae(o,3));super(n,i);this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let t=this.geometry,n=this.pointMap,i=!0;Qr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let s=1,o=1,a=i?.8:1e-4;di("n1",n,t,Qr,-s,-o,a),di("n2",n,t,Qr,s,-o,a),di("n3",n,t,Qr,-s,o,a),di("n4",n,t,Qr,s,o,a);let l=a;di("f1",n,t,Qr,-s,-o,l),di("f2",n,t,Qr,s,-o,l),di("f3",n,t,Qr,-s,o,l),di("f4",n,t,Qr,s,o,l);let u=l,c=.5;di("u1",n,t,Qr,s*.7*c,o*1.1,u),di("u2",n,t,Qr,-s*.7*c,o*1.1,u),di("u3",n,t,Qr,0,o*(1.1+.9*c),u),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function di(r,e,t,n,i,s,o){zp.set(i,s,o).unproject(n);let a=e[r];if(a!==void 0){let l=t.getAttribute("position");for(let u=0,c=a.length;u<c;u++)l.setXYZ(a[u],zp.x,zp.y,zp.z)}}var kp=class extends Bi(zv){constructor(t){super(t);this.object=t;this.object=t,this.name=`CombinedCameraHelper: ${t.uuid}`}updateMatrixWorld(t){super.updateMatrixWorld(t),this.updateTarget()}updateTarget(){let t=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(t)}raycast(t,n){Fi(this.object,this.geometry,t,n,!0)}};var dc=class extends Bi(uf){constructor(t,n=15,i=10066329){super(t,n,i);this.object=t;this.added=!1;this.name=`DirectionalLightHelper: ${t.uuid}`}raycast(t,n){Fi(this.object,dc.geometryHelper,t,n)}};var fc=class extends Bi(hf){constructor(t,n=15){super(n);this.object=t;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${t.uuid}`,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}raycast(t,n){Fi(this.object,fc.geometryHelper,t,n)}update(){}};var pc=class extends Bi(cf){constructor(t,n=15,i=6710886){super(t,n,i);this.object=t;this.name=`PointLightHelper: ${t.uuid}`}raycast(t,n){Fi(this.object,pc.geometryHelper,t,n)}};var Vp=class extends Bi(lf){constructor(t,n=6710886){super(t,n);this.object=t;this.name=`SpotLightHelper: ${t.uuid}`}raycast(t,n){Fi(this.object,Vp.geometryHelper,t,n)}update(){if(this.object!==void 0){let t=Vp._vector,n=this.object.distance?this.object.distance:1e3,i=n*Math.tan(this.object.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(t);let s=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let o=0,a=this.cone.material.length;o<a;o++)this.cone.material[o].color.set(s);else this.cone.material.color.set(s)}}},ph=Vp;ph._vector=new A;var mh=1e-12,mc=class{constructor(e){this.position=new B;this.startPosition=new B;this.uuid=Be.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new mc(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},gc=class extends mc{constructor(t){super(t.position);this.parent=t}copy(t){return super.copy(t),this}clone(){return new gc(this.parent).copy(this)}},fi=class extends mc{constructor(t,n){super(n);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=t,this.controls.push(new gc(this),new gc(this))}static create(t,n){let i=new fi(t,new B(...n.position));return i.controls[0].position.set(...n.controlPrevious.position),i.controls[1].position.set(...n.controlNext.position),i.roundness=n.roundness,i.areControlsDirectionsMirrored=n.areControlsDirectionsMirrored,i}getOppositeControl(t){let n=this.controls.indexOf(t);return n===0?this.controls[1]:n===1?this.controls[0]:null}applyOffsetToControls(t,n=1){for(let i=0,s=this.controls.length;i<s;i++){let o=this.controls[i];this.position.distanceTo(o.position)<=n?o.position.copy(this.position):o.applyOffset(t)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(t){return super.copy(t),this.controls[0].copy(t.controls[0]),this.controls[1].copy(t.controls[1]),this.roundness=t.roundness,this.uuid=t.uuid,this}clone(){return new fi(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let t=this.curveBefore?.getTangentAt(1),n=this.curveAfter?.getTangentAt(0);return[t,n]}computeNormals(t=new B,n=new B){let[i,s]=this.computeTangents();return i&&s&&(L_(i,t),L_(s,n)),[t,n]}computeTangent(t=new B){let[n,i]=this.computeTangents();return n&&i&&t.copy(n).add(i).normalize(),t}computeNormal(t=new B){let[n,i]=this.computeNormals();return t.copy(n).add(i).normalize(),t}};function L_(r,e=new B){let t=r.length();return e.set(-r.y/t,r.x/t)}var Vv=r=>r,yc=new B,Hp=new B,dz=new B,fz=new B,pz=new B,mz=new B,R_=new A,N_=new A;function B_(r){let e=new B;e.addVectors(r.v0,yc.subVectors(r.v1,r.v0).multiplyScalar(2/3));let t=new B;return t.addVectors(r.v2,Hp.subVectors(r.v1,r.v2).multiplyScalar(2/3)),new Wn(r.v0,e,t,r.v2)}function gh(r,e,t=Number.EPSILON){return Math.abs(r-e)<t}function gz(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function yz(r,e,t=Number.EPSILON){return r.distanceTo(e)<t}function Hv(r,e,t){let n=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),i=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2));return Math.acos((i*i+n*n-s*s)/(2*i*n))}function F_(r,e,t){return O_(r,e)&&O_(e,t)&&kv(r.position,e.position,t.position)}function kv(r,e,t){return yc.copy(e).sub(r).cross(Hp.copy(t).sub(r))===0}function U_(r,e,t,n,i){let s=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2)),o=(r.y+e.y)/2,a=(r.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(r.y-e.y)/s,u=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-r.x)/s;return n.set(a+l,o+u),i.set(a-l,o-u),[n,i]}function G_(r,e,t){let n=r.distanceTo(t),i=e.distanceTo(t);return n<i?e:r}function z_(r,e,t,n,i,s){let o=e.x-r.x,a=e.y-r.y,l=t.x-r.x,u=t.y-r.y,c=Math.sqrt((o+l)*(o+l)+(a+u)*(a+u)),h;return Hv(e,r,t)>Math.PI&&(c*=-1),gh(u,a)?h=(a+u)*(n/c-.5)*8/3/(o-l):h=(o+l)*(n/c-.5)*8/3/(u-a),i.set(e.x-h*a,e.y+h*o),s.set(t.x+h*u,t.y-h*l),[i,s]}function Wv(r,e){return r.position.equals(r.controls[1].position)&&e.position.equals(e.controls[0].position)}function O_(r,e){return kv(r.position,r.controls[1].position,e.position)&&kv(r.position,e.controls[0].position,e.position)}function k_(r,e,t,n,i=.5){let s=yc.subVectors(e,r).multiplyScalar(i).add(r),o=Hp.subVectors(t,e).multiplyScalar(i).add(e),a=dz.subVectors(n,t).multiplyScalar(i).add(t),l=s,u=fz.subVectors(o,s).multiplyScalar(i).add(s),c=pz.subVectors(a,o).multiplyScalar(i).add(o),h=a,d=mz.subVectors(c,u).multiplyScalar(i).add(u);return[r.x,r.y,l.x,l.y,u.x,u.y,d.x,d.y,c.x,c.y,h.x,h.y,n.x,n.y]}function V_(r,e,t=12,n=!0){let i=N_.set(0,0,0),s,o=0,a=[];for(let l=0;l<e.length;l++){let u=Vv(e[l]),c=yc,h=uo(u,t);a.push(h);for(let d=0;d<=h;d++)if(u instanceof Wn||u instanceof Er||u instanceof jn){if(u.getPoint(d/h,c),i.set(c.x,c.y,0),s!==void 0&&yz(s,i))continue;s===void 0&&(s=R_),s.copy(i),r.setXYZ(o,i.x,i.y,i.z),o++}}return n&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),r}function H_(r,e,t,n=12,i=!0){let s=N_.set(0,0,0),o=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let u,c=Vv(e[l]),h=yc,d=uo(c,n);a.push(d);for(let f=0;f<=d;f++)if(c instanceof Wn||c instanceof Er||c instanceof jn){if(c.getPoint(f/d,h),s.set(h.x,h.y,0),u?.equals(s))continue;u===void 0?u=R_:(r.setXYZ(o,u.x,u.y,u.z),o++,r.setXYZ(o,s.x,s.y,s.z),o++),u.copy(s)}}return i&&o>1&&!(r.getX(o-1)===r.getX(0)&&r.getY(o-1)===r.getY(0)&&r.getZ(o-1)===r.getZ(0))&&(r.setXYZ(o,r.getX(0),r.getY(0),r.getZ(0)),o++),a}function jv(r,e=12,t=!1){let n=[];for(let i=0,s=r.length;i<s;i++){let o=r[i],a=0;if(t&&o.roundedCurveCorner!==void 0){let l=uo(o.roundedCurveCorner,e)*.5;i>0&&(n[i-1]+=l),a+=l}o.curveAfter!==void 0&&(a+=uo(o.curveAfter,e)),n.push(a)}return r.length>0&&t&&r[0].roundedCurveCorner!==void 0&&(n[r.length-1]+=uo(r[0].roundedCurveCorner,e)*.5),n}function uo(r,e=12){return r&&r instanceof ko?e*2:r&&(r instanceof jn||r instanceof Mu)?1:r&&r instanceof Ja?e*r.points.length:e}function W_(r,e,t=12,n=!0){let i,s=0;for(let o=0;o<e.length;o++){let a=Vv(e[o]),l=uo(a,t),u=yc;for(let c=0;c<=l;c++)if(a instanceof Wn||a instanceof Er||a instanceof jn){if(a.getPoint(c/l,u),i!==void 0&&gz(i,u,mh))continue;i===void 0&&(i=Hp),i.copy(u),r.push(u.x,u.y),s++}}return gh(r[0],r[r.length-2],mh)&&gh(r[1],r[r.length-1],mh)&&(r.pop(),r.pop()),n&&s>1&&!(gh(r[s-1],r[1],mh)&&gh(r[s-2],r[0],mh))&&(r.push(r[0],r[1]),s++),r}var qv=new B,vz=new B,xz=new B,bz=new B,wz=new B,Sz=new B,gt=class extends ds{constructor(t=100,n=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Lt;this.plane=new mn(new A(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=Be.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=t,this._height=n}static createFromState(t,n,i){let s=new gt;return s.isClosed=t.isClosed,s.points=t.points.map(o=>fi.create(o.id,o.data)),typeof t.roundness=="number"&&(s.roundness=t.roundness),s.shapeHoles=t.shapeHoles.map(o=>gt.createFromState(o)),n!==void 0&&i!==void 0&&s.applySize(n,i),s.update(),s}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(t){if(this._roundness!==t){this._roundness=t;for(let n=0,i=this.points.length;n<i;n++)this.points[n].roundness=t;this.needsUpdate=!0}}getPointsIndexesByIds(t){return t.map(n=>this.getPointIndexById(n)).filter(n=>n>=0)}getPointIndexById(t){let n=this.points.length,i=this.points.findIndex(s=>s.uuid===t);if(i<0){let s=n;for(let o=0,a=this.shapeHoles.length;o<a;o++){let l=this.shapeHoles[o],u=l.points.length,c=l.getPointIndexById(t);if(c<0)s+=u;else return c+s}}return i}getLineIndexById(t){return this.getPointIndexById(t)}getBezierPoint(t){if(t<=this.points.length-1)return this.points[t];if(this.shapeHoles.length>0){let n=this.points.length;for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=t-n;if(a<=o.points.length-1)return o.points[a];n+=o.points.length}}throw new Error("This shape does not have a point for this index: "+t)}getBezierPointIndex(t){let n=this.points.indexOf(t);if(n>=0)return n;if(n=this.points.length,this.shapeHoles.length>0)for(let i=0,s=this.shapeHoles.length;i<s;i++){let o=this.shapeHoles[i],a=o.points.indexOf(t);if(a>=0)return n+a;n+=o.points.length}return-1}getAllPoints(){let t=[].concat(...this.shapeHoles.map(n=>n.points));return[...this.points,...t]}applySize(t,n){t===0&&(t=.001),n===0&&(n=.001),this._width=t,this._height=n}applyScale(t,n){let i=qv.set(t,n);for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let s=0,o=this.shapeHoles.length;s<o;s++)this.shapeHoles[s].applyScale(t,n);this._update(!1)}createPoint(t,n=0,i=Be.generateUUID()){let s;t instanceof B?s=t:s=new B(t,n);let o=new fi(i,s);return o.roundness=this.roundness,o}addPoint(t){this.points.push(t),this.needsUpdate=!0}addPointAt(t,n){this.points.splice(n,0,t),this.needsUpdate=!0}getPointByUuid(t){for(let n=0,i=this.points.length;n<i;n++){let s=this.points[n];if(s.uuid===t)return s}for(let n=0,i=this.shapeHoles.length;n<i;n++){let o=this.shapeHoles[n].getPointByUuid(t);if(o)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(t){let n=this.points.indexOf(t);n>=0&&this.points.splice(n,1),this.needsUpdate=!0}removePointById(t){let n=this.points.find(i=>i.uuid===t);n&&this.removePoint(n)}update(t=!0){for(let n=0,i=this.shapeHoles.length;n<i;n++)this.shapeHoles[n].update(!1);this._update(t)}extractShapePointsToBuffer(t,n=12,i=!1){this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n);let s=i?this.roundedCurveDivisions:this.curveDivisions;return V_(t,i?this.roundedCurves:this.curves,n,this.autoClose),s.reduce((o,a)=>o+a,0)+1}computeCurveDivisions(t=12){return this.curveDivisions=jv(this.points,t,!1),this.roundedCurveDivisions=jv(this.points,t,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(t,n,i=12){return H_(t,this.curves,n,i,this.autoClose).reduce((o,a)=>o+a,0)*2}extractShapePointsToFlatArray(t,n=12){return this.subdivision=n,this.curveDivisions===void 0&&this.computeCurveDivisions(n),W_(t,this.roundedCurves,n,this.autoClose)}getCurveIndexFromVertexId(t,n=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let s=n?this.roundedCurveDivisions:this.curveDivisions,o=0;n&&this.points[0].roundedCurveCorner!==void 0&&(o=uo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=t-o;a<0&&(a+=s.reduce((l,u)=>l+u,0));for(let l=0,u=s.length;l<u;l++){let c=s[l];if(a<i+c)return[l,(a-i+1)/c];i+=c}return[0,1]}getCurveT(t,n,i){let s=this.points[t],o=this.points[t>=this.points.length-1?0:t+1],a=this.curveDivisions,l=a[t];if(Wv(s,o)){let h=s.position.distanceTo(o.position);return s.position.distanceTo(qv.set(i.x,i.y))/h}let u=0;for(let h=0;h<t;h++)u+=a[h];return(n-u)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(t,n){Wv(n,t)?this.lineTo(t.position.x,t.position.y):this.bezierCurveTo(n.controls[1].position.x,n.controls[1].position.y,t.controls[0].position.x,t.controls[0].position.y,t.position.x,t.position.y);let i=this.curves[this.curves.length-1];t.curveBefore=i,n.curveAfter=i;let s=i.clone();t.roundedCurveBefore=s,n.roundedCurveAfter=s,t.roundedCurveCorner=void 0,this.roundedCurves.push(s)}_update(t=!0){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let i=0,s=this.points.length;i<s;i++){let o=this.points[i];if(i===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[i-1];this._applyCurveForPoint(o,a)}}let n=this.getLastPoint();if(n?.curveAfter&&(n.curveAfter=void 0),this.isClosed){let i=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(i,s)}if(this.points.length>2){let i=0;for(let s=0,o=this.points.length;s<o;s++){let a=this.points[s],l=this.points[s-1]??this.points[this.points.length-1],u=this.points[s+1]??this.points[0],c=a.roundness,h=l&&u&&F_(l,a,u);if(!a.controlsMoved()&&c>0&&!h){let d=a.curveBefore,f=a.curveAfter;if(d===void 0||f===void 0)continue;let m=a.roundedCurveBefore,p=a.roundedCurveAfter,g=d.getLength(),v=f.getLength(),y=Math.min(c,g*.499),b=Math.min(c,v*.499),w=Math.min(y,b),S=1-w/g,_=w/v,M=d.getPointAt(S,qv),x=f.getPointAt(_,vz);this._subSplitCurve(d,m,S,M,void 0),this._subSplitCurve(f,p,_,void 0,x);let T;if(this.useCubicForRoundedCorners){let E=Hv(M,a.position,x)/2,C=Math.tan(E)*M.distanceTo(a.position),[P,O]=U_(M,x,C,xz,bz),D=G_(P,O,a.position),[N,F]=z_(D,M,x,C,wz,Sz);T=new Wn(M.clone(),N.clone(),F.clone(),x.clone())}else T=new Er(M.clone(),a.position.clone(),x.clone());a.roundedCurveCorner=T,this.roundedCurves.splice(s+i,0,T),i++}}}t&&this.eventDispatcher?.dispatchEvent({type:"update"})}_subSplitCurve(t,n,i,s,o){if(t instanceof jn)s!==void 0&&n.v2.copy(s),o!==void 0&&n.v1.copy(o);else{let a=t,l=n,u=a.getUtoTmapping(i,0),c=k_(a.v0,a.v1,a.v2,a.v3,u);return s!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),o!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return n}clone(){let t=new gt(this._width,this._height);return t.points=this.points.map(n=>n.clone()),t.isClosed=this.isClosed,t.roundness=this.roundness,t.isMesh2D=this.isMesh2D,t.shapeHoles=this.shapeHoles.map(n=>n.clone()),t}toJSON(){return{points:this.points.reduce((t,n)=>t.concat(n.toJSON()),[]),shapeHoles:this.shapeHoles.map(t=>t.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(t){this.points=[],this.pointIDs=0;let n=t.points.length/7;for(let i=0;i<n;i++){let s=i*7,o=t.points[s+0],a=t.points[s+1],l=t.points[s+2],u=t.points[s+3],c=t.points[s+4],h=t.points[s+5],d=t.points[s+6],f=new fi(Be.generateUUID(),new B(o,a));f.controls[0].position.set(l,u),f.controls[1].position.set(c,h),f.roundness=d,this.points.push(f)}return this.shapeHoles=t.shapeHoles?.length?t.shapeHoles.map(i=>{let s=new gt;return s.fromJSON(i),s}):[],this.isClosed=t.isClosed,this._roundness=t.roundness,this._update(),this}fromShape(t){let n=(s,o)=>{o instanceof Wn&&o.v3.equals(s.position)&&s.controls[0].position.copy(o.v2)},i=s=>{let o=[],a,l;for(a=0,l=s.length;a<l;a++)s[a]instanceof Er&&(s[a]=B_(s[a]));for(a=0,l=s.length;a<l;a++){let h=s[a],d=a>0?s[a-1]:null,f;h instanceof Wn?(f=this.createPoint(h.v0),f.controls[1].position.copy(h.v1)):h instanceof jn&&(f=this.createPoint(h.v1)),f!==void 0&&(d!==null&&n(f,d),o.push(f))}let u=s[s.length-1],c=!1;return u instanceof Wn?u.v3.equals(o[0].position)&&(o[0].controls[0].position.copy(u.v2),c=!0):u instanceof jn&&u.v2.equals(o[0].position)&&(c=!0),this.isClosed=c,o};return this.points=i(t.curves),t instanceof ds&&(this.shapeHoles=t.holes.map(s=>{let o=new gt;return o.fromShape(s),o})),this.update(),this}};var It;(function(r){r[r.ODD=0]="ODD",r[r.NONZERO=1]="NONZERO",r[r.POSITIVE=2]="POSITIVE",r[r.NEGATIVE=3]="NEGATIVE",r[r.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(It||(It={}));var xn;(function(r){r[r.POLYGONS=0]="POLYGONS",r[r.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",r[r.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(xn||(xn={}));function We(r,e){if(!r)throw e||"Assertion Failed!"}var ze=function(){function r(){}return r.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},r.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},r.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},r.edgeGoesLeft=function(e){return r.vertLeq(e.Dst,e.Org)},r.edgeGoesRight=function(e){return r.vertLeq(e.Org,e.Dst)},r.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},r.edgeEval=function(e,t,n){We(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?i<s?t.t-e.t+(e.t-n.t)*(i/(i+s)):t.t-n.t+(n.t-e.t)*(s/(i+s)):0},r.edgeSign=function(e,t,n){We(r.vertLeq(e,t)&&r.vertLeq(t,n));var i=t.s-e.s,s=n.s-t.s;return i+s>0?(t.t-n.t)*i+(t.t-e.t)*s:0},r.transEval=function(e,t,n){We(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?i<s?t.s-e.s+(e.s-n.s)*(i/(i+s)):t.s-n.s+(n.s-e.s)*(s/(i+s)):0},r.transSign=function(e,t,n){We(r.transLeq(e,t)&&r.transLeq(t,n));var i=t.t-e.t,s=n.t-t.t;return i+s>0?(t.s-n.s)*i+(t.s-e.s)*s:0},r.vertCCW=function(e,t,n){return e.s*(t.t-n.t)+t.s*(n.t-e.t)+n.s*(e.t-t.t)>=0},r.interpolate=function(e,t,n,i){return e=e<0?0:e,n=n<0?0:n,e<=n?n===0?(t+i)/2:t+(i-t)*(e/(e+n)):i+(t-i)*(n/(e+n))},r.intersect=function(e,t,n,i,s){var o,a,l;r.vertLeq(e,t)||(l=e,e=t,t=l),r.vertLeq(n,i)||(l=n,n=i,i=l),r.vertLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.vertLeq(n,t)?r.vertLeq(t,i)?(o=r.edgeEval(e,n,t),a=r.edgeEval(n,t,i),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,t.s)):(o=r.edgeSign(e,n,t),a=-r.edgeSign(e,i,t),o+a<0&&(o=-o,a=-a),s.s=r.interpolate(o,n.s,a,i.s)):s.s=(n.s+t.s)/2,r.transLeq(e,t)||(l=e,e=t,t=l),r.transLeq(n,i)||(l=n,n=i,i=l),r.transLeq(e,n)||(l=e,e=n,n=l,l=t,t=i,i=l),r.transLeq(n,t)?r.transLeq(t,i)?(o=r.transEval(e,n,t),a=r.transEval(n,t,i),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,t.t)):(o=r.transSign(e,n,t),a=-r.transSign(e,i,t),o+a<0&&(o=-o,a=-a),s.t=r.interpolate(o,n.t,a,i.t)):s.t=(n.t+t.t)/2},r}(),yh=function(){function r(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return r}(),Wp=function(){function r(e){this.side=e,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(r.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),r}(),vc=function(){function r(){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 r}(),j_=function(){function r(){var e=new vc,t=new yh,n=new Wp(0),i=new Wp(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,n.next=n,n.Sym=i,i.next=i,i.Sym=n,this.vHead=e,this.fHead=t,this.eHead=n,this.eHeadSym=i}return r.prototype.makeEdge_=function(e){var t=new Wp(0),n=new Wp(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return n.next=i,i.Sym.next=t,t.next=e,e.Sym.next=n,t.Sym=n,t.Onext=t,t.Lnext=n,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,n.Sym=t,n.Onext=n,n.Lnext=t,n.Org=null,n.Lface=null,n.winding=0,n.activeRegion=null,t},r.prototype.splice_=function(e,t){var n=e.Onext,i=t.Onext;n.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=n},r.prototype.makeVertex_=function(e,t,n){var i=e;We(i,"Vertex can't be null!");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t;var o=t;do o.Org=i,o=o.Onext;while(o!==t)},r.prototype.makeFace_=function(e,t,n){var i=e;We(i,"Face can't be null");var s=n.prev;i.prev=s,s.next=i,i.next=n,n.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=n.inside;var o=t;do o.Lface=i,o=o.Lnext;while(o!==t)},r.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,n=e.Sym.next;t.Sym.next=n,n.Sym.next=t},r.prototype.killVertex_=function(e,t){var n=e.anEdge,i=n;do i.Org=t,i=i.Onext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.killFace_=function(e,t){var n=e.anEdge,i=n;do i.Lface=t,i=i.Lnext;while(i!==n);var s=e.prev,o=e.next;o.prev=s,s.next=o},r.prototype.makeEdge=function(){var e=new vc,t=new vc,n=new yh,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(n,i,this.fHead),i},r.prototype.splice=function(e,t){var n=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var s=new vc;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!n){var o=new yh;this.makeFace_(o,t,e.Lface),e.Lface.anEdge=e}}},r.prototype.delete=function(e){var t=e.Sym,n=!1;if(e.Lface!==e.Rface&&(n=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!n){var i=new yh;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},r.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),n=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new vc;return this.makeVertex_(i,n,t.Org),t.Lface=n.Lface=e.Lface,t},r.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),n=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,n),e.Dst=n.Org,n.Dst.anEdge=n.Sym,n.Rface=e.Rface,n.winding=e.winding,n.Sym.winding=e.Sym.winding,n.idx=e.idx,n.Sym.idx=e.Sym.idx,n},r.prototype.connect=function(e,t){var n=!1,i=this.makeEdge_(e),s=i.Sym;if(t.Lface!==e.Lface&&(n=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(s,t),i.Org=e.Dst,s.Org=t.Org,i.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!n){var o=new yh;this.makeFace_(o,i,e.Lface)}return i},r.prototype.zapFace=function(e){var t=e.anEdge,n,i,s,o,a;i=t.Lnext;do n=i,i=n.Lnext,n.Lface=null,n.Rface===null&&(n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),s=n.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(n));while(n!=t);o=e.prev,a=e.next,a.prev=o,o.next=a},r.prototype.countFaceVerts_=function(e){var t=e.anEdge,n=0;do n++,t=t.Lnext;while(t!==e.anEdge);return n},r.prototype.mergeConvexFaces=function(e){var t,n,i,s,o,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(n=t.anEdge,o=n.Org;i=n.Lnext,s=n.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&ze.vertCCW(n.Lprev.Org,n.Org,s.Lnext.Lnext.Org)&&ze.vertCCW(s.Lprev.Org,s.Org,n.Lnext.Lnext.Org)&&(i=s.Lnext,this.delete(s),n=null,s=null)),!(n&&n.Lnext.Org===o);)n=i;return!0},r.prototype.check=function(){var e=this.fHead,t=this.vHead,n=this.eHead,i,s,o,a,l,u;for(s=e,s=e;(i=s.next)!==e;s=i){We(i.prev===s),l=i.anEdge;do We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l),We(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(We(i.prev===s&&i.anEdge===null),a=t,a=t;(o=a.next)!==t;a=o){We(o.prev===a),l=o.anEdge;do We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l),We(l.Org===o),l=l.Onext;while(l!==o.anEdge)}for(We(o.prev===a&&o.anEdge===null),u=n,u=n;(l=u.next)!==n;u=l)We(l.Sym.next===u.Sym),We(l.Sym!==l),We(l.Sym.Sym===l),We(l.Org!==null),We(l.Dst!==null),We(l.Lnext.Onext.Sym===l),We(l.Onext.Sym.Lnext===l);We(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},r}(),q_=function(){function r(){this.handle=null}return r}(),X_=function(){function r(){this.key=null,this.node=0}return r}(),Az=function(){function r(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var n=0;n<e+1;n++)this.nodes[n]=new q_,this.handles[n]=new X_;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return r.prototype.floatDown_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e<<1,o<this.size&&this.leq(n[t[o+1].handle].key,n[t[o].handle].key)&&++o,We(o<=this.max),s=t[o].handle,o>this.size||this.leq(n[i].key,n[s].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.floatUp_=function(e){var t=this.nodes,n=this.handles,i,s,o;for(i=t[e].handle;;){if(o=e>>1,s=t[o].handle,o===0||this.leq(n[s].key,n[i].key)){t[e].handle=i,n[i].node=e;break}t[e].handle=s,n[s].node=e,e=o}},r.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},r.prototype.min=function(){return this.handles[this.nodes[1].handle].key},r.prototype.insert=function(e){var t,n;if(t=++this.size,t*2>this.max){this.max*=2;var i,s;for(s=this.nodes.length,this.nodes.length=this.max+1,i=s;i<this.nodes.length;i++)this.nodes[i]=new q_;for(s=this.handles.length,this.handles.length=this.max+1,i=s;i<this.handles.length;i++)this.handles[i]=new X_}return this.freeList===0?n=t:(n=this.freeList,this.freeList=this.handles[n].node),this.nodes[t].handle=n,this.handles[n].node=t,this.handles[n].key=e,this.initialized&&this.floatUp_(t),n},r.prototype.extractMin=function(){var e=this.nodes,t=this.handles,n=e[1].handle,i=t[n].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[n].key=null,t[n].node=this.freeList,this.freeList=n,--this.size,this.size>0&&this.floatDown_(1)),i},r.prototype.delete=function(e){var t=this.nodes,n=this.handles,i;We(e>=1&&e<=this.max&&n[e].key!==null),i=n[e].node,t[i].handle=t[this.size].handle,n[t[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(n[t[i>>1].handle].key,n[t[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),n[e].key=null,n[e].node=this.freeList,this.freeList=e},r}(),Xv=function(){function r(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return r}(),Y_=function(){function r(){this.key=null,this.next=null,this.prev=null}return r}(),_z=function(){function r(e,t){this.frame=e,this.leq=t,this.head=new Y_,this.head.next=this.head,this.head.prev=this.head}return r.prototype.min=function(){return this.head.next},r.prototype.max=function(){return this.head.prev},r.prototype.insert=function(e){return this.insertBefore(this.head,e)},r.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},r.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var n=new Y_;return n.key=t,n.next=e.next,e.next.prev=n,n.prev=e,e.next=n,n},r.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},r}(),Tz=function(){function r(){}return r.regionBelow=function(e){return e.nodeUp.prev.key},r.regionAbove=function(e){return e.nodeUp.next.key},r.debugEvent=function(e){},r.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.edgeLeq=function(e,t,n){var i=e.event,s=t.eUp,o=n.eUp;if(s.Dst===i)return o.Dst===i?ze.vertLeq(s.Org,o.Org)?ze.edgeSign(o.Dst,s.Org,o.Org)<=0:ze.edgeSign(s.Dst,o.Org,s.Org)>=0:ze.edgeSign(o.Dst,i,o.Org)<=0;if(o.Dst===i)return ze.edgeSign(s.Dst,i,s.Org)>=0;var a=ze.edgeEval(s.Dst,i,s.Org),l=ze.edgeEval(o.Dst,i,o.Org);return a>=l},r.deleteRegion=function(e,t){t.fixUpperEdge&&We(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},r.fixUpperEdge=function(e,t,n){We(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=n,n.activeRegion=t},r.topLeftRegion=function(e,t){var n=t.eUp.Org,i;do t=r.regionAbove(t);while(t.eUp.Org===n);if(t.fixUpperEdge){if(i=e.mesh.connect(r.regionBelow(t).eUp.Sym,t.eUp.Lnext),i===null)return null;r.fixUpperEdge(e,t,i),t=r.regionAbove(t)}return t},r.topRightRegion=function(e){var t=e.eUp.Dst;do e=r.regionAbove(e);while(e.eUp.Dst===t);return e},r.addRegionBelow=function(e,t,n){var i=new Xv;return i.eUp=n,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,n.activeRegion=i,i},r.isWindingInside=function(e,t){switch(e.windingRule){case It.ODD:return(t&1)!==0;case It.NONZERO:return t!==0;case It.POSITIVE:return t>0;case It.NEGATIVE:return t<0;case It.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},r.computeWinding=function(e,t){t.windingNumber=r.regionAbove(t).windingNumber+t.eUp.winding,t.inside=r.isWindingInside(e,t.windingNumber)},r.finishRegion=function(e,t){var n=t.eUp,i=n.Lface;i.inside=t.inside,i.anEdge=n,r.deleteRegion(e,t)},r.finishLeftRegions=function(e,t,n){for(var i,s=null,o=t,a=t.eUp;o!==n;){if(o.fixUpperEdge=!1,s=r.regionBelow(o),i=s.eUp,i.Org!=a.Org){if(!s.fixUpperEdge){r.finishRegion(e,o);break}i=e.mesh.connect(a.Lprev,i.Sym),r.fixUpperEdge(e,s,i)}a.Onext!==i&&(e.mesh.splice(i.Oprev,i),e.mesh.splice(a,i)),r.finishRegion(e,o),a=s.eUp,o=s}return a},r.addRightEdges=function(e,t,n,i,s,o){var a,l,u,c,h=!0;u=n;do We(ze.vertLeq(u.Org,u.Dst)),r.addRegionBelow(e,t,u.Sym),u=u.Onext;while(u!==i);for(s===null&&(s=r.regionBelow(t).eUp.Rprev),l=t,c=s;a=r.regionBelow(l),u=a.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(e.mesh.splice(u.Oprev,u),e.mesh.splice(c.Oprev,u)),a.windingNumber=l.windingNumber-u.winding,a.inside=r.isWindingInside(e,a.windingNumber),l.dirty=!0,!h&&r.checkForRightSplice(e,l)&&(r.addWinding(u,c),r.deleteRegion(e,l),e.mesh.delete(c)),h=!1,l=a,c=u;l.dirty=!0,We(l.windingNumber-u.winding===a.windingNumber),o&&r.walkDirtyRegions(e,l)},r.spliceMergeVertices=function(e,t,n){e.mesh.splice(t,n)},r.vertexWeights=function(e,t,n){var i=ze.vertL1dist(t,e),s=ze.vertL1dist(n,e),o=.5*s/(i+s),a=.5*i/(i+s);e.coords[0]+=o*t.coords[0]+a*n.coords[0],e.coords[1]+=o*t.coords[1]+a*n.coords[1],e.coords[2]+=o*t.coords[2]+a*n.coords[2]},r.getIntersectData=function(e,t,n,i,s,o){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,r.vertexWeights(t,n,i),r.vertexWeights(t,s,o)},r.checkForRightSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp;if(ze.vertLeq(i.Org,s.Org)){if(ze.edgeSign(s.Dst,i.Org,s.Org)>0)return!1;ze.vertEq(i.Org,s.Org)?i.Org!==s.Org&&(e.pq.delete(i.Org.pqHandle),r.spliceMergeVertices(e,s.Oprev,i)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(i,s.Oprev),t.dirty=n.dirty=!0)}else{if(ze.edgeSign(i.Dst,s.Org,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Oprev,i)}return!0},r.checkForLeftSplice=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o;if(We(!ze.vertEq(i.Dst,s.Dst)),ze.vertLeq(i.Dst,s.Dst)){if(ze.edgeSign(i.Dst,s.Dst,i.Org)<0)return!1;r.regionAbove(t).dirty=t.dirty=!0,o=e.mesh.splitEdge(i),e.mesh.splice(s.Sym,o),o.Lface.inside=t.inside}else{if(ze.edgeSign(s.Dst,i.Dst,s.Org)>0)return!1;t.dirty=n.dirty=!0,o=e.mesh.splitEdge(s),e.mesh.splice(i.Lnext,s.Sym),o.Rface.inside=t.inside}return!0},r.checkForIntersect=function(e,t){var n=r.regionBelow(t),i=t.eUp,s=n.eUp,o=i.Org,a=s.Org,l=i.Dst,u=s.Dst,c,h,d=new vc,f,m;if(We(!ze.vertEq(u,l)),We(ze.edgeSign(l,e.event,o)<=0),We(ze.edgeSign(u,e.event,a)>=0),We(o!==e.event&&a!==e.event),We(!t.fixUpperEdge&&!n.fixUpperEdge),o===a||(c=Math.min(o.t,l.t),h=Math.max(a.t,u.t),c>h))return!1;if(ze.vertLeq(o,a)){if(ze.edgeSign(u,o,a)>0)return!1}else if(ze.edgeSign(l,a,o)<0)return!1;return r.debugEvent(e),ze.intersect(l,o,u,a,d),We(Math.min(o.t,l.t)<=d.t),We(d.t<=Math.max(a.t,u.t)),We(Math.min(u.s,l.s)<=d.s),We(d.s<=Math.max(a.s,o.s)),ze.vertLeq(d,e.event)&&(d.s=e.event.s,d.t=e.event.t),f=ze.vertLeq(o,a)?o:a,ze.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),ze.vertEq(d,o)||ze.vertEq(d,a)?(r.checkForRightSplice(e,t),!1):!ze.vertEq(l,e.event)&&ze.edgeSign(l,e.event,d)>=0||!ze.vertEq(u,e.event)&&ze.edgeSign(u,e.event,d)<=0?u===e.event?(e.mesh.splitEdge(i.Sym),e.mesh.splice(s.Sym,i),t=r.topLeftRegion(e,t),i=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),n),r.addRightEdges(e,t,i.Oprev,i,i,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(i.Lnext,s.Oprev),n=t,t=r.topRightRegion(t),m=r.regionBelow(t).eUp.Rprev,n.eUp=s.Oprev,s=r.finishLeftRegions(e,n,null),r.addRightEdges(e,t,s.Onext,i.Rprev,m,!0),!0):(ze.edgeSign(l,e.event,d)>=0&&(r.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(i.Sym),i.Org.s=e.event.s,i.Org.t=e.event.t),ze.edgeSign(u,e.event,d)<=0&&(t.dirty=n.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(i.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=e.pq.insert(i.Org),r.getIntersectData(e,i.Org,o,l,a,u),r.regionAbove(t).dirty=t.dirty=n.dirty=!0,!1)},r.walkDirtyRegions=function(e,t){for(var n=r.regionBelow(t),i,s;;){for(;n.dirty;)t=n,n=r.regionBelow(n);if(!t.dirty&&(n=t,t=r.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,i=t.eUp,s=n.eUp,i.Dst!==s.Dst&&r.checkForLeftSplice(e,t)&&(n.fixUpperEdge?(r.deleteRegion(e,n),e.mesh.delete(s),n=r.regionBelow(t),s=n.eUp):t.fixUpperEdge&&(r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n),i=t.eUp)),i.Org!==s.Org)if(i.Dst!==s.Dst&&!t.fixUpperEdge&&!n.fixUpperEdge&&(i.Dst===e.event||s.Dst===e.event)){if(r.checkForIntersect(e,t))return}else r.checkForRightSplice(e,t);i.Org===s.Org&&i.Dst===s.Dst&&(r.addWinding(s,i),r.deleteRegion(e,t),e.mesh.delete(i),t=r.regionAbove(n))}},r.connectRightVertex=function(e,t,n){var i,s=n.Onext,o=r.regionBelow(t),a=t.eUp,l=o.eUp,u=!1;if(a.Dst!==l.Dst&&r.checkForIntersect(e,t),ze.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=r.topLeftRegion(e,t),s=r.regionBelow(t).eUp,r.finishLeftRegions(e,r.regionBelow(t),o),u=!0),ze.vertEq(l.Org,e.event)&&(e.mesh.splice(n,l.Oprev),n=r.finishLeftRegions(e,o,null),u=!0),u){r.addRightEdges(e,t,n.Onext,s,s,!0);return}ze.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=e.mesh.connect(n.Lprev,i),r.addRightEdges(e,t,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,r.walkDirtyRegions(e,t)},r.connectLeftDegenerate=function(e,t,n){var i,s,o,a,l;if(i=t.eUp,ze.vertEq(i.Org,n)){We(!1),r.spliceMergeVertices(e,i,n.anEdge);return}if(!ze.vertEq(i.Dst,n)){e.mesh.splitEdge(i.Sym),t.fixUpperEdge&&(e.mesh.delete(i.Onext),t.fixUpperEdge=!1),e.mesh.splice(n.anEdge,i),r.sweepEvent(e,n);return}We(!1),t=r.topRightRegion(t),l=r.regionBelow(t),o=l.eUp.Sym,s=a=o.Onext,l.fixUpperEdge&&(We(s!==o),r.deleteRegion(e,l),e.mesh.delete(o),o=s.Oprev),e.mesh.splice(n.anEdge,o),ze.edgeGoesLeft(s)||(s=null),r.addRightEdges(e,t,o.Onext,a,s,!0)},r.connectLeftVertex=function(e,t){var n,i,s,o,a,l,u=new Xv;if(u.eUp=t.anEdge.Sym,n=e.dict.search(u).key,i=r.regionBelow(n),!!i){if(o=n.eUp,a=i.eUp,ze.edgeSign(o.Dst,t,o.Org)===0){r.connectLeftDegenerate(e,n,t);return}if(s=ze.vertLeq(a.Dst,o.Dst)?n:i,n.inside||s.fixUpperEdge){if(s===n)l=e.mesh.connect(t.anEdge.Sym,o.Lnext);else{var c=e.mesh.connect(a.Dnext,t.anEdge);l=c.Sym}s.fixUpperEdge?r.fixUpperEdge(e,s,l):r.computeWinding(e,r.addRegionBelow(e,n,l)),r.sweepEvent(e,t)}else r.addRightEdges(e,n,t.anEdge,t.anEdge,null,!0)}},r.sweepEvent=function(e,t){e.event=t,r.debugEvent(e);for(var n=t.anEdge;n.activeRegion===null;)if(n=n.Onext,n===t.anEdge){r.connectLeftVertex(e,t);return}var i=r.topLeftRegion(e,n.activeRegion);We(i!==null);var s=r.regionBelow(i),o=s.eUp,a=r.finishLeftRegions(e,s,null);a.Onext===o?r.connectRightVertex(e,i,a):r.addRightEdges(e,i,a.Onext,o,o,!0)},r.addSentinel=function(e,t,n,i){var s=new Xv,o=e.mesh.makeEdge();o.Org.s=n,o.Org.t=i,o.Dst.s=t,o.Dst.t=i,e.event=o.Dst,s.eUp=o,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},r.initEdgeDict=function(e){e.dict=new _z(e,r.edgeLeq);var t=e.bmax[0]-e.bmin[0],n=e.bmax[1]-e.bmin[1],i=e.bmin[0]-t,s=e.bmax[0]+t,o=e.bmin[1]-n,a=e.bmax[1]+n;r.addSentinel(e,i,s,o),r.addSentinel(e,i,s,a)},r.doneEdgeDict=function(e){for(var t,n=0;(t=e.dict.min().key)!==null;)t.sentinel||(We(t.fixUpperEdge),We(++n===1)),We(t.windingNumber===0),r.deleteRegion(e,t)},r.removeDegenerateEdges=function(e){var t,n,i,s=e.mesh.eHead;for(t=s.next;t!==s;t=n)n=t.next,i=t.Lnext,ze.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(r.spliceMergeVertices(e,i,t),e.mesh.delete(t),t=i,i=t.Lnext),i.Lnext===t&&(i!==t&&((i===n||i===n.Sym)&&(n=n.next),e.mesh.delete(i)),(t===n||t===n.Sym)&&(n=n.next),e.mesh.delete(t))},r.initPriorityQ=function(e){var t,n,i,s=0;for(i=e.mesh.vHead,n=i.next;n!==i;n=n.next)s++;for(s+=8,t=e.pq=new Az(s,ze.vertLeq),i=e.mesh.vHead,n=i.next;n!==i;n=n.next)n.pqHandle=t.insert(n);return n!==i?!1:(t.init(),!0)},r.donePriorityQ=function(e){e.pq=null},r.removeDegenerateFaces=function(e,t){var n,i,s;for(n=t.fHead.next;n!==t.fHead;n=i)i=n.next,s=n.anEdge,We(s.Lnext!==s),s.Lnext.Lnext===s&&(r.addWinding(s.Onext,s),e.mesh.delete(s));return!0},r.computeInterior=function(e,t){t===void 0&&(t=!0);var n,i;if(r.removeDegenerateEdges(e),!r.initPriorityQ(e))return!1;for(r.initEdgeDict(e);(n=e.pq.extractMin())!==null;){for(;i=e.pq.min(),!(i===null||!ze.vertEq(i,n));)i=e.pq.extractMin(),r.spliceMergeVertices(e,n.anEdge,i.anEdge);r.sweepEvent(e,n)}return e.event=e.dict.min().key.eUp.Org,r.debugEvent(e),r.doneEdgeDict(e),r.donePriorityQ(e),r.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},r}(),Mz=function(){function r(){this.mesh=new j_,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=It.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 r.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},r.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},r.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},r.prototype.computeNormal_=function(e){var t,n,i,s,o,a,l=[0,0,0],u=[0,0,0],c=[0,0,0],h=[0,0,0],d=[0,0,0],f=[null,null,null],m=[null,null,null],p=this.mesh.vHead;t=p.next;for(var g=0;g<3;++g)s=t.coords[g],u[g]=s,m[g]=t,l[g]=s,f[g]=t;for(t=p.next;t!==p;t=t.next)for(var v=0;v<3;++v)s=t.coords[v],s<u[v]&&(u[v]=s,m[v]=t),s>l[v]&&(l[v]=s,f[v]=t);var y=0;if(l[1]-u[1]>l[0]-u[0]&&(y=1),l[2]-u[2]>l[y]-u[y]&&(y=2),u[y]>=l[y]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,n=m[y],i=f[y],c[0]=n.coords[0]-i.coords[0],c[1]=n.coords[1]-i.coords[1],c[2]=n.coords[2]-i.coords[2],t=p.next;t!==p;t=t.next)h[0]=t.coords[0]-i.coords[0],h[1]=t.coords[1]-i.coords[1],h[2]=t.coords[2]-i.coords[2],d[0]=c[1]*h[2]-c[2]*h[1],d[1]=c[2]*h[0]-c[0]*h[2],d[2]=c[0]*h[1]-c[1]*h[0],o=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],o>a&&(a=o,e[0]=d[0],e[1]=d[1],e[2]=d[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(c)]=1)},r.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,n=this.mesh.vHead,i,s=0,o=e.next;o!==e;o=o.next)if(i=o.anEdge,!(i.winding<=0))do s+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==o.anEdge);if(s<0){for(t=n.next;t!==n;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},r.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],n,i,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),n=this.sUnit,i=this.tUnit;var o=this.longAxis_(t);n[o]=0,n[(o+1)%3]=1,n[(o+2)%3]=0,i[o]=0,i[(o+1)%3]=0,i[(o+2)%3]=t[o]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,n),a.t=this.dot_(a.coords,i);s&&this.checkOrientation_();for(var l=!0,u=e.next;u!==e;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},r.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},r.prototype.tessellateMonoRegion_=function(e,t){var n,i;if(n=t.anEdge,!(n.Lnext!==n&&n.Lnext.Lnext!==n))throw"Mono region invalid";for(;ze.vertLeq(n.Dst,n.Org);n=n.Lprev);for(;ze.vertLeq(n.Org,n.Dst);n=n.Lnext);i=n.Lprev;for(var s=void 0;n.Lnext!==i;)if(ze.vertLeq(n.Dst,i.Org)){for(;i.Lnext!==n&&(ze.edgeGoesLeft(i.Lnext)||ze.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)s=e.connect(i.Lnext,i),i=s.Sym;i=i.Lprev}else{for(;i.Lnext!==n&&(ze.edgeGoesRight(n.Lprev)||ze.edgeSign(n.Dst,n.Org,n.Lprev.Org)>=0);)s=e.connect(n,n.Lprev),n=s.Sym;n=n.Lnext}if(i.Lnext===n)throw"Mono region invalid";for(;i.Lnext.Lnext!==n;)s=e.connect(i.Lnext,i),i=s.Sym;return!0},r.prototype.tessellateInterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)if(t=n.next,n.inside&&!this.tessellateMonoRegion_(e,n))return!1;return!0},r.prototype.discardExterior_=function(e){for(var t,n=e.fHead.next;n!==e.fHead;n=t)t=n.next,n.inside||e.zapFace(n)},r.prototype.setWindingNumber_=function(e,t,n){for(var i,s=e.eHead.next;s!==e.eHead;s=i)i=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:n?e.delete(s):s.winding=0},r.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},r.prototype.outputPolymesh_=function(e,t,n,i){var s,o=0,a=0,l;n>3&&e.mergeConvexFaces(n);for(var u=e.vHead.next;u!==e.vHead;u=u.next)u.n=-1;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(c.n=-1,!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;u.n===-1&&(u.n=a,a++),l++,s=s.Lnext}while(s!==c.anEdge);if(l>n)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,t===xn.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*n,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var u=e.vHead.next;u!==e.vHead;u=u.next)if(u.n!==-1){var h=u.n*i;this.vertices[h+0]=u.coords[0],this.vertices[h+1]=u.coords[1],i>2&&(this.vertices[h+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var d=0,c=e.fHead.next;c!==e.fHead;c=c.next)if(!!c.inside){s=c.anEdge,l=0;do{var u=s.Org;this.elements[d++]=u.n,l++,s=s.Lnext}while(s!==c.anEdge);for(var f=l;f<n;++f)this.elements[d++]=-1;if(t===xn.CONNECTED_POLYGONS){s=c.anEdge;do this.elements[d++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==c.anEdge);for(var m=l;m<n;++m)this.elements[d++]=-1}}},r.prototype.outputContours_=function(e,t){var n,i,s=0,o=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){i=n=a.anEdge;do this.vertexCount++,n=n.Lnext;while(n!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,u=0,c=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=0,i=n=a.anEdge;do this.vertices[l++]=n.Org.coords[0],this.vertices[l++]=n.Org.coords[1],t>2&&(this.vertices[l++]=n.Org.coords[2]),this.vertexIndices[u++]=this.vertexIdCallback?this.vertexIdCallback(n):n.Org.idx,o++,n=n.Lnext;while(n!==i);this.elements[c++]=s,this.elements[c++]=o,s+=o}},r.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new j_),e<2&&(e=2),e>3&&(e=3);for(var n=null,i=0;i<t.length;i+=e)n===null?(n=this.mesh.makeEdge(),this.mesh.splice(n,n.Sym)):(this.mesh.splitEdge(n),n=n.Lnext),n.Org.coords[0]=t[i+0],n.Org.coords[1]=t[i+1],e>2?n.Org.coords[2]=t[i+2]:n.Org.coords[2]=0,n.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(n),n.winding=1,n.Sym.winding=-1},r.prototype.tesselate=function(e,t,n,i,s,o){if(e===void 0&&(e=It.ODD),t===void 0&&(t=xn.POLYGONS),o===void 0&&(o=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),Tz.computeInterior(this,o);var a=this.mesh;return t===xn.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),o&&a.check(),t===xn.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,t,n,i),!0},r}();function da(r){var e=r.windingRule,t=e===void 0?It.ODD:e,n=r.elementType,i=n===void 0?xn.POLYGONS:n,s=r.polySize,o=s===void 0?3:s,a=r.vertexSize,l=a===void 0?2:a,u=r.normal,c=u===void 0?[0,0,1]:u,h=r.contours,d=h===void 0?[]:h,f=r.strict,m=f===void 0?!0:f,p=r.debug,g=p===void 0?!1:p;if(!d&&m)throw new Error("Contours can't be empty");if(!!d){var v=new Mz;r.edgeCreateCallback&&(v.edgeCreateCallback=r.edgeCreateCallback),r.vertexIdCallback&&(v.vertexIdCallback=r.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(t,i,o,l,c,m),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}var Eee=It.ODD,Cee=It.NONZERO,Pee=It.POSITIVE,Dee=It.NEGATIVE,Iee=It.ABS_GEQ_TWO,Lee=xn.POLYGONS,Oee=xn.CONNECTED_POLYGONS,Ree=xn.BOUNDARY_CONTOURS;var xc=class extends De{constructor(t,n=12,i={}){super();this.type="ShapeGeometry";this.windingRule=It.ODD;this.elementType=xn.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=t,this._curveSegments=n,this._triangulationOptions=Object.assign({windingRule:It.ODD,elementType:xn.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let s=this._shape.extractShapePointsToFlatArray([],this._curveSegments),o=this._shape.shapeHoles.map(m=>m.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,u=!0,c,h;for(let m=0,p=s.length/2;m<p;m++){let g=m*2,v=s[g+0],y=s[g+1];if(c!==void 0&&v!==c&&(l=!1),h!==void 0&&y!==h&&(u=!1),c=v,h=y,!l&&!u)break}!l&&!u&&(a=da({contours:[s,...o],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=a?.vertexCount??1,f=a?.elementCount??1;if(this._positionAttribute=new Ge(new Float32Array(d*3),3),this._normalAttribute=new Ge(new Float32Array(d*3),3),this._uvAttribute=new Ge(new Float32Array(d*2),2),this._indexAttribute=new Ge(new Uint32Array(f*3),1),a){let m=1/0,p=-1/0,g=1/0,v=-1/0;for(let w=0,S=d;w<S;w++){let _=w*2,M=a.vertices[_+0],x=a.vertices[_+1];M<m&&(m=M),M>p&&(p=M),x<g&&(g=x),x>v&&(v=x)}let y=p-m,b=v-g;for(let w=0,S=d;w<S;w++){let _=w*2,M=a.vertices[_+0],x=a.vertices[_+1],T=(M-m)/y,E=(x-g)/b;this._positionAttribute.setXYZ(w,M,x,0),this._normalAttribute.setXYZ(w,0,0,1),this._uvAttribute.setXY(w,T,E)}for(let w=0,S=f;w<S;w++){let _=w*3,M=a.elements[_+0],x=a.elements[_+1],T=a.elements[_+2];this._indexAttribute.setX(_+0,M),this._indexAttribute.setX(_+1,x),this._indexAttribute.setX(_+2,T)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(a?.elementCount??1)*3)}clone(){let t=new xc(this._shape,this._curveSegments);return t.userData=Hu(this.userData),t}};var jp=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let n=e*jp.eSize;this.buffer=new ArrayBuffer(n);let i=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*i,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let n=e*jp.eSize,i=new ArrayBuffer(n),s=Float32Array.BYTES_PER_ELEMENT,o=0,a=new Float32Array(i,o*s,3*e);o+=3*e;let l=new Float32Array(i,o*s,3*e);o+=3*e;let u=new Float32Array(i,o*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),u.set(this.uvs.slice(0,this.size*2)),this.buffer=i,this.positions=a,this.normals=l,this.uvs=u,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let i=this.capacity;for(;t>i;)i*=2;this.realloc(i)}let n=this.size;return this.size=t,n}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},vh=jp;vh.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Yv=(r,e)=>([t,n])=>(n<t&&(n+=e),(r>=t?r:r+e)<=n),bc=class extends De{constructor(t,n,i=0,s=12,o=3,a=It.ODD){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=t,this._depth=n,this._bevel=i,this._curveSegments=s,this._bevelSegmentsInput=o,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,n/2-1e-12),this._bevelSegments=Math.floor(o));let l=this._shape.extractShapePointsToFlatArray([],s),u=this._shape.shapeHoles.map(x=>{let T=x.extractShapePointsToFlatArray([],s),E=[];for(let C=T.length-1;C>=1;C-=2){let P=T[C-1],O=T[C-0];E.push(P,O)}return E}),c=da({windingRule:a,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[l]}),h=da({windingRule:It.ODD,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]});if(!c)throw new Error("error generating geometry");let d=c.elementCount;if(h){c.elementCount+=h.elementCount;for(let x=0;x<h.elements.length;x++){let T=h.elements[x],E=x%2===0?c.vertexCount:0;c.elements.push(T+E)}for(let x=0;x<h.vertexIndices.length;x++){let T=h.vertexIndices[x],E=c.vertexCount;c.vertexIndices.push(T+E)}for(let x=0;x<h.vertices.length;x++){let T=h.vertices[x];c.vertices.push(T)}}let f=1/0,m=-1/0,p=1/0,g=-1/0;for(let x=0,T=c.vertexCount;x<T;x++){let E=x*2,C=c.vertices[E+0],P=c.vertices[E+1];C<f&&(f=C),C>m&&(m=C),P<p&&(p=P),P>g&&(g=P)}this._minX=f,this._minY=p,this._width=m-f,this._height=g-p;let v=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new vh(v);let y=[],b=[];for(let x=c.elementCount-1;x>=0;x--){let T=x>=d,E=x*2,C=c.elements[E+0],P=c.elements[E+1],O=C+P,D={start:C,count:P,normals:[],continuous:[],concave:[]},N=C,F=O-1,z=C+1,Y=this._shape.roundedCurves.length;do{let V=N-C,k=c.vertices[F*2+0],j=c.vertices[F*2+1],q=c.vertices[N*2+0],W=c.vertices[N*2+1],he=c.vertices[z*2+0],ie=c.vertices[z*2+1],K=q-k,X=W-j,ne=Math.sqrt(K*K+X*X);K/=ne,X/=ne;let ce=q-he,oe=W-ie,Te=Math.sqrt(ce*ce+oe*oe);ce/=Te,oe/=Te,D.normals[V*2+0]=-oe,D.normals[V*2+1]=ce,D.concave[V]=K*oe-X*ce>0;let me=c.vertexIndices[N];if(Array.isArray(me))D.continuous[V]=!1;else{let[ge,ye]=this._shape.getCurveIndexFromVertexId(me-1,!0);if(ye>0&&ye<1)D.continuous[V]=!0;else{let de=ye===1?ge+1:ge-1;de=(de+Y)%Y;let Pe=ye===1?0:1,Ne=this._shape.roundedCurves[ge].getTangent(ye),Ze=this._shape.roundedCurves[de].getTangent(Pe);D.continuous[V]=Ne.dot(Ze)>.95}}T&&(D.normals[V*2+0]*=-1,D.normals[V*2+1]*=-1),[F,N,z]=[N,z,z+1],z>=O&&(z-=P)}while(z!==C+1);let U=[];U.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(C*2,O*2),vertexCount:P,vertexIndices:new Array(P).fill(!0).map((V,k)=>[k,k]),elements:[0,P],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(C*2,O*2)});for(let V=1;V<=this._bevelSegments;V++){let k=V/this._bevelSegments*Math.PI/2,j=(1-Math.cos(k))*this._bevelSize,q=[],W=[],he=[],ie=[],K=0;for(let ne=0;ne<P;ne++){let ce=ne*2,oe=(ne-1+P)%P*2,Te=c.vertices[D.start*2+ce+0],me=c.vertices[D.start*2+ce+1],ge=-D.normals[oe+0]*j,ye=-D.normals[oe+1]*j,de=-D.normals[ce+0]*j,Pe=-D.normals[ce+1]*j;if(D.concave[ne]||!D.concave[ne]&&T){let Ne=Math.atan2(ye,ge),Ze=Math.atan2(Pe,de);Ze>Ne&&(Ze-=Math.PI*2);let R=Ze-Ne;if(D.continuous[ne]||T){let I=Ne+R/2,J=Math.cos(I)*j,le=Math.sin(I)*j;q[2*K+0]=Te+J*(T?-1:1),q[2*K+1]=me+le*(T?-1:1),ie[K]=ne,K++}else{let I=Math.max(1,Math.floor(s/4*Math.abs(R)/Math.PI));for(let J=0;J<=I;J++){let le=Ne+R*(J/I),fe=Math.cos(le)*j,Ee=Math.sin(le)*j;q[2*K+0]=Te+fe,q[2*K+1]=me+Ee,ie[K]=ne,K++}}}else q[2*K+0]=Te+ge,q[2*K+1]=me+ye,ie[K]=ne,W[ne]=K,K++,q[2*K+0]=Te,q[2*K+1]=me,ie[K]=ne,K++,q[2*K+0]=Te+de,q[2*K+1]=me+Pe,ie[K]=ne,he[ne]=K,K++}let X=da({windingRule:It.POSITIVE,elementType:xn.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[q],edgeCreateCallback:ne=>{let oe=ne.Org.idx,Te=ie[oe],me=ie[(oe+1)%ie.length];ne.idx=[Te,me],ne.Sym.idx=[me,Te]},vertexIdCallback:ne=>{let ce=ne.Lprev.idx;return[ce?ce[1]:0,ne.idx[0]]}});if(!X)throw console.log("Error"),new Error(`error generating bevel geometry for ${V}'th loop`);if(!X.vertexCount)break;for(let ne=0;ne<X.vertexIndices.length;ne++){let[ce,oe]=X.vertexIndices[ne];if(ce===oe)continue;let Te=oe;oe<ce&&(Te+=P);for(let me=ce;me<Te;me++){let ge=me%P,ye=(me+1)%P;if(!D.continuous[ge]||!D.continuous[ye]){X.vertexIndices[ne]=[ce,ge],X.vertexIndices.splice(ne+1,0,[ye,oe]),X.vertices.splice((ne+1)*2,0,X.vertices[ne*2],X.vertices[ne*2+1]);break}}}U.push({bevelI:V,angle:k,size:j,boundary:X,reverseMap:ie,insetPoints:q})}let G=(V,k,j)=>{let q=0,W=V.boundary.vertexIndices.length;for(;q<W&&j(V.boundary.vertexIndices[k]);)k=(k+1)%W,q++;return q},Q=y.length;for(let V=1;V<U.length;V++){let k=U[V-1],j=U[V],q=k.boundary.vertexIndices.length,W=j.boundary.vertexIndices.length;if(!q||!W)break;let he=D.concave.length,ie=0,K=Yv(ie,P);for(;!k.boundary.vertexIndices.filter(K).length||!j.boundary.vertexIndices.filter(K).length;)ie++,K=Yv(ie,P);let X=k.boundary.vertexIndices.findIndex(K),ne=j.boundary.vertexIndices.findIndex(K);do X=(X+1)%q;while(K(k.boundary.vertexIndices[X]));do ne=(ne+1)%W;while(K(j.boundary.vertexIndices[ne]));ie=(ie+1)%P;let ce=ie,oe=this.buildBevelVert(D,k,(X-1+q)%q),Te=this.buildBevelVert(D,j,(ne-1+W)%W),me=oe,ge=Te,ye,de,Pe=!1;do{K=Yv(ie,P);let Ne=G(k,X,K),Ze=G(j,ne,K),R=Pe;if(Pe=!1,Ne&&!Ze){for(let I=0;I<Ne;I++)ye=this.buildBevelVert(D,k,(X+I)%q,I/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye;Pe=!0}else if(!Ne&&Ze)for(let I=0;I<Ze;I++)de=this.buildBevelVert(D,j,(ne+I)%W,I/(Ze-1)),y.push(ge.topN,me.topP,de.topP),y.push(me.bottomP,ge.bottomN,de.bottomP),ge=de;else if(Ne&&Ze)if(ye=this.buildBevelVert(D,k,X,0),de=this.buildBevelVert(D,j,ne,0),R?(y.push(me.topN,de.topP,ge.topN),y.push(me.topN,ye.topP,de.topP),y.push(de.bottomP,me.bottomN,ge.bottomN),y.push(de.bottomP,ye.bottomP,me.bottomN)):(y.push(ge.topN,me.topN,ye.topP),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,me.bottomN,ge.bottomN),y.push(ye.bottomP,ge.bottomN,de.bottomP)),me=ye,ge=de,Ne===Ze)for(let I=1;I<Ne;I++)ye=this.buildBevelVert(D,k,(X+I)%q,I/(Ne-1)),de=this.buildBevelVert(D,j,(ne+I)%W,I/(Ze-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,me.bottomN,ge.bottomN),y.push(ye.bottomP,ge.bottomN,de.bottomP),me=ye,ge=de;else if(Ne>Ze){let I=Ne/Ze,J=0;for(let le=1;le<Ne;le++)ye=this.buildBevelVert(D,k,(X+le)%q,le/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye,le>(J+1)*I&&(J++,de=this.buildBevelVert(D,j,(ne+J)%W,J/(Ze-1)),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,de.bottomP),ge=de)}else{let I=Ze/Ne,J=0;for(let le=1;le<Ze;le++)de=this.buildBevelVert(D,j,(ne+le)%W,le/(Ze-1)),y.push(ge.topN,ye.topP,de.topP),y.push(ye.bottomP,ge.bottomN,de.bottomP),ge=de,le>(J+1)*I&&(J++,ye=this.buildBevelVert(D,k,(X+J)%q,J/(Ne-1)),y.push(me.topN,ye.topP,ge.topN),y.push(ye.bottomP,me.bottomN,ge.bottomN),me=ye)}X=(X+Ne)%q,ne=(ne+Ze)%W,ie=(ie+1)%he}while(ie!==ce)}{let V=U[0];for(let k=0,j=V.boundary.vertexCount;k<j;k++){let q=this.buildBevelVert(D,V,k),W=this.buildBevelVert(D,V,(k+1)%j);y.push(W.topP,q.topN,q.bottomN),y.push(W.topP,q.bottomN,W.bottomP)}}if(T){let V=[];for(let k=y.length-1;k>=Q+2;k-=3){let j=y[k-2],q=y[k-1],W=y[k-0];V.push(W,q,j)}y.splice(Q,y.length-Q,...V)}if(T){let V=[];for(let k=U[U.length-1].boundary.vertices.length-1;k>=1;k-=2){let j=U[U.length-1].boundary.vertices[k-1],q=U[U.length-1].boundary.vertices[k-0];V.push(j,q)}b.push(V)}if(!T){let V=U[U.length-1],k=da({windingRule:U.length>1?It.POSITIVE:It.ODD,elementType:xn.POLYGONS,vertexSize:2,strict:!0,contours:[V.insetPoints,...b]});if(!k)throw new Error("Error generating geometry for surface");u.length===0&&Object.assign(this,{capStartIndex:y.length});for(let j=0;j<k.elementCount*3;j+=3){let q=this.buildSurfaceVert(k,k.elements[j+0]),W=this.buildSurfaceVert(k,k.elements[j+1]),he=this.buildSurfaceVert(k,k.elements[j+2]);y.push(q.top,W.top,he.top),y.push(he.bottom,W.bottom,q.bottom)}}this.vertexCache={}}this._buffer.shrink();let w=new Ge(Uint32Array.from(y),1),S=new Ge(this._buffer.positions,3),_=new Ge(this._buffer.normals,3),M=new Ge(this._buffer.uvs,2);S.needsUpdate=!0,_.needsUpdate=!0,M.needsUpdate=!0,w.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",_),this.setAttribute("uv",M),this.setIndex(w)}buildSurfaceVert(t,n){let i=n.toString();if(i in this.vertexCache)return this.vertexCache[i];let s=t.vertices[n*2+0],o=t.vertices[n*2+1],a=(s-this._minX)/this._width,l=(o-this._minY)/this._height,u=this._buffer.get(2),c=u*3,h=u*2,d={top:u+0,bottom:u+1};return this._buffer.positions[c+0]=s,this._buffer.positions[c+1]=o,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[h+0]=a,this._buffer.uvs[h+1]=l,this._buffer.positions[c+3]=s,this._buffer.positions[c+4]=o,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[h+2]=a,this._buffer.uvs[h+3]=l,this.vertexCache[i]=d,d}buildBevelVert(t,n,i,s=1){let o=`${n.bevelI}:${i}`;if(o in this.vertexCache)return this.vertexCache[o];let[a,l]=n.boundary.vertexIndices[i],u,c,h,d;a!==l?(c=a,u=l,d=!1,h=t.continuous[c]&&t.continuous[u]):(u=a,c=(u-1+t.count)%t.count,d=t.concave[u]&&n.bevelI>0,h=t.continuous[u]||d);let f=Math.cos(n.angle),m=Math.sin(n.angle),p=i*2,g=u*2,v=c*2,y=n.boundary.vertices[p+0],b=n.boundary.vertices[p+1],w=(1-m)*this._bevelSize,S=(y-this._minX)/this._width,_=(b-this._minY)/this._height,M=t.normals[g+0],x=t.normals[g+1],T=t.normals[v+0],E=t.normals[v+1];if(d){let N=T-M,F=E-x;M=M+N*(1-s),x=x+F*(1-s);let z=Math.sqrt(M*M+x*x);M/=z,x/=z}let C=this._buffer.get(h?2:4),P=C*3,O=C*2,D={i,fi:u,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=M*f,this._buffer.normals[P+1]=x*f,this._buffer.normals[P+2]=m,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=M*f,this._buffer.normals[P+4]=x*f,this._buffer.normals[P+5]=-m,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S,h||(C+=2,P+=6,O+=4,D.topP=C+0,D.bottomP=C+1,this._buffer.positions[P+0]=y,this._buffer.positions[P+1]=b,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=T*f,this._buffer.normals[P+1]=E*f,this._buffer.normals[P+2]=m,this._buffer.uvs[O+0]=S,this._buffer.uvs[O+1]=_,this._buffer.positions[P+3]=y,this._buffer.positions[P+4]=b,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=T*f,this._buffer.normals[P+4]=E*f,this._buffer.normals[P+5]=-m,this._buffer.uvs[O+2]=_,this._buffer.uvs[O+3]=S),this.vertexCache[o]=D,D}clone(){let t=new bc(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return t.userData=Hu(this.userData),t}};var Un=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:It.ODD},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??0),o=r.shape??e?.shape,a=o?.roundness??t.roundness;o!==void 0&&(o instanceof gt?(o.width!==n||o.height!==i)&&o.applySize(n,i):o=new gt(n,i).fromJSON(o),r.parameters?.roundness!==void 0&&r.parameters?.roundness>0&&o.update(!1));let l=o??new gt(n,i);return{parameters:Object.assign(t,{width:n,height:i,depth:s,roundness:a}),shape:l}}static build(r){let{depth:e,extrudeBevelSize:t,extrudeBevelSegments:n,subdivisions:i,roundness:s,windingRule:o}=r.parameters;r.shape.roundness=s;let a;return e<=0?a=new xc(r.shape,i,{windingRule:o}):a=new bc(r.shape,e,t,i,n,o),Object.assign(a,{userData:{...r,type:"VectorGeometry"}})}};var Z_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},r.parameters),n=t.width/2,i=t.radiusTop??n,s=t.radiusBottom??n;return i===s?(i=n,s=n):i>s?(i=n,s=s*n/i):(i=i*n/s,s=n),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),radiusTop:i,radiusBottom:s})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:h,cornerSegments:d,hollow:f}=r.parameters,m;return h||f?m=new xh(u,c,n,i,s,o,a,l*Math.PI/180,h,h,d,f):m=new Ho(u,c,n,i,s,o,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:{...r,type:"CylinderGeometry"}})}};function ho(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function Q_(r){return new B(r.y,-r.x)}var xh=class extends De{constructor(e,t,n,i,s,o,a,l,u,c,h,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,n=n||1,i=Math.floor(i)||8,s=Math.floor(s)||1,o=o!==void 0?o:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,o&&(u=0,c=0);let m=[],p=[],g=[],v=[],y=0,b=n/2,w=new A,S=new A;f&&e==0&&(e=u),f&&t==0&&(t=c);let _=new B(e,b),M=new B(t,-b),x=null,T=null,E=null,C=null,P=_.clone().sub(M),O=0,D=0,N=0;d>0&&(O=Math.min(e,t)*(1-d),D=e-O,N=t-O);let F=_.clone();F.x-=O;let z=Math.PI-P.angle(),Y=P.angle(),U=Math.tan(Y/2),G=Math.tan(z/2),Q=U+G,V=d?Q:G,k=d?Q:U;if(u=Math.min(u,(e-D)/V,P.length()/Q),c=Math.min(c,(t-N)/k,P.length()/Q),u>0){let K=u/U;x=_.clone().sub(new B(K,u)),d&&(E=x.clone(),E.x-=O-Q*u),_.sub(P.clone().setLength(K))}if(c>0){let K=c/G;T=M.clone().sub(new B(K,-c)),M.add(P.clone().setLength(K)),d&&(C=T.clone(),C.x-=O-Q*c,F.sub(P.clone().setLength(K)))}P=_.clone().sub(M);let j=P.length()<.5,q=[];for(let K=0;K<=i;K++){let X=[],ne=K/i,ce=ne*l+a,oe=new B(Math.sin(ce),Math.cos(ce));C&&T?(W(X,ne,oe,z,c,C,-1,!0),W(X,ne,oe,Y,c,T,-1,!1)):T?(he(X,oe,T.x,0,-1),W(X,ne,oe,Y,c,T,-1,!1)):o||he(X,oe,t,N,-1);let Te=Q_(P).normalize();if(ho(Te,oe,w),!j)for(let me=0;me<=s;me++){let ge=me/s,ye=P.clone().multiplyScalar(ge).add(M);ho(ye,oe,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),v.push(ne,.5+S.y/n),X.push(y++)}if(E&&x?(W(X,ne,oe,z,u,x,1,!1),W(X,ne,oe,Y,u,E,1,!0)):x?(W(X,ne,oe,z,u,x,1,!1),he(X,oe,x.x,0,1)):o||he(X,oe,e,D,1),d&&!j){let me=Q_(P).multiplyScalar(-1).normalize();ho(me,oe,w);for(let ge=0;ge<=s;ge++){let ye=ge/s,de=P.clone().multiplyScalar(-ye).add(F);ho(de,oe,S),p.push(S.x,S.y,S.z),g.push(w.x,w.y,w.z),v.push(ne,.5+S.y/n),X.push(y++)}}d&&!o&&X.push(X[0]),q.push(X)}for(let K=0;K<q.length-1;K++)for(let X=0;X<q[0].length-1;X++){if(o&&d&&X==s)continue;let ne=q[K][X],ce=q[K+1][X],oe=q[K+1][X+1],Te=q[K][X+1],me=p[oe*3+0],ge=p[oe*3+2];m.push(ne,ce,Te),(me!=0||ge!=0)&&m.push(ce,oe,Te)}l<Math.PI*2&&(ie(-1,q[0],a),ie(1,q[q.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new Ae(p,3)),this.setAttribute("normal",new Ae(g,3)),this.setAttribute("uv",new Ae(v,2));function W(K,X,ne,ce,oe,Te,me,ge){for(let ye=0;ye<h+1;ye++){let de=ye/h,Pe=me<0?de:1-de;ge&&(Pe-=1),Pe*=ce;let Ne=new B(Math.sin(Pe),Math.cos(Pe)*me),Ze=Ne.clone().multiplyScalar(oe).add(Te);ho(Ze,ne,S),p.push(S.x,S.y,S.z),ho(Ne,ne,w),g.push(w.x,w.y,w.z),v.push(X,.5+S.y/n),K.push(y++)}}function he(K,X,ne,ce,oe){let Te=new A,me=new B,ge=[ne,ce];oe<0&&ge.reverse();for(let ye of ge)me.set(ye,b*oe),ho(me,X,Te),p.push(Te.x,Te.y,Te.z),g.push(0,oe,0),v.push(.5,.5),K.push(y++)}function ie(K,X,ne){let ce=new B(Math.sin(ne),Math.cos(ne)),oe=new B(-Math.cos(ne),Math.sin(ne)),Te=new A,me=K<0?(de,Pe,Ne)=>m.push(de,Pe,Ne):(de,Pe,Ne)=>m.push(de,Ne,Pe),ge=new B((e+t+D+N)/4,0);ho(ge,ce,Te),p.push(Te.x,Te.y,Te.z),g.push(oe.x,0,oe.y),v.push(.5,.5);let ye=y++;for(let de of X){let Pe=p.slice(de*3,de*3+3);p.push(...Pe),g.push(oe.x,0,oe.y);let Ne=v.slice(de*2,de*2+2);v.push(...Ne),y++}for(let de=ye+1;de<y-1;de++)me(ye,de,de+1);me(ye,y-1,ye+1)}}};var K_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,depth:t,height:n,radialSegments:i,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:h}=r.parameters,d;return u>0||c>0||l<360?d=new xh(0,e/2,n,i,s,o,a,l*Math.PI/180,u,c,h,0,!0):d=new el(e/2,n,i,s,o),d.scale(1,1,t/e),Object.assign(d,{userData:{...r,type:"ConeGeometry"}})}};var J_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,widthSegments:i,heightSegments:s,depthSegments:o,cornerRadius:a,cornerSegments:l}=r.parameters,u;return a==0?u=new ur(e,t,n,i,s,o):u=new Zv(e,t,n,i,s,o,a,l),Object.assign(u,{userData:{...r,type:"CubeGeometry"}})}},Qv=Math.PI/2,Zv=class extends De{constructor(e=1,t=1,n=1,i=1,s=1,o=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let u=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o),l=Math.floor(l),a=Math.min(a,e/2,t/2,n/2);let c=[],h=[],d=[],f=[],m=0,p=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,s,4),g("x","y","z",-1,-1,e,t,-n,i,s,5),a>0&&(v("z","y","x",-1,-1,1,n,t,e,o,0),v("z","y","x",1,-1,-1,n,t,e,o,1),v("z","y","x",-1,1,-1,n,t,e,o,1),v("z","y","x",1,1,1,n,t,e,o,0),v("x","y","z",-1,-1,-1,e,t,n,i,0),v("x","y","z",1,-1,1,e,t,n,i,1),v("x","y","z",-1,1,1,e,t,n,i,0),v("x","y","z",1,1,-1,e,t,n,i,1),v("y","x","z",-1,-1,1,t,e,n,s,0),v("y","x","z",1,-1,-1,t,e,n,s,1),v("y","x","z",1,1,1,t,e,n,s,1),v("y","x","z",-1,1,-1,t,e,n,s,0),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Ae(h,3)),this.setAttribute("normal",new Ae(d,3)),this.setAttribute("uv",new Ae(f,2));function g(b,w,S,_,M,x,T,E,C,P,O){let D=(x-2*a)/C,N=(T-2*a)/P,F=x/2-a,z=T/2-a,Y=E/2,U=C+1,G=P+1,Q=0,V=0,k=new A;for(let j=0;j<G;j++){let q=j*N-z;for(let W=0;W<U;W++){let he=W*D-F;k[b]=he*_,k[w]=q*M,k[S]=Y,h.push(k.x,k.y,k.z),k[b]=0,k[w]=0,k[S]=E>0?1:-1,d.push(k.x,k.y,k.z),f.push(W/C),f.push(1-j/P),Q+=1}}for(let j=0;j<P;j++)for(let q=0;q<C;q++){let W=m+q+U*j,he=m+q+U*(j+1),ie=m+(q+1)+U*(j+1),K=m+(q+1)+U*j;c.push(W,he,K),c.push(he,ie,K),V+=6}u.addGroup(p,V,O),p+=V,m+=Q}function v(b,w,S,_,M,x,T,E,C,P,O){let D=(T-2*a)/P,N=T/2-a,F=E/2-a,z=C/2,Y=P+1,U=0,G=0,Q=new A,V=new A;for(let k=0;k<l+1;k++){let j=k/l*Qv,q=Math.sin(j)*a,W=(1-Math.cos(j))*a,he=Math.sin(j),ie=Math.cos(j);Q[w]=(F+q)*M,Q[S]=(z-W)*x,V[b]=0,V[w]=he*Math.sign(Q[w]),V[S]=ie*Math.sign(Q[S]);for(let K=0;K<Y;K++){let X=K*D-N;Q[b]=X*_,h.push(Q.x,Q.y,Q.z),d.push(V.x,V.y,V.z),f.push(K/P),f.push(0),U+=1}}for(let k=0;k<l;k++)for(let j=0;j<P;j++){let q=m+j+Y*k,W=m+j+Y*(k+1),he=m+(j+1)+Y*(k+1),ie=m+(j+1)+Y*k;c.push(q,W,ie),c.push(W,he,ie),G+=6}u.addGroup(p,G,O),p+=G,m+=U}function y(b,w,S){let _=new A,M=new A(e/2,t/2,n/2);M.subScalar(a);let x=[],T=b*w*S>0?(C,P,O)=>c.push(C,P,O):(C,P,O)=>c.push(C,O,P);for(let C=0;C<=l;C++){let P=[],O=Qv*(1-C/l),D=Math.cos(O),N=Math.sin(O),F=0;for(let z=0;z<=C;z++){let Y=Math.cos(F),U=Math.sin(F);_.x=D*Y,_.y=N,_.z=D*U;let G=M.clone().addScaledVector(_,a);h.push(b*G.x,w*G.y,S*G.z),d.push(b*_.x,w*_.y,S*_.z),f.push(0,0),P.push(m++),F+=Qv/C}x.push(P)}let E=x.length-1;for(let C=0;C<E;C++){let P=x[C],O=x[C+1],D=P.length-1;T(P[0],O[1],O[0]);for(let N=1;N<=D;N++)T(P[N-1],P[N],O[N]),T(P[N],O[N+1],O[N])}}}};var fo=class extends De{constructor(e=[],t=[],n="",i=1,s=.2,o=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],u=[];c(),h(),this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(u,3)),this.setAttribute("uv",new Ae(l,2));return;function c(){s=Math.min(1-1e-5,s),s==0&&(o=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[n],m=new A,p=m.clone(),g=new Mn,v=s*i,y=i-v,b=o+1,w=new A,S=(U,G)=>w.subVectors(U,G).normalize(),_=(U,G)=>Array(U).fill(void 0).map(G),M=_(e.length/3,(U,G)=>new A().fromArray(e,G*3).setLength(i)),x=[],T=1e6;for(let U=0;U<M.length;U++){let G=M[U],Q=[],V,k,j,q=1e10,W=-1;for(;(W=t.indexOf(U,W+1))!=-1;){let X=W-W%3;V=t[X+(W+1)%3],k=t[X+(W+2)%3],j=G.distanceToSquared(M[V]),q=Math.min(q,j),Q.push([V,k,j])}q+=1e-6;let he=[],ie=0,K=Q.length;for(let X=0;X<K;X++){[V,k,j]=Q[ie];let ne=x[V]?.includes(U)==!0;j<=q&&he.push(V+ +ne*T),ie=Q.findIndex(ce=>ce[0]==k)}x.push(he)}let E=[];{let U=0,G=0,Q,V,k=f==3;for(let j=0;j<=o;j++){Q=j*(j+1)/2,V=(j+1)*(j+2)/2;for(let q=0;q<o-j;q++)[U,G]=[Q+q+j+2,V+q+j+3],E.push(Q,V,...k?[G,Q]:[U,V],G,U),[Q,V]=[U,G];E.push(Q,V,Q+o+2)}}let C=m.clone(),P=m.clone(),O=m.clone(),D=m.clone(),N=m.clone(),F=[],z=_(M.length,()=>_(f,()=>m.clone()));for(let U=0;U<M.length;U++){m.copy(M[U]).normalize(),C.copy(m).multiplyScalar(y);let G=x[U];for(let he=0;he<G.length;he++){let ie=G[he],K=G[(he+1)%f];g.setFromPointsAndIndices(M,U,ie%T,K%T),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(C,z[U][he])}let Q=[],V=[],k=[],j=new A;o==0&&[...z[U]].reduce((he,ie)=>he.add(ie),j).multiplyScalar(1/f);for(let he=0;he<f;he++){let ie=[],K=(he-1+f)%f,X=z[U][K],ne=z[U][he];m.copy(X).sub(C),p.copy(ne).sub(C);let ce=C.angleTo(m),oe=m.angleTo(p),Te=Math.cos(ce)*v;o==0?P.copy(j):P.copy(C).setLength(y+Te),V.push(Te);let me=[P,X,ne];for(let ge=0;ge<2;ge++){let ye=me[ge],de=me[ge+1];D.subVectors(ye,C),N.subVectors(de,C),O.crossVectors(D,N).normalize();for(let Pe=0;Pe<b;Pe++){let Ne=[ce,oe][ge]*Pe/b;m.copy(D).applyAxisAngle(O,Ne).add(C),Q.push(m.clone()),ge&&(S(m,C),ie.push([Pe==0?ye:m.clone(),w.clone()]))}ge&&(S(de,C),ie.push([de,w.clone()]))}k.push(ie)}F.push(k);let q=2*b,W=2;for(let he=0;he<f;he++){let ie=q*he,K=q*((he+1)%f),X=[Q[ie]];for(let ce=1;ce<b;ce++){D=Q[ie+ce],N=Q[K+ce],X.push(D);for(let oe=1,Te=ce-W+1;oe<=Te;oe++)m.lerpVectors(D,N,oe/(Te+1)),m.sub(C).setLength(V[he]).add(C),X.push(m.clone());X.push(N)}for(let ce=0;ce<b;ce++)X.push(Q[ce+b+ie]);X.push(Q[K+b]);let ne=E.map(ce=>X[ce]);a.push(...ne.map(ce=>[ce.x,ce.y,ce.z]).flat()),u.push(...ne.map(ce=>(S(ce,C),[w.x,w.y,w.z])).flat())}}let Y=[];for(let U=0;U<x.length;U++)for(let G=0;G<f;G++){let Q=x[U][G];if(Q<T){let V=x[Q].findIndex(q=>q%T==U),k=F[U][G],j=F[Q][V];for(let q=0;q<b;q++){let W=k[q],he=j[b-q],ie=k[q+1],K=j[b-(q+1)];[W,he,ie,ie,he,K].forEach(X=>{a.push(X[0].x,X[0].y,X[0].z),u.push(X[1].x,X[1].y,X[1].z)})}Y.push(k[0][0],j[b][0],k[b][0],j[0][0])}}for(;Y.length;){let U,G,Q,V;[U,G]=Y.splice(0,2);let k=[U];for(;U!=G;)k.push(G),Q=Y.indexOf(G),V=Q%2,G=Y.splice(Q-V,2)[1-V];w.subVectors(k[0],k[1]).cross(m.subVectors(k[0],k[2])).normalize();let j=w.dot(k[0])<0;j&&w.negate();for(let q=1;q<=k.length-2;q++)[k[q+ +j],k[q+1-+j],k[0]].forEach(W=>{a.push(W.x,W.y,W.z),u.push(w.x,w.y,w.z)})}}function h(){let d=new A;for(let M=0;M<a.length;M+=3){d.x=a[M+0],d.y=a[M+1],d.z=a[M+2];let x=S(d)/2/Math.PI+.5,T=_(d)/Math.PI+.5;l.push(x,1-T)}let f=new A,m=new A,p=new A,g=new A,v=new B,y=new B,b=new B,w=(M,x,T,E)=>{E<0&&M.x===1&&(l[x]=M.x-1),T.x===0&&T.z===0&&(l[x]=E/2/Math.PI+.5)};for(let M=0,x=0;M<a.length;M+=9,x+=6){f.set(a[M+0],a[M+1],a[M+2]),m.set(a[M+3],a[M+4],a[M+5]),p.set(a[M+6],a[M+7],a[M+8]),v.set(l[x+0],l[x+1]),y.set(l[x+2],l[x+3]),b.set(l[x+4],l[x+5]),g.copy(f).add(m).add(p).divideScalar(3);let T=S(g);w(v,x+0,f,T),w(y,x+2,m,T),w(b,x+4,p,T)}for(let M=0;M<l.length;M+=6){let x=l[M+0],T=l[M+2],E=l[M+4],C=Math.max(x,T,E),P=Math.min(x,T,E);C>.9&&P<.1&&(x<.2&&(l[M+0]+=1),T<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function _(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(e){return new fo(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};var $_=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new bh(e*.5,s,o):new nl(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"DodecahedronGeometry"}})}},bh=class extends fo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=1/i,o=[-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,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(o,a,l,e,t,n),this.type=l}static fromJSON(e){return new bh(e.radius,e.corner,e.cornerSides)}};var Jv=Math.PI*2;function Kv({x:r,y:e},t,n,i,s){return{x:r*t+i,y:e*n+s}}function Ez(r,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),n=Math.cos(r),i=Math.sin(r),s=Math.cos(r+e),o=Math.sin(r+e);return[{x:n-i*t,y:i+n*t},{x:s+o*t,y:o-s*t},{x:s,y:o}]}function eT(r,e,t,n){let i=r*n-e*t<0?-1:1,s=Math.min(1,Math.max(-1,r*t+e*n));return i*Math.acos(s)}function Cz(r,e,t,n,i,s,o,a,l,u){let c=Math.pow(i,2),h=Math.pow(s,2),d=Math.pow(o,2),f=Math.pow(a,2),m=c*h-c*f-h*d;m<0&&(m=0),m/=c*f+h*d,m=Math.sqrt(m)*(l===u?-1:1);let p=m*i/s*a,g=m*-s/i*o,v=p+(r+t)/2,y=g+(e+n)/2,b=(o-p)/i,w=(a-g)/s,S=(-o-p)/i,_=(-a-g)/s,M=eT(1,0,b,w),x=eT(b,w,S,_);return!u&&x>0&&(x-=Jv),u&&x<0&&(x+=Jv),{centerx:v,centery:y,ang1:M,ang2:x}}function tT({px:r,py:e,cx:t,cy:n,rx:i,ry:s,largeArcFlag:o,sweepFlag:a}){let l=[];if(i===0||s===0)return[];let u=(r-t)/2,c=(e-n)/2;if(u===0&&c===0)return[];i=Math.abs(i),s=Math.abs(s);let h=Math.pow(u,2)/Math.pow(i,2)+Math.pow(c,2)/Math.pow(s,2);h>1&&(i*=Math.sqrt(h),s*=Math.sqrt(h));let d=Cz(r,e,t,n,i,s,u,c,o,a),{ang1:f,ang2:m}=d,{centerx:p,centery:g}=d,v=Math.abs(m)/(Jv/4);Math.abs(1-v)<1e-7&&(v=1);let y=Math.max(Math.ceil(v),1);m/=y;for(let b=0;b<y;b++)l.push(Ez(f,m)),f+=m;return l.map(b=>{let{x:w,y:S}=Kv(b[0],i,s,p,g),{x:_,y:M}=Kv(b[1],i,s,p,g),{x,y:T}=Kv(b[2],i,s,p,g);return{x1:w,y1:S,x2:_,y2:M,x,y:T}})}var rT=Math.PI*2,iT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,angle:i,innerRadius:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u=r.shape,c=e*.5,h=t*.5,d=Pz(u,c,h,i*Math.PI/180,n,s);u.isClosed=!0,u.update();let f=Un.create({shape:u,parameters:{subdivisions:d,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:{...r,type:"EllipseGeometry"}})}};function Pz(r,e,t,n,i,s){if(n>=rT)return i>30||i%4===0?(Iz(r,e,t,s),Math.round(i/4)):nT(r,n,i,e,t,s);let o={x:0,y:t},a=n+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},u=tT({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:n>Math.PI,sweepFlag:!0});return i>30||i%u.length===0?Dz(r,o.x,o.y,u,i,e,t,s):nT(r,n,i,e,t,s)}function Dz(r,e,t,n,i,s,o,a){let l=Math.round(i/n.length);r.addPoint(wc(e,t));for(let u=0,c=n.length;u<c;u++){let h=n[u],d=r.points[u],f=wc(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),f.controls[0].position.set(h.x2,h.y2),r.addPoint(f)}return a>0?sT(r,s,o,a):r.addPoint(wc(0,0)),l}function nT(r,e,t,n,i,s){let o=-e/t;for(let a=0;a<=t;a++){let l=o*a,u=Math.sin(l)*n,c=Math.cos(l)*i;r.addPoint(wc(u,c))}return e<rT?s>0?sT(r,n,i,s):r.addPoint(wc(0,0)):(r.removePoint(r.points[r.points.length-1]),s>0&&oT(r,n,i,s)),1}function Iz(r,e,t,n=0,i=0,s=0){let o=.5522847498,a=e*o,l=t*o;r.addPoint(qp(i-e,s,i-e,s-l,i-e,s+l)),r.addPoint(qp(i,s+t,i-a,s+t,i+a,s+t)),r.addPoint(qp(i+e,s,i+e,s+l,i+e,s-l)),r.addPoint(qp(i,s-t,i+a,s-t,i-a,s-t)),n>0&&oT(r,e,t,n)}function wc(r,e){return new fi(Be.generateUUID(),new B(r,e))}function qp(r,e,t,n,i,s){let o=wc(r,e);return o.controls[0].position.set(t,n),o.controls[1].position.set(i,s),o}function sT(r,e,t,n){aT(r,e,t,n).forEach(s=>r.addPoint(s))}function oT(r,e,t,n){let i=aT(r,e,t,n),s=new gt;i.forEach(o=>s.addPoint(o)),s.isClosed=!0,r.shapeHoles.push(s)}function aT(r,e,t,n){let i=n*e/100,s=i*(Math.abs(t)/Math.abs(e)),o=new B(i/e,s/t),a=r.points.map(l=>{let u=l.clone();return u.uuid=Be.generateUUID(),u}).reverse();return a.forEach(l=>{l.position.multiply(o);let u=l.controls[0].position.clone().multiply(o),c=l.controls[1].position.clone().multiply(o);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),a}var lT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??n),s=Math.abs(t.depth??n),o=Math.abs(Math.min(n,s))/2;return{parameters:Object.assign(t,{width:n,height:i,depth:s,radius:o,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(r){let{width:e,height:t,depth:n,radius:i,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:h}=r.parameters,d=new wh(!1,e,t,n,i,s,o,a,l,u,c,h);return Object.assign(d,{userData:{...r,type:"HelixGeometry"}})}},wh=class extends De{constructor(e=!0,t=1,n=1,i=1,s=1,o=1,a=1,l=1,u=1,c=1,h=1,d=1){super();let f=e&&o===1;f&&(d=0),h>100&&(h=100);let m=()=>new A,p=new A,g=m(),v=m(),y=m(),b,w,S,_,M,x,T,E,C=m(),P=m(),O=m(),D=m(),N=m(),F=m(),z=m(),Y=m(),U=n-2*l+.001,G=U/o,Q=Math.ceil(a*o),V=Q+1,k=U/Q,j=-U/2,q=c+1,W=2*Math.PI/c,he=Math.PI/2/d,ie=.01,K=Math.min((1-h/100)*l,l-ie),X=l-K,ne=0,ce=2,oe=d*ce+ce,Te=q*oe/ce,me=Te+q*V,ge=q*(V+oe),[ye,de,Pe]=[3,3,2].map(ve=>Array(ge*ve).fill(0)),Ne=[],Ze=s-l;function R(ve,H){let xe=Math.PI/2;x=H*k,E=2*Math.PI*(x%G)/G+xe,x+=j,T=Math.sin(E)*Ze,M=Math.cos(E)*Ze,e?ve.set(M,T,x):ve.set(M,x,T)}R(p,-1e-10),R(g,0),C.copy(p),R(p,1);let I=p.distanceTo(g),J=X+K,le=I*Q+2*J,fe=K,Ee=le-J;for(let ve=0;ve<=Q;ve++){R(v,ve),Y.subVectors(v,C).normalize(),C.copy(v),F.copy(v).setComponent(+e+1,0).normalize(),z.crossVectors(Y,F).normalize();let H=ve===0,xe=ve===Q,_e=H?3*Math.PI/2:he,Qe=H?fe:Ee,Re=H?q:me,Ke=H?0:ge-q,we=Y.clone().multiplyScalar(H?-X:X).add(v),Je=Y.clone().multiplyScalar(H?-1:1).normalize();for(let it=0;it<q;it++){let yt=it*W;if(P.addVectors(p.copy(F).multiplyScalar(l*Math.cos(yt)),g.copy(z).multiplyScalar(l*Math.sin(yt))),O.copy(P).normalize(),H||xe){f||(ne=Ke+it,[0,1,2].forEach(At=>{ye[ne*3+At]=we.getComponent(At),de[ne*3+At]=Je.getComponent(At)}),Pe[ne*2]=+xe,Pe[ne*2+1]=it/c),g.copy(O).multiplyScalar(K),y.addVectors(v,g);for(let At=0;At<d;At++){let cr=At*he+_e;D.addVectors(p.copy(Y).multiplyScalar(X*Math.sin(cr)),g.copy(O).multiplyScalar(X*Math.cos(cr))),N.copy(D).normalize(),g.addVectors(y,D),D.normalize(),ne=Re+At*q+it,[0,1,2].forEach(Ta=>{ye[ne*3+Ta]=g.getComponent(Ta),de[ne*3+Ta]=N.getComponent(Ta)});let pd=+H+Math.sin(cr);Pe[ne*2]=(Qe+X*pd)/le,Pe[ne*2+1]=it/c}}g.addVectors(v,P),ne=Te+ve*q+it,[0,1,2].forEach(At=>{ye[ne*3+At]=g.getComponent(At),de[ne*3+At]=O.getComponent(At)}),Pe[ne*2]=(J+ve*I)/le,Pe[ne*2+1]=it/c}}let Ue=V+2*d+ce,re=1,[Fe,Oe]=f?[re,re+V-1]:[0,Ue-1];for(let ve=Fe;ve<=Oe-1;ve++){let H=f&&ve===Oe-1;for(let xe=0;xe<q-1;xe++)b=ve*q+xe,w=b+1,S=(H?xe:b)+q,_=(H?xe+1:w)+q,ve===0?Ne.push(w,_,S):ve===Ue-2?Ne.push(b,w,S):Ne.push(b,w,S,w,_,S)}this.setIndex(Ne),this.setAttribute("position",new Ae(ye,3)),this.setAttribute("normal",new Ae(de,3)),this.setAttribute("uv",new Ae(Pe,2))}};var cT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,detail:0,corner:0,cornerSides:4},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,detail:i,corner:s,cornerSides:o}=r.parameters,a=i===0&&s!==0?new Sh(e*.5,s,o):new il(e*.5,i);return a.scale(1,t/e,n/e),Object.assign(a,{userData:{...r,type:"IcosahedronGeometry"}})}},Sh=class extends fo{constructor(e=1,t=.2,n=4){let i=(1+Math.sqrt(5))/2,s=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],o=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(s,o,a,e,t,n),this.type=a}static fromJSON(e){return new Sh(e.radius,e.corner,e.cornerSides)}};var uT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){(r.parameters?.points??[]).forEach(n=>{Array.isArray(n)&&(n.x=n[0],n.y=n[1])});let t=Object.assign({},e?.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}]},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{points:e,segments:t,verticalSegments:n}=r.parameters,i=new ds;i.moveTo(e[0].x,e[0].y),i.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new $a(i.extractPoints(n).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:{...r,type:"LatheGeometry"}})}};var Ui=new be,$v=new ht,Xp=new A,po=class extends Lt{constructor(){super(),this.uuid=Be.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(e){let t=new jt().getNormalMatrix(e);for(let n=0,i=this.vertices.length;n<i;n++)this.vertices[n].applyMatrix4(e);for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];s.normal.applyMatrix3(t).normalize();for(let o=0,a=s.vertexNormals.length;o<a;o++)s.vertexNormals[o].applyMatrix3(t).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return Ui.makeRotationX(e),this.applyMatrix4(Ui),this}rotateY(e){return Ui.makeRotationY(e),this.applyMatrix4(Ui),this}rotateZ(e){return Ui.makeRotationZ(e),this.applyMatrix4(Ui),this}translate(e,t,n){return Ui.makeTranslation(e,t,n),this.applyMatrix4(Ui),this}scale(e,t,n){return Ui.makeScale(e,t,n),this.applyMatrix4(Ui),this}lookAt(e){return $v.lookAt(e),$v.updateMatrix(),this.applyMatrix4($v.matrix),this}fromBufferGeometry(e){let t=this,n=e.index!==null?e.index:void 0,i=e.attributes;if(i.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let s=i.position,o=i.normal,a=i.color,l=i.uv,u=i.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<s.count;d++)t.vertices.push(new A().fromBufferAttribute(s,d)),a!==void 0&&t.colors.push(new Le().fromBufferAttribute(a,d));function c(d,f,m,p){let g=a===void 0?[]:[t.colors[d].clone(),t.colors[f].clone(),t.colors[m].clone()],v=o===void 0?[]:[new A().fromBufferAttribute(o,d),new A().fromBufferAttribute(o,f),new A().fromBufferAttribute(o,m)],y=new Sc(d,f,m,v,g,p);t.faces.push(y),l!==void 0&&t.faceVertexUvs[0].push([new B().fromBufferAttribute(l,d),new B().fromBufferAttribute(l,f),new B().fromBufferAttribute(l,m)]),u!==void 0&&t.faceVertexUvs[1].push([new B().fromBufferAttribute(u,d),new B().fromBufferAttribute(u,f),new B().fromBufferAttribute(u,m)])}let h=e.groups;if(h.length>0)for(let d=0;d<h.length;d++){let f=h[d],m=f.start,p=f.count;for(let g=m,v=m+p;g<v;g+=3)n!==void 0?c(n.getX(g),n.getX(g+1),n.getX(g+2),f.materialIndex):c(g,g+1,g+2,f.materialIndex)}else if(n!==void 0)for(let d=0;d<n.count;d+=3)c(n.getX(d),n.getX(d+1),n.getX(d+2));else for(let d=0;d<s.count;d+=3)c(d,d+1,d+2);return this.computeFaceNormals(),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xp).negate(),this.translate(Xp.x,Xp.y,Xp.z),this}normalize(){this.computeBoundingSphere();let e=this.boundingSphere.center,t=this.boundingSphere.radius,n=t===0?1:1/t,i=new be;return i.set(n,0,0,-n*e.x,0,n,0,-n*e.y,0,0,n,-n*e.z,0,0,0,1),this.applyMatrix4(i),this}computeFaceNormals(){let e=new A,t=new A;for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=this.vertices[s.a],a=this.vertices[s.b],l=this.vertices[s.c];e.subVectors(l,a),t.subVectors(o,a),e.cross(t),e.normalize(),s.normal.copy(e)}}computeVertexNormals(e=!0){let t=new Array(this.vertices.length);for(let n=0,i=this.vertices.length;n<i;n++)t[n]=new A;if(e){let n=new A,i=new A;for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=this.vertices[a.a],u=this.vertices[a.b],c=this.vertices[a.c];n.subVectors(c,u),i.subVectors(l,u),n.cross(i),t[a.a].add(n),t[a.b].add(n),t[a.c].add(n)}}else{this.computeFaceNormals();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n];t[s.a].add(s.normal),t[s.b].add(s.normal),t[s.c].add(s.normal)}}for(let n=0,i=this.vertices.length;n<i;n++)t[n].normalize();for(let n=0,i=this.faces.length;n<i;n++){let s=this.faces[n],o=s.vertexNormals;o.length===3?(o[0].copy(t[s.a]),o[1].copy(t[s.b]),o[2].copy(t[s.c])):(o[0]=t[s.a].clone(),o[1]=t[s.b].clone(),o[2]=t[s.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let n=this.faces[e],i=n.vertexNormals;i.length===3?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.__originalFaceNormal?i.__originalFaceNormal.copy(i.normal):i.__originalFaceNormal=i.normal.clone(),i.__originalVertexNormals||(i.__originalVertexNormals=[]);for(let s=0,o=i.vertexNormals.length;s<o;s++)i.__originalVertexNormals[s]?i.__originalVertexNormals[s].copy(i.vertexNormals[s]):i.__originalVertexNormals[s]=i.vertexNormals[s].clone()}let e=new po;e.faces=this.faces;for(let t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];let s=this.morphNormals[t].faceNormals,o=this.morphNormals[t].vertexNormals;for(let a=0,l=this.faces.length;a<l;a++){let u=new A,c={a:new A,b:new A,c:new A};s.push(u),o.push(c)}}let i=this.morphNormals[t];e.vertices=this.morphTargets[t].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let s=0,o=this.faces.length;s<o;s++){let a=this.faces[s],l=i.faceNormals[s],u=i.vertexNormals[s];l.copy(a.normal),u.a.copy(a.vertexNormals[0]),u.b.copy(a.vertexNormals[1]),u.c.copy(a.vertexNormals[2])}}for(let t=0,n=this.faces.length;t<n;t++){let i=this.faces[t];i.normal=i.__originalFaceNormal,i.vertexNormals=i.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Mt),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new En),this.boundingSphere.setFromPoints(this.vertices)}merge(e,t,n=0){if(!(e&&e.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);return}let i,s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,u=e.faces,c=this.colors,h=e.colors;t!==void 0&&(i=new jt().getNormalMatrix(t));for(let d=0,f=a.length;d<f;d++){let p=a[d].clone();t!==void 0&&p.applyMatrix4(t),o.push(p)}for(let d=0,f=h.length;d<f;d++)c.push(h[d].clone());for(let d=0,f=u.length;d<f;d++){let m=u[d],p,g,v=m.vertexNormals,y=m.vertexColors,b=new Sc(m.a+s,m.b+s,m.c+s);b.normal.copy(m.normal),i!==void 0&&b.normal.applyMatrix3(i).normalize();for(let w=0,S=v.length;w<S;w++)p=v[w].clone(),i!==void 0&&p.applyMatrix3(i).normalize(),b.vertexNormals.push(p);b.color.copy(m.color);for(let w=0,S=y.length;w<S;w++)g=y[w],b.vertexColors.push(g.clone());b.materialIndex=m.materialIndex+n,l.push(b)}for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let v=m[p],y=[];for(let b=0,w=v.length;b<w;b++)y.push(v[b].clone());this.faceVertexUvs[d].push(y)}}}mergeMesh(e){if(!(e&&e.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)}mergeVertices(e=4){let t={},n=[],i=[],s=Math.pow(10,e);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],h=Math.round(c.x*s)+"_"+Math.round(c.y*s)+"_"+Math.round(c.z*s);t[h]===void 0?(t[h]=l,n.push(this.vertices[l]),i[l]=n.length-1):i[l]=i[t[h]]}let o=[];for(let l=0,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=i[c.a],c.b=i[c.b],c.c=i[c.c];let h=[c.a,c.b,c.c];for(let d=0;d<3;d++)if(h[d]===h[(d+1)%3]){o.push(l);break}}for(let l=o.length-1;l>=0;l--){let u=o[l];this.faces.splice(u,1);for(let c=0,h=this.faceVertexUvs.length;c<h;c++)this.faceVertexUvs[c].splice(u,1)}let a=this.vertices.length-n.length;return this.vertices=n,a}setFromPoints(e){this.vertices=[];for(let t=0,n=e.length;t<n;t++){let i=e[t];this.vertices.push(new A(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){let e=this.faces,t=e.length;for(let l=0;l<t;l++)e[l]._id=l;function n(l,u){return l.materialIndex-u.materialIndex}e.sort(n);let i=this.faceVertexUvs[0],s=this.faceVertexUvs[1],o,a;i&&i.length===t&&(o=[]),s&&s.length===t&&(a=[]);for(let l=0;l<t;l++){let u=e[l]._id;o&&o.push(i[u]),a&&a.push(s[u])}o&&(this.faceVertexUvs[0]=o),a&&(this.faceVertexUvs[1]=a)}toJSON(){let e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),this.parameters!==void 0){let m=this.parameters;for(let p in m)m[p]!==void 0&&(e[p]=m[p]);return e}let t=[];for(let m=0;m<this.vertices.length;m++){let p=this.vertices[m];t.push(p.x,p.y,p.z)}let n=[],i=[],s={},o=[],a={},l=[],u={};for(let m=0;m<this.faces.length;m++){let p=this.faces[m],g=!0,v=!1,y=this.faceVertexUvs[0][m]!==void 0,b=p.normal.length()>0,w=p.vertexNormals.length>0,S=p.color.r!==1||p.color.g!==1||p.color.b!==1,_=p.vertexColors.length>0,M=0;if(M=c(M,0,0),M=c(M,1,g),M=c(M,2,v),M=c(M,3,y),M=c(M,4,b),M=c(M,5,w),M=c(M,6,S),M=c(M,7,_),n.push(M),n.push(p.a,p.b,p.c),n.push(p.materialIndex),y){let x=this.faceVertexUvs[0][m];n.push(f(x[0]),f(x[1]),f(x[2]))}if(b&&n.push(h(p.normal)),w){let x=p.vertexNormals;n.push(h(x[0]),h(x[1]),h(x[2]))}if(S&&n.push(d(p.color)),_){let x=p.vertexColors;n.push(d(x[0]),d(x[1]),d(x[2]))}}function c(m,p,g){return g?m|1<<p:m&~(1<<p)}function h(m){let p=m.x.toString()+m.y.toString()+m.z.toString();return s[p]!==void 0||(s[p]=i.length/3,i.push(m.x,m.y,m.z)),s[p]}function d(m){let p=m.r.toString()+m.g.toString()+m.b.toString();return a[p]!==void 0||(a[p]=o.length,o.push(m.getHex())),a[p]}function f(m){let p=m.x.toString()+m.y.toString();return u[p]!==void 0||(u[p]=l.length/2,l.push(m.x,m.y)),u[p]}return e.data={},e.data.vertices=t,e.data.normals=i,o.length>0&&(e.data.colors=o),l.length>0&&(e.data.uvs=[l]),e.data.faces=n,e}clone(){return new po().copy(this)}copy(e){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=e.name;let t=e.vertices;for(let d=0,f=t.length;d<f;d++)this.vertices.push(t[d].clone());let n=e.colors;for(let d=0,f=n.length;d<f;d++)this.colors.push(n[d].clone());let i=e.faces;for(let d=0,f=i.length;d<f;d++)this.faces.push(i[d].clone());for(let d=0,f=e.faceVertexUvs.length;d<f;d++){let m=e.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let p=0,g=m.length;p<g;p++){let v=m[p],y=[];for(let b=0,w=v.length;b<w;b++){let S=v[b];y.push(S.clone())}this.faceVertexUvs[d].push(y)}}let s=e.morphTargets;for(let d=0,f=s.length;d<f;d++){let m={};if(m.name=s[d].name,s[d].vertices!==void 0){m.vertices=[];for(let p=0,g=s[d].vertices.length;p<g;p++)m.vertices.push(s[d].vertices[p].clone())}if(s[d].normals!==void 0){m.normals=[];for(let p=0,g=s[d].normals.length;p<g;p++)m.normals.push(s[d].normals[p].clone())}this.morphTargets.push(m)}let o=e.morphNormals;for(let d=0,f=o.length;d<f;d++){let m={};if(o[d].vertexNormals!==void 0){m.vertexNormals=[];for(let p=0,g=o[d].vertexNormals.length;p<g;p++){let v=o[d].vertexNormals[p],y={};y.a=v.a.clone(),y.b=v.b.clone(),y.c=v.c.clone(),m.vertexNormals.push(y)}}if(o[d].faceNormals!==void 0){m.faceNormals=[];for(let p=0,g=o[d].faceNormals.length;p<g;p++)m.faceNormals.push(o[d].faceNormals[p].clone())}this.morphNormals.push(m)}let a=e.skinWeights;for(let d=0,f=a.length;d<f;d++)this.skinWeights.push(a[d].clone());let l=e.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let u=e.lineDistances;for(let d=0,f=u.length;d<f;d++)this.lineDistances.push(u[d]);let c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());let h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){let e=new e0().fromGeometry(this),t=new De,n=new Float32Array(e.vertices.length*3);if(t.setAttribute("position",new Ge(n,3).copyVector3sArray(e.vertices)),e.normals.length>0){let i=new Float32Array(e.normals.length*3);t.setAttribute("normal",new Ge(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){let i=new Float32Array(e.colors.length*3);t.setAttribute("color",new Ge(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){let i=new Float32Array(e.uvs.length*2);t.setAttribute("uv",new Ge(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){let i=new Float32Array(e.uvs2.length*2);t.setAttribute("uv2",new Ge(i,2).copyVector2sArray(e.uvs2))}t.groups=e.groups;for(let i in e.morphTargets){let s=[],o=e.morphTargets[i];for(let a=0,l=o.length;a<l;a++){let u=o[a],c=new Ae(u.data.length*3,3);c.name=u.name,s.push(c.copyVector3sArray(u.data))}t.morphAttributes[i]=s}if(e.skinIndices.length>0){let i=new Ae(e.skinIndices.length*4,4);t.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){let i=new Ae(e.skinWeights.length*4,4);t.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return e.boundingSphere!==null&&(t.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(t.boundingBox=e.boundingBox.clone()),t}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let t=new De,n=e.geometry;if(e.isPoints||e.isLine){let i=new Ae(n.vertices.length*3,3),s=new Ae(n.colors.length*3,3);if(t.setAttribute("position",i.copyVector3sArray(n.vertices)),t.setAttribute("color",s.copyColorsArray(n.colors)),n.lineDistances&&n.lineDistances.length===n.vertices.length){let o=new Ae(n.lineDistances.length,1);t.setAttribute("lineDistance",o.copyArray(n.lineDistances))}n.boundingSphere!==null&&(t.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(t.boundingBox=n.boundingBox.clone())}else e.isMesh&&(t=n.toBufferGeometry());return t}};po.prototype.isGeometry=!0;var e0=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(e){let t=[],n,i,s,o=e.faces;for(i=0;i<o.length;i++){let a=o[i];a.materialIndex!==s&&(s=a.materialIndex,n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:s})}n!==void 0&&(n.count=i*3-n.start,t.push(n)),this.groups=t}fromGeometry(e){let t=e.faces,n=e.vertices,i=e.faceVertexUvs,s=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,l=a.length,u;if(l>0){u=[];for(let v=0;v<l;v++)u[v]={name:a[v].name,data:[]};this.morphTargets.position=u}let c=e.morphNormals,h=c.length,d;if(h>0){d=[];for(let v=0;v<h;v++)d[v]={name:c[v].name,data:[]};this.morphTargets.normal=d}let f=e.skinIndices,m=e.skinWeights,p=f.length===n.length,g=m.length===n.length;n.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let v=0;v<t.length;v++){let y=t[v];this.vertices.push(n[y.a],n[y.b],n[y.c]);let b=y.vertexNormals;if(b.length===3)this.normals.push(b[0],b[1],b[2]);else{let S=y.normal;this.normals.push(S,S,S)}let w=y.vertexColors;if(w.length===3)this.colors.push(w[0],w[1],w[2]);else{let S=y.color;this.colors.push(S,S,S)}if(s===!0){let S=i[0][v];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",v),this.uvs.push(new B,new B,new B))}if(o===!0){let S=i[1][v];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",v),this.uvs2.push(new B,new B,new B))}for(let S=0;S<l;S++){let _=a[S].vertices;u[S].data.push(_[y.a],_[y.b],_[y.c])}for(let S=0;S<h;S++){let _=c[S].vertexNormals[v];d[S].data.push(_.a,_.b,_.c)}p&&this.skinIndices.push(f[y.a],f[y.b],f[y.c]),g&&this.skinWeights.push(m[y.a],m[y.b],m[y.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}},Sc=class{constructor(e,t,n,i,s,o=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new A,this.vertexNormals=Array.isArray(i)?i:[],this.color=s&&s.isColor?s:new Le,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}};var Lz=["a","b","c"];function Oz(r,e){switch(e){case"c":return r.c;case"b":return r.b;case"a":default:return r.a}}function t0(r,e,t){let n=Math.min(r,e),i=Math.max(r,e),s=n+"_"+i;return t.get(s)}function n0(r,e,t,n,i,s){let o=Math.min(r,e),a=Math.max(r,e),l=o+"_"+a,u;if(n.has(l))u=n.get(l);else{let c=t[o],h=t[a];u={a:c,b:h,newEdge:null,faces:[]},n.set(l,u)}u.faces.push(i),s[r].edges.push(u),s[e].edges.push(u)}function Rz(r,e,t,n){let i,s,o;for(i=0,s=r.length;i<s;i++)t[i]={edges:[]};for(i=0,s=e.length;i<s;i++)o=e[i],n0(o.a,o.b,r,n,o,t),n0(o.b,o.c,r,n,o,t),n0(o.c,o.a,r,n,o,t)}function Yp(r,e,t,n,i){r.push(new Sc(e,t,n,void 0,void 0,i))}function Ac(r,e){return Math.abs(e-r)/2+Math.min(r,e)}function Qp(r,e,t,n){r.push([e.clone(),t.clone(),n.clone()])}var Zp=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof De?e=new po().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new A,n,i,s,o,a,l=e.vertices,u=e.faces,c=e.faceVertexUvs[0],h=c!==void 0&&c.length>0,d=[],f=new Map;Rz(l,u,d,f);let m=[],p,g,v,y,b,w,S;for(let ie of Array.from(f.keys())){for(g=f.get(ie),v=new A,b=3/8,w=1/8,S=g.faces.length,S!=2&&(b=.5,w=0,S!=1),v.addVectors(g.a,g.b).multiplyScalar(b),t.set(0,0,0),o=0;o<S;o++){for(y=g.faces[o],a=0;a<3&&(p=l[Oz(y,Lz[a])],!(p!==g.a&&p!==g.b));a++);p&&t.add(p)}t.multiplyScalar(w),v.add(t),g.newEdge=m.length,m.push(v)}let _,M,x,T,E,C,P,O=[];for(i=0,s=l.length;i<s;i++){for(C=l[i],E=d[i].edges,n=E.length,n==3?_=3/16:n>3&&(_=3/(8*n)),M=1-n*Number(_),x=_,n<=2&&(n==2?(M=3/4,x=1/8):n==1||n==0),P=C.clone().multiplyScalar(M),t.set(0,0,0),o=0;o<n;o++)T=E[o],p=T.a!==C?T.a:T.b,t.add(p);t.multiplyScalar(Number(x)),P.add(t),O.push(P)}let D=O.concat(m),N=O.length,F,z,Y,U=[],G=[],Q,V,k,j,q=new B,W=new B,he=new B;for(i=0,s=u.length;i<s;i++)y=u[i],F=Number(t0(y.a,y.b,f).newEdge)+N,z=Number(t0(y.b,y.c,f).newEdge)+N,Y=Number(t0(y.c,y.a,f).newEdge)+N,Yp(U,F,z,Y,y.materialIndex),Yp(U,y.a,F,Y,y.materialIndex),Yp(U,y.b,z,F,y.materialIndex),Yp(U,y.c,Y,z,y.materialIndex),h&&(Q=c[i],V=Q[0],k=Q[1],j=Q[2],q.set(Ac(V.x,k.x),Ac(V.y,k.y)),W.set(Ac(k.x,j.x),Ac(k.y,j.y)),he.set(Ac(V.x,j.x),Ac(V.y,j.y)),Qp(G,q,W,he),Qp(G,V,q,he),Qp(G,k,W,q),Qp(G,j,he,W));e.vertices=D,e.faces=U,h&&(e.faceVertexUvs[0]=G)}};var bn=new A,hT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=r.geometry??e?.geometry??new De().copy(new ur(100,100,100)),n;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(bn),n={width:bn.x,height:bn.y,depth:bn.z,subdivisions:0}):n=e.parameters;let i={...n,...r.parameters};return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:t}}static build(r){let{width:e,height:t,depth:n,subdivisions:i}=r.parameters,s=r.geometry??new De().copy(new ur(100,100,100)),o=s.userData.parameters;o===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(bn)):bn.set(o.width,o.height,o.depth),(e!==bn.x||t!==bn.y||n!==bn.z)&&s.scale(bn.x===0?1:e/bn.x,bn.y===0?1:t/bn.y,bn.z===0?1:n/bn.z);let a=s.originalGeometry;return i>0?(a===void 0||o?.subdivisions!==i)&&(a===void 0&&(a=s),s=new Zp(i).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete r.geometry,Object.assign(s,{userData:{...r,type:"NonParametricGeometry"}})}static loadFromUrl(r,e,t){new ul(t).load(r,i=>{let s=this.normalizeInputs({geometry:i});i.boundingBox.getSize(bn);let o=100/bn.x;Object.assign(s.parameters,{width:100,height:bn.y*o,depth:bn.z*o}),e(this.build(s))})}};var dT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,spikes:n,cornerRadius:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}=r.parameters,l=r.shape,u=e*.5,c=t*.5,h=0,d=0,f=2*Math.PI/n;for(let p=0;p<n;p++){let g=f*p,v=h+Math.sin(g)*u,y=d+Math.cos(g)*c;l.addPoint(l.createPoint(v,y))}l.isClosed=!0;for(let p=0,g=l.points.length;p<g;p++)l.points[p].roundness=i;l.roundness=i,l.update();let m=Un.create({shape:l,parameters:{roundness:i,depth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(m,{userData:{...r,type:"PolygonGeometry"}})}};var fT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=new i0(e*.5,t,i,s,o,a,l);return u.scale(1,1,n/e),Object.assign(u,{userData:{...r,type:"PyramidGeometry"}})}};function Ah(r,e,t){t.x=r.x*e.x,t.y=r.y,t.z=r.x*e.y}function r0(r,e,t,n,i,s){let o=e.clone().sub(r),a=t.clone().sub(r),l=o.angleTo(a);if(o.normalize(),a.normalize(),n===i){let u=o.add(a).normalize();s.copy(r).addScaledVector(u,n/Math.sin(l/2))}else{let u=o.angleTo(a);s.copy(r),s.addScaledVector(o,i/Math.sin(u)),s.addScaledVector(a,n/Math.sin(u))}}function Nz(r,e,t){let n=r.clone().sub(e),i=t.clone().sub(e);return n.projectOnVector(i),n.add(e)}var i0=class extends De{constructor(e=.5,t=1,n=4,i=1,s=!1,o=0,a=4){super(),n=Math.floor(Math.max(3,n)),i=Math.floor(i),a=Math.floor(a);let l=[],u=[],c=[],h=[],d=0,f=t/2,m=Math.PI/n,p=e*Math.cos(Math.PI/n),g=2*Math.PI/n,v=(n-2)*Math.PI/n,y=Math.PI-v,b=new A(0,-f,0),w=new A(0,f,0),S=new B(e,-f),_=new B(p,-f),M=new B(0,w.y).sub(_),x=new B(0,w.y).sub(S),T=new B(M.y,-M.x).normalize(),E=new B(x.y,-x.x).normalize(),P=e*Math.cos(Math.PI/n)*Math.tan((Math.PI-M.angle())/2)-1e-8;o=Math.min(o,P);let O;{let G=new A(T.x,T.y,0),Q=new A(Math.cos(g)*G.x,G.y,Math.sin(g)*G.x);O=G.angleTo(Q)}let D=o/Math.tan((Math.PI-M.angle())/2),N=o/Math.tan((Math.PI-O)/2),F=new A;if(!s){u.push(b.x,b.y,b.z),c.push(0,-1,0),h.push(0,0);let G=d++,Q=[],V=S.clone(),k=D/Math.cos(Math.PI/n);V.x-=k;for(let j=0;j<n;j++){let q=j/n*Math.PI*2+m,W=new B(Math.sin(q),Math.cos(q));Ah(V,W,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),h.push(0,0),Q.push(d++)}for(let j=0;j<Q.length;j++)l.push(Q[j],G,Q[(j+1)%Q.length])}let z=[];{let G=new A,Q=new A,V=new A,k=new A,j=new A,q=new A;for(let W=0;W<n;W++){let he=W/n*Math.PI*2+m,ie=(W+.5)/n*Math.PI*2+m,K=(W+1)/n*Math.PI*2+m,X=new B(Math.sin(he),Math.cos(he)),ne=new B(Math.sin(ie),Math.cos(ie)),ce=new B(Math.sin(K),Math.cos(K));Ah(S,X,Q),Ah(S,ce,V),Ah(T,ne,G),r0(w,Q,V,N,N,k),u.push(k.x,k.y,k.z),r0(Q,w,V,N,D,j),u.push(j.x,j.y,j.z),r0(V,Q,w,D,N,q),u.push(q.x,q.y,q.z),c.push(G.x,G.y,G.z),c.push(G.x,G.y,G.z),c.push(G.x,G.y,G.z),h.push(0,0),h.push(0,0),h.push(0,0);let oe=d++,Te=d++,me=d++;if(l.push(oe,Te,me),o>0){{let de=Q.clone().add(V).multiplyScalar(.5),Pe=w.clone().sub(de).normalize(),Ze=b.clone().sub(de).normalize().add(Pe).normalize().multiplyScalar(-1),R=q.clone().sub(j);Y(de,R,Ze,M.angle())}let ge,ye;{let de=new A;Ah(E,ce,de);let Pe=q.clone().add(k).multiplyScalar(.5);Pe=Nz(Pe,V,w);let Ne=q.clone().sub(k);[ge,ye]=Y(Pe,Ne,de,O,k.y)}{let de=ge,Pe=de.clone().setY(0).normalize(),Ne=new A(0,-1,0),Ze=Pe.clone().cross(Ne);U(de,Pe,Ne,Ze)}z.concat(ye);{let de=M.angle(),Pe=Math.PI-de,Ne=w.clone();Ne.y-=o/Math.sin(de-Math.PI/2);let Ze=new A,R=[];for(let J=0;J<a;J++){let le=[],fe=Math.PI/2-Pe*J/a,Ee=Math.cos(fe),Ue=Math.sin(fe),re=ie;for(let Fe=0;Fe<=J;Fe++){let Oe=Math.cos(re),ve=Math.sin(re);G.x=Ee*ve,G.y=Ue,G.z=Ee*Oe,Ze.copy(Ne).addScaledVector(G,o),u.push(Ze.x,Ze.y,Ze.z),c.push(G.x,G.y,G.z),h.push(0,0),le.push(d++),re+=Math.PI*2/J/n}R.push(le)}ye.reverse(),R.push(ye);let I=R.length-1;for(let J=0;J<I;J++){let le=R[J],fe=R[J+1],Ee=le.length-1;l.push(fe[1],le[0],fe[0]);for(let Ue=1;Ue<=Ee;Ue++)l.push(le[Ue],le[Ue-1],fe[Ue]),l.push(fe[Ue+1],le[Ue],fe[Ue])}}}}}this.setIndex(l),this.setAttribute("position",new Ae(u,3)),this.setAttribute("normal",new Ae(c,3)),this.setAttribute("uv",new Ae(h,2));function Y(G,Q,V,k,j){let q=-k/2,W=(Math.PI-k)/2,he=Q.clone().normalize().cross(V);G.addScaledVector(V,-o/Math.sin(W));let ie=new A,K=new A,X=1,ne=d,ce=[];for(let oe=0;oe<=a;oe++){let Te=q+oe/a*k;K.set(0,0,0),K.addScaledVector(he,Math.sin(Te)),K.addScaledVector(V,Math.cos(Te));for(let me=0;me<=X;me++){let ge=me/X-.5;if(ie.copy(G),ie.addScaledVector(Q,ge),ie.addScaledVector(K,o),j!=null){let ye=Math.max(0,ie.y-j);ie.addScaledVector(Q,-ye/Q.y)}u.push(ie.x,ie.y,ie.z),c.push(K.x,K.y,K.z),h.push(0,0),me===0&&ce.push(d),d++}}for(let oe=0;oe<a;oe++)for(let Te=0;Te<X;Te++){let me=ne+Te+(X+1)*oe,ge=me+(X+1),ye=ge+1,de=me+1;l.push(me,ge,de),l.push(ge,ye,de)}return[G.clone().addScaledVector(Q,.5),ce]}function U(G,Q,V,k){let j=Math.PI/2,q=x.angle()-j,W=[],he=new A,ie=new A;for(let X=0;X<=a;X++){let ne=[],ce=X/a;for(let oe=0;oe<=X;oe++){let me=((X?oe/X:0)-.5)*y,ge=Math.cos(me),ye=Math.sin(me),de=Math.atan(Math.tan(q)*ge),Pe=(j+de)*ce,Ne=Math.cos(Pe),Ze=Math.sin(Pe);he.set(0,0,0),he.addScaledVector(Q,Ze*ge),he.addScaledVector(V,Ne),he.addScaledVector(k,Ze*ye),ie.copy(G).addScaledVector(he,o),u.push(ie.x,ie.y,ie.z),c.push(he.x,he.y,he.z),h.push(0,0),ne.push(d++)}W.push(ne)}let K=W.length-1;for(let X=0;X<K;X++){let ne=W[X],ce=W[X+1],oe=ne.length-1;l.push(ne[0],ce[1],ce[0]);for(let Te=1;Te<=oe;Te++)l.push(ne[Te-1],ne[Te],ce[Te]),l.push(ne[Te],ce[Te+1],ce[Te])}}}};var pT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters),n=Object.assign(e?.ui??{enabledIndieCorners:!1},r.ui);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)}),ui:n}}static build(r){let e=r.shape,{width:t,height:n,cornerRadius:i,cornerType:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}=r.parameters,u={x:t*.5,y:n*.5},c={x:-u.x,y:-u.y},h={x:u.x,y:u.y};function d(w,S,_){return S>t&&_>n?Math.min(w*t/S,w*n/_):S>t?w*t/S:_>n?w*n/_:w}let f=[];f[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),f[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),f[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),f[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let m=c.x,p=h.x,g=h.y,v=c.y;e.addPoint(e.createPoint(m,g)),e.addPoint(e.createPoint(p,g)),e.addPoint(e.createPoint(p,v)),e.addPoint(e.createPoint(m,v)),e.isClosed=!0;let y=!0;for(let w=0,S=e.points.length;w<S;w++)e.points[w].roundness=f[w],w>0&&f[w]!==f[w-1]&&(y=!1);y&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let b=Un.create({shape:e,parameters:{depth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(b,{userData:{...r,type:"RectangleGeometry"}})}};var mT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e=100,height:t=e,depth:n=e,widthSegments:i=64,heightSegments:s=64,phiStart:o,phiLength:a,thetaStart:l,thetaLength:u}=r.parameters,c=new Wo(.5*e,i,s,o,a,l,u);return c.scale(1,t/e,n/e),Object.assign(c,{userData:{...r,type:"SphereGeometry"}})}};var gT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:0})}}static build(r){let{width:e=100,height:t=e,widthSegments:n=8,heightSegments:i=8}=r.parameters,s=new hs(e,t,n,i);return s.scale(1,1,1),Object.assign(s,{userData:{...r,type:"PlaneGeometry"}})}};var yT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width)})}}static build(r){let{width:e,height:t,depth:n,angle:i,cornerRadius:s,cornerSegments:o}=r.parameters,a=new s0(e,t,n,i,s,o);return Object.assign(a,{userData:{...r,type:"BackdropGeometry"}})}},s0=class extends De{constructor(e=1,t=1,n=1,i=90,s=10,o=24){super(),this.type="BackdropGeometry";let a=[],l=[],u=[],c=.001;s==0&&(o=1),o=Math.max(1,Math.floor(o)),s=Math.min(s,100),i=Math.min(180-c,i),i*=Math.PI/180;let h=[],d=Math.PI/2,f=(ie=0,K=0,X=0)=>new A(ie,K,X),m=f(),p=f(),[g,v,y]=[t/2,e/2,n/2],b=-v,w=+v,[S,_,M]=[f(b,-g,+y),f(b,-g,-y),f(b,+g,-y)],x=(ie,K=!1)=>Math.sin(ie-Math.PI/(1+ +K)),T=(ie,K=!1)=>Math.cos(ie-Math.PI/(1+ +K));M.y=Math.sin(i)*t-g;let E=Math.cos(i)*t-y,C=S.z-c;i<=d?(M.z=Math.min(E,C),M.z==C&&(M.y-=(E-C)/Math.tan(d-i))):_.z=Math.min(_.z-E-y,S.z-c),m.subVectors(S,_),p.subVectors(M,_);let P=Math.min(m.length(),p.length())*s/100,O=P*Math.tan(i/2),D=P/Math.cos(i/2),N=m.clone().normalize().add(p.normalize()).setLength(D).add(_);m.set(0,x(i,!0),T(i,!0)),h.push([M,m.clone()]);let F=(Math.PI-i)/o;for(let ie=0;ie<=o;ie++){let K=d+i+ie*F;m.set(0,Math.sin(K)*O,Math.cos(K)*O),m.add(N),p.set(0,x(K),T(K)),h.push([m.clone(),p.clone()])}h.push([S,f(0,1,0)]);let z=Math.sin(F/2)*O*2,Y=h.length-1,U=h[0][0].distanceTo(h[1][0]),G=h[Y-1][0].distanceTo(h[Y][0]),Q=U+z*o+G;h[0].push(1);for(let ie=0;ie<=o;ie++)h[ie+1].push(1-(U+ie*z)/Q);h[Y].push(0);let[V,k,j]=h[0],q,W,he;for(let ie=1;ie<h.length;ie++)[q,W,he]=h[ie],a.push(b,V.y,V.z,b,q.y,q.z,w,V.y,V.z,w,V.y,V.z,b,q.y,q.z,w,q.y,q.z),l.push(0,k.y,k.z,0,W.y,W.z,0,k.y,k.z,0,k.y,k.z,0,W.y,W.z,0,W.y,W.z),u.push(0,j,0,he,1,j,1,j,0,he,1,he),[V,k,j]=[q,W,he];this.setAttribute("position",new Ae(a,3)),this.setAttribute("normal",new Ae(l,3)),this.setAttribute("uv",new Ae(u,2))}};var vT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t,innerRadiusPercent:n,spikes:i,cornerRadius:s,angle:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}=r.parameters,c=r.shape,h=e*.5,d=t*.5,f=0,m=0,p=o*Math.PI/360/i,g=Math.PI/2*3*-1,v=h*n/100,y=d*n/100;if(i===3&&n===50){p=2*Math.PI/i;for(let w=0;w<i;w++){let S=p*w,_=f+Math.sin(S)*h,M=m+Math.cos(S)*d;c.addPoint(c.createPoint(_,M))}}else for(let w=0;w<i;w++){let S=f+Math.cos(g)*h,_=m+Math.sin(g)*d;c.addPoint(c.createPoint(S,_)),g+=p,S=f+Math.cos(g)*v,_=m+Math.sin(g)*y,w<=i,c.addPoint(c.createPoint(S,_)),g+=p}c.isClosed=!0;for(let w=0,S=c.points.length;w<S;w++)c.points[w].roundness=s;c.roundness=s,c.update();let b=Un.create({shape:c,parameters:{roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(b,{userData:{...r,type:"StarGeometry"}})}};var xT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e,height:t}=r.parameters,n=new hs(e,t);return Object.assign(n,{userData:{...r,type:"TextFrameGeometry"}})}};var bT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},r.parameters),n=Math.abs(t.width),i=Math.abs(t.height??t.width),s=Math.abs(t.depth??t.width*.25);return{parameters:Object.assign(t,{width:n,height:i,depth:s})}}static build(r){let{width:e,height:t,depth:n,radialSegments:i,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=r.parameters,u=Bz(e,t,n,e*.5,o,s,0,0,i,a,l);return u.scale(1,t/e,1),Object.assign(u,{userData:{...r,type:"TorusGeometry"}})}};function Bz(r,e,t,n,i,s,o,a,l,u,c){return[e,t]=[t,e],o=e/2,i/=2*Math.PI,i==1&&(u=0),new wh(!0,r,e,t,n,i,s,o,a,l,u,c)}var wT=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},r.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width),depth:Math.abs(t.depth??t.width),tube:t.tube??t.width*.125})}}static build(r){let{width:e,tube:t,tubularSegments:n,radialSegments:i,p:s,q:o}=r.parameters,a=e*.5;a!==t&&(a-=t);let l=new sl(a,t,n,i,s,o);return Object.assign(l,{userData:{...r,type:"TorusKnotGeometry"}})}};var ST=class{static create(r){return this.build(this.normalizeInputs(r))}static normalizeInputs(r,e){let t=Object.assign({},e?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},r.parameters);return{shape:r.shape&&r.shape instanceof gt?r.shape:new gt,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs(t.height??t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth??0)})}}static build(r){let{width:e=100,height:t,cornerRadius:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a}=r.parameters,l=r.shape,u=e*.5,c=t*.5;a?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=n;l.roundness=n,l.update();let h=Un.create({shape:l,parameters:{roundness:n,depth:i,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(h,{userData:{...r,type:"TriangleGeometry"}})}};function AT(){let r=new De;return r.setAttribute("position",new Ge(new Float32Array([]),3)),r.setIndex(new Ge(new Uint16Array([]),1)),r}var Fz=12;var _c=class extends De{constructor(t,n){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.vectorShapes=[];let i=AT();Object.entries(i.attributes).forEach(([s,o])=>{this.setAttribute(s,o)}),this.setIndex(i.index),this.updateFont(t.font,n),this.update(t)}async updateFont(t,n){let i=n.getFont(t);i&&(this.font=i,await i.loadingPromise)}async update(t){let n=this.font;if(this.userData={parameters:t,type:"TextGeometry"},!n||!n.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:i,height:s,depth:o,extrudeBevelSize:a,extrudeBevelSegments:l,text:u,textTransform:c,subdivisions:h}=t;await n.loadingPromise;let d=c===2?u.toUpperCase():c===3?u.toLowerCase():u,f=Uz(t,n,d),{shapes:m,charWidths:p,charCoords:g}=await n.generateShapes(f,t),v=i*.5,y=s*.5,b=m.map(_=>new gt().fromShape(_));this.vectorShapes=b;let w=b.map(_=>Un.create({shape:_,parameters:{depth:o,extrudeBevelSegments:l,extrudeBevelSize:a,windingRule:o<=0?It.NONZERO:It.ODD,subdivisions:h??Fz}})),S=w.length?xs(w):AT();S.translate(-v,y,0),this.dispose(),this.wrappedText=f,this.charCoords=g,this.charWidths=p,Object.entries(S.attributes).forEach(([_,M])=>{this.setAttribute(_,M)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let t=aa(new De,_c.prototype);return t.copy(this),t}copy(t){return Object.entries(t.attributes).forEach(([n,i])=>{this.setAttribute(n,i)}),this.setIndex(t.index),this.userData={parameters:{...t.userData.parameters},type:"TextGeometry"},this}async setText(t){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:t})}get text(){return this.userData.parameters.text??""}};function Uz(r,e,t){t=t??r.text;let n=[""],i="";for(let s of t)i+=s,s===" "||s===`
3138
3138
  `?(n[n.length-1]+=i,i="",s===`
3139
- `&&n.push("")):e.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),e.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var TT,Kp=new Promise(r=>{TT=r}),_T=!1;async function MT(){if(_T)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.127/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});TT(s),_T=!0}function Jp(r,e){return zz(r)}function zz(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=gt.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new ul().parse(r));let t;try{t=_h(e)}catch(n){console.error(n)}if(!t){let n=gt.createFromState(Ql.defaultData(),100,100);e.shape=n,t=_h(e)}return t}var qe;Kp.then(r=>{qe=r});var ET=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),CT=new Uint32Array([0,1,2,3]),PT=new Uint8Array([4]),Zr=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(qe.free_bvh(t),qe.free_subdivision_surface(t));try{s=Zr.allocate(r,i)}catch(u){console.error(u,r),s=Zr.allocate({positionWASM:ET,indexWASM:CT,verticesPerFaceWASM:PT},i)}qe.set_destination_refinement_level(s,0),o=Zr.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=Zr.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(qe.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=Zr.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:Jp(r),n,i,s,o;({positions:n,triIndices:o}=Th(t.getAttribute("position"),t.getIndex()));let a;if(r.type==="CylinderGeometry"&&r.cornerRadius===0&&r.hollow===0&&r.openEnded===!1){let l=r.radialSegments*r.heightSegments*3*2,u=l+r.radialSegments*3;a=[l,u]}return{indices:i,verticesPerFace:s}=c0(n,o,t,a),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=ET,n=CT,i=PT);let a=t.length,l=n.length,u=i.length,c=t.length+s.length+o.length,h=n.length+i.length,d=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,f=c*Float32Array.BYTES_PER_ELEMENT,m=h*Uint32Array.BYTES_PER_ELEMENT,p=qe._malloc(d),g=new Float32Array(qe.HEAPF32.buffer,p,c),v=new Uint32Array(qe.HEAPU32.buffer,p+f,h);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),v.set(n,0),v.set(i,n.length);let y;r?.scaleBaked?.some(b=>b!==1)&&(y=new be().makeScale(...r.scaleBaked)),e&&(y?y.premultiply(e):y=e);let w=y?qe.alloc_subdivision_surface2(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u,y.elements):qe.alloc_subdivision_surface(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u);return qe._free(p),w}static buildLevel(r,e,t,n,i){let s=i?qe.get_mesh_data2(r,e?qe.Level.CONTROL:qe.Level.REFINED,t,i.elements):qe.get_mesh_data(r,e?qe.Level.CONTROL:qe.Level.REFINED,t),o=8,a=qe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),u=0,c=qe.HEAPU32[a[u]>>2],h=qe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=qe.HEAPU32[a[u]>>2],f=qe.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let m=qe.HEAPU32[a[u]>>2],p=qe.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g=qe.HEAPU32[a[u]>>2],v=qe.HEAPU32.subarray(g>>2,(g>>2)+l[u]);if(u++,n===void 0){let y=new De;if(y.setIndex(new zs(v,1)),y.setAttribute("position",new Ae(h,3)),y.setAttribute("normal",new Ae(f,3)),e){y.setAttribute("faceMap",new zs(p,1));let w=new Float32Array(f.length/3*4).fill(0);y.setAttribute("color",new Ge(w,4))}return qe.free_mesh_data(s),y.userData.type="SubdivGeometry",y}n.getAttribute("position").copyArray(h),n.getAttribute("normal").copyArray(f),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,qe.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=qe.get_wireframe_data_for_base_level(r),i=4,s=qe.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=qe.HEAPU32[s[a]>>2],u=qe.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let c=qe.HEAPU32[s[a]>>2],h=qe.HEAPU32.subarray(c>>2,(c>>2)+o[a]);if(e===void 0){let d=new De;d.setAttribute("position",new Ae(u,3));let f=new Float32Array(u.length);for(let m=0,p=u.length;m<p;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return d.setAttribute("color",new Ge(f,3)),d.setIndex(new zs(h,1)),qe.free_wireframe_data_for_base_level(n),d}e.getAttribute("position").copyArray(u),e.attributes.position.needsUpdate=!0,qe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){let n=e===0;n||qe.set_destination_refinement_level(r,e);let i=t?qe.get_topological_data2(r,n?qe.Level.CONTROL:qe.Level.REFINED,t.elements):qe.get_topological_data(r,n?qe.Level.CONTROL:qe.Level.REFINED),s=6,o=qe.HEAPU32.subarray(i>>2,(i>>2)+s),a=o.subarray(3,3+3),l=0,u=qe.HEAPU32[o[l]>>2],c=new Float32Array(qe.HEAPF32.subarray(u>>2,(u>>2)+a[l]));l++;let h=qe.HEAPU32[o[l]>>2],d=new Uint32Array(qe.HEAPU32.subarray(h>>2,(h>>2)+a[l]));l++;let f=qe.HEAPU32[o[l]>>2],m=new Uint8Array(qe.HEAPU32.subarray(f>>2,(f>>2)+a[l]));return qe.free_topological_data(i),{positions:c,indices:d,verticesPerFace:m}}};var DT=["getX","getY","getZ"];function Th(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=e?e.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(r[DT[d]](c)*a)},`;if(h in t)s.push(t[h]);else{for(let d=0;d<3;d++)o.push(r[DT[d]](c));t[h]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var $p=new A,o0=new A,a0=new A,l0=new A;function c0(r,e,t,n){let i=[],s=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let o=t.userData.shape.extractShapePointsToFlatArray([]),a=0;for(let u=0;u<o.length;u+=2)a+=(o[u]-o[(u===0?o.length:u)-2])*(o[u+1]+o[(u===0?o.length:u)-1]);r.length=0;let l=0;if(a<0)for(let u=0;u<o.length;u+=2)r.push(o[u],o[u+1],0),i.push(l++);else for(let u=o.length-2;u>=0;u-=2)r.push(o[u],o[u+1],0),i.push(l++);return s.push(l),{indices:i,verticesPerFace:s}}for(let o=0,a=t.capStartIndex??e.length;o<a;)if(e[o+1]===e[o+3]&&e[o+2]===e[o+5]||e[o+0]===e[o+3]&&e[o+2]===e[o+4]){$p.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),o0.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),a0.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),l0.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),o0.sub($p).normalize(),a0.sub($p).normalize(),l0.sub($p).normalize();let l=o0.cross(a0).dot(l0);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3):(i.push(e[o],e[o+1],e[o+4],e[o+5]),s.push(4),o+=6)}else i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3;if(t.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([t.userData.parameters.depth])[0];for(let c=0,h=0;c<r.length;c+=3,h++)r[c+2]===0&&(o.push(h),l++),r[c+2]===u&&a.push(h);if(t.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var pi={};EC(pi,{calcBoolean:()=>Hz,calcBooleanTopological:()=>Vz,freeMeshSet:()=>qz,getMeshSet:()=>Wz,transformMeshSet:()=>jz});var LT,OT=new Promise(r=>{LT=r}),IT=!1;async function RT(){if(IT)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.127/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});LT(s),IT=!0}var lt,Tc;OT.then(r=>lt=r);function kz(r,e,t){let n,{positions:i,triIndices:s}=Th(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=c0(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let h=0;h<l[u];h++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function NT(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=lt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(lt.HEAPU32.buffer,s,e):new Float32Array(lt.HEAPF32.buffer,s,e)).set(r,0),s}function BT(r){switch(r){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function Vz(r,e){Tc===void 0&&(Tc=lt.init_csg());let t=NT(r),n=lt.csg_calc_topological(Tc,t,r.length,BT(e));lt._free(t);let i=6,s=lt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=lt.HEAPU32[s[a]>>2],u=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=lt.HEAPU32[s[a]>>2],h=new Uint32Array(lt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=lt.HEAPU32[s[a]>>2],f=new Uint8Array(lt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return lt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:f}}function Hz(r,e,t,n){Tc===void 0&&(Tc=lt.init_csg());let i=NT(r),s=lt.csg_calc(Tc,i,r.length,n,BT(e));lt._free(i);let o=5,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=lt.HEAPU32[a[u]>>2],h=lt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=lt.HEAPU32[a[u]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let m=l[u];t.setAttribute("position",new Ae(h,3)),t.setAttribute("normal",new Ae(f,3));let p=lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new En),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},lt.free_mesh_data(s),m}function Wz(r,e,t){if(lt===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+s);for(let v=0,y=0,w=0;v<g.verticesPerFace.length;v++){i[w++]=g.verticesPerFace[v];for(let b=0;b<g.verticesPerFace[v];b++)i[w++]=g.indices[y++]}}else({positions:n,faceIndices:i,nFaces:s}=kz(r,e,t));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=lt._malloc(c),m=new Float32Array(lt.HEAPF32.buffer,f,l),p=new Uint32Array(lt.HEAPU32.buffer,f+h,u);return m.set(n,0),p.set(i,0),lt.get_csg_mesh(f,o,f+h,a,s)}function jz(r,e){lt.transform_csg_mesh(r,e.elements)}function qz(r){lt.free_csg_mesh(r)}var u0={ConeGeometry:K_,CubeGeometry:J_,CylinderGeometry:Z_,DodecahedronGeometry:$_,EllipseGeometry:iT,HelixGeometry:lT,IcosahedronGeometry:cT,LatheGeometry:uT,NonParametricGeometry:hT,PolygonGeometry:dT,PyramidGeometry:fT,RectangleGeometry:pT,SphereGeometry:mT,PlaneGeometry:gT,BackdropGeometry:yT,StarGeometry:vT,TextFrameGeometry:xT,TorusGeometry:bT,TorusKnotGeometry:wT,TriangleGeometry:ST,VectorGeometry:Un},_h=r=>u0[r.type].create(r);function In(r,e){return e.color(r)}var Kr=r=>"isEntity"in r,kt=r=>"isAbstractMesh"in r,Vt=r=>r!==null&&r.objectType==="BooleanObject",FT=r=>r.objectType==="CombinedCamera",UT=r=>Kr(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var h0=r=>r.objectType==="EmptyObject",em=r=>"objectHelper"in r;function d0(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??io.identity)),t&&(r.updateMatrix(),Vt(r.parent)&&kt(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function Xz(r,e){d0(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.visible=e.visible)}function GT(r,e,t){Xz(r,e),e.color!==void 0&&(r.color=In(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof Xo)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof Xo)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0)}function zT(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var tm=r=>class extends r{hasEntityChild(){return this.children.some(t=>Kr(t))}isDescendantOf(t){t instanceof ht&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Kr(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var Mc=new Mt,mi=new A,Gi=new A,Ec=new be,VT=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],Yz=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Qz=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function Zz(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t;c<n;c++){let h=e.getX(c),d=e.getY(c),f=e.getZ(c);h<i&&(i=h),d<s&&(s=d),f<o&&(o=f),h>a&&(a=h),d>l&&(l=d),f>u&&(u=f)}return r.min.set(i,s,o),r.max.set(a,l,u),r}var kT=(r,e,t)=>{if(kt(r)){let n=r.geometry.userData.parameters,i=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?mi.copy(r.originalGeometry.boundingSphere.center):r.geometry.userData.type==="TextGeometry"?mi.set(0,0,n.depth*.5):i!==void 0&&(Zz(Mc,i,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:i.count),Mc.getCenter(mi)),r.forceComputeSize?Mc.getSize(Gi).multiplyScalar(.5):Gi.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}else if(em(r)&&r.objectHelper.visible){let n=r.geometryHelper.getAttribute("position");Mc.setFromArray(n.array),Mc.getCenter(mi),Mc.getSize(Gi).multiplyScalar(.5)}else mi.setScalar(0),Gi.setScalar(0);Ec.copy(e).multiply(r.matrixWorld),Gi.x===0&&Gi.y===0&&Gi.z===0?t.push(new A(mi.x,mi.y,mi.z).applyMatrix4(Ec)):VT.forEach(n=>{t.push(n.clone().multiply(Gi).add(mi).applyMatrix4(Ec))})},Mh=class extends Mt{constructor(){super(...arguments);this.matrix=new be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&kT(o,n,s)}):kT(t,n,s),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(Ec.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Gi).multiplyScalar(.5),this.getCenter(mi),Ec.copy(this.matrix).setPosition(mi),this.vertices=VT.map(t=>t.clone().multiply(Gi).applyMatrix4(Ec))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Yz.map(([t,n])=>new gn(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Qz.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var zi=r=>"isEntity"in r,HT=r=>"isAbstractMesh"in r,Jr=r=>class extends tm(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new be;this._singleBBox=new Mh;this._recursiveBBox=new Mh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1;this.states={};this.currentState=null;this.currentTransitionAction=null}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{zi(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)zi(i)&&i.traverseEntity(n)}traverseVisibleEntity(n){n(this);for(let i of this.children)zi(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(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,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)zi(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)zi(s)&&s.hiddenMatrix.premultiply(n)}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return kl(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return kl(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visible=n.visible),this.fromObjectTransformState(n),this}};var Eh=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var Ln=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Be.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof Ln&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}};var f0=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},wn=new f0;var ke=class extends Ln{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=Be.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let u=this.getTemp(t,i);if(u)return t.format(u,l,n);{u=super.generate(t,n,i,a.output,s);let c=this.generate(t,l,i);return t.addNodeCode(u+" = "+c+";"),t.format(u,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Ot=class extends ke{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}};var On=class extends Ot{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof B?t:new B(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var Gn=class extends Ot{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var $t=class extends Le{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var $r=class extends Ot{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof $t?t:new $t(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var Kz=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,WT=/[a-z_0-9]+/gi,Me=class extends ke{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)t.include(this.includes[h],this);for(let h in this.extensions)t.extensions[h]=!0;let c=[];for(;a=WT.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&wn.containsKeyword(f)){let g=this.keywords[f];if(!g){let v=wn.getKeywordData(f);v.cache&&(g=t.keywords[f]),g=g||wn.getKeyword(f,t),v.cache&&(t.keywords[f]=g)}p=g.build(t)}f!==p&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+p+u.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&wn.contains(p)&&t.include(wn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||t.include(this,void 0,u),this.name):t.format("( "+u+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=Kz.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(WT);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var Jz=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,p0=class extends ke{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||p0.PI,void 0,void 0,void 0,n)}getType(t){return t.getTypeByFormat(this.type)}parse(t,n,i,s,o){this.src=t||"";let a,l,u="",c=Jz.exec(t);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(t,n){if(n==="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 t.include(this),t.format(this.name,this.getType(t),n)}generate(t,n,i,s,o){return t.format(this.name,this.getType(t),n)}},ft=p0;ft.PI="PI",ft.PI2="PI2",ft.RECIPROCAL_PI="RECIPROCAL_PI",ft.RECIPROCAL_PI2="RECIPROCAL_PI2",ft.LOG2="LOG2",ft.EPSILON="EPSILON";var $z=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3139
+ `&&n.push("")):e.getTextWidth(n[n.length-1]+i,r)>r.width&&(n[n.length-1].length&&n.push(""),e.getTextWidth(n[n.length-1]+i,r)>r.width&&(i.length===1?(n[n.length-1]+=i,i=""):(n[n.length-1]+=i.slice(0,-1),i=i[i.length-1],n.push(""))));return n[n.length-1]+=i,n}var TT,Kp=new Promise(r=>{TT=r}),_T=!1;async function MT(){if(_T)return;let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@0.9.129/build",[t,n]=await Promise.all([import("./process.js"),fetch(`${e}/process.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});TT(s),_T=!0}function Jp(r,e){return zz(r)}function zz(r){let e={parameters:r,type:r.type};if(r.type==="VectorGeometry"){let n=gt.createFromState(r.shape,r.width,r.height);e.shape=n}else r.type==="NonParametricGeometry"&&(r.data.groups&&r.data.groups.forEach(n=>n.materialIndex=Math.max(n.materialIndex??0,0)),e.geometry=new ul().parse(r));let t;try{t=_h(e)}catch(n){console.error(n)}if(!t){let n=gt.createFromState(Ql.defaultData(),100,100);e.shape=n,t=_h(e)}return t}var qe;Kp.then(r=>{qe=r});var ET=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),CT=new Uint32Array([0,1,2,3]),PT=new Uint8Array([4]),Zr=class{static build(r,e,t,n,i){let s,o,a,l=r?.phongAngle??e?.phongAngle??35;if(n===!1&&(l=-1),r.positionWASM!==void 0){t&&t!==0&&(qe.free_bvh(t),qe.free_subdivision_surface(t));try{s=Zr.allocate(r,i)}catch(u){console.error(u,r),s=Zr.allocate({positionWASM:ET,indexWASM:CT,verticesPerFaceWASM:PT},i)}qe.set_destination_refinement_level(s,0),o=Zr.buildLevel(s,!0,l)}else s=t,r.phongAngle!==void 0&&(o=Zr.buildLevel(s,!0,l));return r.subdivisions!==void 0&&(qe.set_destination_refinement_level(s,r.subdivisions),r.subdivisions>0?a=Zr.buildLevel(s,!1,l):a=null),{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}}static primitiveToQuads(r,e){r.widthSegments>16&&(r.widthSegments=16),r.heightSegments>16&&(r.heightSegments=16),r.depthSegments>16&&(r.depthSegments=16),r.radialSegments>16&&(r.radialSegments=16),r.type==="DodecahedronGeometry"&&(r.detail=0);let t=r.shape!==void 0?e.geometry:Jp(r),n,i,s,o;({positions:n,triIndices:o}=Th(t.getAttribute("position"),t.getIndex()));let a;if(r.type==="CylinderGeometry"&&r.cornerRadius===0&&r.hollow===0&&r.openEnded===!1){let l=r.radialSegments*r.heightSegments*3*2,u=l+r.radialSegments*3;a=[l,u]}return{indices:i,verticesPerFace:s}=c0(n,o,t,a),{positions:n,indices:i,verticesPerFace:s}}static allocate(r,e){let t,n,i,s=[],o=[];r.positionWASM&&r.positionWASM.length>0?(t=r.positionWASM,n=r.indexWASM,i=r.verticesPerFaceWASM):(t=ET,n=CT,i=PT);let a=t.length,l=n.length,u=i.length,c=t.length+s.length+o.length,h=n.length+i.length,d=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT,f=c*Float32Array.BYTES_PER_ELEMENT,m=h*Uint32Array.BYTES_PER_ELEMENT,p=qe._malloc(d),g=new Float32Array(qe.HEAPF32.buffer,p,c),v=new Uint32Array(qe.HEAPU32.buffer,p+f,h);g.set(t,0),g.set(s,t.length),g.set(o,t.length+s.length),v.set(n,0),v.set(i,n.length);let y;r?.scaleBaked?.some(w=>w!==1)&&(y=new be().makeScale(...r.scaleBaked)),e&&(y?y.premultiply(e):y=e);let b=y?qe.alloc_subdivision_surface2(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u,y.elements):qe.alloc_subdivision_surface(p,a,p+f,l,p+f+n.length*Uint32Array.BYTES_PER_ELEMENT,u);return qe._free(p),b}static buildLevel(r,e,t,n,i){let s=i?qe.get_mesh_data2(r,e?qe.Level.CONTROL:qe.Level.REFINED,t,i.elements):qe.get_mesh_data(r,e?qe.Level.CONTROL:qe.Level.REFINED,t),o=8,a=qe.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(4,4+4),u=0,c=qe.HEAPU32[a[u]>>2],h=qe.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=qe.HEAPU32[a[u]>>2],f=qe.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let m=qe.HEAPU32[a[u]>>2],p=qe.HEAPU32.subarray(m>>2,(m>>2)+l[u]);u++;let g=qe.HEAPU32[a[u]>>2],v=qe.HEAPU32.subarray(g>>2,(g>>2)+l[u]);if(u++,n===void 0){let y=new De;if(y.setIndex(new zs(v,1)),y.setAttribute("position",new Ae(h,3)),y.setAttribute("normal",new Ae(f,3)),e){y.setAttribute("faceMap",new zs(p,1));let b=new Float32Array(f.length/3*4).fill(0);y.setAttribute("color",new Ge(b,4))}return qe.free_mesh_data(s),y.userData.type="SubdivGeometry",y}n.getAttribute("position").copyArray(h),n.getAttribute("normal").copyArray(f),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,qe.free_mesh_data(s)}static buildControlCageWireframe(r,e,t){let n=qe.get_wireframe_data_for_base_level(r),i=4,s=qe.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(2,2+2),a=0,l=qe.HEAPU32[s[a]>>2],u=qe.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;let c=qe.HEAPU32[s[a]>>2],h=qe.HEAPU32.subarray(c>>2,(c>>2)+o[a]);if(e===void 0){let d=new De;d.setAttribute("position",new Ae(u,3));let f=new Float32Array(u.length);for(let m=0,p=u.length;m<p;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return d.setAttribute("color",new Ge(f,3)),d.setIndex(new zs(h,1)),qe.free_wireframe_data_for_base_level(n),d}e.getAttribute("position").copyArray(u),e.attributes.position.needsUpdate=!0,qe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(r,e,t){let n=e===0;n||qe.set_destination_refinement_level(r,e);let i=t?qe.get_topological_data2(r,n?qe.Level.CONTROL:qe.Level.REFINED,t.elements):qe.get_topological_data(r,n?qe.Level.CONTROL:qe.Level.REFINED),s=6,o=qe.HEAPU32.subarray(i>>2,(i>>2)+s),a=o.subarray(3,3+3),l=0,u=qe.HEAPU32[o[l]>>2],c=new Float32Array(qe.HEAPF32.subarray(u>>2,(u>>2)+a[l]));l++;let h=qe.HEAPU32[o[l]>>2],d=new Uint32Array(qe.HEAPU32.subarray(h>>2,(h>>2)+a[l]));l++;let f=qe.HEAPU32[o[l]>>2],m=new Uint8Array(qe.HEAPU32.subarray(f>>2,(f>>2)+a[l]));return qe.free_topological_data(i),{positions:c,indices:d,verticesPerFace:m}}};var DT=["getX","getY","getZ"];function Th(r,e){let t={},n=e?e.count:r.count,i=0,s=[],o=[],a=1e4;for(let u=0;u<n;u++){let c=e?e.getX(u):u,h="";for(let d=0;d<3;d++)h+=`${~~(r[DT[d]](c)*a)},`;if(h in t)s.push(t[h]);else{for(let d=0;d<3;d++)o.push(r[DT[d]](c));t[h]=i,s.push(i),i++}}let l=[];for(let u=0;u<s.length;u+=3)s[u]===s[u+1]||s[u]===s[u+2]||s[u+1]===s[u+2]||l.push(s[u],s[u+1],s[u+2]);return{positions:o,triIndices:l}}var $p=new A,o0=new A,a0=new A,l0=new A;function c0(r,e,t,n){let i=[],s=[];if(t.userData.shape!==void 0&&t.userData.parameters.depth===0&&t.userData.shape.shapeHoles.length===0){let o=t.userData.shape.extractShapePointsToFlatArray([]),a=0;for(let u=0;u<o.length;u+=2)a+=(o[u]-o[(u===0?o.length:u)-2])*(o[u+1]+o[(u===0?o.length:u)-1]);r.length=0;let l=0;if(a<0)for(let u=0;u<o.length;u+=2)r.push(o[u],o[u+1],0),i.push(l++);else for(let u=o.length-2;u>=0;u-=2)r.push(o[u],o[u+1],0),i.push(l++);return s.push(l),{indices:i,verticesPerFace:s}}for(let o=0,a=t.capStartIndex??e.length;o<a;)if(e[o+1]===e[o+3]&&e[o+2]===e[o+5]||e[o+0]===e[o+3]&&e[o+2]===e[o+4]){$p.set(r[e[o]*3],r[e[o]*3+1],r[e[o]*3+2]),o0.set(r[e[o+1]*3],r[e[o+1]*3+1],r[e[o+1]*3+2]),a0.set(r[e[o+4]*3],r[e[o+4]*3+1],r[e[o+4]*3+2]),l0.set(r[e[o+5]*3],r[e[o+5]*3+1],r[e[o+5]*3+2]),o0.sub($p).normalize(),a0.sub($p).normalize(),l0.sub($p).normalize();let l=o0.cross(a0).dot(l0);Math.abs(l)>.005||n&&n.some((u,c)=>c%2===1?!1:o>=n[c]&&o<n[c+1])?(i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3):(i.push(e[o],e[o+1],e[o+4],e[o+5]),s.push(4),o+=6)}else i.push(e[o],e[o+1],e[o+2]),s.push(3),o+=3;if(t.capStartIndex!==void 0){let o=[],a=[],l=0,u=new Float32Array([t.userData.parameters.depth])[0];for(let c=0,h=0;c<r.length;c+=3,h++)r[c+2]===0&&(o.push(h),l++),r[c+2]===u&&a.push(h);if(t.userData.parameters.extrudeBevelSize===0){let c=a[0];a[0]=a[1],a[1]=c}o.reverse(),i.push(...o,...a),s.push(l,l)}return{indices:i,verticesPerFace:s}}var pi={};EC(pi,{calcBoolean:()=>Hz,calcBooleanTopological:()=>Vz,freeMeshSet:()=>qz,getMeshSet:()=>Wz,transformMeshSet:()=>jz});var LT,OT=new Promise(r=>{LT=r}),IT=!1;async function RT(){if(IT)return;let e=!1?".":"https://unpkg.com/@splinetool/boolean-wasm@0.9.129/build",[t,n]=await Promise.all([import("./boolean.js"),fetch(`${e}/boolean.wasm`).then(o=>o.arrayBuffer())]),s=await t.default({wasmBinary:n});LT(s),IT=!0}var lt,Tc;OT.then(r=>lt=r);function kz(r,e,t){let n,{positions:i,triIndices:s}=Th(r.getAttribute("position"),r.getIndex()),o;if(e&&t){let{indices:a,verticesPerFace:l}=c0(i,s,r);o=l.length,n=[];for(let u=0,c=0;u<o;u++){n.push(l[u]);for(let h=0;h<l[u];h++)n.push(a[c++])}}else{let a=s.length;n=Array(a+a/3),o=0;for(let l=0,u=0;u<n.length;)n[u++]=3,o++,n[u++]=s[l++],n[u++]=s[l++],n[u++]=s[l++]}return{positions:i,faceIndices:n,nFaces:o}}function NT(r){let e=r.length,t=e*Uint32Array.BYTES_PER_ELEMENT,n=e*Float32Array.BYTES_PER_ELEMENT,i=Number.isInteger(r[0])?t:n,s=lt._malloc(i);return(Number.isInteger(r[0])?new Uint32Array(lt.HEAPU32.buffer,s,e):new Float32Array(lt.HEAPF32.buffer,s,e)).set(r,0),s}function BT(r){switch(r){case 0:return lt.OP.UNION;case 1:return lt.OP.INTERSECTION;case 2:return lt.OP.A_MINUS_B;case 3:return lt.OP.B_MINUS_A;case 4:return lt.OP.SYMMETRIC_DIFFERENCE;case 5:return lt.OP.ALL;default:throw new Error("Unknown boolean operation "+r)}}function Vz(r,e){Tc===void 0&&(Tc=lt.init_csg());let t=NT(r),n=lt.csg_calc_topological(Tc,t,r.length,BT(e));lt._free(t);let i=6,s=lt.HEAPU32.subarray(n>>2,(n>>2)+i),o=s.subarray(3,3+3),a=0,l=lt.HEAPU32[s[a]>>2],u=new Float32Array(lt.HEAPF32.subarray(l>>2,(l>>2)+o[a]));a++;let c=lt.HEAPU32[s[a]>>2],h=new Uint32Array(lt.HEAPU32.subarray(c>>2,(c>>2)+o[a]));a++;let d=lt.HEAPU32[s[a]>>2],f=new Uint8Array(lt.HEAPU32.subarray(d>>2,(d>>2)+o[a]));return lt.free_mesh_data(n),{positions:u,indices:h,verticesPerFace:f}}function Hz(r,e,t,n){Tc===void 0&&(Tc=lt.init_csg());let i=NT(r),s=lt.csg_calc(Tc,i,r.length,n,BT(e));lt._free(i);let o=5,a=lt.HEAPU32.subarray(s>>2,(s>>2)+o),l=a.subarray(2,2+3),u=0,c=lt.HEAPU32[a[u]>>2],h=lt.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let d=lt.HEAPU32[a[u]>>2],f=lt.HEAPF32.subarray(d>>2,(d>>2)+l[u]);u++;let m=l[u];t.setAttribute("position",new Ae(h,3)),t.setAttribute("normal",new Ae(f,3));let p=lt.HEAPF32.subarray((s>>2)+5,(s>>2)+5+6);return t.boundingSphere===null&&(t.boundingSphere=new En),t.boundingSphere.center.set(p[0],p[1],p[2]),t.boundingSphere.radius=(p[3]**2+p[4]**2+p[5]**2)**.5,t.userData.parameters={width:p[3]*2,height:p[4]*2,depth:p[5]*2},lt.free_mesh_data(s),m}function Wz(r,e,t){if(lt===void 0)return-1;let n,i,s;if(e&&r.userData.positions!==void 0){let g=r.userData;s=g.verticesPerFace.length,n=g.positions,i=Array(g.verticesPerFace.reduce((v,y)=>v+y,0)+s);for(let v=0,y=0,b=0;v<g.verticesPerFace.length;v++){i[b++]=g.verticesPerFace[v];for(let w=0;w<g.verticesPerFace[v];w++)i[b++]=g.indices[y++]}}else({positions:n,faceIndices:i,nFaces:s}=kz(r,e,t));let o=n.length,a=i.length,l=n.length,u=i.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,h=l*Float32Array.BYTES_PER_ELEMENT,d=u*Uint32Array.BYTES_PER_ELEMENT,f=lt._malloc(c),m=new Float32Array(lt.HEAPF32.buffer,f,l),p=new Uint32Array(lt.HEAPU32.buffer,f+h,u);return m.set(n,0),p.set(i,0),lt.get_csg_mesh(f,o,f+h,a,s)}function jz(r,e){lt.transform_csg_mesh(r,e.elements)}function qz(r){lt.free_csg_mesh(r)}var u0={ConeGeometry:K_,CubeGeometry:J_,CylinderGeometry:Z_,DodecahedronGeometry:$_,EllipseGeometry:iT,HelixGeometry:lT,IcosahedronGeometry:cT,LatheGeometry:uT,NonParametricGeometry:hT,PolygonGeometry:dT,PyramidGeometry:fT,RectangleGeometry:pT,SphereGeometry:mT,PlaneGeometry:gT,BackdropGeometry:yT,StarGeometry:vT,TextFrameGeometry:xT,TorusGeometry:bT,TorusKnotGeometry:wT,TriangleGeometry:ST,VectorGeometry:Un},_h=r=>u0[r.type].create(r);function In(r,e){return e.color(r)}var Kr=r=>"isEntity"in r,kt=r=>"isAbstractMesh"in r,Vt=r=>r!==null&&r.objectType==="BooleanObject",FT=r=>r.objectType==="CombinedCamera",UT=r=>Kr(r)&&(r.objectType==="LightDirectional"||r.objectType==="LightSpot"||r.objectType==="LightPoint");var h0=r=>r.objectType==="EmptyObject",em=r=>"objectHelper"in r;function d0(r,e){let t=!1;e.position&&(r.position.fromArray(e.position),t=!0),e.rotation&&(r.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,r.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in r&&(t=!0,r.hiddenMatrix.fromArray(e.hiddenMatrix??io.identity)),t&&(r.updateMatrix(),Vt(r.parent)&&kt(r)&&r.invalidateDownstreamBooleanData(!0).recomputeBoolean()),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&r.updateWorldMatrix(!1,!0),r.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(r.isUpVectorFlipped=e.isUpVectorFlipped),r.updateUp())}function Xz(r,e){d0(r,e),e.name!==void 0&&(r.name=e.name),e.visible!==void 0&&(r.visible=e.visible)}function GT(r,e,t){Xz(r,e),e.color!==void 0&&(r.color=In(e.color,t)),e.intensity!==void 0&&(r.intensity=e.intensity),e.shadows!==void 0&&!(r instanceof Xo)&&(r.castShadow=e.shadows),r.shadow&&!(r instanceof Xo)&&e.depth!==void 0&&(r.shadow.camera.far=e.depth,r.shadow.needsUpdate=!0)}function zT(r,e){r.shadow.camera.right=e/2,r.shadow.camera.left=-e/2,r.shadow.camera.top=e/2,r.shadow.camera.bottom=-e/2,r.shadow.needsUpdate=!0}var tm=r=>class extends r{hasEntityChild(){return this.children.some(t=>Kr(t))}isDescendantOf(t){t instanceof ht&&(t=t.uuid);let n=this;for(;n.parent;){if(n.parent.uuid===t)return!0;n=n.parent}return!1}attach(t,n){this.updateWorldMatrix(!0,!1);let i=new be().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),i.multiply(t.parent.matrixWorld)),Kr(t)?t.hiddenMatrix.premultiply(i):t.applyMatrix4(i),t.updateWorldMatrix(!1,!1),this.add(t),n!==void 0&&(this.children.pop(),this.children.splice(n,0,t)),this}copy(t,n=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),n===!0)for(let i=0;i<t.children.length;i++){let s=t.children[i];this.add(s.clone())}return this}};var Mc=new Mt,mi=new A,Gi=new A,Ec=new be,VT=[new A(-1,1,1),new A(-1,-1,1),new A(1,-1,1),new A(1,1,1),new A(-1,1,-1),new A(-1,-1,-1),new A(1,-1,-1),new A(1,1,-1)],Yz=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],Qz=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]];function Zz(r,e,t=0,n=e.count){let i=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,u=-1/0;for(let c=t;c<n;c++){let h=e.getX(c),d=e.getY(c),f=e.getZ(c);h<i&&(i=h),d<s&&(s=d),f<o&&(o=f),h>a&&(a=h),d>l&&(l=d),f>u&&(u=f)}return r.min.set(i,s,o),r.max.set(a,l,u),r}var kT=(r,e,t)=>{if(kt(r)){let n=r.geometry.userData.parameters,i=r.geometry.getAttribute("position");r.geometry.userData.type==="SubdivGeometry"?mi.copy(r.originalGeometry.boundingSphere.center):r.geometry.userData.type==="TextGeometry"?mi.set(0,0,n.depth*.5):i!==void 0&&(Zz(Mc,i,r.geometry.drawRange.start,r.geometry.drawRange.count<1/0?r.geometry.drawRange.count:i.count),Mc.getCenter(mi)),r.forceComputeSize?Mc.getSize(Gi).multiplyScalar(.5):Gi.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}else if(em(r)&&r.objectHelper.visible){let n=r.geometryHelper.getAttribute("position");Mc.setFromArray(n.array),Mc.getCenter(mi),Mc.getSize(Gi).multiplyScalar(.5)}else mi.setScalar(0),Gi.setScalar(0);Ec.copy(e).multiply(r.matrixWorld),Gi.x===0&&Gi.y===0&&Gi.z===0?t.push(new A(mi.x,mi.y,mi.z).applyMatrix4(Ec)):VT.forEach(n=>{t.push(n.clone().multiply(Gi).add(mi).applyMatrix4(Ec))})},Mh=class extends Mt{constructor(){super(...arguments);this.matrix=new be;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(t){return super.copy(t),this.matrix.copy(t.matrix),this.vertices=t.vertices.map(n=>n.clone()),this.faces=t.faces.map(n=>n.clone()),this.edges=t.edges.map(n=>n.clone()),this.centerEdges=t.centerEdges.map(n=>n.clone()),this}setFromObjectSize(t,n=!1){t.updateWorldMatrix(!1,n),this.makeEmpty(),this.matrix.copy(t.matrixWorld);let i=new be().copy(t.matrixWorld).invert();return this.expandByObjectSize(t,i,n)}expandByObjectSize(t,n,i=!1){let s=[];return i===!0?t.traverseEntity(o=>{o.visible&&kT(o,n,s)}):kT(t,n,s),this.setFromPoints(s)}getCenter(t){return t=super.getCenter(t),t.applyMatrix4(this.matrix),t}getPositionToCenter(t){return t=super.getCenter(t),t.applyMatrix4(Ec.copy(this.matrix).setPosition(0,0,0)),t}computeVertices(){this.getSize(Gi).multiplyScalar(.5),this.getCenter(mi),Ec.copy(this.matrix).setPosition(mi),this.vertices=VT.map(t=>t.clone().multiply(Gi).applyMatrix4(Ec))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=Yz.map(([t,n])=>new gn(this.vertices[t],this.vertices[n])),this.centerEdges=this.edges.map(t=>t.getCenter(new A))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=Qz.map(([t,n])=>this.vertices[t].clone().add(this.vertices[n]).multiplyScalar(.5))}};var zi=r=>"isEntity"in r,HT=r=>"isAbstractMesh"in r,Jr=r=>class extends tm(r){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new be;this._singleBBox=new Mh;this._recursiveBBox=new Mh;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1;this.states={};this.currentState=null;this.currentTransitionAction=null}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}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(n=>{zi(n)&&(n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(n=>{n.singleBBoxNeedsUpdate=!0,n.recursiveBBoxNeedsUpdate=!0})}traverseEntity(n){n(this);for(let i of this.children)zi(i)&&i.traverseEntity(n)}traverseVisibleEntity(n){n(this);for(let i of this.children)zi(i)&&i.visible&&i.traverseVisibleEntity(n)}updateMatrix(){super.updateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(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,n=!0);for(let i of this.children)i.updateMatrixWorld(n)}updateWorldMatrix(n,i){let s=this.parent;if(n&&s!==null&&s.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)),i)for(let o of this.children)o.updateWorldMatrix(!1,!0)}clone(n){return new this.constructor().copy(this,n)}copy(n,i=!0){if(super.copy(n,!1),this.raycastLock=n.raycastLock,this.scaleLock=n.scaleLock,this.hiddenMatrix.copy(n.hiddenMatrix),i===!0)for(let s of n.children)zi(s)&&this.add(s.clone());return this}keepChildrenMatrixWorld(){let n=new be,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),n.copy(this.matrixWorld).invert(),n.multiply(i);for(let s of this.children)zi(s)&&s.hiddenMatrix.premultiply(n)}toObjectTransformState(n=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return kl(i,n)}fromObjectTransformState(n){return n.position&&this.position.fromArray(n.position),n.rotation&&this.rotation.fromArray(n.rotation),n.scale&&this.scale.fromArray(n.scale),n.hiddenMatrix&&this.hiddenMatrix.fromArray(n.hiddenMatrix),this.updateMatrix(),this}toState(n=[]){let i={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(n)};return kl(i,n)}fromState(n,i){return n.name&&(this.name=n.name),n.raycastLock!==void 0&&(this.raycastLock=n.raycastLock),n.type!=="OrthographicCamera"&&n.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),n.visible!==void 0&&(this.visible=n.visible),this.fromObjectTransformState(n),this}};var Eh=class{constructor(e){e=e??{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};var Ln=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Be.generateUUID(),this.type=e,this.name=""}analyze(e,t){t=t??{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,n){return n=n??{},this.analyze(e,n),this.flow(e,t,n)}flow(e,t,n){n=n??{},e.addFlow(n.slot,n.cache,n.context);let i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,n){t=t??this.getType(e,t);let i=e.getNodeData(n??this);return e.analyzing&&this.appendDepsNode(e,i,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,n)}updateFrame(e){}generateReadonly(e,t,n,i,s,o){return""}generate(e,t,n,i,s){return""}parse(e,t,n,i){}appendDepsNode(e,t,n){t.deps=(t.deps||0)+1;let i=e.getTypeLength(n);(i>(t.outputMax||0)||this.getType(e,n))&&(t.outputMax=i,t.output=n)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getHash(){let e="{",t,n;for(t in this)n=this[t],n instanceof Ln&&(e+='"'+t+'":'+n.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)t=this.hashProperties[i],n=this[t],e+='"'+t+'":"'+String(n)+'",';return e+='"id":"'+this.uuid+'"}',e}};var f0=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,n){n=n!==void 0?n:!0,this.keywords[e]={callback:t,cache:n}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},wn=new f0;var ke=class extends Ln{constructor(t,n){super(t);this.scope="";n=n??{},this.shared=n.shared!==void 0?n.shared:!0,this.unique=n.unique!==void 0?n.unique:!1}build(t,n,i,s){if(n=n??this.getType(t),this.getShared(t,n)){let o=this.getUnique(t,n);o&&this.uuid===void 0&&(this.uuid=Be.generateUUID()),i=t.getUUID(i??this.getUUID(),!o);let a=t.getNodeData(i),l=a.output||this.getType(t);if(t.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(t,a,n),this.generate(t,n,i)):super.build(t,n,i);if(o)return a.name=a.name||super.build(t,n,i),a.name;if(!this.getLabel()&&(!this.getShared(t,l)||t.context.ignoreCache||a.deps===1))return super.build(t,n,i);i=this.getUUID(!1);let u=this.getTemp(t,i);if(u)return t.format(u,l,n);{u=super.generate(t,n,i,a.output,s);let c=this.generate(t,l,i);return t.addNodeCode(u+" = "+c+";"),t.format(u,l,n)}}return super.build(t,n,i)}getShared(t,n){return n!=="sampler2D"&&n!=="samplerCube"&&this.shared}getUnique(t,n){return this.unique}setLabel(t){return this.label=t,this}getLabel(){return this.label}getUUID(t){let n=this.uuid;return typeof this.scope=="string"&&(n=this.scope+"-"+n),n}getTemp(t,n){n=n||this.uuid;let i=t.getVars()[n];return i?i.name:void 0}generate(t,n,i,s,o){return this.getShared(t,n)||console.error("TempNode is not shared"),i=i??this.uuid,t.getTempVar(i,s??this.getType(t),o,this.getLabel()).name}};var Ot=class extends ke{constructor(t,n){n=n??{},n.shared=n.shared!==void 0?n.shared:!1;super(t,n);this.readonly=!1}setReadonly(t){return this.readonly=t,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(t,n,i,s,o,a){i=t.getUUID(i??this.getUUID()),s=s??this.getType(t);let l=t.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(t,n,i,s,o,a):t.isShader("vertex")?(l.vertex||(l.vertex=t.createVertexUniform(s,this,o,a,this.getLabel())),t.format(l.vertex.name,s,n)):(l.fragment||(l.fragment=t.createFragmentUniform(s,this,o,a,this.getLabel())),t.format(l.fragment.name,s,n))}};var On=class extends Ot{constructor(t=0,n){super("v2");this.nodeType="Vector2";this.value=t instanceof B?t:new B(t,n)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}generateReadonly(t,n,i,s,o,a){return t.format("vec2("+this.value.x+", "+this.value.y+")",s,n)}};var Gn=class extends Ot{constructor(t=0,n,i){super("v3");this.nodeType="Vector3";this.value=t instanceof A?t:new A(t,n,i)}get x(){return this.value.x}set x(t){this.value.x=t}get y(){return this.value.y}set y(t){this.value.y=t}get z(){return this.value.z}set z(t){this.value.z=t}generateReadonly(t,n,i,s,o,a){return t.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",s,n)}};var $t=class extends Le{constructor(t,n,i,s){super(t,n,i);this.isColorA=!0;this.a=s}setRGBA(t,n,i,s){super.setRGB(t,n,i),this.a=s}copy(t){return super.copy(t),this.a="a"in t?t.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(t){this.r=t}set y(t){this.g=t}set z(t){this.b=t}set w(t){this.a=t}};var $r=class extends Ot{constructor(t){super("v4");this.nodeType="Vector4";this.value=t instanceof $t?t:new $t(t.r,t.g,t.b,t.a)}generateReadonly(t,n,i,s,o,a){return t.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",s,n)}};var Kz=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,WT=/[a-z_0-9]+/gi,Me=class extends ke{constructor(t,n,i,s,o){super(o);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=o===void 0,this.isInterface=!1,this.parse(t,n,i,s)}getShared(t,n){return!this.isMethod}getType(t){return t.getTypeByFormat(this.type)}getInputByName(t){if(this.inputs){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}}getIncludeByName(t){if(this.includes){let n=this.includes.length;for(;n--;)if(this.includes[n].name===t)return this.includes[n]}}generate(t,n,i,s,o){let a,l=0,u=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)t.include(this.includes[h],this);for(let h in this.extensions)t.extensions[h]=!0;let c=[];for(;a=WT.exec(this.src);)c.push(a);for(let h=0;h<c.length;h++){let d=c[h],f=d[0],m=this.isMethod?!this.getInputByName(f):!0,p=f;if(this.keywords[f]||this.useKeywords&&m&&wn.containsKeyword(f)){let g=this.keywords[f];if(!g){let v=wn.getKeywordData(f);v.cache&&(g=t.keywords[f]),g=g||wn.getKeyword(f,t),v.cache&&(t.keywords[f]=g)}p=g.build(t)}f!==p&&u[d.index+l-1]!=="."&&(u=u.substring(0,d.index+l)+p+u.substring(d.index+f.length+l),l+=p.length-f.length),this.getIncludeByName(p)===void 0&&wn.contains(p)&&t.include(wn.get(p))}return n==="source"?u:this.isMethod?(this.isInterface||t.include(this,void 0,u),this.name):t.format("( "+u+" )",this.getType(t),n)}parse(t,n,i,s){if(this.src=t||"",this.includes=n??[],this.extensions=i??{},this.keywords=s??{},this.isMethod){let o=Kz.exec(this.src);if(this.inputs=[],o&&o.length==4){this.type=o[1],this.name=o[2];let a=o[3].match(WT);if(a){let l=0;for(;l<a.length;){let u=a[l++],c;u==="in"||u==="out"||u==="inout"?c=a[l++]:(c=u,u="");let h=a[l++];this.inputs.push({name:h,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var Jz=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,p0=class extends ke{constructor(t="",n){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(t||p0.PI,void 0,void 0,void 0,n)}getType(t){return t.getTypeByFormat(this.type)}parse(t,n,i,s,o){this.src=t||"";let a,l,u="",c=Jz.exec(t);this.useDefine=o??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],a=c[2],u=c[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=u}build(t,n){if(n==="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 t.include(this),t.format(this.name,this.getType(t),n)}generate(t,n,i,s,o){return t.format(this.name,this.getType(t),n)}},ft=p0;ft.PI="PI",ft.PI2="PI2",ft.RECIPROCAL_PI="RECIPROCAL_PI",ft.RECIPROCAL_PI2="RECIPROCAL_PI2",ft.LOG2="LOG2",ft.EPSILON="EPSILON";var $z=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
3140
3140
  )*?)}`,"gim"),ek=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Cc=class extends ke{constructor(t=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(t)}getType(t){return t.getTypeByFormat(this.name)}getInputByName(t){let n=this.inputs.length;for(;n--;)if(this.inputs[n].name===t)return this.inputs[n]}generate(t,n,i,s,o){return n==="source"?this.src+";":t.format("( "+this.src+" )",this.getType(t),n)}parse(t=""){this.src=t,this.inputs=[];let n=$z.exec(t);if(n){let i=n[2],s;for(;s=ek.exec(i);)this.inputs.push({type:s[1],name:s[2]});this.name=n[1]}else this.name="";this.type=this.name}};var Pc=class extends ke{constructor(t){super("v2",{shared:!1});this.nodeType="UV";this.index=t??0}generate(t,n){t.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",s=t.isShader("vertex")?"uv"+i:"vUv"+i;return t.format(s,this.getType(t),n)}};wn.addKeyword("uv",function(){return new Pc});wn.addKeyword("uv2",function(){return new Pc(1)});var fa=class extends ke{constructor(t,n){super("v4");this.nodeType="ColorSpace";this.input=t,this.method=n??fa.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(t){switch(t){case Mr:return["Linear"];case Xe:return["sRGB"];default:return[]}}generate(t,n){let i=this.input.build(t,"v4"),s=this.getType(t),o=fa.Nodes[this.method],a=t.include(o);if(a===fa.LINEAR_TO_LINEAR)return t.format(i,s,n);if(o.inputs?.length===2){let l=this.factor.build(t,"f");return t.format(a+"( "+i+", "+l+" )",s,n)}else return t.format(a+"( "+i+" )",s,n)}fromEncoding(t){let n=fa.getEncodingComponents(t);this.method="LinearTo"+n[0],this.factor=n[1]}fromDecoding(t){let n=fa.getEncodingComponents(t);this.method=n[0]+"ToLinear",this.factor=n[1]}},lr=fa;lr.Nodes={LinearToLinear:new Me(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3141
3141
  `)),sRGBToLinear:new Me(["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(`
3142
3142
  `)),LinearTosRGB:new Me(["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(`
@@ -3205,7 +3205,7 @@ void main() {
3205
3205
  uv.x -= texelSize;
3206
3206
  vec4 bl = texture2D(envMap, uv);
3207
3207
  return TextureCubeUVData( tl, tr, br, bl, f );
3208
- }`,[t,a,l,n,i,s,o]);u.useKeywords=!1;let c=new ft("float r0 1.0",!0),h=new ft("float v0 0.339",!0),d=new ft("float m0 -2.0",!0),f=new ft("float r1 0.8",!0),m=new ft("float v1 0.276",!0),p=new ft("float m1 -1.0",!0),g=new ft("float r4 0.4",!0),v=new ft("float v4 0.046",!0),y=new ft("float m4 2.0",!0),w=new ft("float r5 0.305",!0),b=new ft("float v5 0.016",!0),S=new ft("float m5 3.0",!0),_=new ft("float r6 0.21",!0),M=new ft("float v6 0.0038",!0),x=new ft("float m6 4.0",!0),T=[c,h,d,f,m,p,g,v,y,w,b,S,_,M,x],E=new Me(`float roughnessToMip(float roughness) {
3208
+ }`,[t,a,l,n,i,s,o]);u.useKeywords=!1;let c=new ft("float r0 1.0",!0),h=new ft("float v0 0.339",!0),d=new ft("float m0 -2.0",!0),f=new ft("float r1 0.8",!0),m=new ft("float v1 0.276",!0),p=new ft("float m1 -1.0",!0),g=new ft("float r4 0.4",!0),v=new ft("float v4 0.046",!0),y=new ft("float m4 2.0",!0),b=new ft("float r5 0.305",!0),w=new ft("float v5 0.016",!0),S=new ft("float m5 3.0",!0),_=new ft("float r6 0.21",!0),M=new ft("float v6 0.0038",!0),x=new ft("float m6 4.0",!0),T=[c,h,d,f,m,p,g,v,y,b,w,S,_,M,x],E=new Me(`float roughnessToMip(float roughness) {
3209
3209
  float mip = 0.0;
3210
3210
  if (roughness >= r1) {
3211
3211
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -4467,7 +4467,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
4467
4467
 
4468
4468
  return color.xyz;
4469
4469
 
4470
- }`,[Yn.simplex,t,i,o])}}();function ZT(r,e,t){r.setUvTransform(t[0],t[1],e[0],e[1],0,0,0)}var am=class extends Lc{constructor(t,n){super(new jt);this.repeat=t;this.offset=n;ZT(this.value,t,n)}updateMatrix(){ZT(this.value,this.repeat,this.offset)}};var ji=class{constructor(e,t,n,i){this.id=e;this.uuid=t;this.data=n;this.uniforms={};for(let s in i)this.uniforms[`f${this.id}_${s}`]=i[s];for(let s in n)C0(s,this,n)}get type(){return this.data.type}static create(e,t,n,i){if(n.type==="light")return qi.createLigherLayer(e,t,n,i);if(n.type==="texture"){let s=i.image(n.texture.image),o=new Xh(s,n.texture.wrapping),a=new om(s),l=new am(n.texture.repeat,n.texture.offset),u=new Ce(n.crop?1:0),c=new ct(n.projection??0),h=new ct(["x","y","z"].indexOf(n.axis)??0),d=new ct(n.side??0),f=new On(n.size?new B(n.size[0],n.size[1]):new B(100,100)),m=new Ce(n.alpha??1),p=new ct(n.mode??0),g=new Gh(o,a,u,c,h,d,f,l,m,p),v=new bt(g.calpha,"f");return new Sn(e,t,n,{texture:o,textureSize:a,crop:u,projection:c,axis:h,side:d,size:f,mat:l,alpha:m,mode:p},g,p,v)}else if(n.type==="matcap"){let s=i.image(n.texture.image),o=new Xh(s,n.texture.wrapping),a=new Ce(n.alpha??1),l=new ct(n.mode??0),u=new qh(o,a,l),c=new bt(u.calpha,"f");return new Sn(e,t,n,{texture:o,alpha:a,mode:l},u,l,c)}else if(n.type==="displace")if(n.displacementType==="noise"){let s=new Gn(new A(...n.offset)),o=new Ce(n.scale??10),a=new Ce(n.intensity??8),l=new Ce(n.movement??1),u=new ct(n.noiseType??0),c=new Fh(a,l,s,o,u);return new Qh(e,t,n,{offset:s,scale:o,intensity:a,movement:l,noiseType:u},c)}else throw new Error;else return yk(e,t,n,i)}updateByOp(e,t,n){let i=e;if(i.path[0]===void 0){if(i.type===0)return"type"in i.props||"category"in i.props?!0:QT(i.props,n,this,t)}else if(i.path[0]==="texture")return"texture"in t?E0(i.props,n,this):!0;return!1}dispose(){}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;this.hasValueByKey(n)&&t!==void 0&&(this.uniforms[n].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let n=/f\d+_(.*)/.exec(e);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}},Sn=class extends ji{constructor(t,n,i,s,o,a,l){super(t,n,i,s);this.color=o;this.mode=a;this.alpha=l}},Qh=class extends ji{constructor(t,n,i,s,o){super(t,n,i,s);this.position=o}},qi=class extends ji{constructor(t,n,i,s,o){super(t,n,i,o);this.data=i;this.node=s}static createLigherLayer(t,n,i,s){let o,a=new Ce(i.alpha),l=new ct(i.mode),u;if(i.category==="lambert"){o=new Vh;let c=new St(s.color(i.emissive)??0);u={emissive:c},o.emissive=c}else if(i.category==="phong"){o=new sm;let c=new Ce(i.shininess??30),h=new St(s.color(i.specular)??1118481);u={shininess:c,specular:h},o.shininess=c,o.specular=h}else if(i.category==="toon"){o=new Wh;let c=new Ce(i.shininess??30),h=new St(s.color(i.specular)??1118481);u={shininess:c,specular:h},o.shininess=c,o.specular=h}else if(i.category==="physical"){o=new Hh;let c=new Ce(i.roughness??.3),h=new Ce(i.metalness??0),d=new Ce(i.reflectivity??.5);u={roughness:c,metalness:h,reflectivity:d},o.roughness=c,o.metalness=h,o.reflectivity=d}else o=new ma,u={};return o.alpha=new Ce(1),o.shadingAlpha=a,o.shadingBlend=l,u.alpha=o.shadingAlpha,u.mode=o.shadingBlend,new qi(t,n,i,o,u)}};function KT(r){let e=r instanceof ji?r.type:r;return e==="texture"||e==="displace_map"||e==="matcap"}function gk(r,e,t,n){switch(r.type){case"color":{let i=new St(n.color??5855577),s=new Ce(n.alpha??1),o=new bt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new ct(n.mode??0);return i.alpha=s,new Sn(e,t,r,{color:i,alpha:s,mode:a},i,a,o)}case"fresnel":{let i=new St(n.color??16777215),s=new Ce(n.bias??.1),o=new Ce(n.scale??1),a=new Ce(n.intensity??2),l=new Ce(n.factor??1),u=new Ce(n.alpha??1),c=new ct(n.mode??0),h=new Ih(i,s,o,a,l,u,c),d=new bt(h.calpha,"f");return new Sn(e,t,r,{color:i,bias:s,scale:o,intensity:a,factor:l,alpha:u,mode:c},h,c,d)}case"rainbow":{let i=new Ce(n.filmThickness??30),s=new Ce(n.movement??0),o=new Gn(n.wavelengths??new A(0,0,0)),a=new Ce(n.noiseStrength??0),l=new Ce(n.noiseScale??1),u=new Gn(n.offset??new A(0,0,0)),c=new Ce(n.alpha??1),h=new Lh(i,s,o,a,l,u,c),d=new bt(h.calpha,"f"),f=new ct(n.mode??0);return new Sn(e,t,r,{filmThickness:i,movement:s,wavelengths:o,noiseStrength:a,noiseScale:l,offset:u,alpha:c,mode:f},h,f,d)}case"transmission":{let i=new Ce(n.thickness??10),s=new Ce(n.ior??1.5),o=new Ce(n.roughness??.5),a=Pt.transmissionSize,l=Pt.transmissionRenderTarget,u=Pt.transmissionRenderTargetDepth,c=window.innerWidth,h=window.innerHeight,d=c>=h?new On(h/c,1):new On(1,c/h),f=new Ce(n.alpha??1),m=new Rh(i,s,o,a,l,u,d,f),p=new bt(m.calpha,"f"),g=new ct(n.mode??0);return new Sn(e,t,r,{thickness:i,ior:s,roughness:o,aspectRatio:d,alpha:f,mode:g},m,g,p)}case"toon":{let i=new ct(n.positioning??0),s;n.colors?s=new vi(n.colors.length,n.colors):(s=new vi(10,new He(0,0,0,1)),s.value[1]=new He(1,1,1,1));let o;n.steps?o=new yi(n.steps.length,n.steps):(o=new yi(10,1),o.value[0]=0);let a=new Gn(n.source??new A(0,0,0)),l=new mo(n.isWorldSpace??!0),u=new Ce(n.noiseStrength??0),c=new Ce(n.noiseScale??1),h=new $r(n.shadowColor),d=new Gn(n.offset??new A(0,0,0)),f=new Ce(n.alpha??1),m=new Yh(i,s,o,a,l,u,c,h,d,f),p=new bt(m.calpha,"f"),g=new ct(n.mode??0);return new Sn(e,t,r,{positioning:i,colors:s,steps:o,source:a,isWorldSpace:l,noiseStrength:u,noiseScale:c,shadowColor:h,offset:d,alpha:f,mode:g},m,g,p)}case"outline":{let i=new St(n.outlineColor??16777215),s=new St(n.contourColor??16777215),o=new Ce(n.outlineWidth??.1),a=new Ce(n.contourWidth??.1),l=new Ce(n.outlineThreshold??.1),u=new Ce(n.contourThreshold??.1),c=new Ce(n.outlineSmoothing??.1),h=new Ce(n.contourFrequency??.1),d=new Gn(n.contourDirections??new A(0,1,0)),f=new mo(n.positionalLines??!1),m=new mo(n.compensation??!0),p=Pt.normalRenderTarget,g=Pt.normalRenderTargetDepth,v=Pt.pixelRatioNode,y=Pt.resolution,w=new Ce(n.alpha??1),b=new Oh(i,s,o,a,l,u,c,h,d,f,m,y,p,g,v,w),S=new bt(b.calpha,"f"),_=new ct(n.mode??0);return new Sn(e,t,r,{outlineColor:i,contourColor:s,outlineWidth:o,contourWidth:a,outlineThreshold:l,contourThreshold:u,outlineSmoothing:c,contourFrequency:h,contourDirection:d,positionalLines:f,compensation:m,alpha:w,mode:_},b,_,S)}case"depth":{let i=new ct(n.gradientType??0),s=new mo(n.smooth??!1),o=new Ce(n.near??50),a=new Ce(n.far??200),l=new Ce(n.isVector??1),u=new Ce(n.isWorldSpace??0),c=new Gn(n.origin??new A),h=new Gn(n.direction??new A),d;n.colors?d=new vi(n.colors.length,n.colors):(d=new vi(2,new He(0,0,0,1)),d.value[1]=new He(1,1,1,1));let f;n.steps?f=new yi(n.steps.length,n.steps):(f=new yi(2,1),f.value[0]=0);let m=new Ce(n.alpha??1),p=new ct(n.mode??0),g=new Nh(i,s,o,a,l,u,c,h,d,f,m),v=new bt(g.calpha,"f");return new Sn(e,t,r,{gradientType:i,smooth:s,near:o,far:a,isVector:l,isWorldSpace:u,origin:c,direction:h,colors:d,steps:f,alpha:m,mode:p},g,p,v)}case"noise":{let i=new Ce(n.scale??1),s=new Gn(n.size??new A(100,100,100)),o=new Ce(n.move??1),a=new On(n.fA??new B(1.7,9.2)),l=new On(n.fB??new B(8.3,2.8)),u=new On(n.distortion??new B(1,1)),c=new $r(n.colorA),h=new $r(n.colorB),d=new $r(n.colorC),f=new $r(n.colorD),m=new Ce(n.alpha??1),p=new ct(n.mode??0),g=new ct(n.noiseType??0),v=new Dh(i,s,o,a,l,u,c,h,d,f,m,g),y=new bt(v.calpha,"f");return new Sn(e,t,r,{scale:i,size:s,move:o,fA:a,fB:l,distortion:u,colorA:c,colorB:h,colorC:d,colorD:f,alpha:m,mode:p,noiseType:g},v,p,y)}case"normal":{let i=new Gn(n.cnormal??new A(1,1,1)),s=new Ce(n.alpha??1),o=new ct(n.mode??0),a=new kh(i,s),l=new bt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return l.keywords.alpha=s,new Sn(e,t,r,{cnormal:i,alpha:s,mode:o},a,o,l)}case"gradient":{let i=new ct(n.gradientType??0),s=new mo(n.smooth??!1),o;n.colors?o=new vi(n.colors.length,n.colors):(o=new vi(10,new He(0,0,0,1)),o.value[1]=new He(1,1,1,1));let a;n.steps?a=new yi(n.steps.length,n.steps):(a=new yi(10,1),a.value[0]=0);let l=new On(n.offset??new B(0,0)),u=new On(n.morph??new B(0,0)),c=new Ce(n.angle??0),h=new Ce(n.alpha??1),d=new ct(n.mode??0),f=new Uh(i,s,o,a,l,u,c,h),m=new bt(f.calpha,"f");return new Sn(e,t,r,{gradientType:i,smooth:s,colors:o,steps:a,offset:l,morph:u,angle:c,alpha:h,mode:d},f,d,m)}default:{let i=new St(1,0,0,1),s=new Ce(1),o=new bt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new ct(0);return i.alpha=s,new Sn(e,t,r,{color:i,alpha:s,mode:a},i,a,o)}}}function yk(r,e,t,n){let i=qT(t,n);return gk(t,r,e,i)}function C0(r,e,t){if(t.type==="displace"&&(r==="intensity"||r==="visible")){let n=e.uniforms[`f${e.id}_intensity`];return n?(n.value=t.intensity*(t.visible?1:0),n):void 0}if(t.type!=="displace"&&(r==="alpha"||r==="visible")){let n=e.uniforms[`f${e.id}_alpha`];if(!n)return;if(n.value=t.alpha*(t.visible?1:0),t.type==="outline"&&r=="visible"){let i=e.uniforms[`f${e.id}_compensation`];i&&(i.value=t.compensation&&t.visible)}return n}}var Or=class extends mt{constructor(t,n){super(void 0);this.data=t;this.layerIdGen=0;this.type="NodeMaterial";this.uniformsBackup={};this.fog=!0,this.updaters=[],this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile,this.transparent=!0,this.reset(t,n)}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.data.category}reset(t,n){let i=t.layers??Fn.defaultTwoLayerData("phong").layers;this.layers=i.map(s=>ji.create(this.layerIdGen++,s.id,s.data,n)),this.layers.reverse(),this.name=t.name??"Untitled Material",this.onUpdate(n)}getLayersOfType(t){return this.layers.filter(n=>n.type===t)}getLayerByUuid(t){return this.layers.find(n=>n.uuid===t)}onUpdate(t){this.lightLayer=this.layers.find(n=>n instanceof qi),this.lightLayer===void 0&&(this.lightLayer=new qi(0,"",so.defaultData("light","basic"),new ma,{})),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(t,n,i){if(this.data=n,t.path[0]==="layers"){let s=t.path[1];if(s===void 0){if(this.layers.reverse(),t.type===4){let o=ji.create(this.layerIdGen++,t.id,t.data,i);this.layers.splice(t.localIndex,0,o)}else if(t.type===5)this.layers.splice(t.localIndex,1)[0].dispose();else if(t.type===6){let o=this.layers.findIndex(l=>l.uuid===t.id),a=this.layers[o];this.layers.splice(o,1),this.layers.splice(t.localIndex,0,a)}this.layers.reverse(),this.onUpdate(i)}else{let o=this.layers.find(a=>a.uuid===s);if(o){let a=n.layers.data(s);if(o.updateByOp({...t,path:t.path.slice(2)},a,i)){let u=ji.create(this.layerIdGen++,s,a,i);this.layers.splice(this.layers.findIndex(c=>c.uuid===s),1,u),this.onUpdate(i)}}}}}blendColors(){let t=this.layers.findIndex(i=>i instanceof Sn),n=this.layers.findIndex(i=>i instanceof qi);if(t!==-1&&t<n){let i=this.layers[t].color;for(let s=t+1;s<n;++s){let o=this.layers[s];o instanceof Sn&&(i=new Bh(i,o.color,o.alpha,o.mode))}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let t=new bt("outgoingLight","f"),n=this.layers.findIndex(i=>i instanceof qi);if(this.layers.length>n+1){for(let i=n+1;i<this.layers.length;++i){let s=this.layers[i];s instanceof Sn&&(t=new Bh(t,s.color,s.alpha,s.mode))}this.fragment.afterColor=t}else this.fragment.afterColor=void 0}blendPositions(){let t=this.layers.filter(n=>n instanceof Qh);if(t.length>0){let n=t[0].position;for(let i=1;i<t.length;++i)t[i]&&(n=new xr(n,t[i].position,xr.ADD),n=new xr(n,new Ce(.5).setReadonly(!0),xr.MUL));this.fragment.position=n}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(t,n){this.build({renderer:n}),t.defines=this.defines,t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.extensionDerivatives=this.extensions.derivatives===!0,t.extensionFragDepth=this.extensions.fragDepth===!0,t.extensionDrawBuffers=this.extensions.drawBuffers===!0,t.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(t,n){let i=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){this.uniformsBackup[`f${s.id}_intensity`]=s.uniforms[`f${s.id}_intensity`].value;let o=i(s.uniforms[`f${s.id}_intensity`].value,t,n);s.uniforms[`f${s.id}_intensity`].value=o}}restoreClampedUniforms(){for(let t of this.layers)t.type==="displace"&&(t.uniforms[`f${t.id}_intensity`].value=this.uniformsBackup[`f${t.id}_intensity`])}customProgramCacheKey(){let t="[";for(let{data:n}of this.data.layers)if(n.type==="light")t+=`"${n.category.toUpperCase()}",`;else{let i=(T0[n.type]??[]).map(a=>n[a]),s=(M0[n.type]??[]).map(a=>n[a]?.length??0),o=[...i,...s];o.length?t+=`["${n.type}", "${o.join('","')}"],`:t+=`"${n.type}",`}return t=t.slice(0,-1)+"]",t}updateFrame(t){for(let n=0;n<this.updaters.length;++n)t.updateNode(this.updaters[n])}build(t){t=t??{};let n=t.builder??new im;return this.lights=this.lightLayer.data.category!=="basic",n.setMaterial(this,t.renderer),n.build(this.fragment,this.fragment),this.vertexShader=n.getCode("vertex"),this.fragmentShader=n.getCode("fragment"),this.defines=n.defines,this.uniforms=n.uniforms,this.extensions=n.extensions,this.updaters=n.updaters,this.transparent=n.requires.transparent||this.blending>Ns,this}dispose(){this.layers.forEach(t=>t.dispose()),super.dispose()}getHash(){let t="{";return t+='"fragment":'+this.fragment.getHash(),t+="}",t}};Object.defineProperties(Or.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(r){r===!0&&this.version++,this.needsCompile=r},get:function(){return this.needsCompile}}});var vk=r=>`
4470
+ }`,[Yn.simplex,t,i,o])}}();function ZT(r,e,t){r.setUvTransform(t[0],t[1],e[0],e[1],0,0,0)}var am=class extends Lc{constructor(t,n){super(new jt);this.repeat=t;this.offset=n;ZT(this.value,t,n)}updateMatrix(){ZT(this.value,this.repeat,this.offset)}};var ji=class{constructor(e,t,n,i){this.id=e;this.uuid=t;this.data=n;this.uniforms={};for(let s in i)this.uniforms[`f${this.id}_${s}`]=i[s];for(let s in n)C0(s,this,n)}get type(){return this.data.type}static create(e,t,n,i){if(n.type==="light")return qi.createLigherLayer(e,t,n,i);if(n.type==="texture"){let s=i.image(n.texture.image),o=new Xh(s,n.texture.wrapping),a=new om(s),l=new am(n.texture.repeat,n.texture.offset),u=new Ce(n.crop?1:0),c=new ct(n.projection??0),h=new ct(["x","y","z"].indexOf(n.axis)??0),d=new ct(n.side??0),f=new On(n.size?new B(n.size[0],n.size[1]):new B(100,100)),m=new Ce(n.alpha??1),p=new ct(n.mode??0),g=new Gh(o,a,u,c,h,d,f,l,m,p),v=new bt(g.calpha,"f");return new Sn(e,t,n,{texture:o,textureSize:a,crop:u,projection:c,axis:h,side:d,size:f,mat:l,alpha:m,mode:p},g,p,v)}else if(n.type==="matcap"){let s=i.image(n.texture.image),o=new Xh(s,n.texture.wrapping),a=new Ce(n.alpha??1),l=new ct(n.mode??0),u=new qh(o,a,l),c=new bt(u.calpha,"f");return new Sn(e,t,n,{texture:o,alpha:a,mode:l},u,l,c)}else if(n.type==="displace")if(n.displacementType==="noise"){let s=new Gn(new A(...n.offset)),o=new Ce(n.scale??10),a=new Ce(n.intensity??8),l=new Ce(n.movement??1),u=new ct(n.noiseType??0),c=new Fh(a,l,s,o,u);return new Qh(e,t,n,{offset:s,scale:o,intensity:a,movement:l,noiseType:u},c)}else throw new Error;else return yk(e,t,n,i)}updateByOp(e,t,n){let i=e;if(i.path[0]===void 0){if(i.type===0)return"type"in i.props||"category"in i.props?!0:QT(i.props,n,this,t)}else if(i.path[0]==="texture")return"texture"in t?E0(i.props,n,this):!0;return!1}dispose(){}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let n=`f${this.id}_${e}`;this.hasValueByKey(n)&&t!==void 0&&(this.uniforms[n].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let n=/f\d+_(.*)/.exec(e);if(n&&n.length>1)return n[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let n=this.getName(t);n&&e.push(n)}return e}},Sn=class extends ji{constructor(t,n,i,s,o,a,l){super(t,n,i,s);this.color=o;this.mode=a;this.alpha=l}},Qh=class extends ji{constructor(t,n,i,s,o){super(t,n,i,s);this.position=o}},qi=class extends ji{constructor(t,n,i,s,o){super(t,n,i,o);this.data=i;this.node=s}static createLigherLayer(t,n,i,s){let o,a=new Ce(i.alpha),l=new ct(i.mode),u;if(i.category==="lambert"){o=new Vh;let c=new St(s.color(i.emissive)??0);u={emissive:c},o.emissive=c}else if(i.category==="phong"){o=new sm;let c=new Ce(i.shininess??30),h=new St(s.color(i.specular)??1118481);u={shininess:c,specular:h},o.shininess=c,o.specular=h}else if(i.category==="toon"){o=new Wh;let c=new Ce(i.shininess??30),h=new St(s.color(i.specular)??1118481);u={shininess:c,specular:h},o.shininess=c,o.specular=h}else if(i.category==="physical"){o=new Hh;let c=new Ce(i.roughness??.3),h=new Ce(i.metalness??0),d=new Ce(i.reflectivity??.5);u={roughness:c,metalness:h,reflectivity:d},o.roughness=c,o.metalness=h,o.reflectivity=d}else o=new ma,u={};return o.alpha=new Ce(1),o.shadingAlpha=a,o.shadingBlend=l,u.alpha=o.shadingAlpha,u.mode=o.shadingBlend,new qi(t,n,i,o,u)}};function KT(r){let e=r instanceof ji?r.type:r;return e==="texture"||e==="displace_map"||e==="matcap"}function gk(r,e,t,n){switch(r.type){case"color":{let i=new St(n.color??5855577),s=new Ce(n.alpha??1),o=new bt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new ct(n.mode??0);return i.alpha=s,new Sn(e,t,r,{color:i,alpha:s,mode:a},i,a,o)}case"fresnel":{let i=new St(n.color??16777215),s=new Ce(n.bias??.1),o=new Ce(n.scale??1),a=new Ce(n.intensity??2),l=new Ce(n.factor??1),u=new Ce(n.alpha??1),c=new ct(n.mode??0),h=new Ih(i,s,o,a,l,u,c),d=new bt(h.calpha,"f");return new Sn(e,t,r,{color:i,bias:s,scale:o,intensity:a,factor:l,alpha:u,mode:c},h,c,d)}case"rainbow":{let i=new Ce(n.filmThickness??30),s=new Ce(n.movement??0),o=new Gn(n.wavelengths??new A(0,0,0)),a=new Ce(n.noiseStrength??0),l=new Ce(n.noiseScale??1),u=new Gn(n.offset??new A(0,0,0)),c=new Ce(n.alpha??1),h=new Lh(i,s,o,a,l,u,c),d=new bt(h.calpha,"f"),f=new ct(n.mode??0);return new Sn(e,t,r,{filmThickness:i,movement:s,wavelengths:o,noiseStrength:a,noiseScale:l,offset:u,alpha:c,mode:f},h,f,d)}case"transmission":{let i=new Ce(n.thickness??10),s=new Ce(n.ior??1.5),o=new Ce(n.roughness??.5),a=Pt.transmissionSize,l=Pt.transmissionRenderTarget,u=Pt.transmissionRenderTargetDepth,c=window.innerWidth,h=window.innerHeight,d=c>=h?new On(h/c,1):new On(1,c/h),f=new Ce(n.alpha??1),m=new Rh(i,s,o,a,l,u,d,f),p=new bt(m.calpha,"f"),g=new ct(n.mode??0);return new Sn(e,t,r,{thickness:i,ior:s,roughness:o,aspectRatio:d,alpha:f,mode:g},m,g,p)}case"toon":{let i=new ct(n.positioning??0),s;n.colors?s=new vi(n.colors.length,n.colors):(s=new vi(10,new He(0,0,0,1)),s.value[1]=new He(1,1,1,1));let o;n.steps?o=new yi(n.steps.length,n.steps):(o=new yi(10,1),o.value[0]=0);let a=new Gn(n.source??new A(0,0,0)),l=new mo(n.isWorldSpace??!0),u=new Ce(n.noiseStrength??0),c=new Ce(n.noiseScale??1),h=new $r(n.shadowColor),d=new Gn(n.offset??new A(0,0,0)),f=new Ce(n.alpha??1),m=new Yh(i,s,o,a,l,u,c,h,d,f),p=new bt(m.calpha,"f"),g=new ct(n.mode??0);return new Sn(e,t,r,{positioning:i,colors:s,steps:o,source:a,isWorldSpace:l,noiseStrength:u,noiseScale:c,shadowColor:h,offset:d,alpha:f,mode:g},m,g,p)}case"outline":{let i=new St(n.outlineColor??16777215),s=new St(n.contourColor??16777215),o=new Ce(n.outlineWidth??.1),a=new Ce(n.contourWidth??.1),l=new Ce(n.outlineThreshold??.1),u=new Ce(n.contourThreshold??.1),c=new Ce(n.outlineSmoothing??.1),h=new Ce(n.contourFrequency??.1),d=new Gn(n.contourDirections??new A(0,1,0)),f=new mo(n.positionalLines??!1),m=new mo(n.compensation??!0),p=Pt.normalRenderTarget,g=Pt.normalRenderTargetDepth,v=Pt.pixelRatioNode,y=Pt.resolution,b=new Ce(n.alpha??1),w=new Oh(i,s,o,a,l,u,c,h,d,f,m,y,p,g,v,b),S=new bt(w.calpha,"f"),_=new ct(n.mode??0);return new Sn(e,t,r,{outlineColor:i,contourColor:s,outlineWidth:o,contourWidth:a,outlineThreshold:l,contourThreshold:u,outlineSmoothing:c,contourFrequency:h,contourDirection:d,positionalLines:f,compensation:m,alpha:b,mode:_},w,_,S)}case"depth":{let i=new ct(n.gradientType??0),s=new mo(n.smooth??!1),o=new Ce(n.near??50),a=new Ce(n.far??200),l=new Ce(n.isVector??1),u=new Ce(n.isWorldSpace??0),c=new Gn(n.origin??new A),h=new Gn(n.direction??new A),d;n.colors?d=new vi(n.colors.length,n.colors):(d=new vi(2,new He(0,0,0,1)),d.value[1]=new He(1,1,1,1));let f;n.steps?f=new yi(n.steps.length,n.steps):(f=new yi(2,1),f.value[0]=0);let m=new Ce(n.alpha??1),p=new ct(n.mode??0),g=new Nh(i,s,o,a,l,u,c,h,d,f,m),v=new bt(g.calpha,"f");return new Sn(e,t,r,{gradientType:i,smooth:s,near:o,far:a,isVector:l,isWorldSpace:u,origin:c,direction:h,colors:d,steps:f,alpha:m,mode:p},g,p,v)}case"noise":{let i=new Ce(n.scale??1),s=new Gn(n.size??new A(100,100,100)),o=new Ce(n.move??1),a=new On(n.fA??new B(1.7,9.2)),l=new On(n.fB??new B(8.3,2.8)),u=new On(n.distortion??new B(1,1)),c=new $r(n.colorA),h=new $r(n.colorB),d=new $r(n.colorC),f=new $r(n.colorD),m=new Ce(n.alpha??1),p=new ct(n.mode??0),g=new ct(n.noiseType??0),v=new Dh(i,s,o,a,l,u,c,h,d,f,m,g),y=new bt(v.calpha,"f");return new Sn(e,t,r,{scale:i,size:s,move:o,fA:a,fB:l,distortion:u,colorA:c,colorB:h,colorC:d,colorD:f,alpha:m,mode:p,noiseType:g},v,p,y)}case"normal":{let i=new Gn(n.cnormal??new A(1,1,1)),s=new Ce(n.alpha??1),o=new ct(n.mode??0),a=new kh(i,s),l=new bt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return l.keywords.alpha=s,new Sn(e,t,r,{cnormal:i,alpha:s,mode:o},a,o,l)}case"gradient":{let i=new ct(n.gradientType??0),s=new mo(n.smooth??!1),o;n.colors?o=new vi(n.colors.length,n.colors):(o=new vi(10,new He(0,0,0,1)),o.value[1]=new He(1,1,1,1));let a;n.steps?a=new yi(n.steps.length,n.steps):(a=new yi(10,1),a.value[0]=0);let l=new On(n.offset??new B(0,0)),u=new On(n.morph??new B(0,0)),c=new Ce(n.angle??0),h=new Ce(n.alpha??1),d=new ct(n.mode??0),f=new Uh(i,s,o,a,l,u,c,h),m=new bt(f.calpha,"f");return new Sn(e,t,r,{gradientType:i,smooth:s,colors:o,steps:a,offset:l,morph:u,angle:c,alpha:h,mode:d},f,d,m)}default:{let i=new St(1,0,0,1),s=new Ce(1),o=new bt("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;let a=new ct(0);return i.alpha=s,new Sn(e,t,r,{color:i,alpha:s,mode:a},i,a,o)}}}function yk(r,e,t,n){let i=qT(t,n);return gk(t,r,e,i)}function C0(r,e,t){if(t.type==="displace"&&(r==="intensity"||r==="visible")){let n=e.uniforms[`f${e.id}_intensity`];return n?(n.value=t.intensity*(t.visible?1:0),n):void 0}if(t.type!=="displace"&&(r==="alpha"||r==="visible")){let n=e.uniforms[`f${e.id}_alpha`];if(!n)return;if(n.value=t.alpha*(t.visible?1:0),t.type==="outline"&&r=="visible"){let i=e.uniforms[`f${e.id}_compensation`];i&&(i.value=t.compensation&&t.visible)}return n}}var Or=class extends mt{constructor(t,n){super(void 0);this.data=t;this.layerIdGen=0;this.type="NodeMaterial";this.uniformsBackup={};this.fog=!0,this.updaters=[],this.dithering=!0,this.vertexColors=!0,this.onBeforeCompile=this._onBeforeCompile,this.transparent=!0,this.reset(t,n)}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.data.category}reset(t,n){let i=t.layers??Fn.defaultTwoLayerData("phong").layers;this.layers=i.map(s=>ji.create(this.layerIdGen++,s.id,s.data,n)),this.layers.reverse(),this.name=t.name??"Untitled Material",this.onUpdate(n)}getLayersOfType(t){return this.layers.filter(n=>n.type===t)}getLayerByUuid(t){return this.layers.find(n=>n.uuid===t)}onUpdate(t){this.lightLayer=this.layers.find(n=>n instanceof qi),this.lightLayer===void 0&&(this.lightLayer=new qi(0,"",so.defaultData("light","basic"),new ma,{})),this.dispose(),this.needsUpdate=!0,this.blendColors(),this.blendAfterColors(),this.blendPositions()}updateByOp(t,n,i){if(this.data=n,t.path[0]==="layers"){let s=t.path[1];if(s===void 0){if(this.layers.reverse(),t.type===4){let o=ji.create(this.layerIdGen++,t.id,t.data,i);this.layers.splice(t.localIndex,0,o)}else if(t.type===5)this.layers.splice(t.localIndex,1)[0].dispose();else if(t.type===6){let o=this.layers.findIndex(l=>l.uuid===t.id),a=this.layers[o];this.layers.splice(o,1),this.layers.splice(t.localIndex,0,a)}this.layers.reverse(),this.onUpdate(i)}else{let o=this.layers.find(a=>a.uuid===s);if(o){let a=n.layers.data(s);if(o.updateByOp({...t,path:t.path.slice(2)},a,i)){let u=ji.create(this.layerIdGen++,s,a,i);this.layers.splice(this.layers.findIndex(c=>c.uuid===s),1,u),this.onUpdate(i)}}}}}blendColors(){let t=this.layers.findIndex(i=>i instanceof Sn),n=this.layers.findIndex(i=>i instanceof qi);if(t!==-1&&t<n){let i=this.layers[t].color;for(let s=t+1;s<n;++s){let o=this.layers[s];o instanceof Sn&&(i=new Bh(i,o.color,o.alpha,o.mode))}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let t=new bt("outgoingLight","f"),n=this.layers.findIndex(i=>i instanceof qi);if(this.layers.length>n+1){for(let i=n+1;i<this.layers.length;++i){let s=this.layers[i];s instanceof Sn&&(t=new Bh(t,s.color,s.alpha,s.mode))}this.fragment.afterColor=t}else this.fragment.afterColor=void 0}blendPositions(){let t=this.layers.filter(n=>n instanceof Qh);if(t.length>0){let n=t[0].position;for(let i=1;i<t.length;++i)t[i]&&(n=new xr(n,t[i].position,xr.ADD),n=new xr(n,new Ce(.5).setReadonly(!0),xr.MUL));this.fragment.position=n}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(t,n){this.build({renderer:n}),t.defines=this.defines,t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.extensionDerivatives=this.extensions.derivatives===!0,t.extensionFragDepth=this.extensions.fragDepth===!0,t.extensionDrawBuffers=this.extensions.drawBuffers===!0,t.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(t,n){let i=(s,o,a)=>Math.min(Math.max(s,o),a);for(let s of this.layers)if(s.type==="displace"){this.uniformsBackup[`f${s.id}_intensity`]=s.uniforms[`f${s.id}_intensity`].value;let o=i(s.uniforms[`f${s.id}_intensity`].value,t,n);s.uniforms[`f${s.id}_intensity`].value=o}}restoreClampedUniforms(){for(let t of this.layers)t.type==="displace"&&(t.uniforms[`f${t.id}_intensity`].value=this.uniformsBackup[`f${t.id}_intensity`])}customProgramCacheKey(){let t="[";for(let{data:n}of this.data.layers)if(n.type==="light")t+=`"${n.category.toUpperCase()}",`;else{let i=(T0[n.type]??[]).map(a=>n[a]),s=(M0[n.type]??[]).map(a=>n[a]?.length??0),o=[...i,...s];o.length?t+=`["${n.type}", "${o.join('","')}"],`:t+=`"${n.type}",`}return t=t.slice(0,-1)+"]",t}updateFrame(t){for(let n=0;n<this.updaters.length;++n)t.updateNode(this.updaters[n])}build(t){t=t??{};let n=t.builder??new im;return this.lights=this.lightLayer.data.category!=="basic",n.setMaterial(this,t.renderer),n.build(this.fragment,this.fragment),this.vertexShader=n.getCode("vertex"),this.fragmentShader=n.getCode("fragment"),this.defines=n.defines,this.uniforms=n.uniforms,this.extensions=n.extensions,this.updaters=n.updaters,this.transparent=n.requires.transparent||this.blending>Ns,this}dispose(){this.layers.forEach(t=>t.dispose()),super.dispose()}getHash(){let t="{";return t+='"fragment":'+this.fragment.getHash(),t+="}",t}};Object.defineProperties(Or.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(r){r===!0&&this.version++,this.needsCompile=r},get:function(){return this.needsCompile}}});var vk=r=>`
4471
4471
 
4472
4472
  // PCSS implementation based on:
4473
4473
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -4904,17 +4904,18 @@ float contrastDepth = (gl_FragCoord.z - 0.5) * depthContrast + 0.5;
4904
4904
  vec3 resultColor = mix(mix(vColor, normal, 0.2), vec3(contrastDepth), 0.4);
4905
4905
  gl_FragColor = vec4(resultColor, vColor.r);
4906
4906
  }
4907
- `,lm=new mt({vertexShader:Sk,fragmentShader:Ak,uniforms:{depthContrast:{value:1}}});function _k(r){if(r.geometry.attributes.extrudeNormal||!r.geometry.attributes.position)return;let e=new Map,t=r.geometry.attributes.position.array,n=r.geometry.attributes.normal.array,i=new Float32Array(t.length);for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=new A(n[s],n[s+1],n[s+2]);e.has(o)?e.get(o)?.normals.push(a):e.set(o,{normals:[a],result:new A})}e.forEach((s,o)=>{for(let a of s.normals)s.result.add(a);s.result.divideScalar(s.normals.length)});for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=e.get(o)?.result;a&&(i[s]=a.x,i[s+1]=a.y,i[s+2]=a.z)}r.geometry.setAttribute("extrudeNormal",new Ae(i,3))}function Tk(r){if(r.geometry.attributes.extrudeNormals||!r.geometry.attributes.position)return;let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=new A;for(let i=0;i<e.length;i+=3)n.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=n.x,t[i+1]=n.y,t[i+2]=n.z;r.geometry.setAttribute("extrudeNormal",new Ae(t,3))}function Xi(r){if(Array.isArray(r.material)){for(let e of r.material)if(e.getLayersOfType("outline").length===0)return}else if(!(r.material instanceof Or)||r.material.getLayersOfType("outline").length===0)return;r.objectType==="Mesh2D"||r.objectType==="TextFrame"&&r.data?.geometry?.depth===0?Tk(r):_k(r)}function Yi(r){if(!r.geometry.attributes.position)return;let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=parseInt(r.uuid.replace(/\D/g,"")),i=[Be.seededRandom(n),Be.seededRandom(n+1e4),Be.seededRandom(n+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];r.geometry.setAttribute("randomColor",new Ge(t,3))}var wt=class extends Jr(rn){constructor(t,n){super(t,n);this.isAbstractMesh=!0;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new be;this.booleanExclude=null;Array.isArray(n)&&t.groups.length===0&&t.addGroup(0,Math.max(t.getIndex()?.count??0,t.getAttribute("position").count),0)}get isGroup(){return this._cloner?.parameters.hideBase===!0}get isMesh(){return!this.isGroup}set isMesh(t){}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}updateGeometry(t,n){let i=this.geometry,s=u0[i.userData.type],o=this.objectType==="NonParametric"?Object.assign({},i.userData,{geometry:i}):i.userData,a=s.build(s.normalizeInputs(t,o)),l=i.uuid;this.geometry.dispose(),this.geometry=a,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),Xi(this),i.getAttribute("randomColor")&&Yi(this)}clone(t){let n=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=_h(n),s=this.material;return new this.constructor(i,s).copy(this,t)}copy(t,n=!0){return super.copy(t,n),t.cloner&&(this.cloner=new fh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new fh(this)),this.cloner.fromClonerState(t))}fromState(t,n){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(pi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Vt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)kt(t)&&(t.freeBooleanPointer(),Vt(t)&&t.invalidateUpstreamBooleanData())}};var Mk=new A(0,0,1),eM=new A,tM=new A,nM=new jt,Bc=class extends wt{constructor(t=Un.create({}),n){super(t,n);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Lt;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t,n){if(super.updateGeometry(t,n),"userData"in this.geometry){let i=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:i})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),nM.getNormalMatrix(this.matrixWorld),eM.copy(Mk).applyMatrix3(nM).normalize(),tM.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(eM,tM)}clone(t){let n=this.shape.clone(),i=this.material,s=this.geometry.userData,o=Un.create(Object.assign({},s,{shape:n})),a=new Bc(o,i).copy(this,t);return a.shape=n,n.update(),a}raycast(t,n){wt.prototype.raycast.call(this,t,n)}};var Qi=(r,e)=>class extends r{constructor(){super(...arguments);this.objectHelper=new e(this)}get geometryHelper(){return e.geometryHelper}raycast(i,s){this.objectHelper.raycast(i,s)}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=In(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows)}return this}};var Fc=new A,I0=new A,zn=class extends Qi(Jr(ai),kp){constructor(t=window.innerWidth,n=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=ia.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=n,this.orthoCamera=new Za(t*-.5,t*.5,n*.5,n*-.5,s??-5e4,o),this.perspCamera=new nn(i,t/n,s??50,o),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic()}static createFromState(t,n){let i=new zn().fromState(n);return i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,n){t==="PerspectiveCamera"?this.perspCamera.near=n:this.orthoCamera.near=n}setZoom(t,n){n>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=n:this.orthoCamera.zoom=n)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Fc),this.targetOffset=Fc.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(I0),this.getWorldPosition(Fc),I0.multiplyScalar(this.targetOffset),t.copy(Fc).add(I0),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Fc),Fc.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new nt),n=new A(0,0,1).applyQuaternion(t),i=new A().copy(ht.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(ht.DefaultUp).projectOnPlane(n),o=new A().crossVectors(s,i).dot(n)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let n=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().add(s),target:n}}getViewToObject(t){let n=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().sub(s),target:n}}setViewplaneSize(t,n){this.left=-t*.5,this.right=t*.5,this.top=n*.5,this.bottom=-n*.5,this.aspect=t/n,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(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,n,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,n,i,s,o,a):this.orthoCamera.setViewOffset(t,n,i,s,o,a)}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(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,n){return super.copy(t,n),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}toCameraState(t=[]){let n={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return kl(n,t)}fromCameraState(t){let{orthographic:n,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),n!==void 0&&(n.near!==void 0&&(this.orthoCamera.near=n.near),n.zoom!==void 0&&(this.orthoCamera.zoom=n.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.type==="PerspectiveCamera"?(this.zoom=this.perspCamera.zoom,this.fov=this.perspCamera.fov,this.near=this.perspCamera.near):(this.near=this.orthoCamera.near,this.zoom=this.orthoCamera.zoom),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var rM=new be;function L0(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var cm=class extends wt{constructor(t=new De,n){super(t,n);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.objectType="BooleanObject",this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.objectType="BooleanObject",this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t,n=!0){if(this.booleanMeshSetAddress!==-1)return;for(let s=0;s<this.children.length;s++){let o=this.children[s];Vt(o)&&o.recomputeBoolean(t===!0,n)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let o=this.children[s];if(HT(o)&&o.booleanExclude===!1&&o.geometry.attributes.position?.count>0&&o.geometry.drawRange.count>0){if(o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=pi.getMeshSet(o.geometry,t===!0,n)),o.booleanMeshSetAddress===-1)return;pi.transformMeshSet(o.booleanMeshSetAddress,o.matrix),o.booleanMatrixInvOld.copy(o.matrix).invert(),o.booleanWasTransformed=!1}else Vt(o)&&o.needsTransformForDownstream===!0?(pi.transformMeshSet(o.booleanMeshSetAddress,o.matrix),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(rM.multiplyMatrices(o.matrix,o.booleanMatrixInvOld),pi.transformMeshSet(o.booleanMeshSetAddress,rM),o.booleanMatrixInvOld.copy(o.matrix).invert(),o.booleanWasTransformed=!1);this.meshSetAddresses.push(o.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return pi.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new De,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=pi.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Xi(this),Yi(this)}updateGeometry(t,n){let i=t.parameters;i.operation!==void 0&&(this.booleanOp=i.operation),i.phongAngle!==void 0&&(this.phongAngle=i.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var ya=class extends Qi(Jr(Rs),fc){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,n){let i=new ya().fromState(n);return i.uuid=t,i.objectHelper.update(),i}};var Uc=class extends Qi(Jr(sf),dc){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};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 Vr(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new Uc().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}fromDirectionalLightState(t,n){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,n),t.size!==void 0&&zT(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),i&&this.update(),this}fromState(t,n){return super.fromState(t),this.fromDirectionalLightState(t,n),this}};var Gc=class extends Qi(Jr(rf),pc){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};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 A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new Mt(s,o),l=new Yo(a,new Le(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,n,i){let s=new Gc().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Yo&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Yo&&(n.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let n=this._gizmos[t];if(n instanceof Yo){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);n.box.set(s,o),n.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}fromPointLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromPointLightState(t,n),this}};var iM=new A,sM=new A,oM=new nt,zc=class extends Qi(Jr(nf),ph){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};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=Be.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new Vr(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new zc().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),sM.setFromMatrixPosition(this.matrixWorld),oM.setFromRotationMatrix(this.matrixWorld),iM.copy(this.up).applyQuaternion(oM).negate().multiplyScalar(this.distance),this.target.position.copy(sM).add(iM),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}fromSpotLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromSpotLightState(t,n),this}};var aM=r=>r.tagName==="VIDEO",kc=class{static resize(e,t,n){let i=e/t,s;if(!n.image)return;let o=n.image;aM(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*s/i):n.repeat.set(1,1*s/i)),i<s&&(n.imageType=="WEBCAM"?n.repeat.set(1*i/s*-1,1):n.repeat.set(1*i/s,1)),i==s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1))}static resizeTextureLayer(e,t,n){let i=e/t,s=n.image!==void 0?n.image.width/n.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},n.repeat.set(o.x,o.y),n.updateMatrix()}static resizeTextureLayers(e,t,n){let i=n.layers;for(let s=0;s<i.length;s++){let o=i[s];KT(o)&&kc.resizeTextureLayer(e,t,o.uniforms[`f${o.id}_texture`].value)}}static resizeComplex(e,t,n,i){let s=e/t,o,a=n.image;aM(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t*o/s):n.repeat.set(1/e,1/t*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*s/o*-1,1/t):n.repeat.set(1/e*s/o,1/t)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t):n.repeat.set(1/e,1/t))):(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*o/s):n.repeat.set(1,1*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1*s/o*-1,1):n.repeat.set(1*s/o,1)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1)))}};var um=class extends wt{constructor(t,n){super(t,n);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t,n){super.updateGeometry(t,n),this.material.layers&&kc.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var Vc=class extends wt{constructor(t,n){super(t,n);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var hm=class extends Vc{constructor(t,n){super(t,n);this.objectType="NonParametric"}};var cM,Zh=new Promise(r=>{cM=r}),lM=!1;async function uM(){if(lM)return;let r=await import("./opentype.js");cM(r),lM=!0}var Kh=class{async load(e,t,n=()=>{}){let{load:i}=await Zh;i(e,(s,o)=>{s||!o?n(s??"Something went wrong"):t(o)})}async parse(e){let{parse:t}=await Zh;try{return t(e)}catch(n){console.error(n)}}};async function Ek(r){return await(await fetch(r)).arrayBuffer()}var Ck=new Kh;async function O0(r){let e,t,n=!1;if(r.url?(e=await Ek(r.url),t=r.url,n=r.url.startsWith("/")):r.data&&(e=r.data.buffer),e){let i=await Ck.parse(e);if(i)return{font:i,url:t,intercepted:n,arr:e}}}var hM=new A,dM=new be,fM=new oi;function pM(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(e=!0)}),e}var dm=class extends wt{constructor(t,n,i){super(new _c(n.geometry,i),i.material(n.material));this.data=n;this.objectType="TextFrame";this.wrappedText=[""];this.charWidths=[];this.charCoords=[];this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.name=n.name,this.uuid=t,this.updateState(n,i)}async updateGeometry(t,n){let i=t.parameters,s=this.geometry.getAttribute("randomColor"),o={...this.geometry.userData.parameters,...i};this.geometry.userData={parameters:o,type:"TextGeometry"},n&&(i.font||!this.geometry.font&&n.getFont(o.font))&&await this.geometry.updateFont(i.font??o.font,n),await this.geometry.update(o),Xi(this),s&&Yi(this);let{wrappedText:a,charCoords:l,charWidths:u}=this.geometry;this.wrappedText=a,this.charWidths=u,this.charCoords=l,this.resetBBoxNeedsUpdate()}updateState(t,n){this.data=t,this.material=n.material(t.material),this.fromState(t,n),this.updateGeometry({parameters:t.geometry},n)}get font(){return this.geometry.font}get initialOffsetY(){return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,this.geometry.userData.parameters.height,this.fontScale,this.geometry.userData.parameters.verticalAlign)??0}get fontScale(){return this.font?this.geometry.userData.parameters.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(){return this.geometry.userData.parameters.fontSize*this.geometry.userData.parameters.lineHeight}raycast(t,n){let{matrixWorld:i}=this;if(dM.copy(i).invert(),fM.copy(t.ray).applyMatrix4(dM),fM.intersectBox(this.singleBBox,hM)){let s=hM.applyMatrix4(i),o=t.ray.origin.distanceTo(s);n.push({distance:o,point:s.clone(),object:this})}}};var vM=Hx(gM());var R0;Kp.then(r=>{R0=r});var xM=new be,Pk=new be,Dk=new be,xi=new Mt,vo=new A,Ik=new be,Lk=new be;function bM(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.type==="Mesh"&&n.geometry.type==="SubdivGeometry"&&(e=!0)}),e}var xo=class extends wt{constructor(t,n,i,s){super(i??n,s);this.subdivPointer=t;this.originalGeometry=n;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new be;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new be;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,n,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Zr.build(n.geometry,void 0,void 0,!n.flatShading),l=i.material(n.material),u=new xo(s,o,a||void 0,l);return n.geometry.phongAngle!==void 0&&(u.phongAngle=n.geometry.phongAngle),u.calcBoundingBox(),u.freeSubdivPointer(),u.uuid=t,u.fromState(n),u}buildFromStore(t,n){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Zr.build(t,n,this.subdivPointer,this.smoothShading,this.shearScale);t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,Xi(this),Yi(this),t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,n){this.geometry=this.originalGeometry,wt.prototype.raycast.call(this,t,n),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,n=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,vM.SVD)(n),a=xM.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),l=Pk.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),u=Dk.copy(l).transpose();this.shearScale=Ik.makeScale(o[0],o[1],o[2]).multiply(u).premultiply(l),this.shearScaleInv=Lk.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,u),o.every(c=>Math.abs(o[0]-c)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new En);let n=t.attributes.position,i=t.boundingSphere.center;xi.setFromBufferAttribute(n),xi.getCenter(i),t.boundingSphere.radius=i.distanceTo(xi.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),xi.getSize(vo);let s={width:vo.x,height:vo.y,depth:vo.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let n=this.originalGeometry;xi.min.set(t[0],t[2],t[4]),xi.max.set(t[1],t[3],t[5]),this.shearScaleInv&&(xi.min.applyMatrix4(this.shearScaleInv),xi.max.applyMatrix4(this.shearScaleInv)),n.boundingSphere===null&&(n.boundingSphere=new En);let i=n.boundingSphere.center;xi.getCenter(i),n.boundingSphere.radius=i.distanceTo(xi.max),isNaN(n.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),xi.getSize(vo);let s={width:vo.x,height:vo.y,depth:vo.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&(R0.free_bvh(this.subdivPointer),R0.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t,n){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,yM(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(yM(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function yM(r,e,t,n){let i=r.position.array,s=r.normal.array,o=xM.makeScale(e,t,n).invert().elements,a,l,u;for(var c=0,h=i.length;c<h;c+=3)i[c]*=e,i[c+1]*=t,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u}function wM(r,e){e.flatShading!==void 0&&(r.flatShading=e.flatShading,r.needsUpdate=!0),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?r.side=Gr:e.side===1?r.side=un:r.side=tr)}function Ok(r,e){if(Array.isArray(r.material))for(let t of r.material)wM(t,e);else{let t=r.material;wM(t,e)}r.objectType==="SubdivObject"&&e.flatShading!==void 0&&(r.material.flatShading=!1,r.smoothShading=!e.flatShading,r.updateMesh())}function SM(r,e,t){let n;if(e.geometry.type==="SubdivGeometry")n=xo.createFromState(r,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new De:Jp(e.geometry,t),s="materials"in e?e.materials.map(o=>t.material(o)):t.material(e.material);gp.is2DParametricMesh(i.userData.type)?n=new um(i,s):i?.userData.type==="VectorGeometry"?n=new Bc(i,s):e.geometry.type==="NonParametricGeometry"?n=new hm(i,s):e.geometry.type==="BooleanGeometry"?(n=new cm(void 0,s),n.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(n.phongAngle=e.geometry.phongAngle)):n=new Vc(i,s),n.uuid=r,n.fromState(e,t)}return Ok(n,e),n}function AM(r,e,t){return e.type==="Mesh"?e.geometry.type==="TextGeometry"?new dm(r,e,t):SM(r,e,t):e.type==="Empty"?ya.createFromState(r,e):e.type==="PointLight"?Gc.createFromState(r,e,t):e.type==="SpotLight"?zc.createFromState(r,e,t):e.type==="DirectionalLight"?Uc.createFromState(r,e,t):Ri.is(e.type)?zn.createFromState(r,e):(console.error(e),new ya)}var va=class extends Or{};function _M(r,e){let t=!1,n=e.getLayersOfType("transmission"),i=e.getLayersOfType("outline");return i.length>0&&(r.layers.set(8),n.length>0&&r.layers.enable(3),t=!0,Yi(r),Xi(r)),n.length===0&&i.length===0&&r.layers.set(0),t}function TM(r,e){if(!e.layers)return!1;let t=!1,n=e.getLayersOfType("transmission"),i=e.getLayersOfType("outline");return n.length>0&&(r.layers.set(3),i.length>0&&r.layers.enable(8),t=!0),n.length===0&&i.length===0&&r.layers.set(0),t}function MM(r){let e=!1;return r.traverseEntity(t=>{if(t instanceof rn)if(Array.isArray(t.material))for(let n=0;n<t.material.length;n++)_M(t,t.material[n])&&(e=!0);else _M(t,t.material)&&(e=!0)}),e}function EM(r){let e=!1;return r.traverseEntity(t=>{if(t instanceof rn)if(Array.isArray(t.material))for(let n=0;n<t.material.length;n++)TM(t,t.material[n])&&(e=!0);else TM(t,t.material)&&(e=!0)}),e}function CM(r){"material"in r&&Rk(r.material),"geometry"in r&&r.geometry.dispose()}function Rk(r){J1(r).forEach(e=>{e instanceof va||e.dispose()})}var Nk=new hl,Bk=new be,Fk=new oi;function PM(r,e,t){let n=r.cloner;if(n)for(let i of n.children){let s=Bk.copy(i.matrixWorld).invert(),o=Fk.copy(e.ray).applyMatrix4(s),a=r.matrixWorld;o.applyMatrix4(a);let l=Nk;l.set(o.origin,o.direction),l.near=e.near,l.far=e.far,l.intersectObject(r,!1).length>0&&t.push({object:r})}}var DM=new A,N0=class extends tm(ir){constructor(t,n){super();this.objectType="Scene";this.backupFog=new Ka(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.bgColor=new $t(1,1,1,1);this.entityByUuid={};this.ambientLight=new Xo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=t.postprocessing,this.init(t,n),this.matrixAutoUpdate=!1}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=EM(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=MM(this),this.needsNormalDirty=!1),this._needsNormal}find(t){if(t===""||t===void 0)return;let n=this.entityByUuid[t];return n===void 0?this.getObjectByProperty("uuid",t):n}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,n){if(this.createChildrenObjects(t.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(In(t.backgroundColor,n)),this.updateFog(t.fog,n),this.updateAmbientLight(t.environment.ambientLight,n),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof zn&&this.switchActiveCamera(i)}this.traverse(i=>{Vt(i)&&i.recomputeBoolean()})}clearScene(){this.traverseEntity(t=>{CM(t)});for(let t of this.children)zi(t)&&t.removeFromParent()}resetAfterClear(t,n){this.init(t,n)}createPersonalCamera(){let t=zn.createFromState(N0.PERSONAL_CAMERA_ID,{...yp.defaultData,name:"Personal Camera"});return t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let n=[],i=s=>{for(let o of s.children)zi(o)&&!o.raycastLock&&o.visible&&((kt(o)||em(o)&&this.enableHelpers&&o.objectHelper.visible)&&(t.intersectObject(o,!1,n),PM(o,t,n)),i(o))};return i(this),n}traverseEntity(t){for(let n of this.children)zi(n)&&n.traverseEntity(t)}traverseVisibleEntity(t){for(let n of this.children)zi(n)&&n.visible&&n.traverseVisibleEntity(t)}updateFog(t,n){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=In(t.color,n),this.backupFog.near=t.near,this.backupFog.far=t.far}dispose(){this.clearScene()}updateAmbientLight(t,n){GT(this.ambientLight,t,n),t.groundColor!==void 0&&(this.ambientLight.groundColor=In(t.groundColor,n)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}createChildrenObjects(t,n,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,n,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let n of t.children)this.unregisterObject(n)}createChildObject(t,n,i,s,o){let a=AM(t,n,o);return a&&(this.entityByUuid[t]=a,s.add(a),Vt(s)&&kt(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let n=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let i=new Mt;return i.setFromPoints(n),i.getCenter(DM),DM}copyMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(t){this.traverseEntity(n=>{if(n instanceof wt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)n.material[i]instanceof Or&&t(n.material[i]);else n.material instanceof Or&&t(n.material)})}updateCanvasSize(t,n){this.activeCamera.setViewplaneSize(t,n);let i,s;t>=n?(i=n/t,s=1):(i=1,s=t/n),this.traverseMaterial(o=>{o.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Ss=N0;Ss.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var $h=(r,e)=>{let t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)},IM=(r,e)=>{let t=e.x-r.x,n=e.y-r.y;return Uk(Math.atan2(n,t))},LM=(r,e,t)=>{let n={x:0,y:0};return t=pm(t),n.x=r.x-e*Math.cos(t),n.y=r.y-e*Math.sin(t),n},pm=r=>r*(Math.PI/180),Uk=r=>r*(180/Math.PI),OM=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,B0=new Map,F0=r=>{B0.has(r)&&clearTimeout(B0.get(r)),B0.set(r,setTimeout(r,100))},Hc=(r,e,t)=>{let n=e.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.addEventListener?r.addEventListener(i,t,!1):r.attachEvent&&r.attachEvent(i,t)},U0=(r,e,t)=>{let n=e.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.removeEventListener?r.removeEventListener(i,t):r.detachEvent&&r.detachEvent(i,t)};var mm=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),G0=()=>{if(typeof window>"u")return;let r=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:r,y:e}},gm=(r,e)=>{e.top||e.right||e.bottom||e.left?(r.style.top=e.top,r.style.right=e.right,r.style.bottom=e.bottom,r.style.left=e.left):(r.style.left=e.x+"px",r.style.top=e.y+"px")},ym=(r,e,t)=>{let n=NM(r);for(let i in n)if(n.hasOwnProperty(i))if(typeof e=="string")n[i]=e+" "+t;else{let s="";for(let o=0,a=e.length;o<a;o+=1)s+=e[o]+" "+t+", ";n[i]=s.slice(0,-2)}return n},RM=(r,e)=>{let t=NM(r);for(let n in t)t.hasOwnProperty(n)&&(t[n]=e);return t},NM=r=>{let e={};return e[r]="",["webkit","Moz","o"].forEach(function(n){e[n+r.charAt(0).toUpperCase()+r.slice(1)]=""}),e},vm=(r,e)=>{for(let t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r},BM=(r,e)=>{let t={};for(let n in r)r.hasOwnProperty(n)&&e.hasOwnProperty(n)?t[n]=e[n]:r.hasOwnProperty(n)&&(t[n]=r[n]);return t},ed=(r,e)=>{if(r.length)for(let t=0,n=r.length;t<n;t+=1)e(r[t]);else e(r)},FM=(r,e,t)=>({x:Math.min(Math.max(r.x,e.x-t),e.x+t),y:Math.min(Math.max(r.y,e.y-t),e.y+t)});typeof window<"u"&&(UM="ontouchstart"in window,GM=!!window.PointerEvent,zM=!!window.MSPointerEvent);var UM,GM,zM,td={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Wc,nd={};GM?Wc=td.pointer:zM?Wc=td.MSPointer:UM?(Wc=td.touch,nd=td.mouse):Wc=td.mouse;function xa(){}xa.prototype.on=function(r,e){var t=this,n=r.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],t._handlers_[i]=t._handlers_[i]||[],t._handlers_[i].push(e);return t};xa.prototype.off=function(r,e){var t=this;return t._handlers_=t._handlers_||{},r===void 0?t._handlers_={}:e===void 0?t._handlers_[r]=null:t._handlers_[r]&&t._handlers_[r].indexOf(e)>=0&&t._handlers_[r].splice(t._handlers_[r].indexOf(e),1),t};xa.prototype.trigger=function(r,e){var t=this,n=r.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],t._handlers_[i]&&t._handlers_[i].length&&t._handlers_[i].forEach(function(o){o.call(t,{type:i,target:t},e)})};xa.prototype.config=function(r){var e=this;e.options=e.defaults||{},r&&(e.options=BM(e.options,r))};xa.prototype.bindEvt=function(r,e){var t=this;return t._domHandlers_=t._domHandlers_||{},t._domHandlers_[e]=function(){typeof t["on"+e]=="function"?t["on"+e].apply(t,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},Hc(r,Wc[e],t._domHandlers_[e]),nd[e]&&Hc(r,nd[e],t._domHandlers_[e]),t};xa.prototype.unbindEvt=function(r,e){var t=this;return t._domHandlers_=t._domHandlers_||{},U0(r,Wc[e],t._domHandlers_[e]),nd[e]&&U0(r,nd[e],t._domHandlers_[e]),delete t._domHandlers_[e],this};var jc=xa;function An(r,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=r,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=An.id,An.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}An.prototype=new jc;An.constructor=An;An.id=0;An.prototype.buildEl=function(r){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};An.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",e=RM("borderRadius","50%"),t=ym("transition","opacity",r),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},vm(n.el,t),this.options.shape==="circle"&&vm(n.back,e),vm(n.front,e),this.applyStyles(n),this};An.prototype.applyStyles=function(r){for(var e in this.ui)if(this.ui.hasOwnProperty(e))for(var t in r[e])this.ui[e].style[t]=r[e][t];return this};An.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};An.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};An.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};An.prototype.show=function(r){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof r=="function"&&r.call(this)},e.options.fadeTime)),e};An.prototype.hide=function(r){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var t=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=t,typeof r=="function"&&r.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let t=e.options.restJoystick,n={};n.x=t===!0||t.x!==!1?0:e.instance.frontPosition.x,n.y=t===!0||t.y!==!1?0:e.instance.frontPosition.y,e.setPosition(r,n)}return e};An.prototype.setPosition=function(r,e){var t=this;t.frontPosition={x:e.x,y:e.y};var n=t.options.fadeTime+"ms",i={};i.front=ym("transition",["top","left"],n);var s={front:{}};s.front={left:t.frontPosition.x+"px",top:t.frontPosition.y+"px"},t.applyStyles(i),t.applyStyles(s),t.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(t),t.restCallback()},t.options.fadeTime)};An.prototype.restCallback=function(){var r=this,e={};e.front=ym("transition","none",""),r.applyStyles(e),r.trigger("rested",r.instance)};An.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};An.prototype.computeDirection=function(r){var e=r.angle.radian,t=Math.PI/4,n=Math.PI/2,i,s,o;if(e>t&&e<t*3&&!r.lockX?i="up":e>-t&&e<=t&&!r.lockY?i="left":e>-t*3&&e<=-t&&!r.lockX?i="down":r.lockY||(i="right"),r.lockY||(e>-n&&e<n?s="left":s="right"),r.lockX||(e>0?o="up":o="down"),r.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:i},r.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return r;(!u.x||!u.y)&&this.trigger("plain",r),u.x||this.trigger("plain:"+s,r),u.y||this.trigger("plain:"+o,r),u.angle||this.trigger("dir dir:"+i,r)}else this.resetDirection();return r};var kM=An;function on(r,e){var t=this;t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.pressureIntervals={},t.manager=r,t.id=on.id,on.id+=1,t.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},t.config(e),(t.options.mode==="static"||t.options.mode==="semi")&&(t.options.multitouch=!1),t.options.multitouch||(t.options.maxNumberOfNipples=1);let n=getComputedStyle(t.options.zone.parentElement);return n&&n.display==="flex"&&(t.parentIsFlex=!0),t.updateBox(),t.prepareNipples(),t.bindings(),t.begin(),t.nipples}on.prototype=new jc;on.constructor=on;on.id=0;on.prototype.prepareNipples=function(){var r=this,e=r.nipples;e.on=r.on.bind(r),e.off=r.off.bind(r),e.options=r.options,e.destroy=r.destroy.bind(r),e.ids=r.ids,e.id=r.id,e.processOnMove=r.processOnMove.bind(r),e.processOnEnd=r.processOnEnd.bind(r),e.get=function(t){if(t===void 0)return e[0];for(var n=0,i=e.length;n<i;n+=1)if(e[n].identifier===t)return e[n];return!1}};on.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};on.prototype.begin=function(){var r=this,e=r.options;if(e.mode==="static"){var t=r.createNipple(e.position,r.manager.getIdentifier());t.add(),r.idles.push(t)}};on.prototype.createNipple=function(r,e){var t=this,n=t.manager.scroll,i={},s=t.options,o={x:t.parentIsFlex?n.x:n.x+t.box.left,y:t.parentIsFlex?n.y:n.y+t.box.top};if(r.x&&r.y)i={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=r,r={x:l.left+n.x,y:l.top+n.y}}var u=new kM(t,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:e,position:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(gm(u.ui.el,i),gm(u.ui.front,u.frontPosition)),t.nipples.push(u),t.trigger("added "+u.identifier+":added",u),t.manager.trigger("added "+u.identifier+":added",u),t.bindNipple(u),u};on.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};on.prototype.bindNipple=function(r){var e=this,t,n=function(i,s){t=i.type+" "+s.id+":"+i.type,e.trigger(t,s)};r.on("destroyed",e.onDestroyed.bind(e)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};on.prototype.pressureFn=function(r,e,t){var n=this,i=0;clearInterval(n.pressureIntervals[t]),n.pressureIntervals[t]=setInterval(function(){var s=r.force||r.pressure||r.webkitForce||0;s!==i&&(e.trigger("pressure",s),n.trigger("pressure "+e.identifier+":pressure",s),i=s)}.bind(n),100)};on.prototype.onstart=function(r){var e=this,t=e.options,n=r;r=mm(r),e.updateBox();var i=function(s){e.actives.length<t.maxNumberOfNipples?e.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[r[0]];a.identifier=o,e.processOnEnd(a)}}),e.actives.length<t.maxNumberOfNipples&&e.processOnStart(s))};return ed(r,i),e.manager.bindDocument(),!1};on.prototype.processOnStart=function(r){var e=this,t=e.options,n,i=e.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=e.getOrCreate(i,o);a.identifier!==i&&e.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(c){c.trigger("start",c),e.trigger("start "+c.id+":start",c),c.show(),s>0&&e.pressureFn(r,c,c.identifier),e.processOnMove(r)};if((n=e.idles.indexOf(a))>=0&&e.idles.splice(n,1),e.actives.push(a),e.ids.push(a.identifier),t.mode!=="semi")l(a);else{var u=$h(o,a.position);if(u<=t.catchDistance)l(a);else{a.destroy(),e.processOnStart(r);return}}return a};on.prototype.getOrCreate=function(r,e){var t=this,n=t.options,i;return/(semi|static)/.test(n.mode)?(i=t.idles[0],i?(t.idles.splice(0,1),i):n.mode==="semi"?t.createNipple(e,r):(console.warn("Coudln't find the needed nipple."),!1)):(i=t.createNipple(e,r),i)};on.prototype.processOnMove=function(r){var e=this,t=e.options,n=e.manager.getIdentifier(r),i=e.nipples.get(n),s=e.manager.scroll;if(!OM(r)){this.processOnEnd(r);return}if(!i){console.error("Found zombie joystick with ID "+n),e.manager.removeIdentifier(n);return}if(t.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=n;var a=i.options.size/2,l={x:r.pageX,y:r.pageY};t.lockX&&(l.y=i.position.y),t.lockY&&(l.x=i.position.x);var u=$h(l,i.position),c=IM(l,i.position),h=pm(c),d=u/a,f={distance:u,position:l},m,p;if(i.options.shape==="circle"?(m=Math.min(u,a),p=LM(i.position,m,c)):(p=FM(l,i.position,a),m=$h(p,i.position)),t.follow){if(u>a){let w=l.x-p.x,b=l.y-p.y;i.position.x+=w,i.position.y+=b,i.el.style.top=i.position.y-(e.box.top+s.y)+"px",i.el.style.left=i.position.x-(e.box.left+s.x)+"px",u=$h(l,i.position)}}else l=p,u=m;var g=l.x-i.position.x,v=l.y-i.position.y;i.frontPosition={x:g,y:v},t.dataOnly||gm(i.ui.front,i.frontPosition);var y={identifier:i.identifier,position:l,force:d,pressure:r.force||r.pressure||r.webkitForce||0,distance:u,angle:{radian:h,degree:c},vector:{x:g/a,y:-v/a},raw:f,instance:i,lockX:t.lockX,lockY:t.lockY};y=i.computeDirection(y),y.angle={radian:pm(180-c),degree:180-c},i.trigger("move",y),e.trigger("move "+i.id+":move",y)};on.prototype.processOnEnd=function(r){var e=this,t=e.options,n=e.manager.getIdentifier(r),i=e.nipples.get(n),s=e.manager.removeIdentifier(i.identifier);!i||(t.dataOnly||i.hide(function(){t.mode==="dynamic"&&(i.trigger("removed",i),e.trigger("removed "+i.id+":removed",i),e.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(e.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),e.trigger("end "+i.id+":end",i),e.ids.indexOf(i.identifier)>=0&&e.ids.splice(e.ids.indexOf(i.identifier),1),e.actives.indexOf(i)>=0&&e.actives.splice(e.actives.indexOf(i),1),/(semi|static)/.test(t.mode)?e.idles.push(i):e.nipples.indexOf(i)>=0&&e.nipples.splice(e.nipples.indexOf(i),1),e.manager.unbindDocument(),/(semi|static)/.test(t.mode)&&(e.manager.ids[s.id]=s.identifier))};on.prototype.onDestroyed=function(r,e){var t=this;t.nipples.indexOf(e)>=0&&t.nipples.splice(t.nipples.indexOf(e),1),t.actives.indexOf(e)>=0&&t.actives.splice(t.actives.indexOf(e),1),t.idles.indexOf(e)>=0&&t.idles.splice(t.idles.indexOf(e),1),t.ids.indexOf(e.identifier)>=0&&t.ids.splice(t.ids.indexOf(e.identifier),1),t.manager.removeIdentifier(e.identifier),t.manager.unbindDocument()};on.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(t){t.destroy()});for(var e in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(e)&&clearInterval(r.pressureIntervals[e]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};var VM=on;function Nn(r){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=G0(),e.config(r),e.prepareCollections();var t=function(){var i;e.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:e.scroll.x+i.left,y:e.scroll.y+i.top}})})};if(typeof window>"u")return e.collections;Hc(window,"resize",function(){F0(t)});var n=function(){e.scroll=G0()};return Hc(window,"scroll",function(){F0(n)}),e.collections}Nn.prototype=new jc;Nn.constructor=Nn;Nn.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(e){var t;return r.collections.every(function(n){return t=n.get(e),!t}),t}};Nn.prototype.create=function(r){return this.createCollection(r)};Nn.prototype.createCollection=function(r){var e=this,t=new VM(e,r);return e.bindCollection(t),e.collections.push(t),t};Nn.prototype.bindCollection=function(r){var e=this,t,n=function(i,s){t=i.type+" "+s.id+":"+i.type,e.trigger(t,s)};r.on("destroyed",e.onDestroyed.bind(e)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};Nn.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};Nn.prototype.unbindDocument=function(r){var e=this;(!Object.keys(e.ids).length||r===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)};Nn.prototype.getIdentifier=function(r){var e;return r?(e=r.identifier===void 0?r.pointerId:r.identifier,e===void 0&&(e=this.latest||0)):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]};Nn.prototype.removeIdentifier=function(r){var e={};for(var t in this.ids)if(this.ids[t]===r){e.id=t,e.identifier=this.ids[t],delete this.ids[t];break}return e};Nn.prototype.onmove=function(r){var e=this;return e.onAny("move",r),!1};Nn.prototype.onend=function(r){var e=this;return e.onAny("end",r),!1};Nn.prototype.oncancel=function(r){var e=this;return e.onAny("end",r),!1};Nn.prototype.onAny=function(r,e){var t=this,n,i="processOn"+r.charAt(0).toUpperCase()+r.slice(1);e=mm(e);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[i](a),a._found_=!0)},o=function(a){n=t.getIdentifier(a),ed(t.collections,s.bind(null,a,n)),a._found_||t.removeIdentifier(n)};return ed(e,o),!1};Nn.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(e){e.destroy()}),r.off()};Nn.prototype.onDestroyed=function(r,e){var t=this;if(t.collections.indexOf(e)<0)return!1;t.collections.splice(t.collections.indexOf(e),1)};var HM=Nn;var WM=new HM,jM={create:function(r){return WM.create(r)},factory:WM};function bo(r,e){let t=new De,{positions:n,triIndices:i}=Th(r.getAttribute("position"),r.getIndex());return t.setAttribute("position",new Ae(n,3)),t.setIndex(i),e&&t.applyMatrix4(e),t}var bm=class extends hl{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,n=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,n)}),n}createRaycastLineHelper(){let e=new zr({color:65280,linewidth:10}),t=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(t,n.multiplyScalar(i)),o=new De;return o.setFromPoints([t,s]),new zo(o,e)}};var QM=Hx(qM());var XM=new Map;function YM(r){if(typeof r=="string")return r;let e=XM.get(r);return e||(e={url:URL.createObjectURL(new Blob([r]))},XM.set(r,e)),e.url}var wo=class{constructor({src:e,volume:t,delay:n,loop:i}){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 s;typeof e=="string"?s={src:e}:s={src:YM(e),format:"wav"},this.sound=new QM.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),n!==void 0&&(this.delay=n),i!==void 0&&(this.loop=i)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,n){this.sound.on(e,t,n)}off(e,t,n){this.sound.off(e,t,n)}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(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Sm=class{constructor(){this.type="ShapePath";this.color=new Le;this.subPaths=[];this.currentPath=null}moveTo(e,t){return this.currentPath=new Vo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath?.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath?.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let t={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},n={loc:t.ORIGIN,t:0};function i(p,g,v,y){let w=p.x,b=g.x,S=v.x,_=y.x,M=p.y,x=g.y,T=v.y,E=y.y,C=(_-S)*(M-T)-(E-T)*(w-S),P=(b-w)*(M-T)-(x-M)*(w-S),O=(E-T)*(b-w)-(_-S)*(x-M),I=C/O,N=P/O;if(O===0&&C!==0||I<=0||I>=1||N<0||N>1)return null;if(C===0&&O===0){for(let F=0;F<2;F++)if(s(F===0?v:y,p,g),n.loc===t.ORIGIN){let G=F===0?v:y;return{x:G.x,y:G.y,t:n.t}}else if(n.loc===t.BETWEEN){let G=+(w+n.t*(b-w)).toPrecision(10),Y=+(M+n.t*(x-M)).toPrecision(10);return{x:G,y:Y,t:n.t}}return null}else{for(let Y=0;Y<2;Y++)if(s(Y===0?v:y,p,g),n.loc===t.ORIGIN){let U=Y===0?v:y;return{x:U.x,y:U.y,t:n.t}}let F=+(w+I*(b-w)).toPrecision(10),G=+(M+I*(x-M)).toPrecision(10);return{x:F,y:G,t:I}}}function s(p,g,v){let y=v.x-g.x,w=v.y-g.y,b=p.x-g.x,S=p.y-g.y,_=y*S-b*w;if(p.x===g.x&&p.y===g.y){n.loc=t.ORIGIN,n.t=0;return}if(p.x===v.x&&p.y===v.y){n.loc=t.DESTINATION,n.t=1;return}if(_<-Number.EPSILON){n.loc=t.LEFT;return}if(_>Number.EPSILON){n.loc=t.RIGHT;return}if(y*b<0||w*S<0){n.loc=t.BEHIND;return}if(Math.sqrt(y*y+w*w)<Math.sqrt(b*b+S*S)){n.loc=t.BEYOND;return}let M;y!==0?M=b/y:M=S/w,n.loc=t.BETWEEN,n.t=M}function o(p,g){let v=[],y=[];for(let w=1;w<p.length;w++){let b=p[w-1],S=p[w];for(let _=1;_<g.length;_++){let M=g[_-1],x=g[_],T=i(b,S,M,x);T!==null&&v.find(E=>E.t<=T.t+Number.EPSILON&&E.t>=T.t-Number.EPSILON)===void 0&&(v.push(T),y.push(new B(T.x,T.y)))}}return y}function a(p,g,v){let y=new B;g.getCenter(y);let w=[];return v.forEach(b=>{b.boundingBox.containsPoint(y)&&o(p,b.points).forEach(_=>{w.push({identifier:b.identifier,isCW:b.isCW,point:_})})}),w.sort((b,S)=>b.point.x-S.point.x),w}function l(p,g,v,y,w){(w==null||w==="")&&(w="nonzero");let b=new B;p.boundingBox.getCenter(b);let S=[new B(v,b.y),new B(y,b.y)],_=a(S,p.boundingBox,g);_.sort((P,O)=>P.point.x-O.point.x);let M=[],x=[];_.forEach(P=>{P.identifier===p.identifier?M.push(P):x.push(P)});let T=M[0].point.x,E=[],C=0;for(;C<x.length&&x[C].point.x<T;)E.length>0&&E[E.length-1]===x[C].identifier?E.pop():E.push(x[C].identifier),C++;if(E.push(p.identifier),w==="evenodd"){let P=E.length%2===0,O=E[E.length-2];return{identifier:p.identifier,isHole:P,for:O}}else if(w==="nonzero"){let P=!0,O=null,I=null;for(let N=0;N<E.length;N++){let F=E[N];g[F]&&(P?(I=g[F].isCW,P=!1,O=F):I!==g[F].isCW&&(I=g[F].isCW,P=!0))}return{identifier:p.identifier,isHole:P,for:O}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,c=999999999,h=-999999999,d=[];this.subPaths.forEach(p=>{let g=p.getPoints(),v=-999999999,y=999999999,w=-999999999,b=999999999;for(let S=0;S<g.length;S++){let _=g[S];_.y>v&&(v=_.y),_.y<y&&(y=_.y),_.x>w&&(w=_.x),_.x<b&&(b=_.x)}h<=w&&(h=w+1),c>=b&&(c=b-1),g.length&&d.push({curves:p.curves,points:g,isCW:rl.isClockWise(g),identifier:u++,boundingBox:new af(new B(b,y),new B(w,v))})});let f=d.map(p=>l(p,d,c,h,this.userData?.style.fillRule)),m=[];return d.forEach(p=>{let g=f[p.identifier];if(g&&!g.isHole){let v=new ds;v.curves=p.curves,f.filter(w=>w?.isHole&&w.for===p.identifier).forEach(w=>{if(w){let b=d[w.identifier],S=new Vo;S.curves=b.curves,v.holes.push(S)}}),m.push(v)}}),m}};var z0=new WeakMap,Am=class extends al{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new ll(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let u=t.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=u.name)}let n=JSON.stringify(t);if(z0.has(e)){let l=z0.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((u,c)=>{i._callbacks[s]={resolve:u,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),z0.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new De;e.index&&t.setIndex(new Ge(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new Ge(o,a))}return t}_loadLibrary(e,t){let n=new ll(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=Gk.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4908
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function Gk(){let r,e;onmessage=function(o){let a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(c){r.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(r)});break;case"decode":let l=a.buffer,u=a.taskConfig;e.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=t(h,d,f,u),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{h.destroy(f),h.destroy(d)}});break}};function t(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in c){let v=self[h[g]],y,w;if(u.useUniqueIDs)w=c[g],y=a.GetAttributeByUniqueId(d,w);else{if(w=a.GetAttributeId(d,o[c[g]]),w===-1)continue;y=a.GetAttribute(d,w)}p.attributes.push(i(o,a,d,g,v,y))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,d)),o.destroy(d),p}function n(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,u,c,h){let d=h.num_components(),m=l.num_points()*d,p=m*c.BYTES_PER_ELEMENT,g=s(o,c),v=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,h,g,p,v);let y=new c(o.HEAPF32.buffer,v,m).slice();return o._free(v),{name:u,array:y,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var So;function zk(){return So||(So=new Am,So.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),So.decoderPending}async function kk(r){if(So){let e={attributeIDs:So.defaultAttributeIDs,attributeTypes:So.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await So.decodeGeometry(new Int8Array(r).buffer,e)}catch(n){console.error(n)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([n,i])=>({name:n,itemSize:i.itemSize,array:i.array}))}}return null}async function ZM(r,e){let[t,n]=iv(ap.deserialize(new Uint8Array(r)));c_(t);let i=[];t.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&i.push(o)}),i.length&&await zk();for(let s of i){let o=await kk(dr(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return e&&e(t),n.result().data}function Vk(r,e){return e.state.glyphIndex===r||e.state.fina===r||e.state.medi===r||e.state.init===r}var _m=class{constructor(e,t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=e.isUserFont??!1,this._loadingPromise=O0(e).then(n=>{n&&(this._arrayBuffer=n.arr,this._url=n.url,this.font=n.font,this._intercepted=n.intercepted,this._isLoaded=!0,t())})}update(e,t){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=O0(e).then(n=>{n&&(this._arrayBuffer=n.arr,this._url=n.url,this.font=n.font,this._intercepted=n.intercepted,this._isLoaded=!0,t())})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}async reverseLigaturesTable(e,t,n){let{Bidi:i}=await Zh,s=new i,o=h=>e.charToGlyphIndex(h.char);s.registerModifier("glyphIndex",null,o),s.applyFeatures(e,e.defaultRenderOptions.features),s.getTextGlyphs(t);let a=s.tokenizer.tokens,l=[],u=0,c=n.length===a.length;for(let h=0;h<n.length;h++){let d=n[h].index,f=String.fromCharCode(n[h].unicode),m=a[u];if(Vk(d,m)||c)l.push({char:f,index:d,replacements:[m.state.glyphIndex],replacementChars:[m.char]}),u++;else{let p=m.char,g="",v=[m.state.glyphIndex],y=[],w=!1;for(;!w;)u++,g=t.charAt(u),p+=g,v.push(e.charToGlyphIndex(g)),y=e.stringToGlyphs(p),y.length===1&&y[0].index===d&&(w=!0),u>t.length&&(w=!0);l.push({char:f,index:d,replacements:v,replacementChars:Array.from(p)}),u++}}return l}async generateShapes(e,t){await this._loadingPromise;let n=this.font,i=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,o=e.map(v=>this.getTextWidth(v,t)),a=t.width,l=this.getLineInitialOffsetX(o[0],a,t.horizontalAlign),u=this.getLineInitialOffsetY(s,e.length,t.height,i,t.verticalAlign),c=this.computeSpaceWidthForLine(e,0,t),h=this.getCharWidth(`
4909
- `,t),d=[],f=e.map(v=>[]),m=e.map(v=>[]),p;for(let v=0;v<e.length;v++){let y=e[v],w={features:{liga:!0}},b=[];try{b=n.stringToGlyphs(y,w)}catch(_){console.warn(_)}l=this.getLineInitialOffsetX(o[v],a,t.horizontalAlign);let S=[];try{S=await this.reverseLigaturesTable(n,y,b)}catch(_){console.warn(_)}c=this.computeSpaceWidthForLine(e,v,t);for(let _=0;_<b.length;_++){let M=b[_],x=M.index===0?`
4910
- `:M.unicode?String.fromCharCode(M.unicode):void 0,T=S[_],E=0,C=0;_===0&&t.horizontalAlign===2&&M.leftSideBearing!==void 0&&(C=-M.leftSideBearing*i),p&&(E=n.getKerningValue(M,p)*i),l+=C+E;let P=0;if(x===`
4911
- `)P=h;else if(x===" ")P=c;else{let O=this.createPath(M,i,l,u,t);O&&(P=O.offsetX-(E+C),d.push(O.path))}if(T.replacements.length===1)m[v].push([l,u]),f[v].push(P);else{let O=T.replacements.map(G=>(n.glyphs.get(G).advanceWidth??0)*i),I=O.reduce((G,Y)=>G+=Y,0),N=O.map(G=>G/I),F=l;for(let G=0;G<N.length;G++){let Y=P*N[G];m[v].push([F,u]),f[v].push(Y),F+=Y}}l+=P,p=M}u-=s}let g=[];for(let v=0,y=d.length;v<y;v++)g.push(...d[v].toShapes());return{shapes:g,charWidths:f,lineWidths:o,charCoords:m}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(e,t,n){return n===3?t*.5-e*.5:n===2?t-e:0}getLineInitialOffsetY(e,t,n,i,s){let o=t*e,a=Math.abs(this.ascender-this.descender)*i,l=e-a,u=-this.ascender*i-l/2;return s===3?-(n-o-u):s===2?-(n*.5-o*.5-u):u}createPath(e,t,n,i,s){let o=e.getPath(n,-i,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!o){console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");return}let a=new Sm,l=(e.advanceWidth??1)*t;if(e)for(let u of o.commands){let c=a.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let c=Hk(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+s.fontSize*s.letterSpacing,path:a}}getCharWidth(e,t){return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}getTextWidth(e,t){return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}computeSpaceWidthForLine(e,t,n){let i=this.getCharWidth(" ",n),s=e[t];if(s){let o=this.countSpaces(s.trimEnd());if(n.horizontalAlign===4&&t<e.length-1&&o){let a=n.width,l=this.getTextWidth(s,n);return(a-(l-o*i))/o}}return i}countSpaces(e){return(e.match(/ /g)||[]).length}};function Hk(r){if(r.length){let e=r[0];if(e instanceof jn)return e.v1;if(e instanceof Wn||e instanceof Er)return e.v0}}var ba=class{constructor(e,t={}){this.deletedMaterial=new va(Fn.defaultTwoLayerData("basic"),this);this.deletedImage=new ga(Tp.emptyImage);this.materials={};this.images={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};this.onFontLoad=()=>{this._onFontLoad&&this._onFontLoad()};if(t.images)for(let[n,i]of Object.entries(t.images))this.addImage(n,i);if(t.audios)for(let[n,i]of Object.entries(t.audios))this.addAudio(n,i.data);this.reset(e)}setOnImageLoad(e){this._onImageLoad=e}setOnFontLoad(e){this._onFontLoad=e}reset(e){for(let[t,n]of Object.entries(e.images))this.addImage(t,n);for(let[t,n]of Object.entries(e.colors))this.addColor(t,n);for(let[t,n]of Object.entries(e.materials))this.addMaterial(t,new va(n,this));for(let[t,n]of Object.entries(e.audios))this.addAudio(t,n.data);for(let[t,n]of Object.entries(e.fonts))this.addFont(t,n);this.penumbraSize=e.penumbraSize}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):new Or(e,this)}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.images[e].updateSrc(t.data),!0):(this.images[e]=new ga(t,this.onImageLoad),!1)}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):new Nc(e,this.onImageLoad)}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new go(t.r,t.g,t.b,t.a):this.colors[e]=new go(t.r,t.g,t.b,1),!1)}updateColor(e,t){if(this.colors[e]){let n=this.colors[e];return this.colors[e].r=t.r??n.r,this.colors[e].g=t.g??n.g,this.colors[e].b=t.b??n.b,this.colors[e].a=t.a??n.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}color(e){let t;if(typeof e=="string"){let n=this.getColor(e);n?t=n:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new $t(0,0,0,0))}else return"a"in e?new $t(e.r,e.g,e.b,e.a):new $t(e.r,e.g,e.b,1);return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof wo)return t;{let n=new wo({src:t});return this.audios[e]=n,n}}deleteAudio(e){this.audios[e]&&delete this.audios[e]}addFont(e,t){this.fonts[e]=new _m(t,this.onFontLoad)}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._onImageLoad=void 0,Object.values(this.audios).forEach(t=>{t instanceof wo&&t.dispose()}),this.audios={}}},Ape=new ba(ec.emptyData());function Wk(r,e){return r.distance-e.distance}function JM(r,e,t){if(Kr(e)&&e.visible&&!e.raycastLock)e.raycast(r,t);else return;for(let n of e.children)JM(r,n,t)}function Mm(r,e,t){if(!t.some(i=>rd(r,i)!==void 0))return[];let n=[];return e.children.forEach(i=>JM(r,i,n)),n.sort(Wk),n}function Em(r){let e=[];if(r.length){let t=r[0].object;Kr(t)&&e.push(t);let n=t.parent;for(;n;)h0(n)&&e.push(n),n=n.parent}return e}function rd(r,e){if(kt(e)){if(!e.raycastLock&&e.visible){let t=[];return e.raycast(r,t),t.length?t[0]:void 0}}else if(h0(e))return $M(r,e)}function $M(r,e){if(kt(e)&&!e.raycastLock&&e.visible){let t=[];if(e.raycast(r,t),t.length)return t[0]}for(let t of e.children)if(Kr(t)){let n=$M(r,t);if(n)return n}}function jk(r){if(r.style.transform!==""){let e=getComputedStyle(r).getPropertyValue("transform");if(e!=="none"){let t=e.replace("matrix(","").split(",");return{x:parseFloat(t[0]),y:parseFloat(t[3])}}}return{x:1,y:1}}function KM(r){let e=r.getViewport(new He),t=jk(r.domElement);return{left:e.x*t.x,top:e.y*t.y,width:e.z*t.x,height:e.w*t.y}}function qk(r,e,t,n){let i=t.height-n.height,s=(r-n.left-t.left)*(t.width/n.width),o=(e-i+n.top-t.top)*(t.height/n.height);return{x:s/t.width*2-1,y:-(o/t.height)*2+1}}var Tm=class{constructor(e,t,n,i,s,o){this.isExport=o;this.raycaster=new bm;this.raycasterNeedsUpdate=!0;this.stopRaycast=!1;this.sharedAssets=new ba(ec.emptyData());this.scene=new Ss({...bp.defaultData},this.sharedAssets);this.camera=new zn;this.renderer=e,this.domElement=e.domElement,this._domRect=this.domElement.getBoundingClientRect(),this._viewRect=KM(this.renderer),this.stopRaycast=s,this.sharedAssets=i,this.scene=t,this.camera=n}get domRect(){return this._domRect}get viewRect(){return this._viewRect}updaterRect(){this._domRect=this.domElement.getBoundingClientRect(),this._viewRect=KM(this.renderer)}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{clientX:t,clientY:n}=e.touches!==void 0&&e.touches.length>0?e.touches[0]:e;this.raycaster.setFromCamera(qk(t,n,this._domRect,this._viewRect),this.camera)}};var k0=(o=>(o[o.keydown=0]="keydown",o[o.keyup=1]="keyup",o[o.pointerdown=2]="pointerdown",o[o.pointerup=3]="pointerup",o[o.pointermove=4]="pointermove",o[o.wheel=5]="wheel",o))(k0||{}),Bn=class{constructor(e){this.eventContext=e;this.domEventsNeeded=new Set}connect(){}disconnect(){}};var eE=new Map,id=new Map,As=class{constructor(e,t,n,i){this.data=t;let{audio:s,volume:o,delay:a,loop:l}=t;if(!s)throw new Error("Missing property");let u=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new wo({src:u,volume:o,delay:a,loop:l}),id.has(n.uuid)?id.get(n.uuid).push(this):id.set(n.uuid,[this]),eE.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},qc=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=eE.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=id.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...id.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Zi=class{constructor(e,t,n,i){this.data=t;if(t.interaction==="play")this.interaction=new As(e,t,n,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new qc(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof As?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof As?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof As&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Xk="text/plain",Yk="us-ascii",tE=(r,e)=>e.some(t=>t instanceof RegExp?t.test(r):t===r),Qk=(r,{stripHash:e})=>{let t=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(r);if(!t)throw new Error(`Invalid URL: ${r}`);let{type:n,data:i,hash:s}=t.groups,o=n.split(";");s=e?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(h=>{let[d,f=""]=h.split("=").map(m=>m.trim());return d==="charset"&&(f=f.toLowerCase(),f===Yk)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==Xk)&&c.unshift(l),`data:${c.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function V0(r,e){if(e={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...e},r=r.trim(),/^data:/i.test(r))return Qk(r,e);if(/^view-source:/i.test(r))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let t=r.startsWith("//");!t&&/^\.*\//.test(r)||(r=r.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,e.defaultProtocol));let i=new URL(r);if(e.forceHttp&&e.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(e.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),e.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),e.stripAuthentication&&(i.username="",i.password=""),e.stripHash?i.hash="":e.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(i.pathname);if(!c)break;let h=c[0],d=c.index;l+=i.pathname.slice(a,d).replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}l+=i.pathname.slice(a,i.pathname.length).replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(e.removeDirectoryIndex===!0&&(e.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(e.removeDirectoryIndex)&&e.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];tE(a,e.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),e.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(e.removeQueryParameters))for(let o of[...i.searchParams.keys()])tE(o,e.removeQueryParameters)&&i.searchParams.delete(o);if(e.removeQueryParameters===!0&&(i.search=""),e.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}e.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=r;return r=i.toString(),!e.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(r=r.replace(/\/$/,"")),(e.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&e.removeSingleSlash&&(r=r.replace(/\/$/,"")),t&&!e.normalizeProtocol&&(r=r.replace(/^http:\/\//,"//")),e.stripProtocol&&(r=r.replace(/^(?:https?:)?\/\//,"")),r}var Cm=class{constructor({url:e}){if(!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:V0(e)}dispatch(){sh?window.location.assign(this.url):window.open(this.url,"_blank")}};var aE={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},q0={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},Zk=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Dm={CSS:{},springs:{}};function Ki(r,e,t){return Math.min(Math.max(r,e),t)}function sd(r,e){return r.indexOf(e)>-1}function H0(r,e){return r.apply(null,e)}var je={arr:function(r){return Array.isArray(r)},obj:function(r){return sd(Object.prototype.toString.call(r),"Object")},pth:function(r){return je.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||je.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return je.hex(r)||je.rgb(r)||je.hsl(r)},key:function(r){return!aE.hasOwnProperty(r)&&!q0.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function lE(r){var e=/\(([^)]+)\)/.exec(r);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function cE(r,e){var t=lE(r),n=Ki(je.und(t[0])?1:t[0],.1,100),i=Ki(je.und(t[1])?100:t[1],.1,100),s=Ki(je.und(t[2])?10:t[2],.1,100),o=Ki(je.und(t[3])?0:t[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,h=l<1?(l*a+-o)/u:-o+a;function d(m){var p=e?e*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+h*Math.sin(u*p)):p=(c+h*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=Dm.springs[r];if(m)return m;for(var p=1/6,g=0,v=0;;)if(g+=p,d(g)===1){if(v++,v>=16)break}else v=0;var y=g*p*1e3;return Dm.springs[r]=y,y}return e?d:f}function Kk(r){return r===void 0&&(r=10),function(e){return Math.ceil(Ki(e,1e-6,1)*r)*(1/r)}}var Jk=function(){var r=11,e=1/(r-1);function t(c,h){return 1-3*h+3*c}function n(c,h){return 3*h-6*c}function i(c){return 3*c}function s(c,h,d){return((t(h,d)*c+n(h,d))*c+i(h))*c}function o(c,h,d){return 3*t(h,d)*c*c+2*n(h,d)*c+i(h)}function a(c,h,d,f,m){var p,g,v=0;do g=h+(d-h)/2,p=s(g,f,m)-c,p>0?d=g:h=g;while(Math.abs(p)>1e-7&&++v<10);return g}function l(c,h,d,f){for(var m=0;m<4;++m){var p=o(h,d,f);if(p===0)return h;var g=s(h,d,f)-c;h-=g/p}return h}function u(c,h,d,f){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var m=new Float32Array(r);if(c!==h||d!==f)for(var p=0;p<r;++p)m[p]=s(p*e,c,d);function g(v){for(var y=0,w=1,b=r-1;w!==b&&m[w]<=v;++w)y+=e;--w;var S=(v-m[w])/(m[w+1]-m[w]),_=y+S*e,M=o(_,c,d);return M>=.001?l(v,_,c,d):M===0?_:a(v,y,y+e,c,d)}return function(v){return c===h&&d===f||v===0||v===1?v:s(g(v),h,f)}}return u}(),uE=function(){var r={linear:function(){return function(n){return n}}},e={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=Ki(n,1,10),o=Ki(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(n,i){e[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(e).forEach(function(n){var i=e[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function X0(r,e){if(je.fnc(r))return r;var t=r.split("(")[0],n=uE[t],i=lE(r);switch(t){case"spring":return cE(r,e);case"cubicBezier":return H0(Jk,i);case"steps":return H0(Kk,i);default:return H0(n,i)}}function hE(r){try{var e=document.querySelectorAll(r);return e}catch{return}}function Im(r,e){for(var t=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<t;s++)if(s in r){var o=r[s];e.call(n,o,s,r)&&i.push(o)}return i}function Lm(r){return r.reduce(function(e,t){return e.concat(je.arr(t)?Lm(t):t)},[])}function nE(r){return je.arr(r)?r:(je.str(r)&&(r=hE(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function Y0(r,e){return r.some(function(t){return t===e})}function Q0(r){var e={};for(var t in r)e[t]=r[t];return e}function W0(r,e){var t=Q0(r);for(var n in r)t[n]=e.hasOwnProperty(n)?e[n]:r[n];return t}function Om(r,e){var t=Q0(r);for(var n in e)t[n]=je.und(r[n])?e[n]:r[n];return t}function $k(r){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return e?"rgba("+e[1]+",1)":r}function eV(r){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=r.replace(e,function(a,l,u,c){return l+l+u+u+c+c}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function tV(r){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),t=parseInt(e[1],10)/360,n=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100,s=e[4]||1;function o(d,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(f-d)*6*m:m<1/2?f:m<2/3?d+(f-d)*(2/3-m)*6:d}var a,l,u;if(n==0)a=l=u=i;else{var c=i<.5?i*(1+n):i+n-i*n,h=2*i-c;a=o(h,c,t+1/3),l=o(h,c,t),u=o(h,c,t-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function nV(r){if(je.rgb(r))return $k(r);if(je.hex(r))return eV(r);if(je.hsl(r))return tV(r)}function _s(r){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(e)return e[1]}function rV(r){if(sd(r,"translate")||r==="perspective")return"px";if(sd(r,"rotate")||sd(r,"skew"))return"deg"}function j0(r,e){return je.fnc(r)?r(e.target,e.id,e.total):r}function Ji(r,e){return r.getAttribute(e)}function Z0(r,e,t){var n=_s(e);if(Y0([t,"deg","rad","turn"],n))return e;var i=Dm.CSS[e+t];if(!je.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(e);return Dm.CSS[e+t]=u,u}function dE(r,e,t){if(e in r.style){var n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[e]||getComputedStyle(r).getPropertyValue(n)||"0";return t?Z0(r,i,t):i}}function K0(r,e){if(je.dom(r)&&!je.inp(r)&&(Ji(r,e)||je.svg(r)&&r[e]))return"attribute";if(je.dom(r)&&Y0(Zk,e))return"transform";if(je.dom(r)&&e!=="transform"&&dE(r,e))return"css";if(r[e]!=null)return"object"}function fE(r){if(!!je.dom(r)){for(var e=r.style.transform||"",t=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=t.exec(e);)n.set(i[1],i[2]);return n}}function iV(r,e,t,n){var i=sd(e,"scale")?1:0+rV(e),s=fE(r).get(e)||i;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),n?Z0(r,s,n):s}function J0(r,e,t,n){switch(K0(r,e)){case"transform":return iV(r,e,n,t);case"css":return dE(r,e,t);case"attribute":return Ji(r,e);default:return r[e]||0}}function $0(r,e){var t=/^(\*=|\+=|-=)/.exec(r);if(!t)return r;var n=_s(r)||0,i=parseFloat(e),s=parseFloat(r.replace(t[0],""));switch(t[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function pE(r,e){if(je.col(r))return nV(r);if(/\s/g.test(r))return r;var t=_s(r),n=t?r.substr(0,r.length-t.length):r;return e?n+e:n}function ex(r,e){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function sV(r){return Math.PI*2*Ji(r,"r")}function oV(r){return Ji(r,"width")*2+Ji(r,"height")*2}function aV(r){return ex({x:Ji(r,"x1"),y:Ji(r,"y1")},{x:Ji(r,"x2"),y:Ji(r,"y2")})}function mE(r){for(var e=r.points,t=0,n,i=0;i<e.numberOfItems;i++){var s=e.getItem(i);i>0&&(t+=ex(n,s)),n=s}return t}function lV(r){var e=r.points;return mE(r)+ex(e.getItem(e.numberOfItems-1),e.getItem(0))}function gE(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return sV(r);case"rect":return oV(r);case"line":return aV(r);case"polyline":return mE(r);case"polygon":return lV(r)}}function cV(r){var e=gE(r);return r.setAttribute("stroke-dasharray",e),e}function uV(r){for(var e=r.parentNode;je.svg(e)&&je.svg(e.parentNode);)e=e.parentNode;return e}function yE(r,e){var t=e||{},n=t.el||uV(r),i=n.getBoundingClientRect(),s=Ji(n,"viewBox"),o=i.width,a=i.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function hV(r,e){var t=je.str(r)?hE(r)[0]:r,n=e||100;return function(i){return{property:i,el:t,svg:yE(t),totalLength:gE(t)*(n/100)}}}function dV(r,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return r.el.getPointAtLength(l)}var n=yE(r.el,r.svg),i=t(),s=t(-1),o=t(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function rE(r,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=pE(je.pth(r)?r.totalLength:r,e)+"";return{original:n,numbers:n.match(t)?n.match(t).map(Number):[0],strings:je.str(r)||e?n.split(t):[]}}function vE(r){var e=r?Lm(je.arr(r)?r.map(nE):nE(r)):[];return Im(e,function(t,n,i){return i.indexOf(t)===n})}function xE(r){var e=vE(r);return e.map(function(t,n){return{target:t,id:n,total:e.length,transforms:{list:fE(t)}}})}function fV(r,e){var t=Q0(e);if(/^spring/.test(t.easing)&&(t.duration=cE(t.easing)),je.arr(r)){var n=r.length,i=n===2&&!je.obj(r[0]);i?r={value:r}:je.fnc(e.duration)||(t.duration=e.duration/n)}var s=je.arr(r)?r:[r];return s.map(function(o,a){var l=je.obj(o)&&!je.pth(o)?o:{value:o};return je.und(l.delay)&&(l.delay=a?0:e.delay),je.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return Om(o,t)})}function pV(r){for(var e=Im(Lm(r.map(function(s){return Object.keys(s)})),function(s){return je.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},n=function(s){var o=e[s];t[o]=r.map(function(a){var l={};for(var u in a)je.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},i=0;i<e.length;i++)n(i);return t}function mV(r,e){var t=[],n=e.keyframes;n&&(e=Om(pV(n),e));for(var i in e)je.key(i)&&t.push({name:i,tweens:fV(e[i],r)});return t}function gV(r,e){var t={};for(var n in r){var i=j0(r[n],e);je.arr(i)&&(i=i.map(function(s){return j0(s,e)}),i.length===1&&(i=i[0])),t[n]=i}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function yV(r,e){var t;return r.tweens.map(function(n){var i=gV(n,e),s=i.value,o=je.arr(s)?s[1]:s,a=_s(o),l=J0(e.target,r.name,a,e),u=t?t.to.original:l,c=je.arr(s)?s[0]:u,h=_s(c)||_s(l),d=a||h;return je.und(o)&&(o=u),i.from=rE(c,d),i.to=rE($0(o,c),d),i.start=t?t.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=X0(i.easing,i.duration),i.isPath=je.pth(s),i.isColor=je.col(i.from.original),i.isColor&&(i.round=1),t=i,i})}var bE={css:function(r,e,t){return r.style[e]=t},attribute:function(r,e,t){return r.setAttribute(e,t)},object:function(r,e,t){return r[e]=t},transform:function(r,e,t,n,i){if(n.list.set(e,t),e===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function wE(r,e){var t=xE(r);t.forEach(function(n){for(var i in e){var s=j0(e[i],n),o=n.target,a=_s(s),l=J0(o,i,a,n),u=a||_s(l),c=$0(pE(s,u),l),h=K0(o,i);bE[h](o,i,c,n.transforms,!0)}})}function vV(r,e){var t=K0(r.target,e.name);if(t){var n=yV(e,r),i=n[n.length-1];return{type:t,property:e.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function xV(r,e){return Im(Lm(r.map(function(t){return e.map(function(n){return vV(t,n)})})),function(t){return!je.und(t)})}function SE(r,e){var t=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=t?Math.max.apply(Math,r.map(function(s){return n(s)+s.duration})):e.duration,i.delay=t?Math.min.apply(Math,r.map(function(s){return n(s)+s.delay})):e.delay,i.endDelay=t?i.duration-Math.max.apply(Math,r.map(function(s){return n(s)+s.duration-s.endDelay})):e.endDelay,i}var iE=0;function bV(r){var e=W0(aE,r),t=W0(q0,r),n=mV(t,r),i=xE(r.targets),s=xV(i,n),o=SE(s,t),a=iE;return iE++,Om(e,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var wr=[],sE=[],Pm,wV=function(){function r(){Pm=requestAnimationFrame(e)}function e(t){var n=wr.length;if(n){for(var i=0;i<n;){var s=wr[i];if(!s.paused)s.tick(t);else{var o=wr.indexOf(s);o>-1&&(wr.splice(o,1),n=wr.length)}i++}r()}else Pm=cancelAnimationFrame(Pm)}return r}();function SV(){document.hidden?(wr.forEach(function(r){return r.pause()}),sE=wr.slice(0),hn.running=wr=[]):sE.forEach(function(r){return r.play()})}typeof document<"u"&&document.addEventListener("visibilitychange",SV);function hn(r){r===void 0&&(r={});var e=0,t=0,n=0,i,s=0,o=null;function a(w){var b=window.Promise&&new Promise(function(S){return o=S});return w.finished=b,b}var l=bV(r),u=a(l);function c(){var w=l.direction;w!=="alternate"&&(l.direction=w!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,i.forEach(function(b){return b.reversed=l.reversed})}function h(w){return l.reversed?l.duration-w:w}function d(){e=0,t=h(l.currentTime)*(1/hn.speed)}function f(w,b){b&&b.seek(w-b.timelineOffset)}function m(w){if(l.reversePlayback)for(var S=s;S--;)f(w,i[S]);else for(var b=0;b<s;b++)f(w,i[b])}function p(w){var b=0,S=l.animations,_=S.length;for(l.reversePlayback===!0&&l.rewind===!1&&(w=l.duration+l.delay-l.endDelay-w);b<_;){var M=S[b],x=M.animatable,T=M.tweens,E=T.length-1,C=T[E];E&&(C=Im(T,function(ie){return w<ie.end})[0]||C);for(var P=Ki(w-C.start-C.delay,0,C.duration)/C.duration,O=isNaN(P)?1:C.easing(P),I=C.to.strings,N=C.round,F=[],G=C.to.numbers.length,Y=void 0,U=0;U<G;U++){var z=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var Q=C.to.numbers[U],V=C.from.numbers[U]||0;else var V=C.to.numbers[U],Q=C.from.numbers[U]||0;C.isPath?z=dV(C.value,O*V):z=Q+O*(V-Q),N&&(C.isColor&&U>2||(z=Math.round(z*N)/N)),F.push(z)}var k=I.length;if(!k)Y=F[0];else{Y=I[0];for(var j=0;j<k;j++){var q=I[j],W=I[j+1],he=F[j];isNaN(he)||(W?Y+=he+W:Y+=he+" ")}}bE[M.type](x.target,M.property,Y,x.transforms),M.currentValue=Y,b++}}function g(w){l[w]&&!l.passThrough&&l[w](l)}function v(){l.remaining&&l.remaining!==!0&&l.remaining--}function y(w){var b=l.duration,S=l.delay,_=b-l.endDelay,M=h(w);l.progress=Ki(M/b*100,0,100),l.reversePlayback=M<l.currentTime,i&&m(M),!l.began&&l.currentTime>=0&&(l.began=!0,g("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,g("loopBegin")),M<=S&&l.currentTime!==0&&(p(0),g("change")),(M>=_&&l.currentTime!==b||!b)&&(p(b),g("change")),M>S&&M<_?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,g("changeBegin")),g("change"),p(M)):l.changeBegan?(l.changeCompleted=!0,l.changeBegan=!1,g("change"),g("changeComplete")):l.began&&M>_&&(g("change"),g("changeComplete")),l.currentTime=Ki(M,0,b),l.began&&g("update"),w>=b&&(t=0,v(),l.remaining?(e=n,g("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&c()):(l.paused=!0,l.completed||(l.completed=!0,g("loopComplete"),g("complete"),!l.passThrough&&"Promise"in window&&(o(),u=a(l)))))}return l.reset=function(){var w=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=w==="reverse",l.remaining=l.loop,i=l.children,s=i.length;for(var b=s;b--;)l.children[b].reset();(l.reversed&&l.loop!==!0||w==="alternate"&&l.loop===1)&&l.remaining++,p(l.reversed?l.duration:0)},l.set=function(w,b){return wE(w,b),l},l.tick=function(w){n=w,e||(e=n),y((n+(t-e))*hn.speed)},l.seek=function(w){y(h(w))},l.pause=function(){l.paused=!0,d()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,wr.push(l),d(),Pm||wV())},l.reverse=function(){c(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function oE(r,e){for(var t=e.length;t--;)Y0(r,e[t].animatable.target)&&e.splice(t,1)}function AV(r){for(var e=vE(r),t=wr.length;t--;){var n=wr[t],i=n.animations,s=n.children;oE(e,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;oE(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function _V(r,e){e===void 0&&(e={});var t=e.direction||"normal",n=e.easing?X0(e.easing):null,i=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",u=o==="last",c=je.arr(r),h=parseFloat(c?r[0]:r),d=c?parseFloat(r[1]):0,f=_s(c?r[1]:r)||0,m=e.start||0+(c?h:0),p=[],g=0;return function(v,y,w){if(a&&(o=0),l&&(o=(w-1)/2),u&&(o=w-1),!p.length){for(var b=0;b<w;b++){if(!i)p.push(Math.abs(o-b));else{var S=l?(i[0]-1)/2:o%i[0],_=l?(i[1]-1)/2:Math.floor(o/i[0]),M=b%i[0],x=Math.floor(b/i[0]),T=S-M,E=_-x,C=Math.sqrt(T*T+E*E);s==="x"&&(C=-T),s==="y"&&(C=-E),p.push(C)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(O){return n(O/g)*g})),t==="reverse"&&(p=p.map(function(O){return s?O<0?O*-1:-O:Math.abs(g-O)}))}var P=c?(d-h)/g:h;return m+P*(Math.round(p[y]*100)/100)+f}}function TV(r){r===void 0&&(r={});var e=hn(r);return e.duration=0,e.add=function(t,n){var i=wr.indexOf(e),s=e.children;i>-1&&wr.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Om(t,W0(q0,r));l.targets=l.targets||r.targets;var u=e.duration;l.autoplay=!1,l.direction=e.direction,l.timelineOffset=je.und(n)?u:$0(n,u),o(e),l.rewind=e.rewind,e.seek(l.timelineOffset);var c=hn(l);o(c),s.push(c);var h=SE(s,r);return e.delay=h.delay,e.endDelay=h.endDelay,e.duration=h.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}hn.version="3.2.0";hn.speed=1;hn.running=wr;hn.remove=AV;hn.get=J0;hn.set=wE;hn.convertPx=Z0;hn.path=hV;hn.setDashoffset=cV;hn.stagger=_V;hn.timeline=TV;hn.easing=X0;hn.penner=uE;hn.random=function(r,e){return Math.floor(Math.random()*(e-r+1))+r};var tx=hn;var AE=new A,_E=new A,TE=new nt;function ME(r,e,t,n){if(n===0)return t.copy(r);if(n===1)return t.copy(e);let i=r.w*e.w+r.x*e.x+r.y*e.y+r.z*e.z;if(i>=1)return t.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let c=1-n;return t.w=c*r.w+n*e.w,t.x=c*r.x+n*e.x,t.y=c*r.y+n*e.y,t.z=c*r.z+n*e.z,t.normalize(),t}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return t.w=r.w*l+e.w*u,t.x=r.x*l+e.x*u,t.y=r.y*l+e.y*u,t.z=r.z*l+e.z*u,t}function Rm(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=i??e[r],a=s;if(o!==a)return{update:l=>{e[r]=Be.lerp(o,a,l)},start:()=>{e[r]=o},end:()=>{e[r]=a}}}function nx(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=e[r],a=i?new A().fromArray(i):o.clone(),l=new A().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function EE(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=e[r],a=i?new be().fromArray(i):o.clone(),l=new A,u=new nt,c=new A;a.decompose(l,u,c);let h=new be().fromArray(s),d=new A,f=new nt,m=new A;if(h.decompose(d,f,m),!a.equals(h))return{update:p=>{TE.slerpQuaternions(u,f,p),AE.lerpVectors(l,d,p),_E.lerpVectors(c,m,p),o.compose(AE,TE,_E)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(d,f,m)}}}function CE(r,e,t,n,i){let s=t[r]?t[r]:void 0,o=n[r];if(!o)return;let a=e[r],l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return e[r]=c,{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function PE(r,e,t){let n=[],i=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom,s=r.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom;if(s!==void 0){let o=i??r.zoom,a=s;o!==a&&n.push({update:l=>{r.zoom=Be.lerp(o,a,l),r.updateProjectionMatrix()},start:()=>{r.zoom=o,r.updateProjectionMatrix()},end:()=>{r.zoom=a,r.updateProjectionMatrix()}})}if(t.targetOffset!==void 0){let o=Rm("targetOffset",r,e,t);o&&n.push(o)}return n}function DE(r,e,t){let n=[];if(!("geometry"in t))return n;let i="geometry"in e?e.geometry:{},s=t.geometry,{width:o,height:a,depth:l}=i,{width:u,height:c,depth:h}=s;if(u!==void 0||c!==void 0||h!==void 0){let{width:d,height:f,depth:m}=r.geometry.userData.parameters,p=o??d,g=a??f,v=l??m,y=u??d,w=c??f,b=h??m;(p!==y||g!==w||v!==b)&&!Vt(r)&&n.push({update:S=>{r.updateGeometry({parameters:{width:Be.lerp(p,y,S),height:Be.lerp(g,w,S),depth:Be.lerp(v,b,S)}}),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometry({parameters:{width:p,height:g,depth:v}}),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometry({parameters:{width:y,height:w,depth:b}}),r.invalidateDownstreamBooleanData()}})}return n}function IE(r,e,t,n){let i=[];if(t.intensity!==void 0){let s=Rm("intensity",r,e,t);s&&i.push(s)}if(t.color!==void 0){let s=CE("color",r,e,t,n);s&&i.push(s)}return i}function LE(r,e,t,n){let i=[];if(!("material"in t||"materials"in t))return i;let s;if("materials"in e?s=e.materials?.[0]:"material"in e?s=e.material:s={},!s||typeof s=="string")return i;let o;if("materials"in t?o=t.materials?.[0]:"material"in t&&(o=t.material),!o||typeof o=="string")return i;let a=Array.isArray(r.material)?r.material[0]:r.material;return MV(a,s,o,n)}function MV(r,e,t,n){let i=[];for(let s of r.layers){let o=e.layers?.data(s.uuid),a=t.layers.data(s.uuid);if(!a||!(s.visible??!0)||!(a.visible??!0))continue;let l=s.getNames().filter(u=>!mp.some(c=>u.includes(c)));for(let u of l)try{let c=s.getValue(u),h;if(u==="colors")h=OV(s,o,a,u);else if(Array.isArray(c))u==="steps"&&(h=LV(s,o,a,u));else if(typeof c=="number")h=EV(s,o,a,u);else{if(typeof c=="boolean")continue;c instanceof B?h=CV(s,o,a,u):c instanceof A?h=PV(s,o,a,u):c instanceof $t?h=IV(s,o,a,u,n):c instanceof Le?h=DV(s,o,a,u,n):"isTexture"in c&&(h=RV(s,o,a,u))}h&&(Array.isArray(h)?i.push(...h):i.push(h))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return i}function EV(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=e?e[n]:r.getValue(n),s=t[n];if(i!==s)return{update:o=>{r.setValue(n,Be.lerp(i,s,o))},start:()=>{r.setValue(n,i)},end:()=>{r.setValue(n,s)}}}function CV(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=r.getValue(n),s=e?new B().fromArray(e[n]):i.clone(),o=new B().fromArray(t[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function PV(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=r.getValue(n),s=e?new A().fromArray(e[n]):i.clone(),o=new A().fromArray(t[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function DV(r,e,t,n,i){if(!r.hasValue(n)||!(n in t))return;let s=e?e[n]:void 0,o=t[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function IV(r,e,t,n,i){if(!r.hasValue(n)||!(n in t))return;let s=e?e[n]:void 0,o=t[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new $t(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function LV(r,e,t,n="steps"){if(!r.hasValue(n)||!(n in t))return;let i=[],s=r.getValue(n),o=e?e[n]:s,a=t[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&i.push({update:h=>{s[l]=Be.lerp(u,c,h)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return i.length?i:void 0}function OV(r,e,t,n="colors"){if(!r.hasValue(n)||!(n in t))return;let i=[],s=r.getValue(n),o=e?e[n]:s.map(l=>l.toArray()),a=t[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];th.isEqual(u,c)||i.push({update:h=>{s[l].fromArray(th.lerp(u,c,h))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return i.length?i:void 0}function RV(r,e,t,n="texture"){if(!r.hasValue(n)||!(n in t))return;let i=r.getNode("mat");if(!i)return;let s=e?e[n]:i,o=t[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!ra.isEqual(a,u)||!ra.isEqual(l,c))return{update:h=>{i.repeat=ra.lerp(a,u,h),i.offset=ra.lerp(l,c,h),i.updateMatrix()},start:()=>{i.repeat=[...a],i.offset=[...l],i.updateMatrix()},end:()=>{i.repeat=[...u],i.offset=[...c],i.updateMatrix()}}}var rx=new A,OE=new Qt;function RE(r,e,t,n){let i=[],s=nx("position",r,e,t);s&&i.push(s);let o=nx("scale",r,e,t);o&&i.push(o);let a=NV(r,e,t,n);a&&i.push(a);let l=EE("hiddenMatrix",r,e,t);if(l&&i.push(l),s||o||a||l){let u=()=>{r.updateMatrix(),r.parent?.matrixWorldFusedFalse&&(r.matrixWorld.multiplyMatrices(r.parent.matrixWorldFusedFalse,r.matrix),r.matrixWorldNeedsUpdate=!1),kt(r)&&Vt(r.parent)&&r.invalidateDownstreamBooleanData(!0)};i.push({update:u,start:u,end:u})}return i}function NV(r,e,t,n){let i=e?.rotation?e.rotation:void 0,s=t.rotation;if(!s)return;let o=i?new A().fromArray(i):new A().setFromEuler(r.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=rx.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new nt().setFromEuler(OE.setFromVector3(o)),c=new nt().setFromEuler(OE.setFromVector3(a));return{update:h=>{ME(u,c,r.quaternion,h)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}else return{update:u=>{rx.lerpVectors(o,a,u),r.rotation.setFromVector3(rx)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}function Nm(r,e,t,n,i){let s=[];return(r.visible||Vt(r.parent))&&s.push(...RE(r,e,t,i)),kt(r)?((r.visible||Vt(r.parent))&&s.push(...DE(r,e,t)),r.visible&&s.push(...LE(r,e,t,n))):UT(r)?r.visible&&s.push(...IE(r,e,t,n)):FT(r)&&s.push(...PE(r,e,t)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var ix=new A,FV=new nt;function NE(r,e,t){let n=[];r.objects.traverse((i,s)=>{let o=e.find(i);if(!!o&&(o.states={},!!s.states)){n.some(l=>r.objects.isDescendantOf(i,l))||s.physics?.fusedBody===!0&&s.physics.rigidBody==="dynamic"&&n.push(i),o.data=s,o.currentState=null,o.currentTransitionAction=null;for(let l of s.states){if(r.environment.usePhysics===!0&&s.physics&&(s.physics.rigidBody==="dynamic"||n.some(u=>r.objects.isDescendantOf(i,u)))&&(l.data.position!==void 0||l.data.rotation!==void 0||l.data.hiddenMatrix!==void 0))return;o.states[l.id]=rh.patch(s,l.data)}if(o.matrixWorld0!==void 0||o.hiddenMatrix0){if(o.hiddenMatrix0?(o.hiddenMatrix.copy(o.hiddenMatrix0),o.hiddenMatrix.premultiply(o.parent.matrixWorld0)):(o.matrixWorld.identity(),o.rigidBody?.setTranslation(ix,!0),o.rigidBody?.setRotation(FV,!0),o.rigidBody?.setLinvel(ix,!0),o.rigidBody?.setAngvel(ix,!0)),o instanceof wt&&s.type==="Mesh"){if("material"in s){if(o.material instanceof Array)return;Bm(o.material,s.material,t)}else if("materials"in s){if(!(o.material instanceof Array))return;var a=0;for(let l of s.materials)Bm(o.material[a],l,t),a++}}return}sx(o,s,null,t,s.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0)}})}function Bm(r,e,t){typeof e!="string"&&r.reset(e,t)}function sx(r,e,t,n,i=!1){if(!i&&e.states.length===0)return;let s=t===null?e:rh.patch(e,e.states.data(t));if(d0(r,s),r instanceof wt&&s.type==="Mesh"){if(r instanceof xo?r.buildFromStore(s.geometry):r.updateGeometry({parameters:s.geometry},n),r.freeBooleanPointer(),Vt(r.parent)&&r.parent.invalidateDownstreamBooleanData().recomputeBoolean(),"material"in s){if(r.material instanceof Array)return;Bm(r.material,s.material,n)}else if("materials"in s){if(!(r.material instanceof Array))return;var o=0;for(let a of s.materials)Bm(r.material[o],a,n),o++}}else if(s.type==="DirectionalLight")r.fromDirectionalLightState(s,n);else if(s.type==="PointLight")r.fromPointLightState(s,n);else if(s.type==="SpotLight")r.fromSpotLightState(s,n);else if(r instanceof zn&&Ri.is(s.type)){let a=s;r.setZoom("PerspectiveCamera",a.perspective.zoom),r.setZoom("OrthographicCamera",a.orthographic.zoom),r.isUpVectorFlipped=a.isUpVectorFlipped,r.targetOffset=a.targetOffset,r.fov=a.perspective.fov}}function UV(r){let e={duration:r.duration,easing:"linear"};switch(r.easing){case 0:e.easing="cubicBezier( 0, 0, 1, 1 )";break;case 1:e.easing="cubicBezier( .25, .1, .25, 1 )";break;case 2:e.easing="cubicBezier( .42, 0, 1, 1 )";break;case 3:e.easing="cubicBezier( 0, 0, .58, 1 )";break;case 4:e.easing="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:t,control2:n}=r;e.easing=`cubicBezier(
4907
+ `,lm=new mt({vertexShader:Sk,fragmentShader:Ak,uniforms:{depthContrast:{value:1}}});function _k(r){if(r.geometry.attributes.extrudeNormal||!r.geometry.attributes.position||!r.geometry.attributes.normal)return;let e=new Map,t=r.geometry.attributes.position.array,n=r.geometry.attributes.normal.array,i=new Float32Array(t.length);for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=new A(n[s],n[s+1],n[s+2]);e.has(o)?e.get(o)?.normals.push(a):e.set(o,{normals:[a],result:new A})}e.forEach((s,o)=>{for(let a of s.normals)s.result.add(a);s.result.divideScalar(s.normals.length)});for(let s=0;s<t.length;s+=3){let o=`${t[s]}_${t[s+1]}_${t[s+2]}`,a=e.get(o)?.result;a&&(i[s]=a.x,i[s+1]=a.y,i[s+2]=a.z)}r.geometry.setAttribute("extrudeNormal",new Ae(i,3))}function Tk(r){if(r.geometry.attributes.extrudeNormals||!r.geometry.attributes.position)return;let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=new A;for(let i=0;i<e.length;i+=3)n.set(e[i],e[i+1],e[i+2]).normalize(),t[i]=n.x,t[i+1]=n.y,t[i+2]=n.z;r.geometry.setAttribute("extrudeNormal",new Ae(t,3))}function Xi(r){if(Array.isArray(r.material)){for(let e of r.material)if(e.getLayersOfType("outline").length===0)return}else if(!(r.material instanceof Or)||r.material.getLayersOfType("outline").length===0)return;r.objectType==="Mesh2D"||r.objectType==="TextFrame"&&r.data?.geometry?.depth===0?Tk(r):_k(r)}function Yi(r){if(!r.geometry.attributes.position)return;let e=r.geometry.attributes.position.array,t=new Float32Array(e.length),n=parseInt(r.uuid.replace(/\D/g,"")),i=[Be.seededRandom(n),Be.seededRandom(n+1e4),Be.seededRandom(n+2e4)];for(let s=0;s<e.length;s++)t[s]=i[s%3];r.geometry.setAttribute("randomColor",new Ge(t,3))}var wt=class extends Jr(rn){constructor(t,n){super(t,n);this.isAbstractMesh=!0;this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new be;this.booleanExclude=null;Array.isArray(n)&&t.groups.length===0&&t.addGroup(0,Math.max(t.getIndex()?.count??0,t.getAttribute("position").count),0)}get isGroup(){return this._cloner?.parameters.hideBase===!0}get isMesh(){return!this.isGroup}set isMesh(t){}get cloner(){return this._cloner}set cloner(t){this._cloner&&this.remove(this._cloner),t&&this.add(t),this._cloner=t}updateGeometry(t,n){let i=this.geometry,s=u0[i.userData.type],o=this.objectType==="NonParametric"?Object.assign({},i.userData,{geometry:i}):i.userData,a=s.build(s.normalizeInputs(t,o)),l=i.uuid;this.geometry.dispose(),this.geometry=a,this.geometry.uuid=l,this.geometry.computeBoundingSphere(),Xi(this),i.getAttribute("randomColor")&&Yi(this)}clone(t){let n=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=_h(n),s=this.material;return new this.constructor(i,s).copy(this,t)}copy(t,n=!0){return super.copy(t,n),t.cloner&&(this.cloner=new fh(t,t.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(t){t===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new fh(this)),this.cloner.fromClonerState(t))}fromState(t,n){return super.fromState(t),t.type==="Mesh"&&(this.setFromClonerState(t.cloner),this.castShadow=t.castShadow??!0,this.receiveShadow=t.receiveShadow??!0,this.booleanExclude=t.booleanExclude??null),this}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(pi.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(t=!1){return t?this.booleanWasTransformed=!0:this.freeBooleanPointer(),Vt(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let t of this.children)kt(t)&&(t.freeBooleanPointer(),Vt(t)&&t.invalidateUpstreamBooleanData())}};var Mk=new A(0,0,1),eM=new A,tM=new A,nM=new jt,Bc=class extends wt{constructor(t=Un.create({}),n){super(t,n);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new Lt;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=t.userData.shape,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}fromState(t){return super.fromState(t),this.shape.update(),this}setHelperVisibility(){}updateGeometry(t,n){if(super.updateGeometry(t,n),"userData"in this.geometry){let i=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:i})}}setShape(t){this.shape&&this.shape.eventDispatcher?.removeEventListener("update",this._onShapeUpdate),this.shape=t,this.shape.eventDispatcher?.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),nM.getNormalMatrix(this.matrixWorld),eM.copy(Mk).applyMatrix3(nM).normalize(),tM.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(eM,tM)}clone(t){let n=this.shape.clone(),i=this.material,s=this.geometry.userData,o=Un.create(Object.assign({},s,{shape:n})),a=new Bc(o,i).copy(this,t);return a.shape=n,n.update(),a}raycast(t,n){wt.prototype.raycast.call(this,t,n)}};var Qi=(r,e)=>class extends r{constructor(){super(...arguments);this.objectHelper=new e(this)}get geometryHelper(){return e.geometryHelper}raycast(i,s){this.objectHelper.raycast(i,s)}fromLightState(i,s){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let o=this;i.color!==void 0&&(o.color=In(i.color,s)),i.intensity!==void 0&&(o.intensity=i.intensity),i.depth!==void 0&&(o.shadow.camera.far=i.depth,o.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows)}return this}};var Fc=new A,I0=new A,zn=class extends Qi(Jr(ai),kp){constructor(t=window.innerWidth,n=window.innerHeight,i=45,s,o=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=ia.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=t,this.height=n,this.orthoCamera=new Za(t*-.5,t*.5,n*.5,n*-.5,s??-5e4,o),this.perspCamera=new nn(i,t/n,s??50,o),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.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic()}static createFromState(t,n){let i=new zn().fromState(n);return i.objectHelper.update(),i.uuid=t,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(t,n){t==="PerspectiveCamera"?this.perspCamera.near=n:this.orthoCamera.near=n}setZoom(t,n){n>=0&&(t==="PerspectiveCamera"?this.perspCamera.zoom=n:this.orthoCamera.zoom=n)}set cameraType(t){t==="PerspectiveCamera"?this.toPerspective():t==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(t){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(t){t>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}lookAt(t){super.lookAt(t),this.getWorldPosition(Fc),this.targetOffset=Fc.distanceTo(t)}getTarget(t=new A){return this.getWorldDirection(I0),this.getWorldPosition(Fc),I0.multiplyScalar(this.targetOffset),t.copy(Fc).add(I0),t}getDistanceToTarget(){let t=this.getTarget();return this.getWorldPosition(Fc),Fc.distanceTo(t)}updateUp(){let t=this.getWorldQuaternion(new nt),n=new A(0,0,1).applyQuaternion(t),i=new A().copy(ht.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(t);let s=new A().copy(ht.DefaultUp).projectOnPlane(n),o=new A().crossVectors(s,i).dot(n)>=0?1:-1;this.angleOffsetFromUp=s.angleTo(i)*o}getViewFrontToObject(t){let n=t.getWorldPosition(new A),s=t.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().add(s),target:n}}getViewToObject(t){let n=t.getWorldPosition(new A),s=this.getWorldDirection(new A).multiplyScalar(this.targetOffset);return{position:n.clone().sub(s),target:n}}setViewplaneSize(t,n){this.left=-t*.5,this.right=t*.5,this.top=n*.5,this.bottom=-n*.5,this.aspect=t/n,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(t){this.perspCamera.setFocalLength(t),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(t,n,i,s,o,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(t,n,i,s,o,a):this.orthoCamera.setViewOffset(t,n,i,s,o,a)}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(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,n){super.updateWorldMatrix(t,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(t,n){return super.copy(t,n),this.orthoCamera.copy(t.orthoCamera),this.perspCamera.copy(t.perspCamera),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.far=t.far,this.view=t.view===null?null:Object.assign({},t.view),this._cameraType=t._cameraType,this.aspect=t.aspect,this.fov=t.fov,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this.targetOffset=t.targetOffset,this.updateProjectionMatrix(),this}toCameraState(t=[]){let n={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return kl(n,t)}fromCameraState(t){let{orthographic:n,perspective:i}=t;return t.type!==void 0&&(this.cameraType=t.type),t.far!==void 0&&(this.far=t.far),n!==void 0&&(n.near!==void 0&&(this.orthoCamera.near=n.near),n.zoom!==void 0&&(this.orthoCamera.zoom=n.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.zoom)),t.type==="PerspectiveCamera"?(this.zoom=this.perspCamera.zoom,this.fov=this.perspCamera.fov,this.near=this.perspCamera.near):(this.near=this.orthoCamera.near,this.zoom=this.orthoCamera.zoom),t.up!==void 0&&this.up.fromArray(t.up),t.targetOffset!==void 0&&(this.targetOffset=t.targetOffset),t.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=t.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(t){return{...super.toState(t),...this.toCameraState(t),type:this.cameraType}}fromState(t){return super.fromState(t),this.fromCameraState(t),this}};var rM=new be;function L0(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.geometry?.type==="BooleanGeometry"&&(e=!0)}),e}var cm=class extends wt{constructor(t=new De,n){super(t,n);this.booleanOp=2;this.phongAngle=35;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.objectType="BooleanObject",this.castShadow=!0,this.receiveShadow=!0,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}reInit(){this.objectType="BooleanObject",this.meshSetAddresses=[],this.needsTransformForDownstream=!1,this.geometry.userData.parameters={width:0,height:0,depth:0},this.onAfterRender=this.recomputeBoolean.bind(this)}recomputeBoolean(t,n=!0){if(this.booleanMeshSetAddress!==-1)return;for(let s=0;s<this.children.length;s++){let o=this.children[s];Vt(o)&&o.recomputeBoolean(t===!0,n)}this.meshSetAddresses=[];for(let s=0;s<this.children.length;s++){let o=this.children[s];if(HT(o)&&o.booleanExclude===!1&&o.geometry.attributes.position?.count>0&&o.geometry.drawRange.count>0){if(o.booleanMeshSetAddress===-1){if((o.geometry.index??o.geometry.getAttribute("position")).count/3<15e5&&(o.booleanMeshSetAddress=pi.getMeshSet(o.geometry,t===!0,n)),o.booleanMeshSetAddress===-1)return;pi.transformMeshSet(o.booleanMeshSetAddress,o.matrix),o.booleanMatrixInvOld.copy(o.matrix).invert(),o.booleanWasTransformed=!1}else Vt(o)&&o.needsTransformForDownstream===!0?(pi.transformMeshSet(o.booleanMeshSetAddress,o.matrix),o.needsTransformForDownstream=!1):o.booleanWasTransformed===!0&&(rM.multiplyMatrices(o.matrix,o.booleanMatrixInvOld),pi.transformMeshSet(o.booleanMeshSetAddress,rM),o.booleanMatrixInvOld.copy(o.matrix).invert(),o.booleanWasTransformed=!1);this.meshSetAddresses.push(o.booleanMeshSetAddress)}}if(this.meshSetAddresses.length===0){this.geometry.setDrawRange(0,0);return}if(t===!0)return pi.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let i=this.geometry;i.dispose(),this.geometry=new De,this.geometry.userData=i.userData,this.geometry.boundingSphere=i.boundingSphere;try{this.booleanMeshSetAddress=pi.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(s){this.booleanMeshSetAddress=0,console.error(s)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Xi(this),Yi(this)}updateGeometry(t,n){let i=t.parameters;i.operation!==void 0&&(this.booleanOp=i.operation),i.phongAngle!==void 0&&(this.phongAngle=i.phongAngle),this.invalidateDownstreamBooleanData().recomputeBoolean()}};var ya=class extends Qi(Jr(Rs),fc){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(t,n){let i=new ya().fromState(n);return i.uuid=t,i.objectHelper.update(),i}};var Uc=class extends Qi(Jr(sf),dc){constructor(...t){super(...t);this.objectType="LightDirectional";this._gizmos={};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 Vr(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new Uc().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}fromDirectionalLightState(t,n){let i=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;return super.fromLightState(t,n),t.size!==void 0&&zT(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),i&&this.update(),this}fromState(t,n){return super.fromState(t),this.fromDirectionalLightState(t,n),this}};var Gc=class extends Qi(Jr(rf),pc){constructor(...t){super(...t);this.objectType="LightPoint";this._gizmos={};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 A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new Mt(s,o),l=new Yo(a,new Le(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(t,n,i){let s=new Gc().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Yo&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Yo&&(n.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let t in this._gizmos){let n=this._gizmos[t];if(n instanceof Yo){let i=this.shadow.camera,s=new A(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),o=new A(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);n.box.set(s,o),n.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}fromPointLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromPointLightState(t,n),this}};var iM=new A,sM=new A,oM=new nt,zc=class extends Qi(Jr(nf),ph){constructor(...t){super(...t);this.objectType="LightSpot";this._gizmos={};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=Be.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let s=new Vr(this.shadow.camera);s.visible=!1,this._gizmos.shadowmap=s,this.update()}static createFromState(t,n,i){let s=new zc().fromState(n,i);return s.uuid=t,s}get gizmos(){return this._gizmos}showGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!0)}}hideGizmos(){for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&(n.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this._gizmos){let n=this._gizmos[t];n instanceof Vr&&n.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),sM.setFromMatrixPosition(this.matrixWorld),oM.setFromRotationMatrix(this.matrixWorld),iM.copy(this.up).applyQuaternion(oM).negate().multiplyScalar(this.distance),this.target.position.copy(sM).add(iM),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}fromSpotLightState(t,n){return super.fromLightState(t,n),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(t,n){return super.fromState(t),this.fromSpotLightState(t,n),this}};var aM=r=>r.tagName==="VIDEO",kc=class{static resize(e,t,n){let i=e/t,s;if(!n.image)return;let o=n.image;aM(o)?s=o.videoWidth/o.videoHeight:s=o.width/o.height,i>s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*s/i):n.repeat.set(1,1*s/i)),i<s&&(n.imageType=="WEBCAM"?n.repeat.set(1*i/s*-1,1):n.repeat.set(1*i/s,1)),i==s&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1))}static resizeTextureLayer(e,t,n){let i=e/t,s=n.image!==void 0?n.image.width/n.image.height:1,o;i>s?o={x:1,y:s/i}:i<s?o={x:i/s,y:1}:o={x:1,y:1},n.repeat.set(o.x,o.y),n.updateMatrix()}static resizeTextureLayers(e,t,n){let i=n.layers;for(let s=0;s<i.length;s++){let o=i[s];KT(o)&&kc.resizeTextureLayer(e,t,o.uniforms[`f${o.id}_texture`].value)}}static resizeComplex(e,t,n,i){let s=e/t,o,a=n.image;aM(a)?o=a.videoWidth/a.videoHeight:o=a.width/a.height,i.geometry.type.includes("Shape")?(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t*o/s):n.repeat.set(1/e,1/t*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*s/o*-1,1/t):n.repeat.set(1/e*s/o,1/t)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(1/e*-1,1/t):n.repeat.set(1/e,1/t))):(s>o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1*o/s):n.repeat.set(1,1*o/s)),s<o&&(n.imageType=="WEBCAM"?n.repeat.set(1*s/o*-1,1):n.repeat.set(1*s/o,1)),s==o&&(n.imageType=="WEBCAM"?n.repeat.set(-1,1):n.repeat.set(1,1)))}};var um=class extends wt{constructor(t,n){super(t,n);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(t,n){super.updateGeometry(t,n),this.material.layers&&kc.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}};var Vc=class extends wt{constructor(t,n){super(t,n);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}};var hm=class extends Vc{constructor(t,n){super(t,n);this.objectType="NonParametric"}};var cM,Zh=new Promise(r=>{cM=r}),lM=!1;async function uM(){if(lM)return;let r=await import("./opentype.js");cM(r),lM=!0}var Kh=class{async load(e,t,n=()=>{}){let{load:i}=await Zh;i(e,(s,o)=>{s||!o?n(s??"Something went wrong"):t(o)})}async parse(e){let{parse:t}=await Zh;try{return t(e)}catch(n){console.error(n)}}};async function Ek(r){return await(await fetch(r)).arrayBuffer()}var Ck=new Kh;async function O0(r){let e,t,n=!1;if(r.url?(e=await Ek(r.url),t=r.url,n=r.url.startsWith("/")):r.data&&(e=r.data.buffer),e){let i=await Ck.parse(e);if(i)return{font:i,url:t,intercepted:n,arr:e}}}var hM=new A,dM=new be,fM=new oi;function pM(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(e=!0)}),e}var dm=class extends wt{constructor(t,n,i){super(new _c(n.geometry,i),i.material(n.material));this.data=n;this.objectType="TextFrame";this.wrappedText=[""];this.charWidths=[];this.charCoords=[];this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.name=n.name,this.uuid=t,this.updateState(n,i)}async updateGeometry(t,n){let i=t.parameters,s={...this.geometry.userData.parameters,...i};this.geometry.userData={parameters:s,type:"TextGeometry"},n&&(i.font||!this.geometry.font&&n.getFont(s.font))&&await this.geometry.updateFont(i.font??s.font,n),await this.geometry.update(s),Xi(this),Yi(this);let{wrappedText:o,charCoords:a,charWidths:l}=this.geometry;this.wrappedText=o,this.charWidths=l,this.charCoords=a,this.resetBBoxNeedsUpdate()}updateState(t,n){this.data=t,this.material=n.material(t.material),this.fromState(t,n),this.updateGeometry({parameters:t.geometry},n)}get font(){return this.geometry.font}get initialOffsetY(){return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,this.geometry.userData.parameters.height,this.fontScale,this.geometry.userData.parameters.verticalAlign)??0}get fontScale(){return this.font?this.geometry.userData.parameters.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(){return this.geometry.userData.parameters.fontSize*this.geometry.userData.parameters.lineHeight}raycast(t,n){let{matrixWorld:i}=this;if(dM.copy(i).invert(),fM.copy(t.ray).applyMatrix4(dM),fM.intersectBox(this.singleBBox,hM)){let s=hM.applyMatrix4(i),o=t.ray.origin.distanceTo(s);n.push({distance:o,point:s.clone(),object:this})}}};var vM=Hx(gM());var R0;Kp.then(r=>{R0=r});var xM=new be,Pk=new be,Dk=new be,xi=new Mt,vo=new A,Ik=new be,Lk=new be;function bM(r){let e=!1;return r.scene.objects.traverse((t,n)=>{n.type==="Mesh"&&n.geometry.type==="SubdivGeometry"&&(e=!0)}),e}var xo=class extends wt{constructor(t,n,i,s){super(i??n,s);this.subdivPointer=t;this.originalGeometry=n;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new be;this.smoothShading=!0;this.phongAngle=35;this.matrixWorldRigid=new be;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(t,n,i){let{subdivPointer:s,originalGeometry:o,subdividedGeometry:a}=Zr.build(n.geometry,void 0,void 0,!n.flatShading),l=i.material(n.material),u=new xo(s,o,a||void 0,l);return n.geometry.phongAngle!==void 0&&(u.phongAngle=n.geometry.phongAngle),u.calcBoundingBox(),u.freeSubdivPointer(),u.uuid=t,u.fromState(n),u}buildFromStore(t,n){let{originalGeometry:i,subdividedGeometry:s,subdivPointer:o}=Zr.build(t,n,this.subdivPointer,this.smoothShading,this.shearScale);t.phongAngle!==void 0&&(this.phongAngle=t.phongAngle),this.subdivPointer=o,i!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=i),s!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=s??void 0),this.geometry=this.subdividedGeometry??this.originalGeometry,Xi(this),Yi(this),t.width&&(this.geometry.userData.parameters={width:t.width,height:t.height,depth:t.depth})}updateMesh(t=!1){Zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,t?this.shearScaleInv:void 0),this.subdividedGeometry&&Zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,t?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=Zr.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Zr.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.geometry=this.subdividedGeometry??this.originalGeometry}raycast(t,n){this.geometry=this.originalGeometry,wt.prototype.raycast.call(this,t,n),this.geometry=this.subdividedGeometry??this.originalGeometry}updateMatrixWorldSVD(){let t=this.matrixWorld.elements,n=[[t[0],t[4],t[8]],[t[1],t[5],t[9]],[t[2],t[6],t[10]]],{u:i,v:s,q:o}=(0,vM.SVD)(n),a=xM.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),l=Pk.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),u=Dk.copy(l).transpose();this.shearScale=Ik.makeScale(o[0],o[1],o[2]).multiply(u).premultiply(l),this.shearScaleInv=Lk.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,u),o.every(c=>Math.abs(o[0]-c)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let t=this.originalGeometry;t.boundingSphere===null&&(t.boundingSphere=new En);let n=t.attributes.position,i=t.boundingSphere.center;xi.setFromBufferAttribute(n),xi.getCenter(i),t.boundingSphere.radius=i.distanceTo(xi.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),xi.getSize(vo);let s={width:vo.x,height:vo.y,depth:vo.z};return this.geometry.userData.parameters=s,s}updateBoundingBox(t){let n=this.originalGeometry;xi.min.set(t[0],t[2],t[4]),xi.max.set(t[1],t[3],t[5]),this.shearScaleInv&&(xi.min.applyMatrix4(this.shearScaleInv),xi.max.applyMatrix4(this.shearScaleInv)),n.boundingSphere===null&&(n.boundingSphere=new En);let i=n.boundingSphere.center;xi.getCenter(i),n.boundingSphere.radius=i.distanceTo(xi.max),isNaN(n.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),xi.getSize(vo);let s={width:vo.x,height:vo.y,depth:vo.z};return this.geometry.userData.parameters=s,s}freeSubdivPointer(){this.subdivPointer&&(R0.free_bvh(this.subdivPointer),R0.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(t,n){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:t.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:t.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:t.parameters.depth/this.geometry.userData.parameters.depth,yM(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(yM(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters={...t.parameters}}};function yM(r,e,t,n){let i=r.position.array,s=r.normal.array,o=xM.makeScale(e,t,n).invert().elements,a,l,u;for(var c=0,h=i.length;c<h;c+=3)i[c]*=e,i[c+1]*=t,i[c+2]*=n,a=s[c],l=s[c+1],u=s[c+2],s[c]=o[0]*a+o[4]*l+o[8]*u,s[c+1]=o[1]*a+o[5]*l+o[9]*u,s[c+2]=o[2]*a+o[6]*l+o[10]*u}function wM(r,e){e.flatShading!==void 0&&(r.flatShading=e.flatShading,r.needsUpdate=!0),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.side!==void 0&&(e.side===0?r.side=Gr:e.side===1?r.side=un:r.side=tr)}function Ok(r,e){if(Array.isArray(r.material))for(let t of r.material)wM(t,e);else{let t=r.material;wM(t,e)}r.objectType==="SubdivObject"&&e.flatShading!==void 0&&(r.material.flatShading=!1,r.smoothShading=!e.flatShading,r.updateMesh())}function SM(r,e,t){let n;if(e.geometry.type==="SubdivGeometry")n=xo.createFromState(r,e,t);else{let i=e.geometry.type==="BooleanGeometry"?new De:Jp(e.geometry,t),s="materials"in e?e.materials.map(o=>t.material(o)):t.material(e.material);gp.is2DParametricMesh(i.userData.type)?n=new um(i,s):i?.userData.type==="VectorGeometry"?n=new Bc(i,s):e.geometry.type==="NonParametricGeometry"?n=new hm(i,s):e.geometry.type==="BooleanGeometry"?(n=new cm(void 0,s),n.booleanOp=e.geometry.operation,e.geometry.phongAngle!==void 0&&(n.phongAngle=e.geometry.phongAngle)):n=new Vc(i,s),n.uuid=r,n.fromState(e,t)}return Ok(n,e),n}function AM(r,e,t){return e.type==="Mesh"?e.geometry.type==="TextGeometry"?new dm(r,e,t):SM(r,e,t):e.type==="Empty"?ya.createFromState(r,e):e.type==="PointLight"?Gc.createFromState(r,e,t):e.type==="SpotLight"?zc.createFromState(r,e,t):e.type==="DirectionalLight"?Uc.createFromState(r,e,t):Ri.is(e.type)?zn.createFromState(r,e):(console.error(e),new ya)}var va=class extends Or{};function _M(r,e){let t=!1,n=e.getLayersOfType("transmission"),i=e.getLayersOfType("outline");return i.length>0&&(r.layers.set(8),n.length>0&&r.layers.enable(3),t=!0,Yi(r),Xi(r)),n.length===0&&i.length===0&&r.layers.set(0),t}function TM(r,e){if(!e.layers)return!1;let t=!1,n=e.getLayersOfType("transmission"),i=e.getLayersOfType("outline");return n.length>0&&(r.layers.set(3),i.length>0&&r.layers.enable(8),t=!0),n.length===0&&i.length===0&&r.layers.set(0),t}function MM(r){let e=!1;return r.traverseEntity(t=>{if(t instanceof rn)if(Array.isArray(t.material))for(let n=0;n<t.material.length;n++)_M(t,t.material[n])&&(e=!0);else _M(t,t.material)&&(e=!0)}),e}function EM(r){let e=!1;return r.traverseEntity(t=>{if(t instanceof rn)if(Array.isArray(t.material))for(let n=0;n<t.material.length;n++)TM(t,t.material[n])&&(e=!0);else TM(t,t.material)&&(e=!0)}),e}function CM(r){"material"in r&&Rk(r.material),"geometry"in r&&r.geometry.dispose()}function Rk(r){J1(r).forEach(e=>{e instanceof va||e.dispose()})}var Nk=new hl,Bk=new be,Fk=new oi;function PM(r,e,t){let n=r.cloner;if(n)for(let i of n.children){let s=Bk.copy(i.matrixWorld).invert(),o=Fk.copy(e.ray).applyMatrix4(s),a=r.matrixWorld;o.applyMatrix4(a);let l=Nk;l.set(o.origin,o.direction),l.near=e.near,l.far=e.far,l.intersectObject(r,!1).length>0&&t.push({object:r})}}var DM=new A,N0=class extends tm(ir){constructor(t,n){super();this.objectType="Scene";this.backupFog=new Ka(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.bgColor=new $t(1,1,1,1);this.entityByUuid={};this.ambientLight=new Xo(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.postprocessing=t.postprocessing,this.init(t,n),this.matrixAutoUpdate=!1}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=EM(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=MM(this),this.needsNormalDirty=!1),this._needsNormal}find(t){if(t===""||t===void 0)return;let n=this.entityByUuid[t];return n===void 0?this.getObjectByProperty("uuid",t):n}get enableFog(){return this.fog!==null}set enableFog(t){this.fog=t===!0?this.backupFog:null}init(t,n){if(this.createChildrenObjects(t.objects,this,n),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(In(t.backgroundColor,n)),this.updateFog(t.fog,n),this.updateAmbientLight(t.environment.ambientLight,n),this.activeCamera=this.personalCamera,t.publish.playCamera!==null){let i=this.find(t.publish.playCamera);i instanceof zn&&this.switchActiveCamera(i)}this.traverse(i=>{Vt(i)&&i.recomputeBoolean()})}clearScene(){this.traverseEntity(t=>{CM(t)});for(let t of this.children)zi(t)&&t.removeFromParent()}resetAfterClear(t,n){this.init(t,n)}createPersonalCamera(){let t=zn.createFromState(N0.PERSONAL_CAMERA_ID,{...yp.defaultData,name:"Personal Camera"});return t.objectHelper.visible=!1,delete t.isEntity,this.registerObjectCreatedInLegacy(t),t}raycast(t){let n=[],i=s=>{for(let o of s.children)zi(o)&&!o.raycastLock&&o.visible&&((kt(o)||em(o)&&this.enableHelpers&&o.objectHelper.visible)&&(t.intersectObject(o,!1,n),PM(o,t,n)),i(o))};return i(this),n}traverseEntity(t){for(let n of this.children)zi(n)&&n.traverseEntity(t)}traverseVisibleEntity(t){for(let n of this.children)zi(n)&&n.visible&&n.traverseVisibleEntity(t)}updateFog(t,n){this.enableFog=t.enabled,this.fogUseBGColor=t.useBackgroundColor,t.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=In(t.color,n),this.backupFog.near=t.near,this.backupFog.far=t.far}dispose(){this.clearScene()}updateAmbientLight(t,n){GT(this.ambientLight,t,n),t.groundColor!==void 0&&(this.ambientLight.groundColor=In(t.groundColor,n)),t.enabled!==void 0&&(this.ambientLight.visible=t.enabled)}switchActiveCamera(t){this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=t,t.objectHelper.visible=!1}setBackgroundColor(t){this.bgColor=t,this.fogUseBGColor===!0&&(this.backupFog.color=t)}createChildrenObjects(t,n,i){for(let s of t)this.createChildObject(s.id,s.data,s.children,n,i)}registerObjectCreatedInLegacy(t){this.entityByUuid[t.uuid]=t}unregisterObject(t){delete this.entityByUuid[t.uuid];for(let n of t.children)this.unregisterObject(n)}createChildObject(t,n,i,s,o){let a=AM(t,n,o);return a&&(this.entityByUuid[t]=a,s.add(a),Vt(s)&&kt(a)&&(a.prevBooleanObjectParent=s),this.createChildrenObjects(i,a,o)),a}getCenter(t){let n=[];for(let s=0,o=t.length;s<o;++s){let{id:a,recursive:l}=t[s],u=this.find(a),c=l?u.recursiveBBox:u.singleBBox;n.push(...c.vertices)}let i=new Mt;return i.setFromPoints(n),i.getCenter(DM),DM}copyMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t);i?n.copy(i.matrixWorld):n.identity()}copyParentMatrixWorld(t,n){if(t===null){n.identity();return}let i=this.find(t)?.parent;i?n.copy(i.matrixWorld):n.identity()}traverseMaterial(t){this.traverseEntity(n=>{if(n instanceof wt)if(Array.isArray(n.material))for(let i=0;i<n.material.length;i++)n.material[i]instanceof Or&&t(n.material[i]);else n.material instanceof Or&&t(n.material)})}updateCanvasSize(t,n){this.activeCamera.setViewplaneSize(t,n);let i,s;t>=n?(i=n/t,s=1):(i=1,s=t/n),this.traverseMaterial(o=>{o.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=s})})}},Ss=N0;Ss.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";var $h=(r,e)=>{let t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)},IM=(r,e)=>{let t=e.x-r.x,n=e.y-r.y;return Uk(Math.atan2(n,t))},LM=(r,e,t)=>{let n={x:0,y:0};return t=pm(t),n.x=r.x-e*Math.cos(t),n.y=r.y-e*Math.sin(t),n},pm=r=>r*(Math.PI/180),Uk=r=>r*(180/Math.PI),OM=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,B0=new Map,F0=r=>{B0.has(r)&&clearTimeout(B0.get(r)),B0.set(r,setTimeout(r,100))},Hc=(r,e,t)=>{let n=e.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.addEventListener?r.addEventListener(i,t,!1):r.attachEvent&&r.attachEvent(i,t)},U0=(r,e,t)=>{let n=e.split(/[ ,]+/g),i;for(let s=0;s<n.length;s+=1)i=n[s],r.removeEventListener?r.removeEventListener(i,t):r.detachEvent&&r.detachEvent(i,t)};var mm=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),G0=()=>{if(typeof window>"u")return;let r=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:r,y:e}},gm=(r,e)=>{e.top||e.right||e.bottom||e.left?(r.style.top=e.top,r.style.right=e.right,r.style.bottom=e.bottom,r.style.left=e.left):(r.style.left=e.x+"px",r.style.top=e.y+"px")},ym=(r,e,t)=>{let n=NM(r);for(let i in n)if(n.hasOwnProperty(i))if(typeof e=="string")n[i]=e+" "+t;else{let s="";for(let o=0,a=e.length;o<a;o+=1)s+=e[o]+" "+t+", ";n[i]=s.slice(0,-2)}return n},RM=(r,e)=>{let t=NM(r);for(let n in t)t.hasOwnProperty(n)&&(t[n]=e);return t},NM=r=>{let e={};return e[r]="",["webkit","Moz","o"].forEach(function(n){e[n+r.charAt(0).toUpperCase()+r.slice(1)]=""}),e},vm=(r,e)=>{for(let t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r},BM=(r,e)=>{let t={};for(let n in r)r.hasOwnProperty(n)&&e.hasOwnProperty(n)?t[n]=e[n]:r.hasOwnProperty(n)&&(t[n]=r[n]);return t},ed=(r,e)=>{if(r.length)for(let t=0,n=r.length;t<n;t+=1)e(r[t]);else e(r)},FM=(r,e,t)=>({x:Math.min(Math.max(r.x,e.x-t),e.x+t),y:Math.min(Math.max(r.y,e.y-t),e.y+t)});typeof window<"u"&&(UM="ontouchstart"in window,GM=!!window.PointerEvent,zM=!!window.MSPointerEvent);var UM,GM,zM,td={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Wc,nd={};GM?Wc=td.pointer:zM?Wc=td.MSPointer:UM?(Wc=td.touch,nd=td.mouse):Wc=td.mouse;function xa(){}xa.prototype.on=function(r,e){var t=this,n=r.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],t._handlers_[i]=t._handlers_[i]||[],t._handlers_[i].push(e);return t};xa.prototype.off=function(r,e){var t=this;return t._handlers_=t._handlers_||{},r===void 0?t._handlers_={}:e===void 0?t._handlers_[r]=null:t._handlers_[r]&&t._handlers_[r].indexOf(e)>=0&&t._handlers_[r].splice(t._handlers_[r].indexOf(e),1),t};xa.prototype.trigger=function(r,e){var t=this,n=r.split(/[ ,]+/g),i;t._handlers_=t._handlers_||{};for(var s=0;s<n.length;s+=1)i=n[s],t._handlers_[i]&&t._handlers_[i].length&&t._handlers_[i].forEach(function(o){o.call(t,{type:i,target:t},e)})};xa.prototype.config=function(r){var e=this;e.options=e.defaults||{},r&&(e.options=BM(e.options,r))};xa.prototype.bindEvt=function(r,e){var t=this;return t._domHandlers_=t._domHandlers_||{},t._domHandlers_[e]=function(){typeof t["on"+e]=="function"?t["on"+e].apply(t,arguments):console.warn('[WARNING] : Missing "on'+e+'" handler.')},Hc(r,Wc[e],t._domHandlers_[e]),nd[e]&&Hc(r,nd[e],t._domHandlers_[e]),t};xa.prototype.unbindEvt=function(r,e){var t=this;return t._domHandlers_=t._domHandlers_||{},U0(r,Wc[e],t._domHandlers_[e]),nd[e]&&U0(r,nd[e],t._domHandlers_[e]),delete t._domHandlers_[e],this};var jc=xa;function An(r,e){return this.identifier=e.identifier,this.position=e.position,this.frontPosition=e.frontPosition,this.collection=r,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(e),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=An.id,An.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}An.prototype=new jc;An.constructor=An;An.id=0;An.prototype.buildEl=function(r){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};An.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",e=RM("borderRadius","50%"),t=ym("transition","opacity",r),n={};return n.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},n.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},n.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},vm(n.el,t),this.options.shape==="circle"&&vm(n.back,e),vm(n.front,e),this.applyStyles(n),this};An.prototype.applyStyles=function(r){for(var e in this.ui)if(this.ui.hasOwnProperty(e))for(var t in r[e])this.ui[e].style[t]=r[e][t];return this};An.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};An.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};An.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};An.prototype.show=function(r){var e=this;return e.options.dataOnly||(clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.addToDom(),e.restCallback(),setTimeout(function(){e.ui.el.style.opacity=1},0),e.showTimeout=setTimeout(function(){e.trigger("shown",e.instance),typeof r=="function"&&r.call(this)},e.options.fadeTime)),e};An.prototype.hide=function(r){var e=this;if(e.options.dataOnly)return e;if(e.ui.el.style.opacity=e.options.restOpacity,clearTimeout(e.removeTimeout),clearTimeout(e.showTimeout),clearTimeout(e.restTimeout),e.removeTimeout=setTimeout(function(){var t=e.options.mode==="dynamic"?"none":"block";e.ui.el.style.display=t,typeof r=="function"&&r.call(e),e.trigger("hidden",e.instance)},e.options.fadeTime),e.options.restJoystick){let t=e.options.restJoystick,n={};n.x=t===!0||t.x!==!1?0:e.instance.frontPosition.x,n.y=t===!0||t.y!==!1?0:e.instance.frontPosition.y,e.setPosition(r,n)}return e};An.prototype.setPosition=function(r,e){var t=this;t.frontPosition={x:e.x,y:e.y};var n=t.options.fadeTime+"ms",i={};i.front=ym("transition",["top","left"],n);var s={front:{}};s.front={left:t.frontPosition.x+"px",top:t.frontPosition.y+"px"},t.applyStyles(i),t.applyStyles(s),t.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(t),t.restCallback()},t.options.fadeTime)};An.prototype.restCallback=function(){var r=this,e={};e.front=ym("transition","none",""),r.applyStyles(e),r.trigger("rested",r.instance)};An.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};An.prototype.computeDirection=function(r){var e=r.angle.radian,t=Math.PI/4,n=Math.PI/2,i,s,o;if(e>t&&e<t*3&&!r.lockX?i="up":e>-t&&e<=t&&!r.lockY?i="left":e>-t*3&&e<=-t&&!r.lockX?i="down":r.lockY||(i="right"),r.lockY||(e>-n&&e<n?s="left":s="right"),r.lockX||(e>0?o="up":o="down"),r.force>this.options.threshold){var a={},l;for(l in this.direction)this.direction.hasOwnProperty(l)&&(a[l]=this.direction[l]);var u={};this.direction={x:s,y:o,angle:i},r.direction=this.direction;for(l in a)a[l]===this.direction[l]&&(u[l]=!0);if(u.x&&u.y&&u.angle)return r;(!u.x||!u.y)&&this.trigger("plain",r),u.x||this.trigger("plain:"+s,r),u.y||this.trigger("plain:"+o,r),u.angle||this.trigger("dir dir:"+i,r)}else this.resetDirection();return r};var kM=An;function on(r,e){var t=this;t.nipples=[],t.idles=[],t.actives=[],t.ids=[],t.pressureIntervals={},t.manager=r,t.id=on.id,on.id+=1,t.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},t.config(e),(t.options.mode==="static"||t.options.mode==="semi")&&(t.options.multitouch=!1),t.options.multitouch||(t.options.maxNumberOfNipples=1);let n=getComputedStyle(t.options.zone.parentElement);return n&&n.display==="flex"&&(t.parentIsFlex=!0),t.updateBox(),t.prepareNipples(),t.bindings(),t.begin(),t.nipples}on.prototype=new jc;on.constructor=on;on.id=0;on.prototype.prepareNipples=function(){var r=this,e=r.nipples;e.on=r.on.bind(r),e.off=r.off.bind(r),e.options=r.options,e.destroy=r.destroy.bind(r),e.ids=r.ids,e.id=r.id,e.processOnMove=r.processOnMove.bind(r),e.processOnEnd=r.processOnEnd.bind(r),e.get=function(t){if(t===void 0)return e[0];for(var n=0,i=e.length;n<i;n+=1)if(e[n].identifier===t)return e[n];return!1}};on.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};on.prototype.begin=function(){var r=this,e=r.options;if(e.mode==="static"){var t=r.createNipple(e.position,r.manager.getIdentifier());t.add(),r.idles.push(t)}};on.prototype.createNipple=function(r,e){var t=this,n=t.manager.scroll,i={},s=t.options,o={x:t.parentIsFlex?n.x:n.x+t.box.left,y:t.parentIsFlex?n.y:n.y+t.box.top};if(r.x&&r.y)i={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var l=a.getBoundingClientRect();s.zone.removeChild(a),i=r,r={x:l.left+n.x,y:l.top+n.y}}var u=new kM(t,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:e,position:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(gm(u.ui.el,i),gm(u.ui.front,u.frontPosition)),t.nipples.push(u),t.trigger("added "+u.identifier+":added",u),t.manager.trigger("added "+u.identifier+":added",u),t.bindNipple(u),u};on.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};on.prototype.bindNipple=function(r){var e=this,t,n=function(i,s){t=i.type+" "+s.id+":"+i.type,e.trigger(t,s)};r.on("destroyed",e.onDestroyed.bind(e)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};on.prototype.pressureFn=function(r,e,t){var n=this,i=0;clearInterval(n.pressureIntervals[t]),n.pressureIntervals[t]=setInterval(function(){var s=r.force||r.pressure||r.webkitForce||0;s!==i&&(e.trigger("pressure",s),n.trigger("pressure "+e.identifier+":pressure",s),i=s)}.bind(n),100)};on.prototype.onstart=function(r){var e=this,t=e.options,n=r;r=mm(r),e.updateBox();var i=function(s){e.actives.length<t.maxNumberOfNipples?e.processOnStart(s):n.type.match(/^touch/)&&(Object.keys(e.manager.ids).forEach(function(o){if(Object.values(n.touches).findIndex(function(l){return l.identifier===o})<0){var a=[r[0]];a.identifier=o,e.processOnEnd(a)}}),e.actives.length<t.maxNumberOfNipples&&e.processOnStart(s))};return ed(r,i),e.manager.bindDocument(),!1};on.prototype.processOnStart=function(r){var e=this,t=e.options,n,i=e.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=e.getOrCreate(i,o);a.identifier!==i&&e.manager.removeIdentifier(a.identifier),a.identifier=i;var l=function(c){c.trigger("start",c),e.trigger("start "+c.id+":start",c),c.show(),s>0&&e.pressureFn(r,c,c.identifier),e.processOnMove(r)};if((n=e.idles.indexOf(a))>=0&&e.idles.splice(n,1),e.actives.push(a),e.ids.push(a.identifier),t.mode!=="semi")l(a);else{var u=$h(o,a.position);if(u<=t.catchDistance)l(a);else{a.destroy(),e.processOnStart(r);return}}return a};on.prototype.getOrCreate=function(r,e){var t=this,n=t.options,i;return/(semi|static)/.test(n.mode)?(i=t.idles[0],i?(t.idles.splice(0,1),i):n.mode==="semi"?t.createNipple(e,r):(console.warn("Coudln't find the needed nipple."),!1)):(i=t.createNipple(e,r),i)};on.prototype.processOnMove=function(r){var e=this,t=e.options,n=e.manager.getIdentifier(r),i=e.nipples.get(n),s=e.manager.scroll;if(!OM(r)){this.processOnEnd(r);return}if(!i){console.error("Found zombie joystick with ID "+n),e.manager.removeIdentifier(n);return}if(t.dynamicPage){var o=i.el.getBoundingClientRect();i.position={x:s.x+o.left,y:s.y+o.top}}i.identifier=n;var a=i.options.size/2,l={x:r.pageX,y:r.pageY};t.lockX&&(l.y=i.position.y),t.lockY&&(l.x=i.position.x);var u=$h(l,i.position),c=IM(l,i.position),h=pm(c),d=u/a,f={distance:u,position:l},m,p;if(i.options.shape==="circle"?(m=Math.min(u,a),p=LM(i.position,m,c)):(p=FM(l,i.position,a),m=$h(p,i.position)),t.follow){if(u>a){let b=l.x-p.x,w=l.y-p.y;i.position.x+=b,i.position.y+=w,i.el.style.top=i.position.y-(e.box.top+s.y)+"px",i.el.style.left=i.position.x-(e.box.left+s.x)+"px",u=$h(l,i.position)}}else l=p,u=m;var g=l.x-i.position.x,v=l.y-i.position.y;i.frontPosition={x:g,y:v},t.dataOnly||gm(i.ui.front,i.frontPosition);var y={identifier:i.identifier,position:l,force:d,pressure:r.force||r.pressure||r.webkitForce||0,distance:u,angle:{radian:h,degree:c},vector:{x:g/a,y:-v/a},raw:f,instance:i,lockX:t.lockX,lockY:t.lockY};y=i.computeDirection(y),y.angle={radian:pm(180-c),degree:180-c},i.trigger("move",y),e.trigger("move "+i.id+":move",y)};on.prototype.processOnEnd=function(r){var e=this,t=e.options,n=e.manager.getIdentifier(r),i=e.nipples.get(n),s=e.manager.removeIdentifier(i.identifier);!i||(t.dataOnly||i.hide(function(){t.mode==="dynamic"&&(i.trigger("removed",i),e.trigger("removed "+i.id+":removed",i),e.manager.trigger("removed "+i.id+":removed",i),i.destroy())}),clearInterval(e.pressureIntervals[i.identifier]),i.resetDirection(),i.trigger("end",i),e.trigger("end "+i.id+":end",i),e.ids.indexOf(i.identifier)>=0&&e.ids.splice(e.ids.indexOf(i.identifier),1),e.actives.indexOf(i)>=0&&e.actives.splice(e.actives.indexOf(i),1),/(semi|static)/.test(t.mode)?e.idles.push(i):e.nipples.indexOf(i)>=0&&e.nipples.splice(e.nipples.indexOf(i),1),e.manager.unbindDocument(),/(semi|static)/.test(t.mode)&&(e.manager.ids[s.id]=s.identifier))};on.prototype.onDestroyed=function(r,e){var t=this;t.nipples.indexOf(e)>=0&&t.nipples.splice(t.nipples.indexOf(e),1),t.actives.indexOf(e)>=0&&t.actives.splice(t.actives.indexOf(e),1),t.idles.indexOf(e)>=0&&t.idles.splice(t.idles.indexOf(e),1),t.ids.indexOf(e.identifier)>=0&&t.ids.splice(t.ids.indexOf(e.identifier),1),t.manager.removeIdentifier(e.identifier),t.manager.unbindDocument()};on.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(t){t.destroy()});for(var e in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(e)&&clearInterval(r.pressureIntervals[e]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};var VM=on;function Nn(r){var e=this;e.ids={},e.index=0,e.collections=[],e.scroll=G0(),e.config(r),e.prepareCollections();var t=function(){var i;e.collections.forEach(function(s){s.forEach(function(o){i=o.el.getBoundingClientRect(),o.position={x:e.scroll.x+i.left,y:e.scroll.y+i.top}})})};if(typeof window>"u")return e.collections;Hc(window,"resize",function(){F0(t)});var n=function(){e.scroll=G0()};return Hc(window,"scroll",function(){F0(n)}),e.collections}Nn.prototype=new jc;Nn.constructor=Nn;Nn.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(e){var t;return r.collections.every(function(n){return t=n.get(e),!t}),t}};Nn.prototype.create=function(r){return this.createCollection(r)};Nn.prototype.createCollection=function(r){var e=this,t=new VM(e,r);return e.bindCollection(t),e.collections.push(t),t};Nn.prototype.bindCollection=function(r){var e=this,t,n=function(i,s){t=i.type+" "+s.id+":"+i.type,e.trigger(t,s)};r.on("destroyed",e.onDestroyed.bind(e)),r.on("shown hidden rested dir plain",n),r.on("dir:up dir:right dir:down dir:left",n),r.on("plain:up plain:right plain:down plain:left",n)};Nn.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};Nn.prototype.unbindDocument=function(r){var e=this;(!Object.keys(e.ids).length||r===!0)&&(e.unbindEvt(document,"move").unbindEvt(document,"end"),e.binded=!1)};Nn.prototype.getIdentifier=function(r){var e;return r?(e=r.identifier===void 0?r.pointerId:r.identifier,e===void 0&&(e=this.latest||0)):e=this.index,this.ids[e]===void 0&&(this.ids[e]=this.index,this.index+=1),this.latest=e,this.ids[e]};Nn.prototype.removeIdentifier=function(r){var e={};for(var t in this.ids)if(this.ids[t]===r){e.id=t,e.identifier=this.ids[t],delete this.ids[t];break}return e};Nn.prototype.onmove=function(r){var e=this;return e.onAny("move",r),!1};Nn.prototype.onend=function(r){var e=this;return e.onAny("end",r),!1};Nn.prototype.oncancel=function(r){var e=this;return e.onAny("end",r),!1};Nn.prototype.onAny=function(r,e){var t=this,n,i="processOn"+r.charAt(0).toUpperCase()+r.slice(1);e=mm(e);var s=function(a,l,u){u.ids.indexOf(l)>=0&&(u[i](a),a._found_=!0)},o=function(a){n=t.getIdentifier(a),ed(t.collections,s.bind(null,a,n)),a._found_||t.removeIdentifier(n)};return ed(e,o),!1};Nn.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(e){e.destroy()}),r.off()};Nn.prototype.onDestroyed=function(r,e){var t=this;if(t.collections.indexOf(e)<0)return!1;t.collections.splice(t.collections.indexOf(e),1)};var HM=Nn;var WM=new HM,jM={create:function(r){return WM.create(r)},factory:WM};function bo(r,e){let t=new De,{positions:n,triIndices:i}=Th(r.getAttribute("position"),r.getIndex());return t.setAttribute("position",new Ae(n,3)),t.setIndex(i),e&&t.applyMatrix4(e),t}var bm=class extends hl{constructor(){super(),this.layers.enable(3),this.layers.enable(8)}setFromCamera(e,t){t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):t.isPerspectiveCamera?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}intersectVisibleObjects(e,t=!0,n=[]){return e.forEach(i=>{i.visible&&this.intersectObject(i,t,n)}),n}createRaycastLineHelper(){let e=new zr({color:65280,linewidth:10}),t=new A(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),n=new A(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),i=this.camera.far-this.camera.near,s=new A().addVectors(t,n.multiplyScalar(i)),o=new De;return o.setFromPoints([t,s]),new zo(o,e)}};var QM=Hx(qM());var XM=new Map;function YM(r){if(typeof r=="string")return r;let e=XM.get(r);return e||(e={url:URL.createObjectURL(new Blob([r]))},XM.set(r,e)),e.url}var wo=class{constructor({src:e,volume:t,delay:n,loop:i}){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 s;typeof e=="string"?s={src:e}:s={src:YM(e),format:"wav"},this.sound=new QM.Howl(s),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),n!==void 0&&(this.delay=n),i!==void 0&&(this.loop=i)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,n){this.sound.on(e,t,n)}off(e,t,n){this.sound.off(e,t,n)}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(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var Sm=class{constructor(){this.type="ShapePath";this.color=new Le;this.subPaths=[];this.currentPath=null}moveTo(e,t){return this.currentPath=new Vo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath?.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath?.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,s,o){return this.currentPath?.bezierCurveTo(e,t,n,i,s,o),this}splineThru(e){return this.currentPath?.splineThru(e),this}toShapes(){let t={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},n={loc:t.ORIGIN,t:0};function i(p,g,v,y){let b=p.x,w=g.x,S=v.x,_=y.x,M=p.y,x=g.y,T=v.y,E=y.y,C=(_-S)*(M-T)-(E-T)*(b-S),P=(w-b)*(M-T)-(x-M)*(b-S),O=(E-T)*(w-b)-(_-S)*(x-M),D=C/O,N=P/O;if(O===0&&C!==0||D<=0||D>=1||N<0||N>1)return null;if(C===0&&O===0){for(let F=0;F<2;F++)if(s(F===0?v:y,p,g),n.loc===t.ORIGIN){let z=F===0?v:y;return{x:z.x,y:z.y,t:n.t}}else if(n.loc===t.BETWEEN){let z=+(b+n.t*(w-b)).toPrecision(10),Y=+(M+n.t*(x-M)).toPrecision(10);return{x:z,y:Y,t:n.t}}return null}else{for(let Y=0;Y<2;Y++)if(s(Y===0?v:y,p,g),n.loc===t.ORIGIN){let U=Y===0?v:y;return{x:U.x,y:U.y,t:n.t}}let F=+(b+D*(w-b)).toPrecision(10),z=+(M+D*(x-M)).toPrecision(10);return{x:F,y:z,t:D}}}function s(p,g,v){let y=v.x-g.x,b=v.y-g.y,w=p.x-g.x,S=p.y-g.y,_=y*S-w*b;if(p.x===g.x&&p.y===g.y){n.loc=t.ORIGIN,n.t=0;return}if(p.x===v.x&&p.y===v.y){n.loc=t.DESTINATION,n.t=1;return}if(_<-Number.EPSILON){n.loc=t.LEFT;return}if(_>Number.EPSILON){n.loc=t.RIGHT;return}if(y*w<0||b*S<0){n.loc=t.BEHIND;return}if(Math.sqrt(y*y+b*b)<Math.sqrt(w*w+S*S)){n.loc=t.BEYOND;return}let M;y!==0?M=w/y:M=S/b,n.loc=t.BETWEEN,n.t=M}function o(p,g){let v=[],y=[];for(let b=1;b<p.length;b++){let w=p[b-1],S=p[b];for(let _=1;_<g.length;_++){let M=g[_-1],x=g[_],T=i(w,S,M,x);T!==null&&v.find(E=>E.t<=T.t+Number.EPSILON&&E.t>=T.t-Number.EPSILON)===void 0&&(v.push(T),y.push(new B(T.x,T.y)))}}return y}function a(p,g,v){let y=new B;g.getCenter(y);let b=[];return v.forEach(w=>{w.boundingBox.containsPoint(y)&&o(p,w.points).forEach(_=>{b.push({identifier:w.identifier,isCW:w.isCW,point:_})})}),b.sort((w,S)=>w.point.x-S.point.x),b}function l(p,g,v,y,b){(b==null||b==="")&&(b="nonzero");let w=new B;p.boundingBox.getCenter(w);let S=[new B(v,w.y),new B(y,w.y)],_=a(S,p.boundingBox,g);_.sort((P,O)=>P.point.x-O.point.x);let M=[],x=[];_.forEach(P=>{P.identifier===p.identifier?M.push(P):x.push(P)});let T=M[0].point.x,E=[],C=0;for(;C<x.length&&x[C].point.x<T;)E.length>0&&E[E.length-1]===x[C].identifier?E.pop():E.push(x[C].identifier),C++;if(E.push(p.identifier),b==="evenodd"){let P=E.length%2===0,O=E[E.length-2];return{identifier:p.identifier,isHole:P,for:O}}else if(b==="nonzero"){let P=!0,O=null,D=null;for(let N=0;N<E.length;N++){let F=E[N];g[F]&&(P?(D=g[F].isCW,P=!1,O=F):D!==g[F].isCW&&(D=g[F].isCW,P=!0))}return{identifier:p.identifier,isHole:P,for:O}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let u=0,c=999999999,h=-999999999,d=[];this.subPaths.forEach(p=>{let g=p.getPoints(),v=-999999999,y=999999999,b=-999999999,w=999999999;for(let S=0;S<g.length;S++){let _=g[S];_.y>v&&(v=_.y),_.y<y&&(y=_.y),_.x>b&&(b=_.x),_.x<w&&(w=_.x)}h<=b&&(h=b+1),c>=w&&(c=w-1),g.length&&d.push({curves:p.curves,points:g,isCW:rl.isClockWise(g),identifier:u++,boundingBox:new af(new B(w,y),new B(b,v))})});let f=d.map(p=>l(p,d,c,h,this.userData?.style.fillRule)),m=[];return d.forEach(p=>{let g=f[p.identifier];if(g&&!g.isHole){let v=new ds;v.curves=p.curves,f.filter(b=>b?.isHole&&b.for===p.identifier).forEach(b=>{if(b){let w=d[b.identifier],S=new Vo;S.curves=w.curves,v.holes.push(S)}}),m.push(v)}}),m}};var z0=new WeakMap,Am=class extends al{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){let s=new ll(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{let a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(o,a).then(t).catch(i)},n,i)}decodeDracoFile(e,t,n,i){let s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(let l in t.attributeTypes){let u=t.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=u.name)}let n=JSON.stringify(t);if(z0.has(e)){let l=z0.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((u,c)=>{i._callbacks[s]={resolve:u,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),z0.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new De;e.index&&t.setIndex(new Ge(e.index.array,1));for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n],s=i.name,o=i.array,a=i.itemSize;t.setAttribute(s,new Ge(o,a))}return t}_loadLibrary(e,t){let n=new ll(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{let i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);let s=Gk.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
4908
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){let o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}};function Gk(){let r,e;onmessage=function(o){let a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(c){r.onModuleLoaded=function(h){c({draco:h})},DracoDecoderModule(r)});break;case"decode":let l=a.buffer,u=a.taskConfig;e.then(c=>{let h=c.draco,d=new h.Decoder,f=new h.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{let m=t(h,d,f,u),p=m.attributes.map(g=>g.array.buffer);m.index&&p.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},p)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{h.destroy(f),h.destroy(d)}});break}};function t(o,a,l,u){let c=u.attributeIDs,h=u.attributeTypes,d,f,m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeBufferToMesh(l,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeBufferToPointCloud(l,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let g in c){let v=self[h[g]],y,b;if(u.useUniqueIDs)b=c[g],y=a.GetAttributeByUniqueId(d,b);else{if(b=a.GetAttributeId(d,o[c[g]]),b===-1)continue;y=a.GetAttribute(d,b)}p.attributes.push(i(o,a,d,g,v,y))}return m===o.TRIANGULAR_MESH&&(p.index=n(o,a,d)),o.destroy(d),p}function n(o,a,l){let c=l.num_faces()*3,h=c*4,d=o._malloc(h);a.GetTrianglesUInt32Array(l,h,d);let f=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,u,c,h){let d=h.num_components(),m=l.num_points()*d,p=m*c.BYTES_PER_ELEMENT,g=s(o,c),v=o._malloc(p);a.GetAttributeDataArrayForAllPoints(l,h,g,p,v);let y=new c(o.HEAPF32.buffer,v,m).slice();return o._free(v),{name:u,array:y,itemSize:d}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var So;function zk(){return So||(So=new Am,So.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),So.decoderPending}async function kk(r){if(So){let e={attributeIDs:So.defaultAttributeIDs,attributeTypes:So.defaultAttributeTypes,useUniqueIDs:!1},t;try{t=await So.decodeGeometry(new Int8Array(r).buffer,e)}catch(n){console.error(n)}if(t)return{index:t.index?{array:t.index.array}:void 0,attributes:Object.entries(t.attributes).map(([n,i])=>({name:n,itemSize:i.itemSize,array:i.array}))}}return null}async function ZM(r,e){let[t,n]=iv(ap.deserialize(new Uint8Array(r)));c_(t);let i=[];t.scene.objects.traverse((s,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&i.push(o)}),i.length&&await zk();for(let s of i){let o=await kk(dr(s.geometry.data.draco));if(o){o.index&&(s.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let a={};o.attributes.forEach(({name:l,array:u,itemSize:c})=>{a[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),s.geometry.data.attributes=a,s.geometry.data.draco=void 0}}return e&&e(t),n.result().data}function Vk(r,e){return e.state.glyphIndex===r||e.state.fina===r||e.state.medi===r||e.state.init===r}var _m=class{constructor(e,t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=e.isUserFont??!1,this._loadingPromise=O0(e).then(n=>{n&&(this._arrayBuffer=n.arr,this._url=n.url,this.font=n.font,this._intercepted=n.intercepted,this._isLoaded=!0,t())})}update(e,t){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=O0(e).then(n=>{n&&(this._arrayBuffer=n.arr,this._url=n.url,this.font=n.font,this._intercepted=n.intercepted,this._isLoaded=!0,t())})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}async reverseLigaturesTable(e,t,n){let{Bidi:i}=await Zh,s=new i,o=h=>e.charToGlyphIndex(h.char);s.registerModifier("glyphIndex",null,o),s.applyFeatures(e,e.defaultRenderOptions.features),s.getTextGlyphs(t);let a=s.tokenizer.tokens,l=[],u=0,c=n.length===a.length;for(let h=0;h<n.length;h++){let d=n[h].index,f=String.fromCharCode(n[h].unicode),m=a[u];if(Vk(d,m)||c)l.push({char:f,index:d,replacements:[m.state.glyphIndex],replacementChars:[m.char]}),u++;else{let p=m.char,g="",v=[m.state.glyphIndex],y=[],b=!1;for(;!b;)u++,g=t.charAt(u),p+=g,v.push(e.charToGlyphIndex(g)),y=e.stringToGlyphs(p),y.length===1&&y[0].index===d&&(b=!0),u>t.length&&(b=!0);l.push({char:f,index:d,replacements:v,replacementChars:Array.from(p)}),u++}}return l}async generateShapes(e,t){await this._loadingPromise;let n=this.font,i=t.fontSize/this.unitsPerEm,s=t.fontSize*t.lineHeight,o=e.map(y=>this.getTextWidth(y,t)),a=t.width,l=this.getCharWidth(`
4909
+ `,t),u=t.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(e,0,t),h=this.getLineInitialOffsetX(o[0],a,t.horizontalAlign,e[0],l),d=this.getLineInitialOffsetY(s,e.length,t.height,i,t.verticalAlign),f=[],m=e.map(y=>[]),p=e.map(y=>[]),g;for(let y=0;y<e.length;y++){let b=e[y],w={features:{liga:!0}},S=[];try{S=n.stringToGlyphs(b,w)}catch(M){console.warn(M)}h=this.getLineInitialOffsetX(o[y],a,t.horizontalAlign,b,l);let _=[];try{_=await this.reverseLigaturesTable(n,b,S)}catch(M){console.warn(M)}c=this.computeSpaceWidthForLine(e,y,t);for(let M=0;M<S.length;M++){let x=S[M],T=x.index===0?`
4910
+ `:x.unicode?String.fromCharCode(x.unicode):void 0,E=_[M],C=0,P=0;M===0&&t.horizontalAlign===2&&x.leftSideBearing!==void 0&&(P=-x.leftSideBearing*i),g&&(C=n.getKerningValue(x,g)*i),h+=P+C;let O=0;if(T===`
4911
+ `)O=u;else if(T===" ")O=c;else{let D=this.createPath(x,i,h,d,t);D&&(O=D.offsetX-(C+P),f.push(D.path))}if(E.replacements.length===1)p[y].push([h,d]),m[y].push(O);else{let D=E.replacements.map(Y=>(n.glyphs.get(Y).advanceWidth??0)*i),N=D.reduce((Y,U)=>Y+=U,0),F=D.map(Y=>Y/N),z=h;for(let Y=0;Y<F.length;Y++){let U=O*F[Y];p[y].push([z,d]),m[y].push(U),z+=U}}h+=O,g=x}d-=s}let v=[];for(let y=0,b=f.length;y<b;y++)v.push(...f[y].toShapes());return{shapes:v,charWidths:m,lineWidths:o,charCoords:p}}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(e,t,n,i,s){return(n===3||n===2)&&i.indexOf(`
4912
+ `)>=0&&(e-=s),n===3?t*.5-e*.5:n===2?t-e:0}getLineInitialOffsetY(e,t,n,i,s){let o=t*e,a=Math.abs(this.ascender-this.descender)*i,l=e-a,u=-this.ascender*i-l/2;return s===3?-(n-o-u):s===2?-(n*.5-o*.5-u):u}createPath(e,t,n,i,s){let o=e.getPath(n,-i,s.fontSize,{kerning:!1,letterSpacing:s.letterSpacing});if(!o){console.error('THREE.Font: character "'+e+'" does not exists in font family '+this.familyName+".");return}let a=new Sm,l=(e.advanceWidth??1)*t;if(e)for(let u of o.commands){let c=a.currentPath?.currentPoint;if(!(c&&u.type!=="Z"&&c.x===u.x&&-c.y===u.y))switch(u.type){case"M":a.moveTo(u.x,-u.y);break;case"L":a.lineTo(u.x,-u.y);break;case"Q":a.quadraticCurveTo(u.x1,-u.y1,u.x,-u.y);break;case"C":a.bezierCurveTo(u.x1,-u.y1,u.x2,-u.y2,u.x,-u.y);break}}return a.subPaths.forEach(u=>{let c=Hk(u.curves);c!==void 0&&u.currentPoint.distanceTo(c)>0&&u.lineTo(c.x,c.y)}),{offsetX:l+s.fontSize*s.letterSpacing,path:a}}getCharWidth(e,t){return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}getTextWidth(e,t){return this.font?.getAdvanceWidth(e,t.fontSize,{kerning:!0,letterSpacing:t.letterSpacing})??0}computeSpaceWidthForLine(e,t,n){let i=this.getCharWidth(" ",n),s=e[t];if(s){let o=this.countSpaces(s.trimEnd());if(n.horizontalAlign===4&&t<e.length-1&&o){let a=n.width,l=this.getTextWidth(s,n);return(a-(l-o*i))/o}}return i}countSpaces(e){return(e.match(/ /g)||[]).length}};function Hk(r){if(r.length){let e=r[0];if(e instanceof jn)return e.v1;if(e instanceof Wn||e instanceof Er)return e.v0}}var ba=class{constructor(e,t={}){this.deletedMaterial=new va(Fn.defaultTwoLayerData("basic"),this);this.deletedImage=new ga(Tp.emptyImage);this.materials={};this.images={};this.colors={};this.audios={};this.fonts={};this.penumbraSize=[];this.onImageLoad=()=>{this._onImageLoad&&this._onImageLoad()};this.onFontLoad=()=>{this._onFontLoad&&this._onFontLoad()};if(t.images)for(let[n,i]of Object.entries(t.images))this.addImage(n,i);if(t.audios)for(let[n,i]of Object.entries(t.audios))this.addAudio(n,i.data);this.reset(e)}setOnImageLoad(e){this._onImageLoad=e}setOnFontLoad(e){this._onFontLoad=e}reset(e){for(let[t,n]of Object.entries(e.images))this.addImage(t,n);for(let[t,n]of Object.entries(e.colors))this.addColor(t,n);for(let[t,n]of Object.entries(e.materials))this.addMaterial(t,new va(n,this));for(let[t,n]of Object.entries(e.audios))this.addAudio(t,n.data);for(let[t,n]of Object.entries(e.fonts))this.addFont(t,n);this.penumbraSize=e.penumbraSize}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){return this.materials[e]??this.deletedMaterial}material(e){return typeof e=="string"?this.getMaterialOrDeletedPlaceholder(e):new Or(e,this)}getMaterials(){return this.materials}addImage(e,t){return this.images[e]?(this.images[e].updateSrc(t.data),!0):(this.images[e]=new ga(t,this.onImageLoad),!1)}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]??this.deletedImage}image(e){return typeof e=="string"?this.getImage(e):new Nc(e,this.onImageLoad)}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new go(t.r,t.g,t.b,t.a):this.colors[e]=new go(t.r,t.g,t.b,1),!1)}updateColor(e,t){if(this.colors[e]){let n=this.colors[e];return this.colors[e].r=t.r??n.r,this.colors[e].g=t.g??n.g,this.colors[e].b=t.b??n.b,this.colors[e].a=t.a??n.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}color(e){let t;if(typeof e=="string"){let n=this.getColor(e);n?t=n:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new $t(0,0,0,0))}else return"a"in e?new $t(e.r,e.g,e.b,e.a):new $t(e.r,e.g,e.b,1);return t}addAudio(e,t){this.audios[e]=t}getAudio(e){let t=this.audios[e];if(t instanceof wo)return t;{let n=new wo({src:t});return this.audios[e]=n,n}}deleteAudio(e){this.audios[e]&&delete this.audios[e]}addFont(e,t){this.fonts[e]=new _m(t,this.onFontLoad)}getFont(e){return this.fonts[e]}deleteFont(e){this.fonts[e]&&delete this.fonts[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this._onImageLoad=void 0,Object.values(this.audios).forEach(t=>{t instanceof wo&&t.dispose()}),this.audios={}}},Ape=new ba(ec.emptyData());function Wk(r,e){return r.distance-e.distance}function JM(r,e,t){if(Kr(e)&&e.visible&&!e.raycastLock)e.raycast(r,t);else return;for(let n of e.children)JM(r,n,t)}function Mm(r,e,t){if(!t.some(i=>rd(r,i)!==void 0))return[];let n=[];return e.children.forEach(i=>JM(r,i,n)),n.sort(Wk),n}function Em(r){let e=[];if(r.length){let t=r[0].object;Kr(t)&&e.push(t);let n=t.parent;for(;n;)h0(n)&&e.push(n),n=n.parent}return e}function rd(r,e){if(kt(e)){if(!e.raycastLock&&e.visible){let t=[];return e.raycast(r,t),t.length?t[0]:void 0}}else if(h0(e))return $M(r,e)}function $M(r,e){if(kt(e)&&!e.raycastLock&&e.visible){let t=[];if(e.raycast(r,t),t.length)return t[0]}for(let t of e.children)if(Kr(t)){let n=$M(r,t);if(n)return n}}function jk(r){if(r.style.transform!==""){let e=getComputedStyle(r).getPropertyValue("transform");if(e!=="none"){let t=e.replace("matrix(","").split(",");return{x:parseFloat(t[0]),y:parseFloat(t[3])}}}return{x:1,y:1}}function KM(r){let e=r.getViewport(new He),t=jk(r.domElement);return{left:e.x*t.x,top:e.y*t.y,width:e.z*t.x,height:e.w*t.y}}function qk(r,e,t,n){let i=t.height-n.height,s=(r-n.left-t.left)*(t.width/n.width),o=(e-i+n.top-t.top)*(t.height/n.height);return{x:s/t.width*2-1,y:-(o/t.height)*2+1}}var Tm=class{constructor(e,t,n,i,s,o){this.isExport=o;this.raycaster=new bm;this.raycasterNeedsUpdate=!0;this.stopRaycast=!1;this.sharedAssets=new ba(ec.emptyData());this.scene=new Ss({...bp.defaultData},this.sharedAssets);this.camera=new zn;this.renderer=e,this.domElement=e.domElement,this._domRect=this.domElement.getBoundingClientRect(),this._viewRect=KM(this.renderer),this.stopRaycast=s,this.sharedAssets=i,this.scene=t,this.camera=n}get domRect(){return this._domRect}get viewRect(){return this._viewRect}updaterRect(){this._domRect=this.domElement.getBoundingClientRect(),this._viewRect=KM(this.renderer)}updateRaycaster(e){if(!this.raycasterNeedsUpdate)return;this.raycasterNeedsUpdate=!1;let{clientX:t,clientY:n}=e.touches!==void 0&&e.touches.length>0?e.touches[0]:e;this.raycaster.setFromCamera(qk(t,n,this._domRect,this._viewRect),this.camera)}};var k0=(o=>(o[o.keydown=0]="keydown",o[o.keyup=1]="keyup",o[o.pointerdown=2]="pointerdown",o[o.pointerup=3]="pointerup",o[o.pointermove=4]="pointermove",o[o.wheel=5]="wheel",o))(k0||{}),Bn=class{constructor(e){this.eventContext=e;this.domEventsNeeded=new Set}connect(){}disconnect(){}};var eE=new Map,id=new Map,As=class{constructor(e,t,n,i){this.data=t;let{audio:s,volume:o,delay:a,loop:l}=t;if(!s)throw new Error("Missing property");let u=typeof s=="string"?i.getAudio(s).src:s.data;this.audioPlayer=new wo({src:u,volume:o,delay:a,loop:l}),id.has(n.uuid)?id.get(n.uuid).push(this):id.set(n.uuid,[this]),eE.set(e,this)}playByToggle(){this.data.toggle==="stop"?this.audioPlayer.status==="playing"?this.audioPlayer.stop():(this.audioPlayer.stop(),this.audioPlayer.play()):this.data.toggle==="pause"?this.audioPlayer.status==="playing"?this.audioPlayer.pause():this.audioPlayer.play():(this.audioPlayer.stop(),this.audioPlayer.play())}dispose(){this.audioPlayer.stop()}},qc=class{constructor(e){this.data=e}dispatch(){this.data.playAudio?this.pauseAudio(this.data.playAudio):this.data.object?this.pauseAllAudiosFromObject(this.data.object):this.pauseAllAudios()}pauseAudio(e){let t=eE.get(e);!t||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.audioPlayer[this.data.interaction](),this.disposeDelay()},this.data.delay)):t.audioPlayer[this.data.interaction]())}pauseAllAudiosFromObject(e){let t=id.get(e);!t?.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{t.forEach(n=>n.audioPlayer[this.data.interaction]()),this.disposeDelay()},this.data.delay)):t.forEach(n=>n.audioPlayer[this.data.interaction]()))}pauseAllAudios(){let e=[...id.values()];!e.length||(this.data.delay>0?(this.disposeDelay(),this.timeoutId=window.setTimeout(()=>{e.forEach(t=>{t.forEach(n=>{n.audioPlayer[this.data.interaction]()})}),this.disposeDelay()},this.data.delay)):e.forEach(t=>{t.forEach(n=>{n.audioPlayer[this.data.interaction]()})}))}disposeDelay(){clearTimeout(this.timeoutId),delete this.timeoutId}dispose(){clearTimeout(this.timeoutId),delete this.timeoutId}},Zi=class{constructor(e,t,n,i){this.data=t;if(t.interaction==="play")this.interaction=new As(e,t,n,i);else if(t.interaction==="pause"||t.interaction==="stop")this.interaction=new qc(t);else throw new Error("Missing property")}dispatchBasic(){this.interaction instanceof As?this.interaction.playByToggle():this.interaction.dispatch()}dispatchConditional(){this.interaction instanceof As?this.interaction.audioPlayer.play():this.interaction.dispatch()}dispatchGameControl(e){this.interaction instanceof As&&(e==="start"?this.interaction.audioPlayer.play():this.interaction.audioPlayer.stop())}dispose(){this.interaction.dispose()}};var Xk="text/plain",Yk="us-ascii",tE=(r,e)=>e.some(t=>t instanceof RegExp?t.test(r):t===r),Qk=(r,{stripHash:e})=>{let t=/^data:(?<type>[^,]*?),(?<data>[^#]*?)(?:#(?<hash>.*))?$/.exec(r);if(!t)throw new Error(`Invalid URL: ${r}`);let{type:n,data:i,hash:s}=t.groups,o=n.split(";");s=e?"":s;let a=!1;o[o.length-1]==="base64"&&(o.pop(),a=!0);let l=(o.shift()||"").toLowerCase(),c=[...o.map(h=>{let[d,f=""]=h.split("=").map(m=>m.trim());return d==="charset"&&(f=f.toLowerCase(),f===Yk)?"":`${d}${f?`=${f}`:""}`}).filter(Boolean)];return a&&c.push("base64"),(c.length>0||l&&l!==Xk)&&c.unshift(l),`data:${c.join(";")},${a?i.trim():i}${s?`#${s}`:""}`};function V0(r,e){if(e={defaultProtocol:"http:",normalizeProtocol:!0,forceHttp:!1,forceHttps:!1,stripAuthentication:!0,stripHash:!1,stripTextFragment:!0,stripWWW:!0,removeQueryParameters:[/^utm_\w+/i],removeTrailingSlash:!0,removeSingleSlash:!0,removeDirectoryIndex:!1,sortQueryParameters:!0,...e},r=r.trim(),/^data:/i.test(r))return Qk(r,e);if(/^view-source:/i.test(r))throw new Error("`view-source:` is not supported as it is a non-standard protocol");let t=r.startsWith("//");!t&&/^\.*\//.test(r)||(r=r.replace(/^(?!(?:\w+:)?\/\/)|^\/\//,e.defaultProtocol));let i=new URL(r);if(e.forceHttp&&e.forceHttps)throw new Error("The `forceHttp` and `forceHttps` options cannot be used together");if(e.forceHttp&&i.protocol==="https:"&&(i.protocol="http:"),e.forceHttps&&i.protocol==="http:"&&(i.protocol="https:"),e.stripAuthentication&&(i.username="",i.password=""),e.stripHash?i.hash="":e.stripTextFragment&&(i.hash=i.hash.replace(/#?:~:text.*?$/i,"")),i.pathname){let o=/\b[a-z][a-z\d+\-.]{1,50}:\/\//g,a=0,l="";for(;;){let c=o.exec(i.pathname);if(!c)break;let h=c[0],d=c.index;l+=i.pathname.slice(a,d).replace(/\/{2,}/g,"/"),l+=h,a=d+h.length}l+=i.pathname.slice(a,i.pathname.length).replace(/\/{2,}/g,"/"),i.pathname=l}if(i.pathname)try{i.pathname=decodeURI(i.pathname)}catch{}if(e.removeDirectoryIndex===!0&&(e.removeDirectoryIndex=[/^index\.[a-z]+$/]),Array.isArray(e.removeDirectoryIndex)&&e.removeDirectoryIndex.length>0){let o=i.pathname.split("/"),a=o[o.length-1];tE(a,e.removeDirectoryIndex)&&(o=o.slice(0,-1),i.pathname=o.slice(1).join("/")+"/")}if(i.hostname&&(i.hostname=i.hostname.replace(/\.$/,""),e.stripWWW&&/^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(i.hostname)&&(i.hostname=i.hostname.replace(/^www\./,""))),Array.isArray(e.removeQueryParameters))for(let o of[...i.searchParams.keys()])tE(o,e.removeQueryParameters)&&i.searchParams.delete(o);if(e.removeQueryParameters===!0&&(i.search=""),e.sortQueryParameters){i.searchParams.sort();try{i.search=decodeURIComponent(i.search)}catch{}}e.removeTrailingSlash&&(i.pathname=i.pathname.replace(/\/$/,""));let s=r;return r=i.toString(),!e.removeSingleSlash&&i.pathname==="/"&&!s.endsWith("/")&&i.hash===""&&(r=r.replace(/\/$/,"")),(e.removeTrailingSlash||i.pathname==="/")&&i.hash===""&&e.removeSingleSlash&&(r=r.replace(/\/$/,"")),t&&!e.normalizeProtocol&&(r=r.replace(/^http:\/\//,"//")),e.stripProtocol&&(r=r.replace(/^(?:https?:)?\/\//,"")),r}var Cm=class{constructor({url:e}){if(!e)throw new Error("Missing property");this.url=e.startsWith("mailto:")?e:V0(e)}dispatch(){sh?window.location.assign(this.url):window.open(this.url,"_blank")}};var aE={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},q0={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},Zk=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Dm={CSS:{},springs:{}};function Ki(r,e,t){return Math.min(Math.max(r,e),t)}function sd(r,e){return r.indexOf(e)>-1}function H0(r,e){return r.apply(null,e)}var je={arr:function(r){return Array.isArray(r)},obj:function(r){return sd(Object.prototype.toString.call(r),"Object")},pth:function(r){return je.obj(r)&&r.hasOwnProperty("totalLength")},svg:function(r){return r instanceof SVGElement},inp:function(r){return r instanceof HTMLInputElement},dom:function(r){return!("isNode"in r)&&(r.nodeType||je.svg(r))},str:function(r){return typeof r=="string"},fnc:function(r){return typeof r=="function"},und:function(r){return typeof r>"u"},hex:function(r){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(r)},rgb:function(r){return/^rgb/.test(r)},hsl:function(r){return/^hsl/.test(r)},col:function(r){return je.hex(r)||je.rgb(r)||je.hsl(r)},key:function(r){return!aE.hasOwnProperty(r)&&!q0.hasOwnProperty(r)&&r!=="targets"&&r!=="keyframes"}};function lE(r){var e=/\(([^)]+)\)/.exec(r);return e?e[1].split(",").map(function(t){return parseFloat(t)}):[]}function cE(r,e){var t=lE(r),n=Ki(je.und(t[0])?1:t[0],.1,100),i=Ki(je.und(t[1])?100:t[1],.1,100),s=Ki(je.und(t[2])?10:t[2],.1,100),o=Ki(je.und(t[3])?0:t[3],.1,100),a=Math.sqrt(i/n),l=s/(2*Math.sqrt(i*n)),u=l<1?a*Math.sqrt(1-l*l):0,c=1,h=l<1?(l*a+-o)/u:-o+a;function d(m){var p=e?e*m/1e3:m;return l<1?p=Math.exp(-p*l*a)*(c*Math.cos(u*p)+h*Math.sin(u*p)):p=(c+h*p)*Math.exp(-p*a),m===0||m===1?m:1-p}function f(){var m=Dm.springs[r];if(m)return m;for(var p=1/6,g=0,v=0;;)if(g+=p,d(g)===1){if(v++,v>=16)break}else v=0;var y=g*p*1e3;return Dm.springs[r]=y,y}return e?d:f}function Kk(r){return r===void 0&&(r=10),function(e){return Math.ceil(Ki(e,1e-6,1)*r)*(1/r)}}var Jk=function(){var r=11,e=1/(r-1);function t(c,h){return 1-3*h+3*c}function n(c,h){return 3*h-6*c}function i(c){return 3*c}function s(c,h,d){return((t(h,d)*c+n(h,d))*c+i(h))*c}function o(c,h,d){return 3*t(h,d)*c*c+2*n(h,d)*c+i(h)}function a(c,h,d,f,m){var p,g,v=0;do g=h+(d-h)/2,p=s(g,f,m)-c,p>0?d=g:h=g;while(Math.abs(p)>1e-7&&++v<10);return g}function l(c,h,d,f){for(var m=0;m<4;++m){var p=o(h,d,f);if(p===0)return h;var g=s(h,d,f)-c;h-=g/p}return h}function u(c,h,d,f){if(!(0<=c&&c<=1&&0<=d&&d<=1))return;var m=new Float32Array(r);if(c!==h||d!==f)for(var p=0;p<r;++p)m[p]=s(p*e,c,d);function g(v){for(var y=0,b=1,w=r-1;b!==w&&m[b]<=v;++b)y+=e;--b;var S=(v-m[b])/(m[b+1]-m[b]),_=y+S*e,M=o(_,c,d);return M>=.001?l(v,_,c,d):M===0?_:a(v,y,y+e,c,d)}return function(v){return c===h&&d===f||v===0||v===1?v:s(g(v),h,f)}}return u}(),uE=function(){var r={linear:function(){return function(n){return n}}},e={Sine:function(){return function(n){return 1-Math.cos(n*Math.PI/2)}},Circ:function(){return function(n){return 1-Math.sqrt(1-n*n)}},Back:function(){return function(n){return n*n*(3*n-2)}},Bounce:function(){return function(n){for(var i,s=4;n<((i=Math.pow(2,--s))-1)/11;);return 1/Math.pow(4,3-s)-7.5625*Math.pow((i*3-2)/22-n,2)}},Elastic:function(n,i){n===void 0&&(n=1),i===void 0&&(i=.5);var s=Ki(n,1,10),o=Ki(i,.1,2);return function(a){return a===0||a===1?a:-s*Math.pow(2,10*(a-1))*Math.sin((a-1-o/(Math.PI*2)*Math.asin(1/s))*(Math.PI*2)/o)}}},t=["Quad","Cubic","Quart","Quint","Expo"];return t.forEach(function(n,i){e[n]=function(){return function(s){return Math.pow(s,i+2)}}}),Object.keys(e).forEach(function(n){var i=e[n];r["easeIn"+n]=i,r["easeOut"+n]=function(s,o){return function(a){return 1-i(s,o)(1-a)}},r["easeInOut"+n]=function(s,o){return function(a){return a<.5?i(s,o)(a*2)/2:1-i(s,o)(a*-2+2)/2}}}),r}();function X0(r,e){if(je.fnc(r))return r;var t=r.split("(")[0],n=uE[t],i=lE(r);switch(t){case"spring":return cE(r,e);case"cubicBezier":return H0(Jk,i);case"steps":return H0(Kk,i);default:return H0(n,i)}}function hE(r){try{var e=document.querySelectorAll(r);return e}catch{return}}function Im(r,e){for(var t=r.length,n=arguments.length>=2?arguments[1]:void 0,i=[],s=0;s<t;s++)if(s in r){var o=r[s];e.call(n,o,s,r)&&i.push(o)}return i}function Lm(r){return r.reduce(function(e,t){return e.concat(je.arr(t)?Lm(t):t)},[])}function nE(r){return je.arr(r)?r:(je.str(r)&&(r=hE(r)||r),r instanceof NodeList||r instanceof HTMLCollection?[].slice.call(r):[r])}function Y0(r,e){return r.some(function(t){return t===e})}function Q0(r){var e={};for(var t in r)e[t]=r[t];return e}function W0(r,e){var t=Q0(r);for(var n in r)t[n]=e.hasOwnProperty(n)?e[n]:r[n];return t}function Om(r,e){var t=Q0(r);for(var n in e)t[n]=je.und(r[n])?e[n]:r[n];return t}function $k(r){var e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(r);return e?"rgba("+e[1]+",1)":r}function eV(r){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,t=r.replace(e,function(a,l,u,c){return l+l+u+u+c+c}),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t),i=parseInt(n[1],16),s=parseInt(n[2],16),o=parseInt(n[3],16);return"rgba("+i+","+s+","+o+",1)"}function tV(r){var e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(r)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(r),t=parseInt(e[1],10)/360,n=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100,s=e[4]||1;function o(d,f,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(f-d)*6*m:m<1/2?f:m<2/3?d+(f-d)*(2/3-m)*6:d}var a,l,u;if(n==0)a=l=u=i;else{var c=i<.5?i*(1+n):i+n-i*n,h=2*i-c;a=o(h,c,t+1/3),l=o(h,c,t),u=o(h,c,t-1/3)}return"rgba("+a*255+","+l*255+","+u*255+","+s+")"}function nV(r){if(je.rgb(r))return $k(r);if(je.hex(r))return eV(r);if(je.hsl(r))return tV(r)}function _s(r){var e=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(r);if(e)return e[1]}function rV(r){if(sd(r,"translate")||r==="perspective")return"px";if(sd(r,"rotate")||sd(r,"skew"))return"deg"}function j0(r,e){return je.fnc(r)?r(e.target,e.id,e.total):r}function Ji(r,e){return r.getAttribute(e)}function Z0(r,e,t){var n=_s(e);if(Y0([t,"deg","rad","turn"],n))return e;var i=Dm.CSS[e+t];if(!je.und(i))return i;var s=100,o=document.createElement(r.tagName),a=r.parentNode&&r.parentNode!==document?r.parentNode:document.body;a.appendChild(o),o.style.position="absolute",o.style.width=s+t;var l=s/o.offsetWidth;a.removeChild(o);var u=l*parseFloat(e);return Dm.CSS[e+t]=u,u}function dE(r,e,t){if(e in r.style){var n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),i=r.style[e]||getComputedStyle(r).getPropertyValue(n)||"0";return t?Z0(r,i,t):i}}function K0(r,e){if(je.dom(r)&&!je.inp(r)&&(Ji(r,e)||je.svg(r)&&r[e]))return"attribute";if(je.dom(r)&&Y0(Zk,e))return"transform";if(je.dom(r)&&e!=="transform"&&dE(r,e))return"css";if(r[e]!=null)return"object"}function fE(r){if(!!je.dom(r)){for(var e=r.style.transform||"",t=/(\w+)\(([^)]*)\)/g,n=new Map,i;i=t.exec(e);)n.set(i[1],i[2]);return n}}function iV(r,e,t,n){var i=sd(e,"scale")?1:0+rV(e),s=fE(r).get(e)||i;return t&&(t.transforms.list.set(e,s),t.transforms.last=e),n?Z0(r,s,n):s}function J0(r,e,t,n){switch(K0(r,e)){case"transform":return iV(r,e,n,t);case"css":return dE(r,e,t);case"attribute":return Ji(r,e);default:return r[e]||0}}function $0(r,e){var t=/^(\*=|\+=|-=)/.exec(r);if(!t)return r;var n=_s(r)||0,i=parseFloat(e),s=parseFloat(r.replace(t[0],""));switch(t[0][0]){case"+":return i+s+n;case"-":return i-s+n;case"*":return i*s+n}}function pE(r,e){if(je.col(r))return nV(r);if(/\s/g.test(r))return r;var t=_s(r),n=t?r.substr(0,r.length-t.length):r;return e?n+e:n}function ex(r,e){return Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))}function sV(r){return Math.PI*2*Ji(r,"r")}function oV(r){return Ji(r,"width")*2+Ji(r,"height")*2}function aV(r){return ex({x:Ji(r,"x1"),y:Ji(r,"y1")},{x:Ji(r,"x2"),y:Ji(r,"y2")})}function mE(r){for(var e=r.points,t=0,n,i=0;i<e.numberOfItems;i++){var s=e.getItem(i);i>0&&(t+=ex(n,s)),n=s}return t}function lV(r){var e=r.points;return mE(r)+ex(e.getItem(e.numberOfItems-1),e.getItem(0))}function gE(r){if(r.getTotalLength)return r.getTotalLength();switch(r.tagName.toLowerCase()){case"circle":return sV(r);case"rect":return oV(r);case"line":return aV(r);case"polyline":return mE(r);case"polygon":return lV(r)}}function cV(r){var e=gE(r);return r.setAttribute("stroke-dasharray",e),e}function uV(r){for(var e=r.parentNode;je.svg(e)&&je.svg(e.parentNode);)e=e.parentNode;return e}function yE(r,e){var t=e||{},n=t.el||uV(r),i=n.getBoundingClientRect(),s=Ji(n,"viewBox"),o=i.width,a=i.height,l=t.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:n,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function hV(r,e){var t=je.str(r)?hE(r)[0]:r,n=e||100;return function(i){return{property:i,el:t,svg:yE(t),totalLength:gE(t)*(n/100)}}}function dV(r,e){function t(a){a===void 0&&(a=0);var l=e+a>=1?e+a:0;return r.el.getPointAtLength(l)}var n=yE(r.el,r.svg),i=t(),s=t(-1),o=t(1);switch(r.property){case"x":return(i.x-n.x)*n.w;case"y":return(i.y-n.y)*n.h;case"angle":return Math.atan2(o.y-s.y,o.x-s.x)*180/Math.PI}}function rE(r,e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,n=pE(je.pth(r)?r.totalLength:r,e)+"";return{original:n,numbers:n.match(t)?n.match(t).map(Number):[0],strings:je.str(r)||e?n.split(t):[]}}function vE(r){var e=r?Lm(je.arr(r)?r.map(nE):nE(r)):[];return Im(e,function(t,n,i){return i.indexOf(t)===n})}function xE(r){var e=vE(r);return e.map(function(t,n){return{target:t,id:n,total:e.length,transforms:{list:fE(t)}}})}function fV(r,e){var t=Q0(e);if(/^spring/.test(t.easing)&&(t.duration=cE(t.easing)),je.arr(r)){var n=r.length,i=n===2&&!je.obj(r[0]);i?r={value:r}:je.fnc(e.duration)||(t.duration=e.duration/n)}var s=je.arr(r)?r:[r];return s.map(function(o,a){var l=je.obj(o)&&!je.pth(o)?o:{value:o};return je.und(l.delay)&&(l.delay=a?0:e.delay),je.und(l.endDelay)&&(l.endDelay=a===s.length-1?e.endDelay:0),l}).map(function(o){return Om(o,t)})}function pV(r){for(var e=Im(Lm(r.map(function(s){return Object.keys(s)})),function(s){return je.key(s)}).reduce(function(s,o){return s.indexOf(o)<0&&s.push(o),s},[]),t={},n=function(s){var o=e[s];t[o]=r.map(function(a){var l={};for(var u in a)je.key(u)?u==o&&(l.value=a[u]):l[u]=a[u];return l})},i=0;i<e.length;i++)n(i);return t}function mV(r,e){var t=[],n=e.keyframes;n&&(e=Om(pV(n),e));for(var i in e)je.key(i)&&t.push({name:i,tweens:fV(e[i],r)});return t}function gV(r,e){var t={};for(var n in r){var i=j0(r[n],e);je.arr(i)&&(i=i.map(function(s){return j0(s,e)}),i.length===1&&(i=i[0])),t[n]=i}return t.duration=parseFloat(t.duration),t.delay=parseFloat(t.delay),t}function yV(r,e){var t;return r.tweens.map(function(n){var i=gV(n,e),s=i.value,o=je.arr(s)?s[1]:s,a=_s(o),l=J0(e.target,r.name,a,e),u=t?t.to.original:l,c=je.arr(s)?s[0]:u,h=_s(c)||_s(l),d=a||h;return je.und(o)&&(o=u),i.from=rE(c,d),i.to=rE($0(o,c),d),i.start=t?t.end:0,i.end=i.start+i.delay+i.duration+i.endDelay,i.easing=X0(i.easing,i.duration),i.isPath=je.pth(s),i.isColor=je.col(i.from.original),i.isColor&&(i.round=1),t=i,i})}var bE={css:function(r,e,t){return r.style[e]=t},attribute:function(r,e,t){return r.setAttribute(e,t)},object:function(r,e,t){return r[e]=t},transform:function(r,e,t,n,i){if(n.list.set(e,t),e===n.last||i){var s="";n.list.forEach(function(o,a){s+=a+"("+o+") "}),r.style.transform=s}}};function wE(r,e){var t=xE(r);t.forEach(function(n){for(var i in e){var s=j0(e[i],n),o=n.target,a=_s(s),l=J0(o,i,a,n),u=a||_s(l),c=$0(pE(s,u),l),h=K0(o,i);bE[h](o,i,c,n.transforms,!0)}})}function vV(r,e){var t=K0(r.target,e.name);if(t){var n=yV(e,r),i=n[n.length-1];return{type:t,property:e.name,animatable:r,tweens:n,duration:i.end,delay:n[0].delay,endDelay:i.endDelay}}}function xV(r,e){return Im(Lm(r.map(function(t){return e.map(function(n){return vV(t,n)})})),function(t){return!je.und(t)})}function SE(r,e){var t=r.length,n=function(s){return s.timelineOffset?s.timelineOffset:0},i={};return i.duration=t?Math.max.apply(Math,r.map(function(s){return n(s)+s.duration})):e.duration,i.delay=t?Math.min.apply(Math,r.map(function(s){return n(s)+s.delay})):e.delay,i.endDelay=t?i.duration-Math.max.apply(Math,r.map(function(s){return n(s)+s.duration-s.endDelay})):e.endDelay,i}var iE=0;function bV(r){var e=W0(aE,r),t=W0(q0,r),n=mV(t,r),i=xE(r.targets),s=xV(i,n),o=SE(s,t),a=iE;return iE++,Om(e,{id:a,children:[],animatables:i,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}var wr=[],sE=[],Pm,wV=function(){function r(){Pm=requestAnimationFrame(e)}function e(t){var n=wr.length;if(n){for(var i=0;i<n;){var s=wr[i];if(!s.paused)s.tick(t);else{var o=wr.indexOf(s);o>-1&&(wr.splice(o,1),n=wr.length)}i++}r()}else Pm=cancelAnimationFrame(Pm)}return r}();function SV(){document.hidden?(wr.forEach(function(r){return r.pause()}),sE=wr.slice(0),hn.running=wr=[]):sE.forEach(function(r){return r.play()})}typeof document<"u"&&document.addEventListener("visibilitychange",SV);function hn(r){r===void 0&&(r={});var e=0,t=0,n=0,i,s=0,o=null;function a(b){var w=window.Promise&&new Promise(function(S){return o=S});return b.finished=w,w}var l=bV(r),u=a(l);function c(){var b=l.direction;b!=="alternate"&&(l.direction=b!=="normal"?"normal":"reverse"),l.reversed=!l.reversed,i.forEach(function(w){return w.reversed=l.reversed})}function h(b){return l.reversed?l.duration-b:b}function d(){e=0,t=h(l.currentTime)*(1/hn.speed)}function f(b,w){w&&w.seek(b-w.timelineOffset)}function m(b){if(l.reversePlayback)for(var S=s;S--;)f(b,i[S]);else for(var w=0;w<s;w++)f(b,i[w])}function p(b){var w=0,S=l.animations,_=S.length;for(l.reversePlayback===!0&&l.rewind===!1&&(b=l.duration+l.delay-l.endDelay-b);w<_;){var M=S[w],x=M.animatable,T=M.tweens,E=T.length-1,C=T[E];E&&(C=Im(T,function(ie){return b<ie.end})[0]||C);for(var P=Ki(b-C.start-C.delay,0,C.duration)/C.duration,O=isNaN(P)?1:C.easing(P),D=C.to.strings,N=C.round,F=[],z=C.to.numbers.length,Y=void 0,U=0;U<z;U++){var G=void 0;if(l.reversePlayback===!0&&l.rewind===!1)var Q=C.to.numbers[U],V=C.from.numbers[U]||0;else var V=C.to.numbers[U],Q=C.from.numbers[U]||0;C.isPath?G=dV(C.value,O*V):G=Q+O*(V-Q),N&&(C.isColor&&U>2||(G=Math.round(G*N)/N)),F.push(G)}var k=D.length;if(!k)Y=F[0];else{Y=D[0];for(var j=0;j<k;j++){var q=D[j],W=D[j+1],he=F[j];isNaN(he)||(W?Y+=he+W:Y+=he+" ")}}bE[M.type](x.target,M.property,Y,x.transforms),M.currentValue=Y,w++}}function g(b){l[b]&&!l.passThrough&&l[b](l)}function v(){l.remaining&&l.remaining!==!0&&l.remaining--}function y(b){var w=l.duration,S=l.delay,_=w-l.endDelay,M=h(b);l.progress=Ki(M/w*100,0,100),l.reversePlayback=M<l.currentTime,i&&m(M),!l.began&&l.currentTime>=0&&(l.began=!0,g("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,g("loopBegin")),M<=S&&l.currentTime!==0&&(p(0),g("change")),(M>=_&&l.currentTime!==w||!w)&&(p(w),g("change")),M>S&&M<_?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,g("changeBegin")),g("change"),p(M)):l.changeBegan?(l.changeCompleted=!0,l.changeBegan=!1,g("change"),g("changeComplete")):l.began&&M>_&&(g("change"),g("changeComplete")),l.currentTime=Ki(M,0,w),l.began&&g("update"),b>=w&&(t=0,v(),l.remaining?(e=n,g("loopComplete"),l.loopBegan=!1,l.direction==="alternate"&&c()):(l.paused=!0,l.completed||(l.completed=!0,g("loopComplete"),g("complete"),!l.passThrough&&"Promise"in window&&(o(),u=a(l)))))}return l.reset=function(){var b=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed=b==="reverse",l.remaining=l.loop,i=l.children,s=i.length;for(var w=s;w--;)l.children[w].reset();(l.reversed&&l.loop!==!0||b==="alternate"&&l.loop===1)&&l.remaining++,p(l.reversed?l.duration:0)},l.set=function(b,w){return wE(b,w),l},l.tick=function(b){n=b,e||(e=n),y((n+(t-e))*hn.speed)},l.seek=function(b){y(h(b))},l.pause=function(){l.paused=!0,d()},l.play=function(){!l.paused||(l.completed&&l.reset(),l.paused=!1,wr.push(l),d(),Pm||wV())},l.reverse=function(){c(),l.completed=!l.reversed,d()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function oE(r,e){for(var t=e.length;t--;)Y0(r,e[t].animatable.target)&&e.splice(t,1)}function AV(r){for(var e=vE(r),t=wr.length;t--;){var n=wr[t],i=n.animations,s=n.children;oE(e,i);for(var o=s.length;o--;){var a=s[o],l=a.animations;oE(e,l),!l.length&&!a.children.length&&s.splice(o,1)}!i.length&&!s.length&&n.pause()}}function _V(r,e){e===void 0&&(e={});var t=e.direction||"normal",n=e.easing?X0(e.easing):null,i=e.grid,s=e.axis,o=e.from||0,a=o==="first",l=o==="center",u=o==="last",c=je.arr(r),h=parseFloat(c?r[0]:r),d=c?parseFloat(r[1]):0,f=_s(c?r[1]:r)||0,m=e.start||0+(c?h:0),p=[],g=0;return function(v,y,b){if(a&&(o=0),l&&(o=(b-1)/2),u&&(o=b-1),!p.length){for(var w=0;w<b;w++){if(!i)p.push(Math.abs(o-w));else{var S=l?(i[0]-1)/2:o%i[0],_=l?(i[1]-1)/2:Math.floor(o/i[0]),M=w%i[0],x=Math.floor(w/i[0]),T=S-M,E=_-x,C=Math.sqrt(T*T+E*E);s==="x"&&(C=-T),s==="y"&&(C=-E),p.push(C)}g=Math.max.apply(Math,p)}n&&(p=p.map(function(O){return n(O/g)*g})),t==="reverse"&&(p=p.map(function(O){return s?O<0?O*-1:-O:Math.abs(g-O)}))}var P=c?(d-h)/g:h;return m+P*(Math.round(p[y]*100)/100)+f}}function TV(r){r===void 0&&(r={});var e=hn(r);return e.duration=0,e.add=function(t,n){var i=wr.indexOf(e),s=e.children;i>-1&&wr.splice(i,1);function o(d){d.passThrough=!0}for(var a=0;a<s.length;a++)o(s[a]);var l=Om(t,W0(q0,r));l.targets=l.targets||r.targets;var u=e.duration;l.autoplay=!1,l.direction=e.direction,l.timelineOffset=je.und(n)?u:$0(n,u),o(e),l.rewind=e.rewind,e.seek(l.timelineOffset);var c=hn(l);o(c),s.push(c);var h=SE(s,r);return e.delay=h.delay,e.endDelay=h.endDelay,e.duration=h.duration,e.seek(0),e.reset(),e.autoplay&&e.play(),e},e}hn.version="3.2.0";hn.speed=1;hn.running=wr;hn.remove=AV;hn.get=J0;hn.set=wE;hn.convertPx=Z0;hn.path=hV;hn.setDashoffset=cV;hn.stagger=_V;hn.timeline=TV;hn.easing=X0;hn.penner=uE;hn.random=function(r,e){return Math.floor(Math.random()*(e-r+1))+r};var tx=hn;var AE=new A,_E=new A,TE=new nt;function ME(r,e,t,n){if(n===0)return t.copy(r);if(n===1)return t.copy(e);let i=r.w*e.w+r.x*e.x+r.y*e.y+r.z*e.z;if(i>=1)return t.copy(r);let s=1-i*i;if(s<=Number.EPSILON){let c=1-n;return t.w=c*r.w+n*e.w,t.x=c*r.x+n*e.x,t.y=c*r.y+n*e.y,t.z=c*r.z+n*e.z,t.normalize(),t}let o=Math.sqrt(s),a=Math.atan2(o,i),l=Math.sin((1-n)*a)/o,u=Math.sin(n*a)/o;return t.w=r.w*l+e.w*u,t.x=r.x*l+e.x*u,t.y=r.y*l+e.y*u,t.z=r.z*l+e.z*u,t}function Rm(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(s==null)return;let o=i??e[r],a=s;if(o!==a)return{update:l=>{e[r]=Be.lerp(o,a,l)},start:()=>{e[r]=o},end:()=>{e[r]=a}}}function nx(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=e[r],a=i?new A().fromArray(i):o.clone(),l=new A().fromArray(s);if(!a.equals(l))return{update:u=>{o.lerpVectors(a,l,u)},start:()=>{o.copy(a)},end:()=>{o.copy(l)}}}function EE(r,e,t,n){let i=t[r]?t[r]:void 0,s=n[r];if(!s)return;let o=e[r],a=i?new be().fromArray(i):o.clone(),l=new A,u=new nt,c=new A;a.decompose(l,u,c);let h=new be().fromArray(s),d=new A,f=new nt,m=new A;if(h.decompose(d,f,m),!a.equals(h))return{update:p=>{TE.slerpQuaternions(u,f,p),AE.lerpVectors(l,d,p),_E.lerpVectors(c,m,p),o.compose(AE,TE,_E)},start:()=>{o.compose(l,u,c)},end:()=>{o.compose(d,f,m)}}}function CE(r,e,t,n,i){let s=t[r]?t[r]:void 0,o=n[r];if(!o)return;let a=e[r],l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return e[r]=c,{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function PE(r,e,t){let n=[],i=r.cameraType==="OrthographicCamera"?e.orthographic?.zoom:e.perspective?.zoom,s=r.cameraType==="OrthographicCamera"?t.orthographic?.zoom:t.perspective?.zoom;if(s!==void 0){let o=i??r.zoom,a=s;o!==a&&n.push({update:l=>{r.zoom=Be.lerp(o,a,l),r.updateProjectionMatrix()},start:()=>{r.zoom=o,r.updateProjectionMatrix()},end:()=>{r.zoom=a,r.updateProjectionMatrix()}})}if(t.targetOffset!==void 0){let o=Rm("targetOffset",r,e,t);o&&n.push(o)}return n}function DE(r,e,t){let n=[];if(!("geometry"in t))return n;let i="geometry"in e?e.geometry:{},s=t.geometry,{width:o,height:a,depth:l}=i,{width:u,height:c,depth:h}=s;if(u!==void 0||c!==void 0||h!==void 0){let{width:d,height:f,depth:m}=r.geometry.userData.parameters,p=o??d,g=a??f,v=l??m,y=u??d,b=c??f,w=h??m;(p!==y||g!==b||v!==w)&&!Vt(r)&&n.push({update:S=>{r.updateGeometry({parameters:{width:Be.lerp(p,y,S),height:Be.lerp(g,b,S),depth:Be.lerp(v,w,S)}}),r.invalidateDownstreamBooleanData()},start:()=>{r.updateGeometry({parameters:{width:p,height:g,depth:v}}),r.invalidateDownstreamBooleanData()},end:()=>{r.updateGeometry({parameters:{width:y,height:b,depth:w}}),r.invalidateDownstreamBooleanData()}})}return n}function IE(r,e,t,n){let i=[];if(t.intensity!==void 0){let s=Rm("intensity",r,e,t);s&&i.push(s)}if(t.color!==void 0){let s=CE("color",r,e,t,n);s&&i.push(s)}return i}function LE(r,e,t,n){let i=[];if(!("material"in t||"materials"in t))return i;let s;if("materials"in e?s=e.materials?.[0]:"material"in e?s=e.material:s={},!s||typeof s=="string")return i;let o;if("materials"in t?o=t.materials?.[0]:"material"in t&&(o=t.material),!o||typeof o=="string")return i;let a=Array.isArray(r.material)?r.material[0]:r.material;return MV(a,s,o,n)}function MV(r,e,t,n){let i=[];for(let s of r.layers){let o=e.layers?.data(s.uuid),a=t.layers.data(s.uuid);if(!a||!(s.visible??!0)||!(a.visible??!0))continue;let l=s.getNames().filter(u=>!mp.some(c=>u.includes(c)));for(let u of l)try{let c=s.getValue(u),h;if(u==="colors")h=OV(s,o,a,u);else if(Array.isArray(c))u==="steps"&&(h=LV(s,o,a,u));else if(typeof c=="number")h=EV(s,o,a,u);else{if(typeof c=="boolean")continue;c instanceof B?h=CV(s,o,a,u):c instanceof A?h=PV(s,o,a,u):c instanceof $t?h=IV(s,o,a,u,n):c instanceof Le?h=DV(s,o,a,u,n):"isTexture"in c&&(h=RV(s,o,a,u))}h&&(Array.isArray(h)?i.push(...h):i.push(h))}catch(c){console.error(`lerpMaterial: unexpected material layer for ${u}`,c)}}return i}function EV(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=e?e[n]:r.getValue(n),s=t[n];if(i!==s)return{update:o=>{r.setValue(n,Be.lerp(i,s,o))},start:()=>{r.setValue(n,i)},end:()=>{r.setValue(n,s)}}}function CV(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=r.getValue(n),s=e?new B().fromArray(e[n]):i.clone(),o=new B().fromArray(t[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function PV(r,e,t,n){if(!r.hasValue(n)||!(n in t))return;let i=r.getValue(n),s=e?new A().fromArray(e[n]):i.clone(),o=new A().fromArray(t[n]);if(!s.equals(o))return{update:a=>{i.lerpVectors(s,o,a)},start:()=>{i.copy(s)},end:()=>{i.copy(o)}}}function DV(r,e,t,n,i){if(!r.hasValue(n)||!(n in t))return;let s=e?e[n]:void 0,o=t[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new Le().setRGB(o.r,o.g,o.b);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function IV(r,e,t,n,i){if(!r.hasValue(n)||!(n in t))return;let s=e?e[n]:void 0,o=t[n],a=r.getValue(n),l=s?typeof s=="string"?i.getColor(s).clone():new Le().setRGB(s.r,s.g,s.b):a.clone(),u=typeof o=="string"?i.getColor(o).clone():new $t(o.r,o.g,o.b,o.a);if(l.equals(u))return;let c=a.clone();return r.setValue(n,c),{update:h=>{c.lerpColors(l,u,h)},start:()=>{c.copy(l)},end:()=>{c.copy(u)}}}function LV(r,e,t,n="steps"){if(!r.hasValue(n)||!(n in t))return;let i=[],s=r.getValue(n),o=e?e[n]:s,a=t[n];for(let l=0;l<s.length;++l){let u=o[l],c=a[l];u!==c&&i.push({update:h=>{s[l]=Be.lerp(u,c,h)},start:()=>{s[l]=u},end:()=>{s[l]=c}})}return i.length?i:void 0}function OV(r,e,t,n="colors"){if(!r.hasValue(n)||!(n in t))return;let i=[],s=r.getValue(n),o=e?e[n]:s.map(l=>l.toArray()),a=t[n];for(let l=0;l<s.length;++l){let u=[...o[l]],c=[...a[l]];th.isEqual(u,c)||i.push({update:h=>{s[l].fromArray(th.lerp(u,c,h))},start:()=>{s[l].fromArray(u)},end:()=>{s[l].fromArray(c)}})}return i.length?i:void 0}function RV(r,e,t,n="texture"){if(!r.hasValue(n)||!(n in t))return;let i=r.getNode("mat");if(!i)return;let s=e?e[n]:i,o=t[n],a=[...s.repeat],l=[...s.offset],u=[...o.repeat],c=[...o.offset];if(!ra.isEqual(a,u)||!ra.isEqual(l,c))return{update:h=>{i.repeat=ra.lerp(a,u,h),i.offset=ra.lerp(l,c,h),i.updateMatrix()},start:()=>{i.repeat=[...a],i.offset=[...l],i.updateMatrix()},end:()=>{i.repeat=[...u],i.offset=[...c],i.updateMatrix()}}}var rx=new A,OE=new Qt;function RE(r,e,t,n){let i=[],s=nx("position",r,e,t);s&&i.push(s);let o=nx("scale",r,e,t);o&&i.push(o);let a=NV(r,e,t,n);a&&i.push(a);let l=EE("hiddenMatrix",r,e,t);if(l&&i.push(l),s||o||a||l){let u=()=>{r.updateMatrix(),r.parent?.matrixWorldFusedFalse&&(r.matrixWorld.multiplyMatrices(r.parent.matrixWorldFusedFalse,r.matrix),r.matrixWorldNeedsUpdate=!1),kt(r)&&Vt(r.parent)&&r.invalidateDownstreamBooleanData(!0)};i.push({update:u,start:u,end:u})}return i}function NV(r,e,t,n){let i=e?.rotation?e.rotation:void 0,s=t.rotation;if(!s)return;let o=i?new A().fromArray(i):new A().setFromEuler(r.rotation),a=new A().fromArray(s);if(o.equals(a))return;let l=rx.subVectors(a,o);if(n&&l.toArray().every(u=>Math.abs(u)<2*Math.PI)){let u=new nt().setFromEuler(OE.setFromVector3(o)),c=new nt().setFromEuler(OE.setFromVector3(a));return{update:h=>{ME(u,c,r.quaternion,h)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}else return{update:u=>{rx.lerpVectors(o,a,u),r.rotation.setFromVector3(rx)},start:()=>{r.rotation.setFromVector3(o)},end:()=>{r.rotation.setFromVector3(a)}}}function Nm(r,e,t,n,i){let s=[];return(r.visible||Vt(r.parent))&&s.push(...RE(r,e,t,i)),kt(r)?((r.visible||Vt(r.parent))&&s.push(...DE(r,e,t)),r.visible&&s.push(...LE(r,e,t,n))):UT(r)?r.visible&&s.push(...IE(r,e,t,n)):FT(r)&&s.push(...PE(r,e,t)),s.length?{update:o=>{s.forEach(a=>a.update(o))},start:o=>{s.forEach(a=>a.start?.(o))},end:o=>{s.forEach(a=>a.end?.(o))}}:void 0}var ix=new A,FV=new nt;function NE(r,e,t){let n=[];r.objects.traverse((i,s)=>{let o=e.find(i);if(!!o&&(o.states={},!!s.states)){n.some(l=>r.objects.isDescendantOf(i,l))||s.physics?.fusedBody===!0&&s.physics.rigidBody==="dynamic"&&n.push(i),o.data=s,o.currentState=null,o.currentTransitionAction=null;for(let l of s.states){if(r.environment.usePhysics===!0&&s.physics&&(s.physics.rigidBody==="dynamic"||n.some(u=>r.objects.isDescendantOf(i,u)))&&(l.data.position!==void 0||l.data.rotation!==void 0||l.data.hiddenMatrix!==void 0))return;o.states[l.id]=rh.patch(s,l.data)}if(o.matrixWorld0!==void 0||o.hiddenMatrix0){if(o.hiddenMatrix0?(o.hiddenMatrix.copy(o.hiddenMatrix0),o.hiddenMatrix.premultiply(o.parent.matrixWorld0)):(o.matrixWorld.identity(),o.rigidBody?.setTranslation(ix,!0),o.rigidBody?.setRotation(FV,!0),o.rigidBody?.setLinvel(ix,!0),o.rigidBody?.setAngvel(ix,!0)),o instanceof wt&&s.type==="Mesh"){if("material"in s){if(o.material instanceof Array)return;Bm(o.material,s.material,t)}else if("materials"in s){if(!(o.material instanceof Array))return;var a=0;for(let l of s.materials)Bm(o.material[a],l,t),a++}}return}sx(o,s,null,t,s.events.find(l=>l.data.type==="Follow"||l.data.type==="LookAt")!==void 0)}})}function Bm(r,e,t){typeof e!="string"&&r.reset(e,t)}function sx(r,e,t,n,i=!1){if(!i&&e.states.length===0)return;let s=t===null?e:rh.patch(e,e.states.data(t));if(d0(r,s),r instanceof wt&&s.type==="Mesh"){if(r instanceof xo?r.buildFromStore(s.geometry):r.updateGeometry({parameters:s.geometry},n),r.freeBooleanPointer(),Vt(r.parent)&&r.parent.invalidateDownstreamBooleanData().recomputeBoolean(),"material"in s){if(r.material instanceof Array)return;Bm(r.material,s.material,n)}else if("materials"in s){if(!(r.material instanceof Array))return;var o=0;for(let a of s.materials)Bm(r.material[o],a,n),o++}}else if(s.type==="DirectionalLight")r.fromDirectionalLightState(s,n);else if(s.type==="PointLight")r.fromPointLightState(s,n);else if(s.type==="SpotLight")r.fromSpotLightState(s,n);else if(r instanceof zn&&Ri.is(s.type)){let a=s;r.setZoom("PerspectiveCamera",a.perspective.zoom),r.setZoom("OrthographicCamera",a.orthographic.zoom),r.isUpVectorFlipped=a.isUpVectorFlipped,r.targetOffset=a.targetOffset,r.fov=a.perspective.fov}}function UV(r){let e={duration:r.duration,easing:"linear"};switch(r.easing){case 0:e.easing="cubicBezier( 0, 0, 1, 1 )";break;case 1:e.easing="cubicBezier( .25, .1, .25, 1 )";break;case 2:e.easing="cubicBezier( .42, 0, 1, 1 )";break;case 3:e.easing="cubicBezier( 0, 0, .58, 1 )";break;case 4:e.easing="cubicBezier( .42, 0, .58, 1 )";break;case 5:let{control1:t,control2:n}=r;e.easing=`cubicBezier(
4912
4913
  ${t[0]}, ${t[1]}, ${n[0]}, ${n[1]}
4913
- )`;break;case 6:let{mass:i,stiffness:s,damping:o,velocity:a}=r;e.easing=`spring( ${i}, ${s}, ${o}, ${a} )`}return e}function GV(r){let e={startOnceDelay:0,delay:0,repeatDelay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)e.direction="normal",e.rewind=r.direction==="pingpong-rewind";else switch(r.direction){case"pingpong":e.direction="alternate",e.rewind=!1;break;case"pingpong-rewind":e.direction="alternate",e.rewind=!0;break;default:e.direction="normal",e.rewind=!1;break}switch(r.delayDirection){case"start-once":break;case"start":e.delay=r.delay;break;case"end":e.endDelay=r.delay;break;case"start-end":case void 0:e.delay=r.delay,e.endDelay=r.delay;break}return e}var ox=class{constructor(e,t,n,i,s,o,a){this.object=e;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.id=a;this.targets={t:0};this.firstLoop=!0;this.firstReverse=!0;this.reversed=!1;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{let e,t;this.reversed?(e=this.to,t=this.from):(e=this.from,t=this.to),this.object.currentState=t.id,this.object.dispatchEvent({type:"beginState",state:this.targets.t>.5?e.id:t.id})};this.onChangeComplete=()=>{let e,t;this.reversed?(e=this.to,t=this.from):(e=this.from,t=this.to),this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.currentState=t.id,this.object.dispatchEvent({type:"completeState",state:this.targets.t<.5?e.id:t.id})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=Nm(this.object,this.reversed?this.to.data:this.from.data,this.reversed?this.from.data:this.to.data,this.sharedAssets,this.allowSlerp))};let l=this.getState(t);if(!l)throw new Error("Missing property");this.from=l;let u=this.getState(n);if(!u)throw new Error("Missing property");this.to=u,this.useCurrentState=t===void 0||n===void 0;let c={};this.object.hiddenMatrix0&&(c.hiddenMatrix=this.object.hiddenMatrix0.elements),this.callback=Nm(this.object,t===void 0?c:this.from.data,n===void 0?c:this.to.data,this.sharedAssets,this.allowSlerp),this.core={targets:this.targets,t:1,autoplay:!1,...GV(i),...UV(i),change:this.onChange},this.startOnceDelay=i.delayDirection==="start-once"?i.delay:0}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}getState(e){let t,n;if(typeof e=="string"?(t=e,n=this.object.states[t]):e===null?(t=null,n=this.object.data):e===void 0&&(t=this.object.currentState,n=t?this.object.states[t]:this.object.data),!(t===void 0||n===void 0))return{id:t,data:n}}toggle(e){this._changeBegan=!1,this._changeCompleted=!0,this.reversed=!e,this.targets.t=0,this.firstReverse?(this.firstReverse=!1,this.reversed=!1):this.callback=Nm(this.object,{},e?this.to.data:this.from.data,this.sharedAssets,this.allowSlerp)}},od=class{constructor(e,t,n,i){this.object=t;this.id=i;this.tweens=[];this._finished=!1;if(e.tweens.length<1)throw new Error("Missing property");try{let s=new ox(t,e.tweens[0].data.state,e.tweens[1].data.state,e.tweens[1].data,n,e.allowSlerp??!1,"0");this.tween=s,this.core=tx({...s.core}),this.core.finished.then(()=>this._finished=!0),this.startOnceDelay=s.startOnceDelay}catch{throw new Error("Missing property")}}get finished(){return this._finished}get paused(){return this.core.paused}play(){this._finished||(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>this.core.play(),this.startOnceDelay))}pause(){this.core.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.pause(),this.seek(0),this.core.reset(),this._finished=!1}seek(e){let t=e*this.core.duration;this.core.seek(t)}toggle(e){this.core.pause(),clearTimeout(this.timeoutId),this.tween.toggle(e),this.core=tx({...this.tween.core}),this.core.finished.then(()=>this._finished=!0),this.tween.changeCompleted?this.timeoutId=window.setTimeout(()=>this.core.play(),this.startOnceDelay):this.core.play()}dispose(){this.pause()}},$i=class extends Lt{constructor(t,n,i,s){super();this.id=t;this.data=n;this.sharedAssets=s;if(!n.object)throw new Error("Missing property");let o=i.find(n.object);if(!o)throw new Error("Missing property");this.object=o;try{this.timeline=new od(this.data,this.object,this.sharedAssets,"0")}catch{throw new Error("Missing property")}}play(){this.object.currentTransitionAction!==this&&(this.object.currentTransitionAction?.dispose(),this.object.currentTransitionAction=this,this.timeline=new od(this.data,this.object,this.sharedAssets,"0"),this.dispatchEvent({type:"reset"})),this.timeline.play()}stop(){this.timeline.stop()}seek(t){this.timeline.seek(t)}toggle(t){this.object.currentTransitionAction!==this&&(this.object.currentTransitionAction?.dispose(),this.object.currentTransitionAction=this,this.timeline=new od(this.data,this.object,this.sharedAssets,"0"),this.dispatchEvent({type:"reset"})),this.timeline.toggle(t)}dispose(){this.timeline.dispose()}};function Nr(r,e,t,n,i){let s={Audio:[],Link:[],Transition:[]};return e.forEach(({id:o,data:a})=>{try{a.type==="Audio"?cp[r.type].includes("Audio")&&s.Audio.push(new Zi(o,a,t,i)):a.type==="Link"?cp[r.type].includes("Link")&&s.Link.push(new Cm(a)):a.type==="Transition"&&cp[r.type].includes("Transition")&&s.Transition.push(new $i(o,a,n,i))}catch{}}),s}function Br(r){Object.values(r).forEach(e=>{e.forEach(t=>{(t instanceof Zi||t instanceof $i)&&t.dispose()})})}var ax=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],BE=r=>ax.find(([e,t])=>t===r)?.[0],Ao=r=>ax.find(([e])=>e===r)?.[1],zV=(r,e)=>{let t=BE(r);if(t){let n=new CustomEvent(t,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:e}),n}},Fm=class extends Bn{constructor(t){super(t);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=t=>{if(!t.eventName||!t.target)return;let n=this.splineEvents[BE(t.eventName)]?.[t.target.uuid];if(!n)return;t.eventName==="Scroll"&&t.deltaY!==void 0&&Object.assign(n,{deltaY:t.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of ax)if(i.data.events.some(a=>a.data.type===o)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=zV(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var lx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.isToggleEnable=!1;this.onReset=()=>{this.isToggleEnable=!0};if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp")&&!e.key)throw new Error("Missing property");this.actions=Nr(e,e.actions,t,n,i),this.actions.Transition.forEach(s=>{s.addEventListener("reset",this.onReset)})}disconnect(){Br(this.actions)}dispatch(){this.useToggle?(this.isToggleEnable=!this.isToggleEnable,this.actions.Transition.forEach(e=>{e.toggle(this.isToggleEnable)})):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()})}},Um=class extends Bn{constructor(t){super(t);this.objectsPerTypes={MouseDown:[],MouseUp:[],KeyDown:[],KeyUp:[]};this.eventsPerObjects={MouseDown:{},MouseUp:{},KeyDown:{},KeyUp:{}};this.heldKeys={};this.onMouseDown=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseDown"))};this.onMouseUp=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseUp"))};this.onKeyDown=t=>{this.heldKeys[t.key]||this.handleKeyEvent(t,"KeyDown"),this.heldKeys[t.key]=!0};this.onKeyUp=t=>{this.handleKeyEvent(t,"KeyUp")};this.releaseHeldKey=t=>{delete this.heldKeys[t.key]};this._onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&(s==="MouseDown"||s==="MouseUp"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!s.data?.events.length)return;let o=s.visible?["MouseDown","MouseUp","KeyDown","KeyUp"]:["KeyDown","KeyUp"];for(let a of o){let l=this.eventsPerObjects[a];s.data.events.filter(({data:u})=>u.type===a).forEach(({data:u})=>{try{let c=new lx(u,s,n,i);l[s.uuid]?l[s.uuid].push(c):l[s.uuid]=[c]}catch{}}),l[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:t}=this.eventContext;this.heldKeys={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(n=>{Object.values(n).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(t){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[t];if(!!o.length)if(n){let a=Mm(i,s,o);Em(a).forEach(l=>{this.eventsPerObjects[t][l.uuid]&&this.handleObjectMouseEventDispatch(l,t)})}else o.forEach(a=>{rd(i,a)&&this.handleObjectMouseEventDispatch(a,t)})}handleObjectMouseEventDispatch(t,n){t.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[t.uuid]?.forEach(i=>{i.dispatch()})}handleKeyEvent(t,n){this.objectsPerTypes[n].forEach(i=>{let s=this.eventsPerObjects[n][i.uuid];s.some(({data:o})=>"key"in o&&o.key===t.key)&&i.dispatchEvent({type:"beginEvent",eventName:n}),s.forEach(o=>{"key"in o.data&&o.data.key===t.key&&o.dispatch()})})}};var kV=new A,VV=new A,cx=new be,ux=new be;var Gm=class{constructor(e,t,n,i){this.actionsIn=Nr(e,e.inActions,t,n,i),this.actionsOut=Nr(e,e.outActions,t,n,i)}disconnect(){Br(this.actionsIn),Br(this.actionsOut)}};var hx=class extends Gm{constructor(t,n,i,s){super(t,n,i,s);this.data=t;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{cx.copy(this.objects[0].matrixWorld),this.objects[0].matrixWorld0&&cx.multiply(this.objects[0].matrixWorld0);let t=kV.setFromMatrixPosition(cx);ux.copy(this.objects[1].matrixWorld),this.objects[1].matrixWorld0&&ux.multiply(this.objects[1].matrixWorld0);let n=VV.setFromMatrixPosition(ux),i=t.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){this.stage=i;let s=this.stage==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Transition.forEach(o=>o.play())}};let{distance:o,fromObject:a,toObject:l}=t.condition;this.distance=o;for(let u of[a,l]){if(!u)throw new Error("Missing property");let c=i.find(u);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){this.objects.forEach(t=>{t.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(t=>{t.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},dx=class extends Gm{constructor(t,n,i,s){super(t,n,i,s);this.data=t;this.object=n;this.onBegin=({target:t,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Transition.forEach(i=>i.play()))};this.onComplete=({target:t,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Transition.forEach(i=>i.play()))};let{condition:o}=t;if(!o.object)throw new Error("Missing property");let a=i.find(o.object);if(!a)throw new Error("Missing property");if(this.toObject=a,o.state&&!this.toObject.states[o.state])throw new Error("Missing property");this.toState=o.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},zm=class extends Bn{constructor(t){super(t);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length){for(let{data:o}of s.data.events)if(o.type==="Conditional")try{let a;o.condition.type==="Comparison"||(o.condition.type==="Distance"?a=new hx(o,s,n,i):o.condition.type==="State"&&(a=new dx(o,s,n,i))),a&&this.eventsPerConditions[o.condition.type].push(a)}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.disconnect()))}};var fx=new A,FE=new mn,UE=new be,px=new A,mx=class{constructor(e,t){this.data=e;this.object=t}dispatch(e,t){FE.setFromNormalAndCoplanarPoint(e,this.object.getWorldPosition(fx)),t.ray.intersectPlane(FE,fx),this.object.position.copy(fx),this.object.parent!==null&&this.object.position.applyMatrix4(UE.copy(this.object.parent.matrixWorld).invert()),this.object.position.applyMatrix4(UE.copy(this.object.hiddenMatrix).invert()),this.object.updateMatrix(),kt(this.object)&&Vt(this.object.parent)&&this.object.invalidateDownstreamBooleanData(!0),this.object.dispatchEvent({type:"requestRender"})}},km=class extends Bn{constructor(t){super(t);this.events=[];this.onMouseMove=t=>{if($e.length>1)return;let{camera:n,raycaster:i}=this.eventContext;this.eventContext.updateRaycaster(t),n.getWorldDirection(px),px.negate(),this.events.forEach(s=>{s.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),s.dispatch(px,i)})};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="Follow");s&&this.events.push(new mx(s.data,i))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove)}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove)}};var GE=new A,zE=new mn,gx=new A,yx=class{constructor(e,t){this.data=e;this.object=t}dispatch(e,t){zE.set(e,-this.data.distance),t.ray.intersectPlane(zE,GE),this.object.lookAt(GE),this.object.updateMatrix(),kt(this.object)&&Vt(this.object.parent)&&this.object.invalidateDownstreamBooleanData(!0),this.object.dispatchEvent({type:"requestRender"}),this.object.dispatchEvent({type:"changeRotation"})}},Vm=class extends Bn{constructor(t){super(t);this.events=[];this.onMouseMove=t=>{if($e.length>1)return;let{camera:n,raycaster:i}=this.eventContext;this.eventContext.updateRaycaster(t),n.getWorldDirection(gx),gx.negate(),this.events.forEach(s=>{s.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),s.dispatch(gx,i)})};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt");s&&this.events.push(new yx(s.data,i))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove)}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove)}};var vx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.entered=!1;this.actions=Nr(e,e.actions,t,n,i)}disconnect(){Br(this.actions)}dispatchEnter(){this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.toggle(!0)))}dispatchLeave(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.toggle(!1)))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>t.toggle(!e))}},Hm=class extends Bn{constructor(t){super(t);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onMouseUp=t=>{$e.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{data:o}of s.data.events)if(o.type==="MouseHover")try{let a=new vx(o,s,n,i);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(a):this.eventsPerObjects[s.uuid]=[a]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp)),t.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(t=!1){let n=[];if(!t){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=Mm(s,o,this.objects);n=Em(a)}else this.objects.forEach(a=>{rd(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var xx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.scrollCounter=0;this.actions=Nr(e,e.actions,t,n,i)}connect(){this.scrollCounter=0}disconnect(){Br(this.actions)}dispatch(e){let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(n))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)})}},Wm=class extends Bn{constructor(t){super(t);this.eventsPerObject=new Map;this.onWheel=t=>{[...this.eventsPerObject.entries()].forEach(([n,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:t.deltaY}),i.forEach(s=>s.dispatch(t.deltaY))})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{data:o}of s.data.events){if(o.type!=="Scroll")continue;let a=new xx(o,s,n,i);this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(a):this.eventsPerObject.set(s,[a])}})}connect(){let{domElement:t}=this.eventContext;[...this.eventsPerObject.entries()].forEach(([n,i])=>{i.forEach(s=>s.connect()),n.addEventListener("userEvent",this.onUserEvent)}),[...this.eventsPerObject.values()].some(n=>n.length)&&(this.domEventsNeeded.add("wheel"),t.addEventListener("wheel",this.onWheel))}disconnect(){let{domElement:t}=this.eventContext;t.removeEventListener("wheel",this.onWheel),this.domEventsNeeded.clear(),[...this.eventsPerObject.entries()].forEach(([n,i])=>{i.forEach(s=>s.disconnect()),n.removeEventListener("userEvent",this.onUserEvent)})}};var bx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.actions=Nr(e,e.actions,t,n,i)}disconnect(){Br(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof As?t.interaction.audioPlayer.play():t.interaction instanceof qc&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Audio.forEach(t=>{t.interaction instanceof As?t.interaction.audioPlayer.play():t.interaction instanceof qc&&t.interaction.dispatch()})}},jm=class extends Bn{constructor(t){super(t);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:t,isExport:n}=this.eventContext;(n?document:t).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{data:o}of s.data.events){if(o.type!=="Start")continue;let a=new bx(o,s,n,i);a.actions.Transition.length&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(a):this.eventsPerObject.set(s,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(a):this.eventsAfterPerObject.set(s,[a]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)})}[...this.eventsPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([t,n])=>{t.removeEventListener("userEvent",this.onUserEvent),n.forEach(i=>i.disconnect())})}};var qm=class{constructor(e,t,n,i){this.data=e;this.object=t;this.isToggleEnable=!1;this.actions=Nr(e,e.actions,t,n,i),this.target=e.target,this.useToggle=e.toggle}disconnect(){Br(this.actions)}dispatch(){this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.isToggleEnable=!this.isToggleEnable,this.actions.Transition.forEach(e=>{e.toggle(this.isToggleEnable)})):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()})}};var en;i1.then(r=>en=r);var wa=new be,HV=new A(1,1,1),Qn=new A,Ts=new nt,_o=new A,wx=new Qt(0,0,0,"YXZ"),WV={type:"updateMatrix"},Sx={type:"beginEvent",eventName:"Collision"},Xm=class{constructor(e,t,n,i,s,o=!1){this.scene=t;this.sharedAssets=s;this.isExport=o;this.gameControls=[];this.gameControlStates=[];this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{}};this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.processRigidBody=e=>{if(e.bodyType()!==en.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let t=e.translation(),n=e.rotation(),i=this.rigidBodyToMesh.get(e.handle);if(Qn.set(t.x,t.y,t.z),Qn.multiplyScalar(this.pixelsPerMeter),Ts.set(n.x,n.y,n.z,n.w),i[0].matrixWorld.compose(Qn,Ts,i[1]),i[0].dispatchEvent(WV),i[2])for(let s of i[0].children)s.updateMatrixWorld(!0)};this.handleCollisionEvents=(e,t,n)=>{if(n!==!1)if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[e])){let i=this.sharedGameControlGlobals.colliderToEntity[t],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[t])){let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else{let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let l of s)l.data.target==="scene"&&this.dispatchCollisionEvent(l,i);let o=this.sharedGameControlGlobals.colliderToEntity[t],a=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(a===void 0)return;for(let l of a)l.data.target==="scene"&&this.dispatchCollisionEvent(l,o)}};this.domElement=n.domElement;let a;e.scene.publish.playCamera===null?a=Ss.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let l=this.scene.find(a),u=!1,c=!1,h,d=5,f=8,m=9,p="drag";if(this.usePhysics=e.scene.environment.usePhysics??qr.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??qr.defaultData.pixelsPerMeter,this.sceneGraph=e.scene.objects,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(y=>{y.data.type==="GameControl"&&(h=y.data.keyAssignments,d=y.data.joystickPosLoc,f=y.data.joystickRotLoc,m=y.data.jumpTouchButtonLoc,p=y.data.rotByTouch)}),this.sceneGraph.traverse((y,w)=>{w.events.forEach(b=>{if(b.data.type!=="GameControl")return;let S=this.scene.find(y),_=S;for(;(_=_.parent)?.parent!==null;)if(this.sceneGraph.data(_.uuid)?.physics?.fusedBody)return;b.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([S,w,b.data])})}),this.usePhysics&&(this.gameControlStates.length===0||this.needsCollisionDetection)&&this.initPhysics(e.scene.environment.gravity??qr.defaultData.gravity),this.gameControlStates.forEach(([y,w,b])=>{Ri.is(w.type)&&(c=!0),u=u||b.camera===l.uuid;let S=new ad(y,e.scene.objects,n.domElement,{...b,keyAssignments:h},e.scene.environment,this.sharedGameControlGlobals,b.camera===l.uuid,l,this.scene,s);S.addEventListener("change",i),S.addEventListener("end",i),S.addEventListener("start",i),this.gameControls.push(S),vn&&b.touchControl&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([S,"pos"]):this.joystickToGameControls[d]=[[S,"pos"]],b.moveMode==="walk"&&(this.joystickToGameControls[m]!==void 0?this.joystickToGameControls[m].push([S,"jmp"]):this.joystickToGameControls[m]=[[S,"jmp"]]),p==="joystick"&&(this.joystickToGameControls[f]!==void 0?this.joystickToGameControls[f].push([S,"rot"]):this.joystickToGameControls[f]=[[S,"rot"]]))}),u===!1){let{enableRotate:y,enablePan:w,enableZoom:b,autoRotate:S,hoverRotatePanMode:_}=e.scene.publish.orbitControls;c===!1&&(y||w||b||S||_!==0)&&!Object.keys(l.states).length&&(this.orbitControls=new Xc(l,n.domElement,this.isExport),this.orbitControls.addEventListener("change",i),this.orbitControls.addEventListener("end",i),this.orbitControls.addEventListener("start",i),this.orbitControls.fromJSON(e.scene.publish.orbitControls),this.orbitControls.useKeyEvents=!1)}let g=n.domElement.width/n.getPixelRatio(),v=n.domElement.height/n.getPixelRatio();this.joystickToGameControls.forEach((y,w)=>{let b=document.body.appendChild(document.createElement("div")),[S,_,M]=(e.scene.publish.joystickSizeAndXYOffset??vs.defaultData.joystickSizeAndXYOffset)[w],x=(g-5*S)/4+S,T={},E=y.some(I=>I[1]==="jmp"),C=E?0:S;w<10?(w<5?T.top=C/2:T.bottom=C/2,T.left=C/2+w%5*x):w===10?(T.left=C/2,T.top=v/2):(T.right=C/2,T.top=v/2),T.top?T.top-=_[1]:T.bottom+=_[1],T.left?T.left+=_[0]:T.right-=_[0];for(let I in T)T[I]+="px";if(E){let I=b.appendChild(document.createElement("div"));Object.assign(I.style,T,{position:"absolute",width:S+"px",height:S+"px",backgroundColor:`rgba(255,255,255,${M==="show"?.4:0})`,zIndex:"9999",borderRadius:S+"px",border:"solid 2px rgba(0, 0, 0, .1)",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let N=S/16*16*.4;I.innerHTML=`
4914
+ )`;break;case 6:let{mass:i,stiffness:s,damping:o,velocity:a}=r;e.easing=`spring( ${i}, ${s}, ${o}, ${a} )`}return e}function GV(r){let e={startOnceDelay:0,delay:0,repeatDelay:0,loop:r.repeat===-1?!0:r.repeat+1};if(r.repeat===0)e.direction="normal",e.rewind=r.direction==="pingpong-rewind";else switch(r.direction){case"pingpong":e.direction="alternate",e.rewind=!1;break;case"pingpong-rewind":e.direction="alternate",e.rewind=!0;break;default:e.direction="normal",e.rewind=!1;break}switch(r.delayDirection){case"start-once":break;case"start":e.delay=r.delay;break;case"end":e.endDelay=r.delay;break;case"start-end":case void 0:e.delay=r.delay,e.endDelay=r.delay;break}return e}var ox=class{constructor(e,t,n,i,s,o,a){this.object=e;this.data=i;this.sharedAssets=s;this.allowSlerp=o;this.id=a;this.targets={t:0};this.firstLoop=!0;this.firstReverse=!0;this.reversed=!1;this._changeBegan=!1;this._changeCompleted=!0;this.onChange=()=>{this.callback&&(this.callback.update(this.targets.t),this.object.dispatchEvent({type:"requestRender"})),this.targets.t===0?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):this.targets.t===1?this._changeCompleted||(this._changeCompleted=!0,this._changeBegan=!1,this.onChangeComplete()):(this._changeCompleted&&(this._changeCompleted=!1),this._changeBegan||(this._changeBegan=!0,this.onChangeBegin()))};this.onChangeBegin=()=>{let e,t;this.reversed?(e=this.to,t=this.from):(e=this.from,t=this.to),this.object.currentState=t.id,this.object.dispatchEvent({type:"beginState",state:this.targets.t>.5?e.id:t.id})};this.onChangeComplete=()=>{let e,t;this.reversed?(e=this.to,t=this.from):(e=this.from,t=this.to),this.firstLoop&&(this.onFirstLoop(),this.firstLoop=!1),this.object.currentState=t.id,this.object.dispatchEvent({type:"completeState",state:this.targets.t<.5?e.id:t.id})};this.onFirstLoop=()=>{this.useCurrentState&&(this.callback=Nm(this.object,this.reversed?this.to.data:this.from.data,this.reversed?this.from.data:this.to.data,this.sharedAssets,this.allowSlerp))};let l=this.getState(t);if(!l)throw new Error("Missing property");this.from=l;let u=this.getState(n);if(!u)throw new Error("Missing property");this.to=u,this.useCurrentState=t===void 0||n===void 0;let c={};this.object.hiddenMatrix0&&(c.hiddenMatrix=this.object.hiddenMatrix0.elements),this.callback=Nm(this.object,t===void 0?c:this.from.data,n===void 0?c:this.to.data,this.sharedAssets,this.allowSlerp),this.core={targets:this.targets,t:1,autoplay:!1,...GV(i),...UV(i),change:this.onChange},this.startOnceDelay=i.delayDirection==="start-once"?i.delay:0}get changeBegan(){return this._changeBegan}get changeCompleted(){return this._changeCompleted}getState(e){let t,n;if(typeof e=="string"?(t=e,n=this.object.states[t]):e===null?(t=null,n=this.object.data):e===void 0&&(t=this.object.currentState,n=t?this.object.states[t]:this.object.data),!(t===void 0||n===void 0))return{id:t,data:n}}toggle(e){this._changeBegan=!1,this._changeCompleted=!0,this.reversed=!e,this.targets.t=0,this.firstReverse?(this.firstReverse=!1,this.reversed=!1):this.callback=Nm(this.object,{},e?this.to.data:this.from.data,this.sharedAssets,this.allowSlerp)}},od=class{constructor(e,t,n,i){this.object=t;this.id=i;this.tweens=[];this._finished=!1;if(e.tweens.length<1)throw new Error("Missing property");try{let s=new ox(t,e.tweens[0].data.state,e.tweens[1].data.state,e.tweens[1].data,n,e.allowSlerp??!1,"0");this.tween=s,this.core=tx({...s.core}),this.core.finished.then(()=>this._finished=!0),this.startOnceDelay=s.startOnceDelay}catch{throw new Error("Missing property")}}get finished(){return this._finished}get paused(){return this.core.paused}play(){this._finished||(clearTimeout(this.timeoutId),this.timeoutId=window.setTimeout(()=>this.core.play(),this.startOnceDelay))}pause(){this.core.pause(),clearTimeout(this.timeoutId),delete this.timeoutId}stop(){this.pause(),this.seek(0),this.core.reset(),this._finished=!1}seek(e){let t=e*this.core.duration;this.core.seek(t)}toggle(e){this.core.pause(),clearTimeout(this.timeoutId),this.tween.toggle(e),this.core=tx({...this.tween.core}),this.core.finished.then(()=>this._finished=!0),this.tween.changeCompleted?this.timeoutId=window.setTimeout(()=>this.core.play(),this.startOnceDelay):this.core.play()}dispose(){this.pause()}},$i=class extends Lt{constructor(t,n,i,s){super();this.id=t;this.data=n;this.sharedAssets=s;if(!n.object)throw new Error("Missing property");let o=i.find(n.object);if(!o)throw new Error("Missing property");this.object=o;try{this.timeline=new od(this.data,this.object,this.sharedAssets,"0")}catch{throw new Error("Missing property")}}play(){this.object.currentTransitionAction!==this&&(this.object.currentTransitionAction?.dispose(),this.object.currentTransitionAction=this,this.timeline=new od(this.data,this.object,this.sharedAssets,"0"),this.dispatchEvent({type:"reset"})),this.timeline.play()}stop(){this.timeline.stop()}seek(t){this.timeline.seek(t)}toggle(t){this.object.currentTransitionAction!==this&&(this.object.currentTransitionAction?.dispose(),this.object.currentTransitionAction=this,this.timeline=new od(this.data,this.object,this.sharedAssets,"0"),this.dispatchEvent({type:"reset"})),this.timeline.toggle(t)}dispose(){this.timeline.dispose()}};function Nr(r,e,t,n,i){let s={Audio:[],Link:[],Transition:[]};return e.forEach(({id:o,data:a})=>{try{a.type==="Audio"?cp[r.type].includes("Audio")&&s.Audio.push(new Zi(o,a,t,i)):a.type==="Link"?cp[r.type].includes("Link")&&s.Link.push(new Cm(a)):a.type==="Transition"&&cp[r.type].includes("Transition")&&s.Transition.push(new $i(o,a,n,i))}catch{}}),s}function Br(r){Object.values(r).forEach(e=>{e.forEach(t=>{(t instanceof Zi||t instanceof $i)&&t.dispose()})})}var ax=[["start","Start"],["keyDown","KeyDown"],["keyUp","KeyUp"],["mouseDown","MouseDown"],["mouseUp","MouseUp"],["mouseHover","MouseHover"],["collision","Collision"],["lookAt","LookAt"],["follow","Follow"],["scroll","Scroll"]],BE=r=>ax.find(([e,t])=>t===r)?.[0],Ao=r=>ax.find(([e])=>e===r)?.[1],zV=(r,e)=>{let t=BE(r);if(t){let n=new CustomEvent(t,{bubbles:!0});return Object.defineProperty(n,"target",{writable:!1,value:e}),n}},Fm=class extends Bn{constructor(t){super(t);this.objectsPerEvents=new Map;this.splineEvents={};this.onBeginEvent=t=>{if(!t.eventName||!t.target)return;let n=this.splineEvents[BE(t.eventName)]?.[t.target.uuid];if(!n)return;t.eventName==="Scroll"&&t.deltaY!==void 0&&Object.assign(n,{deltaY:t.deltaY});let{domElement:i}=this.eventContext;i.dispatchEvent(n)};let{scene:n}=this.eventContext;n.traverseEntity(i=>{if(!!i.data?.events.length){for(let[s,o]of ax)if(i.data.events.some(a=>a.data.type===o)){this.objectsPerEvents.has(s)?this.objectsPerEvents.get(s)?.push(i):this.objectsPerEvents.set(s,[i]);let a={id:i.uuid,name:i.name},l=zV(o,a),u=this.splineEvents[s];u?u[i.uuid]=l:this.splineEvents[s]={[i.uuid]:l}}}})}connect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.addEventListener("beginEvent",this.onBeginEvent)})})}disconnect(){this.objectsPerEvents.forEach(t=>{t.forEach(n=>{n.removeEventListener("beginEvent",this.onBeginEvent)})})}};var lx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.isToggleEnable=!1;this.onReset=()=>{this.isToggleEnable=!0};if(this.useToggle=e.toggle,(e.type==="KeyDown"||e.type==="KeyUp")&&!e.key)throw new Error("Missing property");this.actions=Nr(e,e.actions,t,n,i),this.actions.Transition.forEach(s=>{s.addEventListener("reset",this.onReset)})}disconnect(){Br(this.actions)}dispatch(){this.useToggle?(this.isToggleEnable=!this.isToggleEnable,this.actions.Transition.forEach(e=>{e.toggle(this.isToggleEnable)})):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Audio.forEach(t=>{t.dispatchBasic()})}},Um=class extends Bn{constructor(t){super(t);this.objectsPerTypes={MouseDown:[],MouseUp:[],KeyDown:[],KeyUp:[]};this.eventsPerObjects={MouseDown:{},MouseUp:{},KeyDown:{},KeyUp:{}};this.heldKeys={};this.onMouseDown=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseDown"))};this.onMouseUp=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseEvent("MouseUp"))};this.onKeyDown=t=>{this.heldKeys[t.key]||this.handleKeyEvent(t,"KeyDown"),this.heldKeys[t.key]=!0};this.onKeyUp=t=>{this.handleKeyEvent(t,"KeyUp")};this.releaseHeldKey=t=>{delete this.heldKeys[t.key]};this._onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&(s==="MouseDown"||s==="MouseUp"?(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent(i)})):(s==="KeyDown"||s==="KeyUp")&&(n.dispatchEvent({type:"beginEvent",eventName:s}),this.eventsPerObjects[s]?.[n.uuid]?.forEach(o=>{o.dispatchUserEvent()})))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!s.data?.events.length)return;let o=s.visible?["MouseDown","MouseUp","KeyDown","KeyUp"]:["KeyDown","KeyUp"];for(let a of o){let l=this.eventsPerObjects[a];s.data.events.filter(({data:u})=>u.type===a).forEach(({data:u})=>{try{let c=new lx(u,s,n,i);l[s.uuid]?l[s.uuid].push(c):l[s.uuid]=[c]}catch{}}),l[s.uuid]?.length&&this.objectsPerTypes[a].push(s)}})}connect(){let{domElement:t}=this.eventContext;this.heldKeys={},this.domEventsNeeded.clear(),this.objectsPerTypes.MouseDown?.length&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown)),this.objectsPerTypes.MouseUp?.length&&(this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.objectsPerTypes.KeyDown?.length&&(this.domEventsNeeded.add("keydown"),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.releaseHeldKey)),this.objectsPerTypes.KeyUp?.length&&(this.domEventsNeeded.add("keyup"),document.addEventListener("keyup",this.onKeyUp)),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.addEventListener("userEvent",this._onUserEvent)})})}disconnect(){let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),this.heldKeys={},t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("keyup",this.releaseHeldKey),Object.values(this.eventsPerObjects).forEach(n=>{Object.values(n).forEach(i=>{i.forEach(s=>{s.disconnect()})})}),Object.entries(this.objectsPerTypes).forEach(([n,i])=>{i.forEach(s=>{s.removeEventListener("userEvent",this._onUserEvent)})})}handleMouseEvent(t){let{stopRaycast:n,raycaster:i,scene:s}=this.eventContext,o=this.objectsPerTypes[t];if(!!o.length)if(n){let a=Mm(i,s,o);Em(a).forEach(l=>{this.eventsPerObjects[t][l.uuid]&&this.handleObjectMouseEventDispatch(l,t)})}else o.forEach(a=>{rd(i,a)&&this.handleObjectMouseEventDispatch(a,t)})}handleObjectMouseEventDispatch(t,n){t.dispatchEvent({type:"beginEvent",eventName:n}),this.eventsPerObjects[n]?.[t.uuid]?.forEach(i=>{i.dispatch()})}handleKeyEvent(t,n){this.objectsPerTypes[n].forEach(i=>{let s=this.eventsPerObjects[n][i.uuid];s.some(({data:o})=>"key"in o&&o.key===t.key)&&i.dispatchEvent({type:"beginEvent",eventName:n}),s.forEach(o=>{"key"in o.data&&o.data.key===t.key&&o.dispatch()})})}};var kV=new A,VV=new A,cx=new be,ux=new be;var Gm=class{constructor(e,t,n,i){this.actionsIn=Nr(e,e.inActions,t,n,i),this.actionsOut=Nr(e,e.outActions,t,n,i)}disconnect(){Br(this.actionsIn),Br(this.actionsOut)}};var hx=class extends Gm{constructor(t,n,i,s){super(t,n,i,s);this.data=t;this.object=n;this.stage="out";this.objects=[];this.onUpdateMatrix=()=>{cx.copy(this.objects[0].matrixWorld),this.objects[0].matrixWorld0&&cx.multiply(this.objects[0].matrixWorld0);let t=kV.setFromMatrixPosition(cx);ux.copy(this.objects[1].matrixWorld),this.objects[1].matrixWorld0&&ux.multiply(this.objects[1].matrixWorld0);let n=VV.setFromMatrixPosition(ux),i=t.distanceTo(n)<=this.distance?"in":"out";if(this.stage!==i){this.stage=i;let s=this.stage==="in"?this.actionsIn:this.actionsOut;s.Audio.forEach(o=>o.dispatchConditional()),s.Transition.forEach(o=>o.play())}};let{distance:o,fromObject:a,toObject:l}=t.condition;this.distance=o;for(let u of[a,l]){if(!u)throw new Error("Missing property");let c=i.find(u);if(!c)throw new Error("Missing property");this.objects.push(c)}}connect(){this.objects.forEach(t=>{t.addEventListener("updateMatrix",this.onUpdateMatrix)}),this.onUpdateMatrix()}disconnect(){super.disconnect(),this.stage="out",this.objects.forEach(t=>{t.removeEventListener("updateMatrix",this.onUpdateMatrix)})}},dx=class extends Gm{constructor(t,n,i,s){super(t,n,i,s);this.data=t;this.object=n;this.onBegin=({target:t,state:n})=>{this.toState!==n&&(this.actionsOut.Audio.forEach(i=>i.dispatchConditional()),this.actionsOut.Transition.forEach(i=>i.play()))};this.onComplete=({target:t,state:n})=>{this.toState===n&&(this.actionsIn.Audio.forEach(i=>i.dispatchConditional()),this.actionsIn.Transition.forEach(i=>i.play()))};let{condition:o}=t;if(!o.object)throw new Error("Missing property");let a=i.find(o.object);if(!a)throw new Error("Missing property");if(this.toObject=a,o.state&&!this.toObject.states[o.state])throw new Error("Missing property");this.toState=o.state}connect(){(this.actionsOut.Audio.length||this.actionsOut.Transition.length)&&this.toObject.addEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Transition.length)&&this.toObject.addEventListener("completeState",this.onComplete)}disconnect(){super.disconnect(),(this.actionsOut.Audio.length||this.actionsOut.Transition.length)&&this.toObject.removeEventListener("beginState",this.onBegin),(this.actionsIn.Audio.length||this.actionsIn.Transition.length)&&this.toObject.removeEventListener("completeState",this.onComplete)}},zm=class extends Bn{constructor(t){super(t);this.eventsPerConditions={Comparison:[],Distance:[],State:[]};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length){for(let{data:o}of s.data.events)if(o.type==="Conditional")try{let a;o.condition.type==="Comparison"||(o.condition.type==="Distance"?a=new hx(o,s,n,i):o.condition.type==="State"&&(a=new dx(o,s,n,i))),a&&this.eventsPerConditions[o.condition.type].push(a)}catch{}}})}connect(){super.connect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.connect()))}disconnect(){super.disconnect(),Object.values(this.eventsPerConditions).forEach(t=>t.forEach(n=>n.disconnect()))}};var fx=new A,FE=new mn,UE=new be,px=new A,mx=class{constructor(e,t){this.data=e;this.object=t}dispatch(e,t){FE.setFromNormalAndCoplanarPoint(e,this.object.getWorldPosition(fx)),t.ray.intersectPlane(FE,fx),this.object.position.copy(fx),this.object.parent!==null&&this.object.position.applyMatrix4(UE.copy(this.object.parent.matrixWorld).invert()),this.object.position.applyMatrix4(UE.copy(this.object.hiddenMatrix).invert()),this.object.updateMatrix(),kt(this.object)&&Vt(this.object.parent)&&this.object.invalidateDownstreamBooleanData(!0),this.object.dispatchEvent({type:"requestRender"})}},km=class extends Bn{constructor(t){super(t);this.events=[];this.onMouseMove=t=>{if($e.length>1)return;let{camera:n,raycaster:i}=this.eventContext;this.eventContext.updateRaycaster(t),n.getWorldDirection(px),px.negate(),this.events.forEach(s=>{s.object?.dispatchEvent({type:"beginEvent",eventName:"Follow"}),s.dispatch(px,i)})};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="Follow");s&&this.events.push(new mx(s.data,i))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove)}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove)}};var GE=new A,zE=new mn,gx=new A,yx=class{constructor(e,t){this.data=e;this.object=t}dispatch(e,t){zE.set(e,-this.data.distance),t.ray.intersectPlane(zE,GE),this.object.lookAt(GE),this.object.updateMatrix(),kt(this.object)&&Vt(this.object.parent)&&this.object.invalidateDownstreamBooleanData(!0),this.object.dispatchEvent({type:"requestRender"}),this.object.dispatchEvent({type:"changeRotation"})}},Vm=class extends Bn{constructor(t){super(t);this.events=[];this.onMouseMove=t=>{if($e.length>1)return;let{camera:n,raycaster:i}=this.eventContext;this.eventContext.updateRaycaster(t),n.getWorldDirection(gx),gx.negate(),this.events.forEach(s=>{s.object?.dispatchEvent({type:"beginEvent",eventName:"LookAt"}),s.dispatch(gx,i)})};let{scene:n}=this.eventContext;n.traverseEntity(i=>{let s=i.data?.events.find(o=>o.data.type==="LookAt");s&&this.events.push(new yx(s.data,i))})}connect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseMove)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove)}disconnect(){if(!this.events.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&t.removeEventListener("pointerdown",this.onMouseMove),t.removeEventListener("pointermove",this.onMouseMove)}};var vx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.entered=!1;this.actions=Nr(e,e.actions,t,n,i)}disconnect(){Br(this.actions)}dispatchEnter(){this.entered||(this.entered=!0,this.actions.Transition.forEach(e=>e.toggle(!0)))}dispatchLeave(){this.entered&&(this.entered=!1,this.actions.Transition.forEach(e=>e.toggle(!1)))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>t.toggle(!e))}},Hm=class extends Bn{constructor(t){super(t);this.eventsPerObjects={};this.objects=[];this._prevObjects=[];this.onMouseDown=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onMouseUp=t=>{$e.length>1||this.handleMouseHoverEvent(!0)};this.onMouseMove=t=>{$e.length>1||(this.eventContext.updateRaycaster(t),this.handleMouseHoverEvent())};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&s==="MouseHover"&&(n.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[n.uuid]?.forEach(o=>o.dispatchUserEvent(i)))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!(!s.visible||!s.data?.events.length)){for(let{data:o}of s.data.events)if(o.type==="MouseHover")try{let a=new vx(o,s,n,i);this.eventsPerObjects[s.uuid]?this.eventsPerObjects[s.uuid].push(a):this.eventsPerObjects[s.uuid]=[a]}catch{}this.eventsPerObjects[s.uuid]?.length&&this.objects.push(s)}})}connect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(this.domEventsNeeded.add("pointerdown"),t.addEventListener("pointerdown",this.onMouseDown),this.domEventsNeeded.add("pointerup"),t.addEventListener("pointerup",this.onMouseUp)),this.domEventsNeeded.add("pointermove"),t.addEventListener("pointermove",this.onMouseMove),this.objects.forEach(n=>{n.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if(!this.objects.length)return;let{domElement:t}=this.eventContext;this.domEventsNeeded.clear(),vn&&(t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("pointerup",this.onMouseUp)),t.removeEventListener("pointermove",this.onMouseMove),Object.values(this.eventsPerObjects).forEach(n=>{n.forEach(i=>{i.disconnect()})}),this.objects.forEach(n=>{n.removeEventListener("userEvent",this.onUserEvent)})}handleMouseHoverEvent(t=!1){let n=[];if(!t){let{stopRaycast:i,raycaster:s,scene:o}=this.eventContext;if(i){let a=Mm(s,o,this.objects);n=Em(a)}else this.objects.forEach(a=>{rd(s,a)&&n.push(a)})}this._prevObjects.length&&this._prevObjects.forEach(i=>{n.includes(i)||(i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchLeave()))}),n.length&&n.forEach(i=>{i.dispatchEvent({type:"beginEvent",eventName:"MouseHover"}),this.eventsPerObjects[i.uuid]?.forEach(s=>s.dispatchEnter())}),this._prevObjects=n}};var xx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.scrollCounter=0;this.actions=Nr(e,e.actions,t,n,i)}connect(){this.scrollCounter=0}disconnect(){Br(this.actions)}dispatch(e){let t=e>0?1:-1;this.scrollCounter+=t,this.scrollCounter=Math.min(Math.max(this.scrollCounter,0),this.data.steps);let n=this.scrollCounter/this.data.steps;this.actions.Transition.forEach(i=>i.seek(n))}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)})}},Wm=class extends Bn{constructor(t){super(t);this.eventsPerObject=new Map;this.onWheel=t=>{[...this.eventsPerObject.entries()].forEach(([n,i])=>{n.dispatchEvent({type:"beginEvent",eventName:"Scroll",deltaY:t.deltaY}),i.forEach(s=>s.dispatch(t.deltaY))})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&s==="Scroll"&&(n.dispatchEvent({type:"beginEvent",eventName:"Scroll"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{data:o}of s.data.events){if(o.type!=="Scroll")continue;let a=new xx(o,s,n,i);this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(a):this.eventsPerObject.set(s,[a])}})}connect(){let{domElement:t}=this.eventContext;[...this.eventsPerObject.entries()].forEach(([n,i])=>{i.forEach(s=>s.connect()),n.addEventListener("userEvent",this.onUserEvent)}),[...this.eventsPerObject.values()].some(n=>n.length)&&(this.domEventsNeeded.add("wheel"),t.addEventListener("wheel",this.onWheel))}disconnect(){let{domElement:t}=this.eventContext;t.removeEventListener("wheel",this.onWheel),this.domEventsNeeded.clear(),[...this.eventsPerObject.entries()].forEach(([n,i])=>{i.forEach(s=>s.disconnect()),n.removeEventListener("userEvent",this.onUserEvent)})}};var bx=class{constructor(e,t,n,i){this.data=e;this.object=t;this.actions=Nr(e,e.actions,t,n,i)}disconnect(){Br(this.actions)}dispatch(){this.actions.Transition.forEach(e=>{e.play()})}dispatchAfter(e){this.actions.Audio.forEach(t=>{(t.interaction.data.triggerAfter??"any")===e&&(t.interaction instanceof As?t.interaction.audioPlayer.play():t.interaction instanceof qc&&t.interaction.dispatch())})}dispatchUserEvent(e){this.actions.Transition.forEach(t=>{t.toggle(!e)}),this.actions.Audio.forEach(t=>{t.interaction instanceof As?t.interaction.audioPlayer.play():t.interaction instanceof qc&&t.interaction.dispatch()})}},jm=class extends Bn{constructor(t){super(t);this.eventsPerObject=new Map;this.eventsAfterPerObject=new Map;this.onMouseDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("mouseDown")})})};this.onKeyDown=()=>{[...this.eventsAfterPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>{i.dispatchAfter("keyDown")})})};this.onAny=()=>{let{domElement:t,isExport:n}=this.eventContext;(n?document:t).removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.dispatchEvent({type:"beginEvent",eventName:"Start"}),o.forEach(a=>{a.dispatchAfter("any")})})};this.onUserEvent=({eventName:t,target:n,reverse:i})=>{if(!t||!n)return;let s=Ao(t);s&&s==="Start"&&(n.dispatchEvent({type:"beginEvent",eventName:"Start"}),this.eventsPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}),this.eventsAfterPerObject.get(n)?.forEach(o=>{o.dispatchUserEvent(i)}))};let{scene:n,sharedAssets:i}=this.eventContext;n.traverseEntity(s=>{if(!!s.data?.events.length)for(let{data:o}of s.data.events){if(o.type!=="Start")continue;let a=new bx(o,s,n,i);a.actions.Transition.length&&(this.eventsPerObject.has(s)?this.eventsPerObject.get(s)?.push(a):this.eventsPerObject.set(s,[a])),a.actions.Audio.length&&(this.eventsAfterPerObject.has(s)?this.eventsAfterPerObject.get(s)?.push(a):this.eventsAfterPerObject.set(s,[a]))}})}connect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.addEventListener("pointerdown",this.onMouseDown,{once:!0}),document.addEventListener("keydown",this.onKeyDown,{once:!0}),i.addEventListener("pointerdown",this.onAny),document.addEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.addEventListener("userEvent",this.onUserEvent)})}[...this.eventsPerObject.entries()].forEach(([t,n])=>{t.dispatchEvent({type:"beginEvent",eventName:"Start"}),n.forEach(i=>i.dispatch()),t.addEventListener("userEvent",this.onUserEvent)})}disconnect(){if([...this.eventsAfterPerObject.values()].some(t=>t.length)){let{domElement:t,isExport:n}=this.eventContext,i=n?document:t;i.removeEventListener("pointerdown",this.onMouseDown),document.removeEventListener("keydown",this.onKeyDown),i.removeEventListener("pointerdown",this.onAny),document.removeEventListener("keydown",this.onAny),[...this.eventsAfterPerObject.entries()].forEach(([s,o])=>{s.removeEventListener("userEvent",this.onUserEvent),o.forEach(a=>a.disconnect())})}[...this.eventsPerObject.entries()].forEach(([t,n])=>{t.removeEventListener("userEvent",this.onUserEvent),n.forEach(i=>i.disconnect())})}};var qm=class{constructor(e,t,n,i){this.data=e;this.object=t;this.isToggleEnable=!1;this.actions=Nr(e,e.actions,t,n,i),this.target=e.target,this.useToggle=e.toggle}disconnect(){Br(this.actions)}dispatch(){this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.useToggle?(this.isToggleEnable=!this.isToggleEnable,this.actions.Transition.forEach(e=>{e.toggle(this.isToggleEnable)})):this.actions.Transition.forEach(e=>{e.play()}),this.actions.Link.forEach(e=>{e.dispatch()}),this.actions.Audio.forEach(e=>{e.dispatchBasic()})}};var en;i1.then(r=>en=r);var wa=new be,HV=new A(1,1,1),Qn=new A,Ts=new nt,_o=new A,wx=new Qt(0,0,0,"YXZ"),WV={type:"updateMatrix"},Sx={type:"beginEvent",eventName:"Collision"},Xm=class{constructor(e,t,n,i,s,o=!1){this.scene=t;this.sharedAssets=s;this.isExport=o;this.gameControls=[];this.gameControlStates=[];this.joysticks=[];this.joystickToGameControls=[];this.sharedGameControlGlobals={entitiesWithTransformAnim:[],eventsPerObjects:{},colliderToEntity:{}};this.needsCollisionDetection=!1;this.initializationCounter=-1;this.rigidBodyToMesh=new Map;this.nActiveRigidBodies=0;this.processRigidBody=e=>{if(e.bodyType()!==en.RigidBodyType.Dynamic)return;e.isSleeping()||this.nActiveRigidBodies++;let t=e.translation(),n=e.rotation(),i=this.rigidBodyToMesh.get(e.handle);if(Qn.set(t.x,t.y,t.z),Qn.multiplyScalar(this.pixelsPerMeter),Ts.set(n.x,n.y,n.z,n.w),i[0].matrixWorld.compose(Qn,Ts,i[1]),i[0].dispatchEvent(WV),i[2])for(let s of i[0].children)s.updateMatrixWorld(!0)};this.handleCollisionEvents=(e,t,n)=>{if(n!==!1)if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[e])){let i=this.sharedGameControlGlobals.colliderToEntity[t],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else if(this.gameControls.some(i=>i.object===this.sharedGameControlGlobals.colliderToEntity[t])){let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let o of s)o.data.target==="character"&&this.dispatchCollisionEvent(o,i)}else{let i=this.sharedGameControlGlobals.colliderToEntity[e],s=this.sharedGameControlGlobals.eventsPerObjects[i.uuid];if(s===void 0)return;for(let l of s)l.data.target==="scene"&&this.dispatchCollisionEvent(l,i);let o=this.sharedGameControlGlobals.colliderToEntity[t],a=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(a===void 0)return;for(let l of a)l.data.target==="scene"&&this.dispatchCollisionEvent(l,o)}};this.domElement=n.domElement;let a;e.scene.publish.playCamera===null?a=Ss.PERSONAL_CAMERA_ID:a=e.scene.publish.playCamera;let l=this.scene.find(a),u=!1,c=!1,h,d=5,f=8,m=9,p="drag";if(this.usePhysics=e.scene.environment.usePhysics??qr.defaultData.usePhysics,this.pixelsPerMeter=e.scene.environment.pixelsPerMeter??qr.defaultData.pixelsPerMeter,this.sceneGraph=e.scene.objects,e.scene.objects.data(e.scene.publish.gameControlObject)?.events.forEach(y=>{y.data.type==="GameControl"&&(h=y.data.keyAssignments,d=y.data.joystickPosLoc,f=y.data.joystickRotLoc,m=y.data.jumpTouchButtonLoc,p=y.data.rotByTouch)}),this.sceneGraph.traverse((y,b)=>{b.events.forEach(w=>{if(w.data.type!=="GameControl")return;let S=this.scene.find(y),_=S;for(;(_=_.parent)?.parent!==null;)if(this.sceneGraph.data(_.uuid)?.physics?.fusedBody)return;w.data.collisionEnabled&&(this.needsCollisionDetection=!0),this.gameControlStates.push([S,b,w.data])})}),this.usePhysics&&(this.gameControlStates.length===0||this.needsCollisionDetection)&&this.initPhysics(e.scene.environment.gravity??qr.defaultData.gravity),this.gameControlStates.forEach(([y,b,w])=>{Ri.is(b.type)&&(c=!0),u=u||w.camera===l.uuid;let S=new ad(y,e.scene.objects,n.domElement,{...w,keyAssignments:h},e.scene.environment,this.sharedGameControlGlobals,w.camera===l.uuid,l,this.scene,s);S.addEventListener("change",i),S.addEventListener("end",i),S.addEventListener("start",i),this.gameControls.push(S),vn&&w.touchControl&&(this.joystickToGameControls[d]!==void 0?this.joystickToGameControls[d].push([S,"pos"]):this.joystickToGameControls[d]=[[S,"pos"]],w.moveMode==="walk"&&(this.joystickToGameControls[m]!==void 0?this.joystickToGameControls[m].push([S,"jmp"]):this.joystickToGameControls[m]=[[S,"jmp"]]),p==="joystick"&&(this.joystickToGameControls[f]!==void 0?this.joystickToGameControls[f].push([S,"rot"]):this.joystickToGameControls[f]=[[S,"rot"]]))}),u===!1){let{enableRotate:y,enablePan:b,enableZoom:w,autoRotate:S,hoverRotatePanMode:_}=e.scene.publish.orbitControls;c===!1&&(y||b||w||S||_!==0)&&!Object.keys(l.states).length&&(this.orbitControls=new Xc(l,n.domElement,this.isExport),this.orbitControls.addEventListener("change",i),this.orbitControls.addEventListener("end",i),this.orbitControls.addEventListener("start",i),this.orbitControls.fromJSON(e.scene.publish.orbitControls),this.orbitControls.useKeyEvents=!1)}let g=n.domElement.width/n.getPixelRatio(),v=n.domElement.height/n.getPixelRatio();this.joystickToGameControls.forEach((y,b)=>{let w=document.body.appendChild(document.createElement("div")),[S,_,M]=(e.scene.publish.joystickSizeAndXYOffset??vs.defaultData.joystickSizeAndXYOffset)[b],x=(g-5*S)/4+S,T={},E=y.some(D=>D[1]==="jmp"),C=E?0:S;b<10?(b<5?T.top=C/2:T.bottom=C/2,T.left=C/2+b%5*x):b===10?(T.left=C/2,T.top=v/2):(T.right=C/2,T.top=v/2),T.top?T.top-=_[1]:T.bottom+=_[1],T.left?T.left+=_[0]:T.right-=_[0];for(let D in T)T[D]+="px";if(E){let D=w.appendChild(document.createElement("div"));Object.assign(D.style,T,{position:"absolute",width:S+"px",height:S+"px",backgroundColor:`rgba(255,255,255,${M==="show"?.4:0})`,zIndex:"9999",borderRadius:S+"px",border:"solid 2px rgba(0, 0, 0, .1)",display:"flex",alignItems:"center",justifyContent:"center",touchAction:"none"});let N=S/16*16*.4;D.innerHTML=`
4914
4915
  <svg width="${N}" height="${S*.4}" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4915
4916
  <path d="M2 10L8 4L14 10" stroke="black" stroke-opacity="40%" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
4916
4917
  </svg>
4917
- `,I.addEventListener("pointerdown",()=>{y.forEach(F=>{F[0].movementState.jump=1}),i()}),I.addEventListener("touchend",F=>F.preventDefault()),this.joysticks[w]=[void 0,b];return}let P={zone:b,mode:"static",position:T,size:S};M==="hide"&&(P.restOpacity=0);let O=jM.create(P);O.on("move",(I,N)=>{y.forEach(F=>{let G=F[0];F[1]==="pos"?N.force<.2?G.moveForce=0:(G.movementState.movePosZ=Math.sin(-N.angle.radian),G.movementState.movePosX=Math.cos(-N.angle.radian),N.force<.3?G.moveForce=(N.force-.2)/.1:G.moveForce=1):N.force<.2?G.rotForce=0:(G.movementState.rotPosX=N.vector.y,G.movementState.rotPosY=-N.vector.x,N.force<.3?G.rotForce=(N.force-.2)/.1:G.rotForce=1)}),i()}),O.on("end",(I,N)=>{y.forEach(F=>{let G=F[0];F[1]==="pos"?(G.movementState.movePosZ=0,G.movementState.movePosX=0,G.moveForce=1):(G.movementState.rotPosX=0,G.movementState.rotPosY=0,G.rotForce=1)})}),this.joysticks[w]=[O,b]}),this.usePhysics===!1&&this.needsCollisionDetection&&this.initBVH(),this.initializationCounter++}initBVH(){let e=[];this.scene.updateMatrixWorld(!0);let t=new Set;if(this.scene.traverse(n=>{if(!!Kr(n))if(!n.visible||t.has(n))n.children.forEach(i=>Kr(i)&&t.add(i));else if(Object.keys(n.states).length||n.data?.events.some(i=>i.data.type==="GameControl")){let i=[];n.matrixWorld.decompose(Qn,Ts,_o);let s=new be().compose(Qn,Ts,HV);kt(n)&&i.push(bo(n.geometry,wa.makeScale(_o.x,_o.y,_o.z))),n.updateMatrixWorld();let o=s.clone().invert();if(n.traverse(a=>{!kt(a)||(a.updateMatrixWorld(),wa.multiplyMatrices(o,a.matrixWorld),i.push(bo(a.geometry,wa)))}),i.length>0){let a=xs(i,!1);n.boundsTree=new Jt(a),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(n)}}else kt(n)&&!this.sharedGameControlGlobals.entitiesWithTransformAnim.some(i=>n.isDescendantOf(i))&&e.push(bo(n.geometry,n.matrixWorld))}),e.length>0){let n=xs(e,!1);this.sharedGameControlGlobals.staticMeshBVH=new Jt(n)}}addCollider(e,t,n,i,s=!0){let o=e.rigidBody,a;i!==void 0?i.collider.type==="sphere"?a=en.ColliderDesc.ball(i.collider.radius/this.pixelsPerMeter):i.collider.type==="capsule"?a=en.ColliderDesc.capsule((i.collider.height/2-i.collider.radius)/this.pixelsPerMeter,i.collider.radius/this.pixelsPerMeter):a=en.ColliderDesc.cuboid(i.collider.width/this.pixelsPerMeter/2,i.collider.height/this.pixelsPerMeter/2,i.collider.depth/this.pixelsPerMeter/2):n.colliderType==="trimesh"?a=en.ColliderDesc.trimesh(t.getAttribute("position").array,t.getIndex().array):a=en.ColliderDesc.convexMesh(t.getAttribute("position").array,s?t.getIndex().array:void 0),a.setFrictionCombineRule(en.CoefficientCombineRule.Average).setRestitutionCombineRule(en.CoefficientCombineRule.Average).setDensity(n.density).setFriction(n.friction).setRestitution(n.restitution);let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);if(this.sharedGameControlGlobals.colliderToEntity[l.handle]=e,i!==void 0){Qn.fromArray(i.collider.position).multiply(_o.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter),l.setTranslationWrtParent(Qn);let u=new nt().setFromEuler(new Qt().setFromVector3(new A().fromArray(i.collider.rotation)));l.setRotationWrtParent(u),l.setActiveEvents(en.ActiveEvents.COLLISION_EVENTS)}else n.rigidBody==="dynamic"&&this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some(u=>u.target==="scene")&&l.setActiveEvents(en.ActiveEvents.COLLISION_EVENTS)}initPhysics(e){this.sharedGameControlGlobals.rapierWorld=new en.World(new en.Vector3(0,e??-10,0)),this.events=new en.EventQueue(!0);let t=[],n=[],i=[];if(this.sceneGraph.traverse((u,c)=>{let h=this.scene.find(u);if(h&&Kr(h)&&h.visible){let d,f=c.states.some(p=>p.data.position!==void 0||p.data.rotation!==void 0||p.data.hiddenMatrix!==void 0),m=!1;for(let p of c.events)if(p.data.type==="GameControl")d=p.data;else if(p.data.type==="Collision"){m=!0;let g=new qm(p.data,h,this.scene,this.sharedAssets);this.sharedGameControlGlobals.eventsPerObjects[h.uuid]?this.sharedGameControlGlobals.eventsPerObjects[h.uuid].push(g):this.sharedGameControlGlobals.eventsPerObjects[h.uuid]=[g]}if(n.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(!c.physics){n.push(u);return}if(i.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(c.physics.fusedBody===!0&&i.push(u),c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(h.matrixWorldFusedFalse=h.matrixWorld.clone()),c.physics.rigidBody==="dynamic"||f||m||d!==void 0){let p=[];d===void 0&&c.physics.rigidBody==="dynamic"&&(h.matrixWorld0=h.matrixWorld.clone(),h.matrixWorld.identity()),h instanceof wt&&h.geometry.getAttribute("position")!==void 0&&(h.matrixWorld0!==void 0&&h.geometry.applyMatrix4(h.matrixWorld0),p.push(bo(h.geometry)));let g=h.matrixWorld.clone().invert();if(c.physics.fusedBody&&h.traverse(v=>{v!==h&&(h.matrixWorld0?(wa.copy(v.matrixWorld),v.parent===h&&(v.hiddenMatrix0=v.hiddenMatrix.clone(),v.hiddenMatrix.premultiply(h.matrixWorld0))):wa.multiplyMatrices(g,v.matrixWorld),v instanceof wt&&v.geometry.getAttribute("position")!==void 0&&p.push(bo(v.geometry,wa)))}),p.length>0){let v=xs(p);v.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter),h.matrixWorld.decompose(Qn,Ts,_o),Qn.divideScalar(this.pixelsPerMeter);let y;d!==void 0?y=en.RigidBodyDesc.kinematicPositionBased():c.physics.rigidBody==="dynamic"?(y=en.RigidBodyDesc.dynamic(),y.setLinearDamping(c.physics.damping).setAdditionalMass(1e-9).setGravityScale(c.physics.gravityScale).enabledRotations(...c.physics.enabledRotation).enabledTranslations(...c.physics.enabledTranslation)):f?(y=en.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(h)):y=en.RigidBodyDesc.fixed(),y.setTranslation(Qn.x,Qn.y,Qn.z).setRotation(Ts);let w=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);d===void 0&&c.physics.rigidBody==="dynamic"&&this.rigidBodyToMesh.set(w.handle,[h,_o.clone(),c.physics.fusedBody]),h.rigidBody=w;let b=!(c.geometry===void 0||c.geometry.type==="SubdivGeometry"||c.geometry.type==="NonParametricGeometry"||c.geometry.type==="BooleanGeometry"||c.geometry.type==="VectorGeometry"||c.geometry.type==="StarGeometry"||c.geometry.type==="RectangleGeometry"||c.geometry.type==="EllipseGeometry"||c.geometry.type==="TriangleGeometry"||c.geometry.type==="TorusGeometry"||c.geometry.type==="HelixGeometry");try{this.addCollider(h,v,c.physics,d,b)}catch{this.addCollider(h,v,c.physics,d,!1)}}}else this.gameControlStates.some(([p])=>h.isDescendantOf(p))||(kt(h)&&t.push(bo(h.geometry,h.matrixWorld)),c.physics.fusedBody&&h.traverse(p=>{!kt(p)||p===h||t.push(bo(p.geometry,p.matrixWorld))}))}}),t.length===0)return;let s=xs(t);s.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let o=en.RigidBodyDesc.fixed(),a=this.sharedGameControlGlobals.rapierWorld.createRigidBody(o),l=en.ColliderDesc.trimesh(s.getAttribute("position").array,s.getIndex().array).setFrictionCombineRule(en.CoefficientCombineRule.Multiply).setRestitutionCombineRule(en.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(l,a)}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}dispose(){this.scene.traverse(e=>{let t=e;if(t.matrixWorld0){let n=wa.copy(t.matrixWorld0).invert();t instanceof wt&&t.geometry.applyMatrix4(n),t.matrixWorld.copy(t.matrixWorld0),t.matrixWorld0=void 0}t.hiddenMatrix0&&(t.hiddenMatrix=t.hiddenMatrix0,t.hiddenMatrix0=void 0),t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.gameControls.forEach(e=>{e.reset(),e.dispose()}),this.gameControls=[],this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls?.dispose(),this.orbitControls=void 0;for(let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.eventsPerObjects={},this.scene.updateMatrixWorld(!0)}update(e){let t=!0;if(this.orbitControls!==void 0&&(t=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2)this.initializationCounter++,t=!1;else if(this.initializationCounter===2)for(let n of this.gameControls)t=!n.update(e)&&t;if(this.usePhysics&&(this.gameControls.length===0||this.needsCollisionDetection)){for(let n of this.sharedGameControlGlobals.entitiesWithTransformAnim){n.matrixWorld.decompose(Qn,Ts,_o),wx.setFromQuaternion(Ts);let i=n;i.prevR===void 0?(i.prevR=wx.clone(),i.prevT=Qn.clone()):(i.prevR.copy(wx),i.prevT.copy(Qn)),n.rigidBody.setNextKinematicTranslation(Qn.divideScalar(this.pixelsPerMeter)),n.rigidBody.setNextKinematicRotation(Ts)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),t=!this.updatePositions()&&t}return t}dispatchCollisionEvent(e,t){t.dispatchEvent(Sx),e.dispatch()}};var Ax={type:"change"},jV={type:"lock"},qV={type:"unlock"},XV=new A,Sa=new A,YV=new A,_n=new A,kn=new A,Fr=new A,ld=new be,kE=new be,QV=new be,ZV=new be,Yc=new nt,cd=new nt,KV=new Qt(0,0,0,"YXZ"),Aa=new A(0,1,0),_x=new A(1,1,1),JV=1,$V=.025,e4=16e-6,t4=12,n4=20,Zn=new gn,ei=new Mt,Ym=class extends Lt{constructor(t,n,i,s,o,a,l,u,c,h){super();this.object=t;this.sceneGraph=n;this.domElement=i;this.sharedGameControlGlobals=a;this.cameraFollow=l;this.camera=u;this.scene=c;this.sharedAssets=h;this.enableDamping=!0;this.position0=new A;this.rotation0=new Qt(0,0,0,"XYZ");this.scale0=new A;this.hiddenMatrix0=new be;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.euler0=new Qt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new nt;this.scale0Cam=new A;this.hiddenMatrix0Cam=new be;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.collider={radius:40,segment:new gn(new A(0,-40,0),new A(0,40,0)),matrix:new be,position:new A,rotation:new nt};this.euler=new Qt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastQuaternion=new nt;this.lastPosition=new A;this.lastCameraQuaternion=new nt;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new B;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.objectRot={x:0,y:0};this.firstPointerId=-1;this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0};this.onObject=!1;this.actionState={};this.slopeAdjust=!1;this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new be;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new nt;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new nt;this.objXZQuatInv=new nt;this.objXZRotMat=new be;this.isFirstPerson=!1;this.actions={};this.lastDummyPos=new A;this.lastDummyPosDelta=new A;this.hit=null;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new nt;this.colliderWorldQuat=new nt;this.groundNormal=new A;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.onPointerDown=t=>{t.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=t.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!vn&&(!Kl||Jl>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(t.clientX,t.clientY))};this.onPointerUp=t=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),t.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=t=>{if(t.pointerId!==this.firstPointerId)return;let n=t.clientX-this.prevMouse.x,i=t.clientY-this.prevMouse.y;this.prevMouse.set(t.clientX,t.clientY),t.pointerType==="mouse"&&this.rotBy!=="keys"&&(Kl&&Jl<15.5&&!vn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-t.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-t.movementY*this.mouseOrbitSensitivity)),t.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.dispatchEvent(Ax)};this.onPointerlockChange=t=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(jV),Ym.isLocked=!0):(this.dispatchEvent(qV),Ym.isLocked=!1)};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.onKeyDown=t=>{t.preventDefault();for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]){this.movementState[n[0]]=1;break}this.dispatchEvent(Ax)};this.onKeyUp=t=>{for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]||t.code.slice(3,t.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.resetChildrenToBaseState=(t,n)=>{if(t===this.object.uuid)return;let i=this.scene.find(t);i.currentState!==null&&sx(i,n,null,this.sharedAssets)};if(t.objectType==="CombinedCamera"&&(this.isFirstPerson=!0),this.position0.copy(this.object.position),this.rotation0.copy(this.object.rotation),this.scale0.copy(this.object.scale),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.rotation.reorder("YXZ"),this.euler0.copy(this.object.rotation),this.isFirstPerson===!1){let m=this.object.rotation.y;this.objectRealQuat.copy(this.object.quaternion),this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,m,0)}if(this.object.matrixAutoUpdate=!1,this.isFirstPerson){let m=this.object;this.target0.copy(m.getTarget()),this.zoom0=m.zoom}else this.cameraFollow===!0&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom);if(this.cameraFollow===!0){if(this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera?.parent?.parent){let y=this.camera.matrix.clone().invert().premultiply(this.camera.matrixWorld),w=y.clone().invert();this.camera.hiddenMatrix.multiply(w),this.camera.matrix.premultiply(y),this.camera.matrixWorld.decompose(this.camera.position,this.camera.quaternion,this.camera.scale)}this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m=new A(0,0,-1).applyQuaternion(this.camera.quaternion),p=new A().subVectors(this.object.position,this.camera.position);this.objectToCamXZ.copy(p),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g;if(Math.abs(m.y)<1e-6){p.y=0,m.y=0;let y=p.projectOnVector(m);this.targetToCamera0.copy(y).negate(),g=this.camera.position.clone().add(y)}else{let y=m.multiplyScalar(p.y/m.y);this.targetToCamera0.copy(y).negate(),g=y.clone().add(this.camera.position)}this.objectToTarget0.subVectors(g,this.object.position);let v=new Qt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.isObjectCamera=this.object.objectType==="CombinedCamera",this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.connect(),this.rotByTouch=s.rotByTouch??"joystick",this.rotBy=s.rotBy??"keys",this.rotationMode=s.rotationMode??"normal",this.moveMode=s.moveMode??"walk",this.collisionEnabled=s.collisionEnabled,this.speedTranslate=(s.speedTranslate??250)*JV,this.speedOrbit=(s.speedRotate??100)*$V,this.mouseOrbitSensitivity=(s.speedRotate??100)*e4,this.keyAssignments=s.keyAssignments.map(m=>{let p=[m[0],m[1]];return p[1]==="\u25B2"?p[1]="ArrowUp":p[1]==="\u25C0"?p[1]="ArrowLeft":p[1]==="\u25BC"?p[1]="ArrowDown":p[1]==="\u25B6"?p[1]="ArrowRight":p[1]==="\u21E7"?p[1]="Shift":p[1]==="\u21B5"?p[1]="Enter":p[1]==="Space"?p[1]=" ":p[1]==="\u2318"?p[1]="Meta":p[1]==="Ctrl"?p[1]="Control":p[1]==="Esc"&&(p[1]="Escape"),p}),s.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(p=>p[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/((s.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((s.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((s.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((s.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((s.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((s.delayRotCamera??.3)*60)),this.gravity=(o.gravity??qr.defaultData.gravity)*t4,this.pixelsPerMeter=o.pixelsPerMeter??qr.defaultData.pixelsPerMeter,this.usePhysics=o.usePhysics??qr.defaultData.usePhysics,this.jumpPower=s.jumpPower*n4,this.resetYPosition=s.resetYPosition,this.orientMode=s.autoOrientMove?s.orientMode:"none",this.orientWith=s.orientWith??Mp.defaultDataThirdPerson.orientWith,s.collider.type==="capsule"?(this.collider.radius=s.collider.radius,this.collider.segment.start.y=s.collider.height/2-s.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y):s.collider.type==="sphere"&&(this.collider.radius=s.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0);let d=new A().fromArray(s.collider.position),f=new nt().setFromEuler(new Qt().fromArray([...s.collider.rotation,"XYZ"]));this.collider.position.copy(d).multiply(this.object.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(d,f,_x),s.cameraXAxis!==void 0&&(this.cameraXAxis=s.cameraXAxis,this.cameraYAxis=s.cameraYAxis,this.minPolarAngle=s.cameraRotXLimits[0],this.maxPolarAngle=s.cameraRotXLimits[1],this.minAzimuthAngleRel=s.cameraRotYLimits[0],this.maxAzimuthAngleRel=s.cameraRotYLimits[1]),s.gameActions!==void 0&&Object.entries(s.gameActions).forEach(([m,p],g)=>{p.forEach(({id:v,data:y})=>{try{this.actions[m]===void 0&&(this.actions[m]=[]),y.type==="Transition"?this.actions[m].push(new $i(v,y,c,h)):y.type==="Audio"&&this.actions[m].push(new Zi(v,y,t,h))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle")}reset(t=!1){if(this.object.rotation.copy(this.rotation0),this.object.position.copy(this.position0),this.object.scale.copy(this.scale0),this.object.hiddenMatrix.copy(this.hiddenMatrix0),t===!0){if(this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.rotation.reorder("YXZ"),this.isFirstPerson===!1){let n=this.object.rotation.y;this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,n,0)}this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}this.isObjectCamera?this.object.matrixAutoUpdate=!0:this.object.updateMatrix(),this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.dispatchEvent(Ax)}connect(){this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError)}disconnect(){this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError)}dispose(){this.disconnect(),Object.values(this.actions).forEach(t=>{t.forEach(n=>{(n instanceof $i||n instanceof Zi)&&n.dispose()})})}resetTo(t,n,i){}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].forEach(n=>{n instanceof $i?n.play():n instanceof Zi&&n.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].forEach(n=>{n instanceof $i?n.stop():n instanceof Zi&&n.dispatchGameControl("stop")}),this.sceneGraph.traverseFrom(this.object.uuid,this.resetChildrenToBaseState)))}update(t){if(this.gravity<0?this.object.position.y<this.resetYPosition:this.object.position.y>this.resetYPosition)return this.reset(!0),!0;let n=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=n*60;if(this.usePhysics){let o=kn.set(0,-(this.jumpPower+this.gravity*i)*n*.5,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(_n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,void 0,void 0,void 0,this.object.rigidBody);if(this.slopeAdjust=!1,a){this.slopeAdjust=!1,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),Math.acos(this.groundNormal.y)*180/Math.PI>45?this.onObject=!0:(this.slopeAdjust=!0,this.onObject=!0);let l=a.collider._parent;this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===l){u.matrixWorld.decompose(_n,cd,kn),this.groundVelocity.subVectors(_n,u.prevT),this.object.getWorldPosition(kn).add(this.collider.position).sub(u.position),this.groundYRotation=KV.setFromQuaternion(cd).y-u.prevR.y,Fr.copy(kn).applyAxisAngle(Aa,this.groundYRotation),this.groundVelocity.add(Fr.sub(kn)).divideScalar(n);break}}else this.onObject=!1}this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.velocityTarget.y+=this.onObject?0:this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.directionXZ.normalize(),this.movementState.moveNegZ||this.movementState.movePosZ?this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce:this.velocityTarget.z=0,this.movementState.moveNegX||this.movementState.movePosX?this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce:this.velocityTarget.x=0,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.hit===null&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("move")));let s=YV.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=kn.copy(s);o.y=0,s.set(0,s.y,o.length()*-1)}if(s.applyQuaternion(this.object.quaternion),this.slopeAdjust&&(cd.setFromUnitVectors(Aa,this.groundNormal),s.applyQuaternion(cd)),this.usePhysics===!0){let o=kn;this.pushedVelocity.set(0,0,0);for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){a.parent?.matrixWorldFusedFalse?(ld.multiplyMatrices(a.parent?.matrixWorldFusedFalse,a.matrix),Fr.setFromMatrixPosition(ld)):Fr.copy(a.position);let l=Fr.sub(a.prevT).divideScalar(n);l.divideScalar(this.pixelsPerMeter);let u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),_n.copy(s).divideScalar(this.pixelsPerMeter),n);if(l.multiplyScalar(this.pixelsPerMeter),u!==null){this.pushedVelocity.copy(l),o.copy(u.normal1).applyQuaternion(a.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let a=o.dot(s);a<0&&s.addScaledVector(o,-a),s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(n),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*n,this.euler.y+=this.rotVelocity.y*n+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*n),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){let o=_n,a=kn.copy(this.directionXZ);a.x*=-1,this.camera.getWorldDirection(o);let l=Fr.copy(Aa).multiplyScalar(o.dot(Aa));if(o.sub(l),Fr.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.orientWith==="camera"?this.object.rotation.y=o.angleTo(a)*(o.cross(a).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera:this.object.rotation.y=this.euler.y+Math.atan2(-this.directionXZ.z,this.directionXZ.x)-Math.PI/2,Sa.copy(this.collider.position).applyQuaternion(this.object.quaternion),Sa.sub(Fr),this.object.position.sub(Sa),this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Aa,this.euler.y-this.euler0.y);let u=kn.copy(this.objectToCamXZ).normalize(),c=Fr.copy(s).multiplyScalar(n);c.y=0;let h=c.sub(_n.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}if(this.cameraFollow===!0&&this.moveMode==="walk"&&this.isFirstPerson===!1?this.cameraXAxis==="Limit"?this.euler.x=Be.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Be.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):(this.cameraXAxis==="Limit"||this.isFirstPerson||this.cameraFollow===!0)&&(this.euler.x=Be.clamp(this.euler.x,-this.PI_2,this.PI_2)),(this.isFirstPerson||this.moveMode!=="walk")&&(this.object.rotation.x=this.euler.x),(this.isFirstPerson||this.orientMode==="none"||this.directionXZ.manhattanLength()===0)&&(Fr.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.object.rotation.y+=this.rotVelocity.y*n+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.object.rotation.y),Sa.copy(this.collider.position).applyQuaternion(this.object.quaternion),Sa.sub(Fr),this.object.position.sub(Sa)),this.object.rotation.x=Be.clamp(this.object.rotation.x,-this.PI_2,this.PI_2),this.objectRot.x=this.euler.x,this.objectRot.y=this.euler.y,this.objectRealQuat.multiplyQuaternions(this.object.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){if(this.hit=this.sharedGameControlGlobals.rapierWorld.castShape(_n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,kn.copy(s).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,n,8,void 0,void 0,this.object.rigidBody),this.hit!==null){let o=this.sharedGameControlGlobals.colliderToEntity[this.hit.collider.handle];if(o!==this.lastHitObj){this.lastHitObj=o;let l=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(l)for(let u of l)u.data.target==="character"&&(o.dispatchEvent(Sx),u.dispatch())}let a=_n.set(this.hit.normal2.x,this.hit.normal2.y,this.hit.normal2.z).applyQuaternion(this.colliderWorldQuat);if(this.hit.toi>0){let l=kn.copy(s).multiplyScalar(this.hit?.toi).dot(a),u=this.hit.toi;l>2&&(u=this.hit.toi*(l-2)/l,this.object.position.addScaledVector(s,u));let c=kn.copy(s).multiplyScalar(n-u);a.multiplyScalar(c.dot(a));let h=c.sub(a),d=this.sharedGameControlGlobals.rapierWorld.castShape(_n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,Fr.copy(h).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,20,8,void 0,void 0,this.object.rigidBody);if(d===null)this.object.position.add(h);else if(d.toi>1){let f=_n.set(d.normal2.x,d.normal2.y,d.normal2.z).applyQuaternion(this.colliderWorldQuat);kn.copy(h).dot(f)>2&&this.object.position.add(h)}this.lastDummyPosDelta.subVectors(this.object.position,this.lastDummyPos),this.lastDummyPos.copy(this.object.position)}}else this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),this.object.position.addScaledVector(s,n);this.object.rigidBody?.setTranslation(_n.copy(this.object.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Yc.copy(this.object.quaternion).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,a=s.multiplyScalar(n/o);for(let l=0;l<o;l++)this.object.position.add(a),this.collisionAdjustment(n/o)}else this.object.position.addScaledVector(s,n);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuat),this.isObjectCamera||this.object.updateMatrix(),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.object.position),a=this.targetToCamera.add(o);ld.lookAt(a,o,Aa).setPosition(a),ld.decompose(this.targetPos,this.targetQuat,_n),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.matrixWorldNeedsUpdate=!0,this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Be.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Be.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.lastPosition.distanceToSquared(this.object.position)<this.threshEndTranslate&&8*(1-this.lastQuaternion.dot(this.object.quaternion))<this.threshEndRotate&&(!this.camera||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode!=="walk"||this.onObject===!0||this.collisionEnabled===!1)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t=Yc.setFromAxisAngle(Aa,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Be.clamp(this.objectRot.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.objectRot.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(t);let n;this.cameraXAxis==="Limit"?n=Be.clamp(this.objectRot.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=Be.clamp(this.objectRot.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=_n.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let s=cd.setFromAxisAngle(i,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}collisionAdjustment(t){let n=Sa.set(0,0,0);this.object.updateMatrix();let i=ld.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(_n,Yc,kn).compose(_n,Yc,_x);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;ei.makeEmpty();let a=ZV.copy(o.matrixWorld).decompose(_n,Yc,kn).compose(_n,Yc,_x),l=kE.copy(a).invert(),u=QV.copy(kE).multiply(i);Zn.copy(this.collider.segment),Zn.start.applyMatrix4(u),Zn.end.applyMatrix4(u);let c=XV.copy(this.object.position).applyMatrix4(l);ei.expandByPoint(Zn.start),ei.expandByPoint(Zn.end),ei.min.addScalar(-this.collider.radius),ei.max.addScalar(this.collider.radius),o.boundsTree.shapecast({intersectsBounds:h=>h.intersectsBox(ei),intersectsTriangle:h=>{let d=_n,f=kn,m=h.closestPointToSegment(Zn,d,f);if(m<this.collider.radius){let p=this.collider.radius-m,g=f.sub(d).normalize(),v=Fr.copy(c);v.addScaledVector(g,p);let y=v.applyMatrix4(a).sub(this.object.position);n.add(y),Zn.start.addScaledVector(g,p),Zn.end.addScaledVector(g,p)}}})}),ei.makeEmpty(),Zn.copy(this.collider.segment),Zn.start.applyMatrix4(i),Zn.end.applyMatrix4(i),ei.expandByPoint(Zn.start),ei.expandByPoint(Zn.end),ei.min.addScalar(-this.collider.radius),ei.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({intersectsBounds:o=>o.intersectsBox(ei),intersectsTriangle:o=>{let a=_n,l=kn,u=o.closestPointToSegment(Zn,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();n.addScaledVector(h,c),Zn.start.addScaledVector(h,c),Zn.end.addScaledVector(h,c)}}}),this.onObject=n.y>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.object.position.add(n)}},ad=Ym;ad.isLocked=!1;var Tx={type:"change"},VE={type:"changeZoom"},r4={type:"changePan"},Qc={type:"start"},ud={type:"end"},Mx=new nt,i4=new B,s4=2*Math.PI,o4=1e-8,a4=.01,HE=2,Ex=.125,WE=2,Cx=1,Px=1,Dx=.1;var Xc=class extends Lt{constructor(t,n,i=!1){super();this.object=t;this.domElement=n;this.isExport=i;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,Cr.DOLLY_ROTATE,Cr.PAN];this.offset=new A;this.eye=new A;this.lastPosition=new A;this.lastQuaternion=new nt;this.current=new B;this.overShoot=new B;this.overRatio=new B;this.spherical=new Ou;this.sphericalDelta=new Ou;this.panOffset=new A;this.panLeftV=new A;this.panUpV=new A;this.panV=new A;this.rotateStart=new B;this.rotateEnd=new B;this.rotateDelta=new B;this.panStart=new B;this.panEnd=new B;this.panDelta=new B;this.dollyStart=new B;this.dollyEnd=new B;this.dollyDelta=new B;this.rotationRangeFactor=new B;this.panRangeFactor=new B;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(Mx.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(Mx),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-Ex),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let n=this.spherical.phi%s4;return this.eye.copy(this.offset).normalize(),this.object.up.copy(ht.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),n>0&&n>Math.PI||n<0&&n>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-Ex,this.sphericalDelta.phi*=1-Ex):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>a4||8*(1-this.lastQuaternion.dot(this.object.quaternion))>o4?(this.dispatchEvent(Tx),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,$e.length===1&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),t.pointerType==="touch"||t.pointerType==="pen"&&vn?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"||t.pointerType==="pen"&&vn?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{this.isPointerDown=!1,$e.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(ud),this.state=-1};this.onPointerDownMouse=t=>{let n;switch(this.useKeyEvents?n=this.mouseButtons[t.button]:n=this.mouseButtonsPlay[t.button],n){case 0:if(t.altKey===!0&&!t.shiftKey&&!oh(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(oh(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(oh(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Qc)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(this.touches[$e.length-1]){case Cr.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Cr.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Cr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Cr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Qc)};this.onPointerMoveTouch=t=>{switch(this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Wu(()=>this.dispatchEvent(ud),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||(this.isExport===!1&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(Qc),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Qc),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(ud)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp($e[0]))};this.onPointerHover=t=>{if(!(t.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let n={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(n):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(n),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,Dx):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,Dx),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.isUpVectorFlipped=this.isUpVectorFlipped0,this.object.updateProjectionMatrix(),this.dispatchEvent(Tx),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,n,i,s=!1){this.target.copy(t),this.object.position.copy(n),this.object.zoom=i,this.object.isUpVectorFlipped=s,this.object.updateProjectionMatrix(),this.dispatchEvent(Tx),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),Dx=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,HE=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(Mx.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=To(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=To(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=To(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=To(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,t.orbitTouches===1&&(this.touches[0]=Cr.ROTATE),t.panTouches===1&&(this.touches[0]=Cr.PAN),t.orbitTouches===2&&(this.touches[1]=Cr.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=Cr.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=Cr.ROTATE),t.panTouches===3&&(this.touches[2]=Cr.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),sh||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),sh||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,n,i,s,o,a,l,u){this.overShoot.set(0,0);let c,h,d;t instanceof A?(c=t.x,h=t.y,this.current.set(this.target.x,this.target.y),d=!0):(c=t.theta,h=t.phi,this.current.set(To(this.spherical.theta),To(this.spherical.phi)),d=!1),i===0&&(this.current.x+=c,this.current.y+=h),(n===3||n===2)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(c=0)),(n===3||n===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(h=0)),d||(this.overShoot.x=To(this.overShoot.x),this.overShoot.y=To(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(u),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=jE(Math.abs(this.overRatio.x)),this.overRatio.y=jE(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(c*this.overShoot.x<0&&(c*=1-this.overRatio.x),h*this.overShoot.y<0&&(h*=1-this.overRatio.y)):i===2&&(!d&&(this.overRatio.x>.002||this.overRatio.y>.002)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(c=this.overShoot.x*.05,h=this.overShoot.y*.05,d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(c+=this.overShoot.x,h+=this.overShoot.y),t instanceof A?(t.x=c,t.y=h):(t.theta=c,t.phi=h)}setEnableDampingSpeed(t){this.enableDamping=t,Cx=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*HE}getZoomScale(){return Math.pow(.95,WE)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,n){this.panLeftV.setFromMatrixColumn(n,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,n){this.panUpV.setFromMatrixColumn(n,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,n){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*n*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(r4)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(VE)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(VE)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Qc),this.dollyOut(t),this.dispatchEvent(ud)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Qc),this.dollyIn(t),this.dispatchEvent(ud)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,n=1){Kl&&Jl<15.5&&!vn?(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)):this.rotateDelta.set(t.movementX,t.movementY),this.rotateDelta.multiplyScalar(Cx*n).rotateAround(i4,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,n=1){Kl&&Jl<15.5&&!vn?(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)):this.panDelta.set(t.movementX,t.movementY),this.panDelta.multiplyScalar(Px*n),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(K1===!1&&oh(t)===!1&&l4(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(Px),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if($e.length===2){let t=.5*($e[0].pageX+$e[1].pageX),n=.5*($e[0].pageY+$e[1].pageY);this.rotateStart.set(t,n)}else this.rotateStart.set($e[0].pageX,$e[0].pageY)}handleTouchStartPan(){if($e.length===2){let t=.5*($e[0].pageX+$e[1].pageX),n=.5*($e[0].pageY+$e[1].pageY);this.panStart.set(t,n)}else this.panStart.set($e[0].pageX,$e[0].pageY)}handleTouchStartDolly(){let t=$e[0].pageX-$e[1].pageX,n=$e[0].pageY-$e[1].pageY,i=Math.sqrt(t*t+n*n);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if($e.length===2){let i=_p(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==$e[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Cx);let n=this.domElement;n&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/n.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/n.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if($e.length===2){let n=_p(t),i=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this.panEnd.set(i,s)}else{if(t.pointerId!==$e[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Px),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let n=_p(t),i=t.pageX-n.x,s=t.pageY-n.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,WE)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function To(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}function jE(r){return 1-Math.pow(1-r,4)}function l4(r){return r.wheelDeltaY===0||r.deltaY===0?la&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120?!1:r.wheelDeltaX?r.wheelDeltaX===-3*r.deltaX:r.deltaMode===0:r.wheelDeltaY?r.wheelDeltaY===-3*r.deltaY:r.deltaMode===0}var qE=Object.keys(k0).filter(r=>isNaN(Number(r))),Qm=class{constructor(e,t,n,i,s,o,a,l){this.preventScroll=s;this.requestRender=a;this.isEnable=!1;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=e=>{(e.touches.length>1||this.preventScroll)&&e.preventDefault()};this.onMouseWheelPreventScroll=e=>{this.preventScroll&&e.preventDefault()};this.eventContext=new Tm(e,t,n,o,i,l??!1),this.handlers={Spline:new Fm(this.eventContext),["Conditional"]:new zm(this.eventContext),["Start"]:new jm(this.eventContext),Basic:new Um(this.eventContext),["MouseHover"]:new Hm(this.eventContext),["Scroll"]:new Wm(this.eventContext),["Follow"]:new km(this.eventContext),["LookAt"]:new Vm(this.eventContext)}}activate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!0,e.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),this.resize(),qE.forEach(n=>{Object.values(this.handlers).some(i=>i.domEventsNeeded.has(n))&&t.addEventListener(n,this.onResetRaycaster)}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll)}deactivate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!1,Object.values(this.handlers).forEach(n=>n.disconnect()),e.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender)}),qE.forEach(n=>{t.removeEventListener(n,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll)}reset(){this.deactivate(),this.activate()}resize(){this.eventContext.updaterRect()}};var Zm=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new B().copy(n),this._editorSize=new B().copy(i),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(n/e,i/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;e<n&&(s=(n-e)*.5,s=-s,a=n),t<i&&(o=(i-t)*.5,o=-o,l=i),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,n=this._fov;if(e>t){let i=c4(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function c4(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var $E={RED:0,GREEN:1,BLUE:2,ALPHA:3};var hd="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var u4=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4918
+ `,D.addEventListener("pointerdown",()=>{y.forEach(F=>{F[0].movementState.jump=1}),i()}),D.addEventListener("touchend",F=>F.preventDefault()),this.joysticks[b]=[void 0,w];return}let P={zone:w,mode:"static",position:T,size:S};M==="hide"&&(P.restOpacity=0);let O=jM.create(P);O.on("move",(D,N)=>{y.forEach(F=>{let z=F[0];F[1]==="pos"?N.force<.2?z.moveForce=0:(z.movementState.movePosZ=Math.sin(-N.angle.radian),z.movementState.movePosX=Math.cos(-N.angle.radian),N.force<.3?z.moveForce=(N.force-.2)/.1:z.moveForce=1):N.force<.2?z.rotForce=0:(z.movementState.rotPosX=N.vector.y,z.movementState.rotPosY=-N.vector.x,N.force<.3?z.rotForce=(N.force-.2)/.1:z.rotForce=1)}),i()}),O.on("end",(D,N)=>{y.forEach(F=>{let z=F[0];F[1]==="pos"?(z.movementState.movePosZ=0,z.movementState.movePosX=0,z.moveForce=1):(z.movementState.rotPosX=0,z.movementState.rotPosY=0,z.rotForce=1)})}),this.joysticks[b]=[O,w]}),this.usePhysics===!1&&this.needsCollisionDetection&&this.initBVH(),this.initializationCounter++}initBVH(){let e=[];this.scene.updateMatrixWorld(!0);let t=new Set;if(this.scene.traverse(n=>{if(!!Kr(n))if(!n.visible||t.has(n))n.children.forEach(i=>Kr(i)&&t.add(i));else if(Object.keys(n.states).length||n.data?.events.some(i=>i.data.type==="GameControl")){let i=[];n.matrixWorld.decompose(Qn,Ts,_o);let s=new be().compose(Qn,Ts,HV);kt(n)&&i.push(bo(n.geometry,wa.makeScale(_o.x,_o.y,_o.z))),n.updateMatrixWorld();let o=s.clone().invert();if(n.traverse(a=>{!kt(a)||(a.updateMatrixWorld(),wa.multiplyMatrices(o,a.matrixWorld),i.push(bo(a.geometry,wa)))}),i.length>0){let a=xs(i,!1);n.boundsTree=new Jt(a),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(n)}}else kt(n)&&!this.sharedGameControlGlobals.entitiesWithTransformAnim.some(i=>n.isDescendantOf(i))&&e.push(bo(n.geometry,n.matrixWorld))}),e.length>0){let n=xs(e,!1);this.sharedGameControlGlobals.staticMeshBVH=new Jt(n)}}addCollider(e,t,n,i,s=!0){let o=e.rigidBody,a;i!==void 0?i.collider.type==="sphere"?a=en.ColliderDesc.ball(i.collider.radius/this.pixelsPerMeter):i.collider.type==="capsule"?a=en.ColliderDesc.capsule((i.collider.height/2-i.collider.radius)/this.pixelsPerMeter,i.collider.radius/this.pixelsPerMeter):a=en.ColliderDesc.cuboid(i.collider.width/this.pixelsPerMeter/2,i.collider.height/this.pixelsPerMeter/2,i.collider.depth/this.pixelsPerMeter/2):n.colliderType==="trimesh"?a=en.ColliderDesc.trimesh(t.getAttribute("position").array,t.getIndex().array):a=en.ColliderDesc.convexMesh(t.getAttribute("position").array,s?t.getIndex().array:void 0),a.setFrictionCombineRule(en.CoefficientCombineRule.Average).setRestitutionCombineRule(en.CoefficientCombineRule.Average).setDensity(n.density).setFriction(n.friction).setRestitution(n.restitution);let l=this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);if(this.sharedGameControlGlobals.colliderToEntity[l.handle]=e,i!==void 0){Qn.fromArray(i.collider.position).multiply(_o.setFromMatrixScale(e.matrixWorld)).divideScalar(this.pixelsPerMeter),l.setTranslationWrtParent(Qn);let u=new nt().setFromEuler(new Qt().setFromVector3(new A().fromArray(i.collider.rotation)));l.setRotationWrtParent(u),l.setActiveEvents(en.ActiveEvents.COLLISION_EVENTS)}else n.rigidBody==="dynamic"&&this.sharedGameControlGlobals.eventsPerObjects[e.uuid]?.some(u=>u.target==="scene")&&l.setActiveEvents(en.ActiveEvents.COLLISION_EVENTS)}initPhysics(e){this.sharedGameControlGlobals.rapierWorld=new en.World(new en.Vector3(0,e??-10,0)),this.events=new en.EventQueue(!0);let t=[],n=[],i=[];if(this.sceneGraph.traverse((u,c)=>{let h=this.scene.find(u);if(h&&Kr(h)&&h.visible){let d,f=c.states.some(p=>p.data.position!==void 0||p.data.rotation!==void 0||p.data.hiddenMatrix!==void 0),m=!1;for(let p of c.events)if(p.data.type==="GameControl")d=p.data;else if(p.data.type==="Collision"){m=!0;let g=new qm(p.data,h,this.scene,this.sharedAssets);this.sharedGameControlGlobals.eventsPerObjects[h.uuid]?this.sharedGameControlGlobals.eventsPerObjects[h.uuid].push(g):this.sharedGameControlGlobals.eventsPerObjects[h.uuid]=[g]}if(n.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(!c.physics){n.push(u);return}if(i.some(p=>this.sceneGraph.isDescendantOf(u,p)))return;if(c.physics.fusedBody===!0&&i.push(u),c.physics.rigidBody==="dynamic"&&c.physics.fusedBody===!1&&(h.matrixWorldFusedFalse=h.matrixWorld.clone()),c.physics.rigidBody==="dynamic"||f||m||d!==void 0){let p=[];d===void 0&&c.physics.rigidBody==="dynamic"&&(h.matrixWorld0=h.matrixWorld.clone(),h.matrixWorld.identity()),h instanceof wt&&h.geometry.getAttribute("position")!==void 0&&(h.matrixWorld0!==void 0&&h.geometry.applyMatrix4(h.matrixWorld0),p.push(bo(h.geometry)));let g=h.matrixWorld.clone().invert();if(c.physics.fusedBody&&h.traverse(v=>{v!==h&&(h.matrixWorld0?(wa.copy(v.matrixWorld),v.parent===h&&(v.hiddenMatrix0=v.hiddenMatrix.clone(),v.hiddenMatrix.premultiply(h.matrixWorld0))):wa.multiplyMatrices(g,v.matrixWorld),v instanceof wt&&v.geometry.getAttribute("position")!==void 0&&p.push(bo(v.geometry,wa)))}),p.length>0){let v=xs(p);v.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter),h.matrixWorld.decompose(Qn,Ts,_o),Qn.divideScalar(this.pixelsPerMeter);let y;d!==void 0?y=en.RigidBodyDesc.kinematicPositionBased():c.physics.rigidBody==="dynamic"?(y=en.RigidBodyDesc.dynamic(),y.setLinearDamping(c.physics.damping).setAdditionalMass(1e-9).setGravityScale(c.physics.gravityScale).enabledRotations(...c.physics.enabledRotation).enabledTranslations(...c.physics.enabledTranslation)):f?(y=en.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(h)):y=en.RigidBodyDesc.fixed(),y.setTranslation(Qn.x,Qn.y,Qn.z).setRotation(Ts);let b=this.sharedGameControlGlobals.rapierWorld.createRigidBody(y);d===void 0&&c.physics.rigidBody==="dynamic"&&this.rigidBodyToMesh.set(b.handle,[h,_o.clone(),c.physics.fusedBody]),h.rigidBody=b;let w=!(c.geometry===void 0||c.geometry.type==="SubdivGeometry"||c.geometry.type==="NonParametricGeometry"||c.geometry.type==="BooleanGeometry"||c.geometry.type==="VectorGeometry"||c.geometry.type==="StarGeometry"||c.geometry.type==="RectangleGeometry"||c.geometry.type==="EllipseGeometry"||c.geometry.type==="TriangleGeometry"||c.geometry.type==="TorusGeometry"||c.geometry.type==="HelixGeometry");try{this.addCollider(h,v,c.physics,d,w)}catch{this.addCollider(h,v,c.physics,d,!1)}}}else this.gameControlStates.some(([p])=>h.isDescendantOf(p))||(kt(h)&&t.push(bo(h.geometry,h.matrixWorld)),c.physics.fusedBody&&h.traverse(p=>{!kt(p)||p===h||t.push(bo(p.geometry,p.matrixWorld))}))}}),t.length===0)return;let s=xs(t);s.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let o=en.RigidBodyDesc.fixed(),a=this.sharedGameControlGlobals.rapierWorld.createRigidBody(o),l=en.ColliderDesc.trimesh(s.getAttribute("position").array,s.getIndex().array).setFrictionCombineRule(en.CoefficientCombineRule.Multiply).setRestitutionCombineRule(en.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(l,a)}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}dispose(){this.scene.traverse(e=>{let t=e;if(t.matrixWorld0){let n=wa.copy(t.matrixWorld0).invert();t instanceof wt&&t.geometry.applyMatrix4(n),t.matrixWorld.copy(t.matrixWorld0),t.matrixWorld0=void 0}t.hiddenMatrix0&&(t.hiddenMatrix=t.hiddenMatrix0,t.hiddenMatrix0=void 0),t.matrixWorldFusedFalse&&(t.matrixWorldFusedFalse=void 0),t.rigidBody&&(t.rigidBody=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.staticMeshBVH=void 0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.gameControls.forEach(e=>{e.reset(),e.dispose()}),this.gameControls=[],this.joysticks.forEach(([e,t])=>{e?.destroy(),t.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls?.dispose(),this.orbitControls=void 0;for(let e of Object.values(this.sharedGameControlGlobals.eventsPerObjects))e.forEach(t=>t.disconnect());this.sharedGameControlGlobals.eventsPerObjects={},this.scene.updateMatrixWorld(!0)}update(e){let t=!0;if(this.orbitControls!==void 0&&(t=!this.orbitControls.update()),this.initializationCounter>=0&&this.initializationCounter<2)this.initializationCounter++,t=!1;else if(this.initializationCounter===2)for(let n of this.gameControls)t=!n.update(e)&&t;if(this.usePhysics&&(this.gameControls.length===0||this.needsCollisionDetection)){for(let n of this.sharedGameControlGlobals.entitiesWithTransformAnim){n.matrixWorld.decompose(Qn,Ts,_o),wx.setFromQuaternion(Ts);let i=n;i.prevR===void 0?(i.prevR=wx.clone(),i.prevT=Qn.clone()):(i.prevR.copy(wx),i.prevT.copy(Qn)),n.rigidBody.setNextKinematicTranslation(Qn.divideScalar(this.pixelsPerMeter)),n.rigidBody.setNextKinematicRotation(Ts)}this.sharedGameControlGlobals.rapierWorld.step(this.events),this.events?.drainCollisionEvents(this.handleCollisionEvents),t=!this.updatePositions()&&t}return t}dispatchCollisionEvent(e,t){t.dispatchEvent(Sx),e.dispatch()}};var Ax={type:"change"},jV={type:"lock"},qV={type:"unlock"},XV=new A,Sa=new A,YV=new A,_n=new A,kn=new A,Fr=new A,ld=new be,kE=new be,QV=new be,ZV=new be,Yc=new nt,cd=new nt,KV=new Qt(0,0,0,"YXZ"),Aa=new A(0,1,0),_x=new A(1,1,1),JV=1,$V=.025,e4=16e-6,t4=12,n4=20,Zn=new gn,ei=new Mt,Ym=class extends Lt{constructor(t,n,i,s,o,a,l,u,c,h){super();this.object=t;this.sceneGraph=n;this.domElement=i;this.sharedGameControlGlobals=a;this.cameraFollow=l;this.camera=u;this.scene=c;this.sharedAssets=h;this.enableDamping=!0;this.position0=new A;this.rotation0=new Qt(0,0,0,"XYZ");this.scale0=new A;this.hiddenMatrix0=new be;this.target0=new A;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.euler0=new Qt(0,0,0,"YXZ");this.position0Cam=new A;this.quat0Cam=new nt;this.scale0Cam=new A;this.hiddenMatrix0Cam=new be;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.collider={radius:40,segment:new gn(new A(0,-40,0),new A(0,40,0)),matrix:new be,position:new A,rotation:new nt};this.euler=new Qt(0,0,0,"YXZ");this.eulerDelta=new A;this.lastQuaternion=new nt;this.lastPosition=new A;this.lastCameraQuaternion=new nt;this.lastCameraPosition=new A;this.PI_2=Math.PI/2;this.prevMouse=new B;this.velocityTarget=new A;this.velocity=new A;this.directionXZ=new A;this.rotVelocityStick=new A;this.rotVelocityTarget=new A;this.rotVelocity=new A;this.rotDirection=new A;this.objectRot={x:0,y:0};this.firstPointerId=-1;this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0};this.onObject=!1;this.actionState={};this.slopeAdjust=!1;this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new be;this.objectToTarget=new A;this.objectToTarget0=new A;this.objectToCamXZ=new A;this.objectToCamXZ0=new A;this.targetToCamera=new A;this.targetToCamera0=new A;this.cameraPolarAxis0=new A;this.targetPos=new A;this.targetQuat=new nt;this.lerpFactorPos=new A().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new nt;this.objXZQuatInv=new nt;this.objXZRotMat=new be;this.isFirstPerson=!1;this.actions={};this.lastDummyPos=new A;this.lastDummyPosDelta=new A;this.hit=null;this.groundVelocity=new A;this.pushedVelocity=new A;this.groundYRotation=0;this.objectRealQuat=new nt;this.colliderWorldQuat=new nt;this.groundNormal=new A;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.onPointerDown=t=>{t.target!==this.domElement||this.firstPointerId!==-1||(this.firstPointerId=t.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!vn&&(!Kl||Jl>=15.5)&&this.domElement.requestPointerLock(),this.prevMouse.set(t.clientX,t.clientY))};this.onPointerUp=t=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),t.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=t=>{if(t.pointerId!==this.firstPointerId)return;let n=t.clientX-this.prevMouse.x,i=t.clientY-this.prevMouse.y;this.prevMouse.set(t.clientX,t.clientY),t.pointerType==="mouse"&&this.rotBy!=="keys"&&(Kl&&Jl<15.5&&!vn?(this.eulerDelta.y=-n*this.mouseOrbitSensitivity,this.eulerDelta.x=-i*this.mouseOrbitSensitivity):(this.eulerDelta.y=-t.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-t.movementY*this.mouseOrbitSensitivity)),t.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-n*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-i*this.mouseOrbitSensitivity*5),this.dispatchEvent(Ax)};this.onPointerlockChange=t=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(jV),Ym.isLocked=!0):(this.dispatchEvent(qV),Ym.isLocked=!1)};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.onKeyDown=t=>{t.preventDefault();for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]){this.movementState[n[0]]=1;break}this.dispatchEvent(Ax)};this.onKeyUp=t=>{for(let n of this.keyAssignments)if(t.key.toUpperCase()===n[1]||t.key===n[1]||t.code.slice(3,t.code.length).toUpperCase()===n[1]){this.movementState[n[0]]=0;break}};this.resetChildrenToBaseState=(t,n)=>{if(t===this.object.uuid)return;let i=this.scene.find(t);i.currentState!==null&&sx(i,n,null,this.sharedAssets)};if(t.objectType==="CombinedCamera"&&(this.isFirstPerson=!0),this.position0.copy(this.object.position),this.rotation0.copy(this.object.rotation),this.scale0.copy(this.object.scale),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.rotation.reorder("YXZ"),this.euler0.copy(this.object.rotation),this.isFirstPerson===!1){let m=this.object.rotation.y;this.objectRealQuat.copy(this.object.quaternion),this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,m,0)}if(this.object.matrixAutoUpdate=!1,this.isFirstPerson){let m=this.object;this.target0.copy(m.getTarget()),this.zoom0=m.zoom}else this.cameraFollow===!0&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom);if(this.cameraFollow===!0){if(this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera?.parent?.parent){let y=this.camera.matrix.clone().invert().premultiply(this.camera.matrixWorld),b=y.clone().invert();this.camera.hiddenMatrix.multiply(b),this.camera.matrix.premultiply(y),this.camera.matrixWorld.decompose(this.camera.position,this.camera.quaternion,this.camera.scale)}this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let m=new A(0,0,-1).applyQuaternion(this.camera.quaternion),p=new A().subVectors(this.object.position,this.camera.position);this.objectToCamXZ.copy(p),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let g;if(Math.abs(m.y)<1e-6){p.y=0,m.y=0;let y=p.projectOnVector(m);this.targetToCamera0.copy(y).negate(),g=this.camera.position.clone().add(y)}else{let y=m.multiplyScalar(p.y/m.y);this.targetToCamera0.copy(y).negate(),g=y.clone().add(this.camera.position)}this.objectToTarget0.subVectors(g,this.object.position);let v=new Qt().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-v.x,v.x=0,v.z=0,v.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(v)}if(this.isObjectCamera=this.object.objectType==="CombinedCamera",this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.connect(),this.rotByTouch=s.rotByTouch??"joystick",this.rotBy=s.rotBy??"keys",this.rotationMode=s.rotationMode??"normal",this.moveMode=s.moveMode??"walk",this.collisionEnabled=s.collisionEnabled,this.speedTranslate=(s.speedTranslate??250)*JV,this.speedOrbit=(s.speedRotate??100)*$V,this.mouseOrbitSensitivity=(s.speedRotate??100)*e4,this.keyAssignments=s.keyAssignments.map(m=>{let p=[m[0],m[1]];return p[1]==="\u25B2"?p[1]="ArrowUp":p[1]==="\u25C0"?p[1]="ArrowLeft":p[1]==="\u25BC"?p[1]="ArrowDown":p[1]==="\u25B6"?p[1]="ArrowRight":p[1]==="\u21E7"?p[1]="Shift":p[1]==="\u21B5"?p[1]="Enter":p[1]==="Space"?p[1]=" ":p[1]==="\u2318"?p[1]="Meta":p[1]==="Ctrl"?p[1]="Control":p[1]==="Esc"&&(p[1]="Escape"),p}),s.rotBy==="mouse"){let m;m=this.keyAssignments.findIndex(p=>p[0]==="rotNegX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosX"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotPosY"),m!==-1&&(this.keyAssignments[m][1]=""),m=this.keyAssignments.findIndex(p=>p[0]==="rotNegY"),m!==-1&&(this.keyAssignments[m][1]="")}this.lerpFactorPosStart=1-.02**(1/((s.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((s.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((s.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((s.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((s.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((s.delayRotCamera??.3)*60)),this.gravity=(o.gravity??qr.defaultData.gravity)*t4,this.pixelsPerMeter=o.pixelsPerMeter??qr.defaultData.pixelsPerMeter,this.usePhysics=o.usePhysics??qr.defaultData.usePhysics,this.jumpPower=s.jumpPower*n4,this.resetYPosition=s.resetYPosition,this.orientMode=s.autoOrientMove?s.orientMode:"none",this.orientWith=s.orientWith??Mp.defaultDataThirdPerson.orientWith,s.collider.type==="capsule"?(this.collider.radius=s.collider.radius,this.collider.segment.start.y=s.collider.height/2-s.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y):s.collider.type==="sphere"&&(this.collider.radius=s.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0);let d=new A().fromArray(s.collider.position),f=new nt().setFromEuler(new Qt().fromArray([...s.collider.rotation,"XYZ"]));this.collider.position.copy(d).multiply(this.object.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(d,f,_x),s.cameraXAxis!==void 0&&(this.cameraXAxis=s.cameraXAxis,this.cameraYAxis=s.cameraYAxis,this.minPolarAngle=s.cameraRotXLimits[0],this.maxPolarAngle=s.cameraRotXLimits[1],this.minAzimuthAngleRel=s.cameraRotYLimits[0],this.maxAzimuthAngleRel=s.cameraRotYLimits[1]),s.gameActions!==void 0&&Object.entries(s.gameActions).forEach(([m,p],g)=>{p.forEach(({id:v,data:y})=>{try{this.actions[m]===void 0&&(this.actions[m]=[]),y.type==="Transition"?this.actions[m].push(new $i(v,y,c,h)):y.type==="Audio"&&this.actions[m].push(new Zi(v,y,t,h))}catch{}})}),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle")}reset(t=!1){if(this.object.rotation.copy(this.rotation0),this.object.position.copy(this.position0),this.object.scale.copy(this.scale0),this.object.hiddenMatrix.copy(this.hiddenMatrix0),t===!0){if(this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.object.position,this.object.quaternion,this.object.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.rotation.reorder("YXZ"),this.isFirstPerson===!1){let n=this.object.rotation.y;this.object.rotation.y=0,this.objXZQuat.copy(this.object.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.object.quaternion),this.object.rotation.set(0,n,0)}this.euler.setFromQuaternion(this.object.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}this.isObjectCamera?this.object.matrixAutoUpdate=!0:this.object.updateMatrix(),this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.dispatchEvent(Ax)}connect(){this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError)}disconnect(){this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError)}dispose(){this.disconnect(),Object.values(this.actions).forEach(t=>{t.forEach(n=>{(n instanceof $i||n instanceof Zi)&&n.dispose()})})}resetTo(t,n,i){}dispatchStartEvent(t){this.actions[t]!==void 0&&(this.actionState[t]||(this.actionState[t]=!0,this.actions[t].forEach(n=>{n instanceof $i?n.play():n instanceof Zi&&n.dispatchGameControl("start")})))}dispatchStopEvent(t){this.actions[t]!==void 0&&(!this.actionState[t]||(this.actionState[t]=!1,this.actions[t].forEach(n=>{n instanceof $i?n.stop():n instanceof Zi&&n.dispatchGameControl("stop")}),this.sceneGraph.traverseFrom(this.object.uuid,this.resetChildrenToBaseState)))}update(t){if(this.gravity<0?this.object.position.y<this.resetYPosition:this.object.position.y>this.resetYPosition)return this.reset(!0),!0;let n=(this.isFirstFrame?16.6:t)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let i=n*60;if(this.usePhysics){let o=kn.set(0,-(this.jumpPower+this.gravity*i)*n*.5,0).divideScalar(this.pixelsPerMeter),a=this.sharedGameControlGlobals.rapierWorld.castShape(_n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,o,this.object.rigidBody?.collider(0).shape,1,void 0,void 0,void 0,this.object.rigidBody);if(this.slopeAdjust=!1,a){this.slopeAdjust=!1,this.groundNormal.set(a.normal2.x,a.normal2.y,a.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),Math.acos(this.groundNormal.y)*180/Math.PI>45?this.onObject=!0:(this.slopeAdjust=!0,this.onObject=!0);let l=a.collider._parent;this.groundYRotation=0,this.groundVelocity.set(0,0,0);for(let u of this.sharedGameControlGlobals.entitiesWithTransformAnim)if(u.rigidBody===l){u.matrixWorld.decompose(_n,cd,kn),this.groundVelocity.subVectors(_n,u.prevT),this.object.getWorldPosition(kn).add(this.collider.position).sub(u.position),this.groundYRotation=KV.setFromQuaternion(cd).y-u.prevR.y,Fr.copy(kn).applyAxisAngle(Aa,this.groundYRotation),this.groundVelocity.add(Fr.sub(kn)).divideScalar(n);break}}else this.onObject=!1}this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.velocityTarget.y+=this.onObject?0:this.gravity*i),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.directionXZ.normalize(),this.movementState.moveNegZ||this.movementState.movePosZ?this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce:this.velocityTarget.z=0,this.movementState.moveNegX||this.movementState.movePosX?this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce:this.velocityTarget.x=0,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.hit===null&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**i),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**i),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**i)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("move")));let s=YV.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let o=kn.copy(s);o.y=0,s.set(0,s.y,o.length()*-1)}if(s.applyQuaternion(this.object.quaternion),this.slopeAdjust&&(cd.setFromUnitVectors(Aa,this.groundNormal),s.applyQuaternion(cd)),this.usePhysics===!0){let o=kn;this.pushedVelocity.set(0,0,0);for(let a of this.sharedGameControlGlobals.entitiesWithTransformAnim){a.parent?.matrixWorldFusedFalse?(ld.multiplyMatrices(a.parent?.matrixWorldFusedFalse,a.matrix),Fr.setFromMatrixPosition(ld)):Fr.copy(a.position);let l=Fr.sub(a.prevT).divideScalar(n);l.divideScalar(this.pixelsPerMeter);let u=a.rigidBody.collider(0).castCollider(l,this.object.rigidBody.collider(0),_n.copy(s).divideScalar(this.pixelsPerMeter),n);if(l.multiplyScalar(this.pixelsPerMeter),u!==null){this.pushedVelocity.copy(l),o.copy(u.normal1).applyQuaternion(a.quaternion);break}}if(this.pushedVelocity.manhattanLength()!==0){let a=o.dot(s);a<0&&s.addScaledVector(o,-a),s.add(this.pushedVelocity)}else s.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(n),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**i):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**i),this.euler.x+=this.rotVelocity.x*n,this.euler.y+=this.rotVelocity.y*n+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*n),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){let o=_n,a=kn.copy(this.directionXZ);a.x*=-1,this.camera.getWorldDirection(o);let l=Fr.copy(Aa).multiplyScalar(o.dot(Aa));if(o.sub(l),Fr.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.orientWith==="camera"?this.object.rotation.y=o.angleTo(a)*(o.cross(a).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera:this.object.rotation.y=this.euler.y+Math.atan2(-this.directionXZ.z,this.directionXZ.x)-Math.PI/2,Sa.copy(this.collider.position).applyQuaternion(this.object.quaternion),Sa.sub(Fr),this.object.position.sub(Sa),this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(Aa,this.euler.y-this.euler0.y);let u=kn.copy(this.objectToCamXZ).normalize(),c=Fr.copy(s).multiplyScalar(n);c.y=0;let h=c.sub(_n.copy(u).multiplyScalar(c.dot(u))).cross(u).y;this.euler.y-=Math.atan2(h,this.objectToCamXZ.length())}}if(this.cameraFollow===!0&&this.moveMode==="walk"&&this.isFirstPerson===!1?this.cameraXAxis==="Limit"?this.euler.x=Be.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=Be.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):(this.cameraXAxis==="Limit"||this.isFirstPerson||this.cameraFollow===!0)&&(this.euler.x=Be.clamp(this.euler.x,-this.PI_2,this.PI_2)),(this.isFirstPerson||this.moveMode!=="walk")&&(this.object.rotation.x=this.euler.x),(this.isFirstPerson||this.orientMode==="none"||this.directionXZ.manhattanLength()===0)&&(Fr.copy(this.collider.position).applyQuaternion(this.object.quaternion),this.object.rotation.y+=this.rotVelocity.y*n+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.object.rotation.y),Sa.copy(this.collider.position).applyQuaternion(this.object.quaternion),Sa.sub(Fr),this.object.position.sub(Sa)),this.object.rotation.x=Be.clamp(this.object.rotation.x,-this.PI_2,this.PI_2),this.objectRot.x=this.euler.x,this.objectRot.y=this.euler.y,this.objectRealQuat.multiplyQuaternions(this.object.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics){if(this.hit=this.sharedGameControlGlobals.rapierWorld.castShape(_n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,kn.copy(s).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,n,8,void 0,void 0,this.object.rigidBody),this.hit!==null){let o=this.sharedGameControlGlobals.colliderToEntity[this.hit.collider.handle];if(o!==this.lastHitObj){this.lastHitObj=o;let l=this.sharedGameControlGlobals.eventsPerObjects[o?.uuid];if(l)for(let u of l)u.data.target==="character"&&(o.dispatchEvent(Sx),u.dispatch())}let a=_n.set(this.hit.normal2.x,this.hit.normal2.y,this.hit.normal2.z).applyQuaternion(this.colliderWorldQuat);if(this.hit.toi>0){let l=kn.copy(s).multiplyScalar(this.hit?.toi).dot(a),u=this.hit.toi;l>2&&(u=this.hit.toi*(l-2)/l,this.object.position.addScaledVector(s,u));let c=kn.copy(s).multiplyScalar(n-u);a.multiplyScalar(c.dot(a));let h=c.sub(a),d=this.sharedGameControlGlobals.rapierWorld.castShape(_n.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.object.position).divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,Fr.copy(h).divideScalar(this.pixelsPerMeter),this.object.rigidBody?.collider(0).shape,20,8,void 0,void 0,this.object.rigidBody);if(d===null)this.object.position.add(h);else if(d.toi>1){let f=_n.set(d.normal2.x,d.normal2.y,d.normal2.z).applyQuaternion(this.colliderWorldQuat);kn.copy(h).dot(f)>2&&this.object.position.add(h)}this.lastDummyPosDelta.subVectors(this.object.position,this.lastDummyPos),this.lastDummyPos.copy(this.object.position)}}else this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),this.object.position.addScaledVector(s,n);this.object.rigidBody?.setTranslation(_n.copy(this.object.position).divideScalar(this.pixelsPerMeter),!0),this.object.rigidBody?.setRotation(Yc.copy(this.object.quaternion).multiply(this.objXZQuat),!0)}else{let o=this.onObject?1:5,a=s.multiplyScalar(n/o);for(let l=0;l<o;l++)this.object.position.add(a),this.collisionAdjustment(n/o)}else this.object.position.addScaledVector(s,n);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuat),this.isObjectCamera||this.object.updateMatrix(),this.isFirstPerson===!1&&this.object.quaternion.multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let o=this.objectToTarget.add(this.object.position),a=this.targetToCamera.add(o);ld.lookAt(a,o,Aa).setPosition(a),ld.decompose(this.targetPos,this.targetQuat,_n),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**i),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**i),this.camera.updateMatrix(),this.camera.matrixWorldNeedsUpdate=!0,this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=Be.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=Be.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.lastPosition.distanceToSquared(this.object.position)<this.threshEndTranslate&&8*(1-this.lastQuaternion.dot(this.object.quaternion))<this.threshEndRotate&&(!this.camera||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode!=="walk"||this.onObject===!0||this.collisionEnabled===!1)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let t=Yc.setFromAxisAngle(Aa,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?Be.clamp(this.objectRot.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.objectRot.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(t);let n;this.cameraXAxis==="Limit"?n=Be.clamp(this.objectRot.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):n=Be.clamp(this.objectRot.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let i=_n.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&i.applyQuaternion(t);let s=cd.setFromAxisAngle(i,n);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(t),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(s)}collisionAdjustment(t){let n=Sa.set(0,0,0);this.object.updateMatrix();let i=ld.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(_n,Yc,kn).compose(_n,Yc,_x);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(o=>{if(o===this.object||o.isDescendantOf(this.object))return;ei.makeEmpty();let a=ZV.copy(o.matrixWorld).decompose(_n,Yc,kn).compose(_n,Yc,_x),l=kE.copy(a).invert(),u=QV.copy(kE).multiply(i);Zn.copy(this.collider.segment),Zn.start.applyMatrix4(u),Zn.end.applyMatrix4(u);let c=XV.copy(this.object.position).applyMatrix4(l);ei.expandByPoint(Zn.start),ei.expandByPoint(Zn.end),ei.min.addScalar(-this.collider.radius),ei.max.addScalar(this.collider.radius),o.boundsTree.shapecast({intersectsBounds:h=>h.intersectsBox(ei),intersectsTriangle:h=>{let d=_n,f=kn,m=h.closestPointToSegment(Zn,d,f);if(m<this.collider.radius){let p=this.collider.radius-m,g=f.sub(d).normalize(),v=Fr.copy(c);v.addScaledVector(g,p);let y=v.applyMatrix4(a).sub(this.object.position);n.add(y),Zn.start.addScaledVector(g,p),Zn.end.addScaledVector(g,p)}}})}),ei.makeEmpty(),Zn.copy(this.collider.segment),Zn.start.applyMatrix4(i),Zn.end.applyMatrix4(i),ei.expandByPoint(Zn.start),ei.expandByPoint(Zn.end),ei.min.addScalar(-this.collider.radius),ei.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({intersectsBounds:o=>o.intersectsBox(ei),intersectsTriangle:o=>{let a=_n,l=kn,u=o.closestPointToSegment(Zn,a,l);if(u<this.collider.radius){let c=this.collider.radius-u,h=l.sub(a).normalize();n.addScaledVector(h,c),Zn.start.addScaledVector(h,c),Zn.end.addScaledVector(h,c)}}}),this.onObject=n.y>Math.abs(t*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let s=Math.max(0,n.length()-1e-5);n.normalize().multiplyScalar(s),this.object.position.add(n)}},ad=Ym;ad.isLocked=!1;var Tx={type:"change"},VE={type:"changeZoom"},r4={type:"changePan"},Qc={type:"start"},ud={type:"end"},Mx=new nt,i4=new B,s4=2*Math.PI,o4=1e-8,a4=.01,HE=2,Ex=.125,WE=2,Cx=1,Px=1,Dx=.1;var Xc=class extends Lt{constructor(t,n,i=!1){super();this.object=t;this.domElement=n;this.isExport=i;this.enabled=!0;this.useKeyEvents=!0;this.enableDamping=!1;this.enableZoom=!0;this.enableRotate=!0;this.enablePan=!0;this.autoRotate=!1;this.rotationLimitsMode=0;this.panLimitsMode=0;this.rotationSoftLimit=2;this.panSoftLimit=2;this.hoverRotatePanMode=0;this.zoomLimitsEnabled=!1;this.mouseButtons=[0,5];this.mouseButtonsPlay=[3,4,5];this.touches=[null,Cr.DOLLY_ROTATE,Cr.PAN];this.offset=new A;this.eye=new A;this.lastPosition=new A;this.lastQuaternion=new nt;this.current=new B;this.overShoot=new B;this.overRatio=new B;this.spherical=new Ou;this.sphericalDelta=new Ou;this.panOffset=new A;this.panLeftV=new A;this.panUpV=new A;this.panV=new A;this.rotateStart=new B;this.rotateEnd=new B;this.rotateDelta=new B;this.panStart=new B;this.panEnd=new B;this.panDelta=new B;this.dollyStart=new B;this.dollyEnd=new B;this.dollyDelta=new B;this.rotationRangeFactor=new B;this.panRangeFactor=new B;this.state=-1;this.zoomChanged=!1;this.isPointerDown=!1;this.isFirstHover=!0;this.isThetaFlipped=!1;this.prevScale=0;this.scale=1;this.gesture=!1;this.timer=-1;this.timerHover=-1;this.minDistance=0;this.maxDistance=1/0;this.minZoom=0;this.maxZoom=1/0;this.minPhi=0;this.maxPhi=Math.PI;this.minTheta=-1/0;this.maxTheta=1/0;this.minH=0;this.maxH=Math.PI;this.minV=-1/0;this.maxV=1/0;this.autoRotateClockwise=!0;this.isPanOverShoot=!1;this.isRotateOverShoot=!1;this.update=()=>{let t=this.object.position;this.offset.copy(t).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&this.state===-1&&this.rotateLeft((this.autoRotateClockwise===!0?1:-1)*this.getAutoRotationAngle()),this.rotationLimitsMode!==0&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),this.rotationLimitsMode!==2&&(this.spherical.phi+=this.sphericalDelta.phi),(this.rotationLimitsMode!==1||this.autoRotate===!0)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),this.panLimitsMode!==0&&(this.target.applyQuaternion(Mx.copy(this.object.quaternion).invert()),this.panOffset.applyQuaternion(Mx),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion(this.object.quaternion),this.panOffset.applyQuaternion(this.object.quaternion)),this.panLimitsMode===2&&(this.panOffset.y=0),this.panLimitsMode===1&&(this.panOffset.x=0),this.state===-1&&!this.gesture?(this.panOffset.multiplyScalar(1-Ex),this.target.add(this.panOffset)):(this.target.add(this.panOffset),this.panOffset.set(0,0,0)),this.offset.setFromSpherical(this.spherical),t.copy(this.target).add(this.offset);let n=this.spherical.phi%s4;return this.eye.copy(this.offset).normalize(),this.object.up.copy(ht.DefaultUp).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),n>0&&n>Math.PI||n<0&&n>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),this.state===-1||this.enableDamping===!0?(this.sphericalDelta.theta*=1-Ex,this.sphericalDelta.phi*=1-Ex):this.sphericalDelta.set(0,0,0),this.scale=1,this.zoomChanged||this.lastPosition.distanceToSquared(this.object.position)>a4||8*(1-this.lastQuaternion.dot(this.object.quaternion))>o4?(this.dispatchEvent(Tx),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),this.zoomChanged=!1,!0):(this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),!1)};this.onPointerDown=t=>{this.enabled!==!1&&(this.isPointerDown=!0,$e.length===1&&(this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)),t.pointerType==="touch"||t.pointerType==="pen"&&vn?this.onPointerDownTouch(t):this.onPointerDownMouse(t))};this.onPointerMove=t=>{this.enabled!==!1&&(t.pointerType==="touch"||t.pointerType==="pen"&&vn?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t))};this.onPointerUp=t=>{this.isPointerDown=!1,$e.length===0&&(this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)),this.dispatchEvent(ud),this.state=-1};this.onPointerDownMouse=t=>{let n;switch(this.useKeyEvents?n=this.mouseButtons[t.button]:n=this.mouseButtonsPlay[t.button],n){case 0:if(t.altKey===!0&&!t.shiftKey&&!oh(t)){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else if(this.key===" "){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;case 4:if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(oh(t)||t.shiftKey){if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}else{if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(oh(t)||t.shiftKey){if(this.enableRotate===!1)return;this.handleMouseDownRotate(t),this.state=0}else{if(this.enablePan===!1)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Qc)};this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(this.enableRotate===!1)return;this.handleMouseMoveRotate(t);break;case 1:if(this.enableZoom===!1)return;this.handleMouseMoveDolly(t);break;case 2:if(this.enablePan===!1)return;this.handleMouseMovePan(t);break}};this.onPointerDownTouch=t=>{switch(this.touches[$e.length-1]){case Cr.ROTATE:if(this.enableRotate===!1){this.state=-1;return}this.handleTouchStartRotate(),this.state=3;break;case Cr.PAN:if(this.enablePan===!1){this.state=-1;return}this.handleTouchStartPan(),this.state=4;break;case Cr.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchStartDollyPan(),this.state=5;break;case Cr.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}this.state!==-1&&this.dispatchEvent(Qc)};this.onPointerMoveTouch=t=>{switch(this.state){case 3:if(this.enableRotate===!1)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(this.enablePan===!1)return;this.handleTouchMovePan(t),this.update();break;case 5:if(this.enableZoom===!1&&this.enablePan===!1)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(this.enableZoom===!1&&this.enableRotate===!1)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}};this.dispatchEndDebounced=Wu(()=>this.dispatchEvent(ud),33);this.onMouseWheel=t=>{this.enabled===!1||this.enableZoom===!1&&this.enablePan===!1||(this.isExport===!1&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(Qc),this.handleMouseWheel(t),this.dispatchEndDebounced())};this.onGesture=t=>{if(this.enabled!==!1)if(t.preventDefault(),t.type==="gesturechange"){if(this.enableZoom===!1)return;this.dispatchEvent(Qc),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update()}else this.dispatchEvent(ud)};this.onContextMenu=t=>{this.enabled!==!1&&t.preventDefault()};this.onTouchEnd=t=>{t.preventDefault()};this.onKeyDown=t=>{this.enabled!==!1&&(this.key=t.key)};this.onKeyUp=()=>{this.enabled!==!1&&(this.key=void 0,this.state!==-1&&this.onPointerUp($e[0]))};this.onPointerHover=t=>{if(!(t.pointerType!=="mouse"||this.enabled===!1||this.state!==-1||this.hoverRotatePanMode===2&&this.isPanOverShoot||this.hoverRotatePanMode===1&&this.isRotateOverShoot)){if(window.clearTimeout(this.timerHover),this.isPointerDown=!0,this.isFirstHover){let n={clientX:window.innerWidth/2,clientY:window.innerHeight/2};this.hoverRotatePanMode===2?this.handleMouseDownPan(n):this.hoverRotatePanMode===1&&this.handleMouseDownRotate(n),this.isFirstHover=!1}this.hoverRotatePanMode===2?this.handleMouseMovePan(t,Dx):this.hoverRotatePanMode===1&&this.handleMouseMoveRotate(t,Dx),this.timerHover=window.setTimeout(()=>{this.isPointerDown=!1},30)}};this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.connect(),this.update()}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.isUpVectorFlipped=this.isUpVectorFlipped0,this.object.updateProjectionMatrix(),this.dispatchEvent(Tx),this.isFirstHover=!0,this.update(),this.state=-1}resetTo(t,n,i,s=!1){this.target.copy(t),this.object.position.copy(n),this.object.zoom=i,this.object.isUpVectorFlipped=s,this.object.updateProjectionMatrix(),this.dispatchEvent(Tx),this.update(),this.state=-1}fromJSON(t){this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.isFirstHover=!0,this.hoverRotatePanMode!==0&&this.domElement.addEventListener("pointermove",this.onPointerHover),Dx=(t.hoverRotatePanStrength/100)**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/t.zoomLimits.max,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,HE=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let i=this.object.getTarget().applyQuaternion(Mx.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+i.y,this.maxV=t.panVerticalOffset.max+i.y,this.minH=-t.panHorizontalOffset.min+i.x,this.maxH=t.panHorizontalOffset.max+i.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=To(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=To(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=To(this.spherical.theta-t.rotationHorizontalOffset.min),this.maxTheta=To(this.spherical.theta+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,t.orbitTouches===1&&(this.touches[0]=Cr.ROTATE),t.panTouches===1&&(this.touches[0]=Cr.PAN),t.orbitTouches===2&&(this.touches[1]=Cr.DOLLY_ROTATE),t.panTouches===2&&(this.touches[1]=Cr.DOLLY_PAN),t.orbitTouches===3&&(this.touches[2]=Cr.ROTATE),t.panTouches===3&&(this.touches[2]=Cr.PAN)}connect(){this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),sh||(this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture)),this.domElement.addEventListener("touchend",this.onTouchEnd)}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),sh||(this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture)),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,n,i,s,o,a,l,u){this.overShoot.set(0,0);let c,h,d;t instanceof A?(c=t.x,h=t.y,this.current.set(this.target.x,this.target.y),d=!0):(c=t.theta,h=t.phi,this.current.set(To(this.spherical.theta),To(this.spherical.phi)),d=!1),i===0&&(this.current.x+=c,this.current.y+=h),(n===3||n===2)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x),s===o&&(c=0)),(n===3||n===1)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<l&&(this.overShoot.y=l-this.current.y),a===l&&(h=0)),d||(this.overShoot.x=To(this.overShoot.x),this.overShoot.y=To(this.overShoot.y)),i!==0?(this.overRatio.copy(this.overShoot).divide(u),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),i===1&&(this.overRatio.x=jE(Math.abs(this.overRatio.x)),this.overRatio.y=jE(Math.abs(this.overRatio.y))),this.isPointerDown||i===1?i===2&&(this.overRatio.x>.9||this.overRatio.y>.9)?this.isPointerDown=!1:(c*this.overShoot.x<0&&(c*=1-this.overRatio.x),h*this.overShoot.y<0&&(h*=1-this.overRatio.y)):i===2&&(!d&&(this.overRatio.x>.002||this.overRatio.y>.002)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(c=this.overShoot.x*.05,h=this.overShoot.y*.05,d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(c+=this.overShoot.x,h+=this.overShoot.y),t instanceof A?(t.x=c,t.y=h):(t.theta=c,t.phi=h)}setEnableDampingSpeed(t){this.enableDamping=t,Cx=t===!0?.2:1}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0}getAutoRotationAngle(){return 2*Math.PI/60/60*HE}getZoomScale(){return Math.pow(.95,WE)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,n){this.panLeftV.setFromMatrixColumn(n,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,n){this.panUpV.setFromMatrixColumn(n,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,n){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrix),this.panUp(2*n*o/i.clientHeight,this.object.matrix)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this.panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix));this.dispatchEvent(r4)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(VE)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(VE)}zoomOut(t=this.getZoomScale()){this.dispatchEvent(Qc),this.dollyOut(t),this.dispatchEvent(ud)}zoomIn(t=this.getZoomScale()){this.dispatchEvent(Qc),this.dollyIn(t),this.dispatchEvent(ud)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,n=1){Kl&&Jl<15.5&&!vn?(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)):this.rotateDelta.set(t.movementX,t.movementY),this.rotateDelta.multiplyScalar(Cx*n).rotateAround(i4,-this.object.angleOffsetFromUp);let i=this.domElement;this.rotateLeft(2*Math.PI*this.rotateDelta.x/i.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/i.clientHeight),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,n=1){Kl&&Jl<15.5&&!vn?(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)):this.panDelta.set(t.movementX,t.movementY),this.panDelta.multiplyScalar(Px*n),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(K1===!1&&oh(t)===!1&&l4(t)===!0){if(this.enablePan===!1)return;this.gesture?(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(Px),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()):(this.gesture=!0,this.isPointerDown=!0),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1},30)}else{if(this.enableZoom===!1)return;t.deltaY===0?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}}handleTouchStartRotate(){if($e.length===2){let t=.5*($e[0].pageX+$e[1].pageX),n=.5*($e[0].pageY+$e[1].pageY);this.rotateStart.set(t,n)}else this.rotateStart.set($e[0].pageX,$e[0].pageY)}handleTouchStartPan(){if($e.length===2){let t=.5*($e[0].pageX+$e[1].pageX),n=.5*($e[0].pageY+$e[1].pageY);this.panStart.set(t,n)}else this.panStart.set($e[0].pageX,$e[0].pageY)}handleTouchStartDolly(){let t=$e[0].pageX-$e[1].pageX,n=$e[0].pageY-$e[1].pageY,i=Math.sqrt(t*t+n*n);this.dollyStart.set(0,i)}handleTouchStartDollyPan(){this.enableZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if($e.length===2){let i=_p(t),s=.5*(t.pageX+i.x),o=.5*(t.pageY+i.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==$e[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(Cx);let n=this.domElement;n&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/n.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/n.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if($e.length===2){let n=_p(t),i=.5*(t.pageX+n.x),s=.5*(t.pageY+n.y);this.panEnd.set(i,s)}else{if(t.pointerId!==$e[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(Px),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let n=_p(t),i=t.pageX-n.x,s=t.pageY-n.y,o=Math.sqrt(i*i+s*s);this.dollyEnd.set(0,o),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,WE)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}};function To(r){let e=Math.PI*2;for(;r<=-Math.PI;)r+=e;for(;r>Math.PI;)r-=e;return r}function jE(r){return 1-Math.pow(1-r,4)}function l4(r){return r.wheelDeltaY===0||r.deltaY===0?la&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120?!1:r.wheelDeltaX?r.wheelDeltaX===-3*r.deltaX:r.deltaMode===0:r.wheelDeltaY?r.wheelDeltaY===-3*r.deltaY:r.deltaMode===0}var qE=Object.keys(k0).filter(r=>isNaN(Number(r))),Qm=class{constructor(e,t,n,i,s,o,a,l){this.preventScroll=s;this.requestRender=a;this.isEnable=!1;this.onResetRaycaster=()=>{this.eventContext.raycasterNeedsUpdate=!0};this.onTouchMovePreventScroll=e=>{(e.touches.length>1||this.preventScroll)&&e.preventDefault()};this.onMouseWheelPreventScroll=e=>{this.preventScroll&&e.preventDefault()};this.eventContext=new Tm(e,t,n,o,i,l??!1),this.handlers={Spline:new Fm(this.eventContext),["Conditional"]:new zm(this.eventContext),["Start"]:new jm(this.eventContext),Basic:new Um(this.eventContext),["MouseHover"]:new Hm(this.eventContext),["Scroll"]:new Wm(this.eventContext),["Follow"]:new km(this.eventContext),["LookAt"]:new Vm(this.eventContext)}}activate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!0,e.traverseEntity(n=>{n.addEventListener("requestRender",this.requestRender)}),Object.values(this.handlers).forEach(n=>n.connect()),this.resize(),qE.forEach(n=>{Object.values(this.handlers).some(i=>i.domEventsNeeded.has(n))&&t.addEventListener(n,this.onResetRaycaster)}),t.addEventListener("wheel",this.onMouseWheelPreventScroll),t.addEventListener("touchmove",this.onTouchMovePreventScroll)}deactivate(){let{scene:e,domElement:t}=this.eventContext;this.isEnable=!1,Object.values(this.handlers).forEach(n=>n.disconnect()),e.traverseEntity(n=>{n.removeEventListener("requestRender",this.requestRender)}),qE.forEach(n=>{t.removeEventListener(n,this.onResetRaycaster)}),t.removeEventListener("touchmove",this.onTouchMovePreventScroll),t.removeEventListener("wheel",this.onMouseWheelPreventScroll)}reset(){this.deactivate(),this.activate()}resize(){this.eventContext.updaterRect()}};var Zm=class{constructor(e,t,n,i,s){this._aspect=1;this._renderer=e,this._camera=t,this._frameSize=new B().copy(n),this._editorSize=new B().copy(i),this._aspect=t.aspect,this._fov=s??t.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){!this._renderer||this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewportForImageExport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y;this._aspect=e/t,this._camera.zoom*=Math.min(n/e,i/t),this._renderer.setViewport(0,0,e,t)}updateViewport(){if(!this._renderer||!this._camera||this._camera.cameraType!=="PerspectiveCamera")return;let e=this._frameSize.x,t=this._frameSize.y,n=this._editorSize.x,i=this._editorSize.y,s=0,o=0,a=e,l=t;e<n&&(s=(n-e)*.5,s=-s,a=n),t<i&&(o=(i-t)*.5,o=-o,l=i),this._aspect=a/l,this._renderer.setViewport(s,o,a,l)}updateCamera(){if(!!this._camera)if(this._camera.cameraType==="PerspectiveCamera"){let e=this._frameSize.y,t=this._editorSize.y,n=this._fov;if(e>t){let i=c4(e,1080,2160,1,15)/100;n*=e/t,n*=1-i}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}setCamera(e){this._camera=e,this._aspect=e.aspect,this._fov=e.fov}revert(){let e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}};function c4(r,e,t,n,i){return(r-e)/(t-e)*(i-n)+n}var $E={RED:0,GREEN:1,BLUE:2,ALPHA:3};var hd="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}";var u4=`#ifdef FRAMEBUFFER_PRECISION_HIGH
4918
4919
  uniform mediump sampler2D inputBuffer;
4919
4920
  #else
4920
4921
  uniform lowp sampler2D inputBuffer;
@@ -5157,9 +5158,9 @@ vec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOf
5157
5158
  `;t.set(p.FRAGMENT_MAIN_UV,t.get(p.FRAGMENT_MAIN_UV)+v),d=!0}if(a.get("vertex")!==null&&/mainSupport/.test(a.get("vertex"))){let v=` ${r}MainSupport(`;v+=/mainSupport *\([\w\s]*?uv\s*?\)/.test(a.get("vertex"))?`vUv);
5158
5159
  `:`);
5159
5160
  `,t.set(p.VERTEX_MAIN_SUPPORT,t.get(p.VERTEX_MAIN_SUPPORT)+v),c=c.concat([...a.get("vertex").matchAll(/(?:varying\s+\w+\s+(\w*))/g)].map(y=>y[1])),h=h.concat(c).concat([...a.get("vertex").matchAll(m)].map(y=>y[1]))}h=h.concat([...a.get("fragment").matchAll(m)].map(v=>v[1])),h=h.concat([...e.defines.keys()].map(v=>v.replace(/\([\w\s,]*\)/g,""))),h=h.concat([...e.uniforms.keys()]),e.uniforms.forEach((v,y)=>s.set(r+y.charAt(0).toUpperCase()+y.slice(1),v)),e.defines.forEach((v,y)=>i.set(r+y.charAt(0).toUpperCase()+y.slice(1),v)),ZE(r,h,i),ZE(r,h,a);let g=e.blendMode;if(n.set(g.blendFunction,g),l){let v=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/,y=`${r}MainImage(color0, UV, `;(o&es.DEPTH)!==0&&v.test(a.get("fragment"))&&(y+="depth, ",f=!0),y+=`color1);
5160
- `;let w=r+"BlendOpacity";s.set(w,g.opacity),y+=`color0 = blend${g.blendFunction}(color0, color1, ${w});
5161
+ `;let b=r+"BlendOpacity";s.set(b,g.opacity),y+=`color0 = blend${g.blendFunction}(color0, color1, ${b});
5161
5162
 
5162
- `,t.set(p.FRAGMENT_MAIN_IMAGE,t.get(p.FRAGMENT_MAIN_IMAGE)+y),y=`uniform float ${w};
5163
+ `,t.set(p.FRAGMENT_MAIN_IMAGE,t.get(p.FRAGMENT_MAIN_IMAGE)+y),y=`uniform float ${b};
5163
5164
 
5164
5165
  `,t.set(p.FRAGMENT_HEAD,t.get(p.FRAGMENT_HEAD)+y)}t.set(p.FRAGMENT_HEAD,t.get(p.FRAGMENT_HEAD)+a.get("fragment")+`
5165
5166
  `),a.get("vertex")!==null&&t.set(p.VERTEX_HEAD,t.get(p.VERTEX_HEAD)+a.get("vertex")+`