@abi-software/scaffoldvuer 1.6.0-beta.1 → 1.6.1

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.
@@ -2912,7 +2912,7 @@ void main() {
2912
2912
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
2913
2913
  }`,tN=`void main() {
2914
2914
  gl_Position = vec4( position, 1.0 );
2915
- }`;function wv(n,e,t){let i=new da;const r=new Se,s=new Se,o=new st,l=[],u=[],c={},f=t.maxTextureSize,h={0:At,1:er,2:tr},m=new Di({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Se},radius:{value:4}},vertexShader:tN,fragmentShader:eN}),y=m.clone();y.defines.HORIZONTAL_PASS=1;const p=new Ve;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const d=new It(p,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yd,this.render=function(S,w,T){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||S.length===0)return;const C=n.getRenderTarget(),R=n.getActiveCubeFace(),P=n.getActiveMipmapLevel(),L=n.state;L.setBlending(_i),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);for(let A=0,I=S.length;A<I;A++){const O=S[A],x=O.shadow;if(x===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(x.autoUpdate===!1&&x.needsUpdate===!1)continue;r.copy(x.mapSize);const N=x.getFrameExtents();if(r.multiply(N),s.copy(x.mapSize),(r.x>f||r.y>f)&&(r.x>f&&(s.x=Math.floor(f/N.x),r.x=s.x*N.x,x.mapSize.x=s.x),r.y>f&&(s.y=Math.floor(f/N.y),r.y=s.y*N.y,x.mapSize.y=s.y)),x.map===null&&!x.isPointLightShadow&&this.type===Rs){const D={minFilter:wt,magFilter:wt,format:vn};x.map=new Vn(r.x,r.y,D),x.map.texture.name=O.name+".shadowMap",x.mapPass=new Vn(r.x,r.y,D),x.camera.updateProjectionMatrix()}if(x.map===null){const D={minFilter:Lt,magFilter:Lt,format:vn};x.map=new Vn(r.x,r.y,D),x.map.texture.name=O.name+".shadowMap",x.camera.updateProjectionMatrix()}n.setRenderTarget(x.map),n.clear();const B=x.getViewportCount();for(let D=0;D<B;D++){const V=x.getViewport(D);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),L.viewport(o),x.updateMatrices(O,D),i=x.getFrustum(),E(w,T,x.camera,O,this.type)}!x.isPointLightShadow&&this.type===Rs&&v(x,T),x.needsUpdate=!1}b.needsUpdate=!1,n.setRenderTarget(C,R,P)};function v(S,w){const T=e.update(d);m.uniforms.shadow_pass.value=S.map.texture,m.uniforms.resolution.value=S.mapSize,m.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(w,null,T,m,d,null),y.uniforms.shadow_pass.value=S.mapPass.texture,y.uniforms.resolution.value=S.mapSize,y.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(w,null,T,y,d,null)}function g(S){const w=S<<0;let T=l[w];return T===void 0&&(T=new fc({depthPacking:Ty,morphTargets:S}),l[w]=T),T}function M(S){const w=S<<0;let T=u[w];return T===void 0&&(T=new pc({morphTargets:S}),u[w]=T),T}function _(S,w,T,C,R,P,L){let A=null,I=g,O=S.customDepthMaterial;if(C.isPointLight===!0&&(I=M,O=S.customDistanceMaterial),O===void 0){let x=!1;T.morphTargets===!0&&(x=w.morphAttributes&&w.morphAttributes.position&&w.morphAttributes.position.length>0),A=I(x)}else A=O;if(n.localClippingEnabled&&T.clipShadows===!0&&T.clippingPlanes.length!==0){const x=A.uuid,N=T.uuid;let B=c[x];B===void 0&&(B={},c[x]=B);let D=B[N];D===void 0&&(D=A.clone(),B[N]=D),A=D}return A.visible=T.visible,A.wireframe=T.wireframe,L===Rs?A.side=T.shadowSide!==null?T.shadowSide:T.side:A.side=T.shadowSide!==null?T.shadowSide:h[T.side],A.clipShadows=T.clipShadows,A.clippingPlanes=T.clippingPlanes,A.clipIntersection=T.clipIntersection,A.wireframeLinewidth=T.wireframeLinewidth,A.linewidth=T.linewidth,C.isPointLight===!0&&A.isMeshDistanceMaterial===!0&&(A.referencePosition.setFromMatrixPosition(C.matrixWorld),A.nearDistance=R,A.farDistance=P),A}function E(S,w,T,C,R){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Rs)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,S.matrixWorld);const A=e.update(S),I=S.material;if(Array.isArray(I)){const O=A.groups;for(let x=0,N=O.length;x<N;x++){const B=O[x],D=I[B.materialIndex];if(D&&D.visible){const V=_(S,A,D,C,T.near,T.far,R);n.renderBufferDirect(T,null,A,V,S,B)}}}else if(I.visible){const O=_(S,A,I,C,T.near,T.far,R);n.renderBufferDirect(T,null,A,O,S,null)}}const L=S.children;for(let A=0,I=L.length;A<I;A++)E(L[A],w,T,C,R)}}function nN(n,e,t){const i=t.isWebGL2;function r(){let se=!1;const be=new st;let he=null;const me=new st(0,0,0,0);return{setMask:function(Te){he!==Te&&!se&&(n.colorMask(Te,Te,Te,Te),he=Te)},setLocked:function(Te){se=Te},setClear:function(Te,He,tt,Re,ot){ot===!0&&(Te*=Re,He*=Re,tt*=Re),be.set(Te,He,tt,Re),me.equals(be)===!1&&(n.clearColor(Te,He,tt,Re),me.copy(be))},reset:function(){se=!1,he=null,me.set(-1,0,0,0)}}}function s(){let se=!1,be=null,he=null,me=null;return{setTest:function(Te){Te?ie(2929):j(2929)},setMask:function(Te){be!==Te&&!se&&(n.depthMask(Te),be=Te)},setFunc:function(Te){if(he!==Te){if(Te)switch(Te){case h0:n.depthFunc(512);break;case f0:n.depthFunc(519);break;case p0:n.depthFunc(513);break;case Dl:n.depthFunc(515);break;case m0:n.depthFunc(514);break;case g0:n.depthFunc(518);break;case y0:n.depthFunc(516);break;case v0:n.depthFunc(517);break;default:n.depthFunc(515)}else n.depthFunc(515);he=Te}},setLocked:function(Te){se=Te},setClear:function(Te){me!==Te&&(n.clearDepth(Te),me=Te)},reset:function(){se=!1,be=null,he=null,me=null}}}function o(){let se=!1,be=null,he=null,me=null,Te=null,He=null,tt=null,Re=null,ot=null;return{setTest:function(Pe){se||(Pe?ie(2960):j(2960))},setMask:function(Pe){be!==Pe&&!se&&(n.stencilMask(Pe),be=Pe)},setFunc:function(Pe,Je,We){(he!==Pe||me!==Je||Te!==We)&&(n.stencilFunc(Pe,Je,We),he=Pe,me=Je,Te=We)},setOp:function(Pe,Je,We){(He!==Pe||tt!==Je||Re!==We)&&(n.stencilOp(Pe,Je,We),He=Pe,tt=Je,Re=We)},setLocked:function(Pe){se=Pe},setClear:function(Pe){ot!==Pe&&(n.clearStencil(Pe),ot=Pe)},reset:function(){se=!1,be=null,he=null,me=null,Te=null,He=null,tt=null,Re=null,ot=null}}}const l=new r,u=new s,c=new o;let f={},h=null,m={},y=null,p=!1,d=null,b=null,v=null,g=null,M=null,_=null,E=null,S=!1,w=null,T=null,C=null,R=null,P=null;const L=n.getParameter(35661);let A=!1,I=0;const O=n.getParameter(7938);O.indexOf("WebGL")!==-1?(I=parseFloat(/^WebGL (\d)/.exec(O)[1]),A=I>=1):O.indexOf("OpenGL ES")!==-1&&(I=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),A=I>=2);let x=null,N={};const B=n.getParameter(3088),D=n.getParameter(2978),V=new st().fromArray(B),z=new st().fromArray(D);function G(se,be,he){const me=new Uint8Array(4),Te=n.createTexture();n.bindTexture(se,Te),n.texParameteri(se,10241,9728),n.texParameteri(se,10240,9728);for(let He=0;He<he;He++)n.texImage2D(be+He,0,6408,1,1,0,6408,5121,me);return Te}const K={};K[3553]=G(3553,3553,1),K[34067]=G(34067,34069,6),l.setClear(0,0,0,1),u.setClear(1),c.setClear(0),ie(2929),u.setFunc(Dl),te(!1),F(gd),ie(2884),ne(_i);function ie(se){f[se]!==!0&&(n.enable(se),f[se]=!0)}function j(se){f[se]!==!1&&(n.disable(se),f[se]=!1)}function H(se){se!==h&&(n.bindFramebuffer(36160,se),h=se)}function W(se,be){return be===null&&h!==null&&(be=h),m[se]!==be?(n.bindFramebuffer(se,be),m[se]=be,i&&(se===36009&&(m[36160]=be),se===36160&&(m[36009]=be)),!0):!1}function q(se){return y!==se?(n.useProgram(se),y=se,!0):!1}const Q={[Nr]:32774,[t0]:32778,[n0]:32779};if(i)Q[Md]=32775,Q[Sd]=32776;else{const se=e.get("EXT_blend_minmax");se!==null&&(Q[Md]=se.MIN_EXT,Q[Sd]=se.MAX_EXT)}const ee={[i0]:0,[r0]:1,[s0]:768,[_d]:770,[d0]:776,[c0]:774,[a0]:772,[o0]:769,[Td]:771,[u0]:775,[l0]:773};function ne(se,be,he,me,Te,He,tt,Re){if(se===_i){p===!0&&(j(3042),p=!1);return}if(p===!1&&(ie(3042),p=!0),se!==e0){if(se!==d||Re!==S){if((b!==Nr||M!==Nr)&&(n.blendEquation(32774),b=Nr,M=Nr),Re)switch(se){case Ps:n.blendFuncSeparate(1,771,1,771);break;case bd:n.blendFunc(1,1);break;case xd:n.blendFuncSeparate(0,0,769,771);break;case wd:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",se);break}else switch(se){case Ps:n.blendFuncSeparate(770,771,1,771);break;case bd:n.blendFunc(770,1);break;case xd:n.blendFunc(0,769);break;case wd:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",se);break}v=null,g=null,_=null,E=null,d=se,S=Re}return}Te=Te||be,He=He||he,tt=tt||me,(be!==b||Te!==M)&&(n.blendEquationSeparate(Q[be],Q[Te]),b=be,M=Te),(he!==v||me!==g||He!==_||tt!==E)&&(n.blendFuncSeparate(ee[he],ee[me],ee[He],ee[tt]),v=he,g=me,_=He,E=tt),d=se,S=null}function Y(se,be){se.side===tr?j(2884):ie(2884);let he=se.side===At;be&&(he=!he),te(he),se.blending===Ps&&se.transparent===!1?ne(_i):ne(se.blending,se.blendEquation,se.blendSrc,se.blendDst,se.blendEquationAlpha,se.blendSrcAlpha,se.blendDstAlpha,se.premultipliedAlpha),u.setFunc(se.depthFunc),u.setTest(se.depthTest),u.setMask(se.depthWrite),l.setMask(se.colorWrite);const me=se.stencilWrite;c.setTest(me),me&&(c.setMask(se.stencilWriteMask),c.setFunc(se.stencilFunc,se.stencilRef,se.stencilFuncMask),c.setOp(se.stencilFail,se.stencilZFail,se.stencilZPass)),J(se.polygonOffset,se.polygonOffsetFactor,se.polygonOffsetUnits),se.alphaToCoverage===!0?ie(32926):j(32926)}function te(se){w!==se&&(se?n.frontFace(2304):n.frontFace(2305),w=se)}function F(se){se!==qg?(ie(2884),se!==T&&(se===gd?n.cullFace(1029):se===Kg?n.cullFace(1028):n.cullFace(1032))):j(2884),T=se}function $(se){se!==C&&(A&&n.lineWidth(se),C=se)}function J(se,be,he){se?(ie(32823),(R!==be||P!==he)&&(n.polygonOffset(be,he),R=be,P=he)):j(32823)}function k(se){se?ie(3089):j(3089)}function U(se){se===void 0&&(se=33984+L-1),x!==se&&(n.activeTexture(se),x=se)}function oe(se,be){x===null&&U();let he=N[x];he===void 0&&(he={type:void 0,texture:void 0},N[x]=he),(he.type!==se||he.texture!==be)&&(n.bindTexture(se,be||K[se]),he.type=se,he.texture=be)}function le(){const se=N[x];se!==void 0&&se.type!==void 0&&(n.bindTexture(se.type,null),se.type=void 0,se.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(se){console.error("THREE.WebGLState:",se)}}function fe(){try{n.texImage2D.apply(n,arguments)}catch(se){console.error("THREE.WebGLState:",se)}}function ge(){try{n.texImage3D.apply(n,arguments)}catch(se){console.error("THREE.WebGLState:",se)}}function we(se){V.equals(se)===!1&&(n.scissor(se.x,se.y,se.z,se.w),V.copy(se))}function ue(se){z.equals(se)===!1&&(n.viewport(se.x,se.y,se.z,se.w),z.copy(se))}function ye(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),i===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),f={},x=null,N={},h=null,m={},y=null,p=!1,d=null,b=null,v=null,g=null,M=null,_=null,E=null,S=!1,w=null,T=null,C=null,R=null,P=null,V.set(0,0,n.canvas.width,n.canvas.height),z.set(0,0,n.canvas.width,n.canvas.height),l.reset(),u.reset(),c.reset()}return{buffers:{color:l,depth:u,stencil:c},enable:ie,disable:j,bindFramebuffer:W,bindXRFramebuffer:H,useProgram:q,setBlending:ne,setMaterial:Y,setFlipSided:te,setCullFace:F,setLineWidth:$,setPolygonOffset:J,setScissorTest:k,activeTexture:U,bindTexture:oe,unbindTexture:le,compressedTexImage2D:ae,texImage2D:fe,texImage3D:ge,scissor:we,viewport:ue,reset:ye}}function iN(n,e,t,i,r,s,o){const l=r.isWebGL2,u=r.maxTextures,c=r.maxCubemapSize,f=r.maxTextureSize,h=r.maxSamples,m=new WeakMap;let y,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function d(k,U){return p?new OffscreenCanvas(k,U):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function b(k,U,oe,le){let ae=1;if((k.width>le||k.height>le)&&(ae=le/Math.max(k.width,k.height)),ae<1||U===!0)if(typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&k instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&k instanceof ImageBitmap){const fe=U?Ly:Math.floor,ge=fe(ae*k.width),we=fe(ae*k.height);y===void 0&&(y=d(ge,we));const ue=oe?d(ge,we):y;return ue.width=ge,ue.height=we,ue.getContext("2d").drawImage(k,0,0,ge,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+k.width+"x"+k.height+") to ("+ge+"x"+we+")."),ue}else return"data"in k&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+k.width+"x"+k.height+")."),k;return k}function v(k){return Hd(k.width)&&Hd(k.height)}function g(k){return l?!1:k.wrapS!==Wt||k.wrapT!==Wt||k.minFilter!==Lt&&k.minFilter!==wt}function M(k,U){return k.generateMipmaps&&U&&k.minFilter!==Lt&&k.minFilter!==wt}function _(k,U,oe,le,ae=1){n.generateMipmap(k);const fe=i.get(U);fe.__maxMipLevel=Math.log2(Math.max(oe,le,ae))}function E(k,U,oe){if(l===!1)return U;if(k!==null){if(n[k]!==void 0)return n[k];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+k+"'")}let le=U;return U===6403&&(oe===5126&&(le=33326),oe===5131&&(le=33325),oe===5121&&(le=33321)),U===6407&&(oe===5126&&(le=34837),oe===5131&&(le=34843),oe===5121&&(le=32849)),U===6408&&(oe===5126&&(le=34836),oe===5131&&(le=34842),oe===5121&&(le=32856)),(le===33325||le===33326||le===34842||le===34836)&&e.get("EXT_color_buffer_float"),le}function S(k){return k===Lt||k===Qo||k===ea?9728:9729}function w(k){const U=k.target;U.removeEventListener("dispose",w),C(U),U.isVideoTexture&&m.delete(U),o.memory.textures--}function T(k){const U=k.target;U.removeEventListener("dispose",T),R(U)}function C(k){const U=i.get(k);U.__webglInit!==void 0&&(n.deleteTexture(U.__webglTexture),i.remove(k))}function R(k){const U=k.texture,oe=i.get(k),le=i.get(U);if(k){if(le.__webglTexture!==void 0&&(n.deleteTexture(le.__webglTexture),o.memory.textures--),k.depthTexture&&k.depthTexture.dispose(),k.isWebGLCubeRenderTarget)for(let ae=0;ae<6;ae++)n.deleteFramebuffer(oe.__webglFramebuffer[ae]),oe.__webglDepthbuffer&&n.deleteRenderbuffer(oe.__webglDepthbuffer[ae]);else n.deleteFramebuffer(oe.__webglFramebuffer),oe.__webglDepthbuffer&&n.deleteRenderbuffer(oe.__webglDepthbuffer),oe.__webglMultisampledFramebuffer&&n.deleteFramebuffer(oe.__webglMultisampledFramebuffer),oe.__webglColorRenderbuffer&&n.deleteRenderbuffer(oe.__webglColorRenderbuffer),oe.__webglDepthRenderbuffer&&n.deleteRenderbuffer(oe.__webglDepthRenderbuffer);if(k.isWebGLMultipleRenderTargets)for(let ae=0,fe=U.length;ae<fe;ae++){const ge=i.get(U[ae]);ge.__webglTexture&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),i.remove(U[ae])}i.remove(U),i.remove(k)}}let P=0;function L(){P=0}function A(){const k=P;return k>=u&&console.warn("THREE.WebGLTextures: Trying to use "+k+" texture units while this GPU supports only "+u),P+=1,k}function I(k,U){const oe=i.get(k);if(k.isVideoTexture&&Y(k),k.version>0&&oe.__version!==k.version){const le=k.image;if(le===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{G(oe,k,U);return}}t.activeTexture(33984+U),t.bindTexture(3553,oe.__webglTexture)}function O(k,U){const oe=i.get(k);if(k.version>0&&oe.__version!==k.version){G(oe,k,U);return}t.activeTexture(33984+U),t.bindTexture(35866,oe.__webglTexture)}function x(k,U){const oe=i.get(k);if(k.version>0&&oe.__version!==k.version){G(oe,k,U);return}t.activeTexture(33984+U),t.bindTexture(32879,oe.__webglTexture)}function N(k,U){const oe=i.get(k);if(k.version>0&&oe.__version!==k.version){K(oe,k,U);return}t.activeTexture(33984+U),t.bindTexture(34067,oe.__webglTexture)}const B={[ir]:10497,[Wt]:33071,[Os]:33648},D={[Lt]:9728,[Qo]:9984,[ea]:9986,[wt]:9729,[kl]:9985,[Ti]:9987};function V(k,U,oe){if(oe?(n.texParameteri(k,10242,B[U.wrapS]),n.texParameteri(k,10243,B[U.wrapT]),(k===32879||k===35866)&&n.texParameteri(k,32882,B[U.wrapR]),n.texParameteri(k,10240,D[U.magFilter]),n.texParameteri(k,10241,D[U.minFilter])):(n.texParameteri(k,10242,33071),n.texParameteri(k,10243,33071),(k===32879||k===35866)&&n.texParameteri(k,32882,33071),(U.wrapS!==Wt||U.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(k,10240,S(U.magFilter)),n.texParameteri(k,10241,S(U.minFilter)),U.minFilter!==Lt&&U.minFilter!==wt&&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){const le=e.get("EXT_texture_filter_anisotropic");if(U.type===Ei&&e.has("OES_texture_float_linear")===!1||l===!1&&U.type===Br&&e.has("OES_texture_half_float_linear")===!1)return;(U.anisotropy>1||i.get(U).__currentAnisotropy)&&(n.texParameterf(k,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(U.anisotropy,r.getMaxAnisotropy())),i.get(U).__currentAnisotropy=U.anisotropy)}}function z(k,U){k.__webglInit===void 0&&(k.__webglInit=!0,U.addEventListener("dispose",w),k.__webglTexture=n.createTexture(),o.memory.textures++)}function G(k,U,oe){let le=3553;U.isDataTexture2DArray&&(le=35866),U.isDataTexture3D&&(le=32879),z(k,U),t.activeTexture(33984+oe),t.bindTexture(le,k.__webglTexture),n.pixelStorei(37440,U.flipY),n.pixelStorei(37441,U.premultiplyAlpha),n.pixelStorei(3317,U.unpackAlignment),n.pixelStorei(37443,0);const ae=g(U)&&v(U.image)===!1,fe=b(U.image,ae,!1,f),ge=v(fe)||l,we=s.convert(U.format);let ue=s.convert(U.type),ye=E(U.internalFormat,we,ue);V(le,U,ge);let se;const be=U.mipmaps;if(U.isDepthTexture)ye=6402,l?U.type===Ei?ye=36012:U.type===na?ye=33190:U.type===Ns?ye=35056:ye=33189:U.type===Ei&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),U.format===Fr&&ye===6402&&U.type!==ta&&U.type!==na&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),U.type=ta,ue=s.convert(U.type)),U.format===Ds&&ye===6402&&(ye=34041,U.type!==Ns&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),U.type=Ns,ue=s.convert(U.type))),t.texImage2D(3553,0,ye,fe.width,fe.height,0,we,ue,null);else if(U.isDataTexture)if(be.length>0&&ge){for(let he=0,me=be.length;he<me;he++)se=be[he],t.texImage2D(3553,he,ye,se.width,se.height,0,we,ue,se.data);U.generateMipmaps=!1,k.__maxMipLevel=be.length-1}else t.texImage2D(3553,0,ye,fe.width,fe.height,0,we,ue,fe.data),k.__maxMipLevel=0;else if(U.isCompressedTexture){for(let he=0,me=be.length;he<me;he++)se=be[he],U.format!==vn&&U.format!==Ci?we!==null?t.compressedTexImage2D(3553,he,ye,se.width,se.height,0,se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):t.texImage2D(3553,he,ye,se.width,se.height,0,we,ue,se.data);k.__maxMipLevel=be.length-1}else if(U.isDataTexture2DArray)t.texImage3D(35866,0,ye,fe.width,fe.height,fe.depth,0,we,ue,fe.data),k.__maxMipLevel=0;else if(U.isDataTexture3D)t.texImage3D(32879,0,ye,fe.width,fe.height,fe.depth,0,we,ue,fe.data),k.__maxMipLevel=0;else if(be.length>0&&ge){for(let he=0,me=be.length;he<me;he++)se=be[he],t.texImage2D(3553,he,ye,we,ue,se);U.generateMipmaps=!1,k.__maxMipLevel=be.length-1}else t.texImage2D(3553,0,ye,we,ue,fe),k.__maxMipLevel=0;M(U,ge)&&_(le,U,fe.width,fe.height),k.__version=U.version,U.onUpdate&&U.onUpdate(U)}function K(k,U,oe){if(U.image.length!==6)return;z(k,U),t.activeTexture(33984+oe),t.bindTexture(34067,k.__webglTexture),n.pixelStorei(37440,U.flipY),n.pixelStorei(37441,U.premultiplyAlpha),n.pixelStorei(3317,U.unpackAlignment),n.pixelStorei(37443,0);const le=U&&(U.isCompressedTexture||U.image[0].isCompressedTexture),ae=U.image[0]&&U.image[0].isDataTexture,fe=[];for(let he=0;he<6;he++)!le&&!ae?fe[he]=b(U.image[he],!1,!0,c):fe[he]=ae?U.image[he].image:U.image[he];const ge=fe[0],we=v(ge)||l,ue=s.convert(U.format),ye=s.convert(U.type),se=E(U.internalFormat,ue,ye);V(34067,U,we);let be;if(le){for(let he=0;he<6;he++){be=fe[he].mipmaps;for(let me=0;me<be.length;me++){const Te=be[me];U.format!==vn&&U.format!==Ci?ue!==null?t.compressedTexImage2D(34069+he,me,se,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):t.texImage2D(34069+he,me,se,Te.width,Te.height,0,ue,ye,Te.data)}}k.__maxMipLevel=be.length-1}else{be=U.mipmaps;for(let he=0;he<6;he++)if(ae){t.texImage2D(34069+he,0,se,fe[he].width,fe[he].height,0,ue,ye,fe[he].data);for(let me=0;me<be.length;me++){const He=be[me].image[he].image;t.texImage2D(34069+he,me+1,se,He.width,He.height,0,ue,ye,He.data)}}else{t.texImage2D(34069+he,0,se,ue,ye,fe[he]);for(let me=0;me<be.length;me++){const Te=be[me];t.texImage2D(34069+he,me+1,se,ue,ye,Te.image[he])}}k.__maxMipLevel=be.length}M(U,we)&&_(34067,U,ge.width,ge.height),k.__version=U.version,U.onUpdate&&U.onUpdate(U)}function ie(k,U,oe,le,ae){const fe=s.convert(oe.format),ge=s.convert(oe.type),we=E(oe.internalFormat,fe,ge);ae===32879||ae===35866?t.texImage3D(ae,0,we,U.width,U.height,U.depth,0,fe,ge,null):t.texImage2D(ae,0,we,U.width,U.height,0,fe,ge,null),t.bindFramebuffer(36160,k),n.framebufferTexture2D(36160,le,ae,i.get(oe).__webglTexture,0),t.bindFramebuffer(36160,null)}function j(k,U,oe){if(n.bindRenderbuffer(36161,k),U.depthBuffer&&!U.stencilBuffer){let le=33189;if(oe){const ae=U.depthTexture;ae&&ae.isDepthTexture&&(ae.type===Ei?le=36012:ae.type===na&&(le=33190));const fe=ne(U);n.renderbufferStorageMultisample(36161,fe,le,U.width,U.height)}else n.renderbufferStorage(36161,le,U.width,U.height);n.framebufferRenderbuffer(36160,36096,36161,k)}else if(U.depthBuffer&&U.stencilBuffer){if(oe){const le=ne(U);n.renderbufferStorageMultisample(36161,le,35056,U.width,U.height)}else n.renderbufferStorage(36161,34041,U.width,U.height);n.framebufferRenderbuffer(36160,33306,36161,k)}else{const le=U.isWebGLMultipleRenderTargets===!0?U.texture[0]:U.texture,ae=s.convert(le.format),fe=s.convert(le.type),ge=E(le.internalFormat,ae,fe);if(oe){const we=ne(U);n.renderbufferStorageMultisample(36161,we,ge,U.width,U.height)}else n.renderbufferStorage(36161,ge,U.width,U.height)}n.bindRenderbuffer(36161,null)}function H(k,U){if(U&&U.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,k),!(U.depthTexture&&U.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(U.depthTexture).__webglTexture||U.depthTexture.image.width!==U.width||U.depthTexture.image.height!==U.height)&&(U.depthTexture.image.width=U.width,U.depthTexture.image.height=U.height,U.depthTexture.needsUpdate=!0),I(U.depthTexture,0);const le=i.get(U.depthTexture).__webglTexture;if(U.depthTexture.format===Fr)n.framebufferTexture2D(36160,36096,3553,le,0);else if(U.depthTexture.format===Ds)n.framebufferTexture2D(36160,33306,3553,le,0);else throw new Error("Unknown depthTexture format")}function W(k){const U=i.get(k),oe=k.isWebGLCubeRenderTarget===!0;if(k.depthTexture){if(oe)throw new Error("target.depthTexture not supported in Cube render targets");H(U.__webglFramebuffer,k)}else if(oe){U.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(36160,U.__webglFramebuffer[le]),U.__webglDepthbuffer[le]=n.createRenderbuffer(),j(U.__webglDepthbuffer[le],k,!1)}else t.bindFramebuffer(36160,U.__webglFramebuffer),U.__webglDepthbuffer=n.createRenderbuffer(),j(U.__webglDepthbuffer,k,!1);t.bindFramebuffer(36160,null)}function q(k){const U=k.texture,oe=i.get(k),le=i.get(U);k.addEventListener("dispose",T),k.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture=n.createTexture(),le.__version=U.version,o.memory.textures++);const ae=k.isWebGLCubeRenderTarget===!0,fe=k.isWebGLMultipleRenderTargets===!0,ge=k.isWebGLMultisampleRenderTarget===!0,we=U.isDataTexture3D||U.isDataTexture2DArray,ue=v(k)||l;if(l&&U.format===Ci&&(U.type===Ei||U.type===Br)&&(U.format=vn,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),ae){oe.__webglFramebuffer=[];for(let ye=0;ye<6;ye++)oe.__webglFramebuffer[ye]=n.createFramebuffer()}else if(oe.__webglFramebuffer=n.createFramebuffer(),fe)if(r.drawBuffers){const ye=k.texture;for(let se=0,be=ye.length;se<be;se++){const he=i.get(ye[se]);he.__webglTexture===void 0&&(he.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(ge)if(l){oe.__webglMultisampledFramebuffer=n.createFramebuffer(),oe.__webglColorRenderbuffer=n.createRenderbuffer(),n.bindRenderbuffer(36161,oe.__webglColorRenderbuffer);const ye=s.convert(U.format),se=s.convert(U.type),be=E(U.internalFormat,ye,se),he=ne(k);n.renderbufferStorageMultisample(36161,he,be,k.width,k.height),t.bindFramebuffer(36160,oe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064,36161,oe.__webglColorRenderbuffer),n.bindRenderbuffer(36161,null),k.depthBuffer&&(oe.__webglDepthRenderbuffer=n.createRenderbuffer(),j(oe.__webglDepthRenderbuffer,k,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(ae){t.bindTexture(34067,le.__webglTexture),V(34067,U,ue);for(let ye=0;ye<6;ye++)ie(oe.__webglFramebuffer[ye],k,U,36064,34069+ye);M(U,ue)&&_(34067,U,k.width,k.height),t.bindTexture(34067,null)}else if(fe){const ye=k.texture;for(let se=0,be=ye.length;se<be;se++){const he=ye[se],me=i.get(he);t.bindTexture(3553,me.__webglTexture),V(3553,he,ue),ie(oe.__webglFramebuffer,k,he,36064+se,3553),M(he,ue)&&_(3553,he,k.width,k.height)}t.bindTexture(3553,null)}else{let ye=3553;we&&(l?ye=U.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),t.bindTexture(ye,le.__webglTexture),V(ye,U,ue),ie(oe.__webglFramebuffer,k,U,36064,ye),M(U,ue)&&_(ye,U,k.width,k.height,k.depth),t.bindTexture(ye,null)}k.depthBuffer&&W(k)}function Q(k){const U=v(k)||l,oe=k.isWebGLMultipleRenderTargets===!0?k.texture:[k.texture];for(let le=0,ae=oe.length;le<ae;le++){const fe=oe[le];if(M(fe,U)){const ge=k.isWebGLCubeRenderTarget?34067:3553,we=i.get(fe).__webglTexture;t.bindTexture(ge,we),_(ge,fe,k.width,k.height),t.bindTexture(ge,null)}}}function ee(k){if(k.isWebGLMultisampleRenderTarget)if(l){const U=k.width,oe=k.height;let le=16384;k.depthBuffer&&(le|=256),k.stencilBuffer&&(le|=1024);const ae=i.get(k);t.bindFramebuffer(36008,ae.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,ae.__webglFramebuffer),n.blitFramebuffer(0,0,U,oe,0,0,U,oe,le,9728),t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,ae.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function ne(k){return l&&k.isWebGLMultisampleRenderTarget?Math.min(h,k.samples):0}function Y(k){const U=o.render.frame;m.get(k)!==U&&(m.set(k,U),k.update())}let te=!1,F=!1;function $(k,U){k&&k.isWebGLRenderTarget&&(te===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),te=!0),k=k.texture),I(k,U)}function J(k,U){k&&k.isWebGLCubeRenderTarget&&(F===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),k=k.texture),N(k,U)}this.allocateTextureUnit=A,this.resetTextureUnits=L,this.setTexture2D=I,this.setTexture2DArray=O,this.setTexture3D=x,this.setTextureCube=N,this.setupRenderTarget=q,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=ee,this.safeSetTexture2D=$,this.safeSetTextureCube=J}function Mv(n,e,t){const i=t.isWebGL2;function r(s){let o;if(s===Dr)return 5121;if(s===L0)return 32819;if(s===R0)return 32820;if(s===P0)return 33635;if(s===E0)return 5120;if(s===C0)return 5122;if(s===ta)return 5123;if(s===A0)return 5124;if(s===na)return 5125;if(s===Ei)return 5126;if(s===Br)return i?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===I0)return 6406;if(s===Ci)return 6407;if(s===vn)return 6408;if(s===O0)return 6409;if(s===N0)return 6410;if(s===Fr)return 6402;if(s===Ds)return 34041;if(s===B0)return 6403;if(s===F0)return 36244;if(s===V0)return 33319;if(s===k0)return 33320;if(s===z0)return 36248;if(s===U0)return 36249;if(s===Ed||s===Cd||s===Ad||s===Ld)if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Ed)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Cd)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ad)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Ld)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Rd||s===Pd||s===Id||s===Od)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Rd)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Pd)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Id)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Od)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===G0)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if((s===Nd||s===Dd)&&(o=e.get("WEBGL_compressed_texture_etc"),o!==null)){if(s===Nd)return o.COMPRESSED_RGB8_ETC2;if(s===Dd)return o.COMPRESSED_RGBA8_ETC2_EAC}if(s===H0||s===W0||s===j0||s===$0||s===Z0||s===X0||s===Y0||s===J0||s===q0||s===K0||s===Q0||s===ey||s===ty||s===ny||s===ry||s===sy||s===oy||s===ay||s===ly||s===cy||s===uy||s===dy||s===hy||s===fy||s===py||s===my||s===gy||s===yy)return o=e.get("WEBGL_compressed_texture_astc"),o!==null?s:null;if(s===iy)return o=e.get("EXT_texture_compression_bptc"),o!==null?s:null;if(s===Ns)return i?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:r}}class xh extends zt{constructor(e=[]){super(),this.cameras=e}}xh.prototype.isArrayCamera=!0;class ni extends $e{constructor(){super(),this.type="Group"}}ni.prototype.isGroup=!0;const rN={type:"move"};class wh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ni,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 ni,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new X,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new X),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ni,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new X,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new X),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,i){let r=null,s=null,o=null;const l=this._targetRay,u=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(l!==null&&(r=t.getPose(e.targetRaySpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(rN))),c&&e.hand){o=!0;for(const d of e.hand.values()){const b=t.getJointPose(d,i);if(c.joints[d.jointName]===void 0){const g=new ni;g.matrixAutoUpdate=!1,g.visible=!1,c.joints[d.jointName]=g,c.add(g)}const v=c.joints[d.jointName];b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=b.radius),v.visible=b!==null}const f=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],m=f.position.distanceTo(h.position),y=.02,p=.005;c.inputState.pinching&&m>y+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&m<=y-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),c!==null&&(c.visible=o!==null),this}}class sN extends sr{constructor(e,t){super();const i=this,r=e.state;let s=null,o=1,l=null,u="local-floor",c=null,f=null,h=null,m=null;const y=[],p=new Map,d=new zt;d.layers.enable(1),d.viewport=new st;const b=new zt;b.layers.enable(2),b.viewport=new st;const v=[d,b],g=new xh;g.layers.enable(1),g.layers.enable(2);let M=null,_=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(O){let x=y[O];return x===void 0&&(x=new wh,y[O]=x),x.getTargetRaySpace()},this.getControllerGrip=function(O){let x=y[O];return x===void 0&&(x=new wh,y[O]=x),x.getGripSpace()},this.getHand=function(O){let x=y[O];return x===void 0&&(x=new wh,y[O]=x),x.getHandSpace()};function E(O){const x=p.get(O.inputSource);x&&x.dispatchEvent({type:O.type,data:O.inputSource})}function S(){p.forEach(function(O,x){O.disconnect(x)}),p.clear(),M=null,_=null,r.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),I.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(O){o=O,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(O){u=O,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l},this.getSession=function(){return s},this.setSession=async function(O){if(s=O,s!==null){s.addEventListener("select",E),s.addEventListener("selectstart",E),s.addEventListener("selectend",E),s.addEventListener("squeeze",E),s.addEventListener("squeezestart",E),s.addEventListener("squeezeend",E),s.addEventListener("end",S),s.addEventListener("inputsourceschange",w);const x=t.getContextAttributes();if(x.xrCompatible!==!0&&await t.makeXRCompatible(),s.renderState.layers===void 0){const N={antialias:x.antialias,alpha:x.alpha,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:o},B=new XRWebGLLayer(s,t,N);s.updateRenderState({baseLayer:B})}else{let N=0;x.depth&&(N=x.stencil?34041:6402);const B={colorFormat:x.alpha?6408:6407,depthFormat:N,scaleFactor:o};f=new XRWebGLBinding(s,t),m=f.createProjectionLayer(B),h=t.createFramebuffer(),s.updateRenderState({layers:[m]})}l=await s.requestReferenceSpace(u),I.setContext(s),I.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function w(O){const x=s.inputSources;for(let N=0;N<y.length;N++)p.set(x[N],y[N]);for(let N=0;N<O.removed.length;N++){const B=O.removed[N],D=p.get(B);D&&(D.dispatchEvent({type:"disconnected",data:B}),p.delete(B))}for(let N=0;N<O.added.length;N++){const B=O.added[N],D=p.get(B);D&&D.dispatchEvent({type:"connected",data:B})}}const T=new X,C=new X;function R(O,x,N){T.setFromMatrixPosition(x.matrixWorld),C.setFromMatrixPosition(N.matrixWorld);const B=T.distanceTo(C),D=x.projectionMatrix.elements,V=N.projectionMatrix.elements,z=D[14]/(D[10]-1),G=D[14]/(D[10]+1),K=(D[9]+1)/D[5],ie=(D[9]-1)/D[5],j=(D[8]-1)/D[0],H=(V[8]+1)/V[0],W=z*j,q=z*H,Q=B/(-j+H),ee=Q*-j;x.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(ee),O.translateZ(Q),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.copy(O.matrixWorld).invert();const ne=z+Q,Y=G+Q,te=W-ee,F=q+(B-ee),$=K*G/Y*ne,J=ie*G/Y*ne;O.projectionMatrix.makePerspective(te,F,$,J,ne,Y)}function P(O,x){x===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices(x.matrixWorld,O.matrix),O.matrixWorldInverse.copy(O.matrixWorld).invert()}this.updateCamera=function(O){if(s===null)return;g.near=b.near=d.near=O.near,g.far=b.far=d.far=O.far,(M!==g.near||_!==g.far)&&(s.updateRenderState({depthNear:g.near,depthFar:g.far}),M=g.near,_=g.far);const x=O.parent,N=g.cameras;P(g,x);for(let D=0;D<N.length;D++)P(N[D],x);g.matrixWorld.decompose(g.position,g.quaternion,g.scale),O.position.copy(g.position),O.quaternion.copy(g.quaternion),O.scale.copy(g.scale),O.matrix.copy(g.matrix),O.matrixWorld.copy(g.matrixWorld);const B=O.children;for(let D=0,V=B.length;D<V;D++)B[D].updateMatrixWorld(!0);N.length===2?R(g,d,b):g.projectionMatrix.copy(d.projectionMatrix)},this.getCamera=function(){return g};let L=null;function A(O,x){if(c=x.getViewerPose(l),c!==null){const B=c.views,D=s.renderState.baseLayer;s.renderState.layers===void 0&&r.bindXRFramebuffer(D.framebuffer);let V=!1;B.length!==g.cameras.length&&(g.cameras.length=0,V=!0);for(let z=0;z<B.length;z++){const G=B[z];let K=null;if(s.renderState.layers===void 0)K=D.getViewport(G);else{const j=f.getViewSubImage(m,G);r.bindXRFramebuffer(h),t.framebufferTexture2D(36160,36064,3553,j.colorTexture,0),j.depthStencilTexture!==void 0&&t.framebufferTexture2D(36160,36096,3553,j.depthStencilTexture,0),K=j.viewport}const ie=v[z];ie.matrix.fromArray(G.transform.matrix),ie.projectionMatrix.fromArray(G.projectionMatrix),ie.viewport.set(K.x,K.y,K.width,K.height),z===0&&g.matrix.copy(ie.matrix),V===!0&&g.cameras.push(ie)}}const N=s.inputSources;for(let B=0;B<y.length;B++){const D=y[B],V=N[B];D.update(V,x,l)}L&&L(O,x)}const I=new Ky;I.setAnimationLoop(A),this.setAnimationLoop=function(O){L=O},this.dispose=function(){}}}function oN(n){function e(v,g){v.fogColor.value.copy(g.color),g.isFog?(v.fogNear.value=g.near,v.fogFar.value=g.far):g.isFogExp2&&(v.fogDensity.value=g.density)}function t(v,g,M,_,E){g.isMeshBasicMaterial?i(v,g):g.isMeshLambertMaterial?(i(v,g),u(v,g)):g.isMeshToonMaterial?(i(v,g),f(v,g)):g.isMeshPhongMaterial?(i(v,g),c(v,g)):g.isMeshStandardMaterial?(i(v,g),g.isMeshPhysicalMaterial?m(v,g,E):h(v,g)):g.isMeshMatcapMaterial?(i(v,g),y(v,g)):g.isMeshDepthMaterial?(i(v,g),p(v,g)):g.isMeshDistanceMaterial?(i(v,g),d(v,g)):g.isMeshNormalMaterial?(i(v,g),b(v,g)):g.isLineBasicMaterial?(r(v,g),g.isLineDashedMaterial&&s(v,g)):g.isPointsMaterial?o(v,g,M,_):g.isSpriteMaterial?l(v,g):g.isShadowMaterial?(v.color.value.copy(g.color),v.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(v,g){v.opacity.value=g.opacity,g.color&&v.diffuse.value.copy(g.color),g.emissive&&v.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(v.map.value=g.map),g.alphaMap&&(v.alphaMap.value=g.alphaMap),g.specularMap&&(v.specularMap.value=g.specularMap);const M=n.get(g).envMap;if(M){v.envMap.value=M,v.flipEnvMap.value=M.isCubeTexture&&M._needsFlipEnvMap?-1:1,v.reflectivity.value=g.reflectivity,v.refractionRatio.value=g.refractionRatio;const S=n.get(M).__maxMipLevel;S!==void 0&&(v.maxMipLevel.value=S)}g.lightMap&&(v.lightMap.value=g.lightMap,v.lightMapIntensity.value=g.lightMapIntensity),g.aoMap&&(v.aoMap.value=g.aoMap,v.aoMapIntensity.value=g.aoMapIntensity);let _;g.map?_=g.map:g.specularMap?_=g.specularMap:g.displacementMap?_=g.displacementMap:g.normalMap?_=g.normalMap:g.bumpMap?_=g.bumpMap:g.roughnessMap?_=g.roughnessMap:g.metalnessMap?_=g.metalnessMap:g.alphaMap?_=g.alphaMap:g.emissiveMap?_=g.emissiveMap:g.clearcoatMap?_=g.clearcoatMap:g.clearcoatNormalMap?_=g.clearcoatNormalMap:g.clearcoatRoughnessMap&&(_=g.clearcoatRoughnessMap),_!==void 0&&(_.isWebGLRenderTarget&&(_=_.texture),_.matrixAutoUpdate===!0&&_.updateMatrix(),v.uvTransform.value.copy(_.matrix));let E;g.aoMap?E=g.aoMap:g.lightMap&&(E=g.lightMap),E!==void 0&&(E.isWebGLRenderTarget&&(E=E.texture),E.matrixAutoUpdate===!0&&E.updateMatrix(),v.uv2Transform.value.copy(E.matrix))}function r(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity}function s(v,g){v.dashSize.value=g.dashSize,v.totalSize.value=g.dashSize+g.gapSize,v.scale.value=g.scale}function o(v,g,M,_){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.size.value=g.size*M,v.scale.value=_*.5,g.map&&(v.map.value=g.map),g.alphaMap&&(v.alphaMap.value=g.alphaMap);let E;g.map?E=g.map:g.alphaMap&&(E=g.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),v.uvTransform.value.copy(E.matrix))}function l(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.rotation.value=g.rotation,g.map&&(v.map.value=g.map),g.alphaMap&&(v.alphaMap.value=g.alphaMap);let M;g.map?M=g.map:g.alphaMap&&(M=g.alphaMap),M!==void 0&&(M.matrixAutoUpdate===!0&&M.updateMatrix(),v.uvTransform.value.copy(M.matrix))}function u(v,g){g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap)}function c(v,g){v.specular.value.copy(g.specular),v.shininess.value=Math.max(g.shininess,1e-4),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function f(v,g){g.gradientMap&&(v.gradientMap.value=g.gradientMap),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function h(v,g){v.roughness.value=g.roughness,v.metalness.value=g.metalness,g.roughnessMap&&(v.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(v.metalnessMap.value=g.metalnessMap),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias),n.get(g).envMap&&(v.envMapIntensity.value=g.envMapIntensity)}function m(v,g,M){h(v,g),v.reflectivity.value=g.reflectivity,v.clearcoat.value=g.clearcoat,v.clearcoatRoughness.value=g.clearcoatRoughness,g.sheen&&v.sheen.value.copy(g.sheen),g.clearcoatMap&&(v.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(v.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),v.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===At&&v.clearcoatNormalScale.value.negate()),v.transmission.value=g.transmission,g.transmissionMap&&(v.transmissionMap.value=g.transmissionMap),g.transmission>0&&(v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height)),v.thickness.value=g.thickness,g.thicknessMap&&(v.thicknessMap.value=g.thicknessMap),v.attenuationDistance.value=g.attenuationDistance,v.attenuationColor.value.copy(g.attenuationColor)}function y(v,g){g.matcap&&(v.matcap.value=g.matcap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function p(v,g){g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function d(v,g){g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias),v.referencePosition.value.copy(g.referencePosition),v.nearDistance.value=g.nearDistance,v.farDistance.value=g.farDistance}function b(v,g){g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function aN(){const n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.style.display="block",n}function lt(n={}){const e=n.canvas!==void 0?n.canvas:aN(),t=n.context!==void 0?n.context:null,i=n.alpha!==void 0?n.alpha:!1,r=n.depth!==void 0?n.depth:!0,s=n.stencil!==void 0?n.stencil:!0,o=n.antialias!==void 0?n.antialias:!1,l=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,u=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,c=n.powerPreference!==void 0?n.powerPreference:"default",f=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1;let h=null,m=null;const y=[],p=[];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.gammaFactor=2,this.outputEncoding=ln,this.physicallyCorrectLights=!1,this.toneMapping=nr,this.toneMappingExposure=1;const d=this;let b=!1,v=0,g=0,M=null,_=-1,E=null;const S=new st,w=new st;let T=null,C=e.width,R=e.height,P=1,L=null,A=null;const I=new st(0,0,C,R),O=new st(0,0,C,R);let x=!1;const N=[],B=new da;let D=!1,V=!1,z=null;const G=new De,K=new X,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return M===null?P:1}let H=t;function W(Z,pe){for(let de=0;de<Z.length;de++){const ve=Z[de],Ee=e.getContext(ve,pe);if(Ee!==null)return Ee}return null}try{const Z={alpha:i,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:c,failIfMajorPerformanceCaveat:f};if(e.addEventListener("webglcontextlost",He,!1),e.addEventListener("webglcontextrestored",tt,!1),H===null){const pe=["webgl2","webgl","experimental-webgl"];if(d.isWebGL1Renderer===!0&&pe.shift(),H=W(pe,Z),H===null)throw W(pe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}H.getShaderPrecisionFormat===void 0&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Z){throw console.error("THREE.WebGLRenderer: "+Z.message),Z}let q,Q,ee,ne,Y,te,F,$,J,k,U,oe,le,ae,fe,ge,we,ue,ye,se,be,he;function me(){q=new PO(H),Q=new AO(H,q,n),q.init(Q),be=new Mv(H,q,Q),ee=new nN(H,q,Q),N[0]=1029,ne=new NO,Y=new j3,te=new iN(H,q,ee,Y,Q,be,ne),F=new RO(d),$=new iP(H,Q),he=new EO(H,q,$,Q),J=new IO(H,$,ne,he),k=new VO(H,J,$,ne),ue=new FO(H),fe=new LO(Y),U=new W3(d,F,q,Q,he,fe),oe=new oN(Y),le=new Z3(Y),ae=new Q3(q,Q),we=new TO(d,F,ee,k,l),ge=new wv(d,k,Q),ye=new CO(H,q,ne,Q),se=new OO(H,q,ne,Q),ne.programs=U.programs,d.capabilities=Q,d.extensions=q,d.properties=Y,d.renderLists=le,d.shadowMap=ge,d.state=ee,d.info=ne}me();const Te=new sN(d,H);this.xr=Te,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const Z=q.get("WEBGL_lose_context");Z&&Z.loseContext()},this.forceContextRestore=function(){const Z=q.get("WEBGL_lose_context");Z&&Z.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(Z){Z!==void 0&&(P=Z,this.setSize(C,R,!1))},this.getSize=function(Z){return Z.set(C,R)},this.setSize=function(Z,pe,de){if(Te.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}C=Z,R=pe,e.width=Math.floor(Z*P),e.height=Math.floor(pe*P),de!==!1&&(e.style.width=Z+"px",e.style.height=pe+"px"),this.setViewport(0,0,Z,pe)},this.getDrawingBufferSize=function(Z){return Z.set(C*P,R*P).floor()},this.setDrawingBufferSize=function(Z,pe,de){C=Z,R=pe,P=de,e.width=Math.floor(Z*de),e.height=Math.floor(pe*de),this.setViewport(0,0,Z,pe)},this.getCurrentViewport=function(Z){return Z.copy(S)},this.getViewport=function(Z){return Z.copy(I)},this.setViewport=function(Z,pe,de,ve){Z.isVector4?I.set(Z.x,Z.y,Z.z,Z.w):I.set(Z,pe,de,ve),ee.viewport(S.copy(I).multiplyScalar(P).floor())},this.getScissor=function(Z){return Z.copy(O)},this.setScissor=function(Z,pe,de,ve){Z.isVector4?O.set(Z.x,Z.y,Z.z,Z.w):O.set(Z,pe,de,ve),ee.scissor(w.copy(O).multiplyScalar(P).floor())},this.getScissorTest=function(){return x},this.setScissorTest=function(Z){ee.setScissorTest(x=Z)},this.setOpaqueSort=function(Z){L=Z},this.setTransparentSort=function(Z){A=Z},this.getClearColor=function(Z){return Z.copy(we.getClearColor())},this.setClearColor=function(){we.setClearColor.apply(we,arguments)},this.getClearAlpha=function(){return we.getClearAlpha()},this.setClearAlpha=function(){we.setClearAlpha.apply(we,arguments)},this.clear=function(Z,pe,de){let ve=0;(Z===void 0||Z)&&(ve|=16384),(pe===void 0||pe)&&(ve|=256),(de===void 0||de)&&(ve|=1024),H.clear(ve)},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",He,!1),e.removeEventListener("webglcontextrestored",tt,!1),le.dispose(),ae.dispose(),Y.dispose(),F.dispose(),k.dispose(),he.dispose(),Te.dispose(),Te.removeEventListener("sessionstart",et),Te.removeEventListener("sessionend",Tt),z&&(z.dispose(),z=null),xt.stop()};function He(Z){Z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function tt(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const Z=ne.autoReset,pe=ge.enabled,de=ge.autoUpdate,ve=ge.needsUpdate,Ee=ge.type;me(),ne.autoReset=Z,ge.enabled=pe,ge.autoUpdate=de,ge.needsUpdate=ve,ge.type=Ee}function Re(Z){const pe=Z.target;pe.removeEventListener("dispose",Re),ot(pe)}function ot(Z){Pe(Z),Y.remove(Z)}function Pe(Z){const pe=Y.get(Z).programs;pe!==void 0&&pe.forEach(function(de){U.releaseProgram(de)})}function Je(Z,pe){Z.render(function(de){d.renderBufferImmediate(de,pe)})}this.renderBufferImmediate=function(Z,pe){he.initAttributes();const de=Y.get(Z);Z.hasPositions&&!de.position&&(de.position=H.createBuffer()),Z.hasNormals&&!de.normal&&(de.normal=H.createBuffer()),Z.hasUvs&&!de.uv&&(de.uv=H.createBuffer()),Z.hasColors&&!de.color&&(de.color=H.createBuffer());const ve=pe.getAttributes();Z.hasPositions&&(H.bindBuffer(34962,de.position),H.bufferData(34962,Z.positionArray,35048),he.enableAttribute(ve.position),H.vertexAttribPointer(ve.position,3,5126,!1,0,0)),Z.hasNormals&&(H.bindBuffer(34962,de.normal),H.bufferData(34962,Z.normalArray,35048),he.enableAttribute(ve.normal),H.vertexAttribPointer(ve.normal,3,5126,!1,0,0)),Z.hasUvs&&(H.bindBuffer(34962,de.uv),H.bufferData(34962,Z.uvArray,35048),he.enableAttribute(ve.uv),H.vertexAttribPointer(ve.uv,2,5126,!1,0,0)),Z.hasColors&&(H.bindBuffer(34962,de.color),H.bufferData(34962,Z.colorArray,35048),he.enableAttribute(ve.color),H.vertexAttribPointer(ve.color,3,5126,!1,0,0)),he.disableUnusedAttributes(),H.drawArrays(4,0,Z.count),Z.count=0},this.renderBufferDirect=function(Z,pe,de,ve,Ee,ce){pe===null&&(pe=ie);const xe=Ee.isMesh&&Ee.matrixWorld.determinant()<0,_e=ct(Z,pe,ve,Ee);ee.setMaterial(ve,xe);let Ie=de.index;const Be=de.attributes.position;if(Ie===null){if(Be===void 0||Be.count===0)return}else if(Ie.count===0)return;let ze=1;ve.wireframe===!0&&(Ie=J.getWireframeAttribute(de),ze=2),(ve.morphTargets||ve.morphNormals)&&ue.update(Ee,de,ve,_e),he.setup(Ee,ve,_e,de,Ie);let ke,qe=ye;Ie!==null&&(ke=$.get(Ie),qe=se,qe.setIndex(ke));const Bt=Ie!==null?Ie.count:Be.count,$t=de.drawRange.start*ze,ds=de.drawRange.count*ze,mt=ce!==null?ce.start*ze:0,hs=ce!==null?ce.count*ze:1/0,sn=Math.max($t,mt),PV=Math.min(Bt,$t+ds,mt+hs)-1,ou=Math.max(0,PV-sn+1);if(ou!==0){if(Ee.isMesh)ve.wireframe===!0?(ee.setLineWidth(ve.wireframeLinewidth*j()),qe.setMode(1)):qe.setMode(4);else if(Ee.isLine){let Ya=ve.linewidth;Ya===void 0&&(Ya=1),ee.setLineWidth(Ya*j()),Ee.isLineSegments?qe.setMode(1):Ee.isLineLoop?qe.setMode(2):qe.setMode(3)}else Ee.isPoints?qe.setMode(0):Ee.isSprite&&qe.setMode(4);if(Ee.isInstancedMesh)qe.renderInstances(sn,ou,Ee.count);else if(de.isInstancedBufferGeometry){const Ya=Math.min(de.instanceCount,de._maxInstanceCount);qe.renderInstances(sn,ou,Ya)}else qe.render(sn,ou)}},this.compile=function(Z,pe){m=ae.get(Z),m.init(),Z.traverseVisible(function(de){de.isLight&&de.layers.test(pe.layers)&&(m.pushLight(de),de.castShadow&&m.pushShadow(de))}),m.setupLights(),Z.traverse(function(de){const ve=de.material;if(ve)if(Array.isArray(ve))for(let Ee=0;Ee<ve.length;Ee++){const ce=ve[Ee];Xe(ce,Z,de)}else Xe(ve,Z,de)})};let We=null;function at(Z){We&&We(Z)}function et(){xt.stop()}function Tt(){xt.start()}const xt=new Ky;xt.setAnimationLoop(at),typeof window<"u"&&xt.setContext(window),this.setAnimationLoop=function(Z){We=Z,Te.setAnimationLoop(Z),Z===null?xt.stop():xt.start()},Te.addEventListener("sessionstart",et),Te.addEventListener("sessionend",Tt),this.render=function(Z,pe){if(pe!==void 0&&pe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;Z.autoUpdate===!0&&Z.updateMatrixWorld(),pe.parent===null&&pe.updateMatrixWorld(),Te.enabled===!0&&Te.isPresenting===!0&&(Te.cameraAutoUpdate===!0&&Te.updateCamera(pe),pe=Te.getCamera()),Z.isScene===!0&&Z.onBeforeRender(d,Z,pe,M),m=ae.get(Z,p.length),m.init(),p.push(m),G.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),B.setFromProjectionMatrix(G),V=this.localClippingEnabled,D=fe.init(this.clippingPlanes,V,pe),h=le.get(Z,y.length),h.init(),y.push(h),re(Z,pe,0,d.sortObjects),h.finish(),d.sortObjects===!0&&h.sort(L,A),D===!0&&fe.beginShadows();const de=m.state.shadowsArray;ge.render(de,Z,pe),m.setupLights(),m.setupLightsView(pe),D===!0&&fe.endShadows(),this.info.autoReset===!0&&this.info.reset(),we.render(h,Z);const ve=h.opaque,Ee=h.transmissive,ce=h.transparent;ve.length>0&&Ce(ve,Z,pe),Ee.length>0&&Me(ve,Ee,Z,pe),ce.length>0&&Ce(ce,Z,pe),M!==null&&(te.updateMultisampleRenderTarget(M),te.updateRenderTargetMipmap(M)),Z.isScene===!0&&Z.onAfterRender(d,Z,pe),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1),he.resetDefaultState(),_=-1,E=null,p.pop(),p.length>0?m=p[p.length-1]:m=null,y.pop(),y.length>0?h=y[y.length-1]:h=null};function re(Z,pe,de,ve){if(Z.visible===!1)return;if(Z.layers.test(pe.layers)){if(Z.isGroup)de=Z.renderOrder;else if(Z.isLOD)Z.autoUpdate===!0&&Z.update(pe);else if(Z.isLight)m.pushLight(Z),Z.castShadow&&m.pushShadow(Z);else if(Z.isSprite){if(!Z.frustumCulled||B.intersectsSprite(Z)){ve&&K.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(G);const xe=k.update(Z),_e=Z.material;_e.visible&&h.push(Z,xe,_e,de,K.z,null)}}else if(Z.isImmediateRenderObject)ve&&K.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(G),h.push(Z,null,Z.material,de,K.z,null);else if((Z.isMesh||Z.isLine||Z.isPoints)&&(Z.isSkinnedMesh&&Z.skeleton.frame!==ne.render.frame&&(Z.skeleton.update(),Z.skeleton.frame=ne.render.frame),!Z.frustumCulled||B.intersectsObject(Z))){ve&&K.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(G);const xe=k.update(Z),_e=Z.material;if(Array.isArray(_e)){const Ie=xe.groups;for(let Be=0,ze=Ie.length;Be<ze;Be++){const ke=Ie[Be],qe=_e[ke.materialIndex];qe&&qe.visible&&h.push(Z,xe,qe,de,K.z,ke)}}else _e.visible&&h.push(Z,xe,_e,de,K.z,null)}}const ce=Z.children;for(let xe=0,_e=ce.length;xe<_e;xe++)re(ce[xe],pe,de,ve)}function Me(Z,pe,de,ve){if(z===null){const _e=o===!0&&Q.isWebGL2===!0?$d:Vn;z=new _e(1024,1024,{generateMipmaps:!0,type:be.convert(Br)!==null?Br:Dr,minFilter:Ti,magFilter:Lt,wrapS:Wt,wrapT:Wt})}const Ee=d.getRenderTarget();d.setRenderTarget(z),d.clear();const ce=d.toneMapping;d.toneMapping=nr,Ce(Z,de,ve),d.toneMapping=ce,te.updateMultisampleRenderTarget(z),te.updateRenderTargetMipmap(z),d.setRenderTarget(Ee),Ce(pe,de,ve)}function Ce(Z,pe,de){const ve=pe.isScene===!0?pe.overrideMaterial:null;for(let Ee=0,ce=Z.length;Ee<ce;Ee++){const xe=Z[Ee],_e=xe.object,Ie=xe.geometry,Be=ve===null?xe.material:ve,ze=xe.group;if(de.isArrayCamera){const ke=de.cameras;for(let qe=0,Bt=ke.length;qe<Bt;qe++){const $t=ke[qe];_e.layers.test($t.layers)&&(ee.viewport(S.copy($t.viewport)),m.setupLightsView($t),Ne(_e,pe,$t,Ie,Be,ze))}}else Ne(_e,pe,de,Ie,Be,ze)}}function Ne(Z,pe,de,ve,Ee,ce){if(Z.onBeforeRender(d,pe,de,ve,Ee,ce),Z.modelViewMatrix.multiplyMatrices(de.matrixWorldInverse,Z.matrixWorld),Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix),Z.isImmediateRenderObject){const xe=ct(de,pe,Ee,Z);ee.setMaterial(Ee),he.reset(),Je(Z,xe)}else Ee.transparent===!0&&Ee.side===tr?(Ee.side=At,Ee.needsUpdate=!0,d.renderBufferDirect(de,pe,ve,Ee,Z,ce),Ee.side=er,Ee.needsUpdate=!0,d.renderBufferDirect(de,pe,ve,Ee,Z,ce),Ee.side=tr):d.renderBufferDirect(de,pe,ve,Ee,Z,ce);Z.onAfterRender(d,pe,de,ve,Ee,ce)}function Xe(Z,pe,de){pe.isScene!==!0&&(pe=ie);const ve=Y.get(Z),Ee=m.state.lights,ce=m.state.shadowsArray,xe=Ee.state.version,_e=U.getParameters(Z,Ee.state,ce,pe,de),Ie=U.getProgramCacheKey(_e);let Be=ve.programs;ve.environment=Z.isMeshStandardMaterial?pe.environment:null,ve.fog=pe.fog,ve.envMap=F.get(Z.envMap||ve.environment),Be===void 0&&(Z.addEventListener("dispose",Re),Be=new Map,ve.programs=Be);let ze=Be.get(Ie);if(ze!==void 0){if(ve.currentProgram===ze&&ve.lightsStateVersion===xe)return it(Z,_e),ze}else _e.uniforms=U.getUniforms(Z),Z.onBuild(_e,d),Z.onBeforeCompile(_e,d),ze=U.acquireProgram(_e,Ie),Be.set(Ie,ze),ve.uniforms=_e.uniforms;const ke=ve.uniforms;(!Z.isShaderMaterial&&!Z.isRawShaderMaterial||Z.clipping===!0)&&(ke.clippingPlanes=fe.uniform),it(Z,_e),ve.needsLights=Et(Z),ve.lightsStateVersion=xe,ve.needsLights&&(ke.ambientLightColor.value=Ee.state.ambient,ke.lightProbe.value=Ee.state.probe,ke.directionalLights.value=Ee.state.directional,ke.directionalLightShadows.value=Ee.state.directionalShadow,ke.spotLights.value=Ee.state.spot,ke.spotLightShadows.value=Ee.state.spotShadow,ke.rectAreaLights.value=Ee.state.rectArea,ke.ltc_1.value=Ee.state.rectAreaLTC1,ke.ltc_2.value=Ee.state.rectAreaLTC2,ke.pointLights.value=Ee.state.point,ke.pointLightShadows.value=Ee.state.pointShadow,ke.hemisphereLights.value=Ee.state.hemi,ke.directionalShadowMap.value=Ee.state.directionalShadowMap,ke.directionalShadowMatrix.value=Ee.state.directionalShadowMatrix,ke.spotShadowMap.value=Ee.state.spotShadowMap,ke.spotShadowMatrix.value=Ee.state.spotShadowMatrix,ke.pointShadowMap.value=Ee.state.pointShadowMap,ke.pointShadowMatrix.value=Ee.state.pointShadowMatrix);const qe=ze.getUniforms(),Bt=pr.seqWithValue(qe.seq,ke);return ve.currentProgram=ze,ve.uniformsList=Bt,ze}function it(Z,pe){const de=Y.get(Z);de.outputEncoding=pe.outputEncoding,de.instancing=pe.instancing,de.skinning=pe.skinning,de.numClippingPlanes=pe.numClippingPlanes,de.numIntersection=pe.numClipIntersection,de.vertexAlphas=pe.vertexAlphas}function ct(Z,pe,de,ve){pe.isScene!==!0&&(pe=ie),te.resetTextureUnits();const Ee=pe.fog,ce=de.isMeshStandardMaterial?pe.environment:null,xe=M===null?d.outputEncoding:M.texture.encoding,_e=F.get(de.envMap||ce),Ie=de.vertexColors===!0&&ve.geometry&&ve.geometry.attributes.color&&ve.geometry.attributes.color.itemSize===4,Be=Y.get(de),ze=m.state.lights;if(D===!0&&(V===!0||Z!==E)){const sn=Z===E&&de.id===_;fe.setState(de,Z,sn)}let ke=!1;de.version===Be.__version?(Be.needsLights&&Be.lightsStateVersion!==ze.state.version||Be.outputEncoding!==xe||ve.isInstancedMesh&&Be.instancing===!1||!ve.isInstancedMesh&&Be.instancing===!0||ve.isSkinnedMesh&&Be.skinning===!1||!ve.isSkinnedMesh&&Be.skinning===!0||Be.envMap!==_e||de.fog&&Be.fog!==Ee||Be.numClippingPlanes!==void 0&&(Be.numClippingPlanes!==fe.numPlanes||Be.numIntersection!==fe.numIntersection)||Be.vertexAlphas!==Ie)&&(ke=!0):(ke=!0,Be.__version=de.version);let qe=Be.currentProgram;ke===!0&&(qe=Xe(de,pe,ve));let Bt=!1,$t=!1,ds=!1;const mt=qe.getUniforms(),hs=Be.uniforms;if(ee.useProgram(qe.program)&&(Bt=!0,$t=!0,ds=!0),de.id!==_&&(_=de.id,$t=!0),Bt||E!==Z){if(mt.setValue(H,"projectionMatrix",Z.projectionMatrix),Q.logarithmicDepthBuffer&&mt.setValue(H,"logDepthBufFC",2/(Math.log(Z.far+1)/Math.LN2)),E!==Z&&(E=Z,$t=!0,ds=!0),de.isShaderMaterial||de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshStandardMaterial||de.envMap){const sn=mt.map.cameraPosition;sn!==void 0&&sn.setValue(H,K.setFromMatrixPosition(Z.matrixWorld))}(de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshLambertMaterial||de.isMeshBasicMaterial||de.isMeshStandardMaterial||de.isShaderMaterial)&&mt.setValue(H,"isOrthographic",Z.isOrthographicCamera===!0),(de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshLambertMaterial||de.isMeshBasicMaterial||de.isMeshStandardMaterial||de.isShaderMaterial||de.isShadowMaterial||ve.isSkinnedMesh)&&mt.setValue(H,"viewMatrix",Z.matrixWorldInverse)}if(ve.isSkinnedMesh){mt.setOptional(H,ve,"bindMatrix"),mt.setOptional(H,ve,"bindMatrixInverse");const sn=ve.skeleton;sn&&(Q.floatVertexTextures?(sn.boneTexture===null&&sn.computeBoneTexture(),mt.setValue(H,"boneTexture",sn.boneTexture,te),mt.setValue(H,"boneTextureSize",sn.boneTextureSize)):mt.setOptional(H,sn,"boneMatrices"))}return($t||Be.receiveShadow!==ve.receiveShadow)&&(Be.receiveShadow=ve.receiveShadow,mt.setValue(H,"receiveShadow",ve.receiveShadow)),$t&&(mt.setValue(H,"toneMappingExposure",d.toneMappingExposure),Be.needsLights&&pt(hs,ds),Ee&&de.fog&&oe.refreshFogUniforms(hs,Ee),oe.refreshMaterialUniforms(hs,de,P,R,z),pr.upload(H,Be.uniformsList,hs,te)),de.isShaderMaterial&&de.uniformsNeedUpdate===!0&&(pr.upload(H,Be.uniformsList,hs,te),de.uniformsNeedUpdate=!1),de.isSpriteMaterial&&mt.setValue(H,"center",ve.center),mt.setValue(H,"modelViewMatrix",ve.modelViewMatrix),mt.setValue(H,"normalMatrix",ve.normalMatrix),mt.setValue(H,"modelMatrix",ve.matrixWorld),qe}function pt(Z,pe){Z.ambientLightColor.needsUpdate=pe,Z.lightProbe.needsUpdate=pe,Z.directionalLights.needsUpdate=pe,Z.directionalLightShadows.needsUpdate=pe,Z.pointLights.needsUpdate=pe,Z.pointLightShadows.needsUpdate=pe,Z.spotLights.needsUpdate=pe,Z.spotLightShadows.needsUpdate=pe,Z.rectAreaLights.needsUpdate=pe,Z.hemisphereLights.needsUpdate=pe}function Et(Z){return Z.isMeshLambertMaterial||Z.isMeshToonMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isShadowMaterial||Z.isShaderMaterial&&Z.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return g},this.getRenderTarget=function(){return M},this.setRenderTarget=function(Z,pe=0,de=0){M=Z,v=pe,g=de,Z&&Y.get(Z).__webglFramebuffer===void 0&&te.setupRenderTarget(Z);let ve=null,Ee=!1,ce=!1;if(Z){const _e=Z.texture;(_e.isDataTexture3D||_e.isDataTexture2DArray)&&(ce=!0);const Ie=Y.get(Z).__webglFramebuffer;Z.isWebGLCubeRenderTarget?(ve=Ie[pe],Ee=!0):Z.isWebGLMultisampleRenderTarget?ve=Y.get(Z).__webglMultisampledFramebuffer:ve=Ie,S.copy(Z.viewport),w.copy(Z.scissor),T=Z.scissorTest}else S.copy(I).multiplyScalar(P).floor(),w.copy(O).multiplyScalar(P).floor(),T=x;if(ee.bindFramebuffer(36160,ve)&&Q.drawBuffers){let _e=!1;if(Z)if(Z.isWebGLMultipleRenderTargets){const Ie=Z.texture;if(N.length!==Ie.length||N[0]!==36064){for(let Be=0,ze=Ie.length;Be<ze;Be++)N[Be]=36064+Be;N.length=Ie.length,_e=!0}}else(N.length!==1||N[0]!==36064)&&(N[0]=36064,N.length=1,_e=!0);else(N.length!==1||N[0]!==1029)&&(N[0]=1029,N.length=1,_e=!0);_e&&(Q.isWebGL2?H.drawBuffers(N):q.get("WEBGL_draw_buffers").drawBuffersWEBGL(N))}if(ee.viewport(S),ee.scissor(w),ee.setScissorTest(T),Ee){const _e=Y.get(Z.texture);H.framebufferTexture2D(36160,36064,34069+pe,_e.__webglTexture,de)}else if(ce){const _e=Y.get(Z.texture),Ie=pe||0;H.framebufferTextureLayer(36160,36064,_e.__webglTexture,de||0,Ie)}},this.readRenderTargetPixels=function(Z,pe,de,ve,Ee,ce,xe){if(!(Z&&Z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=Y.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&xe!==void 0&&(_e=_e[xe]),_e){ee.bindFramebuffer(36160,_e);try{const Ie=Z.texture,Be=Ie.format,ze=Ie.type;if(Be!==vn&&be.convert(Be)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ke=ze===Br&&(q.has("EXT_color_buffer_half_float")||Q.isWebGL2&&q.has("EXT_color_buffer_float"));if(ze!==Dr&&be.convert(ze)!==H.getParameter(35738)&&!(ze===Ei&&(Q.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float")))&&!ke){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H.checkFramebufferStatus(36160)===36053?pe>=0&&pe<=Z.width-ve&&de>=0&&de<=Z.height-Ee&&H.readPixels(pe,de,ve,Ee,be.convert(Be),be.convert(ze),ce):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const Ie=M!==null?Y.get(M).__webglFramebuffer:null;ee.bindFramebuffer(36160,Ie)}}},this.copyFramebufferToTexture=function(Z,pe,de=0){const ve=Math.pow(2,-de),Ee=Math.floor(pe.image.width*ve),ce=Math.floor(pe.image.height*ve);let xe=be.convert(pe.format);Q.isWebGL2&&(xe===6407&&(xe=32849),xe===6408&&(xe=32856)),te.setTexture2D(pe,0),H.copyTexImage2D(3553,de,xe,Z.x,Z.y,Ee,ce,0),ee.unbindTexture()},this.copyTextureToTexture=function(Z,pe,de,ve=0){const Ee=pe.image.width,ce=pe.image.height,xe=be.convert(de.format),_e=be.convert(de.type);te.setTexture2D(de,0),H.pixelStorei(37440,de.flipY),H.pixelStorei(37441,de.premultiplyAlpha),H.pixelStorei(3317,de.unpackAlignment),pe.isDataTexture?H.texSubImage2D(3553,ve,Z.x,Z.y,Ee,ce,xe,_e,pe.image.data):pe.isCompressedTexture?H.compressedTexSubImage2D(3553,ve,Z.x,Z.y,pe.mipmaps[0].width,pe.mipmaps[0].height,xe,pe.mipmaps[0].data):H.texSubImage2D(3553,ve,Z.x,Z.y,xe,_e,pe.image),ve===0&&de.generateMipmaps&&H.generateMipmap(3553),ee.unbindTexture()},this.copyTextureToTexture3D=function(Z,pe,de,ve,Ee=0){if(d.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const ce=Z.max.x-Z.min.x+1,xe=Z.max.y-Z.min.y+1,_e=Z.max.z-Z.min.z+1,Ie=be.convert(ve.format),Be=be.convert(ve.type);let ze;if(ve.isDataTexture3D)te.setTexture3D(ve,0),ze=32879;else if(ve.isDataTexture2DArray)te.setTexture2DArray(ve,0),ze=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,ve.flipY),H.pixelStorei(37441,ve.premultiplyAlpha),H.pixelStorei(3317,ve.unpackAlignment);const ke=H.getParameter(3314),qe=H.getParameter(32878),Bt=H.getParameter(3316),$t=H.getParameter(3315),ds=H.getParameter(32877),mt=de.isCompressedTexture?de.mipmaps[0]:de.image;H.pixelStorei(3314,mt.width),H.pixelStorei(32878,mt.height),H.pixelStorei(3316,Z.min.x),H.pixelStorei(3315,Z.min.y),H.pixelStorei(32877,Z.min.z),de.isDataTexture||de.isDataTexture3D?H.texSubImage3D(ze,Ee,pe.x,pe.y,pe.z,ce,xe,_e,Ie,Be,mt.data):de.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(ze,Ee,pe.x,pe.y,pe.z,ce,xe,_e,Ie,mt.data)):H.texSubImage3D(ze,Ee,pe.x,pe.y,pe.z,ce,xe,_e,Ie,Be,mt),H.pixelStorei(3314,ke),H.pixelStorei(32878,qe),H.pixelStorei(3316,Bt),H.pixelStorei(3315,$t),H.pixelStorei(32877,ds),Ee===0&&ve.generateMipmaps&&H.generateMipmap(ze),ee.unbindTexture()},this.initTexture=function(Z){te.setTexture2D(Z,0),ee.unbindTexture()},this.resetState=function(){v=0,g=0,M=null,ee.reset(),he.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Sv extends lt{}Sv.prototype.isWebGL1Renderer=!0;class pa{constructor(e,t=25e-5){this.name="",this.color=new Ae(e),this.density=t}clone(){return new pa(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}pa.prototype.isFogExp2=!0;class ma{constructor(e,t=1,i=1e3){this.name="",this.color=new Ae(e),this.near=t,this.far=i}clone(){return new ma(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}ma.prototype.isFog=!0;class mc extends $e{constructor(){super(),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){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}mc.prototype.isScene=!0;class mr{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fs,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=bn()}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,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];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=bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}mr.prototype.isInterleavedBuffer=!0;const Ot=new X;class Bi{constructor(e,t,i,r=!1){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r===!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,i=this.data.count;t<i;t++)Ot.x=this.getX(t),Ot.y=this.getY(t),Ot.z=this.getZ(t),Ot.applyMatrix4(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ot.x=this.getX(t),Ot.y=this.getY(t),Ot.z=this.getZ(t),Ot.applyNormalMatrix(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ot.x=this.getX(t),Ot.y=this.getY(t),Ot.z=this.getZ(t),Ot.transformDirection(e),this.setXYZ(t,Ot.x,Ot.y,Ot.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,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+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 Bi(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+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}}}Bi.prototype.isInterleavedBufferAttribute=!0;class ga extends Vt{constructor(e){super(),this.type="SpriteMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}ga.prototype.isSpriteMaterial=!0;let no;const ya=new X,io=new X,ro=new X,so=new Se,va=new Se,_v=new De,gc=new X,ba=new X,yc=new X,Tv=new Se,Mh=new Se,Ev=new Se;class xa extends $e{constructor(e){if(super(),this.type="Sprite",no===void 0){no=new Ve;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new mr(t,5);no.setIndex([0,1,2,0,2,3]),no.setAttribute("position",new Bi(i,3,0,!1)),no.setAttribute("uv",new Bi(i,2,3,!1))}this.geometry=no,this.material=e!==void 0?e:new ga,this.center=new Se(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),io.setFromMatrixScale(this.matrixWorld),_v.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ro.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&io.multiplyScalar(-ro.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const o=this.center;vc(gc.set(-.5,-.5,0),ro,o,io,r,s),vc(ba.set(.5,-.5,0),ro,o,io,r,s),vc(yc.set(.5,.5,0),ro,o,io,r,s),Tv.set(0,0),Mh.set(1,0),Ev.set(1,1);let l=e.ray.intersectTriangle(gc,ba,yc,!1,ya);if(l===null&&(vc(ba.set(-.5,.5,0),ro,o,io,r,s),Mh.set(0,1),l=e.ray.intersectTriangle(gc,yc,ba,!1,ya),l===null))return;const u=e.ray.origin.distanceTo(ya);u<e.near||u>e.far||t.push({distance:u,point:ya.clone(),uv:Pt.getUV(ya,gc,ba,yc,Tv,Mh,Ev,new Se),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}xa.prototype.isSprite=!0;function vc(n,e,t,i,r,s){so.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(va.x=s*so.x-r*so.y,va.y=r*so.x+s*so.y):va.copy(so),n.copy(e),n.x+=va.x,n.y+=va.y,n.applyMatrix4(_v)}const bc=new X,Cv=new X;class Av extends $e{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r&&!(e<t[i].distance);i++);return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){bc.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(bc);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){bc.setFromMatrixPosition(e.matrixWorld),Cv.setFromMatrixPosition(this.matrixWorld);const i=bc.distanceTo(Cv)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s&&i>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance})}return t}}const Lv=new X,Rv=new st,Pv=new st,lN=new X,Iv=new De;class wa extends It{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new De,this.bindMatrixInverse=new De}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const i=this.skeleton,r=this.geometry;Rv.fromBufferAttribute(r.attributes.skinIndex,e),Pv.fromBufferAttribute(r.attributes.skinWeight,e),Lv.fromBufferAttribute(r.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=Pv.getComponent(s);if(o!==0){const l=Rv.getComponent(s);Iv.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),t.addScaledVector(lN.copy(Lv).applyMatrix4(Iv),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}wa.prototype.isSkinnedMesh=!0;class Ma extends $e{constructor(){super(),this.type="Bone"}}Ma.prototype.isBone=!0;class Xr extends Rt{constructor(e=null,t=1,i=1,r,s,o,l,u,c=Lt,f=Lt,h,m){super(null,o,l,u,c,f,r,s,h,m),this.image={data:e,width:t,height:i},this.magFilter=c,this.minFilter=f,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Xr.prototype.isDataTexture=!0;const Ov=new De,cN=new De;class Sa{constructor(e=[],t=[]){this.uuid=bn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new De)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new De;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const l=e[s]?e[s].matrixWorld:cN;Ov.multiplyMatrices(l,t[s]),Ov.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Sa(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Ay(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Xr(t,e,e,vn,Ei);return this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Ma),this.bones.push(o),this.boneInverses.push(new De().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const o=t[r];e.bones.push(o.uuid);const l=i[r];e.boneInverses.push(l.toArray())}return e}}const Nv=new De,Dv=new De,xc=[],_a=new It;class Sh extends It{constructor(e,t,i){super(e,t),this.instanceMatrix=new Ge(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const i=this.matrixWorld,r=this.count;if(_a.geometry=this.geometry,_a.material=this.material,_a.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,Nv),Dv.multiplyMatrices(i,Nv),_a.matrixWorld=Dv,_a.raycast(e,xc);for(let o=0,l=xc.length;o<l;o++){const u=xc[o];u.instanceId=s,u.object=this,t.push(u)}xc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ge(new Float32Array(this.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}Sh.prototype.isInstancedMesh=!0;class Ut extends Vt{constructor(e){super(),this.type="LineBasicMaterial",this.color=new Ae(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,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.morphTargets=e.morphTargets,this}}Ut.prototype.isLineBasicMaterial=!0;const Bv=new X,Fv=new X,Vv=new De,_h=new cr,wc=new Li;class ii extends $e{constructor(e=new Ve,t=new Ut){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Bv.fromBufferAttribute(t,r-1),Fv.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Bv.distanceTo(Fv);e.setAttribute("lineDistance",new Oe(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),wc.copy(i.boundingSphere),wc.applyMatrix4(r),wc.radius+=s,e.ray.intersectsSphere(wc)===!1)return;Vv.copy(r).invert(),_h.copy(e.ray).applyMatrix4(Vv);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,c=new X,f=new X,h=new X,m=new X,y=this.isLineSegments?2:1;if(i.isBufferGeometry){const p=i.index,b=i.attributes.position;if(p!==null){const v=Math.max(0,o.start),g=Math.min(p.count,o.start+o.count);for(let M=v,_=g-1;M<_;M+=y){const E=p.getX(M),S=p.getX(M+1);if(c.fromBufferAttribute(b,E),f.fromBufferAttribute(b,S),_h.distanceSqToSegment(c,f,m,h)>u)continue;m.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(m);T<e.near||T>e.far||t.push({distance:T,point:h.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),g=Math.min(b.count,o.start+o.count);for(let M=v,_=g-1;M<_;M+=y){if(c.fromBufferAttribute(b,M),f.fromBufferAttribute(b,M+1),_h.distanceSqToSegment(c,f,m,h)>u)continue;m.applyMatrix4(this.matrixWorld);const S=e.ray.origin.distanceTo(m);S<e.near||S>e.far||t.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const l=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}ii.prototype.isLine=!0;const kv=new X,zv=new X;class un extends ii{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)kv.fromBufferAttribute(t,r),zv.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+kv.distanceTo(zv);e.setAttribute("lineDistance",new Oe(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}un.prototype.isLineSegments=!0;class Mc extends ii{constructor(e,t){super(e,t),this.type="LineLoop"}}Mc.prototype.isLineLoop=!0;class gr extends Vt{constructor(e){super(),this.type="PointsMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this}}gr.prototype.isPointsMaterial=!0;const Uv=new De,Th=new cr,Sc=new Li,_c=new X;class oo extends $e{constructor(e=new Ve,t=new gr){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Sc.copy(i.boundingSphere),Sc.applyMatrix4(r),Sc.radius+=s,e.ray.intersectsSphere(Sc)===!1)return;Uv.copy(r).invert(),Th.copy(e.ray).applyMatrix4(Uv);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l;if(i.isBufferGeometry){const c=i.index,h=i.attributes.position;if(c!==null){const m=Math.max(0,o.start),y=Math.min(c.count,o.start+o.count);for(let p=m,d=y;p<d;p++){const b=c.getX(p);_c.fromBufferAttribute(h,b),Gv(_c,b,u,r,e,t,this)}}else{const m=Math.max(0,o.start),y=Math.min(h.count,o.start+o.count);for(let p=m,d=y;p<d;p++)_c.fromBufferAttribute(h,p),Gv(_c,p,u,r,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const l=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}oo.prototype.isPoints=!0;function Gv(n,e,t,i,r,s,o){const l=Th.distanceSqToPoint(n);if(l<t){const u=new X;Th.closestPointToPoint(n,u),u.applyMatrix4(i);const c=r.ray.origin.distanceTo(u);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,object:o})}}class Hv extends Rt{constructor(e,t,i,r,s,o,l,u,c){super(e,t,i,r,s,o,l,u,c),this.format=l!==void 0?l:Ci,this.minFilter=o!==void 0?o:wt,this.magFilter=s!==void 0?s:wt,this.generateMipmaps=!1;const f=this;function h(){f.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Hv.prototype.isVideoTexture=!0;class Eh extends Rt{constructor(e,t,i,r,s,o,l,u,c,f,h,m){super(null,o,l,u,c,f,r,s,h,m),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Eh.prototype.isCompressedTexture=!0;class Wv extends Rt{constructor(e,t,i,r,s,o,l,u,c){super(e,t,i,r,s,o,l,u,c),this.needsUpdate=!0}}Wv.prototype.isCanvasTexture=!0;class jv extends Rt{constructor(e,t,i,r,s,o,l,u,c,f){if(f=f!==void 0?f:Fr,f!==Fr&&f!==Ds)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&f===Fr&&(i=ta),i===void 0&&f===Ds&&(i=Ns),super(null,r,s,o,l,u,f,i,c),this.image={width:e,height:t},this.magFilter=l!==void 0?l:Lt,this.minFilter=u!==void 0?u:Lt,this.flipY=!1,this.generateMipmaps=!1}}jv.prototype.isDepthTexture=!0;class ao extends Ve{constructor(e=1,t=8,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],o=[],l=[],u=[],c=new X,f=new Se;o.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let h=0,m=3;h<=t;h++,m+=3){const y=i+h/t*r;c.x=e*Math.cos(y),c.y=e*Math.sin(y),o.push(c.x,c.y,c.z),l.push(0,0,1),f.x=(o[m]/e+1)/2,f.y=(o[m+1]/e+1)/2,u.push(f.x,f.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Oe(o,3)),this.setAttribute("normal",new Oe(l,3)),this.setAttribute("uv",new Oe(u,2))}static fromJSON(e){return new ao(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class yr extends Ve{constructor(e=1,t=1,i=1,r=8,s=1,o=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:l,thetaLength:u};const c=this;r=Math.floor(r),s=Math.floor(s);const f=[],h=[],m=[],y=[];let p=0;const d=[],b=i/2;let v=0;g(),o===!1&&(e>0&&M(!0),t>0&&M(!1)),this.setIndex(f),this.setAttribute("position",new Oe(h,3)),this.setAttribute("normal",new Oe(m,3)),this.setAttribute("uv",new Oe(y,2));function g(){const _=new X,E=new X;let S=0;const w=(t-e)/i;for(let T=0;T<=s;T++){const C=[],R=T/s,P=R*(t-e)+e;for(let L=0;L<=r;L++){const A=L/r,I=A*u+l,O=Math.sin(I),x=Math.cos(I);E.x=P*O,E.y=-R*i+b,E.z=P*x,h.push(E.x,E.y,E.z),_.set(O,w,x).normalize(),m.push(_.x,_.y,_.z),y.push(A,1-R),C.push(p++)}d.push(C)}for(let T=0;T<r;T++)for(let C=0;C<s;C++){const R=d[C][T],P=d[C+1][T],L=d[C+1][T+1],A=d[C][T+1];f.push(R,P,A),f.push(P,L,A),S+=6}c.addGroup(v,S,0),v+=S}function M(_){const E=p,S=new Se,w=new X;let T=0;const C=_===!0?e:t,R=_===!0?1:-1;for(let L=1;L<=r;L++)h.push(0,b*R,0),m.push(0,R,0),y.push(.5,.5),p++;const P=p;for(let L=0;L<=r;L++){const I=L/r*u+l,O=Math.cos(I),x=Math.sin(I);w.x=C*x,w.y=b*R,w.z=C*O,h.push(w.x,w.y,w.z),m.push(0,R,0),S.x=O*.5+.5,S.y=x*.5*R+.5,y.push(S.x,S.y),p++}for(let L=0;L<r;L++){const A=E+L,I=P+L;_===!0?f.push(I,I+1,A):f.push(I+1,I,A),T+=3}c.addGroup(v,T,_===!0?1:2),v+=T}}static fromJSON(e){return new yr(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class lo extends yr{constructor(e=1,t=1,i=8,r=1,s=!1,o=0,l=Math.PI*2){super(0,e,t,i,r,s,o,l),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:l}}static fromJSON(e){return new lo(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ri extends Ve{constructor(e,t,i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],o=[];l(r),c(i),f(),this.setAttribute("position",new Oe(s,3)),this.setAttribute("normal",new Oe(s.slice(),3)),this.setAttribute("uv",new Oe(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function l(g){const M=new X,_=new X,E=new X;for(let S=0;S<t.length;S+=3)y(t[S+0],M),y(t[S+1],_),y(t[S+2],E),u(M,_,E,g)}function u(g,M,_,E){const S=E+1,w=[];for(let T=0;T<=S;T++){w[T]=[];const C=g.clone().lerp(_,T/S),R=M.clone().lerp(_,T/S),P=S-T;for(let L=0;L<=P;L++)L===0&&T===S?w[T][L]=C:w[T][L]=C.clone().lerp(R,L/P)}for(let T=0;T<S;T++)for(let C=0;C<2*(S-T)-1;C++){const R=Math.floor(C/2);C%2===0?(m(w[T][R+1]),m(w[T+1][R]),m(w[T][R])):(m(w[T][R+1]),m(w[T+1][R+1]),m(w[T+1][R]))}}function c(g){const M=new X;for(let _=0;_<s.length;_+=3)M.x=s[_+0],M.y=s[_+1],M.z=s[_+2],M.normalize().multiplyScalar(g),s[_+0]=M.x,s[_+1]=M.y,s[_+2]=M.z}function f(){const g=new X;for(let M=0;M<s.length;M+=3){g.x=s[M+0],g.y=s[M+1],g.z=s[M+2];const _=b(g)/2/Math.PI+.5,E=v(g)/Math.PI+.5;o.push(_,1-E)}p(),h()}function h(){for(let g=0;g<o.length;g+=6){const M=o[g+0],_=o[g+2],E=o[g+4],S=Math.max(M,_,E),w=Math.min(M,_,E);S>.9&&w<.1&&(M<.2&&(o[g+0]+=1),_<.2&&(o[g+2]+=1),E<.2&&(o[g+4]+=1))}}function m(g){s.push(g.x,g.y,g.z)}function y(g,M){const _=g*3;M.x=e[_+0],M.y=e[_+1],M.z=e[_+2]}function p(){const g=new X,M=new X,_=new X,E=new X,S=new Se,w=new Se,T=new Se;for(let C=0,R=0;C<s.length;C+=9,R+=6){g.set(s[C+0],s[C+1],s[C+2]),M.set(s[C+3],s[C+4],s[C+5]),_.set(s[C+6],s[C+7],s[C+8]),S.set(o[R+0],o[R+1]),w.set(o[R+2],o[R+3]),T.set(o[R+4],o[R+5]),E.copy(g).add(M).add(_).divideScalar(3);const P=b(E);d(S,R+0,g,P),d(w,R+2,M,P),d(T,R+4,_,P)}}function d(g,M,_,E){E<0&&g.x===1&&(o[M]=g.x-1),_.x===0&&_.z===0&&(o[M]=E/2/Math.PI+.5)}function b(g){return Math.atan2(g.z,-g.x)}function v(g){return Math.atan2(-g.y,Math.sqrt(g.x*g.x+g.z*g.z))}}static fromJSON(e){return new ri(e.vertices,e.indices,e.radius,e.details)}}class co extends ri{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],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 co(e.radius,e.detail)}}const Tc=new X,Ec=new X,Ch=new X,Cc=new Pt;class Ah extends Ve{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=t!==void 0?t:1,e.isGeometry===!0){console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return}const r=Math.pow(10,4),s=Math.cos(Gr*t),o=e.getIndex(),l=e.getAttribute("position"),u=o?o.count:l.count,c=[0,0,0],f=["a","b","c"],h=new Array(3),m={},y=[];for(let p=0;p<u;p+=3){o?(c[0]=o.getX(p),c[1]=o.getX(p+1),c[2]=o.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:d,b,c:v}=Cc;if(d.fromBufferAttribute(l,c[0]),b.fromBufferAttribute(l,c[1]),v.fromBufferAttribute(l,c[2]),Cc.getNormal(Ch),h[0]=`${Math.round(d.x*r)},${Math.round(d.y*r)},${Math.round(d.z*r)}`,h[1]=`${Math.round(b.x*r)},${Math.round(b.y*r)},${Math.round(b.z*r)}`,h[2]=`${Math.round(v.x*r)},${Math.round(v.y*r)},${Math.round(v.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let g=0;g<3;g++){const M=(g+1)%3,_=h[g],E=h[M],S=Cc[f[g]],w=Cc[f[M]],T=`${_}_${E}`,C=`${E}_${_}`;C in m&&m[C]?(Ch.dot(m[C].normal)<=s&&(y.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z)),m[C]=null):T in m||(m[T]={index0:c[g],index1:c[M],normal:Ch.clone()})}}for(const p in m)if(m[p]){const{index0:d,index1:b}=m[p];Tc.fromBufferAttribute(l,d),Ec.fromBufferAttribute(l,b),y.push(Tc.x,Tc.y,Tc.z),y.push(Ec.x,Ec.y,Ec.z)}this.setAttribute("position",new Oe(y,3))}}class Mn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const 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;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let l=0,u=s-1,c;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),c=i[r]-o,c<0)l=r+1;else if(c>0)u=r-1;else{u=r;break}if(r=u,i[r]===o)return r/(s-1);const f=i[r],m=i[r+1]-f,y=(o-f)/m;return(r+y)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),l=this.getPoint(s),u=t||(o.isVector2?new Se:new X);return u.copy(l).sub(o).normalize(),u}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new X,r=[],s=[],o=[],l=new X,u=new De;for(let y=0;y<=e;y++){const p=y/e;r[y]=this.getTangentAt(p,new X),r[y].normalize()}s[0]=new X,o[0]=new X;let c=Number.MAX_VALUE;const f=Math.abs(r[0].x),h=Math.abs(r[0].y),m=Math.abs(r[0].z);f<=c&&(c=f,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),m<=c&&i.set(0,0,1),l.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],l),o[0].crossVectors(r[0],s[0]);for(let y=1;y<=e;y++){if(s[y]=s[y-1].clone(),o[y]=o[y-1].clone(),l.crossVectors(r[y-1],r[y]),l.length()>Number.EPSILON){l.normalize();const p=Math.acos(Jt(r[y-1].dot(r[y]),-1,1));s[y].applyMatrix4(u.makeRotationAxis(l,p))}o[y].crossVectors(r[y],s[y])}if(t===!0){let y=Math.acos(Jt(s[0].dot(s[e]),-1,1));y/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(y=-y);for(let p=1;p<=e;p++)s[p].applyMatrix4(u.makeRotationAxis(r[p],y*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const 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}}class Ta extends Mn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,l=!1,u=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=l,this.aRotation=u}getPoint(e,t){const i=t||new Se,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const l=this.aStartAngle+e*s;let u=this.aX+this.xRadius*Math.cos(l),c=this.aY+this.yRadius*Math.sin(l);if(this.aRotation!==0){const f=Math.cos(this.aRotation),h=Math.sin(this.aRotation),m=u-this.aX,y=c-this.aY;u=m*f-y*h+this.aX,c=m*h+y*f+this.aY}return i.set(u,c)}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(){const 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}}Ta.prototype.isEllipseCurve=!0;class Lh extends Ta{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.type="ArcCurve"}}Lh.prototype.isArcCurve=!0;function Rh(){let n=0,e=0,t=0,i=0;function r(s,o,l,u){n=s,e=l,t=-3*s+3*o-2*l-u,i=2*s-2*o+l+u}return{initCatmullRom:function(s,o,l,u,c){r(o,l,c*(l-s),c*(u-o))},initNonuniformCatmullRom:function(s,o,l,u,c,f,h){let m=(o-s)/c-(l-s)/(c+f)+(l-o)/f,y=(l-o)/f-(u-o)/(f+h)+(u-l)/h;m*=f,y*=f,r(o,l,m,y)},calc:function(s){const o=s*s,l=o*s;return n+e*s+t*o+i*l}}}const Ac=new X,Ph=new Rh,Ih=new Rh,Oh=new Rh;class Nh extends Mn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new X){const i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e;let l=Math.floor(o),u=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let c,f;this.closed||l>0?c=r[(l-1)%s]:(Ac.subVectors(r[0],r[1]).add(r[0]),c=Ac);const h=r[l%s],m=r[(l+1)%s];if(this.closed||l+2<s?f=r[(l+2)%s]:(Ac.subVectors(r[s-1],r[s-2]).add(r[s-1]),f=Ac),this.curveType==="centripetal"||this.curveType==="chordal"){const y=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(h),y),d=Math.pow(h.distanceToSquared(m),y),b=Math.pow(m.distanceToSquared(f),y);d<1e-4&&(d=1),p<1e-4&&(p=d),b<1e-4&&(b=d),Ph.initNonuniformCatmullRom(c.x,h.x,m.x,f.x,p,d,b),Ih.initNonuniformCatmullRom(c.y,h.y,m.y,f.y,p,d,b),Oh.initNonuniformCatmullRom(c.z,h.z,m.z,f.z,p,d,b)}else this.curveType==="catmullrom"&&(Ph.initCatmullRom(c.x,h.x,m.x,f.x,this.tension),Ih.initCatmullRom(c.y,h.y,m.y,f.y,this.tension),Oh.initCatmullRom(c.z,h.z,m.z,f.z,this.tension));return i.set(Ph.calc(u),Ih.calc(u),Oh.calc(u)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.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,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new X().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}Nh.prototype.isCatmullRomCurve3=!0;function $v(n,e,t,i,r){const s=(i-e)*.5,o=(r-t)*.5,l=n*n,u=n*l;return(2*t-2*i+s+o)*u+(-3*t+3*i-2*s-o)*l+s*n+t}function uN(n,e){const t=1-n;return t*t*e}function dN(n,e){return 2*(1-n)*n*e}function hN(n,e){return n*n*e}function Ea(n,e,t,i){return uN(n,e)+dN(n,t)+hN(n,i)}function fN(n,e){const t=1-n;return t*t*t*e}function pN(n,e){const t=1-n;return 3*t*t*n*e}function mN(n,e){return 3*(1-n)*n*n*e}function gN(n,e){return n*n*n*e}function Ca(n,e,t,i,r){return fN(n,e)+pN(n,t)+mN(n,i)+gN(n,r)}class Lc extends Mn{constructor(e=new Se,t=new Se,i=new Se,r=new Se){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Se){const i=t,r=this.v0,s=this.v1,o=this.v2,l=this.v3;return i.set(Ca(e,r.x,s.x,o.x,l.x),Ca(e,r.y,s.y,o.y,l.y)),i}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(){const 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}}Lc.prototype.isCubicBezierCurve=!0;class Dh extends Mn{constructor(e=new X,t=new X,i=new X,r=new X){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new X){const i=t,r=this.v0,s=this.v1,o=this.v2,l=this.v3;return i.set(Ca(e,r.x,s.x,o.x,l.x),Ca(e,r.y,s.y,o.y,l.y),Ca(e,r.z,s.z,o.z,l.z)),i}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(){const 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}}Dh.prototype.isCubicBezierCurve3=!0;class Aa extends Mn{constructor(e=new Se,t=new Se){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Se){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const i=t||new Se;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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}}Aa.prototype.isLineCurve=!0;class Zv extends Mn{constructor(e=new X,t=new X){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new X){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}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(){const 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}}class Rc extends Mn{constructor(e=new Se,t=new Se,i=new Se){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Se){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Ea(e,r.x,s.x,o.x),Ea(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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}}Rc.prototype.isQuadraticBezierCurve=!0;class Bh extends Mn{constructor(e=new X,t=new X,i=new X){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new X){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Ea(e,r.x,s.x,o.x),Ea(e,r.y,s.y,o.y),Ea(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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}}Bh.prototype.isQuadraticBezierCurve3=!0;class Pc extends Mn{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new Se){const i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),l=s-o,u=r[o===0?o:o-1],c=r[o],f=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set($v(l,u.x,c.x,f.x,h.x),$v(l,u.y,c.y,f.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new Se().fromArray(r))}return this}}Pc.prototype.isSplineCurve=!0;var Fh=Object.freeze({__proto__:null,ArcCurve:Lh,CatmullRomCurve3:Nh,CubicBezierCurve:Lc,CubicBezierCurve3:Dh,EllipseCurve:Ta,LineCurve:Aa,LineCurve3:Zv,QuadraticBezierCurve:Rc,QuadraticBezierCurve3:Bh,SplineCurve:Pc});const yN={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Xv(n,0,r,t,!0);const o=[];if(!s||s.next===s.prev)return o;let l,u,c,f,h,m,y;if(i&&(s=MN(n,e,s,t)),n.length>80*t){l=c=n[0],u=f=n[1];for(let p=t;p<r;p+=t)h=n[p],m=n[p+1],h<l&&(l=h),m<u&&(u=m),h>c&&(c=h),m>f&&(f=m);y=Math.max(c-l,f-u),y=y!==0?1/y:0}return La(s,o,t,l,u,y),o}};function Xv(n,e,t,i,r){let s,o;if(r===ON(n,e,t,i)>0)for(s=e;s<t;s+=i)o=qv(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=qv(s,n[s],n[s+1],o);return o&&Ic(o,o.next)&&(Pa(o),o=o.next),o}function vr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Ic(t,t.next)||vt(t.prev,t,t.next)===0)){if(Pa(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function La(n,e,t,i,r,s,o){if(!n)return;!o&&s&&CN(n,i,r,s);let l=n,u,c;for(;n.prev!==n.next;){if(u=n.prev,c=n.next,s?bN(n,i,r,s):vN(n)){e.push(u.i/t),e.push(n.i/t),e.push(c.i/t),Pa(n),n=c.next,l=c.next;continue}if(n=c,n===l){o?o===1?(n=xN(vr(n),e,t),La(n,e,t,i,r,s,2)):o===2&&wN(n,e,t,i,r,s):La(vr(n),e,t,i,r,s,1);break}}}function vN(n){const e=n.prev,t=n,i=n.next;if(vt(e,t,i)>=0)return!1;let r=n.next.next;for(;r!==n.prev;){if(uo(e.x,e.y,t.x,t.y,i.x,i.y,r.x,r.y)&&vt(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function bN(n,e,t,i){const r=n.prev,s=n,o=n.next;if(vt(r,s,o)>=0)return!1;const l=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,u=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,c=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,f=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,h=Vh(l,u,e,t,i),m=Vh(c,f,e,t,i);let y=n.prevZ,p=n.nextZ;for(;y&&y.z>=h&&p&&p.z<=m;){if(y!==n.prev&&y!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,y.x,y.y)&&vt(y.prev,y,y.next)>=0||(y=y.prevZ,p!==n.prev&&p!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&vt(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;y&&y.z>=h;){if(y!==n.prev&&y!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,y.x,y.y)&&vt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;p&&p.z<=m;){if(p!==n.prev&&p!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&vt(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function xN(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!Ic(r,s)&&Yv(r,i,i.next,s)&&Ra(r,s)&&Ra(s,r)&&(e.push(r.i/t),e.push(i.i/t),e.push(s.i/t),Pa(i),Pa(i.next),i=n=s),i=i.next}while(i!==n);return vr(i)}function wN(n,e,t,i,r,s){let o=n;do{let l=o.next.next;for(;l!==o.prev;){if(o.i!==l.i&&RN(o,l)){let u=Jv(o,l);o=vr(o,o.next),u=vr(u,u.next),La(o,e,t,i,r,s),La(u,e,t,i,r,s);return}l=l.next}o=o.next}while(o!==n)}function MN(n,e,t,i){const r=[];let s,o,l,u,c;for(s=0,o=e.length;s<o;s++)l=e[s]*i,u=s<o-1?e[s+1]*i:n.length,c=Xv(n,l,u,i,!1),c===c.next&&(c.steiner=!0),r.push(LN(c));for(r.sort(SN),s=0;s<r.length;s++)_N(r[s],t),t=vr(t,t.next);return t}function SN(n,e){return n.x-e.x}function _N(n,e){if(e=TN(n,e),e){const t=Jv(e,n);vr(e,e.next),vr(t,t.next)}}function TN(n,e){let t=e;const i=n.x,r=n.y;let s=-1/0,o;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const m=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=i&&m>s){if(s=m,m===i){if(r===t.y)return t;if(r===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(i===s)return o;const l=o,u=o.x,c=o.y;let f=1/0,h;t=o;do i>=t.x&&t.x>=u&&i!==t.x&&uo(r<c?i:s,r,u,c,r<c?s:i,r,t.x,t.y)&&(h=Math.abs(r-t.y)/(i-t.x),Ra(t,n)&&(h<f||h===f&&(t.x>o.x||t.x===o.x&&EN(o,t)))&&(o=t,f=h)),t=t.next;while(t!==l);return o}function EN(n,e){return vt(n.prev,n,e.prev)<0&&vt(e.next,n,n.next)<0}function CN(n,e,t,i){let r=n;do r.z===null&&(r.z=Vh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,AN(r)}function AN(n){let e,t,i,r,s,o,l,u,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,l=0,e=0;e<c&&(l++,i=i.nextZ,!!i);e++);for(u=c;l>0||u>0&&i;)l!==0&&(u===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,l--):(r=i,i=i.nextZ,u--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(o>1);return n}function Vh(n,e,t,i,r){return n=32767*(n-t)*r,e=32767*(e-i)*r,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function LN(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function uo(n,e,t,i,r,s,o,l){return(r-o)*(e-l)-(n-o)*(s-l)>=0&&(n-o)*(i-l)-(t-o)*(e-l)>=0&&(t-o)*(s-l)-(r-o)*(i-l)>=0}function RN(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!PN(n,e)&&(Ra(n,e)&&Ra(e,n)&&IN(n,e)&&(vt(n.prev,n,e.prev)||vt(n,e.prev,e))||Ic(n,e)&&vt(n.prev,n,n.next)>0&&vt(e.prev,e,e.next)>0)}function vt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Ic(n,e){return n.x===e.x&&n.y===e.y}function Yv(n,e,t,i){const r=Nc(vt(n,e,t)),s=Nc(vt(n,e,i)),o=Nc(vt(t,i,n)),l=Nc(vt(t,i,e));return!!(r!==s&&o!==l||r===0&&Oc(n,t,e)||s===0&&Oc(n,i,e)||o===0&&Oc(t,n,i)||l===0&&Oc(t,e,i))}function Oc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Nc(n){return n>0?1:n<0?-1:0}function PN(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Yv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Ra(n,e){return vt(n.prev,n,n.next)<0?vt(n,e,n.next)>=0&&vt(n,n.prev,e)>=0:vt(n,e,n.prev)<0||vt(n,n.next,e)<0}function IN(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Jv(n,e){const t=new kh(n.i,n.x,n.y),i=new kh(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function qv(n,e,t,i){const r=new kh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Pa(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function kh(n,e,t){this.i=n,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 ON(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}class si{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return si.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Kv(e),Qv(i,e);let o=e.length;t.forEach(Kv);for(let u=0;u<t.length;u++)r.push(o),o+=t[u].length,Qv(i,t[u]);const l=yN.triangulate(i,r);for(let u=0;u<l.length;u+=3)s.push(l.slice(u,u+3));return s}}function Kv(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Qv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class Hn extends Ve{constructor(e,t){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let l=0,u=e.length;l<u;l++){const c=e[l];o(c)}this.setAttribute("position",new Oe(r,3)),this.setAttribute("uv",new Oe(s,2)),this.computeVertexNormals();function o(l){const u=[],c=t.curveSegments!==void 0?t.curveSegments:12,f=t.steps!==void 0?t.steps:1;let h=t.depth!==void 0?t.depth:100,m=t.bevelEnabled!==void 0?t.bevelEnabled:!0,y=t.bevelThickness!==void 0?t.bevelThickness:6,p=t.bevelSize!==void 0?t.bevelSize:y-2,d=t.bevelOffset!==void 0?t.bevelOffset:0,b=t.bevelSegments!==void 0?t.bevelSegments:3;const v=t.extrudePath,g=t.UVGenerator!==void 0?t.UVGenerator:NN;t.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=t.amount);let M,_=!1,E,S,w,T;v&&(M=v.getSpacedPoints(f),_=!0,m=!1,E=v.computeFrenetFrames(f,!1),S=new X,w=new X,T=new X),m||(b=0,y=0,p=0,d=0);const C=l.extractPoints(c);let R=C.shape;const P=C.holes;if(!si.isClockWise(R)){R=R.reverse();for(let Y=0,te=P.length;Y<te;Y++){const F=P[Y];si.isClockWise(F)&&(P[Y]=F.reverse())}}const A=si.triangulateShape(R,P),I=R;for(let Y=0,te=P.length;Y<te;Y++){const F=P[Y];R=R.concat(F)}function O(Y,te,F){return te||console.error("THREE.ExtrudeGeometry: vec does not exist"),te.clone().multiplyScalar(F).add(Y)}const x=R.length,N=A.length;function B(Y,te,F){let $,J,k;const U=Y.x-te.x,oe=Y.y-te.y,le=F.x-Y.x,ae=F.y-Y.y,fe=U*U+oe*oe,ge=U*ae-oe*le;if(Math.abs(ge)>Number.EPSILON){const we=Math.sqrt(fe),ue=Math.sqrt(le*le+ae*ae),ye=te.x-oe/we,se=te.y+U/we,be=F.x-ae/ue,he=F.y+le/ue,me=((be-ye)*ae-(he-se)*le)/(U*ae-oe*le);$=ye+U*me-Y.x,J=se+oe*me-Y.y;const Te=$*$+J*J;if(Te<=2)return new Se($,J);k=Math.sqrt(Te/2)}else{let we=!1;U>Number.EPSILON?le>Number.EPSILON&&(we=!0):U<-Number.EPSILON?le<-Number.EPSILON&&(we=!0):Math.sign(oe)===Math.sign(ae)&&(we=!0),we?($=-oe,J=U,k=Math.sqrt(fe)):($=U,J=oe,k=Math.sqrt(fe/2))}return new Se($/k,J/k)}const D=[];for(let Y=0,te=I.length,F=te-1,$=Y+1;Y<te;Y++,F++,$++)F===te&&(F=0),$===te&&($=0),D[Y]=B(I[Y],I[F],I[$]);const V=[];let z,G=D.concat();for(let Y=0,te=P.length;Y<te;Y++){const F=P[Y];z=[];for(let $=0,J=F.length,k=J-1,U=$+1;$<J;$++,k++,U++)k===J&&(k=0),U===J&&(U=0),z[$]=B(F[$],F[k],F[U]);V.push(z),G=G.concat(z)}for(let Y=0;Y<b;Y++){const te=Y/b,F=y*Math.cos(te*Math.PI/2),$=p*Math.sin(te*Math.PI/2)+d;for(let J=0,k=I.length;J<k;J++){const U=O(I[J],D[J],$);W(U.x,U.y,-F)}for(let J=0,k=P.length;J<k;J++){const U=P[J];z=V[J];for(let oe=0,le=U.length;oe<le;oe++){const ae=O(U[oe],z[oe],$);W(ae.x,ae.y,-F)}}}const K=p+d;for(let Y=0;Y<x;Y++){const te=m?O(R[Y],G[Y],K):R[Y];_?(w.copy(E.normals[0]).multiplyScalar(te.x),S.copy(E.binormals[0]).multiplyScalar(te.y),T.copy(M[0]).add(w).add(S),W(T.x,T.y,T.z)):W(te.x,te.y,0)}for(let Y=1;Y<=f;Y++)for(let te=0;te<x;te++){const F=m?O(R[te],G[te],K):R[te];_?(w.copy(E.normals[Y]).multiplyScalar(F.x),S.copy(E.binormals[Y]).multiplyScalar(F.y),T.copy(M[Y]).add(w).add(S),W(T.x,T.y,T.z)):W(F.x,F.y,h/f*Y)}for(let Y=b-1;Y>=0;Y--){const te=Y/b,F=y*Math.cos(te*Math.PI/2),$=p*Math.sin(te*Math.PI/2)+d;for(let J=0,k=I.length;J<k;J++){const U=O(I[J],D[J],$);W(U.x,U.y,h+F)}for(let J=0,k=P.length;J<k;J++){const U=P[J];z=V[J];for(let oe=0,le=U.length;oe<le;oe++){const ae=O(U[oe],z[oe],$);_?W(ae.x,ae.y+M[f-1].y,M[f-1].x+F):W(ae.x,ae.y,h+F)}}}ie(),j();function ie(){const Y=r.length/3;if(m){let te=0,F=x*te;for(let $=0;$<N;$++){const J=A[$];q(J[2]+F,J[1]+F,J[0]+F)}te=f+b*2,F=x*te;for(let $=0;$<N;$++){const J=A[$];q(J[0]+F,J[1]+F,J[2]+F)}}else{for(let te=0;te<N;te++){const F=A[te];q(F[2],F[1],F[0])}for(let te=0;te<N;te++){const F=A[te];q(F[0]+x*f,F[1]+x*f,F[2]+x*f)}}i.addGroup(Y,r.length/3-Y,0)}function j(){const Y=r.length/3;let te=0;H(I,te),te+=I.length;for(let F=0,$=P.length;F<$;F++){const J=P[F];H(J,te),te+=J.length}i.addGroup(Y,r.length/3-Y,1)}function H(Y,te){let F=Y.length;for(;--F>=0;){const $=F;let J=F-1;J<0&&(J=Y.length-1);for(let k=0,U=f+b*2;k<U;k++){const oe=x*k,le=x*(k+1),ae=te+$+oe,fe=te+J+oe,ge=te+J+le,we=te+$+le;Q(ae,fe,ge,we)}}}function W(Y,te,F){u.push(Y),u.push(te),u.push(F)}function q(Y,te,F){ee(Y),ee(te),ee(F);const $=r.length/3,J=g.generateTopUV(i,r,$-3,$-2,$-1);ne(J[0]),ne(J[1]),ne(J[2])}function Q(Y,te,F,$){ee(Y),ee(te),ee($),ee(te),ee(F),ee($);const J=r.length/3,k=g.generateSideWallUV(i,r,J-6,J-3,J-2,J-1);ne(k[0]),ne(k[1]),ne(k[3]),ne(k[1]),ne(k[2]),ne(k[3])}function ee(Y){r.push(u[Y*3+0]),r.push(u[Y*3+1]),r.push(u[Y*3+2])}function ne(Y){s.push(Y.x),s.push(Y.y)}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return DN(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,o=e.shapes.length;s<o;s++){const l=t[e.shapes[s]];i.push(l)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Fh[r.type]().fromJSON(r)),new Hn(i,e.options)}}const NN={generateTopUV:function(n,e,t,i,r){const s=e[t*3],o=e[t*3+1],l=e[i*3],u=e[i*3+1],c=e[r*3],f=e[r*3+1];return[new Se(s,o),new Se(l,u),new Se(c,f)]},generateSideWallUV:function(n,e,t,i,r,s){const o=e[t*3],l=e[t*3+1],u=e[t*3+2],c=e[i*3],f=e[i*3+1],h=e[i*3+2],m=e[r*3],y=e[r*3+1],p=e[r*3+2],d=e[s*3],b=e[s*3+1],v=e[s*3+2];return Math.abs(l-f)<Math.abs(o-c)?[new Se(o,1-u),new Se(c,1-h),new Se(m,1-p),new Se(d,1-v)]:[new Se(l,1-u),new Se(f,1-h),new Se(y,1-p),new Se(b,1-v)]}};function DN(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class ho extends ri{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-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],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(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ho(e.radius,e.detail)}}class fo extends Ve{constructor(e,t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Jt(r,0,Math.PI*2);const s=[],o=[],l=[],u=1/t,c=new X,f=new Se;for(let h=0;h<=t;h++){const m=i+h*u*r,y=Math.sin(m),p=Math.cos(m);for(let d=0;d<=e.length-1;d++)c.x=e[d].x*y,c.y=e[d].y,c.z=e[d].x*p,o.push(c.x,c.y,c.z),f.x=h/t,f.y=d/(e.length-1),l.push(f.x,f.y)}for(let h=0;h<t;h++)for(let m=0;m<e.length-1;m++){const y=m+h*e.length,p=y,d=y+e.length,b=y+e.length+1,v=y+1;s.push(p,d,v),s.push(d,b,v)}if(this.setIndex(s),this.setAttribute("position",new Oe(o,3)),this.setAttribute("uv",new Oe(l,2)),this.computeVertexNormals(),r===Math.PI*2){const h=this.attributes.normal.array,m=new X,y=new X,p=new X,d=t*e.length*3;for(let b=0,v=0;b<e.length;b++,v+=3)m.x=h[v+0],m.y=h[v+1],m.z=h[v+2],y.x=h[d+v+0],y.y=h[d+v+1],y.z=h[d+v+2],p.addVectors(m,y).normalize(),h[v+0]=h[d+v+0]=p.x,h[v+1]=h[d+v+1]=p.y,h[v+2]=h[d+v+2]=p.z}}static fromJSON(e){return new fo(e.points,e.segments,e.phiStart,e.phiLength)}}class Yr extends ri{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Yr(e.radius,e.detail)}}class Dc extends Ve{constructor(e,t,i){super(),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i};const r=[],s=[],o=[],l=[],u=1e-5,c=new X,f=new X,h=new X,m=new X,y=new X;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=t+1;for(let d=0;d<=i;d++){const b=d/i;for(let v=0;v<=t;v++){const g=v/t;e(g,b,f),s.push(f.x,f.y,f.z),g-u>=0?(e(g-u,b,h),m.subVectors(f,h)):(e(g+u,b,h),m.subVectors(h,f)),b-u>=0?(e(g,b-u,h),y.subVectors(f,h)):(e(g,b+u,h),y.subVectors(h,f)),c.crossVectors(m,y).normalize(),o.push(c.x,c.y,c.z),l.push(g,b)}}for(let d=0;d<i;d++)for(let b=0;b<t;b++){const v=d*p+b,g=d*p+b+1,M=(d+1)*p+b+1,_=(d+1)*p+b;r.push(v,g,_),r.push(g,M,_)}this.setIndex(r),this.setAttribute("position",new Oe(s,3)),this.setAttribute("normal",new Oe(o,3)),this.setAttribute("uv",new Oe(l,2))}}class po extends Ve{constructor(e=.5,t=1,i=8,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);const l=[],u=[],c=[],f=[];let h=e;const m=(t-e)/r,y=new X,p=new Se;for(let d=0;d<=r;d++){for(let b=0;b<=i;b++){const v=s+b/i*o;y.x=h*Math.cos(v),y.y=h*Math.sin(v),u.push(y.x,y.y,y.z),c.push(0,0,1),p.x=(y.x/t+1)/2,p.y=(y.y/t+1)/2,f.push(p.x,p.y)}h+=m}for(let d=0;d<r;d++){const b=d*(i+1);for(let v=0;v<i;v++){const g=v+b,M=g,_=g+i+1,E=g+i+2,S=g+1;l.push(M,_,S),l.push(_,E,S)}}this.setIndex(l),this.setAttribute("position",new Oe(u,3)),this.setAttribute("normal",new Oe(c,3)),this.setAttribute("uv",new Oe(f,2))}static fromJSON(e){return new po(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Jr extends Ve{constructor(e,t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],o=[];let l=0,u=0;if(Array.isArray(e)===!1)c(e);else for(let f=0;f<e.length;f++)c(e[f]),this.addGroup(l,u,f),l+=u,u=0;this.setIndex(i),this.setAttribute("position",new Oe(r,3)),this.setAttribute("normal",new Oe(s,3)),this.setAttribute("uv",new Oe(o,2));function c(f){const h=r.length/3,m=f.extractPoints(t);let y=m.shape;const p=m.holes;si.isClockWise(y)===!1&&(y=y.reverse());for(let b=0,v=p.length;b<v;b++){const g=p[b];si.isClockWise(g)===!0&&(p[b]=g.reverse())}const d=si.triangulateShape(y,p);for(let b=0,v=p.length;b<v;b++){const g=p[b];y=y.concat(g)}for(let b=0,v=y.length;b<v;b++){const g=y[b];r.push(g.x,g.y,0),s.push(0,0,1),o.push(g.x,g.y)}for(let b=0,v=d.length;b<v;b++){const g=d[b],M=g[0]+h,_=g[1]+h,E=g[2]+h;i.push(M,_,E),u+=3}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return BN(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}return new Jr(i,e.curveSegments)}}function BN(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class qr extends Ve{constructor(e=1,t=8,i=6,r=0,s=Math.PI*2,o=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:l},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const u=Math.min(o+l,Math.PI);let c=0;const f=[],h=new X,m=new X,y=[],p=[],d=[],b=[];for(let v=0;v<=i;v++){const g=[],M=v/i;let _=0;v==0&&o==0?_=.5/t:v==i&&u==Math.PI&&(_=-.5/t);for(let E=0;E<=t;E++){const S=E/t;h.x=-e*Math.cos(r+S*s)*Math.sin(o+M*l),h.y=e*Math.cos(o+M*l),h.z=e*Math.sin(r+S*s)*Math.sin(o+M*l),p.push(h.x,h.y,h.z),m.copy(h).normalize(),d.push(m.x,m.y,m.z),b.push(S+_,1-M),g.push(c++)}f.push(g)}for(let v=0;v<i;v++)for(let g=0;g<t;g++){const M=f[v][g+1],_=f[v][g],E=f[v+1][g],S=f[v+1][g+1];(v!==0||o>0)&&y.push(M,_,S),(v!==i-1||u<Math.PI)&&y.push(_,E,S)}this.setIndex(y),this.setAttribute("position",new Oe(p,3)),this.setAttribute("normal",new Oe(d,3)),this.setAttribute("uv",new Oe(b,2))}static fromJSON(e){return new qr(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class mo extends ri{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new mo(e.radius,e.detail)}}class Bc extends Hn{constructor(e,t={}){const i=t.font;if(!(i&&i.isFont))return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Ve;const r=i.generateShapes(e,t.size);t.depth=t.height!==void 0?t.height:50,t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t),this.type="TextGeometry"}}class go extends Ve{constructor(e=1,t=.4,i=8,r=6,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],u=[],c=[],f=new X,h=new X,m=new X;for(let y=0;y<=i;y++)for(let p=0;p<=r;p++){const d=p/r*s,b=y/i*Math.PI*2;h.x=(e+t*Math.cos(b))*Math.cos(d),h.y=(e+t*Math.cos(b))*Math.sin(d),h.z=t*Math.sin(b),l.push(h.x,h.y,h.z),f.x=e*Math.cos(d),f.y=e*Math.sin(d),m.subVectors(h,f).normalize(),u.push(m.x,m.y,m.z),c.push(p/r),c.push(y/i)}for(let y=1;y<=i;y++)for(let p=1;p<=r;p++){const d=(r+1)*y+p-1,b=(r+1)*(y-1)+p-1,v=(r+1)*(y-1)+p,g=(r+1)*y+p;o.push(d,b,g),o.push(b,v,g)}this.setIndex(o),this.setAttribute("position",new Oe(l,3)),this.setAttribute("normal",new Oe(u,3)),this.setAttribute("uv",new Oe(c,2))}static fromJSON(e){return new go(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class yo extends Ve{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);const l=[],u=[],c=[],f=[],h=new X,m=new X,y=new X,p=new X,d=new X,b=new X,v=new X;for(let M=0;M<=i;++M){const _=M/i*s*Math.PI*2;g(_,s,o,e,y),g(_+.01,s,o,e,p),b.subVectors(p,y),v.addVectors(p,y),d.crossVectors(b,v),v.crossVectors(d,b),d.normalize(),v.normalize();for(let E=0;E<=r;++E){const S=E/r*Math.PI*2,w=-t*Math.cos(S),T=t*Math.sin(S);h.x=y.x+(w*v.x+T*d.x),h.y=y.y+(w*v.y+T*d.y),h.z=y.z+(w*v.z+T*d.z),u.push(h.x,h.y,h.z),m.subVectors(h,y).normalize(),c.push(m.x,m.y,m.z),f.push(M/i),f.push(E/r)}}for(let M=1;M<=i;M++)for(let _=1;_<=r;_++){const E=(r+1)*(M-1)+(_-1),S=(r+1)*M+(_-1),w=(r+1)*M+_,T=(r+1)*(M-1)+_;l.push(E,S,T),l.push(S,w,T)}this.setIndex(l),this.setAttribute("position",new Oe(u,3)),this.setAttribute("normal",new Oe(c,3)),this.setAttribute("uv",new Oe(f,2));function g(M,_,E,S,w){const T=Math.cos(M),C=Math.sin(M),R=E/_*M,P=Math.cos(R);w.x=S*(2+P)*.5*T,w.y=S*(2+P)*C*.5,w.z=S*Math.sin(R)*.5}}static fromJSON(e){return new yo(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class vo extends Ve{constructor(e,t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const l=new X,u=new X,c=new Se;let f=new X;const h=[],m=[],y=[],p=[];d(),this.setIndex(p),this.setAttribute("position",new Oe(h,3)),this.setAttribute("normal",new Oe(m,3)),this.setAttribute("uv",new Oe(y,2));function d(){for(let M=0;M<t;M++)b(M);b(s===!1?t:0),g(),v()}function b(M){f=e.getPointAt(M/t,f);const _=o.normals[M],E=o.binormals[M];for(let S=0;S<=r;S++){const w=S/r*Math.PI*2,T=Math.sin(w),C=-Math.cos(w);u.x=C*_.x+T*E.x,u.y=C*_.y+T*E.y,u.z=C*_.z+T*E.z,u.normalize(),m.push(u.x,u.y,u.z),l.x=f.x+i*u.x,l.y=f.y+i*u.y,l.z=f.z+i*u.z,h.push(l.x,l.y,l.z)}}function v(){for(let M=1;M<=t;M++)for(let _=1;_<=r;_++){const E=(r+1)*(M-1)+(_-1),S=(r+1)*M+(_-1),w=(r+1)*M+_,T=(r+1)*(M-1)+_;p.push(E,S,T),p.push(S,w,T)}}function g(){for(let M=0;M<=t;M++)for(let _=0;_<=r;_++)c.x=M/t,c.y=_/r,y.push(c.x,c.y)}}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new vo(new Fh[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class zh extends Ve{constructor(e){if(super(),this.type="WireframeGeometry",e.isGeometry===!0){console.error("THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return}const t=[],i=[0,0],r={},s=new X;if(e.index!==null){const o=e.attributes.position,l=e.index;let u=e.groups;u.length===0&&(u=[{start:0,count:l.count,materialIndex:0}]);for(let c=0,f=u.length;c<f;++c){const h=u[c],m=h.start,y=h.count;for(let p=m,d=m+y;p<d;p+=3)for(let b=0;b<3;b++){const v=l.getX(p+b),g=l.getX(p+(b+1)%3);i[0]=Math.min(v,g),i[1]=Math.max(v,g);const M=i[0]+","+i[1];r[M]===void 0&&(r[M]={index1:i[0],index2:i[1]})}}for(const c in r){const f=r[c];s.fromBufferAttribute(o,f.index1),t.push(s.x,s.y,s.z),s.fromBufferAttribute(o,f.index2),t.push(s.x,s.y,s.z)}}else{const o=e.attributes.position;for(let l=0,u=o.count/3;l<u;l++)for(let c=0;c<3;c++){const f=3*l+c;s.fromBufferAttribute(o,f),t.push(s.x,s.y,s.z);const h=3*l+(c+1)%3;s.fromBufferAttribute(o,h),t.push(s.x,s.y,s.z)}}this.setAttribute("position",new Oe(t,3))}}var eb=Object.freeze({__proto__:null,BoxGeometry:Ni,BoxBufferGeometry:Ni,CircleGeometry:ao,CircleBufferGeometry:ao,ConeGeometry:lo,ConeBufferGeometry:lo,CylinderGeometry:yr,CylinderBufferGeometry:yr,DodecahedronGeometry:co,DodecahedronBufferGeometry:co,EdgesGeometry:Ah,ExtrudeGeometry:Hn,ExtrudeBufferGeometry:Hn,IcosahedronGeometry:ho,IcosahedronBufferGeometry:ho,LatheGeometry:fo,LatheBufferGeometry:fo,OctahedronGeometry:Yr,OctahedronBufferGeometry:Yr,ParametricGeometry:Dc,ParametricBufferGeometry:Dc,PlaneGeometry:Zr,PlaneBufferGeometry:Zr,PolyhedronGeometry:ri,PolyhedronBufferGeometry:ri,RingGeometry:po,RingBufferGeometry:po,ShapeGeometry:Jr,ShapeBufferGeometry:Jr,SphereGeometry:qr,SphereBufferGeometry:qr,TetrahedronGeometry:mo,TetrahedronBufferGeometry:mo,TextGeometry:Bc,TextBufferGeometry:Bc,TorusGeometry:go,TorusBufferGeometry:go,TorusKnotGeometry:yo,TorusKnotBufferGeometry:yo,TubeGeometry:vo,TubeBufferGeometry:vo,WireframeGeometry:zh});class Uh extends Vt{constructor(e){super(),this.type="ShadowMaterial",this.color=new Ae(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}Uh.prototype.isShadowMaterial=!0;class bo extends Di{constructor(e){super(e),this.type="RawShaderMaterial"}}bo.prototype.isRawShaderMaterial=!0;class Kr extends Vt{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ae(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.vertexTangents=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this}}Kr.prototype.isMeshStandardMaterial=!0;class Ia extends Kr{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Se(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=Jt(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Ae(1,1,1),this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.reflectivity=e.reflectivity,e.sheen?this.sheen=(this.sheen||new Ae).copy(e.sheen):this.sheen=null,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this}}Ia.prototype.isMeshPhysicalMaterial=!0;class Gh extends Vt{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new Ae(16777215),this.specular=new Ae(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Yo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,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.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}Gh.prototype.isMeshPhongMaterial=!0;class Hh extends Vt{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ae(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this}}Hh.prototype.isMeshToonMaterial=!0;class Wh extends Vt{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}Wh.prototype.isMeshNormalMaterial=!0;class jh extends Vt{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Yo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,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.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this}}jh.prototype.isMeshLambertMaterial=!0;class $h extends Vt{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ae(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}$h.prototype.isMeshMatcapMaterial=!0;class Zh extends Ut{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}Zh.prototype.isLineDashedMaterial=!0;var FN=Object.freeze({__proto__:null,ShadowMaterial:Uh,SpriteMaterial:ga,RawShaderMaterial:bo,ShaderMaterial:Di,PointsMaterial:gr,MeshPhysicalMaterial:Ia,MeshStandardMaterial:Kr,MeshPhongMaterial:Gh,MeshToonMaterial:Hh,MeshNormalMaterial:Wh,MeshLambertMaterial:jh,MeshDepthMaterial:fc,MeshDistanceMaterial:pc,MeshBasicMaterial:mn,MeshMatcapMaterial:$h,LineDashedMaterial:Zh,LineBasicMaterial:Ut,Material:Vt});const ft={arraySlice:function(n,e,t){return ft.isTypedArray(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)},convertArray:function(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)},isTypedArray:function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},getKeyframeOrder:function(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i},sortedArray:function(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const l=t[s]*e;for(let u=0;u!==e;++u)r[o++]=n[l+u]}return r},flattenJSON:function(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)},subclip:function(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let u=0;u<s.tracks.length;++u){const c=s.tracks[u],f=c.getValueSize(),h=[],m=[];for(let y=0;y<c.times.length;++y){const p=c.times[y]*r;if(!(p<t||p>=i)){h.push(c.times[y]);for(let d=0;d<f;++d)m.push(c.values[y*f+d])}}h.length!==0&&(c.times=ft.convertArray(h,c.times.constructor),c.values=ft.convertArray(m,c.values.constructor),o.push(c))}s.tracks=o;let l=1/0;for(let u=0;u<s.tracks.length;++u)l>s.tracks[u].times[0]&&(l=s.tracks[u].times[0]);for(let u=0;u<s.tracks.length;++u)s.tracks[u].shift(-1*l);return s.resetDuration(),s},makeClipAdditive:function(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){const l=t.tracks[o],u=l.ValueTypeName;if(u==="bool"||u==="string")continue;const c=n.tracks.find(function(v){return v.name===l.name&&v.ValueTypeName===u});if(c===void 0)continue;let f=0;const h=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=h/3);let m=0;const y=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(m=y/3);const p=l.times.length-1;let d;if(s<=l.times[0]){const v=f,g=h-f;d=ft.arraySlice(l.values,v,g)}else if(s>=l.times[p]){const v=p*h+f,g=v+h-f;d=ft.arraySlice(l.values,v,g)}else{const v=l.createInterpolant(),g=f,M=h-f;v.evaluate(s),d=ft.arraySlice(v.resultBuffer,g,M)}u==="quaternion"&&new qt().fromArray(d).normalize().conjugate().toArray(d);const b=c.times.length;for(let v=0;v<b;++v){const g=v*y+m;if(u==="quaternion")qt.multiplyQuaternionsFlat(c.values,g,d,0,c.values,g);else{const M=y-m*2;for(let _=0;_<M;++_)c.values[g+_]-=d[_]}}}return n.blendMode=Bd,n}};class oi{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let l=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,s)}if(i===l)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){const l=t[1];e<l&&(i=2,s=l);for(let u=i-2;;){if(s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(i===u)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){const l=i+o>>>1;e<t[l]?o=l:i=l+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(r===void 0)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,s,e)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}oi.prototype.beforeStart_=oi.prototype.copySampleValue_,oi.prototype.afterEnd_=oi.prototype.copySampleValue_;class tb extends oi{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kr,endingEnd:kr}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,o=e+1,l=r[s],u=r[o];if(l===void 0)switch(this.getSettings_().endingStart){case zr:s=e,l=2*t-i;break;case ia:s=r.length-2,l=t+r[s]-r[s+1];break;default:s=e,l=i}if(u===void 0)switch(this.getSettings_().endingEnd){case zr:o=e,u=2*i-t;break;case ia:o=1,u=i+r[1]-r[0];break;default:o=e-1,u=t}const c=(i-t)*.5,f=this.valueSize;this._weightPrev=c/(t-l),this._weightNext=c/(u-i),this._offsetPrev=s*f,this._offsetNext=o*f}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=e*l,c=u-l,f=this._offsetPrev,h=this._offsetNext,m=this._weightPrev,y=this._weightNext,p=(i-t)/(r-t),d=p*p,b=d*p,v=-m*b+2*m*d-m*p,g=(1+m)*b+(-1.5-2*m)*d+(-.5+m)*p+1,M=(-1-y)*b+(1.5+y)*d+.5*p,_=y*b-y*d;for(let E=0;E!==l;++E)s[E]=v*o[f+E]+g*o[c+E]+M*o[u+E]+_*o[h+E];return s}}class Xh extends oi{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=e*l,c=u-l,f=(i-t)/(r-t),h=1-f;for(let m=0;m!==l;++m)s[m]=o[c+m]*h+o[u+m]*f;return s}}class nb extends oi{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Wn{constructor(e,t,i,r){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=ft.convertArray(t,this.TimeBufferType),this.values=ft.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:ft.convertArray(e.times,Array),values:ft.convertArray(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new nb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Xh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new tb(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bs:t=this.InterpolantFactoryMethodDiscrete;break;case Vr:t=this.InterpolantFactoryMethodLinear;break;case zl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="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(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bs;case this.InterpolantFactoryMethodLinear:return Vr;case this.InterpolantFactoryMethodSmooth:return zl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const l=this.getValueSize();this.times=ft.arraySlice(i,s,o),this.values=ft.arraySlice(this.values,s*l,o*l)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let l=0;l!==s;l++){const u=i[l];if(typeof u=="number"&&isNaN(u)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,l,u),e=!1;break}if(o!==null&&o>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,l,u,o),e=!1;break}o=u}if(r!==void 0&&ft.isTypedArray(r))for(let l=0,u=r.length;l!==u;++l){const c=r[l];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,l,c),e=!1;break}}return e}optimize(){const e=ft.arraySlice(this.times),t=ft.arraySlice(this.values),i=this.getValueSize(),r=this.getInterpolation()===zl,s=e.length-1;let o=1;for(let l=1;l<s;++l){let u=!1;const c=e[l],f=e[l+1];if(c!==f&&(l!==1||c!==e[0]))if(r)u=!0;else{const h=l*i,m=h-i,y=h+i;for(let p=0;p!==i;++p){const d=t[h+p];if(d!==t[m+p]||d!==t[y+p]){u=!0;break}}}if(u){if(l!==o){e[o]=e[l];const h=l*i,m=o*i;for(let y=0;y!==i;++y)t[m+y]=t[h+y]}++o}}if(s>0){e[o]=e[s];for(let l=s*i,u=o*i,c=0;c!==i;++c)t[u+c]=t[l+c];++o}return o!==e.length?(this.times=ft.arraySlice(e,0,o),this.values=ft.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this}clone(){const e=ft.arraySlice(this.times,0),t=ft.arraySlice(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Wn.prototype.TimeBufferType=Float32Array,Wn.prototype.ValueBufferType=Float32Array,Wn.prototype.DefaultInterpolation=Vr;class Qr extends Wn{}Qr.prototype.ValueTypeName="bool",Qr.prototype.ValueBufferType=Array,Qr.prototype.DefaultInterpolation=Bs,Qr.prototype.InterpolantFactoryMethodLinear=void 0,Qr.prototype.InterpolantFactoryMethodSmooth=void 0;class Yh extends Wn{}Yh.prototype.ValueTypeName="color";class xo extends Wn{}xo.prototype.ValueTypeName="number";class ib extends oi{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=(i-t)/(r-t);let c=e*l;for(let f=c+l;c!==f;c+=4)qt.slerpFlat(s,0,o,c-l,o,c,u);return s}}class es extends Wn{InterpolantFactoryMethodLinear(e){return new ib(this.times,this.values,this.getValueSize(),e)}}es.prototype.ValueTypeName="quaternion",es.prototype.DefaultInterpolation=Vr,es.prototype.InterpolantFactoryMethodSmooth=void 0;class ts extends Wn{}ts.prototype.ValueTypeName="string",ts.prototype.ValueBufferType=Array,ts.prototype.DefaultInterpolation=Bs,ts.prototype.InterpolantFactoryMethodLinear=void 0,ts.prototype.InterpolantFactoryMethodSmooth=void 0;class wo extends Wn{}wo.prototype.ValueTypeName="vector";class Mo{constructor(e,t=-1,i,r=Ul){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=bn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,l=i.length;o!==l;++o)t.push(kN(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(Wn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let l=0;l<s;l++){let u=[],c=[];u.push((l+s-1)%s,l,(l+1)%s),c.push(0,1,0);const f=ft.getKeyframeOrder(u);u=ft.sortedArray(u,1,f),c=ft.sortedArray(c,1,f),!r&&u[0]===0&&(u.push(s),c.push(c[0])),o.push(new xo(".morphTargetInfluences["+t[l].name+"]",u,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let l=0,u=e.length;l<u;l++){const c=e[l],f=c.name.match(s);if(f&&f.length>1){const h=f[1];let m=r[h];m||(r[h]=m=[]),m.push(c)}}const o=[];for(const l in r)o.push(this.CreateFromMorphTargetSequence(l,r[l],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(h,m,y,p,d){if(y.length!==0){const b=[],v=[];ft.flattenJSON(y,b,v,p),b.length!==0&&d.push(new h(m,b,v))}},r=[],s=e.name||"default",o=e.fps||30,l=e.blendMode;let u=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const m=c[h].keys;if(!(!m||m.length===0))if(m[0].morphTargets){const y={};let p;for(p=0;p<m.length;p++)if(m[p].morphTargets)for(let d=0;d<m[p].morphTargets.length;d++)y[m[p].morphTargets[d]]=-1;for(const d in y){const b=[],v=[];for(let g=0;g!==m[p].morphTargets.length;++g){const M=m[p];b.push(M.time),v.push(M.morphTarget===d?1:0)}r.push(new xo(".morphTargetInfluence["+d+"]",b,v))}u=y.length*(o||1)}else{const y=".bones["+t[h].name+"]";i(wo,y+".position",m,"pos",r),i(es,y+".quaternion",m,"rot",r),i(wo,y+".scale",m,"scl",r)}}return r.length===0?null:new this(s,u,r,l)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function VN(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return xo;case"vector":case"vector2":case"vector3":case"vector4":return wo;case"color":return Yh;case"quaternion":return es;case"bool":case"boolean":return Qr;case"string":return ts}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function kN(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=VN(n.type);if(n.times===void 0){const t=[],i=[];ft.flattenJSON(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const ns={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class Jh{constructor(e,t,i){const r=this;let s=!1,o=0,l=0,u;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(f){l++,s===!1&&r.onStart!==void 0&&r.onStart(f,o,l),s=!0},this.itemEnd=function(f){o++,r.onProgress!==void 0&&r.onProgress(f,o,l),o===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(f){r.onError!==void 0&&r.onError(f)},this.resolveURL=function(f){return u?u(f):f},this.setURLModifier=function(f){return u=f,this},this.addHandler=function(f,h){return c.push(f,h),this},this.removeHandler=function(f){const h=c.indexOf(f);return h!==-1&&c.splice(h,2),this},this.getHandler=function(f){for(let h=0,m=c.length;h<m;h+=2){const y=c[h],p=c[h+1];if(y.global&&(y.lastIndex=0),y.test(f))return p}return null}}}const rb=new Jh;class Kt{constructor(e){this.manager=e!==void 0?e:rb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,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}}const jn={};class Sn extends Kt{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ns.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;if(jn[e]!==void 0){jn[e].push({onLoad:t,onProgress:i,onError:r});return}const l=/^data:(.*?)(;base64)?,(.*)$/,u=e.match(l);let c;if(u){const f=u[1],h=!!u[2];let m=u[3];m=decodeURIComponent(m),h&&(m=atob(m));try{let y;const p=(this.responseType||"").toLowerCase();switch(p){case"arraybuffer":case"blob":const d=new Uint8Array(m.length);for(let v=0;v<m.length;v++)d[v]=m.charCodeAt(v);p==="blob"?y=new Blob([d.buffer],{type:f}):y=d.buffer;break;case"document":y=new DOMParser().parseFromString(m,f);break;case"json":y=JSON.parse(m);break;default:y=m;break}setTimeout(function(){t&&t(y),s.manager.itemEnd(e)},0)}catch(y){setTimeout(function(){r&&r(y),s.manager.itemError(e),s.manager.itemEnd(e)},0)}}else{jn[e]=[],jn[e].push({onLoad:t,onProgress:i,onError:r}),c=new XMLHttpRequest,c.open("GET",e,!0),c.addEventListener("load",function(f){const h=this.response,m=jn[e];if(delete jn[e],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),ns.add(e,h);for(let y=0,p=m.length;y<p;y++){const d=m[y];d.onLoad&&d.onLoad(h)}s.manager.itemEnd(e)}else{for(let y=0,p=m.length;y<p;y++){const d=m[y];d.onError&&d.onError(f)}s.manager.itemError(e),s.manager.itemEnd(e)}},!1),c.addEventListener("progress",function(f){const h=jn[e];for(let m=0,y=h.length;m<y;m++){const p=h[m];p.onProgress&&p.onProgress(f)}},!1),c.addEventListener("error",function(f){const h=jn[e];delete jn[e];for(let m=0,y=h.length;m<y;m++){const p=h[m];p.onError&&p.onError(f)}s.manager.itemError(e),s.manager.itemEnd(e)},!1),c.addEventListener("abort",function(f){const h=jn[e];delete jn[e];for(let m=0,y=h.length;m<y;m++){const p=h[m];p.onError&&p.onError(f)}s.manager.itemError(e),s.manager.itemEnd(e)},!1),this.responseType!==void 0&&(c.responseType=this.responseType),this.withCredentials!==void 0&&(c.withCredentials=this.withCredentials),c.overrideMimeType&&c.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(const f in this.requestHeader)c.setRequestHeader(f,this.requestHeader[f]);c.send(null)}return s.manager.itemStart(e),c}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class zN extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Sn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{t(s.parse(JSON.parse(l)))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=Mo.parse(e[i]);t.push(r)}return t}}class UN extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=[],l=new Eh,u=new Sn(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(s.withCredentials);let c=0;function f(h){u.load(e[h],function(m){const y=s.parse(m,!0);o[h]={width:y.width,height:y.height,format:y.format,mipmaps:y.mipmaps},c+=1,c===6&&(y.mipmapCount===1&&(l.minFilter=wt),l.image=o,l.format=y.format,l.needsUpdate=!0,t&&t(l))},i,r)}if(Array.isArray(e))for(let h=0,m=e.length;h<m;++h)f(h);else u.load(e,function(h){const m=s.parse(h,!0);if(m.isCubemap){const y=m.mipmaps.length/m.mipmapCount;for(let p=0;p<y;p++){o[p]={mipmaps:[]};for(let d=0;d<m.mipmapCount;d++)o[p].mipmaps.push(m.mipmaps[p*m.mipmapCount+d]),o[p].format=m.format,o[p].width=m.width,o[p].height=m.height}l.image=o}else l.image.width=m.width,l.image.height=m.height,l.mipmaps=m.mipmaps;m.mipmapCount===1&&(l.minFilter=wt),l.format=m.format,l.needsUpdate=!0,t&&t(l)},i,r);return l}}class Oa extends Kt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ns.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const l=document.createElementNS("http://www.w3.org/1999/xhtml","img");function u(){l.removeEventListener("load",u,!1),l.removeEventListener("error",c,!1),ns.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){l.removeEventListener("load",u,!1),l.removeEventListener("error",c,!1),r&&r(f),s.manager.itemError(e),s.manager.itemEnd(e)}return l.addEventListener("load",u,!1),l.addEventListener("error",c,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(l.crossOrigin=this.crossOrigin),s.manager.itemStart(e),l.src=e,l}}class sb extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=new Qs,o=new Oa(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let l=0;function u(c){o.load(e[c],function(f){s.images[c]=f,l++,l===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)u(c);return s}}class ob extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Xr,l=new Sn(this.manager);return l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setPath(this.path),l.setWithCredentials(s.withCredentials),l.load(e,function(u){const c=s.parse(u);c&&(c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:Wt,o.wrapT=c.wrapT!==void 0?c.wrapT:Wt,o.magFilter=c.magFilter!==void 0?c.magFilter:wt,o.minFilter=c.minFilter!==void 0?c.minFilter:wt,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.encoding!==void 0&&(o.encoding=c.encoding),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=Ti),c.mipmapCount===1&&(o.minFilter=wt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c))},i,r),o}}class qh extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=new Rt,o=new Oa(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(l){s.image=l;const u=e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0;s.format=u?Ci:vn,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class ab extends Mn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Aa(t,e))}getPoint(e){const t=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=t){const s=i[r]-t,o=this.curves[r],l=o.getLength(),u=l===0?0:1-s/l;return o.getPointAt(u)}r++}return null}getLength(){const 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;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const o=s[r],l=o&&o.isEllipseCurve?e*2:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,u=o.getPoints(l);for(let c=0;c<u.length;c++){const f=u[c];i&&i.equals(f)||(t.push(f),i=f)}}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,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new Fh[r.type]().fromJSON(r))}return this}}class Na extends ab{constructor(e){super(),this.type="Path",this.currentPoint=new Se,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new Aa(this.currentPoint.clone(),new Se(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new Rc(this.currentPoint.clone(),new Se(e,t),new Se(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){const l=new Lc(this.currentPoint.clone(),new Se(e,t),new Se(i,r),new Se(s,o));return this.curves.push(l),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Pc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+l,t+u,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,l,u){const c=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+c,t+f,i,r,s,o,l,u),this}absellipse(e,t,i,r,s,o,l,u){const c=new Ta(e,t,i,r,s,o,l,u);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const f=c.getPoint(1);return this.currentPoint.copy(f),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class br extends Na{constructor(e){super(e),this.uuid=bn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new Na().fromJSON(r))}return this}}class $n extends $e{constructor(e,t=1){super(),this.type="Light",this.color=new Ae(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const 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}}$n.prototype.isLight=!0;class Kh extends $n{constructor(e,t,i){super(e,i),this.type="HemisphereLight",this.position.copy($e.DefaultUp),this.updateMatrix(),this.groundColor=new Ae(t)}copy(e){return $n.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}Kh.prototype.isHemisphereLight=!0;const lb=new De,cb=new X,ub=new X;class Qh{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Se(512,512),this.map=null,this.mapPass=null,this.matrix=new De,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new da,this._frameExtents=new Se(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;cb.setFromMatrixPosition(e.matrixWorld),t.position.copy(cb),ub.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ub),t.updateMatrixWorld(),lb.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lb),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.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(){const 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}}class db extends Qh{constructor(){super(new zt(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,i=ra*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}db.prototype.isSpotLightShadow=!0;class Fc extends $n{constructor(e,t,i=0,r=Math.PI/3,s=0,o=1){super(e,t),this.type="SpotLight",this.position.copy($e.DefaultUp),this.updateMatrix(),this.target=new $e,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.shadow=new db}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),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}}Fc.prototype.isSpotLight=!0;const hb=new De,Da=new X,ef=new X;class fb extends Qh{constructor(){super(new zt(90,1,.5,500)),this._frameExtents=new Se(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new X(1,0,0),new X(-1,0,0),new X(0,0,1),new X(0,0,-1),new X(0,1,0),new X(0,-1,0)],this._cubeUps=[new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,0,1),new X(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Da.setFromMatrixPosition(e.matrixWorld),i.position.copy(Da),ef.copy(i.position),ef.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(ef),i.updateMatrixWorld(),r.makeTranslation(-Da.x,-Da.y,-Da.z),hb.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hb)}}fb.prototype.isPointLightShadow=!0;class Vc extends $n{constructor(e,t,i=0,r=1){super(e,t),this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new fb}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}Vc.prototype.isPointLight=!0;class So extends ua{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,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,i,r,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=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,l=r+t,u=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,l-=f*this.view.offsetY,u=l-f*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,u,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}So.prototype.isOrthographicCamera=!0;class pb extends Qh{constructor(){super(new So(-5,5,5,-5,.5,500))}}pb.prototype.isDirectionalLightShadow=!0;class kc extends $n{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy($e.DefaultUp),this.updateMatrix(),this.target=new $e,this.shadow=new pb}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}kc.prototype.isDirectionalLight=!0;class tf extends $n{constructor(e,t){super(e,t),this.type="AmbientLight"}}tf.prototype.isAmbientLight=!0;class nf extends $n{constructor(e,t,i=10,r=10){super(e,t),this.type="RectAreaLight",this.width=i,this.height=r}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}nf.prototype.isRectAreaLight=!0;class rf{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new X)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}rf.prototype.isSphericalHarmonics3=!0;class Ba extends $n{constructor(e=new rf,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}Ba.prototype.isLightProbe=!0;class mb extends Kt{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(JSON.parse(l)))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=new FN[e.type];if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=new Ae().setHex(e.sheen)),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==1&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.morphTargets!==void 0&&(r.morphTargets=e.morphTargets),e.morphNormals!==void 0&&(r.morphNormals=e.morphNormals),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.vertexTangents!==void 0&&(r.vertexTangents=e.vertexTangents),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ae().setHex(o.value);break;case"v2":r.uniforms[s].value=new Se().fromArray(o.value);break;case"v3":r.uniforms[s].value=new X().fromArray(o.value);break;case"v4":r.uniforms[s].value=new st().fromArray(o.value);break;case"m3":r.uniforms[s].value=new kt().fromArray(o.value);break;case"m4":r.uniforms[s].value=new De().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(r.flatShading=e.shading===1),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Se().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Se().fromArray(e.clearcoatNormalScale)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),r}setTextures(e){return this.textures=e,this}}class Fi{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}}class sf extends Ve{constructor(){super(),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(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}sf.prototype.isInstancedBufferGeometry=!0;class of extends Ge{constructor(e,t,i,r=1){typeof i=="number"&&(r=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,i),this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}of.prototype.isInstancedBufferAttribute=!0;class gb extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(JSON.parse(l)))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(y,p){if(t[p]!==void 0)return t[p];const b=y.interleavedBuffers[p],v=s(y,b.buffer),g=Zs(b.type,v),M=new mr(g,b.stride);return M.uuid=b.uuid,t[p]=M,M}function s(y,p){if(i[p]!==void 0)return i[p];const b=y.arrayBuffers[p],v=new Uint32Array(b).buffer;return i[p]=v,v}const o=e.isInstancedBufferGeometry?new sf:new Ve,l=e.data.index;if(l!==void 0){const y=Zs(l.type,l.array);o.setIndex(new Ge(y,1))}const u=e.data.attributes;for(const y in u){const p=u[y];let d;if(p.isInterleavedBufferAttribute){const b=r(e.data,p.data);d=new Bi(b,p.itemSize,p.offset,p.normalized)}else{const b=Zs(p.type,p.array),v=p.isInstancedBufferAttribute?of:Ge;d=new v(b,p.itemSize,p.normalized)}p.name!==void 0&&(d.name=p.name),p.usage!==void 0&&d.setUsage(p.usage),p.updateRange!==void 0&&(d.updateRange.offset=p.updateRange.offset,d.updateRange.count=p.updateRange.count),o.setAttribute(y,d)}const c=e.data.morphAttributes;if(c)for(const y in c){const p=c[y],d=[];for(let b=0,v=p.length;b<v;b++){const g=p[b];let M;if(g.isInterleavedBufferAttribute){const _=r(e.data,g.data);M=new Bi(_,g.itemSize,g.offset,g.normalized)}else{const _=Zs(g.type,g.array);M=new Ge(_,g.itemSize,g.normalized)}g.name!==void 0&&(M.name=g.name),d.push(M)}o.morphAttributes[y]=d}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let y=0,p=h.length;y!==p;++y){const d=h[y];o.addGroup(d.start,d.count,d.materialIndex)}const m=e.data.boundingSphere;if(m!==void 0){const y=new X;m.center!==void 0&&y.fromArray(m.center),o.boundingSphere=new Li(y,m.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class GN extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=this.path===""?Fi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const l=new Sn(this.manager);l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){let c=null;try{c=JSON.parse(u)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const f=c.metadata;if(f===void 0||f.type===void 0||f.type.toLowerCase()==="geometry"){console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Fi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Sn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(e,t),l=JSON.parse(o),u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(l)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),l=this.parseTextures(e.textures,o),u=this.parseMaterials(e.materials,l),c=this.parseObject(e.object,s,u,l,i),f=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,f),t!==void 0){let h=!1;for(const m in o)if(o[m]instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),l=this.parseMaterials(e.materials,o),u=this.parseObject(e.object,r,l,o,t),c=this.parseSkeletons(e.skeletons,u);return this.bindSkeletons(u,c),u}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new br().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){const l=new Sa().fromJSON(e[s],r);i[l.uuid]=l}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new gb;for(let s=0,o=e.length;s<o;s++){let l;const u=e[s];switch(u.type){case"BufferGeometry":case"InstancedBufferGeometry":l=r.parse(u);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:u.type in eb?l=eb[u.type].fromJSON(u,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${u.type}"`)}l.uuid=u.uuid,u.name!==void 0&&(l.name=u.name),l.isBufferGeometry===!0&&u.userData!==void 0&&(l.userData=u.userData),i[u.uuid]=l}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new mb;s.setTextures(t);for(let o=0,l=e.length;o<l;o++){const u=e[o];if(u.type==="MultiMaterial"){const c=[];for(let f=0;f<u.materials.length;f++){const h=u.materials[f];i[h.uuid]===void 0&&(i[h.uuid]=s.parse(h)),c.push(i[h.uuid])}r[u.uuid]=c}else i[u.uuid]===void 0&&(i[u.uuid]=s.parse(u)),r[u.uuid]=i[u.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=Mo.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function o(u){return i.manager.itemStart(u),s.load(u,function(){i.manager.itemEnd(u)},void 0,function(){i.manager.itemError(u),i.manager.itemEnd(u)})}function l(u){if(typeof u=="string"){const c=u,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(f)}else return u.data?{data:Zs(u.type,u.data),width:u.width,height:u.height}:null}if(e!==void 0&&e.length>0){const u=new Jh(t);s=new Oa(u),s.setCrossOrigin(this.crossOrigin);for(let c=0,f=e.length;c<f;c++){const h=e[c],m=h.url;if(Array.isArray(m)){r[h.uuid]=[];for(let y=0,p=m.length;y<p;y++){const d=m[y],b=l(d);b!==null&&(b instanceof HTMLImageElement?r[h.uuid].push(b):r[h.uuid].push(new Xr(b.data,b.width,b.height)))}}else{const y=l(h.url);y!==null&&(r[h.uuid]=y)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(o){if(typeof o=="string"){const l=o,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:t.resourcePath+l;return await r.loadAsync(u)}else return o.data?{data:Zs(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Oa(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,l=e.length;o<l;o++){const u=e[o],c=u.url;if(Array.isArray(c)){i[u.uuid]=[];for(let f=0,h=c.length;f<h;f++){const m=c[f],y=await s(m);y!==null&&(y instanceof HTMLImageElement?i[u.uuid].push(y):i[u.uuid].push(new Xr(y.data,y.width,y.height)))}}else{const f=await s(u.url);f!==null&&(i[u.uuid]=f)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){const l=e[s];l.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',l.uuid),t[l.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",l.image);let u;const c=t[l.image];Array.isArray(c)?(u=new Qs(c),c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Xr(c.data,c.width,c.height):u=new Rt(c),c&&(u.needsUpdate=!0)),u.uuid=l.uuid,l.name!==void 0&&(u.name=l.name),l.mapping!==void 0&&(u.mapping=i(l.mapping,HN)),l.offset!==void 0&&u.offset.fromArray(l.offset),l.repeat!==void 0&&u.repeat.fromArray(l.repeat),l.center!==void 0&&u.center.fromArray(l.center),l.rotation!==void 0&&(u.rotation=l.rotation),l.wrap!==void 0&&(u.wrapS=i(l.wrap[0],yb),u.wrapT=i(l.wrap[1],yb)),l.format!==void 0&&(u.format=l.format),l.type!==void 0&&(u.type=l.type),l.encoding!==void 0&&(u.encoding=l.encoding),l.minFilter!==void 0&&(u.minFilter=i(l.minFilter,vb)),l.magFilter!==void 0&&(u.magFilter=i(l.magFilter,vb)),l.anisotropy!==void 0&&(u.anisotropy=l.anisotropy),l.flipY!==void 0&&(u.flipY=l.flipY),l.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=l.premultiplyAlpha),l.unpackAlignment!==void 0&&(u.unpackAlignment=l.unpackAlignment),r[l.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function l(m){return t[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",m),t[m]}function u(m){if(m!==void 0){if(Array.isArray(m)){const y=[];for(let p=0,d=m.length;p<d;p++){const b=m[p];i[b]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",b),y.push(i[b])}return y}return i[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",m),i[m]}}function c(m){return r[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",m),r[m]}let f,h;switch(e.type){case"Scene":o=new mc,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ae(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new ma(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new pa(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new zt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new So(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new tf(e.color,e.intensity);break;case"DirectionalLight":o=new kc(e.color,e.intensity);break;case"PointLight":o=new Vc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new nf(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Fc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new Kh(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Ba().fromJSON(e);break;case"SkinnedMesh":f=l(e.geometry),h=u(e.material),o=new wa(f,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":f=l(e.geometry),h=u(e.material),o=new It(f,h);break;case"InstancedMesh":f=l(e.geometry),h=u(e.material);const m=e.count,y=e.instanceMatrix,p=e.instanceColor;o=new Sh(f,h,m),o.instanceMatrix=new Ge(new Float32Array(y.array),16),p!==void 0&&(o.instanceColor=new Ge(new Float32Array(p.array),p.itemSize));break;case"LOD":o=new Av;break;case"Line":o=new ii(l(e.geometry),u(e.material));break;case"LineLoop":o=new Mc(l(e.geometry),u(e.material));break;case"LineSegments":o=new un(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":o=new oo(l(e.geometry),u(e.material));break;case"Sprite":o=new xa(u(e.material));break;case"Group":o=new ni;break;case"Bone":o=new Ma;break;default:o=new $e}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const m=e.children;for(let y=0;y<m.length;y++)o.add(this.parseObject(m[y],t,i,r,s))}if(e.animations!==void 0){const m=e.animations;for(let y=0;y<m.length;y++){const p=m[y];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const m=e.levels;for(let y=0;y<m.length;y++){const p=m[y],d=o.getObjectByProperty("uuid",p.object);d!==void 0&&o.addLevel(d,p.distance)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}setTexturePath(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}const HN={UVMapping:Bl,CubeReflectionMapping:Jo,CubeRefractionMapping:qo,EquirectangularReflectionMapping:Fl,EquirectangularRefractionMapping:Vl,CubeUVReflectionMapping:Is,CubeUVRefractionMapping:Ko},yb={RepeatWrapping:ir,ClampToEdgeWrapping:Wt,MirroredRepeatWrapping:Os},vb={NearestFilter:Lt,NearestMipmapNearestFilter:Qo,NearestMipmapLinearFilter:ea,LinearFilter:wt,LinearMipmapNearestFilter:kl,LinearMipmapLinearFilter:Ti};class af extends Kt{constructor(e){super(e),typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ns.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const l={};l.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",l.headers=this.requestHeader,fetch(e,l).then(function(u){return u.blob()}).then(function(u){return createImageBitmap(u,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(u){ns.add(e,u),t&&t(u),s.manager.itemEnd(e)}).catch(function(u){r&&r(u),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}af.prototype.isImageBitmapLoader=!0;class bb{constructor(){this.type="ShapePath",this.color=new Ae,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Na,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function i(g){const M=[];for(let _=0,E=g.length;_<E;_++){const S=g[_],w=new br;w.curves=S.curves,M.push(w)}return M}function r(g,M){const _=M.length;let E=!1;for(let S=_-1,w=0;w<_;S=w++){let T=M[S],C=M[w],R=C.x-T.x,P=C.y-T.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(T=M[w],R=-R,C=M[S],P=-P),g.y<T.y||g.y>C.y)continue;if(g.y===T.y){if(g.x===T.x)return!0}else{const L=P*(g.x-T.x)-R*(g.y-T.y);if(L===0)return!0;if(L<0)continue;E=!E}}else{if(g.y!==T.y)continue;if(C.x<=g.x&&g.x<=T.x||T.x<=g.x&&g.x<=C.x)return!0}}return E}const s=si.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return i(o);let l,u,c;const f=[];if(o.length===1)return u=o[0],c=new br,c.curves=u.curves,f.push(c),f;let h=!s(o[0].getPoints());h=e?!h:h;const m=[],y=[];let p=[],d=0,b;y[d]=void 0,p[d]=[];for(let g=0,M=o.length;g<M;g++)u=o[g],b=u.getPoints(),l=s(b),l=e?!l:l,l?(!h&&y[d]&&d++,y[d]={s:new br,p:b},y[d].s.curves=u.curves,h&&d++,p[d]=[]):p[d].push({h:u,p:b[0]});if(!y[0])return i(o);if(y.length>1){let g=!1;const M=[];for(let _=0,E=y.length;_<E;_++)m[_]=[];for(let _=0,E=y.length;_<E;_++){const S=p[_];for(let w=0;w<S.length;w++){const T=S[w];let C=!0;for(let R=0;R<y.length;R++)r(T.p,y[R].p)&&(_!==R&&M.push({froms:_,tos:R,hole:w}),C?(C=!1,m[R].push(T)):g=!0);C&&m[_].push(T)}}M.length>0&&(g||(p=m))}let v;for(let g=0,M=y.length;g<M;g++){c=y[g].s,f.push(c),v=p[g];for(let _=0,E=v.length;_<E;_++)c.holes.push(v[_].h)}return f}}class lf{constructor(e){this.type="Font",this.data=e}generateShapes(e,t=100){const i=[],r=WN(e,t,this.data);for(let s=0,o=r.length;s<o;s++)Array.prototype.push.apply(i,r[s].toShapes());return i}}function WN(n,e,t){const i=Array.from(n),r=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*r,o=[];let l=0,u=0;for(let c=0;c<i.length;c++){const f=i[c];if(f===`
2915
+ }`;function wv(n,e,t){let i=new da;const r=new Se,s=new Se,o=new st,l=[],u=[],c={},f=t.maxTextureSize,h={0:At,1:er,2:tr},m=new Di({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new Se},radius:{value:4}},vertexShader:tN,fragmentShader:eN}),y=m.clone();y.defines.HORIZONTAL_PASS=1;const p=new Ve;p.setAttribute("position",new Ge(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const d=new It(p,m),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yd,this.render=function(S,w,T){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||S.length===0)return;const C=n.getRenderTarget(),R=n.getActiveCubeFace(),P=n.getActiveMipmapLevel(),L=n.state;L.setBlending(_i),L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);for(let A=0,I=S.length;A<I;A++){const O=S[A],x=O.shadow;if(x===void 0){console.warn("THREE.WebGLShadowMap:",O,"has no shadow.");continue}if(x.autoUpdate===!1&&x.needsUpdate===!1)continue;r.copy(x.mapSize);const N=x.getFrameExtents();if(r.multiply(N),s.copy(x.mapSize),(r.x>f||r.y>f)&&(r.x>f&&(s.x=Math.floor(f/N.x),r.x=s.x*N.x,x.mapSize.x=s.x),r.y>f&&(s.y=Math.floor(f/N.y),r.y=s.y*N.y,x.mapSize.y=s.y)),x.map===null&&!x.isPointLightShadow&&this.type===Rs){const D={minFilter:wt,magFilter:wt,format:vn};x.map=new Vn(r.x,r.y,D),x.map.texture.name=O.name+".shadowMap",x.mapPass=new Vn(r.x,r.y,D),x.camera.updateProjectionMatrix()}if(x.map===null){const D={minFilter:Lt,magFilter:Lt,format:vn};x.map=new Vn(r.x,r.y,D),x.map.texture.name=O.name+".shadowMap",x.camera.updateProjectionMatrix()}n.setRenderTarget(x.map),n.clear();const B=x.getViewportCount();for(let D=0;D<B;D++){const V=x.getViewport(D);o.set(s.x*V.x,s.y*V.y,s.x*V.z,s.y*V.w),L.viewport(o),x.updateMatrices(O,D),i=x.getFrustum(),E(w,T,x.camera,O,this.type)}!x.isPointLightShadow&&this.type===Rs&&v(x,T),x.needsUpdate=!1}b.needsUpdate=!1,n.setRenderTarget(C,R,P)};function v(S,w){const T=e.update(d);m.uniforms.shadow_pass.value=S.map.texture,m.uniforms.resolution.value=S.mapSize,m.uniforms.radius.value=S.radius,n.setRenderTarget(S.mapPass),n.clear(),n.renderBufferDirect(w,null,T,m,d,null),y.uniforms.shadow_pass.value=S.mapPass.texture,y.uniforms.resolution.value=S.mapSize,y.uniforms.radius.value=S.radius,n.setRenderTarget(S.map),n.clear(),n.renderBufferDirect(w,null,T,y,d,null)}function g(S){const w=S<<0;let T=l[w];return T===void 0&&(T=new fc({depthPacking:Ty,morphTargets:S}),l[w]=T),T}function M(S){const w=S<<0;let T=u[w];return T===void 0&&(T=new pc({morphTargets:S}),u[w]=T),T}function _(S,w,T,C,R,P,L){let A=null,I=g,O=S.customDepthMaterial;if(C.isPointLight===!0&&(I=M,O=S.customDistanceMaterial),O===void 0){let x=!1;T.morphTargets===!0&&(x=w.morphAttributes&&w.morphAttributes.position&&w.morphAttributes.position.length>0),A=I(x)}else A=O;if(n.localClippingEnabled&&T.clipShadows===!0&&T.clippingPlanes.length!==0){const x=A.uuid,N=T.uuid;let B=c[x];B===void 0&&(B={},c[x]=B);let D=B[N];D===void 0&&(D=A.clone(),B[N]=D),A=D}return A.visible=T.visible,A.wireframe=T.wireframe,L===Rs?A.side=T.shadowSide!==null?T.shadowSide:T.side:A.side=T.shadowSide!==null?T.shadowSide:h[T.side],A.clipShadows=T.clipShadows,A.clippingPlanes=T.clippingPlanes,A.clipIntersection=T.clipIntersection,A.wireframeLinewidth=T.wireframeLinewidth,A.linewidth=T.linewidth,C.isPointLight===!0&&A.isMeshDistanceMaterial===!0&&(A.referencePosition.setFromMatrixPosition(C.matrixWorld),A.nearDistance=R,A.farDistance=P),A}function E(S,w,T,C,R){if(S.visible===!1)return;if(S.layers.test(w.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Rs)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(T.matrixWorldInverse,S.matrixWorld);const A=e.update(S),I=S.material;if(Array.isArray(I)){const O=A.groups;for(let x=0,N=O.length;x<N;x++){const B=O[x],D=I[B.materialIndex];if(D&&D.visible){const V=_(S,A,D,C,T.near,T.far,R);n.renderBufferDirect(T,null,A,V,S,B)}}}else if(I.visible){const O=_(S,A,I,C,T.near,T.far,R);n.renderBufferDirect(T,null,A,O,S,null)}}const L=S.children;for(let A=0,I=L.length;A<I;A++)E(L[A],w,T,C,R)}}function nN(n,e,t){const i=t.isWebGL2;function r(){let se=!1;const be=new st;let he=null;const me=new st(0,0,0,0);return{setMask:function(Te){he!==Te&&!se&&(n.colorMask(Te,Te,Te,Te),he=Te)},setLocked:function(Te){se=Te},setClear:function(Te,He,tt,Re,ot){ot===!0&&(Te*=Re,He*=Re,tt*=Re),be.set(Te,He,tt,Re),me.equals(be)===!1&&(n.clearColor(Te,He,tt,Re),me.copy(be))},reset:function(){se=!1,he=null,me.set(-1,0,0,0)}}}function s(){let se=!1,be=null,he=null,me=null;return{setTest:function(Te){Te?ie(2929):j(2929)},setMask:function(Te){be!==Te&&!se&&(n.depthMask(Te),be=Te)},setFunc:function(Te){if(he!==Te){if(Te)switch(Te){case h0:n.depthFunc(512);break;case f0:n.depthFunc(519);break;case p0:n.depthFunc(513);break;case Dl:n.depthFunc(515);break;case m0:n.depthFunc(514);break;case g0:n.depthFunc(518);break;case y0:n.depthFunc(516);break;case v0:n.depthFunc(517);break;default:n.depthFunc(515)}else n.depthFunc(515);he=Te}},setLocked:function(Te){se=Te},setClear:function(Te){me!==Te&&(n.clearDepth(Te),me=Te)},reset:function(){se=!1,be=null,he=null,me=null}}}function o(){let se=!1,be=null,he=null,me=null,Te=null,He=null,tt=null,Re=null,ot=null;return{setTest:function(Pe){se||(Pe?ie(2960):j(2960))},setMask:function(Pe){be!==Pe&&!se&&(n.stencilMask(Pe),be=Pe)},setFunc:function(Pe,Je,We){(he!==Pe||me!==Je||Te!==We)&&(n.stencilFunc(Pe,Je,We),he=Pe,me=Je,Te=We)},setOp:function(Pe,Je,We){(He!==Pe||tt!==Je||Re!==We)&&(n.stencilOp(Pe,Je,We),He=Pe,tt=Je,Re=We)},setLocked:function(Pe){se=Pe},setClear:function(Pe){ot!==Pe&&(n.clearStencil(Pe),ot=Pe)},reset:function(){se=!1,be=null,he=null,me=null,Te=null,He=null,tt=null,Re=null,ot=null}}}const l=new r,u=new s,c=new o;let f={},h=null,m={},y=null,p=!1,d=null,b=null,v=null,g=null,M=null,_=null,E=null,S=!1,w=null,T=null,C=null,R=null,P=null;const L=n.getParameter(35661);let A=!1,I=0;const O=n.getParameter(7938);O.indexOf("WebGL")!==-1?(I=parseFloat(/^WebGL (\d)/.exec(O)[1]),A=I>=1):O.indexOf("OpenGL ES")!==-1&&(I=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),A=I>=2);let x=null,N={};const B=n.getParameter(3088),D=n.getParameter(2978),V=new st().fromArray(B),z=new st().fromArray(D);function G(se,be,he){const me=new Uint8Array(4),Te=n.createTexture();n.bindTexture(se,Te),n.texParameteri(se,10241,9728),n.texParameteri(se,10240,9728);for(let He=0;He<he;He++)n.texImage2D(be+He,0,6408,1,1,0,6408,5121,me);return Te}const K={};K[3553]=G(3553,3553,1),K[34067]=G(34067,34069,6),l.setClear(0,0,0,1),u.setClear(1),c.setClear(0),ie(2929),u.setFunc(Dl),te(!1),F(gd),ie(2884),ne(_i);function ie(se){f[se]!==!0&&(n.enable(se),f[se]=!0)}function j(se){f[se]!==!1&&(n.disable(se),f[se]=!1)}function H(se){se!==h&&(n.bindFramebuffer(36160,se),h=se)}function W(se,be){return be===null&&h!==null&&(be=h),m[se]!==be?(n.bindFramebuffer(se,be),m[se]=be,i&&(se===36009&&(m[36160]=be),se===36160&&(m[36009]=be)),!0):!1}function q(se){return y!==se?(n.useProgram(se),y=se,!0):!1}const Q={[Nr]:32774,[t0]:32778,[n0]:32779};if(i)Q[Md]=32775,Q[Sd]=32776;else{const se=e.get("EXT_blend_minmax");se!==null&&(Q[Md]=se.MIN_EXT,Q[Sd]=se.MAX_EXT)}const ee={[i0]:0,[r0]:1,[s0]:768,[_d]:770,[d0]:776,[c0]:774,[a0]:772,[o0]:769,[Td]:771,[u0]:775,[l0]:773};function ne(se,be,he,me,Te,He,tt,Re){if(se===_i){p===!0&&(j(3042),p=!1);return}if(p===!1&&(ie(3042),p=!0),se!==e0){if(se!==d||Re!==S){if((b!==Nr||M!==Nr)&&(n.blendEquation(32774),b=Nr,M=Nr),Re)switch(se){case Ps:n.blendFuncSeparate(1,771,1,771);break;case bd:n.blendFunc(1,1);break;case xd:n.blendFuncSeparate(0,0,769,771);break;case wd:n.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",se);break}else switch(se){case Ps:n.blendFuncSeparate(770,771,1,771);break;case bd:n.blendFunc(770,1);break;case xd:n.blendFunc(0,769);break;case wd:n.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",se);break}v=null,g=null,_=null,E=null,d=se,S=Re}return}Te=Te||be,He=He||he,tt=tt||me,(be!==b||Te!==M)&&(n.blendEquationSeparate(Q[be],Q[Te]),b=be,M=Te),(he!==v||me!==g||He!==_||tt!==E)&&(n.blendFuncSeparate(ee[he],ee[me],ee[He],ee[tt]),v=he,g=me,_=He,E=tt),d=se,S=null}function Y(se,be){se.side===tr?j(2884):ie(2884);let he=se.side===At;be&&(he=!he),te(he),se.blending===Ps&&se.transparent===!1?ne(_i):ne(se.blending,se.blendEquation,se.blendSrc,se.blendDst,se.blendEquationAlpha,se.blendSrcAlpha,se.blendDstAlpha,se.premultipliedAlpha),u.setFunc(se.depthFunc),u.setTest(se.depthTest),u.setMask(se.depthWrite),l.setMask(se.colorWrite);const me=se.stencilWrite;c.setTest(me),me&&(c.setMask(se.stencilWriteMask),c.setFunc(se.stencilFunc,se.stencilRef,se.stencilFuncMask),c.setOp(se.stencilFail,se.stencilZFail,se.stencilZPass)),J(se.polygonOffset,se.polygonOffsetFactor,se.polygonOffsetUnits),se.alphaToCoverage===!0?ie(32926):j(32926)}function te(se){w!==se&&(se?n.frontFace(2304):n.frontFace(2305),w=se)}function F(se){se!==qg?(ie(2884),se!==T&&(se===gd?n.cullFace(1029):se===Kg?n.cullFace(1028):n.cullFace(1032))):j(2884),T=se}function $(se){se!==C&&(A&&n.lineWidth(se),C=se)}function J(se,be,he){se?(ie(32823),(R!==be||P!==he)&&(n.polygonOffset(be,he),R=be,P=he)):j(32823)}function k(se){se?ie(3089):j(3089)}function U(se){se===void 0&&(se=33984+L-1),x!==se&&(n.activeTexture(se),x=se)}function oe(se,be){x===null&&U();let he=N[x];he===void 0&&(he={type:void 0,texture:void 0},N[x]=he),(he.type!==se||he.texture!==be)&&(n.bindTexture(se,be||K[se]),he.type=se,he.texture=be)}function le(){const se=N[x];se!==void 0&&se.type!==void 0&&(n.bindTexture(se.type,null),se.type=void 0,se.texture=void 0)}function ae(){try{n.compressedTexImage2D.apply(n,arguments)}catch(se){console.error("THREE.WebGLState:",se)}}function fe(){try{n.texImage2D.apply(n,arguments)}catch(se){console.error("THREE.WebGLState:",se)}}function ge(){try{n.texImage3D.apply(n,arguments)}catch(se){console.error("THREE.WebGLState:",se)}}function we(se){V.equals(se)===!1&&(n.scissor(se.x,se.y,se.z,se.w),V.copy(se))}function ue(se){z.equals(se)===!1&&(n.viewport(se.x,se.y,se.z,se.w),z.copy(se))}function ye(){n.disable(3042),n.disable(2884),n.disable(2929),n.disable(32823),n.disable(3089),n.disable(2960),n.disable(32926),n.blendEquation(32774),n.blendFunc(1,0),n.blendFuncSeparate(1,0,1,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(513),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(519,0,4294967295),n.stencilOp(7680,7680,7680),n.clearStencil(0),n.cullFace(1029),n.frontFace(2305),n.polygonOffset(0,0),n.activeTexture(33984),n.bindFramebuffer(36160,null),i===!0&&(n.bindFramebuffer(36009,null),n.bindFramebuffer(36008,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),f={},x=null,N={},h=null,m={},y=null,p=!1,d=null,b=null,v=null,g=null,M=null,_=null,E=null,S=!1,w=null,T=null,C=null,R=null,P=null,V.set(0,0,n.canvas.width,n.canvas.height),z.set(0,0,n.canvas.width,n.canvas.height),l.reset(),u.reset(),c.reset()}return{buffers:{color:l,depth:u,stencil:c},enable:ie,disable:j,bindFramebuffer:W,bindXRFramebuffer:H,useProgram:q,setBlending:ne,setMaterial:Y,setFlipSided:te,setCullFace:F,setLineWidth:$,setPolygonOffset:J,setScissorTest:k,activeTexture:U,bindTexture:oe,unbindTexture:le,compressedTexImage2D:ae,texImage2D:fe,texImage3D:ge,scissor:we,viewport:ue,reset:ye}}function iN(n,e,t,i,r,s,o){const l=r.isWebGL2,u=r.maxTextures,c=r.maxCubemapSize,f=r.maxTextureSize,h=r.maxSamples,m=new WeakMap;let y,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function d(k,U){return p?new OffscreenCanvas(k,U):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function b(k,U,oe,le){let ae=1;if((k.width>le||k.height>le)&&(ae=le/Math.max(k.width,k.height)),ae<1||U===!0)if(typeof HTMLImageElement<"u"&&k instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&k instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&k instanceof ImageBitmap){const fe=U?Ly:Math.floor,ge=fe(ae*k.width),we=fe(ae*k.height);y===void 0&&(y=d(ge,we));const ue=oe?d(ge,we):y;return ue.width=ge,ue.height=we,ue.getContext("2d").drawImage(k,0,0,ge,we),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+k.width+"x"+k.height+") to ("+ge+"x"+we+")."),ue}else return"data"in k&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+k.width+"x"+k.height+")."),k;return k}function v(k){return Hd(k.width)&&Hd(k.height)}function g(k){return l?!1:k.wrapS!==Wt||k.wrapT!==Wt||k.minFilter!==Lt&&k.minFilter!==wt}function M(k,U){return k.generateMipmaps&&U&&k.minFilter!==Lt&&k.minFilter!==wt}function _(k,U,oe,le,ae=1){n.generateMipmap(k);const fe=i.get(U);fe.__maxMipLevel=Math.log2(Math.max(oe,le,ae))}function E(k,U,oe){if(l===!1)return U;if(k!==null){if(n[k]!==void 0)return n[k];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+k+"'")}let le=U;return U===6403&&(oe===5126&&(le=33326),oe===5131&&(le=33325),oe===5121&&(le=33321)),U===6407&&(oe===5126&&(le=34837),oe===5131&&(le=34843),oe===5121&&(le=32849)),U===6408&&(oe===5126&&(le=34836),oe===5131&&(le=34842),oe===5121&&(le=32856)),(le===33325||le===33326||le===34842||le===34836)&&e.get("EXT_color_buffer_float"),le}function S(k){return k===Lt||k===Qo||k===ea?9728:9729}function w(k){const U=k.target;U.removeEventListener("dispose",w),C(U),U.isVideoTexture&&m.delete(U),o.memory.textures--}function T(k){const U=k.target;U.removeEventListener("dispose",T),R(U)}function C(k){const U=i.get(k);U.__webglInit!==void 0&&(n.deleteTexture(U.__webglTexture),i.remove(k))}function R(k){const U=k.texture,oe=i.get(k),le=i.get(U);if(k){if(le.__webglTexture!==void 0&&(n.deleteTexture(le.__webglTexture),o.memory.textures--),k.depthTexture&&k.depthTexture.dispose(),k.isWebGLCubeRenderTarget)for(let ae=0;ae<6;ae++)n.deleteFramebuffer(oe.__webglFramebuffer[ae]),oe.__webglDepthbuffer&&n.deleteRenderbuffer(oe.__webglDepthbuffer[ae]);else n.deleteFramebuffer(oe.__webglFramebuffer),oe.__webglDepthbuffer&&n.deleteRenderbuffer(oe.__webglDepthbuffer),oe.__webglMultisampledFramebuffer&&n.deleteFramebuffer(oe.__webglMultisampledFramebuffer),oe.__webglColorRenderbuffer&&n.deleteRenderbuffer(oe.__webglColorRenderbuffer),oe.__webglDepthRenderbuffer&&n.deleteRenderbuffer(oe.__webglDepthRenderbuffer);if(k.isWebGLMultipleRenderTargets)for(let ae=0,fe=U.length;ae<fe;ae++){const ge=i.get(U[ae]);ge.__webglTexture&&(n.deleteTexture(ge.__webglTexture),o.memory.textures--),i.remove(U[ae])}i.remove(U),i.remove(k)}}let P=0;function L(){P=0}function A(){const k=P;return k>=u&&console.warn("THREE.WebGLTextures: Trying to use "+k+" texture units while this GPU supports only "+u),P+=1,k}function I(k,U){const oe=i.get(k);if(k.isVideoTexture&&Y(k),k.version>0&&oe.__version!==k.version){const le=k.image;if(le===void 0)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{G(oe,k,U);return}}t.activeTexture(33984+U),t.bindTexture(3553,oe.__webglTexture)}function O(k,U){const oe=i.get(k);if(k.version>0&&oe.__version!==k.version){G(oe,k,U);return}t.activeTexture(33984+U),t.bindTexture(35866,oe.__webglTexture)}function x(k,U){const oe=i.get(k);if(k.version>0&&oe.__version!==k.version){G(oe,k,U);return}t.activeTexture(33984+U),t.bindTexture(32879,oe.__webglTexture)}function N(k,U){const oe=i.get(k);if(k.version>0&&oe.__version!==k.version){K(oe,k,U);return}t.activeTexture(33984+U),t.bindTexture(34067,oe.__webglTexture)}const B={[ir]:10497,[Wt]:33071,[Os]:33648},D={[Lt]:9728,[Qo]:9984,[ea]:9986,[wt]:9729,[kl]:9985,[Ti]:9987};function V(k,U,oe){if(oe?(n.texParameteri(k,10242,B[U.wrapS]),n.texParameteri(k,10243,B[U.wrapT]),(k===32879||k===35866)&&n.texParameteri(k,32882,B[U.wrapR]),n.texParameteri(k,10240,D[U.magFilter]),n.texParameteri(k,10241,D[U.minFilter])):(n.texParameteri(k,10242,33071),n.texParameteri(k,10243,33071),(k===32879||k===35866)&&n.texParameteri(k,32882,33071),(U.wrapS!==Wt||U.wrapT!==Wt)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(k,10240,S(U.magFilter)),n.texParameteri(k,10241,S(U.minFilter)),U.minFilter!==Lt&&U.minFilter!==wt&&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){const le=e.get("EXT_texture_filter_anisotropic");if(U.type===Ei&&e.has("OES_texture_float_linear")===!1||l===!1&&U.type===Br&&e.has("OES_texture_half_float_linear")===!1)return;(U.anisotropy>1||i.get(U).__currentAnisotropy)&&(n.texParameterf(k,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(U.anisotropy,r.getMaxAnisotropy())),i.get(U).__currentAnisotropy=U.anisotropy)}}function z(k,U){k.__webglInit===void 0&&(k.__webglInit=!0,U.addEventListener("dispose",w),k.__webglTexture=n.createTexture(),o.memory.textures++)}function G(k,U,oe){let le=3553;U.isDataTexture2DArray&&(le=35866),U.isDataTexture3D&&(le=32879),z(k,U),t.activeTexture(33984+oe),t.bindTexture(le,k.__webglTexture),n.pixelStorei(37440,U.flipY),n.pixelStorei(37441,U.premultiplyAlpha),n.pixelStorei(3317,U.unpackAlignment),n.pixelStorei(37443,0);const ae=g(U)&&v(U.image)===!1,fe=b(U.image,ae,!1,f),ge=v(fe)||l,we=s.convert(U.format);let ue=s.convert(U.type),ye=E(U.internalFormat,we,ue);V(le,U,ge);let se;const be=U.mipmaps;if(U.isDepthTexture)ye=6402,l?U.type===Ei?ye=36012:U.type===na?ye=33190:U.type===Ns?ye=35056:ye=33189:U.type===Ei&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),U.format===Fr&&ye===6402&&U.type!==ta&&U.type!==na&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),U.type=ta,ue=s.convert(U.type)),U.format===Ds&&ye===6402&&(ye=34041,U.type!==Ns&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),U.type=Ns,ue=s.convert(U.type))),t.texImage2D(3553,0,ye,fe.width,fe.height,0,we,ue,null);else if(U.isDataTexture)if(be.length>0&&ge){for(let he=0,me=be.length;he<me;he++)se=be[he],t.texImage2D(3553,he,ye,se.width,se.height,0,we,ue,se.data);U.generateMipmaps=!1,k.__maxMipLevel=be.length-1}else t.texImage2D(3553,0,ye,fe.width,fe.height,0,we,ue,fe.data),k.__maxMipLevel=0;else if(U.isCompressedTexture){for(let he=0,me=be.length;he<me;he++)se=be[he],U.format!==vn&&U.format!==Ci?we!==null?t.compressedTexImage2D(3553,he,ye,se.width,se.height,0,se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):t.texImage2D(3553,he,ye,se.width,se.height,0,we,ue,se.data);k.__maxMipLevel=be.length-1}else if(U.isDataTexture2DArray)t.texImage3D(35866,0,ye,fe.width,fe.height,fe.depth,0,we,ue,fe.data),k.__maxMipLevel=0;else if(U.isDataTexture3D)t.texImage3D(32879,0,ye,fe.width,fe.height,fe.depth,0,we,ue,fe.data),k.__maxMipLevel=0;else if(be.length>0&&ge){for(let he=0,me=be.length;he<me;he++)se=be[he],t.texImage2D(3553,he,ye,we,ue,se);U.generateMipmaps=!1,k.__maxMipLevel=be.length-1}else t.texImage2D(3553,0,ye,we,ue,fe),k.__maxMipLevel=0;M(U,ge)&&_(le,U,fe.width,fe.height),k.__version=U.version,U.onUpdate&&U.onUpdate(U)}function K(k,U,oe){if(U.image.length!==6)return;z(k,U),t.activeTexture(33984+oe),t.bindTexture(34067,k.__webglTexture),n.pixelStorei(37440,U.flipY),n.pixelStorei(37441,U.premultiplyAlpha),n.pixelStorei(3317,U.unpackAlignment),n.pixelStorei(37443,0);const le=U&&(U.isCompressedTexture||U.image[0].isCompressedTexture),ae=U.image[0]&&U.image[0].isDataTexture,fe=[];for(let he=0;he<6;he++)!le&&!ae?fe[he]=b(U.image[he],!1,!0,c):fe[he]=ae?U.image[he].image:U.image[he];const ge=fe[0],we=v(ge)||l,ue=s.convert(U.format),ye=s.convert(U.type),se=E(U.internalFormat,ue,ye);V(34067,U,we);let be;if(le){for(let he=0;he<6;he++){be=fe[he].mipmaps;for(let me=0;me<be.length;me++){const Te=be[me];U.format!==vn&&U.format!==Ci?ue!==null?t.compressedTexImage2D(34069+he,me,se,Te.width,Te.height,0,Te.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):t.texImage2D(34069+he,me,se,Te.width,Te.height,0,ue,ye,Te.data)}}k.__maxMipLevel=be.length-1}else{be=U.mipmaps;for(let he=0;he<6;he++)if(ae){t.texImage2D(34069+he,0,se,fe[he].width,fe[he].height,0,ue,ye,fe[he].data);for(let me=0;me<be.length;me++){const He=be[me].image[he].image;t.texImage2D(34069+he,me+1,se,He.width,He.height,0,ue,ye,He.data)}}else{t.texImage2D(34069+he,0,se,ue,ye,fe[he]);for(let me=0;me<be.length;me++){const Te=be[me];t.texImage2D(34069+he,me+1,se,ue,ye,Te.image[he])}}k.__maxMipLevel=be.length}M(U,we)&&_(34067,U,ge.width,ge.height),k.__version=U.version,U.onUpdate&&U.onUpdate(U)}function ie(k,U,oe,le,ae){const fe=s.convert(oe.format),ge=s.convert(oe.type),we=E(oe.internalFormat,fe,ge);ae===32879||ae===35866?t.texImage3D(ae,0,we,U.width,U.height,U.depth,0,fe,ge,null):t.texImage2D(ae,0,we,U.width,U.height,0,fe,ge,null),t.bindFramebuffer(36160,k),n.framebufferTexture2D(36160,le,ae,i.get(oe).__webglTexture,0),t.bindFramebuffer(36160,null)}function j(k,U,oe){if(n.bindRenderbuffer(36161,k),U.depthBuffer&&!U.stencilBuffer){let le=33189;if(oe){const ae=U.depthTexture;ae&&ae.isDepthTexture&&(ae.type===Ei?le=36012:ae.type===na&&(le=33190));const fe=ne(U);n.renderbufferStorageMultisample(36161,fe,le,U.width,U.height)}else n.renderbufferStorage(36161,le,U.width,U.height);n.framebufferRenderbuffer(36160,36096,36161,k)}else if(U.depthBuffer&&U.stencilBuffer){if(oe){const le=ne(U);n.renderbufferStorageMultisample(36161,le,35056,U.width,U.height)}else n.renderbufferStorage(36161,34041,U.width,U.height);n.framebufferRenderbuffer(36160,33306,36161,k)}else{const le=U.isWebGLMultipleRenderTargets===!0?U.texture[0]:U.texture,ae=s.convert(le.format),fe=s.convert(le.type),ge=E(le.internalFormat,ae,fe);if(oe){const we=ne(U);n.renderbufferStorageMultisample(36161,we,ge,U.width,U.height)}else n.renderbufferStorage(36161,ge,U.width,U.height)}n.bindRenderbuffer(36161,null)}function H(k,U){if(U&&U.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(36160,k),!(U.depthTexture&&U.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(U.depthTexture).__webglTexture||U.depthTexture.image.width!==U.width||U.depthTexture.image.height!==U.height)&&(U.depthTexture.image.width=U.width,U.depthTexture.image.height=U.height,U.depthTexture.needsUpdate=!0),I(U.depthTexture,0);const le=i.get(U.depthTexture).__webglTexture;if(U.depthTexture.format===Fr)n.framebufferTexture2D(36160,36096,3553,le,0);else if(U.depthTexture.format===Ds)n.framebufferTexture2D(36160,33306,3553,le,0);else throw new Error("Unknown depthTexture format")}function W(k){const U=i.get(k),oe=k.isWebGLCubeRenderTarget===!0;if(k.depthTexture){if(oe)throw new Error("target.depthTexture not supported in Cube render targets");H(U.__webglFramebuffer,k)}else if(oe){U.__webglDepthbuffer=[];for(let le=0;le<6;le++)t.bindFramebuffer(36160,U.__webglFramebuffer[le]),U.__webglDepthbuffer[le]=n.createRenderbuffer(),j(U.__webglDepthbuffer[le],k,!1)}else t.bindFramebuffer(36160,U.__webglFramebuffer),U.__webglDepthbuffer=n.createRenderbuffer(),j(U.__webglDepthbuffer,k,!1);t.bindFramebuffer(36160,null)}function q(k){const U=k.texture,oe=i.get(k),le=i.get(U);k.addEventListener("dispose",T),k.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture=n.createTexture(),le.__version=U.version,o.memory.textures++);const ae=k.isWebGLCubeRenderTarget===!0,fe=k.isWebGLMultipleRenderTargets===!0,ge=k.isWebGLMultisampleRenderTarget===!0,we=U.isDataTexture3D||U.isDataTexture2DArray,ue=v(k)||l;if(l&&U.format===Ci&&(U.type===Ei||U.type===Br)&&(U.format=vn,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),ae){oe.__webglFramebuffer=[];for(let ye=0;ye<6;ye++)oe.__webglFramebuffer[ye]=n.createFramebuffer()}else if(oe.__webglFramebuffer=n.createFramebuffer(),fe)if(r.drawBuffers){const ye=k.texture;for(let se=0,be=ye.length;se<be;se++){const he=i.get(ye[se]);he.__webglTexture===void 0&&(he.__webglTexture=n.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");else if(ge)if(l){oe.__webglMultisampledFramebuffer=n.createFramebuffer(),oe.__webglColorRenderbuffer=n.createRenderbuffer(),n.bindRenderbuffer(36161,oe.__webglColorRenderbuffer);const ye=s.convert(U.format),se=s.convert(U.type),be=E(U.internalFormat,ye,se),he=ne(k);n.renderbufferStorageMultisample(36161,he,be,k.width,k.height),t.bindFramebuffer(36160,oe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(36160,36064,36161,oe.__webglColorRenderbuffer),n.bindRenderbuffer(36161,null),k.depthBuffer&&(oe.__webglDepthRenderbuffer=n.createRenderbuffer(),j(oe.__webglDepthRenderbuffer,k,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(ae){t.bindTexture(34067,le.__webglTexture),V(34067,U,ue);for(let ye=0;ye<6;ye++)ie(oe.__webglFramebuffer[ye],k,U,36064,34069+ye);M(U,ue)&&_(34067,U,k.width,k.height),t.bindTexture(34067,null)}else if(fe){const ye=k.texture;for(let se=0,be=ye.length;se<be;se++){const he=ye[se],me=i.get(he);t.bindTexture(3553,me.__webglTexture),V(3553,he,ue),ie(oe.__webglFramebuffer,k,he,36064+se,3553),M(he,ue)&&_(3553,he,k.width,k.height)}t.bindTexture(3553,null)}else{let ye=3553;we&&(l?ye=U.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),t.bindTexture(ye,le.__webglTexture),V(ye,U,ue),ie(oe.__webglFramebuffer,k,U,36064,ye),M(U,ue)&&_(ye,U,k.width,k.height,k.depth),t.bindTexture(ye,null)}k.depthBuffer&&W(k)}function Q(k){const U=v(k)||l,oe=k.isWebGLMultipleRenderTargets===!0?k.texture:[k.texture];for(let le=0,ae=oe.length;le<ae;le++){const fe=oe[le];if(M(fe,U)){const ge=k.isWebGLCubeRenderTarget?34067:3553,we=i.get(fe).__webglTexture;t.bindTexture(ge,we),_(ge,fe,k.width,k.height),t.bindTexture(ge,null)}}}function ee(k){if(k.isWebGLMultisampleRenderTarget)if(l){const U=k.width,oe=k.height;let le=16384;k.depthBuffer&&(le|=256),k.stencilBuffer&&(le|=1024);const ae=i.get(k);t.bindFramebuffer(36008,ae.__webglMultisampledFramebuffer),t.bindFramebuffer(36009,ae.__webglFramebuffer),n.blitFramebuffer(0,0,U,oe,0,0,U,oe,le,9728),t.bindFramebuffer(36008,null),t.bindFramebuffer(36009,ae.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}function ne(k){return l&&k.isWebGLMultisampleRenderTarget?Math.min(h,k.samples):0}function Y(k){const U=o.render.frame;m.get(k)!==U&&(m.set(k,U),k.update())}let te=!1,F=!1;function $(k,U){k&&k.isWebGLRenderTarget&&(te===!1&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),te=!0),k=k.texture),I(k,U)}function J(k,U){k&&k.isWebGLCubeRenderTarget&&(F===!1&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),F=!0),k=k.texture),N(k,U)}this.allocateTextureUnit=A,this.resetTextureUnits=L,this.setTexture2D=I,this.setTexture2DArray=O,this.setTexture3D=x,this.setTextureCube=N,this.setupRenderTarget=q,this.updateRenderTargetMipmap=Q,this.updateMultisampleRenderTarget=ee,this.safeSetTexture2D=$,this.safeSetTextureCube=J}function Mv(n,e,t){const i=t.isWebGL2;function r(s){let o;if(s===Dr)return 5121;if(s===L0)return 32819;if(s===R0)return 32820;if(s===P0)return 33635;if(s===E0)return 5120;if(s===C0)return 5122;if(s===ta)return 5123;if(s===A0)return 5124;if(s===na)return 5125;if(s===Ei)return 5126;if(s===Br)return i?5131:(o=e.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(s===I0)return 6406;if(s===Ci)return 6407;if(s===vn)return 6408;if(s===O0)return 6409;if(s===N0)return 6410;if(s===Fr)return 6402;if(s===Ds)return 34041;if(s===B0)return 6403;if(s===F0)return 36244;if(s===V0)return 33319;if(s===k0)return 33320;if(s===z0)return 36248;if(s===U0)return 36249;if(s===Ed||s===Cd||s===Ad||s===Ld)if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(s===Ed)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===Cd)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Ad)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Ld)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Rd||s===Pd||s===Id||s===Od)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(s===Rd)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===Pd)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Id)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Od)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===G0)return o=e.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if((s===Nd||s===Dd)&&(o=e.get("WEBGL_compressed_texture_etc"),o!==null)){if(s===Nd)return o.COMPRESSED_RGB8_ETC2;if(s===Dd)return o.COMPRESSED_RGBA8_ETC2_EAC}if(s===H0||s===W0||s===j0||s===$0||s===Z0||s===X0||s===Y0||s===J0||s===q0||s===K0||s===Q0||s===ey||s===ty||s===ny||s===ry||s===sy||s===oy||s===ay||s===ly||s===cy||s===uy||s===dy||s===hy||s===fy||s===py||s===my||s===gy||s===yy)return o=e.get("WEBGL_compressed_texture_astc"),o!==null?s:null;if(s===iy)return o=e.get("EXT_texture_compression_bptc"),o!==null?s:null;if(s===Ns)return i?34042:(o=e.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null)}return{convert:r}}class xh extends zt{constructor(e=[]){super(),this.cameras=e}}xh.prototype.isArrayCamera=!0;class ni extends $e{constructor(){super(),this.type="Group"}}ni.prototype.isGroup=!0;const rN={type:"move"};class wh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ni,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 ni,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new X,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new X),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ni,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new X,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new X),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,i){let r=null,s=null,o=null;const l=this._targetRay,u=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred")if(l!==null&&(r=t.getPose(e.targetRaySpace,i),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(rN))),c&&e.hand){o=!0;for(const d of e.hand.values()){const b=t.getJointPose(d,i);if(c.joints[d.jointName]===void 0){const g=new ni;g.matrixAutoUpdate=!1,g.visible=!1,c.joints[d.jointName]=g,c.add(g)}const v=c.joints[d.jointName];b!==null&&(v.matrix.fromArray(b.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.jointRadius=b.radius),v.visible=b!==null}const f=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],m=f.position.distanceTo(h.position),y=.02,p=.005;c.inputState.pinching&&m>y+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&m<=y-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(u.matrix.fromArray(s.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),s.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(s.linearVelocity)):u.hasLinearVelocity=!1,s.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(s.angularVelocity)):u.hasAngularVelocity=!1));return l!==null&&(l.visible=r!==null),u!==null&&(u.visible=s!==null),c!==null&&(c.visible=o!==null),this}}class sN extends sr{constructor(e,t){super();const i=this,r=e.state;let s=null,o=1,l=null,u="local-floor",c=null,f=null,h=null,m=null;const y=[],p=new Map,d=new zt;d.layers.enable(1),d.viewport=new st;const b=new zt;b.layers.enable(2),b.viewport=new st;const v=[d,b],g=new xh;g.layers.enable(1),g.layers.enable(2);let M=null,_=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(O){let x=y[O];return x===void 0&&(x=new wh,y[O]=x),x.getTargetRaySpace()},this.getControllerGrip=function(O){let x=y[O];return x===void 0&&(x=new wh,y[O]=x),x.getGripSpace()},this.getHand=function(O){let x=y[O];return x===void 0&&(x=new wh,y[O]=x),x.getHandSpace()};function E(O){const x=p.get(O.inputSource);x&&x.dispatchEvent({type:O.type,data:O.inputSource})}function S(){p.forEach(function(O,x){O.disconnect(x)}),p.clear(),M=null,_=null,r.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),I.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(O){o=O,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(O){u=O,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l},this.getSession=function(){return s},this.setSession=async function(O){if(s=O,s!==null){s.addEventListener("select",E),s.addEventListener("selectstart",E),s.addEventListener("selectend",E),s.addEventListener("squeeze",E),s.addEventListener("squeezestart",E),s.addEventListener("squeezeend",E),s.addEventListener("end",S),s.addEventListener("inputsourceschange",w);const x=t.getContextAttributes();if(x.xrCompatible!==!0&&await t.makeXRCompatible(),s.renderState.layers===void 0){const N={antialias:x.antialias,alpha:x.alpha,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:o},B=new XRWebGLLayer(s,t,N);s.updateRenderState({baseLayer:B})}else{let N=0;x.depth&&(N=x.stencil?34041:6402);const B={colorFormat:x.alpha?6408:6407,depthFormat:N,scaleFactor:o};f=new XRWebGLBinding(s,t),m=f.createProjectionLayer(B),h=t.createFramebuffer(),s.updateRenderState({layers:[m]})}l=await s.requestReferenceSpace(u),I.setContext(s),I.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}};function w(O){const x=s.inputSources;for(let N=0;N<y.length;N++)p.set(x[N],y[N]);for(let N=0;N<O.removed.length;N++){const B=O.removed[N],D=p.get(B);D&&(D.dispatchEvent({type:"disconnected",data:B}),p.delete(B))}for(let N=0;N<O.added.length;N++){const B=O.added[N],D=p.get(B);D&&D.dispatchEvent({type:"connected",data:B})}}const T=new X,C=new X;function R(O,x,N){T.setFromMatrixPosition(x.matrixWorld),C.setFromMatrixPosition(N.matrixWorld);const B=T.distanceTo(C),D=x.projectionMatrix.elements,V=N.projectionMatrix.elements,z=D[14]/(D[10]-1),G=D[14]/(D[10]+1),K=(D[9]+1)/D[5],ie=(D[9]-1)/D[5],j=(D[8]-1)/D[0],H=(V[8]+1)/V[0],W=z*j,q=z*H,Q=B/(-j+H),ee=Q*-j;x.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(ee),O.translateZ(Q),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.copy(O.matrixWorld).invert();const ne=z+Q,Y=G+Q,te=W-ee,F=q+(B-ee),$=K*G/Y*ne,J=ie*G/Y*ne;O.projectionMatrix.makePerspective(te,F,$,J,ne,Y)}function P(O,x){x===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices(x.matrixWorld,O.matrix),O.matrixWorldInverse.copy(O.matrixWorld).invert()}this.updateCamera=function(O){if(s===null)return;g.near=b.near=d.near=O.near,g.far=b.far=d.far=O.far,(M!==g.near||_!==g.far)&&(s.updateRenderState({depthNear:g.near,depthFar:g.far}),M=g.near,_=g.far);const x=O.parent,N=g.cameras;P(g,x);for(let D=0;D<N.length;D++)P(N[D],x);g.matrixWorld.decompose(g.position,g.quaternion,g.scale),O.position.copy(g.position),O.quaternion.copy(g.quaternion),O.scale.copy(g.scale),O.matrix.copy(g.matrix),O.matrixWorld.copy(g.matrixWorld);const B=O.children;for(let D=0,V=B.length;D<V;D++)B[D].updateMatrixWorld(!0);N.length===2?R(g,d,b):g.projectionMatrix.copy(d.projectionMatrix)},this.getCamera=function(){return g};let L=null;function A(O,x){if(c=x.getViewerPose(l),c!==null){const B=c.views,D=s.renderState.baseLayer;s.renderState.layers===void 0&&r.bindXRFramebuffer(D.framebuffer);let V=!1;B.length!==g.cameras.length&&(g.cameras.length=0,V=!0);for(let z=0;z<B.length;z++){const G=B[z];let K=null;if(s.renderState.layers===void 0)K=D.getViewport(G);else{const j=f.getViewSubImage(m,G);r.bindXRFramebuffer(h),t.framebufferTexture2D(36160,36064,3553,j.colorTexture,0),j.depthStencilTexture!==void 0&&t.framebufferTexture2D(36160,36096,3553,j.depthStencilTexture,0),K=j.viewport}const ie=v[z];ie.matrix.fromArray(G.transform.matrix),ie.projectionMatrix.fromArray(G.projectionMatrix),ie.viewport.set(K.x,K.y,K.width,K.height),z===0&&g.matrix.copy(ie.matrix),V===!0&&g.cameras.push(ie)}}const N=s.inputSources;for(let B=0;B<y.length;B++){const D=y[B],V=N[B];D.update(V,x,l)}L&&L(O,x)}const I=new Ky;I.setAnimationLoop(A),this.setAnimationLoop=function(O){L=O},this.dispose=function(){}}}function oN(n){function e(v,g){v.fogColor.value.copy(g.color),g.isFog?(v.fogNear.value=g.near,v.fogFar.value=g.far):g.isFogExp2&&(v.fogDensity.value=g.density)}function t(v,g,M,_,E){g.isMeshBasicMaterial?i(v,g):g.isMeshLambertMaterial?(i(v,g),u(v,g)):g.isMeshToonMaterial?(i(v,g),f(v,g)):g.isMeshPhongMaterial?(i(v,g),c(v,g)):g.isMeshStandardMaterial?(i(v,g),g.isMeshPhysicalMaterial?m(v,g,E):h(v,g)):g.isMeshMatcapMaterial?(i(v,g),y(v,g)):g.isMeshDepthMaterial?(i(v,g),p(v,g)):g.isMeshDistanceMaterial?(i(v,g),d(v,g)):g.isMeshNormalMaterial?(i(v,g),b(v,g)):g.isLineBasicMaterial?(r(v,g),g.isLineDashedMaterial&&s(v,g)):g.isPointsMaterial?o(v,g,M,_):g.isSpriteMaterial?l(v,g):g.isShadowMaterial?(v.color.value.copy(g.color),v.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function i(v,g){v.opacity.value=g.opacity,g.color&&v.diffuse.value.copy(g.color),g.emissive&&v.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(v.map.value=g.map),g.alphaMap&&(v.alphaMap.value=g.alphaMap),g.specularMap&&(v.specularMap.value=g.specularMap);const M=n.get(g).envMap;if(M){v.envMap.value=M,v.flipEnvMap.value=M.isCubeTexture&&M._needsFlipEnvMap?-1:1,v.reflectivity.value=g.reflectivity,v.refractionRatio.value=g.refractionRatio;const S=n.get(M).__maxMipLevel;S!==void 0&&(v.maxMipLevel.value=S)}g.lightMap&&(v.lightMap.value=g.lightMap,v.lightMapIntensity.value=g.lightMapIntensity),g.aoMap&&(v.aoMap.value=g.aoMap,v.aoMapIntensity.value=g.aoMapIntensity);let _;g.map?_=g.map:g.specularMap?_=g.specularMap:g.displacementMap?_=g.displacementMap:g.normalMap?_=g.normalMap:g.bumpMap?_=g.bumpMap:g.roughnessMap?_=g.roughnessMap:g.metalnessMap?_=g.metalnessMap:g.alphaMap?_=g.alphaMap:g.emissiveMap?_=g.emissiveMap:g.clearcoatMap?_=g.clearcoatMap:g.clearcoatNormalMap?_=g.clearcoatNormalMap:g.clearcoatRoughnessMap&&(_=g.clearcoatRoughnessMap),_!==void 0&&(_.isWebGLRenderTarget&&(_=_.texture),_.matrixAutoUpdate===!0&&_.updateMatrix(),v.uvTransform.value.copy(_.matrix));let E;g.aoMap?E=g.aoMap:g.lightMap&&(E=g.lightMap),E!==void 0&&(E.isWebGLRenderTarget&&(E=E.texture),E.matrixAutoUpdate===!0&&E.updateMatrix(),v.uv2Transform.value.copy(E.matrix))}function r(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity}function s(v,g){v.dashSize.value=g.dashSize,v.totalSize.value=g.dashSize+g.gapSize,v.scale.value=g.scale}function o(v,g,M,_){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.size.value=g.size*M,v.scale.value=_*.5,g.map&&(v.map.value=g.map),g.alphaMap&&(v.alphaMap.value=g.alphaMap);let E;g.map?E=g.map:g.alphaMap&&(E=g.alphaMap),E!==void 0&&(E.matrixAutoUpdate===!0&&E.updateMatrix(),v.uvTransform.value.copy(E.matrix))}function l(v,g){v.diffuse.value.copy(g.color),v.opacity.value=g.opacity,v.rotation.value=g.rotation,g.map&&(v.map.value=g.map),g.alphaMap&&(v.alphaMap.value=g.alphaMap);let M;g.map?M=g.map:g.alphaMap&&(M=g.alphaMap),M!==void 0&&(M.matrixAutoUpdate===!0&&M.updateMatrix(),v.uvTransform.value.copy(M.matrix))}function u(v,g){g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap)}function c(v,g){v.specular.value.copy(g.specular),v.shininess.value=Math.max(g.shininess,1e-4),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function f(v,g){g.gradientMap&&(v.gradientMap.value=g.gradientMap),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function h(v,g){v.roughness.value=g.roughness,v.metalness.value=g.metalness,g.roughnessMap&&(v.roughnessMap.value=g.roughnessMap),g.metalnessMap&&(v.metalnessMap.value=g.metalnessMap),g.emissiveMap&&(v.emissiveMap.value=g.emissiveMap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias),n.get(g).envMap&&(v.envMapIntensity.value=g.envMapIntensity)}function m(v,g,M){h(v,g),v.reflectivity.value=g.reflectivity,v.clearcoat.value=g.clearcoat,v.clearcoatRoughness.value=g.clearcoatRoughness,g.sheen&&v.sheen.value.copy(g.sheen),g.clearcoatMap&&(v.clearcoatMap.value=g.clearcoatMap),g.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap),g.clearcoatNormalMap&&(v.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),v.clearcoatNormalMap.value=g.clearcoatNormalMap,g.side===At&&v.clearcoatNormalScale.value.negate()),v.transmission.value=g.transmission,g.transmissionMap&&(v.transmissionMap.value=g.transmissionMap),g.transmission>0&&(v.transmissionSamplerMap.value=M.texture,v.transmissionSamplerSize.value.set(M.width,M.height)),v.thickness.value=g.thickness,g.thicknessMap&&(v.thicknessMap.value=g.thicknessMap),v.attenuationDistance.value=g.attenuationDistance,v.attenuationColor.value.copy(g.attenuationColor)}function y(v,g){g.matcap&&(v.matcap.value=g.matcap),g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function p(v,g){g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}function d(v,g){g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias),v.referencePosition.value.copy(g.referencePosition),v.nearDistance.value=g.nearDistance,v.farDistance.value=g.farDistance}function b(v,g){g.bumpMap&&(v.bumpMap.value=g.bumpMap,v.bumpScale.value=g.bumpScale,g.side===At&&(v.bumpScale.value*=-1)),g.normalMap&&(v.normalMap.value=g.normalMap,v.normalScale.value.copy(g.normalScale),g.side===At&&v.normalScale.value.negate()),g.displacementMap&&(v.displacementMap.value=g.displacementMap,v.displacementScale.value=g.displacementScale,v.displacementBias.value=g.displacementBias)}return{refreshFogUniforms:e,refreshMaterialUniforms:t}}function aN(){const n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return n.style.display="block",n}function lt(n={}){const e=n.canvas!==void 0?n.canvas:aN(),t=n.context!==void 0?n.context:null,i=n.alpha!==void 0?n.alpha:!1,r=n.depth!==void 0?n.depth:!0,s=n.stencil!==void 0?n.stencil:!0,o=n.antialias!==void 0?n.antialias:!1,l=n.premultipliedAlpha!==void 0?n.premultipliedAlpha:!0,u=n.preserveDrawingBuffer!==void 0?n.preserveDrawingBuffer:!1,c=n.powerPreference!==void 0?n.powerPreference:"default",f=n.failIfMajorPerformanceCaveat!==void 0?n.failIfMajorPerformanceCaveat:!1;let h=null,m=null;const y=[],p=[];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.gammaFactor=2,this.outputEncoding=ln,this.physicallyCorrectLights=!1,this.toneMapping=nr,this.toneMappingExposure=1;const d=this;let b=!1,v=0,g=0,M=null,_=-1,E=null;const S=new st,w=new st;let T=null,C=e.width,R=e.height,P=1,L=null,A=null;const I=new st(0,0,C,R),O=new st(0,0,C,R);let x=!1;const N=[],B=new da;let D=!1,V=!1,z=null;const G=new De,K=new X,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return M===null?P:1}let H=t;function W(Z,pe){for(let de=0;de<Z.length;de++){const ve=Z[de],Ee=e.getContext(ve,pe);if(Ee!==null)return Ee}return null}try{const Z={alpha:i,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:u,powerPreference:c,failIfMajorPerformanceCaveat:f};if(e.addEventListener("webglcontextlost",He,!1),e.addEventListener("webglcontextrestored",tt,!1),H===null){const pe=["webgl2","webgl","experimental-webgl"];if(d.isWebGL1Renderer===!0&&pe.shift(),H=W(pe,Z),H===null)throw W(pe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}H.getShaderPrecisionFormat===void 0&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Z){throw console.error("THREE.WebGLRenderer: "+Z.message),Z}let q,Q,ee,ne,Y,te,F,$,J,k,U,oe,le,ae,fe,ge,we,ue,ye,se,be,he;function me(){q=new PO(H),Q=new AO(H,q,n),q.init(Q),be=new Mv(H,q,Q),ee=new nN(H,q,Q),N[0]=1029,ne=new NO,Y=new j3,te=new iN(H,q,ee,Y,Q,be,ne),F=new RO(d),$=new iP(H,Q),he=new EO(H,q,$,Q),J=new IO(H,$,ne,he),k=new VO(H,J,$,ne),ue=new FO(H),fe=new LO(Y),U=new W3(d,F,q,Q,he,fe),oe=new oN(Y),le=new Z3(Y),ae=new Q3(q,Q),we=new TO(d,F,ee,k,l),ge=new wv(d,k,Q),ye=new CO(H,q,ne,Q),se=new OO(H,q,ne,Q),ne.programs=U.programs,d.capabilities=Q,d.extensions=q,d.properties=Y,d.renderLists=le,d.shadowMap=ge,d.state=ee,d.info=ne}me();const Te=new sN(d,H);this.xr=Te,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){const Z=q.get("WEBGL_lose_context");Z&&Z.loseContext()},this.forceContextRestore=function(){const Z=q.get("WEBGL_lose_context");Z&&Z.restoreContext()},this.getPixelRatio=function(){return P},this.setPixelRatio=function(Z){Z!==void 0&&(P=Z,this.setSize(C,R,!1))},this.getSize=function(Z){return Z.set(C,R)},this.setSize=function(Z,pe,de){if(Te.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}C=Z,R=pe,e.width=Math.floor(Z*P),e.height=Math.floor(pe*P),de!==!1&&(e.style.width=Z+"px",e.style.height=pe+"px"),this.setViewport(0,0,Z,pe)},this.getDrawingBufferSize=function(Z){return Z.set(C*P,R*P).floor()},this.setDrawingBufferSize=function(Z,pe,de){C=Z,R=pe,P=de,e.width=Math.floor(Z*de),e.height=Math.floor(pe*de),this.setViewport(0,0,Z,pe)},this.getCurrentViewport=function(Z){return Z.copy(S)},this.getViewport=function(Z){return Z.copy(I)},this.setViewport=function(Z,pe,de,ve){Z.isVector4?I.set(Z.x,Z.y,Z.z,Z.w):I.set(Z,pe,de,ve),ee.viewport(S.copy(I).multiplyScalar(P).floor())},this.getScissor=function(Z){return Z.copy(O)},this.setScissor=function(Z,pe,de,ve){Z.isVector4?O.set(Z.x,Z.y,Z.z,Z.w):O.set(Z,pe,de,ve),ee.scissor(w.copy(O).multiplyScalar(P).floor())},this.getScissorTest=function(){return x},this.setScissorTest=function(Z){ee.setScissorTest(x=Z)},this.setOpaqueSort=function(Z){L=Z},this.setTransparentSort=function(Z){A=Z},this.getClearColor=function(Z){return Z.copy(we.getClearColor())},this.setClearColor=function(){we.setClearColor.apply(we,arguments)},this.getClearAlpha=function(){return we.getClearAlpha()},this.setClearAlpha=function(){we.setClearAlpha.apply(we,arguments)},this.clear=function(Z,pe,de){let ve=0;(Z===void 0||Z)&&(ve|=16384),(pe===void 0||pe)&&(ve|=256),(de===void 0||de)&&(ve|=1024),H.clear(ve)},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",He,!1),e.removeEventListener("webglcontextrestored",tt,!1),le.dispose(),ae.dispose(),Y.dispose(),F.dispose(),k.dispose(),he.dispose(),Te.dispose(),Te.removeEventListener("sessionstart",et),Te.removeEventListener("sessionend",Tt),z&&(z.dispose(),z=null),xt.stop()};function He(Z){Z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function tt(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;const Z=ne.autoReset,pe=ge.enabled,de=ge.autoUpdate,ve=ge.needsUpdate,Ee=ge.type;me(),ne.autoReset=Z,ge.enabled=pe,ge.autoUpdate=de,ge.needsUpdate=ve,ge.type=Ee}function Re(Z){const pe=Z.target;pe.removeEventListener("dispose",Re),ot(pe)}function ot(Z){Pe(Z),Y.remove(Z)}function Pe(Z){const pe=Y.get(Z).programs;pe!==void 0&&pe.forEach(function(de){U.releaseProgram(de)})}function Je(Z,pe){Z.render(function(de){d.renderBufferImmediate(de,pe)})}this.renderBufferImmediate=function(Z,pe){he.initAttributes();const de=Y.get(Z);Z.hasPositions&&!de.position&&(de.position=H.createBuffer()),Z.hasNormals&&!de.normal&&(de.normal=H.createBuffer()),Z.hasUvs&&!de.uv&&(de.uv=H.createBuffer()),Z.hasColors&&!de.color&&(de.color=H.createBuffer());const ve=pe.getAttributes();Z.hasPositions&&(H.bindBuffer(34962,de.position),H.bufferData(34962,Z.positionArray,35048),he.enableAttribute(ve.position),H.vertexAttribPointer(ve.position,3,5126,!1,0,0)),Z.hasNormals&&(H.bindBuffer(34962,de.normal),H.bufferData(34962,Z.normalArray,35048),he.enableAttribute(ve.normal),H.vertexAttribPointer(ve.normal,3,5126,!1,0,0)),Z.hasUvs&&(H.bindBuffer(34962,de.uv),H.bufferData(34962,Z.uvArray,35048),he.enableAttribute(ve.uv),H.vertexAttribPointer(ve.uv,2,5126,!1,0,0)),Z.hasColors&&(H.bindBuffer(34962,de.color),H.bufferData(34962,Z.colorArray,35048),he.enableAttribute(ve.color),H.vertexAttribPointer(ve.color,3,5126,!1,0,0)),he.disableUnusedAttributes(),H.drawArrays(4,0,Z.count),Z.count=0},this.renderBufferDirect=function(Z,pe,de,ve,Ee,ce){pe===null&&(pe=ie);const xe=Ee.isMesh&&Ee.matrixWorld.determinant()<0,_e=ct(Z,pe,ve,Ee);ee.setMaterial(ve,xe);let Ie=de.index;const Be=de.attributes.position;if(Ie===null){if(Be===void 0||Be.count===0)return}else if(Ie.count===0)return;let ze=1;ve.wireframe===!0&&(Ie=J.getWireframeAttribute(de),ze=2),(ve.morphTargets||ve.morphNormals)&&ue.update(Ee,de,ve,_e),he.setup(Ee,ve,_e,de,Ie);let ke,qe=ye;Ie!==null&&(ke=$.get(Ie),qe=se,qe.setIndex(ke));const Bt=Ie!==null?Ie.count:Be.count,$t=de.drawRange.start*ze,ds=de.drawRange.count*ze,mt=ce!==null?ce.start*ze:0,hs=ce!==null?ce.count*ze:1/0,sn=Math.max($t,mt),RV=Math.min(Bt,$t+ds,mt+hs)-1,ou=Math.max(0,RV-sn+1);if(ou!==0){if(Ee.isMesh)ve.wireframe===!0?(ee.setLineWidth(ve.wireframeLinewidth*j()),qe.setMode(1)):qe.setMode(4);else if(Ee.isLine){let Ya=ve.linewidth;Ya===void 0&&(Ya=1),ee.setLineWidth(Ya*j()),Ee.isLineSegments?qe.setMode(1):Ee.isLineLoop?qe.setMode(2):qe.setMode(3)}else Ee.isPoints?qe.setMode(0):Ee.isSprite&&qe.setMode(4);if(Ee.isInstancedMesh)qe.renderInstances(sn,ou,Ee.count);else if(de.isInstancedBufferGeometry){const Ya=Math.min(de.instanceCount,de._maxInstanceCount);qe.renderInstances(sn,ou,Ya)}else qe.render(sn,ou)}},this.compile=function(Z,pe){m=ae.get(Z),m.init(),Z.traverseVisible(function(de){de.isLight&&de.layers.test(pe.layers)&&(m.pushLight(de),de.castShadow&&m.pushShadow(de))}),m.setupLights(),Z.traverse(function(de){const ve=de.material;if(ve)if(Array.isArray(ve))for(let Ee=0;Ee<ve.length;Ee++){const ce=ve[Ee];Xe(ce,Z,de)}else Xe(ve,Z,de)})};let We=null;function at(Z){We&&We(Z)}function et(){xt.stop()}function Tt(){xt.start()}const xt=new Ky;xt.setAnimationLoop(at),typeof window<"u"&&xt.setContext(window),this.setAnimationLoop=function(Z){We=Z,Te.setAnimationLoop(Z),Z===null?xt.stop():xt.start()},Te.addEventListener("sessionstart",et),Te.addEventListener("sessionend",Tt),this.render=function(Z,pe){if(pe!==void 0&&pe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;Z.autoUpdate===!0&&Z.updateMatrixWorld(),pe.parent===null&&pe.updateMatrixWorld(),Te.enabled===!0&&Te.isPresenting===!0&&(Te.cameraAutoUpdate===!0&&Te.updateCamera(pe),pe=Te.getCamera()),Z.isScene===!0&&Z.onBeforeRender(d,Z,pe,M),m=ae.get(Z,p.length),m.init(),p.push(m),G.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),B.setFromProjectionMatrix(G),V=this.localClippingEnabled,D=fe.init(this.clippingPlanes,V,pe),h=le.get(Z,y.length),h.init(),y.push(h),re(Z,pe,0,d.sortObjects),h.finish(),d.sortObjects===!0&&h.sort(L,A),D===!0&&fe.beginShadows();const de=m.state.shadowsArray;ge.render(de,Z,pe),m.setupLights(),m.setupLightsView(pe),D===!0&&fe.endShadows(),this.info.autoReset===!0&&this.info.reset(),we.render(h,Z);const ve=h.opaque,Ee=h.transmissive,ce=h.transparent;ve.length>0&&Ce(ve,Z,pe),Ee.length>0&&Me(ve,Ee,Z,pe),ce.length>0&&Ce(ce,Z,pe),M!==null&&(te.updateMultisampleRenderTarget(M),te.updateRenderTargetMipmap(M)),Z.isScene===!0&&Z.onAfterRender(d,Z,pe),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1),he.resetDefaultState(),_=-1,E=null,p.pop(),p.length>0?m=p[p.length-1]:m=null,y.pop(),y.length>0?h=y[y.length-1]:h=null};function re(Z,pe,de,ve){if(Z.visible===!1)return;if(Z.layers.test(pe.layers)){if(Z.isGroup)de=Z.renderOrder;else if(Z.isLOD)Z.autoUpdate===!0&&Z.update(pe);else if(Z.isLight)m.pushLight(Z),Z.castShadow&&m.pushShadow(Z);else if(Z.isSprite){if(!Z.frustumCulled||B.intersectsSprite(Z)){ve&&K.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(G);const xe=k.update(Z),_e=Z.material;_e.visible&&h.push(Z,xe,_e,de,K.z,null)}}else if(Z.isImmediateRenderObject)ve&&K.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(G),h.push(Z,null,Z.material,de,K.z,null);else if((Z.isMesh||Z.isLine||Z.isPoints)&&(Z.isSkinnedMesh&&Z.skeleton.frame!==ne.render.frame&&(Z.skeleton.update(),Z.skeleton.frame=ne.render.frame),!Z.frustumCulled||B.intersectsObject(Z))){ve&&K.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(G);const xe=k.update(Z),_e=Z.material;if(Array.isArray(_e)){const Ie=xe.groups;for(let Be=0,ze=Ie.length;Be<ze;Be++){const ke=Ie[Be],qe=_e[ke.materialIndex];qe&&qe.visible&&h.push(Z,xe,qe,de,K.z,ke)}}else _e.visible&&h.push(Z,xe,_e,de,K.z,null)}}const ce=Z.children;for(let xe=0,_e=ce.length;xe<_e;xe++)re(ce[xe],pe,de,ve)}function Me(Z,pe,de,ve){if(z===null){const _e=o===!0&&Q.isWebGL2===!0?$d:Vn;z=new _e(1024,1024,{generateMipmaps:!0,type:be.convert(Br)!==null?Br:Dr,minFilter:Ti,magFilter:Lt,wrapS:Wt,wrapT:Wt})}const Ee=d.getRenderTarget();d.setRenderTarget(z),d.clear();const ce=d.toneMapping;d.toneMapping=nr,Ce(Z,de,ve),d.toneMapping=ce,te.updateMultisampleRenderTarget(z),te.updateRenderTargetMipmap(z),d.setRenderTarget(Ee),Ce(pe,de,ve)}function Ce(Z,pe,de){const ve=pe.isScene===!0?pe.overrideMaterial:null;for(let Ee=0,ce=Z.length;Ee<ce;Ee++){const xe=Z[Ee],_e=xe.object,Ie=xe.geometry,Be=ve===null?xe.material:ve,ze=xe.group;if(de.isArrayCamera){const ke=de.cameras;for(let qe=0,Bt=ke.length;qe<Bt;qe++){const $t=ke[qe];_e.layers.test($t.layers)&&(ee.viewport(S.copy($t.viewport)),m.setupLightsView($t),Ne(_e,pe,$t,Ie,Be,ze))}}else Ne(_e,pe,de,Ie,Be,ze)}}function Ne(Z,pe,de,ve,Ee,ce){if(Z.onBeforeRender(d,pe,de,ve,Ee,ce),Z.modelViewMatrix.multiplyMatrices(de.matrixWorldInverse,Z.matrixWorld),Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix),Z.isImmediateRenderObject){const xe=ct(de,pe,Ee,Z);ee.setMaterial(Ee),he.reset(),Je(Z,xe)}else Ee.transparent===!0&&Ee.side===tr?(Ee.side=At,Ee.needsUpdate=!0,d.renderBufferDirect(de,pe,ve,Ee,Z,ce),Ee.side=er,Ee.needsUpdate=!0,d.renderBufferDirect(de,pe,ve,Ee,Z,ce),Ee.side=tr):d.renderBufferDirect(de,pe,ve,Ee,Z,ce);Z.onAfterRender(d,pe,de,ve,Ee,ce)}function Xe(Z,pe,de){pe.isScene!==!0&&(pe=ie);const ve=Y.get(Z),Ee=m.state.lights,ce=m.state.shadowsArray,xe=Ee.state.version,_e=U.getParameters(Z,Ee.state,ce,pe,de),Ie=U.getProgramCacheKey(_e);let Be=ve.programs;ve.environment=Z.isMeshStandardMaterial?pe.environment:null,ve.fog=pe.fog,ve.envMap=F.get(Z.envMap||ve.environment),Be===void 0&&(Z.addEventListener("dispose",Re),Be=new Map,ve.programs=Be);let ze=Be.get(Ie);if(ze!==void 0){if(ve.currentProgram===ze&&ve.lightsStateVersion===xe)return it(Z,_e),ze}else _e.uniforms=U.getUniforms(Z),Z.onBuild(_e,d),Z.onBeforeCompile(_e,d),ze=U.acquireProgram(_e,Ie),Be.set(Ie,ze),ve.uniforms=_e.uniforms;const ke=ve.uniforms;(!Z.isShaderMaterial&&!Z.isRawShaderMaterial||Z.clipping===!0)&&(ke.clippingPlanes=fe.uniform),it(Z,_e),ve.needsLights=Et(Z),ve.lightsStateVersion=xe,ve.needsLights&&(ke.ambientLightColor.value=Ee.state.ambient,ke.lightProbe.value=Ee.state.probe,ke.directionalLights.value=Ee.state.directional,ke.directionalLightShadows.value=Ee.state.directionalShadow,ke.spotLights.value=Ee.state.spot,ke.spotLightShadows.value=Ee.state.spotShadow,ke.rectAreaLights.value=Ee.state.rectArea,ke.ltc_1.value=Ee.state.rectAreaLTC1,ke.ltc_2.value=Ee.state.rectAreaLTC2,ke.pointLights.value=Ee.state.point,ke.pointLightShadows.value=Ee.state.pointShadow,ke.hemisphereLights.value=Ee.state.hemi,ke.directionalShadowMap.value=Ee.state.directionalShadowMap,ke.directionalShadowMatrix.value=Ee.state.directionalShadowMatrix,ke.spotShadowMap.value=Ee.state.spotShadowMap,ke.spotShadowMatrix.value=Ee.state.spotShadowMatrix,ke.pointShadowMap.value=Ee.state.pointShadowMap,ke.pointShadowMatrix.value=Ee.state.pointShadowMatrix);const qe=ze.getUniforms(),Bt=pr.seqWithValue(qe.seq,ke);return ve.currentProgram=ze,ve.uniformsList=Bt,ze}function it(Z,pe){const de=Y.get(Z);de.outputEncoding=pe.outputEncoding,de.instancing=pe.instancing,de.skinning=pe.skinning,de.numClippingPlanes=pe.numClippingPlanes,de.numIntersection=pe.numClipIntersection,de.vertexAlphas=pe.vertexAlphas}function ct(Z,pe,de,ve){pe.isScene!==!0&&(pe=ie),te.resetTextureUnits();const Ee=pe.fog,ce=de.isMeshStandardMaterial?pe.environment:null,xe=M===null?d.outputEncoding:M.texture.encoding,_e=F.get(de.envMap||ce),Ie=de.vertexColors===!0&&ve.geometry&&ve.geometry.attributes.color&&ve.geometry.attributes.color.itemSize===4,Be=Y.get(de),ze=m.state.lights;if(D===!0&&(V===!0||Z!==E)){const sn=Z===E&&de.id===_;fe.setState(de,Z,sn)}let ke=!1;de.version===Be.__version?(Be.needsLights&&Be.lightsStateVersion!==ze.state.version||Be.outputEncoding!==xe||ve.isInstancedMesh&&Be.instancing===!1||!ve.isInstancedMesh&&Be.instancing===!0||ve.isSkinnedMesh&&Be.skinning===!1||!ve.isSkinnedMesh&&Be.skinning===!0||Be.envMap!==_e||de.fog&&Be.fog!==Ee||Be.numClippingPlanes!==void 0&&(Be.numClippingPlanes!==fe.numPlanes||Be.numIntersection!==fe.numIntersection)||Be.vertexAlphas!==Ie)&&(ke=!0):(ke=!0,Be.__version=de.version);let qe=Be.currentProgram;ke===!0&&(qe=Xe(de,pe,ve));let Bt=!1,$t=!1,ds=!1;const mt=qe.getUniforms(),hs=Be.uniforms;if(ee.useProgram(qe.program)&&(Bt=!0,$t=!0,ds=!0),de.id!==_&&(_=de.id,$t=!0),Bt||E!==Z){if(mt.setValue(H,"projectionMatrix",Z.projectionMatrix),Q.logarithmicDepthBuffer&&mt.setValue(H,"logDepthBufFC",2/(Math.log(Z.far+1)/Math.LN2)),E!==Z&&(E=Z,$t=!0,ds=!0),de.isShaderMaterial||de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshStandardMaterial||de.envMap){const sn=mt.map.cameraPosition;sn!==void 0&&sn.setValue(H,K.setFromMatrixPosition(Z.matrixWorld))}(de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshLambertMaterial||de.isMeshBasicMaterial||de.isMeshStandardMaterial||de.isShaderMaterial)&&mt.setValue(H,"isOrthographic",Z.isOrthographicCamera===!0),(de.isMeshPhongMaterial||de.isMeshToonMaterial||de.isMeshLambertMaterial||de.isMeshBasicMaterial||de.isMeshStandardMaterial||de.isShaderMaterial||de.isShadowMaterial||ve.isSkinnedMesh)&&mt.setValue(H,"viewMatrix",Z.matrixWorldInverse)}if(ve.isSkinnedMesh){mt.setOptional(H,ve,"bindMatrix"),mt.setOptional(H,ve,"bindMatrixInverse");const sn=ve.skeleton;sn&&(Q.floatVertexTextures?(sn.boneTexture===null&&sn.computeBoneTexture(),mt.setValue(H,"boneTexture",sn.boneTexture,te),mt.setValue(H,"boneTextureSize",sn.boneTextureSize)):mt.setOptional(H,sn,"boneMatrices"))}return($t||Be.receiveShadow!==ve.receiveShadow)&&(Be.receiveShadow=ve.receiveShadow,mt.setValue(H,"receiveShadow",ve.receiveShadow)),$t&&(mt.setValue(H,"toneMappingExposure",d.toneMappingExposure),Be.needsLights&&pt(hs,ds),Ee&&de.fog&&oe.refreshFogUniforms(hs,Ee),oe.refreshMaterialUniforms(hs,de,P,R,z),pr.upload(H,Be.uniformsList,hs,te)),de.isShaderMaterial&&de.uniformsNeedUpdate===!0&&(pr.upload(H,Be.uniformsList,hs,te),de.uniformsNeedUpdate=!1),de.isSpriteMaterial&&mt.setValue(H,"center",ve.center),mt.setValue(H,"modelViewMatrix",ve.modelViewMatrix),mt.setValue(H,"normalMatrix",ve.normalMatrix),mt.setValue(H,"modelMatrix",ve.matrixWorld),qe}function pt(Z,pe){Z.ambientLightColor.needsUpdate=pe,Z.lightProbe.needsUpdate=pe,Z.directionalLights.needsUpdate=pe,Z.directionalLightShadows.needsUpdate=pe,Z.pointLights.needsUpdate=pe,Z.pointLightShadows.needsUpdate=pe,Z.spotLights.needsUpdate=pe,Z.spotLightShadows.needsUpdate=pe,Z.rectAreaLights.needsUpdate=pe,Z.hemisphereLights.needsUpdate=pe}function Et(Z){return Z.isMeshLambertMaterial||Z.isMeshToonMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isShadowMaterial||Z.isShaderMaterial&&Z.lights===!0}this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return g},this.getRenderTarget=function(){return M},this.setRenderTarget=function(Z,pe=0,de=0){M=Z,v=pe,g=de,Z&&Y.get(Z).__webglFramebuffer===void 0&&te.setupRenderTarget(Z);let ve=null,Ee=!1,ce=!1;if(Z){const _e=Z.texture;(_e.isDataTexture3D||_e.isDataTexture2DArray)&&(ce=!0);const Ie=Y.get(Z).__webglFramebuffer;Z.isWebGLCubeRenderTarget?(ve=Ie[pe],Ee=!0):Z.isWebGLMultisampleRenderTarget?ve=Y.get(Z).__webglMultisampledFramebuffer:ve=Ie,S.copy(Z.viewport),w.copy(Z.scissor),T=Z.scissorTest}else S.copy(I).multiplyScalar(P).floor(),w.copy(O).multiplyScalar(P).floor(),T=x;if(ee.bindFramebuffer(36160,ve)&&Q.drawBuffers){let _e=!1;if(Z)if(Z.isWebGLMultipleRenderTargets){const Ie=Z.texture;if(N.length!==Ie.length||N[0]!==36064){for(let Be=0,ze=Ie.length;Be<ze;Be++)N[Be]=36064+Be;N.length=Ie.length,_e=!0}}else(N.length!==1||N[0]!==36064)&&(N[0]=36064,N.length=1,_e=!0);else(N.length!==1||N[0]!==1029)&&(N[0]=1029,N.length=1,_e=!0);_e&&(Q.isWebGL2?H.drawBuffers(N):q.get("WEBGL_draw_buffers").drawBuffersWEBGL(N))}if(ee.viewport(S),ee.scissor(w),ee.setScissorTest(T),Ee){const _e=Y.get(Z.texture);H.framebufferTexture2D(36160,36064,34069+pe,_e.__webglTexture,de)}else if(ce){const _e=Y.get(Z.texture),Ie=pe||0;H.framebufferTextureLayer(36160,36064,_e.__webglTexture,de||0,Ie)}},this.readRenderTargetPixels=function(Z,pe,de,ve,Ee,ce,xe){if(!(Z&&Z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let _e=Y.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&xe!==void 0&&(_e=_e[xe]),_e){ee.bindFramebuffer(36160,_e);try{const Ie=Z.texture,Be=Ie.format,ze=Ie.type;if(Be!==vn&&be.convert(Be)!==H.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const ke=ze===Br&&(q.has("EXT_color_buffer_half_float")||Q.isWebGL2&&q.has("EXT_color_buffer_float"));if(ze!==Dr&&be.convert(ze)!==H.getParameter(35738)&&!(ze===Ei&&(Q.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float")))&&!ke){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}H.checkFramebufferStatus(36160)===36053?pe>=0&&pe<=Z.width-ve&&de>=0&&de<=Z.height-Ee&&H.readPixels(pe,de,ve,Ee,be.convert(Be),be.convert(ze),ce):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const Ie=M!==null?Y.get(M).__webglFramebuffer:null;ee.bindFramebuffer(36160,Ie)}}},this.copyFramebufferToTexture=function(Z,pe,de=0){const ve=Math.pow(2,-de),Ee=Math.floor(pe.image.width*ve),ce=Math.floor(pe.image.height*ve);let xe=be.convert(pe.format);Q.isWebGL2&&(xe===6407&&(xe=32849),xe===6408&&(xe=32856)),te.setTexture2D(pe,0),H.copyTexImage2D(3553,de,xe,Z.x,Z.y,Ee,ce,0),ee.unbindTexture()},this.copyTextureToTexture=function(Z,pe,de,ve=0){const Ee=pe.image.width,ce=pe.image.height,xe=be.convert(de.format),_e=be.convert(de.type);te.setTexture2D(de,0),H.pixelStorei(37440,de.flipY),H.pixelStorei(37441,de.premultiplyAlpha),H.pixelStorei(3317,de.unpackAlignment),pe.isDataTexture?H.texSubImage2D(3553,ve,Z.x,Z.y,Ee,ce,xe,_e,pe.image.data):pe.isCompressedTexture?H.compressedTexSubImage2D(3553,ve,Z.x,Z.y,pe.mipmaps[0].width,pe.mipmaps[0].height,xe,pe.mipmaps[0].data):H.texSubImage2D(3553,ve,Z.x,Z.y,xe,_e,pe.image),ve===0&&de.generateMipmaps&&H.generateMipmap(3553),ee.unbindTexture()},this.copyTextureToTexture3D=function(Z,pe,de,ve,Ee=0){if(d.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const ce=Z.max.x-Z.min.x+1,xe=Z.max.y-Z.min.y+1,_e=Z.max.z-Z.min.z+1,Ie=be.convert(ve.format),Be=be.convert(ve.type);let ze;if(ve.isDataTexture3D)te.setTexture3D(ve,0),ze=32879;else if(ve.isDataTexture2DArray)te.setTexture2DArray(ve,0),ze=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}H.pixelStorei(37440,ve.flipY),H.pixelStorei(37441,ve.premultiplyAlpha),H.pixelStorei(3317,ve.unpackAlignment);const ke=H.getParameter(3314),qe=H.getParameter(32878),Bt=H.getParameter(3316),$t=H.getParameter(3315),ds=H.getParameter(32877),mt=de.isCompressedTexture?de.mipmaps[0]:de.image;H.pixelStorei(3314,mt.width),H.pixelStorei(32878,mt.height),H.pixelStorei(3316,Z.min.x),H.pixelStorei(3315,Z.min.y),H.pixelStorei(32877,Z.min.z),de.isDataTexture||de.isDataTexture3D?H.texSubImage3D(ze,Ee,pe.x,pe.y,pe.z,ce,xe,_e,Ie,Be,mt.data):de.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),H.compressedTexSubImage3D(ze,Ee,pe.x,pe.y,pe.z,ce,xe,_e,Ie,mt.data)):H.texSubImage3D(ze,Ee,pe.x,pe.y,pe.z,ce,xe,_e,Ie,Be,mt),H.pixelStorei(3314,ke),H.pixelStorei(32878,qe),H.pixelStorei(3316,Bt),H.pixelStorei(3315,$t),H.pixelStorei(32877,ds),Ee===0&&ve.generateMipmaps&&H.generateMipmap(ze),ee.unbindTexture()},this.initTexture=function(Z){te.setTexture2D(Z,0),ee.unbindTexture()},this.resetState=function(){v=0,g=0,M=null,ee.reset(),he.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Sv extends lt{}Sv.prototype.isWebGL1Renderer=!0;class pa{constructor(e,t=25e-5){this.name="",this.color=new Ae(e),this.density=t}clone(){return new pa(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}pa.prototype.isFogExp2=!0;class ma{constructor(e,t=1,i=1e3){this.name="",this.color=new Ae(e),this.near=t,this.far=i}clone(){return new ma(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}ma.prototype.isFog=!0;class mc extends $e{constructor(){super(),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){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t}}mc.prototype.isScene=!0;class mr{constructor(e,t){this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Fs,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=bn()}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,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[i+r];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=bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=bn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}mr.prototype.isInterleavedBuffer=!0;const Ot=new X;class Bi{constructor(e,t,i,r=!1){this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r===!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,i=this.data.count;t<i;t++)Ot.x=this.getX(t),Ot.y=this.getY(t),Ot.z=this.getZ(t),Ot.applyMatrix4(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ot.x=this.getX(t),Ot.y=this.getY(t),Ot.z=this.getZ(t),Ot.applyNormalMatrix(e),this.setXYZ(t,Ot.x,Ot.y,Ot.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ot.x=this.getX(t),Ot.y=this.getY(t),Ot.z=this.getZ(t),Ot.transformDirection(e),this.setXYZ(t,Ot.x,Ot.y,Ot.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,i){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e=e*this.data.stride+this.offset,this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+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 Bi(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const t=[];for(let i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+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}}}Bi.prototype.isInterleavedBufferAttribute=!0;class ga extends Vt{constructor(e){super(),this.type="SpriteMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this}}ga.prototype.isSpriteMaterial=!0;let no;const ya=new X,io=new X,ro=new X,so=new Se,va=new Se,_v=new De,gc=new X,ba=new X,yc=new X,Tv=new Se,Mh=new Se,Ev=new Se;class xa extends $e{constructor(e){if(super(),this.type="Sprite",no===void 0){no=new Ve;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new mr(t,5);no.setIndex([0,1,2,0,2,3]),no.setAttribute("position",new Bi(i,3,0,!1)),no.setAttribute("uv",new Bi(i,2,3,!1))}this.geometry=no,this.material=e!==void 0?e:new ga,this.center=new Se(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),io.setFromMatrixScale(this.matrixWorld),_v.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ro.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&io.multiplyScalar(-ro.z);const i=this.material.rotation;let r,s;i!==0&&(s=Math.cos(i),r=Math.sin(i));const o=this.center;vc(gc.set(-.5,-.5,0),ro,o,io,r,s),vc(ba.set(.5,-.5,0),ro,o,io,r,s),vc(yc.set(.5,.5,0),ro,o,io,r,s),Tv.set(0,0),Mh.set(1,0),Ev.set(1,1);let l=e.ray.intersectTriangle(gc,ba,yc,!1,ya);if(l===null&&(vc(ba.set(-.5,.5,0),ro,o,io,r,s),Mh.set(0,1),l=e.ray.intersectTriangle(gc,yc,ba,!1,ya),l===null))return;const u=e.ray.origin.distanceTo(ya);u<e.near||u>e.far||t.push({distance:u,point:ya.clone(),uv:Pt.getUV(ya,gc,ba,yc,Tv,Mh,Ev,new Se),face:null,object:this})}copy(e){return super.copy(e),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}xa.prototype.isSprite=!0;function vc(n,e,t,i,r,s){so.subVectors(n,t).addScalar(.5).multiply(i),r!==void 0?(va.x=s*so.x-r*so.y,va.y=r*so.x+s*so.y):va.copy(so),n.copy(e),n.x+=va.x,n.y+=va.y,n.applyMatrix4(_v)}const bc=new X,Cv=new X;class Av extends $e{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let i=0,r=t.length;i<r;i++){const s=t[i];this.addLevel(s.object.clone(),s.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let i,r;for(i=1,r=t.length;i<r&&!(e<t[i].distance);i++);return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){bc.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(bc);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){bc.setFromMatrixPosition(e.matrixWorld),Cv.setFromMatrixPosition(this.matrixWorld);const i=bc.distanceTo(Cv)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s&&i>=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const i=this.levels;for(let r=0,s=i.length;r<s;r++){const o=i[r];t.object.levels.push({object:o.object.uuid,distance:o.distance})}return t}}const Lv=new X,Rv=new st,Pv=new st,lN=new X,Iv=new De;class wa extends It{constructor(e,t){super(e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new De,this.bindMatrixInverse=new De}copy(e){return super.copy(e),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.x=t.getX(i),e.y=t.getY(i),e.z=t.getZ(i),e.w=t.getW(i);const s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const i=this.skeleton,r=this.geometry;Rv.fromBufferAttribute(r.attributes.skinIndex,e),Pv.fromBufferAttribute(r.attributes.skinWeight,e),Lv.fromBufferAttribute(r.attributes.position,e).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){const o=Pv.getComponent(s);if(o!==0){const l=Rv.getComponent(s);Iv.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),t.addScaledVector(lN.copy(Lv).applyMatrix4(Iv),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}wa.prototype.isSkinnedMesh=!0;class Ma extends $e{constructor(){super(),this.type="Bone"}}Ma.prototype.isBone=!0;class Xr extends Rt{constructor(e=null,t=1,i=1,r,s,o,l,u,c=Lt,f=Lt,h,m){super(null,o,l,u,c,f,r,s,h,m),this.image={data:e,width:t,height:i},this.magFilter=c,this.minFilter=f,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}Xr.prototype.isDataTexture=!0;const Ov=new De,cN=new De;class Sa{constructor(e=[],t=[]){this.uuid=bn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new De)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new De;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){const l=e[s]?e[s].matrixWorld:cN;Ov.multiplyMatrices(l,t[s]),Ov.toArray(i,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Sa(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Ay(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const i=new Xr(t,e,e,vn,Ei);return this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const s=e.bones[i];let o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Ma),this.bones.push(o),this.boneInverses.push(new De().fromArray(e.boneInverses[i]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,i=this.boneInverses;for(let r=0,s=t.length;r<s;r++){const o=t[r];e.bones.push(o.uuid);const l=i[r];e.boneInverses.push(l.toArray())}return e}}const Nv=new De,Dv=new De,xc=[],_a=new It;class Sh extends It{constructor(e,t,i){super(e,t),this.instanceMatrix=new Ge(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.frustumCulled=!1}copy(e){return super.copy(e),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const i=this.matrixWorld,r=this.count;if(_a.geometry=this.geometry,_a.material=this.material,_a.material!==void 0)for(let s=0;s<r;s++){this.getMatrixAt(s,Nv),Dv.multiplyMatrices(i,Nv),_a.matrixWorld=Dv,_a.raycast(e,xc);for(let o=0,l=xc.length;o<l;o++){const u=xc[o];u.instanceId=s,u.object=this,t.push(u)}xc.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Ge(new Float32Array(this.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}Sh.prototype.isInstancedMesh=!0;class Ut extends Vt{constructor(e){super(),this.type="LineBasicMaterial",this.color=new Ae(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.morphTargets=!1,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.morphTargets=e.morphTargets,this}}Ut.prototype.isLineBasicMaterial=!0;const Bv=new X,Fv=new X,Vv=new De,_h=new cr,wc=new Li;class ii extends $e{constructor(e=new Ve,t=new Ut){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Bv.fromBufferAttribute(t,r-1),Fv.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Bv.distanceTo(Fv);e.setAttribute("lineDistance",new Oe(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),wc.copy(i.boundingSphere),wc.applyMatrix4(r),wc.radius+=s,e.ray.intersectsSphere(wc)===!1)return;Vv.copy(r).invert(),_h.copy(e.ray).applyMatrix4(Vv);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l,c=new X,f=new X,h=new X,m=new X,y=this.isLineSegments?2:1;if(i.isBufferGeometry){const p=i.index,b=i.attributes.position;if(p!==null){const v=Math.max(0,o.start),g=Math.min(p.count,o.start+o.count);for(let M=v,_=g-1;M<_;M+=y){const E=p.getX(M),S=p.getX(M+1);if(c.fromBufferAttribute(b,E),f.fromBufferAttribute(b,S),_h.distanceSqToSegment(c,f,m,h)>u)continue;m.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(m);T<e.near||T>e.far||t.push({distance:T,point:h.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),g=Math.min(b.count,o.start+o.count);for(let M=v,_=g-1;M<_;M+=y){if(c.fromBufferAttribute(b,M),f.fromBufferAttribute(b,M+1),_h.distanceSqToSegment(c,f,m,h)>u)continue;m.applyMatrix4(this.matrixWorld);const S=e.ray.origin.distanceTo(m);S<e.near||S>e.far||t.push({distance:S,point:h.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}else i.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const l=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}ii.prototype.isLine=!0;const kv=new X,zv=new X;class un extends ii{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)kv.fromBufferAttribute(t,r),zv.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+kv.distanceTo(zv);e.setAttribute("lineDistance",new Oe(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}un.prototype.isLineSegments=!0;class Mc extends ii{constructor(e,t){super(e,t),this.type="LineLoop"}}Mc.prototype.isLineLoop=!0;class gr extends Vt{constructor(e){super(),this.type="PointsMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.morphTargets=e.morphTargets,this}}gr.prototype.isPointsMaterial=!0;const Uv=new De,Th=new cr,Sc=new Li,_c=new X;class oo extends $e{constructor(e=new Ve,t=new gr){super(),this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Sc.copy(i.boundingSphere),Sc.applyMatrix4(r),Sc.radius+=s,e.ray.intersectsSphere(Sc)===!1)return;Uv.copy(r).invert(),Th.copy(e.ray).applyMatrix4(Uv);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),u=l*l;if(i.isBufferGeometry){const c=i.index,h=i.attributes.position;if(c!==null){const m=Math.max(0,o.start),y=Math.min(c.count,o.start+o.count);for(let p=m,d=y;p<d;p++){const b=c.getX(p);_c.fromBufferAttribute(h,b),Gv(_c,b,u,r,e,t,this)}}else{const m=Math.max(0,o.start),y=Math.min(h.count,o.start+o.count);for(let p=m,d=y;p<d;p++)_c.fromBufferAttribute(h,p),Gv(_c,p,u,r,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const l=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=s}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}oo.prototype.isPoints=!0;function Gv(n,e,t,i,r,s,o){const l=Th.distanceSqToPoint(n);if(l<t){const u=new X;Th.closestPointToPoint(n,u),u.applyMatrix4(i);const c=r.ray.origin.distanceTo(u);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(l),point:u,index:e,face:null,object:o})}}class Hv extends Rt{constructor(e,t,i,r,s,o,l,u,c){super(e,t,i,r,s,o,l,u,c),this.format=l!==void 0?l:Ci,this.minFilter=o!==void 0?o:wt,this.magFilter=s!==void 0?s:wt,this.generateMipmaps=!1;const f=this;function h(){f.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}Hv.prototype.isVideoTexture=!0;class Eh extends Rt{constructor(e,t,i,r,s,o,l,u,c,f,h,m){super(null,o,l,u,c,f,r,s,h,m),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Eh.prototype.isCompressedTexture=!0;class Wv extends Rt{constructor(e,t,i,r,s,o,l,u,c){super(e,t,i,r,s,o,l,u,c),this.needsUpdate=!0}}Wv.prototype.isCanvasTexture=!0;class jv extends Rt{constructor(e,t,i,r,s,o,l,u,c,f){if(f=f!==void 0?f:Fr,f!==Fr&&f!==Ds)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&f===Fr&&(i=ta),i===void 0&&f===Ds&&(i=Ns),super(null,r,s,o,l,u,f,i,c),this.image={width:e,height:t},this.magFilter=l!==void 0?l:Lt,this.minFilter=u!==void 0?u:Lt,this.flipY=!1,this.generateMipmaps=!1}}jv.prototype.isDepthTexture=!0;class ao extends Ve{constructor(e=1,t=8,i=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);const s=[],o=[],l=[],u=[],c=new X,f=new Se;o.push(0,0,0),l.push(0,0,1),u.push(.5,.5);for(let h=0,m=3;h<=t;h++,m+=3){const y=i+h/t*r;c.x=e*Math.cos(y),c.y=e*Math.sin(y),o.push(c.x,c.y,c.z),l.push(0,0,1),f.x=(o[m]/e+1)/2,f.y=(o[m+1]/e+1)/2,u.push(f.x,f.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Oe(o,3)),this.setAttribute("normal",new Oe(l,3)),this.setAttribute("uv",new Oe(u,2))}static fromJSON(e){return new ao(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class yr extends Ve{constructor(e=1,t=1,i=1,r=8,s=1,o=!1,l=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:l,thetaLength:u};const c=this;r=Math.floor(r),s=Math.floor(s);const f=[],h=[],m=[],y=[];let p=0;const d=[],b=i/2;let v=0;g(),o===!1&&(e>0&&M(!0),t>0&&M(!1)),this.setIndex(f),this.setAttribute("position",new Oe(h,3)),this.setAttribute("normal",new Oe(m,3)),this.setAttribute("uv",new Oe(y,2));function g(){const _=new X,E=new X;let S=0;const w=(t-e)/i;for(let T=0;T<=s;T++){const C=[],R=T/s,P=R*(t-e)+e;for(let L=0;L<=r;L++){const A=L/r,I=A*u+l,O=Math.sin(I),x=Math.cos(I);E.x=P*O,E.y=-R*i+b,E.z=P*x,h.push(E.x,E.y,E.z),_.set(O,w,x).normalize(),m.push(_.x,_.y,_.z),y.push(A,1-R),C.push(p++)}d.push(C)}for(let T=0;T<r;T++)for(let C=0;C<s;C++){const R=d[C][T],P=d[C+1][T],L=d[C+1][T+1],A=d[C][T+1];f.push(R,P,A),f.push(P,L,A),S+=6}c.addGroup(v,S,0),v+=S}function M(_){const E=p,S=new Se,w=new X;let T=0;const C=_===!0?e:t,R=_===!0?1:-1;for(let L=1;L<=r;L++)h.push(0,b*R,0),m.push(0,R,0),y.push(.5,.5),p++;const P=p;for(let L=0;L<=r;L++){const I=L/r*u+l,O=Math.cos(I),x=Math.sin(I);w.x=C*x,w.y=b*R,w.z=C*O,h.push(w.x,w.y,w.z),m.push(0,R,0),S.x=O*.5+.5,S.y=x*.5*R+.5,y.push(S.x,S.y),p++}for(let L=0;L<r;L++){const A=E+L,I=P+L;_===!0?f.push(I,I+1,A):f.push(I+1,I,A),T+=3}c.addGroup(v,T,_===!0?1:2),v+=T}}static fromJSON(e){return new yr(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class lo extends yr{constructor(e=1,t=1,i=8,r=1,s=!1,o=0,l=Math.PI*2){super(0,e,t,i,r,s,o,l),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:l}}static fromJSON(e){return new lo(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ri extends Ve{constructor(e,t,i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const s=[],o=[];l(r),c(i),f(),this.setAttribute("position",new Oe(s,3)),this.setAttribute("normal",new Oe(s.slice(),3)),this.setAttribute("uv",new Oe(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function l(g){const M=new X,_=new X,E=new X;for(let S=0;S<t.length;S+=3)y(t[S+0],M),y(t[S+1],_),y(t[S+2],E),u(M,_,E,g)}function u(g,M,_,E){const S=E+1,w=[];for(let T=0;T<=S;T++){w[T]=[];const C=g.clone().lerp(_,T/S),R=M.clone().lerp(_,T/S),P=S-T;for(let L=0;L<=P;L++)L===0&&T===S?w[T][L]=C:w[T][L]=C.clone().lerp(R,L/P)}for(let T=0;T<S;T++)for(let C=0;C<2*(S-T)-1;C++){const R=Math.floor(C/2);C%2===0?(m(w[T][R+1]),m(w[T+1][R]),m(w[T][R])):(m(w[T][R+1]),m(w[T+1][R+1]),m(w[T+1][R]))}}function c(g){const M=new X;for(let _=0;_<s.length;_+=3)M.x=s[_+0],M.y=s[_+1],M.z=s[_+2],M.normalize().multiplyScalar(g),s[_+0]=M.x,s[_+1]=M.y,s[_+2]=M.z}function f(){const g=new X;for(let M=0;M<s.length;M+=3){g.x=s[M+0],g.y=s[M+1],g.z=s[M+2];const _=b(g)/2/Math.PI+.5,E=v(g)/Math.PI+.5;o.push(_,1-E)}p(),h()}function h(){for(let g=0;g<o.length;g+=6){const M=o[g+0],_=o[g+2],E=o[g+4],S=Math.max(M,_,E),w=Math.min(M,_,E);S>.9&&w<.1&&(M<.2&&(o[g+0]+=1),_<.2&&(o[g+2]+=1),E<.2&&(o[g+4]+=1))}}function m(g){s.push(g.x,g.y,g.z)}function y(g,M){const _=g*3;M.x=e[_+0],M.y=e[_+1],M.z=e[_+2]}function p(){const g=new X,M=new X,_=new X,E=new X,S=new Se,w=new Se,T=new Se;for(let C=0,R=0;C<s.length;C+=9,R+=6){g.set(s[C+0],s[C+1],s[C+2]),M.set(s[C+3],s[C+4],s[C+5]),_.set(s[C+6],s[C+7],s[C+8]),S.set(o[R+0],o[R+1]),w.set(o[R+2],o[R+3]),T.set(o[R+4],o[R+5]),E.copy(g).add(M).add(_).divideScalar(3);const P=b(E);d(S,R+0,g,P),d(w,R+2,M,P),d(T,R+4,_,P)}}function d(g,M,_,E){E<0&&g.x===1&&(o[M]=g.x-1),_.x===0&&_.z===0&&(o[M]=E/2/Math.PI+.5)}function b(g){return Math.atan2(g.z,-g.x)}function v(g){return Math.atan2(-g.y,Math.sqrt(g.x*g.x+g.z*g.z))}}static fromJSON(e){return new ri(e.vertices,e.indices,e.radius,e.details)}}class co extends ri{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=1/i,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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],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 co(e.radius,e.detail)}}const Tc=new X,Ec=new X,Ch=new X,Cc=new Pt;class Ah extends Ve{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=t!==void 0?t:1,e.isGeometry===!0){console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return}const r=Math.pow(10,4),s=Math.cos(Gr*t),o=e.getIndex(),l=e.getAttribute("position"),u=o?o.count:l.count,c=[0,0,0],f=["a","b","c"],h=new Array(3),m={},y=[];for(let p=0;p<u;p+=3){o?(c[0]=o.getX(p),c[1]=o.getX(p+1),c[2]=o.getX(p+2)):(c[0]=p,c[1]=p+1,c[2]=p+2);const{a:d,b,c:v}=Cc;if(d.fromBufferAttribute(l,c[0]),b.fromBufferAttribute(l,c[1]),v.fromBufferAttribute(l,c[2]),Cc.getNormal(Ch),h[0]=`${Math.round(d.x*r)},${Math.round(d.y*r)},${Math.round(d.z*r)}`,h[1]=`${Math.round(b.x*r)},${Math.round(b.y*r)},${Math.round(b.z*r)}`,h[2]=`${Math.round(v.x*r)},${Math.round(v.y*r)},${Math.round(v.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let g=0;g<3;g++){const M=(g+1)%3,_=h[g],E=h[M],S=Cc[f[g]],w=Cc[f[M]],T=`${_}_${E}`,C=`${E}_${_}`;C in m&&m[C]?(Ch.dot(m[C].normal)<=s&&(y.push(S.x,S.y,S.z),y.push(w.x,w.y,w.z)),m[C]=null):T in m||(m[T]={index0:c[g],index1:c[M],normal:Ch.clone()})}}for(const p in m)if(m[p]){const{index0:d,index1:b}=m[p];Tc.fromBufferAttribute(l,d),Ec.fromBufferAttribute(l,b),y.push(Tc.x,Tc.y,Tc.z),y.push(Ec.x,Ec.y,Ec.z)}this.setAttribute("position",new Oe(y,3))}}class Mn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const 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;const t=[];let i,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)i=this.getPoint(o/e),s+=i.distanceTo(r),t.push(s),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const s=i.length;let o;t?o=t:o=e*i[s-1];let l=0,u=s-1,c;for(;l<=u;)if(r=Math.floor(l+(u-l)/2),c=i[r]-o,c<0)l=r+1;else if(c>0)u=r-1;else{u=r;break}if(r=u,i[r]===o)return r/(s-1);const f=i[r],m=i[r+1]-f,y=(o-f)/m;return(r+y)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const o=this.getPoint(r),l=this.getPoint(s),u=t||(o.isVector2?new Se:new X);return u.copy(l).sub(o).normalize(),u}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new X,r=[],s=[],o=[],l=new X,u=new De;for(let y=0;y<=e;y++){const p=y/e;r[y]=this.getTangentAt(p,new X),r[y].normalize()}s[0]=new X,o[0]=new X;let c=Number.MAX_VALUE;const f=Math.abs(r[0].x),h=Math.abs(r[0].y),m=Math.abs(r[0].z);f<=c&&(c=f,i.set(1,0,0)),h<=c&&(c=h,i.set(0,1,0)),m<=c&&i.set(0,0,1),l.crossVectors(r[0],i).normalize(),s[0].crossVectors(r[0],l),o[0].crossVectors(r[0],s[0]);for(let y=1;y<=e;y++){if(s[y]=s[y-1].clone(),o[y]=o[y-1].clone(),l.crossVectors(r[y-1],r[y]),l.length()>Number.EPSILON){l.normalize();const p=Math.acos(Jt(r[y-1].dot(r[y]),-1,1));s[y].applyMatrix4(u.makeRotationAxis(l,p))}o[y].crossVectors(r[y],s[y])}if(t===!0){let y=Math.acos(Jt(s[0].dot(s[e]),-1,1));y/=e,r[0].dot(l.crossVectors(s[0],s[e]))>0&&(y=-y);for(let p=1;p<=e;p++)s[p].applyMatrix4(u.makeRotationAxis(r[p],y*p)),o[p].crossVectors(r[p],s[p])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const 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}}class Ta extends Mn{constructor(e=0,t=0,i=1,r=1,s=0,o=Math.PI*2,l=!1,u=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=l,this.aRotation=u}getPoint(e,t){const i=t||new Se,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);const l=this.aStartAngle+e*s;let u=this.aX+this.xRadius*Math.cos(l),c=this.aY+this.yRadius*Math.sin(l);if(this.aRotation!==0){const f=Math.cos(this.aRotation),h=Math.sin(this.aRotation),m=u-this.aX,y=c-this.aY;u=m*f-y*h+this.aX,c=m*h+y*f+this.aY}return i.set(u,c)}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(){const 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}}Ta.prototype.isEllipseCurve=!0;class Lh extends Ta{constructor(e,t,i,r,s,o){super(e,t,i,i,r,s,o),this.type="ArcCurve"}}Lh.prototype.isArcCurve=!0;function Rh(){let n=0,e=0,t=0,i=0;function r(s,o,l,u){n=s,e=l,t=-3*s+3*o-2*l-u,i=2*s-2*o+l+u}return{initCatmullRom:function(s,o,l,u,c){r(o,l,c*(l-s),c*(u-o))},initNonuniformCatmullRom:function(s,o,l,u,c,f,h){let m=(o-s)/c-(l-s)/(c+f)+(l-o)/f,y=(l-o)/f-(u-o)/(f+h)+(u-l)/h;m*=f,y*=f,r(o,l,m,y)},calc:function(s){const o=s*s,l=o*s;return n+e*s+t*o+i*l}}}const Ac=new X,Ph=new Rh,Ih=new Rh,Oh=new Rh;class Nh extends Mn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new X){const i=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e;let l=Math.floor(o),u=o-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s)+1)*s:u===0&&l===s-1&&(l=s-2,u=1);let c,f;this.closed||l>0?c=r[(l-1)%s]:(Ac.subVectors(r[0],r[1]).add(r[0]),c=Ac);const h=r[l%s],m=r[(l+1)%s];if(this.closed||l+2<s?f=r[(l+2)%s]:(Ac.subVectors(r[s-1],r[s-2]).add(r[s-1]),f=Ac),this.curveType==="centripetal"||this.curveType==="chordal"){const y=this.curveType==="chordal"?.5:.25;let p=Math.pow(c.distanceToSquared(h),y),d=Math.pow(h.distanceToSquared(m),y),b=Math.pow(m.distanceToSquared(f),y);d<1e-4&&(d=1),p<1e-4&&(p=d),b<1e-4&&(b=d),Ph.initNonuniformCatmullRom(c.x,h.x,m.x,f.x,p,d,b),Ih.initNonuniformCatmullRom(c.y,h.y,m.y,f.y,p,d,b),Oh.initNonuniformCatmullRom(c.z,h.z,m.z,f.z,p,d,b)}else this.curveType==="catmullrom"&&(Ph.initCatmullRom(c.x,h.x,m.x,f.x,this.tension),Ih.initCatmullRom(c.y,h.y,m.y,f.y,this.tension),Oh.initCatmullRom(c.z,h.z,m.z,f.z,this.tension));return i.set(Ph.calc(u),Ih.calc(u),Oh.calc(u)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.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,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new X().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}Nh.prototype.isCatmullRomCurve3=!0;function $v(n,e,t,i,r){const s=(i-e)*.5,o=(r-t)*.5,l=n*n,u=n*l;return(2*t-2*i+s+o)*u+(-3*t+3*i-2*s-o)*l+s*n+t}function uN(n,e){const t=1-n;return t*t*e}function dN(n,e){return 2*(1-n)*n*e}function hN(n,e){return n*n*e}function Ea(n,e,t,i){return uN(n,e)+dN(n,t)+hN(n,i)}function fN(n,e){const t=1-n;return t*t*t*e}function pN(n,e){const t=1-n;return 3*t*t*n*e}function mN(n,e){return 3*(1-n)*n*n*e}function gN(n,e){return n*n*n*e}function Ca(n,e,t,i,r){return fN(n,e)+pN(n,t)+mN(n,i)+gN(n,r)}class Lc extends Mn{constructor(e=new Se,t=new Se,i=new Se,r=new Se){super(),this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Se){const i=t,r=this.v0,s=this.v1,o=this.v2,l=this.v3;return i.set(Ca(e,r.x,s.x,o.x,l.x),Ca(e,r.y,s.y,o.y,l.y)),i}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(){const 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}}Lc.prototype.isCubicBezierCurve=!0;class Dh extends Mn{constructor(e=new X,t=new X,i=new X,r=new X){super(),this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new X){const i=t,r=this.v0,s=this.v1,o=this.v2,l=this.v3;return i.set(Ca(e,r.x,s.x,o.x,l.x),Ca(e,r.y,s.y,o.y,l.y),Ca(e,r.z,s.z,o.z,l.z)),i}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(){const 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}}Dh.prototype.isCubicBezierCurve3=!0;class Aa extends Mn{constructor(e=new Se,t=new Se){super(),this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Se){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const i=t||new Se;return i.copy(this.v2).sub(this.v1).normalize(),i}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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}}Aa.prototype.isLineCurve=!0;class Zv extends Mn{constructor(e=new X,t=new X){super(),this.type="LineCurve3",this.isLineCurve3=!0,this.v1=e,this.v2=t}getPoint(e,t=new X){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}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(){const 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}}class Rc extends Mn{constructor(e=new Se,t=new Se,i=new Se){super(),this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Se){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Ea(e,r.x,s.x,o.x),Ea(e,r.y,s.y,o.y)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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}}Rc.prototype.isQuadraticBezierCurve=!0;class Bh extends Mn{constructor(e=new X,t=new X,i=new X){super(),this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new X){const i=t,r=this.v0,s=this.v1,o=this.v2;return i.set(Ea(e,r.x,s.x,o.x),Ea(e,r.y,s.y,o.y),Ea(e,r.z,s.z,o.z)),i}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const 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}}Bh.prototype.isQuadraticBezierCurve3=!0;class Pc extends Mn{constructor(e=[]){super(),this.type="SplineCurve",this.points=e}getPoint(e,t=new Se){const i=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),l=s-o,u=r[o===0?o:o-1],c=r[o],f=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return i.set($v(l,u.x,c.x,f.x,h.x),$v(l,u.y,c.y,f.y,h.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new Se().fromArray(r))}return this}}Pc.prototype.isSplineCurve=!0;var Fh=Object.freeze({__proto__:null,ArcCurve:Lh,CatmullRomCurve3:Nh,CubicBezierCurve:Lc,CubicBezierCurve3:Dh,EllipseCurve:Ta,LineCurve:Aa,LineCurve3:Zv,QuadraticBezierCurve:Rc,QuadraticBezierCurve3:Bh,SplineCurve:Pc});const yN={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let s=Xv(n,0,r,t,!0);const o=[];if(!s||s.next===s.prev)return o;let l,u,c,f,h,m,y;if(i&&(s=MN(n,e,s,t)),n.length>80*t){l=c=n[0],u=f=n[1];for(let p=t;p<r;p+=t)h=n[p],m=n[p+1],h<l&&(l=h),m<u&&(u=m),h>c&&(c=h),m>f&&(f=m);y=Math.max(c-l,f-u),y=y!==0?1/y:0}return La(s,o,t,l,u,y),o}};function Xv(n,e,t,i,r){let s,o;if(r===ON(n,e,t,i)>0)for(s=e;s<t;s+=i)o=qv(s,n[s],n[s+1],o);else for(s=t-i;s>=e;s-=i)o=qv(s,n[s],n[s+1],o);return o&&Ic(o,o.next)&&(Pa(o),o=o.next),o}function vr(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Ic(t,t.next)||vt(t.prev,t,t.next)===0)){if(Pa(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function La(n,e,t,i,r,s,o){if(!n)return;!o&&s&&CN(n,i,r,s);let l=n,u,c;for(;n.prev!==n.next;){if(u=n.prev,c=n.next,s?bN(n,i,r,s):vN(n)){e.push(u.i/t),e.push(n.i/t),e.push(c.i/t),Pa(n),n=c.next,l=c.next;continue}if(n=c,n===l){o?o===1?(n=xN(vr(n),e,t),La(n,e,t,i,r,s,2)):o===2&&wN(n,e,t,i,r,s):La(vr(n),e,t,i,r,s,1);break}}}function vN(n){const e=n.prev,t=n,i=n.next;if(vt(e,t,i)>=0)return!1;let r=n.next.next;for(;r!==n.prev;){if(uo(e.x,e.y,t.x,t.y,i.x,i.y,r.x,r.y)&&vt(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function bN(n,e,t,i){const r=n.prev,s=n,o=n.next;if(vt(r,s,o)>=0)return!1;const l=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,u=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,c=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,f=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,h=Vh(l,u,e,t,i),m=Vh(c,f,e,t,i);let y=n.prevZ,p=n.nextZ;for(;y&&y.z>=h&&p&&p.z<=m;){if(y!==n.prev&&y!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,y.x,y.y)&&vt(y.prev,y,y.next)>=0||(y=y.prevZ,p!==n.prev&&p!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&vt(p.prev,p,p.next)>=0))return!1;p=p.nextZ}for(;y&&y.z>=h;){if(y!==n.prev&&y!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,y.x,y.y)&&vt(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;p&&p.z<=m;){if(p!==n.prev&&p!==n.next&&uo(r.x,r.y,s.x,s.y,o.x,o.y,p.x,p.y)&&vt(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function xN(n,e,t){let i=n;do{const r=i.prev,s=i.next.next;!Ic(r,s)&&Yv(r,i,i.next,s)&&Ra(r,s)&&Ra(s,r)&&(e.push(r.i/t),e.push(i.i/t),e.push(s.i/t),Pa(i),Pa(i.next),i=n=s),i=i.next}while(i!==n);return vr(i)}function wN(n,e,t,i,r,s){let o=n;do{let l=o.next.next;for(;l!==o.prev;){if(o.i!==l.i&&RN(o,l)){let u=Jv(o,l);o=vr(o,o.next),u=vr(u,u.next),La(o,e,t,i,r,s),La(u,e,t,i,r,s);return}l=l.next}o=o.next}while(o!==n)}function MN(n,e,t,i){const r=[];let s,o,l,u,c;for(s=0,o=e.length;s<o;s++)l=e[s]*i,u=s<o-1?e[s+1]*i:n.length,c=Xv(n,l,u,i,!1),c===c.next&&(c.steiner=!0),r.push(LN(c));for(r.sort(SN),s=0;s<r.length;s++)_N(r[s],t),t=vr(t,t.next);return t}function SN(n,e){return n.x-e.x}function _N(n,e){if(e=TN(n,e),e){const t=Jv(e,n);vr(e,e.next),vr(t,t.next)}}function TN(n,e){let t=e;const i=n.x,r=n.y;let s=-1/0,o;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const m=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=i&&m>s){if(s=m,m===i){if(r===t.y)return t;if(r===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(i===s)return o;const l=o,u=o.x,c=o.y;let f=1/0,h;t=o;do i>=t.x&&t.x>=u&&i!==t.x&&uo(r<c?i:s,r,u,c,r<c?s:i,r,t.x,t.y)&&(h=Math.abs(r-t.y)/(i-t.x),Ra(t,n)&&(h<f||h===f&&(t.x>o.x||t.x===o.x&&EN(o,t)))&&(o=t,f=h)),t=t.next;while(t!==l);return o}function EN(n,e){return vt(n.prev,n,e.prev)<0&&vt(e.next,n,n.next)<0}function CN(n,e,t,i){let r=n;do r.z===null&&(r.z=Vh(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,AN(r)}function AN(n){let e,t,i,r,s,o,l,u,c=1;do{for(t=n,n=null,s=null,o=0;t;){for(o++,i=t,l=0,e=0;e<c&&(l++,i=i.nextZ,!!i);e++);for(u=c;l>0||u>0&&i;)l!==0&&(u===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,l--):(r=i,i=i.nextZ,u--),s?s.nextZ=r:n=r,r.prevZ=s,s=r;t=i}s.nextZ=null,c*=2}while(o>1);return n}function Vh(n,e,t,i,r){return n=32767*(n-t)*r,e=32767*(e-i)*r,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function LN(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function uo(n,e,t,i,r,s,o,l){return(r-o)*(e-l)-(n-o)*(s-l)>=0&&(n-o)*(i-l)-(t-o)*(e-l)>=0&&(t-o)*(s-l)-(r-o)*(i-l)>=0}function RN(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!PN(n,e)&&(Ra(n,e)&&Ra(e,n)&&IN(n,e)&&(vt(n.prev,n,e.prev)||vt(n,e.prev,e))||Ic(n,e)&&vt(n.prev,n,n.next)>0&&vt(e.prev,e,e.next)>0)}function vt(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Ic(n,e){return n.x===e.x&&n.y===e.y}function Yv(n,e,t,i){const r=Nc(vt(n,e,t)),s=Nc(vt(n,e,i)),o=Nc(vt(t,i,n)),l=Nc(vt(t,i,e));return!!(r!==s&&o!==l||r===0&&Oc(n,t,e)||s===0&&Oc(n,i,e)||o===0&&Oc(t,n,i)||l===0&&Oc(t,e,i))}function Oc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function Nc(n){return n>0?1:n<0?-1:0}function PN(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&Yv(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Ra(n,e){return vt(n.prev,n,n.next)<0?vt(n,e,n.next)>=0&&vt(n,n.prev,e)>=0:vt(n,e,n.prev)<0||vt(n,n.next,e)<0}function IN(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function Jv(n,e){const t=new kh(n.i,n.x,n.y),i=new kh(e.i,e.x,e.y),r=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,s.next=i,i.prev=s,i}function qv(n,e,t,i){const r=new kh(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Pa(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function kh(n,e,t){this.i=n,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 ON(n,e,t,i){let r=0;for(let s=e,o=t-i;s<t;s+=i)r+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return r}class si{static area(e){const t=e.length;let i=0;for(let r=t-1,s=0;s<t;r=s++)i+=e[r].x*e[s].y-e[s].x*e[r].y;return i*.5}static isClockWise(e){return si.area(e)<0}static triangulateShape(e,t){const i=[],r=[],s=[];Kv(e),Qv(i,e);let o=e.length;t.forEach(Kv);for(let u=0;u<t.length;u++)r.push(o),o+=t[u].length,Qv(i,t[u]);const l=yN.triangulate(i,r);for(let u=0;u<l.length;u+=3)s.push(l.slice(u,u+3));return s}}function Kv(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function Qv(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class Hn extends Ve{constructor(e,t){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],s=[];for(let l=0,u=e.length;l<u;l++){const c=e[l];o(c)}this.setAttribute("position",new Oe(r,3)),this.setAttribute("uv",new Oe(s,2)),this.computeVertexNormals();function o(l){const u=[],c=t.curveSegments!==void 0?t.curveSegments:12,f=t.steps!==void 0?t.steps:1;let h=t.depth!==void 0?t.depth:100,m=t.bevelEnabled!==void 0?t.bevelEnabled:!0,y=t.bevelThickness!==void 0?t.bevelThickness:6,p=t.bevelSize!==void 0?t.bevelSize:y-2,d=t.bevelOffset!==void 0?t.bevelOffset:0,b=t.bevelSegments!==void 0?t.bevelSegments:3;const v=t.extrudePath,g=t.UVGenerator!==void 0?t.UVGenerator:NN;t.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),h=t.amount);let M,_=!1,E,S,w,T;v&&(M=v.getSpacedPoints(f),_=!0,m=!1,E=v.computeFrenetFrames(f,!1),S=new X,w=new X,T=new X),m||(b=0,y=0,p=0,d=0);const C=l.extractPoints(c);let R=C.shape;const P=C.holes;if(!si.isClockWise(R)){R=R.reverse();for(let Y=0,te=P.length;Y<te;Y++){const F=P[Y];si.isClockWise(F)&&(P[Y]=F.reverse())}}const A=si.triangulateShape(R,P),I=R;for(let Y=0,te=P.length;Y<te;Y++){const F=P[Y];R=R.concat(F)}function O(Y,te,F){return te||console.error("THREE.ExtrudeGeometry: vec does not exist"),te.clone().multiplyScalar(F).add(Y)}const x=R.length,N=A.length;function B(Y,te,F){let $,J,k;const U=Y.x-te.x,oe=Y.y-te.y,le=F.x-Y.x,ae=F.y-Y.y,fe=U*U+oe*oe,ge=U*ae-oe*le;if(Math.abs(ge)>Number.EPSILON){const we=Math.sqrt(fe),ue=Math.sqrt(le*le+ae*ae),ye=te.x-oe/we,se=te.y+U/we,be=F.x-ae/ue,he=F.y+le/ue,me=((be-ye)*ae-(he-se)*le)/(U*ae-oe*le);$=ye+U*me-Y.x,J=se+oe*me-Y.y;const Te=$*$+J*J;if(Te<=2)return new Se($,J);k=Math.sqrt(Te/2)}else{let we=!1;U>Number.EPSILON?le>Number.EPSILON&&(we=!0):U<-Number.EPSILON?le<-Number.EPSILON&&(we=!0):Math.sign(oe)===Math.sign(ae)&&(we=!0),we?($=-oe,J=U,k=Math.sqrt(fe)):($=U,J=oe,k=Math.sqrt(fe/2))}return new Se($/k,J/k)}const D=[];for(let Y=0,te=I.length,F=te-1,$=Y+1;Y<te;Y++,F++,$++)F===te&&(F=0),$===te&&($=0),D[Y]=B(I[Y],I[F],I[$]);const V=[];let z,G=D.concat();for(let Y=0,te=P.length;Y<te;Y++){const F=P[Y];z=[];for(let $=0,J=F.length,k=J-1,U=$+1;$<J;$++,k++,U++)k===J&&(k=0),U===J&&(U=0),z[$]=B(F[$],F[k],F[U]);V.push(z),G=G.concat(z)}for(let Y=0;Y<b;Y++){const te=Y/b,F=y*Math.cos(te*Math.PI/2),$=p*Math.sin(te*Math.PI/2)+d;for(let J=0,k=I.length;J<k;J++){const U=O(I[J],D[J],$);W(U.x,U.y,-F)}for(let J=0,k=P.length;J<k;J++){const U=P[J];z=V[J];for(let oe=0,le=U.length;oe<le;oe++){const ae=O(U[oe],z[oe],$);W(ae.x,ae.y,-F)}}}const K=p+d;for(let Y=0;Y<x;Y++){const te=m?O(R[Y],G[Y],K):R[Y];_?(w.copy(E.normals[0]).multiplyScalar(te.x),S.copy(E.binormals[0]).multiplyScalar(te.y),T.copy(M[0]).add(w).add(S),W(T.x,T.y,T.z)):W(te.x,te.y,0)}for(let Y=1;Y<=f;Y++)for(let te=0;te<x;te++){const F=m?O(R[te],G[te],K):R[te];_?(w.copy(E.normals[Y]).multiplyScalar(F.x),S.copy(E.binormals[Y]).multiplyScalar(F.y),T.copy(M[Y]).add(w).add(S),W(T.x,T.y,T.z)):W(F.x,F.y,h/f*Y)}for(let Y=b-1;Y>=0;Y--){const te=Y/b,F=y*Math.cos(te*Math.PI/2),$=p*Math.sin(te*Math.PI/2)+d;for(let J=0,k=I.length;J<k;J++){const U=O(I[J],D[J],$);W(U.x,U.y,h+F)}for(let J=0,k=P.length;J<k;J++){const U=P[J];z=V[J];for(let oe=0,le=U.length;oe<le;oe++){const ae=O(U[oe],z[oe],$);_?W(ae.x,ae.y+M[f-1].y,M[f-1].x+F):W(ae.x,ae.y,h+F)}}}ie(),j();function ie(){const Y=r.length/3;if(m){let te=0,F=x*te;for(let $=0;$<N;$++){const J=A[$];q(J[2]+F,J[1]+F,J[0]+F)}te=f+b*2,F=x*te;for(let $=0;$<N;$++){const J=A[$];q(J[0]+F,J[1]+F,J[2]+F)}}else{for(let te=0;te<N;te++){const F=A[te];q(F[2],F[1],F[0])}for(let te=0;te<N;te++){const F=A[te];q(F[0]+x*f,F[1]+x*f,F[2]+x*f)}}i.addGroup(Y,r.length/3-Y,0)}function j(){const Y=r.length/3;let te=0;H(I,te),te+=I.length;for(let F=0,$=P.length;F<$;F++){const J=P[F];H(J,te),te+=J.length}i.addGroup(Y,r.length/3-Y,1)}function H(Y,te){let F=Y.length;for(;--F>=0;){const $=F;let J=F-1;J<0&&(J=Y.length-1);for(let k=0,U=f+b*2;k<U;k++){const oe=x*k,le=x*(k+1),ae=te+$+oe,fe=te+J+oe,ge=te+J+le,we=te+$+le;Q(ae,fe,ge,we)}}}function W(Y,te,F){u.push(Y),u.push(te),u.push(F)}function q(Y,te,F){ee(Y),ee(te),ee(F);const $=r.length/3,J=g.generateTopUV(i,r,$-3,$-2,$-1);ne(J[0]),ne(J[1]),ne(J[2])}function Q(Y,te,F,$){ee(Y),ee(te),ee($),ee(te),ee(F),ee($);const J=r.length/3,k=g.generateSideWallUV(i,r,J-6,J-3,J-2,J-1);ne(k[0]),ne(k[1]),ne(k[3]),ne(k[1]),ne(k[2]),ne(k[3])}function ee(Y){r.push(u[Y*3+0]),r.push(u[Y*3+1]),r.push(u[Y*3+2])}function ne(Y){s.push(Y.x),s.push(Y.y)}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return DN(t,i,e)}static fromJSON(e,t){const i=[];for(let s=0,o=e.shapes.length;s<o;s++){const l=t[e.shapes[s]];i.push(l)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Fh[r.type]().fromJSON(r)),new Hn(i,e.options)}}const NN={generateTopUV:function(n,e,t,i,r){const s=e[t*3],o=e[t*3+1],l=e[i*3],u=e[i*3+1],c=e[r*3],f=e[r*3+1];return[new Se(s,o),new Se(l,u),new Se(c,f)]},generateSideWallUV:function(n,e,t,i,r,s){const o=e[t*3],l=e[t*3+1],u=e[t*3+2],c=e[i*3],f=e[i*3+1],h=e[i*3+2],m=e[r*3],y=e[r*3+1],p=e[r*3+2],d=e[s*3],b=e[s*3+1],v=e[s*3+2];return Math.abs(l-f)<Math.abs(o-c)?[new Se(o,1-u),new Se(c,1-h),new Se(m,1-p),new Se(d,1-v)]:[new Se(l,1-u),new Se(f,1-h),new Se(y,1-p),new Se(b,1-v)]}};function DN(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const s=n[i];t.shapes.push(s.uuid)}else t.shapes.push(n.uuid);return e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class ho extends ri{constructor(e=1,t=0){const i=(1+Math.sqrt(5))/2,r=[-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],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(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ho(e.radius,e.detail)}}class fo extends Ve{constructor(e,t=12,i=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Jt(r,0,Math.PI*2);const s=[],o=[],l=[],u=1/t,c=new X,f=new Se;for(let h=0;h<=t;h++){const m=i+h*u*r,y=Math.sin(m),p=Math.cos(m);for(let d=0;d<=e.length-1;d++)c.x=e[d].x*y,c.y=e[d].y,c.z=e[d].x*p,o.push(c.x,c.y,c.z),f.x=h/t,f.y=d/(e.length-1),l.push(f.x,f.y)}for(let h=0;h<t;h++)for(let m=0;m<e.length-1;m++){const y=m+h*e.length,p=y,d=y+e.length,b=y+e.length+1,v=y+1;s.push(p,d,v),s.push(d,b,v)}if(this.setIndex(s),this.setAttribute("position",new Oe(o,3)),this.setAttribute("uv",new Oe(l,2)),this.computeVertexNormals(),r===Math.PI*2){const h=this.attributes.normal.array,m=new X,y=new X,p=new X,d=t*e.length*3;for(let b=0,v=0;b<e.length;b++,v+=3)m.x=h[v+0],m.y=h[v+1],m.z=h[v+2],y.x=h[d+v+0],y.y=h[d+v+1],y.z=h[d+v+2],p.addVectors(m,y).normalize(),h[v+0]=h[d+v+0]=p.x,h[v+1]=h[d+v+1]=p.y,h[v+2]=h[d+v+2]=p.z}}static fromJSON(e){return new fo(e.points,e.segments,e.phiStart,e.phiLength)}}class Yr extends ri{constructor(e=1,t=0){const i=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(i,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Yr(e.radius,e.detail)}}class Dc extends Ve{constructor(e,t,i){super(),this.type="ParametricGeometry",this.parameters={func:e,slices:t,stacks:i};const r=[],s=[],o=[],l=[],u=1e-5,c=new X,f=new X,h=new X,m=new X,y=new X;e.length<3&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");const p=t+1;for(let d=0;d<=i;d++){const b=d/i;for(let v=0;v<=t;v++){const g=v/t;e(g,b,f),s.push(f.x,f.y,f.z),g-u>=0?(e(g-u,b,h),m.subVectors(f,h)):(e(g+u,b,h),m.subVectors(h,f)),b-u>=0?(e(g,b-u,h),y.subVectors(f,h)):(e(g,b+u,h),y.subVectors(h,f)),c.crossVectors(m,y).normalize(),o.push(c.x,c.y,c.z),l.push(g,b)}}for(let d=0;d<i;d++)for(let b=0;b<t;b++){const v=d*p+b,g=d*p+b+1,M=(d+1)*p+b+1,_=(d+1)*p+b;r.push(v,g,_),r.push(g,M,_)}this.setIndex(r),this.setAttribute("position",new Oe(s,3)),this.setAttribute("normal",new Oe(o,3)),this.setAttribute("uv",new Oe(l,2))}}class po extends Ve{constructor(e=.5,t=1,i=8,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:s,thetaLength:o},i=Math.max(3,i),r=Math.max(1,r);const l=[],u=[],c=[],f=[];let h=e;const m=(t-e)/r,y=new X,p=new Se;for(let d=0;d<=r;d++){for(let b=0;b<=i;b++){const v=s+b/i*o;y.x=h*Math.cos(v),y.y=h*Math.sin(v),u.push(y.x,y.y,y.z),c.push(0,0,1),p.x=(y.x/t+1)/2,p.y=(y.y/t+1)/2,f.push(p.x,p.y)}h+=m}for(let d=0;d<r;d++){const b=d*(i+1);for(let v=0;v<i;v++){const g=v+b,M=g,_=g+i+1,E=g+i+2,S=g+1;l.push(M,_,S),l.push(_,E,S)}}this.setIndex(l),this.setAttribute("position",new Oe(u,3)),this.setAttribute("normal",new Oe(c,3)),this.setAttribute("uv",new Oe(f,2))}static fromJSON(e){return new po(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Jr extends Ve{constructor(e,t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],s=[],o=[];let l=0,u=0;if(Array.isArray(e)===!1)c(e);else for(let f=0;f<e.length;f++)c(e[f]),this.addGroup(l,u,f),l+=u,u=0;this.setIndex(i),this.setAttribute("position",new Oe(r,3)),this.setAttribute("normal",new Oe(s,3)),this.setAttribute("uv",new Oe(o,2));function c(f){const h=r.length/3,m=f.extractPoints(t);let y=m.shape;const p=m.holes;si.isClockWise(y)===!1&&(y=y.reverse());for(let b=0,v=p.length;b<v;b++){const g=p[b];si.isClockWise(g)===!0&&(p[b]=g.reverse())}const d=si.triangulateShape(y,p);for(let b=0,v=p.length;b<v;b++){const g=p[b];y=y.concat(g)}for(let b=0,v=y.length;b<v;b++){const g=y[b];r.push(g.x,g.y,0),s.push(0,0,1),o.push(g.x,g.y)}for(let b=0,v=d.length;b<v;b++){const g=d[b],M=g[0]+h,_=g[1]+h,E=g[2]+h;i.push(M,_,E),u+=3}}}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return BN(t,e)}static fromJSON(e,t){const i=[];for(let r=0,s=e.shapes.length;r<s;r++){const o=t[e.shapes[r]];i.push(o)}return new Jr(i,e.curveSegments)}}function BN(n,e){if(e.shapes=[],Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const r=n[t];e.shapes.push(r.uuid)}else e.shapes.push(n.uuid);return e}class qr extends Ve{constructor(e=1,t=8,i=6,r=0,s=Math.PI*2,o=0,l=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:o,thetaLength:l},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const u=Math.min(o+l,Math.PI);let c=0;const f=[],h=new X,m=new X,y=[],p=[],d=[],b=[];for(let v=0;v<=i;v++){const g=[],M=v/i;let _=0;v==0&&o==0?_=.5/t:v==i&&u==Math.PI&&(_=-.5/t);for(let E=0;E<=t;E++){const S=E/t;h.x=-e*Math.cos(r+S*s)*Math.sin(o+M*l),h.y=e*Math.cos(o+M*l),h.z=e*Math.sin(r+S*s)*Math.sin(o+M*l),p.push(h.x,h.y,h.z),m.copy(h).normalize(),d.push(m.x,m.y,m.z),b.push(S+_,1-M),g.push(c++)}f.push(g)}for(let v=0;v<i;v++)for(let g=0;g<t;g++){const M=f[v][g+1],_=f[v][g],E=f[v+1][g],S=f[v+1][g+1];(v!==0||o>0)&&y.push(M,_,S),(v!==i-1||u<Math.PI)&&y.push(_,E,S)}this.setIndex(y),this.setAttribute("position",new Oe(p,3)),this.setAttribute("normal",new Oe(d,3)),this.setAttribute("uv",new Oe(b,2))}static fromJSON(e){return new qr(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class mo extends ri{constructor(e=1,t=0){const i=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(i,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new mo(e.radius,e.detail)}}class Bc extends Hn{constructor(e,t={}){const i=t.font;if(!(i&&i.isFont))return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Ve;const r=i.generateShapes(e,t.size);t.depth=t.height!==void 0?t.height:50,t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(r,t),this.type="TextGeometry"}}class go extends Ve{constructor(e=1,t=.4,i=8,r=6,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:s},i=Math.floor(i),r=Math.floor(r);const o=[],l=[],u=[],c=[],f=new X,h=new X,m=new X;for(let y=0;y<=i;y++)for(let p=0;p<=r;p++){const d=p/r*s,b=y/i*Math.PI*2;h.x=(e+t*Math.cos(b))*Math.cos(d),h.y=(e+t*Math.cos(b))*Math.sin(d),h.z=t*Math.sin(b),l.push(h.x,h.y,h.z),f.x=e*Math.cos(d),f.y=e*Math.sin(d),m.subVectors(h,f).normalize(),u.push(m.x,m.y,m.z),c.push(p/r),c.push(y/i)}for(let y=1;y<=i;y++)for(let p=1;p<=r;p++){const d=(r+1)*y+p-1,b=(r+1)*(y-1)+p-1,v=(r+1)*(y-1)+p,g=(r+1)*y+p;o.push(d,b,g),o.push(b,v,g)}this.setIndex(o),this.setAttribute("position",new Oe(l,3)),this.setAttribute("normal",new Oe(u,3)),this.setAttribute("uv",new Oe(c,2))}static fromJSON(e){return new go(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class yo extends Ve{constructor(e=1,t=.4,i=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:s,q:o},i=Math.floor(i),r=Math.floor(r);const l=[],u=[],c=[],f=[],h=new X,m=new X,y=new X,p=new X,d=new X,b=new X,v=new X;for(let M=0;M<=i;++M){const _=M/i*s*Math.PI*2;g(_,s,o,e,y),g(_+.01,s,o,e,p),b.subVectors(p,y),v.addVectors(p,y),d.crossVectors(b,v),v.crossVectors(d,b),d.normalize(),v.normalize();for(let E=0;E<=r;++E){const S=E/r*Math.PI*2,w=-t*Math.cos(S),T=t*Math.sin(S);h.x=y.x+(w*v.x+T*d.x),h.y=y.y+(w*v.y+T*d.y),h.z=y.z+(w*v.z+T*d.z),u.push(h.x,h.y,h.z),m.subVectors(h,y).normalize(),c.push(m.x,m.y,m.z),f.push(M/i),f.push(E/r)}}for(let M=1;M<=i;M++)for(let _=1;_<=r;_++){const E=(r+1)*(M-1)+(_-1),S=(r+1)*M+(_-1),w=(r+1)*M+_,T=(r+1)*(M-1)+_;l.push(E,S,T),l.push(S,w,T)}this.setIndex(l),this.setAttribute("position",new Oe(u,3)),this.setAttribute("normal",new Oe(c,3)),this.setAttribute("uv",new Oe(f,2));function g(M,_,E,S,w){const T=Math.cos(M),C=Math.sin(M),R=E/_*M,P=Math.cos(R);w.x=S*(2+P)*.5*T,w.y=S*(2+P)*C*.5,w.z=S*Math.sin(R)*.5}}static fromJSON(e){return new yo(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class vo extends Ve{constructor(e,t=64,i=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:s};const o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const l=new X,u=new X,c=new Se;let f=new X;const h=[],m=[],y=[],p=[];d(),this.setIndex(p),this.setAttribute("position",new Oe(h,3)),this.setAttribute("normal",new Oe(m,3)),this.setAttribute("uv",new Oe(y,2));function d(){for(let M=0;M<t;M++)b(M);b(s===!1?t:0),g(),v()}function b(M){f=e.getPointAt(M/t,f);const _=o.normals[M],E=o.binormals[M];for(let S=0;S<=r;S++){const w=S/r*Math.PI*2,T=Math.sin(w),C=-Math.cos(w);u.x=C*_.x+T*E.x,u.y=C*_.y+T*E.y,u.z=C*_.z+T*E.z,u.normalize(),m.push(u.x,u.y,u.z),l.x=f.x+i*u.x,l.y=f.y+i*u.y,l.z=f.z+i*u.z,h.push(l.x,l.y,l.z)}}function v(){for(let M=1;M<=t;M++)for(let _=1;_<=r;_++){const E=(r+1)*(M-1)+(_-1),S=(r+1)*M+(_-1),w=(r+1)*M+_,T=(r+1)*(M-1)+_;p.push(E,S,T),p.push(S,w,T)}}function g(){for(let M=0;M<=t;M++)for(let _=0;_<=r;_++)c.x=M/t,c.y=_/r,y.push(c.x,c.y)}}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new vo(new Fh[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class zh extends Ve{constructor(e){if(super(),this.type="WireframeGeometry",e.isGeometry===!0){console.error("THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return}const t=[],i=[0,0],r={},s=new X;if(e.index!==null){const o=e.attributes.position,l=e.index;let u=e.groups;u.length===0&&(u=[{start:0,count:l.count,materialIndex:0}]);for(let c=0,f=u.length;c<f;++c){const h=u[c],m=h.start,y=h.count;for(let p=m,d=m+y;p<d;p+=3)for(let b=0;b<3;b++){const v=l.getX(p+b),g=l.getX(p+(b+1)%3);i[0]=Math.min(v,g),i[1]=Math.max(v,g);const M=i[0]+","+i[1];r[M]===void 0&&(r[M]={index1:i[0],index2:i[1]})}}for(const c in r){const f=r[c];s.fromBufferAttribute(o,f.index1),t.push(s.x,s.y,s.z),s.fromBufferAttribute(o,f.index2),t.push(s.x,s.y,s.z)}}else{const o=e.attributes.position;for(let l=0,u=o.count/3;l<u;l++)for(let c=0;c<3;c++){const f=3*l+c;s.fromBufferAttribute(o,f),t.push(s.x,s.y,s.z);const h=3*l+(c+1)%3;s.fromBufferAttribute(o,h),t.push(s.x,s.y,s.z)}}this.setAttribute("position",new Oe(t,3))}}var eb=Object.freeze({__proto__:null,BoxGeometry:Ni,BoxBufferGeometry:Ni,CircleGeometry:ao,CircleBufferGeometry:ao,ConeGeometry:lo,ConeBufferGeometry:lo,CylinderGeometry:yr,CylinderBufferGeometry:yr,DodecahedronGeometry:co,DodecahedronBufferGeometry:co,EdgesGeometry:Ah,ExtrudeGeometry:Hn,ExtrudeBufferGeometry:Hn,IcosahedronGeometry:ho,IcosahedronBufferGeometry:ho,LatheGeometry:fo,LatheBufferGeometry:fo,OctahedronGeometry:Yr,OctahedronBufferGeometry:Yr,ParametricGeometry:Dc,ParametricBufferGeometry:Dc,PlaneGeometry:Zr,PlaneBufferGeometry:Zr,PolyhedronGeometry:ri,PolyhedronBufferGeometry:ri,RingGeometry:po,RingBufferGeometry:po,ShapeGeometry:Jr,ShapeBufferGeometry:Jr,SphereGeometry:qr,SphereBufferGeometry:qr,TetrahedronGeometry:mo,TetrahedronBufferGeometry:mo,TextGeometry:Bc,TextBufferGeometry:Bc,TorusGeometry:go,TorusBufferGeometry:go,TorusKnotGeometry:yo,TorusKnotBufferGeometry:yo,TubeGeometry:vo,TubeBufferGeometry:vo,WireframeGeometry:zh});class Uh extends Vt{constructor(e){super(),this.type="ShadowMaterial",this.color=new Ae(0),this.transparent=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this}}Uh.prototype.isShadowMaterial=!0;class bo extends Di{constructor(e){super(e),this.type="RawShaderMaterial"}}bo.prototype.isRawShaderMaterial=!0;class Kr extends Vt{constructor(e){super(),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ae(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.vertexTangents=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this}}Kr.prototype.isMeshStandardMaterial=!0;class Ia extends Kr{constructor(e){super(),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Se(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,Object.defineProperty(this,"ior",{get:function(){return(1+.4*this.reflectivity)/(1-.4*this.reflectivity)},set:function(t){this.reflectivity=Jt(2.5*(t-1)/(t+1),0,1)}}),this.sheen=null,this.transmission=0,this.transmissionMap=null,this.thickness=.01,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Ae(1,1,1),this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.reflectivity=e.reflectivity,e.sheen?this.sheen=(this.sheen||new Ae).copy(e.sheen):this.sheen=null,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this}}Ia.prototype.isMeshPhysicalMaterial=!0;class Gh extends Vt{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new Ae(16777215),this.specular=new Ae(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Yo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,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.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}Gh.prototype.isMeshPhongMaterial=!0;class Hh extends Vt{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ae(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this}}Hh.prototype.isMeshToonMaterial=!0;class Wh extends Vt{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}Wh.prototype.isMeshNormalMaterial=!0;class jh extends Vt{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Yo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.morphTargets=!1,this.morphNormals=!1,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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,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.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this}}jh.prototype.isMeshLambertMaterial=!0;class $h extends Vt{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ae(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rr,this.normalScale=new Se(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.morphTargets=!1,this.morphNormals=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.flatShading=e.flatShading,this}}$h.prototype.isMeshMatcapMaterial=!0;class Zh extends Ut{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}Zh.prototype.isLineDashedMaterial=!0;var FN=Object.freeze({__proto__:null,ShadowMaterial:Uh,SpriteMaterial:ga,RawShaderMaterial:bo,ShaderMaterial:Di,PointsMaterial:gr,MeshPhysicalMaterial:Ia,MeshStandardMaterial:Kr,MeshPhongMaterial:Gh,MeshToonMaterial:Hh,MeshNormalMaterial:Wh,MeshLambertMaterial:jh,MeshDepthMaterial:fc,MeshDistanceMaterial:pc,MeshBasicMaterial:mn,MeshMatcapMaterial:$h,LineDashedMaterial:Zh,LineBasicMaterial:Ut,Material:Vt});const ft={arraySlice:function(n,e,t){return ft.isTypedArray(n)?new n.constructor(n.subarray(e,t!==void 0?t:n.length)):n.slice(e,t)},convertArray:function(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)},isTypedArray:function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},getKeyframeOrder:function(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i},sortedArray:function(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const l=t[s]*e;for(let u=0;u!==e;++u)r[o++]=n[l+u]}return r},flattenJSON:function(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)},subclip:function(n,e,t,i,r=30){const s=n.clone();s.name=e;const o=[];for(let u=0;u<s.tracks.length;++u){const c=s.tracks[u],f=c.getValueSize(),h=[],m=[];for(let y=0;y<c.times.length;++y){const p=c.times[y]*r;if(!(p<t||p>=i)){h.push(c.times[y]);for(let d=0;d<f;++d)m.push(c.values[y*f+d])}}h.length!==0&&(c.times=ft.convertArray(h,c.times.constructor),c.values=ft.convertArray(m,c.values.constructor),o.push(c))}s.tracks=o;let l=1/0;for(let u=0;u<s.tracks.length;++u)l>s.tracks[u].times[0]&&(l=s.tracks[u].times[0]);for(let u=0;u<s.tracks.length;++u)s.tracks[u].shift(-1*l);return s.resetDuration(),s},makeClipAdditive:function(n,e=0,t=n,i=30){i<=0&&(i=30);const r=t.tracks.length,s=e/i;for(let o=0;o<r;++o){const l=t.tracks[o],u=l.ValueTypeName;if(u==="bool"||u==="string")continue;const c=n.tracks.find(function(v){return v.name===l.name&&v.ValueTypeName===u});if(c===void 0)continue;let f=0;const h=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=h/3);let m=0;const y=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(m=y/3);const p=l.times.length-1;let d;if(s<=l.times[0]){const v=f,g=h-f;d=ft.arraySlice(l.values,v,g)}else if(s>=l.times[p]){const v=p*h+f,g=v+h-f;d=ft.arraySlice(l.values,v,g)}else{const v=l.createInterpolant(),g=f,M=h-f;v.evaluate(s),d=ft.arraySlice(v.resultBuffer,g,M)}u==="quaternion"&&new qt().fromArray(d).normalize().conjugate().toArray(d);const b=c.times.length;for(let v=0;v<b;++v){const g=v*y+m;if(u==="quaternion")qt.multiplyQuaternionsFlat(c.values,g,d,0,c.values,g);else{const M=y-m*2;for(let _=0;_<M;++_)c.values[g+_]-=d[_]}}}return n.blendMode=Bd,n}};class oi{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e<r)){for(let l=i+2;;){if(r===void 0){if(e<s)break i;return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,e,s)}if(i===l)break;if(s=r,r=t[++i],e<r)break t}o=t.length;break n}if(!(e>=s)){const l=t[1];e<l&&(i=2,s=l);for(let u=i-2;;){if(s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(i===u)break;if(r=s,s=t[--i-1],e>=s)break t}o=i,i=0;break n}break e}for(;i<o;){const l=i+o>>>1;e<t[l]?o=l:i=l+1}if(r=t[i],s=t[i-1],s===void 0)return this._cachedIndex=0,this.beforeStart_(0,e,r);if(r===void 0)return i=t.length,this._cachedIndex=i,this.afterEnd_(i-1,s,e)}this._cachedIndex=i,this.intervalChanged_(i,s,r)}return this.interpolate_(i,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=i[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}oi.prototype.beforeStart_=oi.prototype.copySampleValue_,oi.prototype.afterEnd_=oi.prototype.copySampleValue_;class tb extends oi{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:kr,endingEnd:kr}}intervalChanged_(e,t,i){const r=this.parameterPositions;let s=e-2,o=e+1,l=r[s],u=r[o];if(l===void 0)switch(this.getSettings_().endingStart){case zr:s=e,l=2*t-i;break;case ia:s=r.length-2,l=t+r[s]-r[s+1];break;default:s=e,l=i}if(u===void 0)switch(this.getSettings_().endingEnd){case zr:o=e,u=2*i-t;break;case ia:o=1,u=i+r[1]-r[0];break;default:o=e-1,u=t}const c=(i-t)*.5,f=this.valueSize;this._weightPrev=c/(t-l),this._weightNext=c/(u-i),this._offsetPrev=s*f,this._offsetNext=o*f}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=e*l,c=u-l,f=this._offsetPrev,h=this._offsetNext,m=this._weightPrev,y=this._weightNext,p=(i-t)/(r-t),d=p*p,b=d*p,v=-m*b+2*m*d-m*p,g=(1+m)*b+(-1.5-2*m)*d+(-.5+m)*p+1,M=(-1-y)*b+(1.5+y)*d+.5*p,_=y*b-y*d;for(let E=0;E!==l;++E)s[E]=v*o[f+E]+g*o[c+E]+M*o[u+E]+_*o[h+E];return s}}class Xh extends oi{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=e*l,c=u-l,f=(i-t)/(r-t),h=1-f;for(let m=0;m!==l;++m)s[m]=o[c+m]*h+o[u+m]*f;return s}}class nb extends oi{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Wn{constructor(e,t,i,r){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=ft.convertArray(t,this.TimeBufferType),this.values=ft.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:ft.convertArray(e.times,Array),values:ft.convertArray(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new nb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Xh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new tb(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bs:t=this.InterpolantFactoryMethodDiscrete;break;case Vr:t=this.InterpolantFactoryMethodLinear;break;case zl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="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(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bs;case this.InterpolantFactoryMethodLinear:return Vr;case this.InterpolantFactoryMethodSmooth:return zl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let s=0,o=r-1;for(;s!==r&&i[s]<e;)++s;for(;o!==-1&&i[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const l=this.getValueSize();this.times=ft.arraySlice(i,s,o),this.values=ft.arraySlice(this.values,s*l,o*l)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let l=0;l!==s;l++){const u=i[l];if(typeof u=="number"&&isNaN(u)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,l,u),e=!1;break}if(o!==null&&o>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,l,u,o),e=!1;break}o=u}if(r!==void 0&&ft.isTypedArray(r))for(let l=0,u=r.length;l!==u;++l){const c=r[l];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,l,c),e=!1;break}}return e}optimize(){const e=ft.arraySlice(this.times),t=ft.arraySlice(this.values),i=this.getValueSize(),r=this.getInterpolation()===zl,s=e.length-1;let o=1;for(let l=1;l<s;++l){let u=!1;const c=e[l],f=e[l+1];if(c!==f&&(l!==1||c!==e[0]))if(r)u=!0;else{const h=l*i,m=h-i,y=h+i;for(let p=0;p!==i;++p){const d=t[h+p];if(d!==t[m+p]||d!==t[y+p]){u=!0;break}}}if(u){if(l!==o){e[o]=e[l];const h=l*i,m=o*i;for(let y=0;y!==i;++y)t[m+y]=t[h+y]}++o}}if(s>0){e[o]=e[s];for(let l=s*i,u=o*i,c=0;c!==i;++c)t[u+c]=t[l+c];++o}return o!==e.length?(this.times=ft.arraySlice(e,0,o),this.values=ft.arraySlice(t,0,o*i)):(this.times=e,this.values=t),this}clone(){const e=ft.arraySlice(this.times,0),t=ft.arraySlice(this.values,0),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Wn.prototype.TimeBufferType=Float32Array,Wn.prototype.ValueBufferType=Float32Array,Wn.prototype.DefaultInterpolation=Vr;class Qr extends Wn{}Qr.prototype.ValueTypeName="bool",Qr.prototype.ValueBufferType=Array,Qr.prototype.DefaultInterpolation=Bs,Qr.prototype.InterpolantFactoryMethodLinear=void 0,Qr.prototype.InterpolantFactoryMethodSmooth=void 0;class Yh extends Wn{}Yh.prototype.ValueTypeName="color";class xo extends Wn{}xo.prototype.ValueTypeName="number";class ib extends oi{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=(i-t)/(r-t);let c=e*l;for(let f=c+l;c!==f;c+=4)qt.slerpFlat(s,0,o,c-l,o,c,u);return s}}class es extends Wn{InterpolantFactoryMethodLinear(e){return new ib(this.times,this.values,this.getValueSize(),e)}}es.prototype.ValueTypeName="quaternion",es.prototype.DefaultInterpolation=Vr,es.prototype.InterpolantFactoryMethodSmooth=void 0;class ts extends Wn{}ts.prototype.ValueTypeName="string",ts.prototype.ValueBufferType=Array,ts.prototype.DefaultInterpolation=Bs,ts.prototype.InterpolantFactoryMethodLinear=void 0,ts.prototype.InterpolantFactoryMethodSmooth=void 0;class wo extends Wn{}wo.prototype.ValueTypeName="vector";class Mo{constructor(e,t=-1,i,r=Ul){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=bn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,l=i.length;o!==l;++o)t.push(kN(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(Wn.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let l=0;l<s;l++){let u=[],c=[];u.push((l+s-1)%s,l,(l+1)%s),c.push(0,1,0);const f=ft.getKeyframeOrder(u);u=ft.sortedArray(u,1,f),c=ft.sortedArray(c,1,f),!r&&u[0]===0&&(u.push(s),c.push(c[0])),o.push(new xo(".morphTargetInfluences["+t[l].name+"]",u,c).scale(1/i))}return new this(e,-1,o)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},s=/^([\w-]*?)([\d]+)$/;for(let l=0,u=e.length;l<u;l++){const c=e[l],f=c.name.match(s);if(f&&f.length>1){const h=f[1];let m=r[h];m||(r[h]=m=[]),m.push(c)}}const o=[];for(const l in r)o.push(this.CreateFromMorphTargetSequence(l,r[l],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(h,m,y,p,d){if(y.length!==0){const b=[],v=[];ft.flattenJSON(y,b,v,p),b.length!==0&&d.push(new h(m,b,v))}},r=[],s=e.name||"default",o=e.fps||30,l=e.blendMode;let u=e.length||-1;const c=e.hierarchy||[];for(let h=0;h<c.length;h++){const m=c[h].keys;if(!(!m||m.length===0))if(m[0].morphTargets){const y={};let p;for(p=0;p<m.length;p++)if(m[p].morphTargets)for(let d=0;d<m[p].morphTargets.length;d++)y[m[p].morphTargets[d]]=-1;for(const d in y){const b=[],v=[];for(let g=0;g!==m[p].morphTargets.length;++g){const M=m[p];b.push(M.time),v.push(M.morphTarget===d?1:0)}r.push(new xo(".morphTargetInfluence["+d+"]",b,v))}u=y.length*(o||1)}else{const y=".bones["+t[h].name+"]";i(wo,y+".position",m,"pos",r),i(es,y+".quaternion",m,"rot",r),i(wo,y+".scale",m,"scl",r)}}return r.length===0?null:new this(s,u,r,l)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const s=this.tracks[i];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function VN(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return xo;case"vector":case"vector2":case"vector3":case"vector4":return wo;case"color":return Yh;case"quaternion":return es;case"bool":case"boolean":return Qr;case"string":return ts}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function kN(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=VN(n.type);if(n.times===void 0){const t=[],i=[];ft.flattenJSON(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const ns={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class Jh{constructor(e,t,i){const r=this;let s=!1,o=0,l=0,u;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(f){l++,s===!1&&r.onStart!==void 0&&r.onStart(f,o,l),s=!0},this.itemEnd=function(f){o++,r.onProgress!==void 0&&r.onProgress(f,o,l),o===l&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(f){r.onError!==void 0&&r.onError(f)},this.resolveURL=function(f){return u?u(f):f},this.setURLModifier=function(f){return u=f,this},this.addHandler=function(f,h){return c.push(f,h),this},this.removeHandler=function(f){const h=c.indexOf(f);return h!==-1&&c.splice(h,2),this},this.getHandler=function(f){for(let h=0,m=c.length;h<m;h+=2){const y=c[h],p=c[h+1];if(y.global&&(y.lastIndex=0),y.test(f))return p}return null}}}const rb=new Jh;class Kt{constructor(e){this.manager=e!==void 0?e:rb,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,s){i.load(e,r,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}}const jn={};class Sn extends Kt{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ns.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;if(jn[e]!==void 0){jn[e].push({onLoad:t,onProgress:i,onError:r});return}const l=/^data:(.*?)(;base64)?,(.*)$/,u=e.match(l);let c;if(u){const f=u[1],h=!!u[2];let m=u[3];m=decodeURIComponent(m),h&&(m=atob(m));try{let y;const p=(this.responseType||"").toLowerCase();switch(p){case"arraybuffer":case"blob":const d=new Uint8Array(m.length);for(let v=0;v<m.length;v++)d[v]=m.charCodeAt(v);p==="blob"?y=new Blob([d.buffer],{type:f}):y=d.buffer;break;case"document":y=new DOMParser().parseFromString(m,f);break;case"json":y=JSON.parse(m);break;default:y=m;break}setTimeout(function(){t&&t(y),s.manager.itemEnd(e)},0)}catch(y){setTimeout(function(){r&&r(y),s.manager.itemError(e),s.manager.itemEnd(e)},0)}}else{jn[e]=[],jn[e].push({onLoad:t,onProgress:i,onError:r}),c=new XMLHttpRequest,c.open("GET",e,!0),c.addEventListener("load",function(f){const h=this.response,m=jn[e];if(delete jn[e],this.status===200||this.status===0){this.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),ns.add(e,h);for(let y=0,p=m.length;y<p;y++){const d=m[y];d.onLoad&&d.onLoad(h)}s.manager.itemEnd(e)}else{for(let y=0,p=m.length;y<p;y++){const d=m[y];d.onError&&d.onError(f)}s.manager.itemError(e),s.manager.itemEnd(e)}},!1),c.addEventListener("progress",function(f){const h=jn[e];for(let m=0,y=h.length;m<y;m++){const p=h[m];p.onProgress&&p.onProgress(f)}},!1),c.addEventListener("error",function(f){const h=jn[e];delete jn[e];for(let m=0,y=h.length;m<y;m++){const p=h[m];p.onError&&p.onError(f)}s.manager.itemError(e),s.manager.itemEnd(e)},!1),c.addEventListener("abort",function(f){const h=jn[e];delete jn[e];for(let m=0,y=h.length;m<y;m++){const p=h[m];p.onError&&p.onError(f)}s.manager.itemError(e),s.manager.itemEnd(e)},!1),this.responseType!==void 0&&(c.responseType=this.responseType),this.withCredentials!==void 0&&(c.withCredentials=this.withCredentials),c.overrideMimeType&&c.overrideMimeType(this.mimeType!==void 0?this.mimeType:"text/plain");for(const f in this.requestHeader)c.setRequestHeader(f,this.requestHeader[f]);c.send(null)}return s.manager.itemStart(e),c}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class zN extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Sn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{t(s.parse(JSON.parse(l)))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}parse(e){const t=[];for(let i=0;i<e.length;i++){const r=Mo.parse(e[i]);t.push(r)}return t}}class UN extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=[],l=new Eh,u=new Sn(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(s.withCredentials);let c=0;function f(h){u.load(e[h],function(m){const y=s.parse(m,!0);o[h]={width:y.width,height:y.height,format:y.format,mipmaps:y.mipmaps},c+=1,c===6&&(y.mipmapCount===1&&(l.minFilter=wt),l.image=o,l.format=y.format,l.needsUpdate=!0,t&&t(l))},i,r)}if(Array.isArray(e))for(let h=0,m=e.length;h<m;++h)f(h);else u.load(e,function(h){const m=s.parse(h,!0);if(m.isCubemap){const y=m.mipmaps.length/m.mipmapCount;for(let p=0;p<y;p++){o[p]={mipmaps:[]};for(let d=0;d<m.mipmapCount;d++)o[p].mipmaps.push(m.mipmaps[p*m.mipmapCount+d]),o[p].format=m.format,o[p].width=m.width,o[p].height=m.height}l.image=o}else l.image.width=m.width,l.image.height=m.height,l.mipmaps=m.mipmaps;m.mipmapCount===1&&(l.minFilter=wt),l.format=m.format,l.needsUpdate=!0,t&&t(l)},i,r);return l}}class Oa extends Kt{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ns.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const l=document.createElementNS("http://www.w3.org/1999/xhtml","img");function u(){l.removeEventListener("load",u,!1),l.removeEventListener("error",c,!1),ns.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(f){l.removeEventListener("load",u,!1),l.removeEventListener("error",c,!1),r&&r(f),s.manager.itemError(e),s.manager.itemEnd(e)}return l.addEventListener("load",u,!1),l.addEventListener("error",c,!1),e.substr(0,5)!=="data:"&&this.crossOrigin!==void 0&&(l.crossOrigin=this.crossOrigin),s.manager.itemStart(e),l.src=e,l}}class sb extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=new Qs,o=new Oa(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let l=0;function u(c){o.load(e[c],function(f){s.images[c]=f,l++,l===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let c=0;c<e.length;++c)u(c);return s}}class ob extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Xr,l=new Sn(this.manager);return l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setPath(this.path),l.setWithCredentials(s.withCredentials),l.load(e,function(u){const c=s.parse(u);c&&(c.image!==void 0?o.image=c.image:c.data!==void 0&&(o.image.width=c.width,o.image.height=c.height,o.image.data=c.data),o.wrapS=c.wrapS!==void 0?c.wrapS:Wt,o.wrapT=c.wrapT!==void 0?c.wrapT:Wt,o.magFilter=c.magFilter!==void 0?c.magFilter:wt,o.minFilter=c.minFilter!==void 0?c.minFilter:wt,o.anisotropy=c.anisotropy!==void 0?c.anisotropy:1,c.encoding!==void 0&&(o.encoding=c.encoding),c.flipY!==void 0&&(o.flipY=c.flipY),c.format!==void 0&&(o.format=c.format),c.type!==void 0&&(o.type=c.type),c.mipmaps!==void 0&&(o.mipmaps=c.mipmaps,o.minFilter=Ti),c.mipmapCount===1&&(o.minFilter=wt),c.generateMipmaps!==void 0&&(o.generateMipmaps=c.generateMipmaps),o.needsUpdate=!0,t&&t(o,c))},i,r),o}}class qh extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=new Rt,o=new Oa(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(l){s.image=l;const u=e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0;s.format=u?Ci:vn,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class ab extends Mn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Aa(t,e))}getPoint(e){const t=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=t){const s=i[r]-t,o=this.curves[r],l=o.getLength(),u=l===0?0:1-s/l;return o.getPointAt(u)}r++}return null}getLength(){const 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;const e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,s=this.curves;r<s.length;r++){const o=s[r],l=o&&o.isEllipseCurve?e*2:o&&(o.isLineCurve||o.isLineCurve3)?1:o&&o.isSplineCurve?e*o.points.length:e,u=o.getPoints(l);for(let c=0;c<u.length;c++){const f=u[c];i&&i.equals(f)||(t.push(f),i=f)}}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,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new Fh[r.type]().fromJSON(r))}return this}}class Na extends ab{constructor(e){super(),this.type="Path",this.currentPoint=new Se,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const i=new Aa(this.currentPoint.clone(),new Se(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const s=new Rc(this.currentPoint.clone(),new Se(e,t),new Se(i,r));return this.curves.push(s),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,s,o){const l=new Lc(this.currentPoint.clone(),new Se(e,t),new Se(i,r),new Se(s,o));return this.curves.push(l),this.currentPoint.set(s,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new Pc(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,s,o){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+l,t+u,i,r,s,o),this}absarc(e,t,i,r,s,o){return this.absellipse(e,t,i,i,r,s,o),this}ellipse(e,t,i,r,s,o,l,u){const c=this.currentPoint.x,f=this.currentPoint.y;return this.absellipse(e+c,t+f,i,r,s,o,l,u),this}absellipse(e,t,i,r,s,o,l,u){const c=new Ta(e,t,i,r,s,o,l,u);if(this.curves.length>0){const h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);const f=c.getPoint(1);return this.currentPoint.copy(f),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class br extends Na{constructor(e){super(e),this.uuid=bn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new Na().fromJSON(r))}return this}}class $n extends $e{constructor(e,t=1){super(),this.type="Light",this.color=new Ae(e),this.intensity=t}dispose(){}copy(e){return super.copy(e),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const 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}}$n.prototype.isLight=!0;class Kh extends $n{constructor(e,t,i){super(e,i),this.type="HemisphereLight",this.position.copy($e.DefaultUp),this.updateMatrix(),this.groundColor=new Ae(t)}copy(e){return $n.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}Kh.prototype.isHemisphereLight=!0;const lb=new De,cb=new X,ub=new X;class Qh{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.mapSize=new Se(512,512),this.map=null,this.mapPass=null,this.matrix=new De,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new da,this._frameExtents=new Se(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;cb.setFromMatrixPosition(e.matrixWorld),t.position.copy(cb),ub.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ub),t.updateMatrixWorld(),lb.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lb),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(t.projectionMatrix),i.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(){const 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}}class db extends Qh{constructor(){super(new zt(50,1,.5,500)),this.focus=1}updateMatrices(e){const t=this.camera,i=ra*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}db.prototype.isSpotLightShadow=!0;class Fc extends $n{constructor(e,t,i=0,r=Math.PI/3,s=0,o=1){super(e,t),this.type="SpotLight",this.position.copy($e.DefaultUp),this.updateMatrix(),this.target=new $e,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.shadow=new db}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),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}}Fc.prototype.isSpotLight=!0;const hb=new De,Da=new X,ef=new X;class fb extends Qh{constructor(){super(new zt(90,1,.5,500)),this._frameExtents=new Se(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new X(1,0,0),new X(-1,0,0),new X(0,0,1),new X(0,0,-1),new X(0,1,0),new X(0,-1,0)],this._cubeUps=[new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,1,0),new X(0,0,1),new X(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),Da.setFromMatrixPosition(e.matrixWorld),i.position.copy(Da),ef.copy(i.position),ef.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(ef),i.updateMatrixWorld(),r.makeTranslation(-Da.x,-Da.y,-Da.z),hb.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hb)}}fb.prototype.isPointLightShadow=!0;class Vc extends $n{constructor(e,t,i=0,r=1){super(e,t),this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new fb}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}Vc.prototype.isPointLight=!0;class So extends ua{constructor(e=-1,t=1,i=1,r=-1,s=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,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,i,r,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=i,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,o=i+e,l=r+t,u=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,f=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,l-=f*this.view.offsetY,u=l-f*this.view.height}this.projectionMatrix.makeOrthographic(s,o,l,u,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const 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}}So.prototype.isOrthographicCamera=!0;class pb extends Qh{constructor(){super(new So(-5,5,5,-5,.5,500))}}pb.prototype.isDirectionalLightShadow=!0;class kc extends $n{constructor(e,t){super(e,t),this.type="DirectionalLight",this.position.copy($e.DefaultUp),this.updateMatrix(),this.target=new $e,this.shadow=new pb}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}kc.prototype.isDirectionalLight=!0;class tf extends $n{constructor(e,t){super(e,t),this.type="AmbientLight"}}tf.prototype.isAmbientLight=!0;class nf extends $n{constructor(e,t,i=10,r=10){super(e,t),this.type="RectAreaLight",this.width=i,this.height=r}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}nf.prototype.isRectAreaLight=!0;class rf{constructor(){this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new X)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*i),t.addScaledVector(o[4],1.092548*(i*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(i*s)),t.addScaledVector(o[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){const i=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*i),t.addScaledVector(o[4],2*.429043*i*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*i*s),t.addScaledVector(o[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const i=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*i*s,t[8]=.546274*(i*i-r*r)}}rf.prototype.isSphericalHarmonics3=!0;class Ba extends $n{constructor(e=new rf,t=1){super(void 0,t),this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}Ba.prototype.isLightProbe=!0;class mb extends Kt{constructor(e){super(e),this.textures={}}load(e,t,i,r){const s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(JSON.parse(l)))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}const r=new FN[e.type];if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=new Ae().setHex(e.sheen)),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==1&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.morphTargets!==void 0&&(r.morphTargets=e.morphTargets),e.morphNormals!==void 0&&(r.morphNormals=e.morphNormals),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.vertexTangents!==void 0&&(r.vertexTangents=e.vertexTangents),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const s in e.uniforms){const o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=i(o.value);break;case"c":r.uniforms[s].value=new Ae().setHex(o.value);break;case"v2":r.uniforms[s].value=new Se().fromArray(o.value);break;case"v3":r.uniforms[s].value=new X().fromArray(o.value);break;case"v4":r.uniforms[s].value=new st().fromArray(o.value);break;case"m3":r.uniforms[s].value=new kt().fromArray(o.value);break;case"m4":r.uniforms[s].value=new De().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const s in e.extensions)r.extensions[s]=e.extensions[s];if(e.shading!==void 0&&(r.flatShading=e.shading===1),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=i(e.map)),e.matcap!==void 0&&(r.matcap=i(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=i(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=i(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=i(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Se().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=i(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=i(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=i(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=i(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=i(e.specularMap)),e.envMap!==void 0&&(r.envMap=i(e.envMap)),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=i(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=i(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=i(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=i(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Se().fromArray(e.clearcoatNormalScale)),e.transmissionMap!==void 0&&(r.transmissionMap=i(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=i(e.thicknessMap)),r}setTextures(e){return this.textures=e,this}}class Fi{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substr(0,t+1)}}class sf extends Ve{constructor(){super(),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(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}sf.prototype.isInstancedBufferGeometry=!0;class of extends Ge{constructor(e,t,i,r=1){typeof i=="number"&&(r=i,i=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,t,i),this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}of.prototype.isInstancedBufferAttribute=!0;class gb extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Sn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){try{t(s.parse(JSON.parse(l)))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(y,p){if(t[p]!==void 0)return t[p];const b=y.interleavedBuffers[p],v=s(y,b.buffer),g=Zs(b.type,v),M=new mr(g,b.stride);return M.uuid=b.uuid,t[p]=M,M}function s(y,p){if(i[p]!==void 0)return i[p];const b=y.arrayBuffers[p],v=new Uint32Array(b).buffer;return i[p]=v,v}const o=e.isInstancedBufferGeometry?new sf:new Ve,l=e.data.index;if(l!==void 0){const y=Zs(l.type,l.array);o.setIndex(new Ge(y,1))}const u=e.data.attributes;for(const y in u){const p=u[y];let d;if(p.isInterleavedBufferAttribute){const b=r(e.data,p.data);d=new Bi(b,p.itemSize,p.offset,p.normalized)}else{const b=Zs(p.type,p.array),v=p.isInstancedBufferAttribute?of:Ge;d=new v(b,p.itemSize,p.normalized)}p.name!==void 0&&(d.name=p.name),p.usage!==void 0&&d.setUsage(p.usage),p.updateRange!==void 0&&(d.updateRange.offset=p.updateRange.offset,d.updateRange.count=p.updateRange.count),o.setAttribute(y,d)}const c=e.data.morphAttributes;if(c)for(const y in c){const p=c[y],d=[];for(let b=0,v=p.length;b<v;b++){const g=p[b];let M;if(g.isInterleavedBufferAttribute){const _=r(e.data,g.data);M=new Bi(_,g.itemSize,g.offset,g.normalized)}else{const _=Zs(g.type,g.array);M=new Ge(_,g.itemSize,g.normalized)}g.name!==void 0&&(M.name=g.name),d.push(M)}o.morphAttributes[y]=d}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let y=0,p=h.length;y!==p;++y){const d=h[y];o.addGroup(d.start,d.count,d.materialIndex)}const m=e.data.boundingSphere;if(m!==void 0){const y=new X;m.center!==void 0&&y.fromArray(m.center),o.boundingSphere=new Li(y,m.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class GN extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=this.path===""?Fi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const l=new Sn(this.manager);l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){let c=null;try{c=JSON.parse(u)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const f=c.metadata;if(f===void 0||f.type===void 0||f.type.toLowerCase()==="geometry"){console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(c,t)},i,r)}async loadAsync(e,t){const i=this,r=this.path===""?Fi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const s=new Sn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);const o=await s.loadAsync(e,t),l=JSON.parse(o),u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await i.parseAsync(l)}parse(e,t){const i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(c)}),l=this.parseTextures(e.textures,o),u=this.parseMaterials(e.materials,l),c=this.parseObject(e.object,s,u,l,i),f=this.parseSkeletons(e.skeletons,c);if(this.bindSkeletons(c,f),t!==void 0){let h=!1;for(const m in o)if(o[m]instanceof HTMLImageElement){h=!0;break}h===!1&&t(c)}return c}async parseAsync(e){const t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),l=this.parseMaterials(e.materials,o),u=this.parseObject(e.object,r,l,o,t),c=this.parseSkeletons(e.skeletons,u);return this.bindSkeletons(u,c),u}parseShapes(e){const t={};if(e!==void 0)for(let i=0,r=e.length;i<r;i++){const s=new br().fromJSON(e[i]);t[s.uuid]=s}return t}parseSkeletons(e,t){const i={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){const l=new Sa().fromJSON(e[s],r);i[l.uuid]=l}return i}parseGeometries(e,t){const i={};if(e!==void 0){const r=new gb;for(let s=0,o=e.length;s<o;s++){let l;const u=e[s];switch(u.type){case"BufferGeometry":case"InstancedBufferGeometry":l=r.parse(u);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:u.type in eb?l=eb[u.type].fromJSON(u,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${u.type}"`)}l.uuid=u.uuid,u.name!==void 0&&(l.name=u.name),l.isBufferGeometry===!0&&u.userData!==void 0&&(l.userData=u.userData),i[u.uuid]=l}}return i}parseMaterials(e,t){const i={},r={};if(e!==void 0){const s=new mb;s.setTextures(t);for(let o=0,l=e.length;o<l;o++){const u=e[o];if(u.type==="MultiMaterial"){const c=[];for(let f=0;f<u.materials.length;f++){const h=u.materials[f];i[h.uuid]===void 0&&(i[h.uuid]=s.parse(h)),c.push(i[h.uuid])}r[u.uuid]=c}else i[u.uuid]===void 0&&(i[u.uuid]=s.parse(u)),r[u.uuid]=i[u.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let i=0;i<e.length;i++){const r=e[i],s=Mo.parse(r);t[s.uuid]=s}return t}parseImages(e,t){const i=this,r={};let s;function o(u){return i.manager.itemStart(u),s.load(u,function(){i.manager.itemEnd(u)},void 0,function(){i.manager.itemError(u),i.manager.itemEnd(u)})}function l(u){if(typeof u=="string"){const c=u,f=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:i.resourcePath+c;return o(f)}else return u.data?{data:Zs(u.type,u.data),width:u.width,height:u.height}:null}if(e!==void 0&&e.length>0){const u=new Jh(t);s=new Oa(u),s.setCrossOrigin(this.crossOrigin);for(let c=0,f=e.length;c<f;c++){const h=e[c],m=h.url;if(Array.isArray(m)){r[h.uuid]=[];for(let y=0,p=m.length;y<p;y++){const d=m[y],b=l(d);b!==null&&(b instanceof HTMLImageElement?r[h.uuid].push(b):r[h.uuid].push(new Xr(b.data,b.width,b.height)))}}else{const y=l(h.url);y!==null&&(r[h.uuid]=y)}}}return r}async parseImagesAsync(e){const t=this,i={};let r;async function s(o){if(typeof o=="string"){const l=o,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:t.resourcePath+l;return await r.loadAsync(u)}else return o.data?{data:Zs(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new Oa(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,l=e.length;o<l;o++){const u=e[o],c=u.url;if(Array.isArray(c)){i[u.uuid]=[];for(let f=0,h=c.length;f<h;f++){const m=c[f],y=await s(m);y!==null&&(y instanceof HTMLImageElement?i[u.uuid].push(y):i[u.uuid].push(new Xr(y.data,y.width,y.height)))}}else{const f=await s(u.url);f!==null&&(i[u.uuid]=f)}}}return i}parseTextures(e,t){function i(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}const r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){const l=e[s];l.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',l.uuid),t[l.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",l.image);let u;const c=t[l.image];Array.isArray(c)?(u=new Qs(c),c.length===6&&(u.needsUpdate=!0)):(c&&c.data?u=new Xr(c.data,c.width,c.height):u=new Rt(c),c&&(u.needsUpdate=!0)),u.uuid=l.uuid,l.name!==void 0&&(u.name=l.name),l.mapping!==void 0&&(u.mapping=i(l.mapping,HN)),l.offset!==void 0&&u.offset.fromArray(l.offset),l.repeat!==void 0&&u.repeat.fromArray(l.repeat),l.center!==void 0&&u.center.fromArray(l.center),l.rotation!==void 0&&(u.rotation=l.rotation),l.wrap!==void 0&&(u.wrapS=i(l.wrap[0],yb),u.wrapT=i(l.wrap[1],yb)),l.format!==void 0&&(u.format=l.format),l.type!==void 0&&(u.type=l.type),l.encoding!==void 0&&(u.encoding=l.encoding),l.minFilter!==void 0&&(u.minFilter=i(l.minFilter,vb)),l.magFilter!==void 0&&(u.magFilter=i(l.magFilter,vb)),l.anisotropy!==void 0&&(u.anisotropy=l.anisotropy),l.flipY!==void 0&&(u.flipY=l.flipY),l.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=l.premultiplyAlpha),l.unpackAlignment!==void 0&&(u.unpackAlignment=l.unpackAlignment),r[l.uuid]=u}return r}parseObject(e,t,i,r,s){let o;function l(m){return t[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",m),t[m]}function u(m){if(m!==void 0){if(Array.isArray(m)){const y=[];for(let p=0,d=m.length;p<d;p++){const b=m[p];i[b]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",b),y.push(i[b])}return y}return i[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",m),i[m]}}function c(m){return r[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",m),r[m]}let f,h;switch(e.type){case"Scene":o=new mc,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Ae(e.background):o.background=c(e.background)),e.environment!==void 0&&(o.environment=c(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new ma(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new pa(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":o=new zt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new So(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new tf(e.color,e.intensity);break;case"DirectionalLight":o=new kc(e.color,e.intensity);break;case"PointLight":o=new Vc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new nf(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Fc(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new Kh(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Ba().fromJSON(e);break;case"SkinnedMesh":f=l(e.geometry),h=u(e.material),o=new wa(f,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":f=l(e.geometry),h=u(e.material),o=new It(f,h);break;case"InstancedMesh":f=l(e.geometry),h=u(e.material);const m=e.count,y=e.instanceMatrix,p=e.instanceColor;o=new Sh(f,h,m),o.instanceMatrix=new Ge(new Float32Array(y.array),16),p!==void 0&&(o.instanceColor=new Ge(new Float32Array(p.array),p.itemSize));break;case"LOD":o=new Av;break;case"Line":o=new ii(l(e.geometry),u(e.material));break;case"LineLoop":o=new Mc(l(e.geometry),u(e.material));break;case"LineSegments":o=new un(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":o=new oo(l(e.geometry),u(e.material));break;case"Sprite":o=new xa(u(e.material));break;case"Group":o=new ni;break;case"Bone":o=new Ma;break;default:o=new $e}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const m=e.children;for(let y=0;y<m.length;y++)o.add(this.parseObject(m[y],t,i,r,s))}if(e.animations!==void 0){const m=e.animations;for(let y=0;y<m.length;y++){const p=m[y];o.animations.push(s[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const m=e.levels;for(let y=0;y<m.length;y++){const p=m[y],d=o.getObjectByProperty("uuid",p.object);d!==void 0&&o.addLevel(d,p.distance)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(i){if(i.isSkinnedMesh===!0&&i.skeleton!==void 0){const r=t[i.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",i.skeleton):i.bind(r,i.bindMatrix)}})}setTexturePath(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}const HN={UVMapping:Bl,CubeReflectionMapping:Jo,CubeRefractionMapping:qo,EquirectangularReflectionMapping:Fl,EquirectangularRefractionMapping:Vl,CubeUVReflectionMapping:Is,CubeUVRefractionMapping:Ko},yb={RepeatWrapping:ir,ClampToEdgeWrapping:Wt,MirroredRepeatWrapping:Os},vb={NearestFilter:Lt,NearestMipmapNearestFilter:Qo,NearestMipmapLinearFilter:ea,LinearFilter:wt,LinearMipmapNearestFilter:kl,LinearMipmapLinearFilter:Ti};class af extends Kt{constructor(e){super(e),typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ns.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const l={};l.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",l.headers=this.requestHeader,fetch(e,l).then(function(u){return u.blob()}).then(function(u){return createImageBitmap(u,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(u){ns.add(e,u),t&&t(u),s.manager.itemEnd(e)}).catch(function(u){r&&r(u),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}af.prototype.isImageBitmapLoader=!0;class bb{constructor(){this.type="ShapePath",this.color=new Ae,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Na,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,s,o){return this.currentPath.bezierCurveTo(e,t,i,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,t){function i(g){const M=[];for(let _=0,E=g.length;_<E;_++){const S=g[_],w=new br;w.curves=S.curves,M.push(w)}return M}function r(g,M){const _=M.length;let E=!1;for(let S=_-1,w=0;w<_;S=w++){let T=M[S],C=M[w],R=C.x-T.x,P=C.y-T.y;if(Math.abs(P)>Number.EPSILON){if(P<0&&(T=M[w],R=-R,C=M[S],P=-P),g.y<T.y||g.y>C.y)continue;if(g.y===T.y){if(g.x===T.x)return!0}else{const L=P*(g.x-T.x)-R*(g.y-T.y);if(L===0)return!0;if(L<0)continue;E=!E}}else{if(g.y!==T.y)continue;if(C.x<=g.x&&g.x<=T.x||T.x<=g.x&&g.x<=C.x)return!0}}return E}const s=si.isClockWise,o=this.subPaths;if(o.length===0)return[];if(t===!0)return i(o);let l,u,c;const f=[];if(o.length===1)return u=o[0],c=new br,c.curves=u.curves,f.push(c),f;let h=!s(o[0].getPoints());h=e?!h:h;const m=[],y=[];let p=[],d=0,b;y[d]=void 0,p[d]=[];for(let g=0,M=o.length;g<M;g++)u=o[g],b=u.getPoints(),l=s(b),l=e?!l:l,l?(!h&&y[d]&&d++,y[d]={s:new br,p:b},y[d].s.curves=u.curves,h&&d++,p[d]=[]):p[d].push({h:u,p:b[0]});if(!y[0])return i(o);if(y.length>1){let g=!1;const M=[];for(let _=0,E=y.length;_<E;_++)m[_]=[];for(let _=0,E=y.length;_<E;_++){const S=p[_];for(let w=0;w<S.length;w++){const T=S[w];let C=!0;for(let R=0;R<y.length;R++)r(T.p,y[R].p)&&(_!==R&&M.push({froms:_,tos:R,hole:w}),C?(C=!1,m[R].push(T)):g=!0);C&&m[_].push(T)}}M.length>0&&(g||(p=m))}let v;for(let g=0,M=y.length;g<M;g++){c=y[g].s,f.push(c),v=p[g];for(let _=0,E=v.length;_<E;_++)c.holes.push(v[_].h)}return f}}class lf{constructor(e){this.type="Font",this.data=e}generateShapes(e,t=100){const i=[],r=WN(e,t,this.data);for(let s=0,o=r.length;s<o;s++)Array.prototype.push.apply(i,r[s].toShapes());return i}}function WN(n,e,t){const i=Array.from(n),r=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*r,o=[];let l=0,u=0;for(let c=0;c<i.length;c++){const f=i[c];if(f===`
2916
2916
  `)l=0,u-=s;else{const h=jN(f,r,l,u,t);l+=h.offsetX,o.push(h.path)}}return o}function jN(n,e,t,i,r){const s=r.glyphs[n]||r.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+".");return}const o=new bb;let l,u,c,f,h,m,y,p;if(s.o){const d=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let b=0,v=d.length;b<v;)switch(d[b++]){case"m":l=d[b++]*e+t,u=d[b++]*e+i,o.moveTo(l,u);break;case"l":l=d[b++]*e+t,u=d[b++]*e+i,o.lineTo(l,u);break;case"q":c=d[b++]*e+t,f=d[b++]*e+i,h=d[b++]*e+t,m=d[b++]*e+i,o.quadraticCurveTo(h,m,c,f);break;case"b":c=d[b++]*e+t,f=d[b++]*e+i,h=d[b++]*e+t,m=d[b++]*e+i,y=d[b++]*e+t,p=d[b++]*e+i,o.bezierCurveTo(h,m,y,p,c,f);break}}return{offsetX:s.ha*e,path:o}}lf.prototype.isFont=!0;class $N extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Sn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(l){let u;try{u=JSON.parse(l)}catch{console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),u=JSON.parse(l.substring(65,l.length-2))}const c=s.parse(u);t&&t(c)},i,r)}parse(e){return new lf(e)}}let zc;const cf={getContext:function(){return zc===void 0&&(zc=new(window.AudioContext||window.webkitAudioContext)),zc},setContext:function(n){zc=n}};class xb extends Kt{constructor(e){super(e)}load(e,t,i,r){const s=this,o=new Sn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const u=l.slice(0);cf.getContext().decodeAudioData(u,function(f){t(f)})}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},i,r)}}class wb extends Ba{constructor(e,t,i=1){super(void 0,i);const r=new Ae().set(e),s=new Ae().set(t),o=new X(r.r,r.g,r.b),l=new X(s.r,s.g,s.b),u=Math.sqrt(Math.PI),c=u*Math.sqrt(.75);this.sh.coefficients[0].copy(o).add(l).multiplyScalar(u),this.sh.coefficients[1].copy(o).sub(l).multiplyScalar(c)}}wb.prototype.isHemisphereLightProbe=!0;class Mb extends Ba{constructor(e,t=1){super(void 0,t);const i=new Ae().set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}}Mb.prototype.isAmbientLightProbe=!0;const Sb=new De,_b=new De;class ZN{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new zt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new zt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep;const r=e.projectionMatrix.clone(),s=t.eyeSep/2,o=s*t.near/t.focus,l=t.near*Math.tan(Gr*t.fov*.5)/t.zoom;let u,c;_b.elements[12]=-s,Sb.elements[12]=s,u=-l*t.aspect+o,c=l*t.aspect+o,r.elements[0]=2*t.near/(c-u),r.elements[8]=(c+u)/(c-u),this.cameraL.projectionMatrix.copy(r),u=-l*t.aspect-o,c=l*t.aspect-o,r.elements[0]=2*t.near/(c-u),r.elements[8]=(c+u)/(c-u),this.cameraR.projectionMatrix.copy(r)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(_b),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Sb)}}class Tb{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Eb(),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){const t=Eb();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Eb(){return(typeof performance>"u"?Date:performance).now()}const is=new X,Cb=new qt,XN=new X,rs=new X;class YN extends $e{constructor(){super(),this.type="AudioListener",this.context=cf.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Tb}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(is,Cb,XN),rs.set(0,0,-1).applyQuaternion(Cb),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(is.x,r),t.positionY.linearRampToValueAtTime(is.y,r),t.positionZ.linearRampToValueAtTime(is.z,r),t.forwardX.linearRampToValueAtTime(rs.x,r),t.forwardY.linearRampToValueAtTime(rs.y,r),t.forwardZ.linearRampToValueAtTime(rs.z,r),t.upX.linearRampToValueAtTime(i.x,r),t.upY.linearRampToValueAtTime(i.y,r),t.upZ.linearRampToValueAtTime(i.z,r)}else t.setPosition(is.x,is.y,is.z),t.setOrientation(rs.x,rs.y,rs.z,i.x,i.y,i.z)}}class uf extends $e{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const ss=new X,Ab=new qt,JN=new X,os=new X;class qN extends uf{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(ss,Ab,JN),os.set(0,0,1).applyQuaternion(Ab);const t=this.panner;if(t.positionX){const i=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(ss.x,i),t.positionY.linearRampToValueAtTime(ss.y,i),t.positionZ.linearRampToValueAtTime(ss.z,i),t.orientationX.linearRampToValueAtTime(os.x,i),t.orientationY.linearRampToValueAtTime(os.y,i),t.orientationZ.linearRampToValueAtTime(os.z,i)}else t.setPosition(ss.x,ss.y,ss.z),t.setOrientation(os.x,os.y,os.z)}}class Lb{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class Rb{constructor(e,t,i){this.binding=e,this.valueSize=i;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const i=this.buffer,r=this.valueSize,s=e*r+r;let o=this.cumulativeWeight;if(o===0){for(let l=0;l!==r;++l)i[s+l]=i[l];o=t}else{o+=t;const l=t/o;this._mixBufferRegion(i,s,0,l,r)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,i=this.valueSize,r=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,i=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,l=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const u=t*this._origIndex;this._mixBufferRegion(i,r,u,1-s,t)}o>0&&this._mixBufferRegionAdditive(i,r,this._addIndex*t,1,t);for(let u=t,c=t+t;u!==c;++u)if(i[u]!==i[u+t]){l.setValue(i,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let s=i,o=r;s!==o;++s)t[s]=t[r+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[i+o]}_slerp(e,t,i,r){qt.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,s){const o=this._workIndex*s;qt.multiplyQuaternionsFlat(e,o,e,t,e,i),qt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,i,r,s){const o=1-r;for(let l=0;l!==s;++l){const u=t+l;e[u]=e[u]*o+e[i+l]*r}}_lerpAdditive(e,t,i,r,s){for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]+e[i+o]*r}}}const df="\\[\\]\\.:\\/",KN=new RegExp("["+df+"]","g"),hf="[^"+df+"]",QN="[^"+df.replace("\\.","")+"]",eD=/((?:WC+[\/:])*)/.source.replace("WC",hf),tD=/(WCOD+)?/.source.replace("WCOD",QN),nD=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",hf),iD=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",hf),rD=new RegExp("^"+eD+tD+nD+iD+"$"),sD=["material","materials","bones"];class oD{constructor(e,t,i){const r=i||Qe.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class Qe{constructor(e,t,i){this.path=t,this.parsedPath=i||Qe.parseTrackName(t),this.node=Qe.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new Qe.Composite(e,t,i):new Qe(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(KN,"")}static parseTrackName(e){const t=rD.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);sD.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(!t||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o<s.length;o++){const l=s[o];if(l.name===t||l.uuid===t)return l;const u=i(l.children);if(u)return u}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.node[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)e[t++]=i[r]}_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){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,s=i.length;r!==s;++r)i[r]=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;const t=this.parsedPath,i=t.objectName,r=t.propertyName;let s=t.propertyIndex;if(e||(e=Qe.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(i){let c=t.objectIndex;switch(i){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 f=0;f<e.length;f++)if(e[f].name===c){c=f;break}break;default:if(e[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const o=e[r];if(o===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let l=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?l=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(l=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(s!==void 0){if(r==="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.isBufferGeometry){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])}else{console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.",this);return}}u=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(u=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][l]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Qe.Composite=oD,Qe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Qe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Qe.prototype.GetterByBindingType=[Qe.prototype._getValue_direct,Qe.prototype._getValue_array,Qe.prototype._getValue_arrayElement,Qe.prototype._getValue_toArray],Qe.prototype.SetterByBindingTypeAndVersioning=[[Qe.prototype._setValue_direct,Qe.prototype._setValue_direct_setNeedsUpdate,Qe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_array,Qe.prototype._setValue_array_setNeedsUpdate,Qe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_arrayElement,Qe.prototype._setValue_arrayElement_setNeedsUpdate,Qe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qe.prototype._setValue_fromArray,Qe.prototype._setValue_fromArray_setNeedsUpdate,Qe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Pb{constructor(){this.uuid=bn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let i=0,r=arguments.length;i!==r;++i)e[arguments[i].uuid]=i;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length;let l,u=e.length,c=this.nCachedObjects_;for(let f=0,h=arguments.length;f!==h;++f){const m=arguments[f],y=m.uuid;let p=t[y];if(p===void 0){p=u++,t[y]=p,e.push(m);for(let d=0,b=o;d!==b;++d)s[d].push(new Qe(m,i[d],r[d]))}else if(p<c){l=e[p];const d=--c,b=e[d];t[b.uuid]=p,e[p]=b,t[y]=d,e[d]=m;for(let v=0,g=o;v!==g;++v){const M=s[v],_=M[d];let E=M[p];M[p]=_,E===void 0&&(E=new Qe(m,i[v],r[v])),M[d]=E}}else e[p]!==l&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=c}remove(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_;for(let o=0,l=arguments.length;o!==l;++o){const u=arguments[o],c=u.uuid,f=t[c];if(f!==void 0&&f>=s){const h=s++,m=e[h];t[m.uuid]=f,e[f]=m,t[c]=h,e[h]=u;for(let y=0,p=r;y!==p;++y){const d=i[y],b=d[h],v=d[f];d[f]=b,d[h]=v}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let s=this.nCachedObjects_,o=e.length;for(let l=0,u=arguments.length;l!==u;++l){const c=arguments[l],f=c.uuid,h=t[f];if(h!==void 0)if(delete t[f],h<s){const m=--s,y=e[m],p=--o,d=e[p];t[y.uuid]=h,e[h]=y,t[d.uuid]=m,e[m]=d,e.pop();for(let b=0,v=r;b!==v;++b){const g=i[b],M=g[m],_=g[p];g[h]=M,g[m]=_,g.pop()}}else{const m=--o,y=e[m];m>0&&(t[y.uuid]=h),e[h]=y,e.pop();for(let p=0,d=r;p!==d;++p){const b=i[p];b[h]=b[m],b.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const i=this._bindingsIndicesByPath;let r=i[e];const s=this._bindings;if(r!==void 0)return s[r];const o=this._paths,l=this._parsedPaths,u=this._objects,c=u.length,f=this.nCachedObjects_,h=new Array(c);r=s.length,i[e]=r,o.push(e),l.push(t),s.push(h);for(let m=f,y=u.length;m!==y;++m){const p=u[m];h[m]=new Qe(p,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,i=t[e];if(i!==void 0){const r=this._paths,s=this._parsedPaths,o=this._bindings,l=o.length-1,u=o[l],c=e[l];t[c]=i,o[i]=u,o.pop(),s[i]=s[l],s.pop(),r[i]=r[l],r.pop()}}}Pb.prototype.isAnimationObjectGroup=!0;class aD{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;const s=t.tracks,o=s.length,l=new Array(o),u={endingStart:kr,endingEnd:kr};for(let c=0;c!==o;++c){const f=s[c].createInterpolant(null);l[c]=f,f.settings=u}this._interpolantSettings=u,this._interpolants=l,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=by,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){if(e.fadeOut(t),this.fadeIn(t),i){const r=this._clip.duration,s=e._clip.duration,o=s/r,l=r/s;e.warp(1,o,t),this.warp(l,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){const r=this._mixer,s=r.time,o=this.timeScale;let l=this._timeScaleInterpolant;l===null&&(l=r._lendControlInterpolant(),this._timeScaleInterpolant=l);const u=l.parameterPositions,c=l.sampleValues;return u[0]=s,u[1]=s+i,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const u=(e-s)*i;if(u<0||i===0)return;this._startTime=null,t=i*u}t*=this._updateTimeScale(e);const o=this._updateTime(t),l=this._updateWeight(e);if(l>0){const u=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Bd:for(let f=0,h=u.length;f!==h;++f)u[f].evaluate(o),c[f].accumulateAdditive(l);break;case Ul:default:for(let f=0,h=u.length;f!==h;++f)u[f].evaluate(o),c[f].accumulate(r,l)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const i=this._weightInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,i=this.loop;let r=this.time+e,s=this._loopCount;const o=i===xy;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(i===vy){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){const l=Math.floor(r/t);r-=t*l,s+=Math.abs(l);const u=this.repetitions-s;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,i){const r=this._interpolantSettings;i?(r.endingStart=zr,r.endingEnd=zr):(e?r.endingStart=this.zeroSlopeAtStart?zr:kr:r.endingStart=ia,t?r.endingEnd=this.zeroSlopeAtEnd?zr:kr:r.endingEnd=ia)}_scheduleFading(e,t,i){const r=this._mixer,s=r.time;let o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);const l=o.parameterPositions,u=o.sampleValues;return l[0]=s,u[0]=t,l[1]=s+e,u[1]=i,this}}class Ib extends sr{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const i=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,l=e._interpolants,u=i.uuid,c=this._bindingsByRootAndName;let f=c[u];f===void 0&&(f={},c[u]=f);for(let h=0;h!==s;++h){const m=r[h],y=m.name;let p=f[y];if(p!==void 0)o[h]=p;else{if(p=o[h],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,u,y));continue}const d=t&&t._propertyBindings[h].binding.parsedPath;p=new Rb(Qe.create(i,y,d),m.ValueTypeName,m.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,u,y),o[h]=p}l[h].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const i=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,i)}const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,i){const r=this._actions,s=this._actionsByClip;let o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{const l=o.knownActions;e._byClipCacheIndex=l.length,l.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[i]=e}_removeInactiveAction(e){const t=this._actions,i=t[t.length-1],r=e._cacheIndex;i._cacheIndex=r,t[r]=i,t.pop(),e._cacheIndex=null;const s=e._clip.uuid,o=this._actionsByClip,l=o[s],u=l.knownActions,c=u[u.length-1],f=e._byClipCacheIndex;c._byClipCacheIndex=f,u[f]=c,u.pop(),e._byClipCacheIndex=null;const h=l.actionByRoot,m=(e._localRoot||this._root).uuid;delete h[m],u.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let i=0,r=t.length;i!==r;++i){const s=t[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){const t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackAction(e){const t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_addInactiveBinding(e,t,i){const r=this._bindingsByRootAndName,s=this._bindings;let o=r[t];o===void 0&&(o={},r[t]=o),o[i]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){const t=this._bindings,i=e.binding,r=i.rootNode.uuid,s=i.path,o=this._bindingsByRootAndName,l=o[r],u=t[t.length-1],c=e._cacheIndex;u._cacheIndex=c,t[c]=u,t.pop(),delete l[s],Object.keys(l).length===0&&delete o[r]}_lendBinding(e){const t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_takeBackBinding(e){const t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=i,t[i]=s}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return i===void 0&&(i=new Xh(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){const t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=i,t[i]=s}clipAction(e,t,i){const r=t||this._root,s=r.uuid;let o=typeof e=="string"?Mo.findByName(r,e):e;const l=o!==null?o.uuid:e,u=this._actionsByClip[l];let c=null;if(i===void 0&&(o!==null?i=o.blendMode:i=Ul),u!==void 0){const h=u.actionByRoot[s];if(h!==void 0&&h.blendMode===i)return h;c=u.knownActions[0],o===null&&(o=c._clip)}if(o===null)return null;const f=new aD(this,o,t,i);return this._bindAction(f,c),this._addInactiveAction(f,l,s),f}existingAction(e,t){const i=t||this._root,r=i.uuid,s=typeof e=="string"?Mo.findByName(i,e):e,o=s?s.uuid:e,l=this._actionsByClip[o];return l!==void 0&&l.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let i=t-1;i>=0;--i)e[i].stop();return this}update(e){e*=this.timeScale;const t=this._actions,i=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==i;++c)t[c]._update(r,e,s,o);const l=this._bindings,u=this._nActiveBindings;for(let c=0;c!==u;++c)l[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,i=e.uuid,r=this._actionsByClip,s=r[i];if(s!==void 0){const o=s.knownActions;for(let l=0,u=o.length;l!==u;++l){const c=o[l];this._deactivateAction(c);const f=c._cacheIndex,h=t[t.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,h._cacheIndex=f,t[f]=h,t.pop(),this._removeInactiveBindingsForAction(c)}delete r[i]}}uncacheRoot(e){const t=e.uuid,i=this._actionsByClip;for(const o in i){const l=i[o].actionByRoot,u=l[t];u!==void 0&&(this._deactivateAction(u),this._removeInactiveAction(u))}const r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(const o in s){const l=s[o];l.restoreOriginalState(),this._removeInactiveBinding(l)}}uncacheAction(e,t){const i=this.existingAction(e,t);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}Ib.prototype._controlInterpolantsResultBuffer=new Float32Array(1);class Uc{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Uc(this.value.clone===void 0?this.value:this.value.clone())}}class Ob extends mr{constructor(e,t,i=1){super(e,t),this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}Ob.prototype.isInstancedInterleavedBuffer=!0;class Nb{constructor(e,t,i,r,s){this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}Nb.prototype.isGLBufferAttribute=!0;class lD{constructor(e,t,i=0,r=1/0){this.ray=new cr(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new th,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){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&&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=!1,i=[]){return ff(e,this,i,t),i.sort(Db),i}intersectObjects(e,t=!1,i=[]){for(let r=0,s=e.length;r<s;r++)ff(e[r],this,i,t);return i.sort(Db),i}}function Db(n,e){return n.distance-e.distance}function ff(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){const r=n.children;for(let s=0,o=r.length;s<o;s++)ff(r[s],e,t,!0)}}class cD{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,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,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class uD{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return new this.constructor().copy(this)}}const Bb=new Se;class _o{constructor(e=new Se(1/0,1/0),t=new Se(-1/0,-1/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,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Bb.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 Bb.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)}}_o.prototype.isBox2=!0;const Fb=new X,Gc=new X;class Vb{constructor(e=new X,t=new X){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){Fb.subVectors(e,this.start),Gc.subVectors(this.end,this.start);const i=Gc.dot(Gc);let s=Gc.dot(Fb)/i;return t&&(s=Jt(s,0,1)),s}closestPointToPoint(e,t,i){const r=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(r).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)}}class kb extends $e{constructor(e){super(),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}}kb.prototype.isImmediateRenderObject=!0;const zb=new X;class dD extends $e{constructor(e,t){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t;const i=new Ve,r=[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,l=1,u=32;o<u;o++,l++){const c=o/u*Math.PI*2,f=l/u*Math.PI*2;r.push(Math.cos(c),Math.sin(c),1,Math.cos(f),Math.sin(f),1)}i.setAttribute("position",new Oe(r,3));const s=new Ut({fog:!1,toneMapped:!1});this.cone=new un(i,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),zb.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(zb),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const xr=new X,Hc=new De,pf=new De;class Ub extends un{constructor(e){const t=Gb(e),i=new Ve,r=[],s=[],o=new Ae(0,0,1),l=new Ae(0,1,0);for(let c=0;c<t.length;c++){const f=t[c];f.parent&&f.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(l.r,l.g,l.b))}i.setAttribute("position",new Oe(r,3)),i.setAttribute("color",new Oe(s,3));const u=new Ut({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(i,u),this.type="SkeletonHelper",this.isSkeletonHelper=!0,this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,i=this.geometry,r=i.getAttribute("position");pf.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){const l=t[s];l.parent&&l.parent.isBone&&(Hc.multiplyMatrices(pf,l.matrixWorld),xr.setFromMatrixPosition(Hc),r.setXYZ(o,xr.x,xr.y,xr.z),Hc.multiplyMatrices(pf,l.parent.matrixWorld),xr.setFromMatrixPosition(Hc),r.setXYZ(o+1,xr.x,xr.y,xr.z),o+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function Gb(n){const e=[];n&&n.isBone&&e.push(n);for(let t=0;t<n.children.length;t++)e.push.apply(e,Gb(n.children[t]));return e}class hD extends It{constructor(e,t,i){const r=new qr(t,4,2),s=new mn({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.light.updateMatrixWorld(),this.color=i,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)}}const fD=new X,Hb=new Ae,Wb=new Ae;class pD extends $e{constructor(e,t,i){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;const r=new Yr(t);r.rotateY(Math.PI*.5),this.material=new mn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new Ge(o,3)),this.add(new It(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Hb.copy(this.light.color),Wb.copy(this.light.groundColor);for(let i=0,r=t.count;i<r;i++){const s=i<r/2?Hb:Wb;t.setXYZ(i,s.r,s.g,s.b)}t.needsUpdate=!0}e.lookAt(fD.setFromMatrixPosition(this.light.matrixWorld).negate())}}class jb extends un{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ae(i),r=new Ae(r);const s=t/2,o=e/t,l=e/2,u=[],c=[];for(let m=0,y=0,p=-l;m<=t;m++,p+=o){u.push(-l,0,p,l,0,p),u.push(p,0,-l,p,0,l);const d=m===s?i:r;d.toArray(c,y),y+=3,d.toArray(c,y),y+=3,d.toArray(c,y),y+=3,d.toArray(c,y),y+=3}const f=new Ve;f.setAttribute("position",new Oe(u,3)),f.setAttribute("color",new Oe(c,3));const h=new Ut({vertexColors:!0,toneMapped:!1});super(f,h),this.type="GridHelper"}}class mD extends un{constructor(e=10,t=16,i=8,r=64,s=4473924,o=8947848){s=new Ae(s),o=new Ae(o);const l=[],u=[];for(let h=0;h<=t;h++){const m=h/t*(Math.PI*2),y=Math.sin(m)*e,p=Math.cos(m)*e;l.push(0,0,0),l.push(y,0,p);const d=h&1?s:o;u.push(d.r,d.g,d.b),u.push(d.r,d.g,d.b)}for(let h=0;h<=i;h++){const m=h&1?s:o,y=e-e/i*h;for(let p=0;p<r;p++){let d=p/r*(Math.PI*2),b=Math.sin(d)*y,v=Math.cos(d)*y;l.push(b,0,v),u.push(m.r,m.g,m.b),d=(p+1)/r*(Math.PI*2),b=Math.sin(d)*y,v=Math.cos(d)*y,l.push(b,0,v),u.push(m.r,m.g,m.b)}}const c=new Ve;c.setAttribute("position",new Oe(l,3)),c.setAttribute("color",new Oe(u,3));const f=new Ut({vertexColors:!0,toneMapped:!1});super(c,f),this.type="PolarGridHelper"}}const $b=new X,Wc=new X,Zb=new X;class gD extends $e{constructor(e,t,i){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,t===void 0&&(t=1);let r=new Ve;r.setAttribute("position",new Oe([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const s=new Ut({fog:!1,toneMapped:!1});this.lightPlane=new ii(r,s),this.add(this.lightPlane),r=new Ve,r.setAttribute("position",new Oe([0,0,0,0,0,1],3)),this.targetLine=new ii(r,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(){$b.setFromMatrixPosition(this.light.matrixWorld),Wc.setFromMatrixPosition(this.light.target.matrixWorld),Zb.subVectors(Wc,$b),this.lightPlane.lookAt(Wc),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(Wc),this.targetLine.scale.z=Zb.length()}}const jc=new X,Mt=new ua;class yD extends un{constructor(e){const t=new Ve,i=new Ut({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={},l=new Ae(16755200),u=new Ae(16711680),c=new Ae(43775),f=new Ae(16777215),h=new Ae(3355443);m("n1","n2",l),m("n2","n4",l),m("n4","n3",l),m("n3","n1",l),m("f1","f2",l),m("f2","f4",l),m("f4","f3",l),m("f3","f1",l),m("n1","f1",l),m("n2","f2",l),m("n3","f3",l),m("n4","f4",l),m("p","n1",u),m("p","n2",u),m("p","n3",u),m("p","n4",u),m("u1","u2",c),m("u2","u3",c),m("u3","u1",c),m("c","t",f),m("p","c",h),m("cn1","cn2",h),m("cn3","cn4",h),m("cf1","cf2",h),m("cf3","cf4",h);function m(p,d,b){y(p,b),y(d,b)}function y(p,d){r.push(0,0,0),s.push(d.r,d.g,d.b),o[p]===void 0&&(o[p]=[]),o[p].push(r.length/3-1)}t.setAttribute("position",new Oe(r,3)),t.setAttribute("color",new Oe(s,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}update(){const e=this.geometry,t=this.pointMap,i=1,r=1;Mt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Nt("c",t,e,Mt,0,0,-1),Nt("t",t,e,Mt,0,0,1),Nt("n1",t,e,Mt,-i,-r,-1),Nt("n2",t,e,Mt,i,-r,-1),Nt("n3",t,e,Mt,-i,r,-1),Nt("n4",t,e,Mt,i,r,-1),Nt("f1",t,e,Mt,-i,-r,1),Nt("f2",t,e,Mt,i,-r,1),Nt("f3",t,e,Mt,-i,r,1),Nt("f4",t,e,Mt,i,r,1),Nt("u1",t,e,Mt,i*.7,r*1.1,-1),Nt("u2",t,e,Mt,-i*.7,r*1.1,-1),Nt("u3",t,e,Mt,0,r*2,-1),Nt("cf1",t,e,Mt,-i,0,1),Nt("cf2",t,e,Mt,i,0,1),Nt("cf3",t,e,Mt,0,-r,1),Nt("cf4",t,e,Mt,0,r,1),Nt("cn1",t,e,Mt,-i,0,-1),Nt("cn2",t,e,Mt,i,0,-1),Nt("cn3",t,e,Mt,0,-r,-1),Nt("cn4",t,e,Mt,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Nt(n,e,t,i,r,s,o){jc.set(r,s,o).unproject(i);const l=e[n];if(l!==void 0){const u=t.getAttribute("position");for(let c=0,f=l.length;c<f;c++)u.setXYZ(l[c],jc.x,jc.y,jc.z)}}const $c=new pn;class Xb extends un{constructor(e,t=16776960){const i=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]),r=new Float32Array(8*3),s=new Ve;s.setIndex(new Ge(i,1)),s.setAttribute("position",new Ge(r,3)),super(s,new Ut({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&$c.setFromObject(this.object),$c.isEmpty())return;const t=$c.min,i=$c.max,r=this.geometry.attributes.position,s=r.array;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[3]=t.x,s[4]=i.y,s[5]=i.z,s[6]=t.x,s[7]=t.y,s[8]=i.z,s[9]=i.x,s[10]=t.y,s[11]=i.z,s[12]=i.x,s[13]=i.y,s[14]=t.z,s[15]=t.x,s[16]=i.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=i.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e){return un.prototype.copy.call(this,e),this.object=e.object,this}}class vD extends un{constructor(e,t=16776960){const i=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]),r=[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 Ve;s.setIndex(new Ge(i,1)),s.setAttribute("position",new Oe(r,3)),super(s,new Ut({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}}class bD extends ii{constructor(e,t=1,i=16776960){const r=i,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,0,1,0,0,0],o=new Ve;o.setAttribute("position",new Oe(s,3)),o.computeBoundingSphere(),super(o,new Ut({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const l=[1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],u=new Ve;u.setAttribute("position",new Oe(l,3)),u.computeBoundingSphere(),this.add(new It(u,new mn({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?At:er,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}}const Yb=new X;let Zc,mf;class xD extends $e{constructor(e=new X(0,0,1),t=new X(0,0,0),i=1,r=16776960,s=i*.2,o=s*.2){super(),this.type="ArrowHelper",Zc===void 0&&(Zc=new Ve,Zc.setAttribute("position",new Oe([0,0,0,0,1,0],3)),mf=new yr(0,.5,1,5,1),mf.translate(0,-.5,0)),this.position.copy(t),this.line=new ii(Zc,new Ut({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new It(mf,new mn({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Yb.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Yb,t)}}setLength(e,t=e*.2,i=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class Jb extends un{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Ve;r.setAttribute("position",new Oe(t,3)),r.setAttribute("color",new Oe(i,3));const s=new Ut({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,i){const r=new Ae,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(i),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}const qb=new Float32Array(1),wD=new Int32Array(qb.buffer);class MD{static toHalfFloat(e){qb[0]=e;const t=wD[0];let i=t>>16&32768,r=t>>12&2047;const s=t>>23&255;return s<103?i:s>142?(i|=31744,i|=(s==255?0:1)&&t&8388607,i):s<113?(r|=2048,i|=(r>>114-s)+(r>>113-s&1),i):(i|=s-112<<10|r>>1,i+=r&1,i)}}const To=4,wr=8,ai=Math.pow(2,wr),Kb=[.125,.215,.35,.446,.526,.582],Qb=wr-To+1+Kb.length,Eo=20,li={[ln]:0,[Ur]:1,[Hl]:2,[Vd]:3,[kd]:4,[zd]:5,[Gl]:6},as=new mn({side:At,depthWrite:!1,depthTest:!1}),SD=new It(new Ni,as),gf=new So,{_lodPlanes:Fa,_sizeLods:ex,_sigmas:Xc}=ED(),tx=new Ae;let yf=null;const ls=(1+Math.sqrt(5))/2,Co=1/ls,nx=[new X(1,1,1),new X(-1,1,1),new X(1,1,-1),new X(-1,1,-1),new X(0,ls,Co),new X(0,ls,-Co),new X(Co,0,ls),new X(-Co,0,ls),new X(ls,Co,0),new X(-ls,Co,0)];function ix(n){const e=Math.max(n.r,n.g,n.b),t=Math.min(Math.max(Math.ceil(Math.log2(e)),-128),127);return n.multiplyScalar(Math.pow(2,-t)),(t+128)/255}class _D{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._blurMaterial=CD(Eo),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){yf=this._renderer.getRenderTarget();const s=this._allocateTargets();return this._sceneToCubeUV(e,i,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){this._cubemapShader===null&&(this._cubemapShader=ox(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){this._equirectShader===null&&(this._equirectShader=sx(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),this._cubemapShader!==null&&this._cubemapShader.dispose(),this._equirectShader!==null&&this._equirectShader.dispose();for(let e=0;e<Fa.length;e++)Fa[e].dispose()}_cleanup(e){this._pingPongRenderTarget.dispose(),this._renderer.setRenderTarget(yf),e.scissorTest=!1,Yc(e,0,0,e.width,e.height)}_fromTexture(e){yf=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(e){const t={magFilter:Lt,minFilter:Lt,generateMipmaps:!1,type:Dr,format:D0,encoding:TD(e)?e.encoding:Hl,depthBuffer:!1},i=rx(t);return i.depthBuffer=!e,this._pingPongRenderTarget=rx(t),i}_compileMaterial(e){const t=new It(Fa[0],e);this._renderer.compile(t,gf)}_sceneToCubeUV(e,t,i,r){const l=new zt(90,1,t,i),u=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],f=this._renderer,h=f.autoClear,m=f.outputEncoding,y=f.toneMapping;f.getClearColor(tx),f.toneMapping=nr,f.outputEncoding=ln,f.autoClear=!1;let p=!1;const d=e.background;if(d){if(d.isColor){as.color.copy(d).convertSRGBToLinear(),e.background=null;const b=ix(as.color);as.opacity=b,p=!0}}else{as.color.copy(tx).convertSRGBToLinear();const b=ix(as.color);as.opacity=b,p=!0}for(let b=0;b<6;b++){const v=b%3;v==0?(l.up.set(0,u[b],0),l.lookAt(c[b],0,0)):v==1?(l.up.set(0,0,u[b]),l.lookAt(0,c[b],0)):(l.up.set(0,u[b],0),l.lookAt(0,0,c[b])),Yc(r,v*ai,b>2?ai:0,ai,ai),f.setRenderTarget(r),p&&f.render(SD,l),f.render(e,l)}f.toneMapping=y,f.outputEncoding=m,f.autoClear=h}_textureToCubeUV(e,t){const i=this._renderer;e.isCubeTexture?this._cubemapShader==null&&(this._cubemapShader=ox()):this._equirectShader==null&&(this._equirectShader=sx());const r=e.isCubeTexture?this._cubemapShader:this._equirectShader,s=new It(Fa[0],r),o=r.uniforms;o.envMap.value=e,e.isCubeTexture||o.texelSize.value.set(1/e.image.width,1/e.image.height),o.inputEncoding.value=li[e.encoding],o.outputEncoding.value=li[t.texture.encoding],Yc(t,0,0,3*ai,2*ai),i.setRenderTarget(t),i.render(s,gf)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;r<Qb;r++){const s=Math.sqrt(Xc[r]*Xc[r]-Xc[r-1]*Xc[r-1]),o=nx[(r-1)%nx.length];this._blur(e,r-1,r,s,o)}t.autoClear=i}_blur(e,t,i,r,s){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,i,r,"latitudinal",s),this._halfBlur(o,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,o,l){const u=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const f=3,h=new It(Fa[r],c),m=c.uniforms,y=ex[i]-1,p=isFinite(s)?Math.PI/(2*y):2*Math.PI/(2*Eo-1),d=s/p,b=isFinite(s)?1+Math.floor(f*d):Eo;b>Eo&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Eo}`);const v=[];let g=0;for(let S=0;S<Eo;++S){const w=S/d,T=Math.exp(-w*w/2);v.push(T),S==0?g+=T:S<b&&(g+=2*T)}for(let S=0;S<v.length;S++)v[S]=v[S]/g;m.envMap.value=e.texture,m.samples.value=b,m.weights.value=v,m.latitudinal.value=o==="latitudinal",l&&(m.poleAxis.value=l),m.dTheta.value=p,m.mipInt.value=wr-i,m.inputEncoding.value=li[e.texture.encoding],m.outputEncoding.value=li[e.texture.encoding];const M=ex[r],_=3*Math.max(0,ai-2*M),E=(r===0?0:2*ai)+2*M*(r>wr-To?r-wr+To:0);Yc(t,_,E,3*M,2*M),u.setRenderTarget(t),u.render(h,gf)}}function TD(n){return n===void 0||n.type!==Dr?!1:n.encoding===ln||n.encoding===Ur||n.encoding===Gl}function ED(){const n=[],e=[],t=[];let i=wr;for(let r=0;r<Qb;r++){const s=Math.pow(2,i);e.push(s);let o=1/s;r>wr-To?o=Kb[r-wr+To-1]:r==0&&(o=0),t.push(o);const l=1/(s-1),u=-l/2,c=1+l/2,f=[u,u,c,u,c,c,u,u,c,c,u,c],h=6,m=6,y=3,p=2,d=1,b=new Float32Array(y*m*h),v=new Float32Array(p*m*h),g=new Float32Array(d*m*h);for(let _=0;_<h;_++){const E=_%3*2/3-1,S=_>2?0:-1,w=[E,S,0,E+2/3,S,0,E+2/3,S+1,0,E,S,0,E+2/3,S+1,0,E,S+1,0];b.set(w,y*m*_),v.set(f,p*m*_);const T=[_,_,_,_,_,_];g.set(T,d*m*_)}const M=new Ve;M.setAttribute("position",new Ge(b,y)),M.setAttribute("uv",new Ge(v,p)),M.setAttribute("faceIndex",new Ge(g,d)),n.push(M),i>To&&i--}return{_lodPlanes:n,_sizeLods:e,_sigmas:t}}function rx(n){const e=new Vn(3*ai,3*ai,n);return e.texture.mapping=Is,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Yc(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function CD(n){const e=new Float32Array(n),t=new X(0,1,0);return new bo({name:"SphericalGaussianBlur",defines:{n},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t},inputEncoding:{value:li[ln]},outputEncoding:{value:li[ln]}},vertexShader:vf(),fragmentShader:`
2917
2917
 
2918
2918
  precision mediump float;
@@ -3447,7 +3447,7 @@ void main() {
3447
3447
  #include <fog_fragment>
3448
3448
  #include <premultiplied_alpha_fragment>
3449
3449
 
3450
- }`};class f extends c.ShaderMaterial{constructor(m){super({type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(p){this.uniforms.diffuse.value=p}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(p){this.uniforms.linewidth.value=p}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(y){!!y!="USE_DASH"in this.defines&&(this.needsUpdate=!0),y===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(p){this.uniforms.dashScale.value=p}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(p){this.uniforms.dashSize.value=p}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(p){this.uniforms.dashOffset.value=p}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(p){this.uniforms.gapSize.value=p}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(p){this.uniforms.opacity.value=p}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(p){this.uniforms.resolution.value.copy(p)}},alphaToCoverage:{enumerable:!0,get:function(){return"ALPHA_TO_COVERAGE"in this.defines},set:function(p){!!p!="ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),p===!0?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(m)}}f.prototype.isLineMaterial=!0},(o,l,u)=>{var c=u(4);l.Minimap=function(f){var h=f;this.camera=new c.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;var m=new c.BufferGeometry,y=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]),p=new c.BufferAttribute(y,3);m.setAttribute("position",p);var d=new c.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new c.Mesh(m,d);var b=new c.Box3,v=new c.Vector3;this.getDiffFromNormalised=(M,_)=>{b.setFromBufferAttribute(p).getCenter(v);var E=v.clone().project(this.camera),S=new c.Vector3(M,_,E.z).unproject(this.camera);return S.sub(v)};var g=(M,_)=>{h.camera.near&&(this.camera.near=h.camera.near),_.farPlane&&(this.camera.far=_.farPlane),_.eyePosition&&this.camera.position.set(_.eyePosition[0],_.eyePosition[1],_.eyePosition[2]),_.upVector&&this.camera.up.set(_.upVector[0],_.upVector[1],_.upVector[2]),_.targetPosition&&this.camera.lookAt(new c.Vector3(_.targetPosition[0],_.targetPosition[1],_.targetPosition[2])),this.camera.zoom=1/M,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{var M=new c.Vector3().copy(h.camera.target).project(h.camera),_=new c.Vector3(-1,-1,M.z).unproject(h.camera),E=new c.Vector3(1,-1,M.z).unproject(h.camera),S=new c.Vector3(1,1,M.z).unproject(h.camera),w=new c.Vector3(-1,1,M.z).unproject(h.camera);p.copyVector3sArray([_,E,S,S,w,_]),p.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();var M=h.getZincCameraControls(),_=h.getBoundingBox();if(_){var E=_.min.distanceTo(_.max),S=E/2,w=(_.min.x+_.max.x)/2,T=(_.min.y+_.max.y)/2,C=(_.min.z+_.max.z)/2,R=M.getViewportFromCentreAndRadius(w,T,C,S,40,S*4);g(E,R)}}}},(o,l,u)=>{var c=u(4),f=u(51)(c),h=u(3).Geometry,m=u(52),y=u(53).default,p=c.BufferGeometryLoader,d=function(b){var v;b&&b.isGeometry&&(v=b);var g=void 0,M=void 0,_=!1,E=void 0,S=P=>{var L=v.getMorph().material.clone();L.morphTargets=!1;var A=new h,I=new p,O=I.parse(P),x=new c.Mesh(O.geometry,L);return A.geometry=x.geometry,x.userData=A,A.setMorph(x),A},w=P=>{switch(P.data.action){case"message":console.log(P.data.message);break;case"result":var L=new d(S(P.data.object));E&&E(L),E=void 0,_=!1;break;default:throw"Cannot handle specified action."}},T=P=>{if(m!==void 0&&(M=m(54)),!M)g=new(u(55)).GeometryCSGInternal(P);else if(P&&P.isGeometry){var L=P.getMorph(),A=L.geometry.clone().applyMatrix(L.matrix).toJSON();M.addEventListener("message",function(I){w(I)}),M.postMessage({action:"initialise",object:A})}};this.getHostGeometry=()=>{var P=new f(v.getMorph());return new C(P)},this.getGeometry=()=>v;var C=P=>{var L=v.getMorph().material.clone();L.morphTargets=!1;var A=P.toMesh(L),I=new h;return I.geometry=A.geometry,A.userData=I,I.setMorph(A),I};this.setCSG=P=>{g.setCSG(P)};var R=(P,L,A,I)=>{if(_)I("On progress");else{var O=P.getMorph(),x=O.geometry.clone().applyMatrix(O.matrix).toJSON();E=A,_=!0,M.postMessage({action:L,object:x})}};this.intersect=P=>new y((L,A)=>{if(M)R(P,"intersect",L,A);else{var I=g.intersect(P),O=new d(C(I));O.setCSG(I),L(O)}}),this.subtract=P=>new y((L,A)=>{if(M)R(P,"intersect",L,A);else{var I=g.subtract(P),O=new d(C(I));O.setCSG(I),L(O)}}),this.union=P=>new y((L,A)=>{if(M)R(P,"intersect",L,A);else{var I=g.union(P),O=new d(C(I));O.setCSG(I),L(O)}}),this.terminateWorker=()=>{M&&M.terminate()},T(b)};l.GeometryCSG=d},o=>{var l=1e-5,u=0,c=1,f=2,h=3;o.exports=function(m){var y=function(p){var d,b,v,g,M,_,E,S=[];if(p.isBufferGeometry&&(p=new m.Geometry().fromBufferGeometry(p)),p instanceof m.Geometry)this.matrix=new m.Matrix4;else if(p.isMesh)p.updateMatrix(),this.matrix=p.matrix.clone(),p=p.geometry,p.isBufferGeometry&&(p=new m.Geometry().fromBufferGeometry(p)),p.mergeVertices(),p.computeVertexNormals(!1);else{if(p instanceof y.Node)return this.tree=p,this.matrix=new m.Matrix4,this;throw"ThreeBSP: Given geometry is unsupported"}for(d=0,b=p.faces.length;d<b;d++)v=p.faces[d],M=p.faceVertexUvs[0][d],E=new y.Polygon,v instanceof m.Face3?(g=p.vertices[v.a],_=M?new m.Vector2(M[0].x,M[0].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[0],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.b],_=M?new m.Vector2(M[1].x,M[1].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[2],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.c],_=M?new m.Vector2(M[2].x,M[2].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[2],_),g.applyMatrix4(this.matrix),E.vertices.push(g)):(m.Face4,g=p.vertices[v.a],_=M?new m.Vector2(M[0].x,M[0].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[0],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.b],_=M?new m.Vector2(M[1].x,M[1].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[1],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.c],_=M?new m.Vector2(M[2].x,M[2].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[2],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.d],_=M?new m.Vector2(M[3].x,M[3].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[3],_),g.applyMatrix4(this.matrix),E.vertices.push(g)),E.calculateProperties(),S.push(E);this.tree=new y.Node(S)};return y.prototype.subtract=function(p){var d=this.tree.clone(),b=p.tree.clone();return d.invert(),d.clipTo(b),b.clipTo(d),b.invert(),b.clipTo(d),b.invert(),d.build(b.allPolygons()),d.invert(),d=new y(d),d.matrix=this.matrix,d},y.prototype.union=function(p){var d=this.tree.clone(),b=p.tree.clone();return d.clipTo(b),b.clipTo(d),b.invert(),b.clipTo(d),b.invert(),d.build(b.allPolygons()),d=new y(d),d.matrix=this.matrix,d},y.prototype.intersect=function(p){var d=this.tree.clone(),b=p.tree.clone();return d.invert(),b.clipTo(d),b.invert(),d.clipTo(b),b.clipTo(d),d.build(b.allPolygons()),d.invert(),d=new y(d),d.matrix=this.matrix,d},y.prototype.toGeometry=function(){var p,d,b,v,g,M,_,E,S,w,T=new m.Matrix4().getInverse(this.matrix),C=new m.Geometry,R=this.tree.allPolygons(),P=R.length,L={};for(p=0;p<P;p++)for(b=R[p],v=b.vertices.length,d=2;d<v;d++)w=[],E=b.vertices[0],w.push(new m.Vector2(E.uv.x,E.uv.y)),E=new m.Vector3(E.x,E.y,E.z),E.applyMatrix4(T),typeof L[E.x+","+E.y+","+E.z]>"u"?(C.vertices.push(E),g=L[E.x+","+E.y+","+E.z]=C.vertices.length-1):g=L[E.x+","+E.y+","+E.z],E=b.vertices[d-1],w.push(new m.Vector2(E.uv.x,E.uv.y)),E=new m.Vector3(E.x,E.y,E.z),E.applyMatrix4(T),typeof L[E.x+","+E.y+","+E.z]>"u"?(C.vertices.push(E),M=L[E.x+","+E.y+","+E.z]=C.vertices.length-1):M=L[E.x+","+E.y+","+E.z],E=b.vertices[d],w.push(new m.Vector2(E.uv.x,E.uv.y)),E=new m.Vector3(E.x,E.y,E.z),E.applyMatrix4(T),typeof L[E.x+","+E.y+","+E.z]>"u"?(C.vertices.push(E),_=L[E.x+","+E.y+","+E.z]=C.vertices.length-1):_=L[E.x+","+E.y+","+E.z],S=new m.Face3(g,M,_,new m.Vector3(b.normal.x,b.normal.y,b.normal.z)),C.faces.push(S),C.faceVertexUvs[0].push(w);return C},y.prototype.toBufferGeometry=function(){var p=this.toGeometry(),d=new m.BufferGeometry().fromGeometry(p);return d},y.prototype.toMesh=function(p){var d=this.toBufferGeometry(),b=new m.Mesh(d,p);return b.position.setFromMatrixPosition(this.matrix),b.rotation.setFromRotationMatrix(this.matrix),b},y.Polygon=function(p){p instanceof Array||(p=[]),this.vertices=p,0<p.length?this.calculateProperties():this.normal=this.w=void 0},y.Polygon.prototype.calculateProperties=function(){var p=this.vertices[0],d=this.vertices[1],b=this.vertices[2];return this.normal=d.clone().subtract(p).cross(b.clone().subtract(p)).normalize(),this.w=this.normal.clone().dot(p),this},y.Polygon.prototype.clone=function(){var p,d,b=new y.Polygon;for(p=0,d=this.vertices.length;p<d;p++)b.vertices.push(this.vertices[p].clone());return b.calculateProperties(),b},y.Polygon.prototype.flip=function(){var p,d=[];for(this.normal.multiplyScalar(-1),this.w*=-1,p=this.vertices.length-1;0<=p;p--)d.push(this.vertices[p]);return this.vertices=d,this},y.Polygon.prototype.classifyVertex=function(p){var d=this.normal.dot(p)-this.w;return d<-l?f:d>l?c:u},y.Polygon.prototype.classifySide=function(p){var d,b,v,g=0,M=0,_=p.vertices.length;for(d=0;d<_;d++)b=p.vertices[d],v=this.classifyVertex(b),v===c?g++:v===f&&M++;return 0<g&&M===0?c:g===0&&0<M?f:g===0&&M===0?u:h},y.Polygon.prototype.splitPolygon=function(p,d,b,v,g){var M=this.classifySide(p);if(M===u)(0<this.normal.dot(p.normal)?d:b).push(p);else if(M===c)v.push(p);else if(M===f)g.push(p);else{var _,E,S,w,T,C,R,P,L,A=[],I=[];for(E=0,_=p.vertices.length;E<_;E++)S=(E+1)%_,C=p.vertices[E],R=p.vertices[S],w=this.classifyVertex(C),T=this.classifyVertex(R),w!=f&&A.push(C),w!=c&&I.push(C),(w|T)==h&&(P=(this.w-this.normal.dot(C))/this.normal.dot(R.clone().subtract(C)),L=C.interpolate(R,P),A.push(L),I.push(L));3<=A.length&&v.push(new y.Polygon(A).calculateProperties()),3<=I.length&&g.push(new y.Polygon(I).calculateProperties())}},y.Vertex=function(p,d,b,v,g){this.x=p,this.y=d,this.z=b,this.normal=v||new m.Vector3,this.uv=g||new m.Vector2},y.Vertex.prototype.clone=function(){return new y.Vertex(this.x,this.y,this.z,this.normal.clone(),this.uv.clone())},y.Vertex.prototype.add=function(p){return this.x+=p.x,this.y+=p.y,this.z+=p.z,this},y.Vertex.prototype.subtract=function(p){return this.x-=p.x,this.y-=p.y,this.z-=p.z,this},y.Vertex.prototype.multiplyScalar=function(p){return this.x*=p,this.y*=p,this.z*=p,this},y.Vertex.prototype.cross=function(p){var d=this.x,b=this.y,v=this.z;return this.x=b*p.z-v*p.y,this.y=v*p.x-d*p.z,this.z=d*p.y-b*p.x,this},y.Vertex.prototype.normalize=function(){var p=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return this.x/=p,this.y/=p,this.z/=p,this},y.Vertex.prototype.dot=function(p){return this.x*p.x+this.y*p.y+this.z*p.z},y.Vertex.prototype.lerp=function(p,d){return this.add(p.clone().subtract(this).multiplyScalar(d)),this.normal.add(p.normal.clone().sub(this.normal).multiplyScalar(d)),this.uv.add(p.uv.clone().sub(this.uv).multiplyScalar(d)),this},y.Vertex.prototype.interpolate=function(p,d){return this.clone().lerp(p,d)},y.Vertex.prototype.applyMatrix4=function(p){var d=this.x,b=this.y,v=this.z,g=p.elements;return this.x=g[0]*d+g[4]*b+g[8]*v+g[12],this.y=g[1]*d+g[5]*b+g[9]*v+g[13],this.z=g[2]*d+g[6]*b+g[10]*v+g[14],this},y.Node=function(p){var d,b,v=[],g=[];if(this.polygons=[],this.front=this.back=void 0,p instanceof Array&&p.length!==0){for(this.divider=p[0].clone(),d=0,b=p.length;d<b;d++)this.divider.splitPolygon(p[d],this.polygons,this.polygons,v,g);0<v.length&&(this.front=new y.Node(v)),0<g.length&&(this.back=new y.Node(g))}},y.Node.isConvex=function(p){var d,b;for(d=0;d<p.length;d++)for(b=0;b<p.length;b++)if(d!==b&&p[d].classifySide(p[b])!==f)return!1;return!0},y.Node.prototype.build=function(p){var d,b,v=[],g=[];for(this.divider||(this.divider=p[0].clone()),d=0,b=p.length;d<b;d++)this.divider.splitPolygon(p[d],this.polygons,this.polygons,v,g);0<v.length&&(!this.front&&(this.front=new y.Node),this.front.build(v)),0<g.length&&(!this.back&&(this.back=new y.Node),this.back.build(g))},y.Node.prototype.allPolygons=function(){var p=this.polygons.slice();return this.front&&(p=p.concat(this.front.allPolygons())),this.back&&(p=p.concat(this.back.allPolygons())),p},y.Node.prototype.clone=function(){var p=new y.Node;return p.divider=this.divider.clone(),p.polygons=this.polygons.map(function(d){return d.clone()}),p.front=this.front&&this.front.clone(),p.back=this.back&&this.back.clone(),p},y.Node.prototype.invert=function(){var p,d,b;for(p=0,d=this.polygons.length;p<d;p++)this.polygons[p].flip();return this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),b=this.front,this.front=this.back,this.back=b,this},y.Node.prototype.clipPolygons=function(p){var d,b,v,g;if(!this.divider)return p.slice();for(v=[],g=[],d=0,b=p.length;d<b;d++)this.divider.splitPolygon(p[d],v,g,v,g);return this.front&&(v=this.front.clipPolygons(v)),g=this.back?this.back.clipPolygons(g):[],v.concat(g)},y.Node.prototype.clipTo=function(p){this.polygons=p.clipPolygons(this.polygons),this.front&&this.front.clipTo(p),this.back&&this.back.clipTo(p)},y}},o=>{o.exports=YB()},o=>{o.exports=iF},(o,l,u)=>{var c=u(3).Geometry,f=u(4),h=f.BufferGeometryLoader;o.exports=function(m){var y=void 0,p=function(_){var E=new h,S=E.parse(_),w=new f.MeshPhongMaterial,T=new f.Mesh(S.geometry,w),C=new c;return C.setMorph(T),C},d=function(_){var E=p(_);y=new(u(55)).GeometryCSGInternal(E),m.postMessage({action:"message",message:"Initialised"})},b=function(_){if(y){var E=p(_),S=y.intersect(E),w=S.toBufferGeometry().toJSON();m.postMessage({action:"result",object:w})}},v=function(_){if(y){var E=p(_),S=y.subtract(E),w=S.toBufferGeometry().toJSON();m.postMessage({action:"result",object:w})}},g=function(_){if(y){var E=p(_),S=y.union(E),w=S.toBufferGeometry().toJSON();m.postMessage({action:"result",object:w})}};m.addEventListener("message",function(M){switch(M.data.action){case"initialise":d(M.data.object);break;case"intersect":b(M.data.object);break;case"subtract":v(M.data.object);break;case"union":g(M.data.object);break;default:throw"Cannot handle specified action."}})}},(o,l,u)=>{var c=u(4),f=u(51)(c);u(3).Geometry,u(50).GeometryCSG;var h=function(m){var y;m&&m.isGeometry&&(y=m);var p;this.setGeometry=b=>{b&&b.isGeometry&&(y=b),p=void 0},this.setCSG=b=>{p=b};var d=b=>{if(y&&y.morph&&b&&b.morph){p===void 0&&(p=new f(y.morph));var v=new f(b.morph);return v}};this.intersect=b=>{var v=d(b);return p&&v?p.intersect(v):void 0},this.subtract=b=>{var v=d(b);return p&&v?p.subtract(v):void 0},this.union=b=>{var v=d(b);return p&&v?p.union(v):void 0}};l.GeometryCSGInternal=h},(o,l,u)=>{var c=u(4),f=u(51)(c);u(18).Glyphset;var h=function(m){var y;m&&m.isGlyphset&&(y=m);var p=[];this.setGlyphset=v=>{v&&v.isGlyphset&&(y=v),hostCSG=void 0},this.getGlyphset=()=>y;var d=()=>v=>{var g=v.getMesh(),M=v.getLabel();if(g){var _=new f(g.geometry.clone().applyMatrix(g.matrix)),E=[];E.csg=_,E.label=M,g.material&&(E.material=g.material.clone()),p.push(E)}},b=v=>{if(y&&v&&v.getMorph()){p.length==0&&y.forEachGlyph(d());var g=new f(v.getMorph());return g}};this.intersect=v=>{var g=b(v);if(0<p.length&&g){for(var M=new(u(18)).Glyphset,_=0;_<p.length;_++){var E=p[_],S=E.csg.intersect(g),w=S.toMesh();if(w&&w.geometry&&0<w.geometry.vertices.length){E.material&&(w.material=E.material,w.material.side=c.DoubleSide,w.material.clippingPlanes=null);var T=M.addMeshAsGlyph(w,_+1);T.setLabel(E.label)}}var C=new h(M);return C}}};l.GlyphsetCSG=h}],i={};function r(o){var l=i[o];if(l!==void 0)return l.exports;var u=i[o]={exports:{}};return t[o].call(u.exports,u,u.exports,r),u.exports}r.n=o=>{var l=o&&o.__esModule?()=>o.default:()=>o;return r.d(l,{a:l}),l},r.d=(o,l)=>{for(var u in l)r.o(l,u)&&!r.o(o,u)&&Object.defineProperty(o,u,{enumerable:!0,get:l[u]})},r.o=(o,l)=>Object.prototype.hasOwnProperty.call(o,l),r.r=o=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})};var s=r(0);return s})())})(Xg);var Sr=Xg.exports;const Kc=OA(Sr),Tx=(n,e)=>{if(n){let t="";n.forEach(i=>{t=i.uuid,i.region&&(t=i.region.uuid+"/"+t),i&&i.getVisibility()&&e.push(t)})}return e},Rf=(n,e)=>{const t=n[0]-e[0],i=n[1]-e[1],r=n[2]-e[2];return Math.sqrt(t*t+i*i+r*r)},rF=n=>{const e=n.zincObjects;if(e.length>0&&e[0]){const t=e[0];if(t.isEditable&&t.isLines2){const i=n.identifiers[0].extraData.intersected;if(i&&i.faceIndex>-1){const r=t.getVerticesByFaceIndex(i.faceIndex),s=n.identifiers[0].extraData.intersected.pointOnLine;if(r.length>1){const o=Rf(r[0],[s.x,s.y,s.z]),l=Rf(r[1],[s.x,s.y,s.z]);return o>l?{zincObject:t,faceIndex:i.faceIndex,vertexIndex:i.faceIndex*2+1,point:r[0]}:{zincObject:t,faceIndex:i.faceIndex,vertexIndex:i.faceIndex*2,point:r[1]}}}}}},sF=n=>{const e=n.zincObjects;if(e.length>0&&e[0]){const t=e[0];if(t.isEditable)return t}},oF=(n,e,t)=>{if(n!=null&&n.isEditable&&(n!=null&&n.isPointset)){let i=!1;for(let r=0;r<3&&!i;r++)t[r]!==0&&(i=!0);if(i&&e>-1){const r=n.getVerticesByIndex(e);return r&&(r[0]=r[0]+t[0],r[1]=r[1]+t[1],r[2]=r[2]+t[2]),n.editVertices([r],e),n.boundingBoxUpdateRequired=!0,!0}}return!1},Qc=(n,e)=>{if(n!=null&&n.isEditable&&(n!=null&&n.isLines2)&&e>-1){const t=n.getVerticesByFaceIndex(e);if(t&&t.length>1)return Rf(t[1],t[0])}return 0},Pf=(n,e,t,i)=>{if(n&&t!==0&&n.isEditable&&n.isLines2&&e>-1){const r=n.getVerticesByFaceIndex(e);let s=[r[1][0]-r[0][0],r[1][1]-r[0][1],r[1][2]-r[0][2]];const o=Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]);for(let l=0;l<3;l++)s[l]=s[l]/o*t,i?r[1][l]=r[0][l]+s[l]:(r[0][l]=r[0][l]+s[l],r[1][l]=r[1][l]+s[l]);return n.editVertices(r,e*2),n.boundingBoxUpdateRequired=!0,!0}return!1},aF=(n,e)=>{const t=e.getBoundingBox(),i=new Sr.THREE.Vector3().subVectors(t.max,t.min),r=new Sr.THREE.BoxGeometry(i.x,i.y,i.z);i.addVectors(t.min,t.max).multiplyScalar(.5);const s=r.getAttribute("position"),o=s.count,l=[];for(let u=0;u<o;u++)l[u]=[s.array[u*3],s.array[u*3+1],s.array[u*3+2]];n.editVertices(l,0),n.setPosition(i.x,i.y,i.z),r.dispose()},Ex=(n,e)=>{let t="";n.isRegion&&(t=`__r${n.regionPath}`),n.isPrimitives&&(t=`${n.regionPath}/${n.label}`),e.push(t),n.children&&n.children.forEach(i=>Ex(i,e))},Lo=(n,e,t,i)=>{let r=n;const s=[];if(t&&(r=n.findChildFromPath(t)),r){const o=Array.isArray(e);let l=e;o||(l=[l]),l.forEach(u=>{const c=r.findObjectsWithGroupName(u,i);s.push(...c)})}return s},If=(n,e,t)=>{const i=n.findIndex(s=>s.uuid===e);let r;return i>-1&&(r=n[i],t&&n.splice(i,1)),r},lF=(n,e)=>{const t=[];if(n&&e&&e.length>0){const i={},r={},s=[n,...n.getChildRegions(!0)];let o,l,u;e.forEach(c=>{const f=c.split("/");u=f[0],o=If(s,u,!1),o&&(r[u]||(r[u]=o.getFullPath()),f[1]?(i[u]||(i[u]=o.getAllObjects(!1)),l=If(i[u],f[1],!0),l&&t.push(`${r[u]}/${l.groupName}`)):t.push(`__r/${r[u]}`))})}return t},cF=n=>{if(n){const e=[];return n.forEach(i=>{i.isZincObject?e.push(i):i.isRegion&&e.push(...i.getAllObjects(!0))}),Object.values(e.reduce((i,r)=>({...i,[r.uuid]:r}),{}))}return[]},Cx=(n,e)=>{const t={label:"Multiple selections",regionPath:"",objects:[]};if(e&&n){const i={},r=n.getRootRegion();e.length>0&&(t.regionPath=e[0].data.region,t.label=e[0].data.group),e.forEach(s=>{s.data.region.includes(t.regionPath)||(t.regionPath=""),t.label!==s.data.group&&(t.label="Multiple selections");const o=r.findChildFromPath(s.data.region);i[o.uuid]||(i[o.uuid]=o.getAllObjects(!1));const l=If(i[o.uuid],s.data.uuid);l&&t.objects.push(l)})}return t},uF=n=>{const e=n.getMorph();let t="position";n.isLines2&&(t="instanceStart");const i=[];let r=0;const s=e.geometry.getAttribute(t);for(let o=0;o<n.drawRange;o++)i.push([s.array[r++],s.array[r++],s.array[r++]]);return i},dF=(n,e,t,i,r)=>{let s;if(n.isPointset?s="MultiPoint":n.isLines2&&(s="MultiLineString"),s){const o=uF(n);let l=e.slice(-1)==="/"?e:e+"/";l=l+t;const u=l,c={resource:i,item:{id:u},body:{evidence:[],comment:r},feature:{id:u,properties:{drawn:!0,label:"Drawn annotation"},geometry:{coordinates:o,type:s}}};return r==="Deleted"&&(c.feature=void 0),c}},Ax=(n,e,t,i,r,s,o)=>{const l=dF(t,i,r,s,o);if(l)return n&&n.currentUser&&(l.creator={...n.currentUser},l.creator.orcid||(l.creator.orcid="0000-0000-0000-0000"),n.addAnnotation(e,l).then(u=>{u.annotationId||console.log("There is a problem with the submission, please try again later")}).catch(()=>{console.log("There is a problem with the submission, please try again later")})),l},Lx=async(n,e,t)=>{const i=t;return await n.drawnFeatures(e,i)},Of=(n,e)=>{n&&e.forEach(t=>{const i=t.geometry,r=decodeURIComponent(t.id),s=r.lastIndexOf("/"),o=r.substring(0,s),l=r.substring(s+1);let u;i.type==="MultiPoint"?u=n.createPoints(o,l,i.coordinates,l,8942):i.type==="MultiLineString"&&(u=n.createLines(o,l,i.coordinates,60962)),u&&(u.zincObject.isEditable=!0)})},ki=(n,e)=>{const t=n.__vccOpts||n;for(const[i,r]of e)t[i]=r;return t},hF={name:"LinesControls",components:{Button:Cs,Col:Fn,Container:ei,InputNumber:Si,Main:Mi,Slider:Ln,ElIconArrowLeft:Wi,ElIconArrowRight:ji},props:{createData:{type:Object}},data:function(){return{adjust:0,pAdjust:0,lengthScale:0,distance:0,newDistance:0,width:1,currentIndex:0,ElIconArrowLeft:a.shallowRef(Wi),ElIconArrowRight:a.shallowRef(ji),edited:!1,zincObject:void 0}},watch:{"createData.faceIndex":{handler:function(n){var e;(e=this.zincObject)!=null&&e.isLines2&&(this.currentIndex=n,this.distance=Qc(this.zincObject,this.currentIndex))},immediate:!0}},methods:{changeIndex:function(n){n?Qc(this.zincObject,this.currentIndex+1)>0&&(this.currentIndex++,this.reset()):(this.currentIndex--,this.reset())},onLengthInput:function(){this.newDistance!==0?(this.distance=this.newDistance,this.edited=Pf(this.zincObject,this.currentIndex,this.newDistance,!0)||this.edited):this.newDistance=this.distance},onLengthSliding:function(){this.newDistance=Math.pow(10,this.lengthScale)*this.distance,this.edited=Pf(this.zincObject,this.currentIndex,this.newDistance,!0)||this.edited},onMoveSliding:function(){const n=(this.adjust-this.pAdjust)*this.distance;this.edited=Pf(this.zincObject,this.currentIndex,n,!1)||this.edited,this.pAdjust=this.adjust},reset:function(){this.adjust=0,this.pAdjust=0,this.lengthScale=0,this.distance=Qc(this.zincObject,this.currentIndex),this.newDistance=this.distance,this.edited&&(this.$emit("primitivesUpdated",this.zincObject),this.edited=!1)},setObject:function(n){this.currentIndex=-1,this.distance=0,n.isLines2?(this.zincObject=a.markRaw(n),this.width=this.zincObject.getMorph().material.linewidth,n.isEditable&&(this.currentIndex=0,this.distance=Qc(n,this.currentIndex))):(this.zincObject=void 0,this.width=10)},modifyWidth:function(){this.zincObject.setWidth(this.width)}}};function fF(n,e,t,i,r,s){const o=Fn,l=Ln,u=Si,c=Qn,f=Cs,h=Mi,m=ei;return a.openBlock(),a.createBlock(m,{class:"lines-container"},{default:a.withCtx(()=>[a.createVNode(h,{class:"slides-block"},{default:a.withCtx(()=>[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Width: ")]),_:1}),a.createVNode(o,{offset:0,span:12},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.width,"onUpdate:modelValue":e[0]||(e[0]=y=>n.width=y),class:"my-slider",step:1,min:1,max:100,"show-tooltip":!1,onInput:s.modifyWidth},null,8,["modelValue","onInput"])]),_:1}),a.createVNode(o,{offset:0,span:4},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.width,"onUpdate:modelValue":e[1]||(e[1]=y=>n.width=y),step:1,min:1,max:100,controls:!1,class:"input-box number-input"},null,8,["modelValue"])]),_:1})]),_:1}),n.currentIndex>-1&&n.distance>0?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:4},{default:a.withCtx(()=>[a.createVNode(f,{size:"small",disabled:n.currentIndex===0,icon:n.ElIconArrowLeft,onClick:e[2]||(e[2]=y=>s.changeIndex(!1))},null,8,["disabled","icon"])]),_:1}),a.createVNode(o,{offset:4,span:9},{default:a.withCtx(()=>[a.createTextVNode(" Editing Line "+a.toDisplayString(n.currentIndex+1),1)]),_:1}),a.createVNode(o,{offset:2,span:2},{default:a.withCtx(()=>[a.createVNode(f,{size:"small",icon:n.ElIconArrowRight,onClick:e[3]||(e[3]=y=>s.changeIndex(!0))},null,8,["icon"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Move: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.adjust,"onUpdate:modelValue":e[4]||(e[4]=y=>n.adjust=y),step:.01,min:-3,max:3,"show-tooltip":!1,onInput:e[5]||(e[5]=y=>s.onMoveSliding()),onChange:e[6]||(e[6]=y=>s.reset())},null,8,["modelValue"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Length: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.lengthScale,"onUpdate:modelValue":e[7]||(e[7]=y=>n.lengthScale=y),step:.01,min:-1,max:1,"show-tooltip":!1,onInput:e[8]||(e[8]=y=>s.onLengthSliding()),onChange:e[9]||(e[9]=y=>s.reset())},null,8,["modelValue"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.newDistance,"onUpdate:modelValue":e[10]||(e[10]=y=>n.newDistance=y),controls:!1,class:"input-box number-input",onChange:s.onLengthInput},null,8,["modelValue","onChange"])]),_:1})]),_:1})],64)):a.createCommentVNode("",!0)]),_:1})]),_:1})}const Rx=ki(hF,[["render",fF],["__scopeId","data-v-6581aa67"]]),pF={name:"PointsControls",components:{Col:Fn,Container:ei,InputNumber:Si,Main:Mi,Select:As,Slider:Ln,Row:Qn,Option:Ls,ElIconArrowLeft:Wi,ElIconArrowRight:ji},inject:["boundingDims"],data:function(){return{attenuation:!1,size:10,choices:[{value:!0,label:"On"},{value:!1,label:"off"}],min:[0,0,0],max:[1,1,1],translation:[0,0,0],pTranslation:[0,0,0],currentIndex:-1,ElIconArrowLeft:a.shallowRef(Wi),ElIconArrowRight:a.shallowRef(ji),edited:!1,zincObject:void 0}},watch:{boundingDims:{handler:function(n){const e=n.size;this.min=[-e[0]/2,-e[1]/2,-e[2]/2],this.max=[e[0]/2,e[1]/2,e[2]/2]},immediate:!0,deep:!0}},methods:{changeIndex:function(n){n?this.zincObject.drawRange>this.currentIndex+1&&(this.currentIndex++,this.reset()):(this.currentIndex--,this.reset())},onMoveSliding:function(){const n=[this.translation[0]-this.pTranslation[0],this.translation[1]-this.pTranslation[1],this.translation[2]-this.pTranslation[2]];this.edited=oF(this.zincObject,this.currentIndex,n)||this.edited;for(let e=0;e<3;e++)this.pTranslation[e]=this.translation[e]},reset:function(){this.translation=[0,0,0],this.pTranslation=[0,0,0],this.edited&&(this.$emit("primitivesUpdated",this.zincObject),this.edited=!1)},setObject:function(n){this.currentIndex=-1,n.isPointset?(this.zincObject=a.markRaw(n),this.size=this.zincObject.morph.material.size,this.attenuation=this.zincObject.morph.material.sizeAttenuation,n.isEditable&&this.zincObject.drawRange>0&&(this.currentIndex=0)):(this.zincObject=void 0,this.size=10,this.attenuation=!1)},modifyAttenuation:function(n){this.attenuation=n,this.zincObject.setSizeAttenuation(n)},modifySize:function(){this.zincObject.setSize(this.size)}}};function mF(n,e,t,i,r,s){const o=Fn,l=Ln,u=Si,c=Qn,f=Ls,h=As,m=Cs,y=Mi,p=ei;return a.openBlock(),a.createBlock(p,{class:"pointset-container"},{default:a.withCtx(()=>[a.createVNode(y,{class:"slides-block"},{default:a.withCtx(()=>[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Size: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.size,"onUpdate:modelValue":e[0]||(e[0]=d=>n.size=d),class:"my-slider",step:1,min:0,max:100,"show-tooltip":!1,onInput:e[1]||(e[1]=d=>s.modifySize())},null,8,["modelValue"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.size,"onUpdate:modelValue":e[2]||(e[2]=d=>n.size=d),step:1,min:0,max:100,controls:!1,class:"input-box number-input"},null,8,["modelValue"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createTextVNode(" Size attenuation: ")]),_:1}),a.createVNode(o,{offset:0,span:5},{default:a.withCtx(()=>[a.createVNode(h,{teleported:!1,"model-value":n.attenuation,placeholder:"Select",class:"input-box","popper-class":"viewer_dropdown",onChange:e[3]||(e[3]=d=>s.modifyAttenuation(d,n.slide))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.choices,d=>(a.openBlock(),a.createBlock(f,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["model-value"])]),_:1})]),_:1}),n.currentIndex>-1?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:4},{default:a.withCtx(()=>[a.createVNode(m,{size:"small",disabled:n.currentIndex===0,icon:n.ElIconArrowLeft,onClick:e[4]||(e[4]=d=>s.changeIndex(!1))},null,8,["disabled","icon"])]),_:1}),a.createVNode(o,{offset:4,span:9},{default:a.withCtx(()=>[a.createTextVNode(" Editing Point "+a.toDisplayString(n.currentIndex+1),1)]),_:1}),a.createVNode(o,{offset:2,span:2},{default:a.withCtx(()=>[a.createVNode(m,{size:"small",icon:n.ElIconArrowRight,onClick:e[5]||(e[5]=d=>s.changeIndex(!0))},null,8,["icon"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" x: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.translation[0],"onUpdate:modelValue":e[6]||(e[6]=d=>n.translation[0]=d),step:.01,min:n.min[0],max:n.max[0],"show-tooltip":!1,onInput:e[7]||(e[7]=d=>s.onMoveSliding()),onChange:e[8]||(e[8]=d=>s.reset())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" y: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.translation[1],"onUpdate:modelValue":e[9]||(e[9]=d=>n.translation[1]=d),step:.01,min:n.min[1],max:n.max[1],"show-tooltip":!1,onInput:e[10]||(e[10]=d=>s.onMoveSliding()),onChange:e[11]||(e[11]=d=>s.reset())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" z: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.translation[2],"onUpdate:modelValue":e[12]||(e[12]=d=>n.translation[2]=d),step:.01,min:n.min[2],max:n.max[2],"show-tooltip":!1,onInput:e[13]||(e[13]=d=>s.onMoveSliding()),onChange:e[14]||(e[14]=d=>s.reset())},null,8,["modelValue","min","max"])]),_:1})]),_:1})],64)):a.createCommentVNode("",!0)]),_:1})]),_:1})}const Px=ki(pF,[["render",mF],["__scopeId","data-v-d1de9c65"]]),gF={name:"TextureSlidesControls",components:{Col:Fn,Container:ei,Footer:Og,Icon:yt,InputNumber:Si,Main:Mi,Row:Qn,Select:As,Slider:Ln,Option:Ls,ElIconDelete:cl,ElIconPlus:ul},data:function(){return{settings:[],directions:[{value:"x",label:"x"},{value:"y",label:"y"},{value:"z",label:"z"}],zincObject:void 0}},methods:{setObject:function(n){n.isTextureSlides?(this.zincObject=a.markRaw(n),this.settings=this.zincObject.getTextureSettings()):(this.zincObject=void 0,this.settings=[])},addNewSlide:function(){const n={direction:"x",value:0},e=this.zincObject.createSlide(n);this.settings.push(e)},modifyDirection:function(n,e){e&&(e.direction=n,this.zincObject.modifySlideSettings(e))},modifySlide:function(n){n&&this.zincObject.modifySlideSettings(n)},removeSlide:function(n,e){this.zincObject.removeSlideWithId(e.id),this.settings.splice(n,1)}}};function yF(n,e,t,i,r,s){const o=Ls,l=As,u=Fn,c=Ln,f=Si,h=cl,m=yt,y=Qn,p=Mi,d=ul,b=Og,v=ei;return a.openBlock(),a.createBlock(v,{class:"t-slides-container"},{default:a.withCtx(()=>[a.createVNode(p,{class:"slides-block"},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.settings,(g,M)=>(a.openBlock(),a.createBlock(y,{key:g.id,class:"slide-row"},{default:a.withCtx(()=>[a.createVNode(u,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(l,{teleported:!1,"model-value":g.direction,placeholder:"Select",class:"input-box","popper-class":"viewer_dropdown",onChange:_=>s.modifyDirection(_,g)},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.directions,_=>(a.openBlock(),a.createBlock(o,{key:_.value,label:_.label,value:_.value},null,8,["label","value"]))),128))]),_:2},1032,["model-value","onChange"])]),_:2},1024),a.createVNode(u,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(c,{modelValue:g.value,"onUpdate:modelValue":_=>g.value=_,class:"my-slider",step:.01,min:0,max:1,"show-tooltip":!1,onInput:_=>s.modifySlide(g)},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024),a.createVNode(u,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(f,{modelValue:g.value,"onUpdate:modelValue":_=>g.value=_,step:.01,min:0,max:1,controls:!1,class:"input-box number-input"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),a.createVNode(u,{offset:0,span:2},{default:a.withCtx(()=>[a.createVNode(m,{class:"delete-icon",onClick:_=>s.removeSlide(M,g)},{default:a.withCtx(()=>[a.createVNode(h)]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1024))),128))]),_:1}),a.createVNode(b,{height:"30px",class:"add-slides-text",onClick:s.addNewSlide},{default:a.withCtx(()=>[a.createVNode(y,null,{default:a.withCtx(()=>[a.createVNode(u,{span:2},{default:a.withCtx(()=>[a.createVNode(m,null,{default:a.withCtx(()=>[a.createVNode(d)]),_:1})]),_:1}),a.createVNode(u,{span:20},{default:a.withCtx(()=>[a.createTextVNode(" Add a new slide ")]),_:1})]),_:1})]),_:1},8,["onClick"])]),_:1})}const Ix=ki(gF,[["render",yF],["__scopeId","data-v-12185b7f"]]),vF={name:"TransformationControls",components:{Col:Fn,Container:ei,InputNumber:Si,Main:Mi,Slider:Ln},inject:["boundingDims"],data:function(){return{x:0,y:0,z:0,scale:1,min:[0,0,0],max:[1,1,1],zincObject:void 0}},watch:{boundingDims:{handler:function(n){const e=n.centre,t=n.size;this.min=[e[0]-t[0],e[1]-t[1],e[2]-t[2]],this.max=[e[0]+t[0],e[1]+t[1],e[2]+t[2]]},immediate:!0,deep:!0}},methods:{setObject:function(n){if(n.isZincObject){this.zincObject=a.markRaw(n);const e=this.zincObject.getGroup();e&&e.position&&(this.x=e.position.x,this.y=e.position.y,this.z=e.position.z,this.scale=e.scale.x)}else this.zincObject=void 0,this.x=0,this.y=0,this.z=0,this.scale=1},modifyPosition:function(){this.zincObject.setPosition(this.x,this.y,this.z)},modifyScale:function(){this.zincObject.setScaleAll(this.scale)}}};function bF(n,e,t,i,r,s){const o=Fn,l=Ln,u=Si,c=Qn,f=Mi,h=ei;return a.openBlock(),a.createBlock(h,{class:"transformation-container"},{default:a.withCtx(()=>[a.createVNode(f,{class:"slides-block"},{default:a.withCtx(()=>[a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" x: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.x,"onUpdate:modelValue":e[0]||(e[0]=m=>n.x=m),step:.01,min:n.min[0],max:n.max[0],"show-tooltip":!1,onInput:e[1]||(e[1]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.x,"onUpdate:modelValue":e[2]||(e[2]=m=>n.x=m),step:.01,min:n.min[0],max:n.max[0],controls:!1,class:"input-box number-input",onChange:e[3]||(e[3]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" y: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.y,"onUpdate:modelValue":e[4]||(e[4]=m=>n.y=m),step:.01,min:n.min[1],max:n.max[1],"show-tooltip":!1,onInput:e[5]||(e[5]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.y,"onUpdate:modelValue":e[6]||(e[6]=m=>n.y=m),step:.01,min:n.min[1],max:n.max[1],controls:!1,class:"input-box number-input",onChange:e[7]||(e[7]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" z: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.z,"onUpdate:modelValue":e[8]||(e[8]=m=>n.z=m),step:.01,min:n.min[2],max:n.max[2],"show-tooltip":!1,onInput:e[9]||(e[9]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.z,"onUpdate:modelValue":e[10]||(e[10]=m=>n.z=m),step:.01,min:n.min[2],max:n.max[2],controls:!1,class:"input-box number-input",onChange:e[11]||(e[11]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Scale: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.scale,"onUpdate:modelValue":e[12]||(e[12]=m=>n.scale=m),step:.01,min:0,max:5,"show-tooltip":!1,onInput:e[13]||(e[13]=m=>s.modifyScale())},null,8,["modelValue"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.scale,"onUpdate:modelValue":e[14]||(e[14]=m=>n.scale=m),step:.01,min:0,max:5,controls:!1,class:"input-box number-input",onChange:e[15]||(e[15]=m=>s.modifyScale())},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1})}const Ox=ki(vF,[["render",bF],["__scopeId","data-v-6b3997b7"]]),xF={name:"OpacityControls",components:{Container:ei,Header:S2,Main:Mi,Slider:Ln},props:{material:void 0,zincObject:void 0},data:function(){return{displayString:"100%"}},watch:{"material.opacity":function(){this.material&&this.zincObject&&this.zincObject.setAlpha(this.material.opacity)}},methods:{formatTooltip(n){return this.displayString=Math.floor(100*n+.5)+"%",this.displayString}}},wF={class:"block"},MF={class:"display"};function SF(n,e,t,i,r,s){const o=Ln,l=ei;return t.material?(a.openBlock(),a.createBlock(l,{key:0,class:"opacity-container"},{default:a.withCtx(()=>[a.createElementVNode("div",wF,[a.createElementVNode("span",MF,a.toDisplayString(n.displayString),1),a.createVNode(o,{modelValue:t.material.opacity,"onUpdate:modelValue":e[0]||(e[0]=u=>t.material.opacity=u),class:"my-slider",step:.01,min:0,max:1,"format-tooltip":s.formatTooltip,"show-tooltip":!1},null,8,["modelValue","format-tooltip"])])]),_:1})):a.createCommentVNode("",!0)}const Nx=ki(xF,[["render",SF],["__scopeId","data-v-cbfc46a5"]]),_F={name:"PrimitiveControls",components:{Collapse:Cg,CollapseItem:Ag,LinesControls:Rx,OpacityControls:Nx,PointsControls:Px,TextureSlidesControls:Ix,TransformationControls:Ox,ElIconArrowRight:ji},props:{createData:{type:Object}},data:function(){return{activeName:"oControls",material:void 0,isTextureSlides:!1,isPointset:!1,isLines:!1,drawerOpen:!0,zincObject:void 0,isEditable:!1,displayString:"100%"}},methods:{formatTooltip:function(n){return this.displayString=Math.floor(100*n+.5)+"%",this.displayString},toggleDrawer:function(){this.drawerOpen=!this.drawerOpen},setObject:function(n){var e;n?this.zincObject=a.markRaw(n):this.zincObject=void 0,this.isEditable=!!((e=this.zincObject)!=null&&e.isEditable),this.isPointset=!1,this.isTextureSlides=!1,this.isLines=!1,this.activeName="trControls",n&&(n.isTextureSlides?(this.isTextureSlides=!0,this.$refs.tSlidesControls.setObject(n),this.activeName="tsControls"):n.isPointset?(this.isPointset=!0,this.$refs.pointsetControls.setObject(n),this.activeName="pControls"):n.isLines2&&(this.isLines=!0,this.$refs.linesControls.setObject(n),this.activeName="lControls"),n.isTextureSlides||this.$refs.transformationControls.setObject(n)),n&&n.getMorph()?this.material=n.getMorph().material:this.material=void 0}}};function TF(n,e,t,i,r,s){const o=Nx,l=Ag,u=Ox,c=Ix,f=Px,h=Rx,m=Cg,y=ji,p=yt;return a.withDirectives((a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["primitive-controls",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createElementVNode("div",{class:a.normalizeClass(["my-drawer",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createVNode(m,{class:"collapse",modelValue:n.activeName,"onUpdate:modelValue":e[2]||(e[2]=d=>n.activeName=d),accordion:""},{default:a.withCtx(()=>[a.withDirectives(a.createVNode(l,{title:"Opacity",name:"oControls"},{default:a.withCtx(()=>[a.createVNode(o,{material:n.material,zincObject:n.zincObject,ref:"opacityControls"},null,8,["material","zincObject"])]),_:1},512),[[a.vShow,!n.isTextureSlides]]),a.withDirectives(a.createVNode(l,{title:"Transformation",name:"trControls"},{default:a.withCtx(()=>[a.createVNode(u,{class:"transformation-controls",ref:"transformationControls"},null,512)]),_:1},512),[[a.vShow,!n.isEditable]]),a.withDirectives(a.createVNode(l,{title:"Texture Slides",name:"tsControls"},{default:a.withCtx(()=>[a.createVNode(c,{class:"texture-controls",ref:"tSlidesControls"},null,512)]),_:1},512),[[a.vShow,n.isTextureSlides]]),a.withDirectives(a.createVNode(l,{title:"Points",name:"pControls"},{default:a.withCtx(()=>[a.createVNode(f,{class:"pointset-controls",ref:"pointsetControls",onPrimitivesUpdated:e[0]||(e[0]=d=>n.$emit("primitivesUpdated",d))},null,512)]),_:1},512),[[a.vShow,n.isPointset]]),a.withDirectives(a.createVNode(l,{title:"Lines",name:"lControls"},{default:a.withCtx(()=>[a.createVNode(h,{class:"lines-controls",ref:"linesControls",createData:t.createData,onPrimitivesUpdated:e[1]||(e[1]=d=>n.$emit("primitivesUpdated",d))},null,8,["createData"])]),_:1},512),[[a.vShow,n.isLines]])]),_:1},8,["modelValue"])],2),a.createElementVNode("div",{class:a.normalizeClass(["drawer-button",{open:n.drawerOpen,close:!n.drawerOpen}]),onClick:e[3]||(e[3]=(...d)=>s.toggleDrawer&&s.toggleDrawer(...d))},[a.createVNode(p,null,{default:a.withCtx(()=>[a.createVNode(y)]),_:1})],2)],2)),[[a.vShow,n.material||n.isTextureSlides]])}const Dx=ki(_F,[["render",TF],["__scopeId","data-v-764a8efa"]]),EF=(n,e)=>{const t=n.label.toUpperCase(),i=e.label.toUpperCase();return t<i?-1:t>i?1:0},CF={name:"ScaffoldTreeControls",components:{ElIconArrowLeft:Wi,TreeControls:Ja.TreeControls},props:{showColourPicker:Boolean,isReady:Boolean},data:function(){return{treeData:[{label:"Root",regionPath:"",id:void 0,children:[]}],active:[],hover:[],drawerOpen:!0,nodeNumbers:0,module:void 0}},computed:{treeDataEntry:function(){return this.treeData[0].children}},watch:{treeDataEntry:{deep:!0,handler:function(n){this.isReady&&this.setColourField(n)}}},methods:{addTreeItem:function(n,e,t){n.some(i=>i.label===e.label)||(Object.assign(e,{activeColour:this.getColour(e)}),n.push(e),n.sort((i,r)=>EF(i,r)),this.nodeNumbers++,this.$nextTick(()=>{!this.$refs.treeControls.$refs.regionTree.getCheckedKeys().includes(e.id)&&t.getVisibility()&&this.$refs.treeControls.$refs.regionTree.setChecked(e.id,!0)}))},findOrCreateRegion:function(n,e,t){if(this.module&&this.module.scene&&(this.treeData[0].id=this.module.scene.getRootRegion().uuid,this.treeData[0].isRegion=!0),e.length>0){const i=[...e];let r=n.children.find(l=>l.label==i[0]);const s=t+"/"+e[0],o=this.module.scene.getRootRegion().findChildFromPath(s);return r||(r={label:i[0],id:o.uuid,children:[],regionPath:s,isRegion:!0},this.addTreeItem(n.children,r,o)),i.shift(),this.findOrCreateRegion(r,i,s)}else return n},zincObjectAdded:function(n){const e=n.region;if(e){const t=e.getFullSeparatedPath(),i=this.findOrCreateRegion(this.treeData[0],t,"");if(n.groupName&&i){i.children||(i.children=[]);const r={label:n.groupName,id:e.uuid+"/"+n.uuid,isPrimitives:!0,regionPath:n.region.getFullPath(),isTextureSlides:!!n.isTextureSlides};this.addTreeItem(i.children,r,n)}}},zincObjectRemoved:function(n){const e=n.groupName;if(n.region.findObjectsWithGroupName(e,!1).length===0){const i=n.region.getFullSeparatedPath(),r=this.findOrCreateRegion(this.treeData[0],i,"");if(r.children){for(let s=0;s<r.children.length;s++)if(r.children[s].label===e){r.children.splice(s,1),this.nodeNumbers--;return}}}},checkChanged:function(n,e){const t=n.isRegion,i=n.isPrimitives,r=e.checkedKeys.includes(n.id),s=this.module.scene.getRootRegion().findChildFromPath(n.regionPath);t&&(r?s.showAllPrimitives():s.hideAllPrimitives()),i&&s.findObjectsWithGroupName(n.label).forEach(l=>{l.setVisibility(r)})},updateActiveUI:function(n){this.active.length=0,Tx(n,this.active)},changeActiveByPrimitives:function(n,e){n&&n.length>0?(this.updateActiveUI(n),this.$emit("object-selected",n,e)):this.removeActive(e),this.removeHover(e)},updateHoverUI:function(n){this.hover.length=0,Tx(n,this.hover)},changeHoverByPrimitives:function(n,e){n&&n.length>0?(this.updateHoverUI(n),this.$emit("object-hovered",n,e)):this.removeHover(e)},changeActiveByNames:function(n,e,t){const i=this.module.scene.getRootRegion(),r=Lo(i,n,e,!0);this.changeActiveByPrimitives(r,t)},changeHoverByNames:function(n,e,t){const i=this.module.scene.getRootRegion(),r=Lo(i,n,e,!0);this.changeHoverByPrimitives(r,t)},changeActiveByNode:function(n,e){if(n.isPrimitives||n.isRegion){const t=!!n.isRegion,i=this.getZincObjectsFromNode(n,t);this.changeActiveByPrimitives(i,e)}},changeHoverByNode:function(n,e){if(n.isPrimitives){const t=this.getZincObjectsFromNode(n,!1);this.changeHoverByPrimitives(t,e)}},removeActive:function(n){this.active=[],this.$emit("object-selected",[],n)},removeHover:function(n){this.hover=[],this.$emit("object-hovered",[],n)},clear:function(){this.active.length=0,this.hover.length=0,this.nodeNumbers=0,this.$refs.treeControls.$refs.regionTree.updateKeyChildren(this.treeData[0].id,[]),this.treeData[0].children.length=0,this.treeData[0].id=void 0,this.$emit("object-selected",[])},getColour:function(n){if(n){let t=this.getZincObjectsFromNode(n,!1)[0];if(t){let i=t.getColourHex();if(i)return"#"+i}}return"#FFFFFF"},getZincObjectsFromNode:function(n,e){const t=this.module.scene.getRootRegion();if(n.isPrimitives)return Lo(t,n.label,n.regionPath,e);if(n.isRegion&&n.regionPath){let i=t.findChildFromPath(n.regionPath);if(i)return i.getAllObjects(e)}return[]},setModule:function(n){this.module=a.markRaw(n),this.nodeNumbers=0,this.module.scene.getRootRegion().getAllObjects(!0).forEach(t=>{this.zincObjectAdded(t)}),this.module.addOrganPartAddedCallback(this.zincObjectAdded),this.module.addOrganPartRemovedCallback(this.zincObjectRemoved)},setColourField:function(n,e=void 0){n.filter(t=>e&&!t.children?t.id===e.id:!0).map(t=>{if(t.children)this.setColourField(t.children,e);else{const i=this.getColour(t);t.defaultColour||(t.defaultColour=i),t.activeColour=i}})},setColour:function(n,e){n&&n.isPrimitives&&this.getZincObjectsFromNode(n,!1).forEach(i=>{let s=(e||n.defaultColour).replace("#","0x");i.setColourHex(s),this.setColourField(this.treeData[0].children,n)})},visibilityToggle:function(n,e){this.module.changeOrganPartsVisibility(n,e),e==!1&&(this.activeRegion===n&&this.removeActive(!0),this.hoverRegion===n&&this.removeHover(!0))},toggleDrawer:function(){this.drawerOpen=!this.drawerOpen,this.$emit("drawer-toggled",this.drawerOpen)},setTreeVisibilityWithFullPaths:function(n,e,t,i){let r=!1,s="";n.isRegion&&(s=`__r${n.regionPath}`),n.isPrimitives&&(s=`${n.regionPath}/${n.label}`);const o=e.indexOf(s);o>-1&&(r=!0,e.splice(o,1),t.push(n.id));const l=this.module.scene.getRootRegion().findChildFromPath(n.regionPath);s&&s!=="__r"&&n.isPrimitives&&l.findObjectsWithGroupName(n.label).forEach(c=>c.setVisibility(r)),n.children&&n.children.forEach(u=>{this.setTreeVisibilityWithFullPaths(u,e,t,!0)})},checkAllKeys:function(){const n=[],e=[];Ex(this.treeData[0],n),this.setTreeVisibilityWithFullPaths(this.treeData[0],n,e,!0),this.$refs.treeControls.$refs.regionTree.setCheckedKeys(e)},getState:function(){let n=this.$refs.treeControls.$refs.regionTree.getCheckedKeys();return n.length===this.nodeNumbers?{checkAll:!0,version:"2.0"}:{checkedItems:lF(this.module.scene.getRootRegion(),n),version:"2.0"}},setState:function(n){if(n){if(n.checkAll)this.checkAllKeys();else if(n.checkedItems){let e=[];n.version!=="2.0"?(e=n.checkedItems.map(i=>"/"+i),e.shift("__r/")):e.push(...n.checkedItems);const t=[];this.setTreeVisibilityWithFullPaths(this.treeData[0],e,t,!0),this.$refs.treeControls.$refs.regionTree.setCheckedKeys(t)}}}}},AF={class:"traditional-container"};function LF(n,e,t,i,r,s){const o=a.resolveComponent("TreeControls"),l=Wi,u=yt;return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["tree-controls",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createElementVNode("div",AF,[a.createVNode(o,{mapType:"scaffold",title:"Regions",isReady:t.isReady,treeData:s.treeDataEntry,active:n.active,hover:n.hover,showColourPicker:t.showColourPicker,onSetColour:s.setColour,onCheckChanged:s.checkChanged,onChangeActive:s.changeActiveByNode,onChangeHover:s.changeHoverByNode,ref:"treeControls"},null,8,["isReady","treeData","active","hover","showColourPicker","onSetColour","onCheckChanged","onChangeActive","onChangeHover"])]),a.createElementVNode("div",{class:a.normalizeClass(["drawer-button",{open:n.drawerOpen,close:!n.drawerOpen}]),onClick:e[0]||(e[0]=(...c)=>s.toggleDrawer&&s.toggleDrawer(...c))},[a.createVNode(u,null,{default:a.withCtx(()=>[a.createVNode(l)]),_:1})],2)],2)}const Bx=ki(CF,[["render",LF],["__scopeId","data-v-a4a52916"]]);var RF=!1;function eu(n,e,t){return Array.isArray(n)?(n.length=Math.max(n.length,e),n.splice(e,1,t),t):(n[e]=t,t)}function Nf(n,e){if(Array.isArray(n)){n.splice(e,1);return}delete n[e]}/*!
3450
+ }`};class f extends c.ShaderMaterial{constructor(m){super({type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(p){this.uniforms.diffuse.value=p}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(p){this.uniforms.linewidth.value=p}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(y){!!y!="USE_DASH"in this.defines&&(this.needsUpdate=!0),y===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(p){this.uniforms.dashScale.value=p}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(p){this.uniforms.dashSize.value=p}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(p){this.uniforms.dashOffset.value=p}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(p){this.uniforms.gapSize.value=p}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(p){this.uniforms.opacity.value=p}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(p){this.uniforms.resolution.value.copy(p)}},alphaToCoverage:{enumerable:!0,get:function(){return"ALPHA_TO_COVERAGE"in this.defines},set:function(p){!!p!="ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),p===!0?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(m)}}f.prototype.isLineMaterial=!0},(o,l,u)=>{var c=u(4);l.Minimap=function(f){var h=f;this.camera=new c.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;var m=new c.BufferGeometry,y=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]),p=new c.BufferAttribute(y,3);m.setAttribute("position",p);var d=new c.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new c.Mesh(m,d);var b=new c.Box3,v=new c.Vector3;this.getDiffFromNormalised=(M,_)=>{b.setFromBufferAttribute(p).getCenter(v);var E=v.clone().project(this.camera),S=new c.Vector3(M,_,E.z).unproject(this.camera);return S.sub(v)};var g=(M,_)=>{h.camera.near&&(this.camera.near=h.camera.near),_.farPlane&&(this.camera.far=_.farPlane),_.eyePosition&&this.camera.position.set(_.eyePosition[0],_.eyePosition[1],_.eyePosition[2]),_.upVector&&this.camera.up.set(_.upVector[0],_.upVector[1],_.upVector[2]),_.targetPosition&&this.camera.lookAt(new c.Vector3(_.targetPosition[0],_.targetPosition[1],_.targetPosition[2])),this.camera.zoom=1/M,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{var M=new c.Vector3().copy(h.camera.target).project(h.camera),_=new c.Vector3(-1,-1,M.z).unproject(h.camera),E=new c.Vector3(1,-1,M.z).unproject(h.camera),S=new c.Vector3(1,1,M.z).unproject(h.camera),w=new c.Vector3(-1,1,M.z).unproject(h.camera);p.copyVector3sArray([_,E,S,S,w,_]),p.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();var M=h.getZincCameraControls(),_=h.getBoundingBox();if(_){var E=_.min.distanceTo(_.max),S=E/2,w=(_.min.x+_.max.x)/2,T=(_.min.y+_.max.y)/2,C=(_.min.z+_.max.z)/2,R=M.getViewportFromCentreAndRadius(w,T,C,S,40,S*4);g(E,R)}}}},(o,l,u)=>{var c=u(4),f=u(51)(c),h=u(3).Geometry,m=u(52),y=u(53).default,p=c.BufferGeometryLoader,d=function(b){var v;b&&b.isGeometry&&(v=b);var g=void 0,M=void 0,_=!1,E=void 0,S=P=>{var L=v.getMorph().material.clone();L.morphTargets=!1;var A=new h,I=new p,O=I.parse(P),x=new c.Mesh(O.geometry,L);return A.geometry=x.geometry,x.userData=A,A.setMorph(x),A},w=P=>{switch(P.data.action){case"message":console.log(P.data.message);break;case"result":var L=new d(S(P.data.object));E&&E(L),E=void 0,_=!1;break;default:throw"Cannot handle specified action."}},T=P=>{if(m!==void 0&&(M=m(54)),!M)g=new(u(55)).GeometryCSGInternal(P);else if(P&&P.isGeometry){var L=P.getMorph(),A=L.geometry.clone().applyMatrix(L.matrix).toJSON();M.addEventListener("message",function(I){w(I)}),M.postMessage({action:"initialise",object:A})}};this.getHostGeometry=()=>{var P=new f(v.getMorph());return new C(P)},this.getGeometry=()=>v;var C=P=>{var L=v.getMorph().material.clone();L.morphTargets=!1;var A=P.toMesh(L),I=new h;return I.geometry=A.geometry,A.userData=I,I.setMorph(A),I};this.setCSG=P=>{g.setCSG(P)};var R=(P,L,A,I)=>{if(_)I("On progress");else{var O=P.getMorph(),x=O.geometry.clone().applyMatrix(O.matrix).toJSON();E=A,_=!0,M.postMessage({action:L,object:x})}};this.intersect=P=>new y((L,A)=>{if(M)R(P,"intersect",L,A);else{var I=g.intersect(P),O=new d(C(I));O.setCSG(I),L(O)}}),this.subtract=P=>new y((L,A)=>{if(M)R(P,"intersect",L,A);else{var I=g.subtract(P),O=new d(C(I));O.setCSG(I),L(O)}}),this.union=P=>new y((L,A)=>{if(M)R(P,"intersect",L,A);else{var I=g.union(P),O=new d(C(I));O.setCSG(I),L(O)}}),this.terminateWorker=()=>{M&&M.terminate()},T(b)};l.GeometryCSG=d},o=>{var l=1e-5,u=0,c=1,f=2,h=3;o.exports=function(m){var y=function(p){var d,b,v,g,M,_,E,S=[];if(p.isBufferGeometry&&(p=new m.Geometry().fromBufferGeometry(p)),p instanceof m.Geometry)this.matrix=new m.Matrix4;else if(p.isMesh)p.updateMatrix(),this.matrix=p.matrix.clone(),p=p.geometry,p.isBufferGeometry&&(p=new m.Geometry().fromBufferGeometry(p)),p.mergeVertices(),p.computeVertexNormals(!1);else{if(p instanceof y.Node)return this.tree=p,this.matrix=new m.Matrix4,this;throw"ThreeBSP: Given geometry is unsupported"}for(d=0,b=p.faces.length;d<b;d++)v=p.faces[d],M=p.faceVertexUvs[0][d],E=new y.Polygon,v instanceof m.Face3?(g=p.vertices[v.a],_=M?new m.Vector2(M[0].x,M[0].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[0],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.b],_=M?new m.Vector2(M[1].x,M[1].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[2],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.c],_=M?new m.Vector2(M[2].x,M[2].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[2],_),g.applyMatrix4(this.matrix),E.vertices.push(g)):(m.Face4,g=p.vertices[v.a],_=M?new m.Vector2(M[0].x,M[0].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[0],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.b],_=M?new m.Vector2(M[1].x,M[1].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[1],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.c],_=M?new m.Vector2(M[2].x,M[2].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[2],_),g.applyMatrix4(this.matrix),E.vertices.push(g),g=p.vertices[v.d],_=M?new m.Vector2(M[3].x,M[3].y):null,g=new y.Vertex(g.x,g.y,g.z,v.vertexNormals[3],_),g.applyMatrix4(this.matrix),E.vertices.push(g)),E.calculateProperties(),S.push(E);this.tree=new y.Node(S)};return y.prototype.subtract=function(p){var d=this.tree.clone(),b=p.tree.clone();return d.invert(),d.clipTo(b),b.clipTo(d),b.invert(),b.clipTo(d),b.invert(),d.build(b.allPolygons()),d.invert(),d=new y(d),d.matrix=this.matrix,d},y.prototype.union=function(p){var d=this.tree.clone(),b=p.tree.clone();return d.clipTo(b),b.clipTo(d),b.invert(),b.clipTo(d),b.invert(),d.build(b.allPolygons()),d=new y(d),d.matrix=this.matrix,d},y.prototype.intersect=function(p){var d=this.tree.clone(),b=p.tree.clone();return d.invert(),b.clipTo(d),b.invert(),d.clipTo(b),b.clipTo(d),d.build(b.allPolygons()),d.invert(),d=new y(d),d.matrix=this.matrix,d},y.prototype.toGeometry=function(){var p,d,b,v,g,M,_,E,S,w,T=new m.Matrix4().getInverse(this.matrix),C=new m.Geometry,R=this.tree.allPolygons(),P=R.length,L={};for(p=0;p<P;p++)for(b=R[p],v=b.vertices.length,d=2;d<v;d++)w=[],E=b.vertices[0],w.push(new m.Vector2(E.uv.x,E.uv.y)),E=new m.Vector3(E.x,E.y,E.z),E.applyMatrix4(T),typeof L[E.x+","+E.y+","+E.z]>"u"?(C.vertices.push(E),g=L[E.x+","+E.y+","+E.z]=C.vertices.length-1):g=L[E.x+","+E.y+","+E.z],E=b.vertices[d-1],w.push(new m.Vector2(E.uv.x,E.uv.y)),E=new m.Vector3(E.x,E.y,E.z),E.applyMatrix4(T),typeof L[E.x+","+E.y+","+E.z]>"u"?(C.vertices.push(E),M=L[E.x+","+E.y+","+E.z]=C.vertices.length-1):M=L[E.x+","+E.y+","+E.z],E=b.vertices[d],w.push(new m.Vector2(E.uv.x,E.uv.y)),E=new m.Vector3(E.x,E.y,E.z),E.applyMatrix4(T),typeof L[E.x+","+E.y+","+E.z]>"u"?(C.vertices.push(E),_=L[E.x+","+E.y+","+E.z]=C.vertices.length-1):_=L[E.x+","+E.y+","+E.z],S=new m.Face3(g,M,_,new m.Vector3(b.normal.x,b.normal.y,b.normal.z)),C.faces.push(S),C.faceVertexUvs[0].push(w);return C},y.prototype.toBufferGeometry=function(){var p=this.toGeometry(),d=new m.BufferGeometry().fromGeometry(p);return d},y.prototype.toMesh=function(p){var d=this.toBufferGeometry(),b=new m.Mesh(d,p);return b.position.setFromMatrixPosition(this.matrix),b.rotation.setFromRotationMatrix(this.matrix),b},y.Polygon=function(p){p instanceof Array||(p=[]),this.vertices=p,0<p.length?this.calculateProperties():this.normal=this.w=void 0},y.Polygon.prototype.calculateProperties=function(){var p=this.vertices[0],d=this.vertices[1],b=this.vertices[2];return this.normal=d.clone().subtract(p).cross(b.clone().subtract(p)).normalize(),this.w=this.normal.clone().dot(p),this},y.Polygon.prototype.clone=function(){var p,d,b=new y.Polygon;for(p=0,d=this.vertices.length;p<d;p++)b.vertices.push(this.vertices[p].clone());return b.calculateProperties(),b},y.Polygon.prototype.flip=function(){var p,d=[];for(this.normal.multiplyScalar(-1),this.w*=-1,p=this.vertices.length-1;0<=p;p--)d.push(this.vertices[p]);return this.vertices=d,this},y.Polygon.prototype.classifyVertex=function(p){var d=this.normal.dot(p)-this.w;return d<-l?f:d>l?c:u},y.Polygon.prototype.classifySide=function(p){var d,b,v,g=0,M=0,_=p.vertices.length;for(d=0;d<_;d++)b=p.vertices[d],v=this.classifyVertex(b),v===c?g++:v===f&&M++;return 0<g&&M===0?c:g===0&&0<M?f:g===0&&M===0?u:h},y.Polygon.prototype.splitPolygon=function(p,d,b,v,g){var M=this.classifySide(p);if(M===u)(0<this.normal.dot(p.normal)?d:b).push(p);else if(M===c)v.push(p);else if(M===f)g.push(p);else{var _,E,S,w,T,C,R,P,L,A=[],I=[];for(E=0,_=p.vertices.length;E<_;E++)S=(E+1)%_,C=p.vertices[E],R=p.vertices[S],w=this.classifyVertex(C),T=this.classifyVertex(R),w!=f&&A.push(C),w!=c&&I.push(C),(w|T)==h&&(P=(this.w-this.normal.dot(C))/this.normal.dot(R.clone().subtract(C)),L=C.interpolate(R,P),A.push(L),I.push(L));3<=A.length&&v.push(new y.Polygon(A).calculateProperties()),3<=I.length&&g.push(new y.Polygon(I).calculateProperties())}},y.Vertex=function(p,d,b,v,g){this.x=p,this.y=d,this.z=b,this.normal=v||new m.Vector3,this.uv=g||new m.Vector2},y.Vertex.prototype.clone=function(){return new y.Vertex(this.x,this.y,this.z,this.normal.clone(),this.uv.clone())},y.Vertex.prototype.add=function(p){return this.x+=p.x,this.y+=p.y,this.z+=p.z,this},y.Vertex.prototype.subtract=function(p){return this.x-=p.x,this.y-=p.y,this.z-=p.z,this},y.Vertex.prototype.multiplyScalar=function(p){return this.x*=p,this.y*=p,this.z*=p,this},y.Vertex.prototype.cross=function(p){var d=this.x,b=this.y,v=this.z;return this.x=b*p.z-v*p.y,this.y=v*p.x-d*p.z,this.z=d*p.y-b*p.x,this},y.Vertex.prototype.normalize=function(){var p=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return this.x/=p,this.y/=p,this.z/=p,this},y.Vertex.prototype.dot=function(p){return this.x*p.x+this.y*p.y+this.z*p.z},y.Vertex.prototype.lerp=function(p,d){return this.add(p.clone().subtract(this).multiplyScalar(d)),this.normal.add(p.normal.clone().sub(this.normal).multiplyScalar(d)),this.uv.add(p.uv.clone().sub(this.uv).multiplyScalar(d)),this},y.Vertex.prototype.interpolate=function(p,d){return this.clone().lerp(p,d)},y.Vertex.prototype.applyMatrix4=function(p){var d=this.x,b=this.y,v=this.z,g=p.elements;return this.x=g[0]*d+g[4]*b+g[8]*v+g[12],this.y=g[1]*d+g[5]*b+g[9]*v+g[13],this.z=g[2]*d+g[6]*b+g[10]*v+g[14],this},y.Node=function(p){var d,b,v=[],g=[];if(this.polygons=[],this.front=this.back=void 0,p instanceof Array&&p.length!==0){for(this.divider=p[0].clone(),d=0,b=p.length;d<b;d++)this.divider.splitPolygon(p[d],this.polygons,this.polygons,v,g);0<v.length&&(this.front=new y.Node(v)),0<g.length&&(this.back=new y.Node(g))}},y.Node.isConvex=function(p){var d,b;for(d=0;d<p.length;d++)for(b=0;b<p.length;b++)if(d!==b&&p[d].classifySide(p[b])!==f)return!1;return!0},y.Node.prototype.build=function(p){var d,b,v=[],g=[];for(this.divider||(this.divider=p[0].clone()),d=0,b=p.length;d<b;d++)this.divider.splitPolygon(p[d],this.polygons,this.polygons,v,g);0<v.length&&(!this.front&&(this.front=new y.Node),this.front.build(v)),0<g.length&&(!this.back&&(this.back=new y.Node),this.back.build(g))},y.Node.prototype.allPolygons=function(){var p=this.polygons.slice();return this.front&&(p=p.concat(this.front.allPolygons())),this.back&&(p=p.concat(this.back.allPolygons())),p},y.Node.prototype.clone=function(){var p=new y.Node;return p.divider=this.divider.clone(),p.polygons=this.polygons.map(function(d){return d.clone()}),p.front=this.front&&this.front.clone(),p.back=this.back&&this.back.clone(),p},y.Node.prototype.invert=function(){var p,d,b;for(p=0,d=this.polygons.length;p<d;p++)this.polygons[p].flip();return this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),b=this.front,this.front=this.back,this.back=b,this},y.Node.prototype.clipPolygons=function(p){var d,b,v,g;if(!this.divider)return p.slice();for(v=[],g=[],d=0,b=p.length;d<b;d++)this.divider.splitPolygon(p[d],v,g,v,g);return this.front&&(v=this.front.clipPolygons(v)),g=this.back?this.back.clipPolygons(g):[],v.concat(g)},y.Node.prototype.clipTo=function(p){this.polygons=p.clipPolygons(this.polygons),this.front&&this.front.clipTo(p),this.back&&this.back.clipTo(p)},y}},o=>{o.exports=YB()},o=>{o.exports=iF},(o,l,u)=>{var c=u(3).Geometry,f=u(4),h=f.BufferGeometryLoader;o.exports=function(m){var y=void 0,p=function(_){var E=new h,S=E.parse(_),w=new f.MeshPhongMaterial,T=new f.Mesh(S.geometry,w),C=new c;return C.setMorph(T),C},d=function(_){var E=p(_);y=new(u(55)).GeometryCSGInternal(E),m.postMessage({action:"message",message:"Initialised"})},b=function(_){if(y){var E=p(_),S=y.intersect(E),w=S.toBufferGeometry().toJSON();m.postMessage({action:"result",object:w})}},v=function(_){if(y){var E=p(_),S=y.subtract(E),w=S.toBufferGeometry().toJSON();m.postMessage({action:"result",object:w})}},g=function(_){if(y){var E=p(_),S=y.union(E),w=S.toBufferGeometry().toJSON();m.postMessage({action:"result",object:w})}};m.addEventListener("message",function(M){switch(M.data.action){case"initialise":d(M.data.object);break;case"intersect":b(M.data.object);break;case"subtract":v(M.data.object);break;case"union":g(M.data.object);break;default:throw"Cannot handle specified action."}})}},(o,l,u)=>{var c=u(4),f=u(51)(c);u(3).Geometry,u(50).GeometryCSG;var h=function(m){var y;m&&m.isGeometry&&(y=m);var p;this.setGeometry=b=>{b&&b.isGeometry&&(y=b),p=void 0},this.setCSG=b=>{p=b};var d=b=>{if(y&&y.morph&&b&&b.morph){p===void 0&&(p=new f(y.morph));var v=new f(b.morph);return v}};this.intersect=b=>{var v=d(b);return p&&v?p.intersect(v):void 0},this.subtract=b=>{var v=d(b);return p&&v?p.subtract(v):void 0},this.union=b=>{var v=d(b);return p&&v?p.union(v):void 0}};l.GeometryCSGInternal=h},(o,l,u)=>{var c=u(4),f=u(51)(c);u(18).Glyphset;var h=function(m){var y;m&&m.isGlyphset&&(y=m);var p=[];this.setGlyphset=v=>{v&&v.isGlyphset&&(y=v),hostCSG=void 0},this.getGlyphset=()=>y;var d=()=>v=>{var g=v.getMesh(),M=v.getLabel();if(g){var _=new f(g.geometry.clone().applyMatrix(g.matrix)),E=[];E.csg=_,E.label=M,g.material&&(E.material=g.material.clone()),p.push(E)}},b=v=>{if(y&&v&&v.getMorph()){p.length==0&&y.forEachGlyph(d());var g=new f(v.getMorph());return g}};this.intersect=v=>{var g=b(v);if(0<p.length&&g){for(var M=new(u(18)).Glyphset,_=0;_<p.length;_++){var E=p[_],S=E.csg.intersect(g),w=S.toMesh();if(w&&w.geometry&&0<w.geometry.vertices.length){E.material&&(w.material=E.material,w.material.side=c.DoubleSide,w.material.clippingPlanes=null);var T=M.addMeshAsGlyph(w,_+1);T.setLabel(E.label)}}var C=new h(M);return C}}};l.GlyphsetCSG=h}],i={};function r(o){var l=i[o];if(l!==void 0)return l.exports;var u=i[o]={exports:{}};return t[o].call(u.exports,u,u.exports,r),u.exports}r.n=o=>{var l=o&&o.__esModule?()=>o.default:()=>o;return r.d(l,{a:l}),l},r.d=(o,l)=>{for(var u in l)r.o(l,u)&&!r.o(o,u)&&Object.defineProperty(o,u,{enumerable:!0,get:l[u]})},r.o=(o,l)=>Object.prototype.hasOwnProperty.call(o,l),r.r=o=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})};var s=r(0);return s})())})(Xg);var Sr=Xg.exports;const Kc=OA(Sr),Tx=(n,e)=>{if(n){let t="";n.forEach(i=>{t=i.uuid,i.region&&(t=i.region.uuid+"/"+t),i&&i.getVisibility()&&e.push(t)})}return e},Rf=(n,e)=>{const t=n[0]-e[0],i=n[1]-e[1],r=n[2]-e[2];return Math.sqrt(t*t+i*i+r*r)},rF=n=>{const e=n.zincObjects;if(e.length>0&&e[0]){const t=e[0];if(t.isEditable&&t.isLines2){const i=n.identifiers[0].extraData.intersected;if(i&&i.faceIndex>-1){const r=t.getVerticesByFaceIndex(i.faceIndex),s=n.identifiers[0].extraData.intersected.pointOnLine;if(r.length>1){const o=Rf(r[0],[s.x,s.y,s.z]),l=Rf(r[1],[s.x,s.y,s.z]);return o>l?{zincObject:t,faceIndex:i.faceIndex,vertexIndex:i.faceIndex*2+1,point:r[0]}:{zincObject:t,faceIndex:i.faceIndex,vertexIndex:i.faceIndex*2,point:r[1]}}}}}},sF=n=>{const e=n.zincObjects;if(e.length>0&&e[0]){const t=e[0];if(t.isEditable)return t}},oF=(n,e,t)=>{if(n!=null&&n.isEditable&&(n!=null&&n.isPointset)){let i=!1;for(let r=0;r<3&&!i;r++)t[r]!==0&&(i=!0);if(i&&e>-1){const r=n.getVerticesByIndex(e);return r&&(r[0]=r[0]+t[0],r[1]=r[1]+t[1],r[2]=r[2]+t[2]),n.editVertices([r],e),n.boundingBoxUpdateRequired=!0,!0}}return!1},Qc=(n,e)=>{if(n!=null&&n.isEditable&&(n!=null&&n.isLines2)&&e>-1){const t=n.getVerticesByFaceIndex(e);if(t&&t.length>1)return Rf(t[1],t[0])}return 0},Pf=(n,e,t,i)=>{if(n&&t!==0&&n.isEditable&&n.isLines2&&e>-1){const r=n.getVerticesByFaceIndex(e);let s=[r[1][0]-r[0][0],r[1][1]-r[0][1],r[1][2]-r[0][2]];const o=Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]);for(let l=0;l<3;l++)s[l]=s[l]/o*t,i?r[1][l]=r[0][l]+s[l]:(r[0][l]=r[0][l]+s[l],r[1][l]=r[1][l]+s[l]);return n.editVertices(r,e*2),n.boundingBoxUpdateRequired=!0,!0}return!1},aF=(n,e)=>{const t=e.getBoundingBox(),i=new Sr.THREE.Vector3().subVectors(t.max,t.min),r=new Sr.THREE.BoxGeometry(i.x,i.y,i.z);i.addVectors(t.min,t.max).multiplyScalar(.5);const s=r.getAttribute("position"),o=s.count,l=[];for(let u=0;u<o;u++)l[u]=[s.array[u*3],s.array[u*3+1],s.array[u*3+2]];n.editVertices(l,0),n.setPosition(i.x,i.y,i.z),r.dispose()},Ex=(n,e)=>{let t="";n.isRegion&&(t=`__r${n.regionPath}`),n.isPrimitives&&(t=`${n.regionPath}/${n.label}`),e.push(t),n.children&&n.children.forEach(i=>Ex(i,e))},Lo=(n,e,t,i)=>{let r=n;const s=[];if(t&&(r=n.findChildFromPath(t)),r){const o=Array.isArray(e);let l=e;o||(l=[l]),l.forEach(u=>{const c=r.findObjectsWithGroupName(u,i);s.push(...c)})}return s},If=(n,e,t)=>{const i=n.findIndex(s=>s.uuid===e);let r;return i>-1&&(r=n[i],t&&n.splice(i,1)),r},lF=(n,e)=>{const t=[];if(n&&e&&e.length>0){const i={},r={},s=[n,...n.getChildRegions(!0)];let o,l,u;e.forEach(c=>{const f=c.split("/");u=f[0],o=If(s,u,!1),o&&(r[u]||(r[u]=o.getFullPath()),f[1]?(i[u]||(i[u]=o.getAllObjects(!1)),l=If(i[u],f[1],!0),l&&t.push(`${r[u]}/${l.groupName}`)):t.push(`__r/${r[u]}`))})}return t},cF=n=>{if(n){const e=[];return n.forEach(i=>{i.isZincObject?e.push(i):i.isRegion&&e.push(...i.getAllObjects(!0))}),Object.values(e.reduce((i,r)=>({...i,[r.uuid]:r}),{}))}return[]},Cx=(n,e)=>{const t={label:"Multiple selections",regionPath:"",objects:[]};if(e&&n){const i={},r=n.getRootRegion();e.length>0&&(t.regionPath=e[0].data.region,t.label=e[0].data.group),e.forEach(s=>{s.data.region.includes(t.regionPath)||(t.regionPath=""),t.label!==s.data.group&&(t.label="Multiple selections");const o=r.findChildFromPath(s.data.region);i[o.uuid]||(i[o.uuid]=o.getAllObjects(!1));const l=If(i[o.uuid],s.data.uuid);l&&t.objects.push(l)})}return t},uF=n=>{const e=n.getMorph();let t="position";n.isLines2&&(t="instanceStart");const i=[];let r=0;const s=e.geometry.getAttribute(t);for(let o=0;o<n.drawRange;o++)i.push([s.array[r++],s.array[r++],s.array[r++]]);return i},dF=(n,e,t,i,r)=>{let s;if(n.isPointset?s="MultiPoint":n.isLines2&&(s="MultiLineString"),s){const o=uF(n);let l=e.slice(-1)==="/"?e:e+"/";l=l+t;const u=l,c={resource:i,item:{id:u},body:{evidence:[],comment:r},feature:{id:u,properties:{drawn:!0,label:"Drawn annotation"},geometry:{coordinates:o,type:s}}};return r==="Deleted"&&(c.feature=void 0),c}},Ax=(n,e,t,i,r,s,o)=>{const l=dF(t,i,r,s,o);if(l)return n&&n.currentUser&&(l.creator={...n.currentUser},l.creator.orcid||(l.creator.orcid="0000-0000-0000-0000"),n.addAnnotation(e,l).then(u=>{u.annotationId||console.log("There is a problem with the submission, please try again later")}).catch(()=>{console.log("There is a problem with the submission, please try again later")})),l},Lx=async(n,e,t)=>{const i=t;return await n.drawnFeatures(e,i)},Of=(n,e)=>{n&&e.forEach(t=>{const i=t.geometry,r=decodeURIComponent(t.id),s=r.lastIndexOf("/"),o=r.substring(0,s),l=r.substring(s+1);let u;i.type==="MultiPoint"?u=n.createPoints(o,l,i.coordinates,l,8942):i.type==="MultiLineString"&&(u=n.createLines(o,l,i.coordinates,60962)),u&&(u.zincObject.isEditable=!0)})},ki=(n,e)=>{const t=n.__vccOpts||n;for(const[i,r]of e)t[i]=r;return t},hF={name:"LinesControls",components:{Button:Cs,Col:Fn,Container:ei,InputNumber:Si,Main:Mi,Slider:Ln,ElIconArrowLeft:Wi,ElIconArrowRight:ji},props:{createData:{type:Object}},data:function(){return{adjust:0,pAdjust:0,lengthScale:0,distance:0,newDistance:0,width:1,currentIndex:0,ElIconArrowLeft:a.shallowRef(Wi),ElIconArrowRight:a.shallowRef(ji),edited:!1,zincObject:void 0}},watch:{"createData.faceIndex":{handler:function(n){var e;(e=this.zincObject)!=null&&e.isLines2&&(this.currentIndex=n,this.distance=Qc(this.zincObject,this.currentIndex))},immediate:!0}},methods:{changeIndex:function(n){n?Qc(this.zincObject,this.currentIndex+1)>0&&(this.currentIndex++,this.reset()):(this.currentIndex--,this.reset())},onLengthInput:function(){this.newDistance!==0?(this.distance=this.newDistance,this.edited=Pf(this.zincObject,this.currentIndex,this.newDistance,!0)||this.edited):this.newDistance=this.distance},onLengthSliding:function(){this.newDistance=Math.pow(10,this.lengthScale)*this.distance,this.edited=Pf(this.zincObject,this.currentIndex,this.newDistance,!0)||this.edited},onMoveSliding:function(){const n=(this.adjust-this.pAdjust)*this.distance;this.edited=Pf(this.zincObject,this.currentIndex,n,!1)||this.edited,this.pAdjust=this.adjust},reset:function(){this.adjust=0,this.pAdjust=0,this.lengthScale=0,this.distance=Qc(this.zincObject,this.currentIndex),this.newDistance=this.distance,this.edited&&(this.$emit("primitivesUpdated",this.zincObject),this.edited=!1)},setObject:function(n){this.currentIndex=-1,this.distance=0,n.isLines2?(this.zincObject=a.markRaw(n),this.width=this.zincObject.getMorph().material.linewidth,n.isEditable&&(this.currentIndex=0,this.distance=Qc(n,this.currentIndex))):(this.zincObject=void 0,this.width=10)},modifyWidth:function(){this.zincObject.setWidth(this.width)}}};function fF(n,e,t,i,r,s){const o=Fn,l=Ln,u=Si,c=Qn,f=Cs,h=Mi,m=ei;return a.openBlock(),a.createBlock(m,{class:"lines-container"},{default:a.withCtx(()=>[a.createVNode(h,{class:"slides-block"},{default:a.withCtx(()=>[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Width: ")]),_:1}),a.createVNode(o,{offset:0,span:12},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.width,"onUpdate:modelValue":e[0]||(e[0]=y=>n.width=y),class:"my-slider",step:1,min:1,max:100,"show-tooltip":!1,onInput:s.modifyWidth},null,8,["modelValue","onInput"])]),_:1}),a.createVNode(o,{offset:0,span:4},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.width,"onUpdate:modelValue":e[1]||(e[1]=y=>n.width=y),step:1,min:1,max:100,controls:!1,class:"input-box number-input"},null,8,["modelValue"])]),_:1})]),_:1}),n.currentIndex>-1&&n.distance>0?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:4},{default:a.withCtx(()=>[a.createVNode(f,{size:"small",disabled:n.currentIndex===0,icon:n.ElIconArrowLeft,onClick:e[2]||(e[2]=y=>s.changeIndex(!1))},null,8,["disabled","icon"])]),_:1}),a.createVNode(o,{offset:4,span:9},{default:a.withCtx(()=>[a.createTextVNode(" Editing Line "+a.toDisplayString(n.currentIndex+1),1)]),_:1}),a.createVNode(o,{offset:2,span:2},{default:a.withCtx(()=>[a.createVNode(f,{size:"small",icon:n.ElIconArrowRight,onClick:e[3]||(e[3]=y=>s.changeIndex(!0))},null,8,["icon"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Move: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.adjust,"onUpdate:modelValue":e[4]||(e[4]=y=>n.adjust=y),step:.01,min:-3,max:3,"show-tooltip":!1,onInput:e[5]||(e[5]=y=>s.onMoveSliding()),onChange:e[6]||(e[6]=y=>s.reset())},null,8,["modelValue"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Length: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.lengthScale,"onUpdate:modelValue":e[7]||(e[7]=y=>n.lengthScale=y),step:.01,min:-1,max:1,"show-tooltip":!1,onInput:e[8]||(e[8]=y=>s.onLengthSliding()),onChange:e[9]||(e[9]=y=>s.reset())},null,8,["modelValue"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.newDistance,"onUpdate:modelValue":e[10]||(e[10]=y=>n.newDistance=y),controls:!1,class:"input-box number-input",onChange:s.onLengthInput},null,8,["modelValue","onChange"])]),_:1})]),_:1})],64)):a.createCommentVNode("",!0)]),_:1})]),_:1})}const Rx=ki(hF,[["render",fF],["__scopeId","data-v-6581aa67"]]),pF={name:"PointsControls",components:{Col:Fn,Container:ei,InputNumber:Si,Main:Mi,Select:As,Slider:Ln,Row:Qn,Option:Ls,ElIconArrowLeft:Wi,ElIconArrowRight:ji},inject:["boundingDims"],data:function(){return{attenuation:!1,size:10,choices:[{value:!0,label:"On"},{value:!1,label:"off"}],min:[0,0,0],max:[1,1,1],translation:[0,0,0],pTranslation:[0,0,0],currentIndex:-1,ElIconArrowLeft:a.shallowRef(Wi),ElIconArrowRight:a.shallowRef(ji),edited:!1,zincObject:void 0}},watch:{boundingDims:{handler:function(n){const e=n.size;this.min=[-e[0]/2,-e[1]/2,-e[2]/2],this.max=[e[0]/2,e[1]/2,e[2]/2]},immediate:!0,deep:!0}},methods:{changeIndex:function(n){n?this.zincObject.drawRange>this.currentIndex+1&&(this.currentIndex++,this.reset()):(this.currentIndex--,this.reset())},onMoveSliding:function(){const n=[this.translation[0]-this.pTranslation[0],this.translation[1]-this.pTranslation[1],this.translation[2]-this.pTranslation[2]];this.edited=oF(this.zincObject,this.currentIndex,n)||this.edited;for(let e=0;e<3;e++)this.pTranslation[e]=this.translation[e]},reset:function(){this.translation=[0,0,0],this.pTranslation=[0,0,0],this.edited&&(this.$emit("primitivesUpdated",this.zincObject),this.edited=!1)},setObject:function(n){this.currentIndex=-1,n.isPointset?(this.zincObject=a.markRaw(n),this.size=this.zincObject.morph.material.size,this.attenuation=this.zincObject.morph.material.sizeAttenuation,n.isEditable&&this.zincObject.drawRange>0&&(this.currentIndex=0)):(this.zincObject=void 0,this.size=10,this.attenuation=!1)},modifyAttenuation:function(n){this.attenuation=n,this.zincObject.setSizeAttenuation(n)},modifySize:function(){this.zincObject.setSize(this.size)}}};function mF(n,e,t,i,r,s){const o=Fn,l=Ln,u=Si,c=Qn,f=Ls,h=As,m=Cs,y=Mi,p=ei;return a.openBlock(),a.createBlock(p,{class:"pointset-container"},{default:a.withCtx(()=>[a.createVNode(y,{class:"slides-block"},{default:a.withCtx(()=>[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Size: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.size,"onUpdate:modelValue":e[0]||(e[0]=d=>n.size=d),class:"my-slider",step:1,min:0,max:100,"show-tooltip":!1,onInput:e[1]||(e[1]=d=>s.modifySize())},null,8,["modelValue"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.size,"onUpdate:modelValue":e[2]||(e[2]=d=>n.size=d),step:1,min:0,max:100,controls:!1,class:"input-box number-input"},null,8,["modelValue"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createTextVNode(" Size attenuation: ")]),_:1}),a.createVNode(o,{offset:0,span:5},{default:a.withCtx(()=>[a.createVNode(h,{teleported:!1,"model-value":n.attenuation,placeholder:"Select",class:"input-box","popper-class":"viewer_dropdown",onChange:e[3]||(e[3]=d=>s.modifyAttenuation(d,n.slide))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.choices,d=>(a.openBlock(),a.createBlock(f,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:1},8,["model-value"])]),_:1})]),_:1}),n.currentIndex>-1?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:4},{default:a.withCtx(()=>[a.createVNode(m,{size:"small",disabled:n.currentIndex===0,icon:n.ElIconArrowLeft,onClick:e[4]||(e[4]=d=>s.changeIndex(!1))},null,8,["disabled","icon"])]),_:1}),a.createVNode(o,{offset:4,span:9},{default:a.withCtx(()=>[a.createTextVNode(" Editing Point "+a.toDisplayString(n.currentIndex+1),1)]),_:1}),a.createVNode(o,{offset:2,span:2},{default:a.withCtx(()=>[a.createVNode(m,{size:"small",icon:n.ElIconArrowRight,onClick:e[5]||(e[5]=d=>s.changeIndex(!0))},null,8,["icon"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" x: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.translation[0],"onUpdate:modelValue":e[6]||(e[6]=d=>n.translation[0]=d),step:.01,min:n.min[0],max:n.max[0],"show-tooltip":!1,onInput:e[7]||(e[7]=d=>s.onMoveSliding()),onChange:e[8]||(e[8]=d=>s.reset())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" y: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.translation[1],"onUpdate:modelValue":e[9]||(e[9]=d=>n.translation[1]=d),step:.01,min:n.min[1],max:n.max[1],"show-tooltip":!1,onInput:e[10]||(e[10]=d=>s.onMoveSliding()),onChange:e[11]||(e[11]=d=>s.reset())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,null,{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" z: ")]),_:1}),a.createVNode(o,{offset:0,span:16},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.translation[2],"onUpdate:modelValue":e[12]||(e[12]=d=>n.translation[2]=d),step:.01,min:n.min[2],max:n.max[2],"show-tooltip":!1,onInput:e[13]||(e[13]=d=>s.onMoveSliding()),onChange:e[14]||(e[14]=d=>s.reset())},null,8,["modelValue","min","max"])]),_:1})]),_:1})],64)):a.createCommentVNode("",!0)]),_:1})]),_:1})}const Px=ki(pF,[["render",mF],["__scopeId","data-v-d1de9c65"]]),gF={name:"TextureSlidesControls",components:{Col:Fn,Container:ei,Footer:Og,Icon:yt,InputNumber:Si,Main:Mi,Row:Qn,Select:As,Slider:Ln,Option:Ls,ElIconDelete:cl,ElIconPlus:ul},data:function(){return{settings:[],directions:[{value:"x",label:"x"},{value:"y",label:"y"},{value:"z",label:"z"}],zincObject:void 0}},methods:{setObject:function(n){n.isTextureSlides?(this.zincObject=a.markRaw(n),this.settings=this.zincObject.getTextureSettings()):(this.zincObject=void 0,this.settings=[])},addNewSlide:function(){const n={direction:"x",value:0},e=this.zincObject.createSlide(n);this.settings.push(e)},modifyDirection:function(n,e){e&&(e.direction=n,this.zincObject.modifySlideSettings(e))},modifySlide:function(n){n&&this.zincObject.modifySlideSettings(n)},removeSlide:function(n,e){this.zincObject.removeSlideWithId(e.id),this.settings.splice(n,1)}}};function yF(n,e,t,i,r,s){const o=Ls,l=As,u=Fn,c=Ln,f=Si,h=cl,m=yt,y=Qn,p=Mi,d=ul,b=Og,v=ei;return a.openBlock(),a.createBlock(v,{class:"t-slides-container"},{default:a.withCtx(()=>[a.createVNode(p,{class:"slides-block"},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.settings,(g,M)=>(a.openBlock(),a.createBlock(y,{key:g.id,class:"slide-row"},{default:a.withCtx(()=>[a.createVNode(u,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(l,{teleported:!1,"model-value":g.direction,placeholder:"Select",class:"input-box","popper-class":"viewer_dropdown",onChange:_=>s.modifyDirection(_,g)},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.directions,_=>(a.openBlock(),a.createBlock(o,{key:_.value,label:_.label,value:_.value},null,8,["label","value"]))),128))]),_:2},1032,["model-value","onChange"])]),_:2},1024),a.createVNode(u,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(c,{modelValue:g.value,"onUpdate:modelValue":_=>g.value=_,class:"my-slider",step:.01,min:0,max:1,"show-tooltip":!1,onInput:_=>s.modifySlide(g)},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024),a.createVNode(u,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(f,{modelValue:g.value,"onUpdate:modelValue":_=>g.value=_,step:.01,min:0,max:1,controls:!1,class:"input-box number-input"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),a.createVNode(u,{offset:0,span:2},{default:a.withCtx(()=>[a.createVNode(m,{class:"delete-icon",onClick:_=>s.removeSlide(M,g)},{default:a.withCtx(()=>[a.createVNode(h)]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1024))),128))]),_:1}),a.createVNode(b,{height:"30px",class:"add-slides-text",onClick:s.addNewSlide},{default:a.withCtx(()=>[a.createVNode(y,null,{default:a.withCtx(()=>[a.createVNode(u,{span:2},{default:a.withCtx(()=>[a.createVNode(m,null,{default:a.withCtx(()=>[a.createVNode(d)]),_:1})]),_:1}),a.createVNode(u,{span:20},{default:a.withCtx(()=>[a.createTextVNode(" Add a new slide ")]),_:1})]),_:1})]),_:1},8,["onClick"])]),_:1})}const Ix=ki(gF,[["render",yF],["__scopeId","data-v-12185b7f"]]),vF={name:"TransformationControls",components:{Col:Fn,Container:ei,InputNumber:Si,Main:Mi,Slider:Ln},inject:["boundingDims"],data:function(){return{x:0,y:0,z:0,scale:1,min:[0,0,0],max:[1,1,1],zincObject:void 0}},watch:{boundingDims:{handler:function(n){const e=n.centre,t=n.size;this.min=[e[0]-t[0],e[1]-t[1],e[2]-t[2]],this.max=[e[0]+t[0],e[1]+t[1],e[2]+t[2]]},immediate:!0,deep:!0}},methods:{setObject:function(n){if(n.isZincObject){this.zincObject=a.markRaw(n);const e=this.zincObject.getGroup();e&&e.position&&(this.x=e.position.x,this.y=e.position.y,this.z=e.position.z,this.scale=e.scale.x)}else this.zincObject=void 0,this.x=0,this.y=0,this.z=0,this.scale=1},modifyPosition:function(){this.zincObject.setPosition(this.x,this.y,this.z)},modifyScale:function(){this.zincObject.setScaleAll(this.scale)}}};function bF(n,e,t,i,r,s){const o=Fn,l=Ln,u=Si,c=Qn,f=Mi,h=ei;return a.openBlock(),a.createBlock(h,{class:"transformation-container"},{default:a.withCtx(()=>[a.createVNode(f,{class:"slides-block"},{default:a.withCtx(()=>[a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" x: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.x,"onUpdate:modelValue":e[0]||(e[0]=m=>n.x=m),step:.01,min:n.min[0],max:n.max[0],"show-tooltip":!1,onInput:e[1]||(e[1]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.x,"onUpdate:modelValue":e[2]||(e[2]=m=>n.x=m),step:.01,min:n.min[0],max:n.max[0],controls:!1,class:"input-box number-input",onChange:e[3]||(e[3]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" y: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.y,"onUpdate:modelValue":e[4]||(e[4]=m=>n.y=m),step:.01,min:n.min[1],max:n.max[1],"show-tooltip":!1,onInput:e[5]||(e[5]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.y,"onUpdate:modelValue":e[6]||(e[6]=m=>n.y=m),step:.01,min:n.min[1],max:n.max[1],controls:!1,class:"input-box number-input",onChange:e[7]||(e[7]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" z: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.z,"onUpdate:modelValue":e[8]||(e[8]=m=>n.z=m),step:.01,min:n.min[2],max:n.max[2],"show-tooltip":!1,onInput:e[9]||(e[9]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.z,"onUpdate:modelValue":e[10]||(e[10]=m=>n.z=m),step:.01,min:n.min[2],max:n.max[2],controls:!1,class:"input-box number-input",onChange:e[11]||(e[11]=m=>s.modifyPosition())},null,8,["modelValue","min","max"])]),_:1})]),_:1}),a.createVNode(c,{class:"tool-row"},{default:a.withCtx(()=>[a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createTextVNode(" Scale: ")]),_:1}),a.createVNode(o,{offset:0,span:10},{default:a.withCtx(()=>[a.createVNode(l,{modelValue:n.scale,"onUpdate:modelValue":e[12]||(e[12]=m=>n.scale=m),step:.01,min:0,max:5,"show-tooltip":!1,onInput:e[13]||(e[13]=m=>s.modifyScale())},null,8,["modelValue"])]),_:1}),a.createVNode(o,{offset:0,span:6},{default:a.withCtx(()=>[a.createVNode(u,{modelValue:n.scale,"onUpdate:modelValue":e[14]||(e[14]=m=>n.scale=m),step:.01,min:0,max:5,controls:!1,class:"input-box number-input",onChange:e[15]||(e[15]=m=>s.modifyScale())},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1})}const Ox=ki(vF,[["render",bF],["__scopeId","data-v-6b3997b7"]]),xF={name:"OpacityControls",components:{Container:ei,Header:S2,Main:Mi,Slider:Ln},props:{material:void 0,zincObject:void 0},data:function(){return{displayString:"100%"}},watch:{"material.opacity":function(){this.material&&this.zincObject&&this.zincObject.setAlpha(this.material.opacity)}},methods:{formatTooltip(n){return this.displayString=Math.floor(100*n+.5)+"%",this.displayString}}},wF={class:"block"},MF={class:"display"};function SF(n,e,t,i,r,s){const o=Ln,l=ei;return t.material?(a.openBlock(),a.createBlock(l,{key:0,class:"opacity-container"},{default:a.withCtx(()=>[a.createElementVNode("div",wF,[a.createElementVNode("span",MF,a.toDisplayString(n.displayString),1),a.createVNode(o,{modelValue:t.material.opacity,"onUpdate:modelValue":e[0]||(e[0]=u=>t.material.opacity=u),class:"my-slider",step:.01,min:0,max:1,"format-tooltip":s.formatTooltip,"show-tooltip":!1},null,8,["modelValue","format-tooltip"])])]),_:1})):a.createCommentVNode("",!0)}const Nx=ki(xF,[["render",SF],["__scopeId","data-v-cbfc46a5"]]),_F={name:"PrimitiveControls",components:{Collapse:Cg,CollapseItem:Ag,LinesControls:Rx,OpacityControls:Nx,PointsControls:Px,TextureSlidesControls:Ix,TransformationControls:Ox,ElIconArrowRight:ji},props:{createData:{type:Object}},data:function(){return{activeName:"oControls",material:void 0,isTextureSlides:!1,isPointset:!1,isLines:!1,drawerOpen:!0,zincObject:void 0,isEditable:!1,displayString:"100%"}},methods:{formatTooltip:function(n){return this.displayString=Math.floor(100*n+.5)+"%",this.displayString},toggleDrawer:function(){this.drawerOpen=!this.drawerOpen},setObject:function(n){var e;n?this.zincObject=a.markRaw(n):this.zincObject=void 0,this.isEditable=!!((e=this.zincObject)!=null&&e.isEditable),this.isPointset=!1,this.isTextureSlides=!1,this.isLines=!1,this.activeName="trControls",n&&(n.isTextureSlides?(this.isTextureSlides=!0,this.$refs.tSlidesControls.setObject(n),this.activeName="tsControls"):n.isPointset?(this.isPointset=!0,this.$refs.pointsetControls.setObject(n),this.activeName="pControls"):n.isLines2&&(this.isLines=!0,this.$refs.linesControls.setObject(n),this.activeName="lControls"),n.isTextureSlides||this.$refs.transformationControls.setObject(n)),n&&n.getMorph()?this.material=n.getMorph().material:this.material=void 0}}};function TF(n,e,t,i,r,s){const o=Nx,l=Ag,u=Ox,c=Ix,f=Px,h=Rx,m=Cg,y=ji,p=yt;return a.withDirectives((a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["primitive-controls",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createElementVNode("div",{class:a.normalizeClass(["my-drawer",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createVNode(m,{class:"collapse",modelValue:n.activeName,"onUpdate:modelValue":e[2]||(e[2]=d=>n.activeName=d),accordion:""},{default:a.withCtx(()=>[a.withDirectives(a.createVNode(l,{title:"Opacity",name:"oControls"},{default:a.withCtx(()=>[a.createVNode(o,{material:n.material,zincObject:n.zincObject,ref:"opacityControls"},null,8,["material","zincObject"])]),_:1},512),[[a.vShow,!n.isTextureSlides]]),a.withDirectives(a.createVNode(l,{title:"Transformation",name:"trControls"},{default:a.withCtx(()=>[a.createVNode(u,{class:"transformation-controls",ref:"transformationControls"},null,512)]),_:1},512),[[a.vShow,!n.isEditable]]),a.withDirectives(a.createVNode(l,{title:"Texture Slides",name:"tsControls"},{default:a.withCtx(()=>[a.createVNode(c,{class:"texture-controls",ref:"tSlidesControls"},null,512)]),_:1},512),[[a.vShow,n.isTextureSlides]]),a.withDirectives(a.createVNode(l,{title:"Points",name:"pControls"},{default:a.withCtx(()=>[a.createVNode(f,{class:"pointset-controls",ref:"pointsetControls",onPrimitivesUpdated:e[0]||(e[0]=d=>n.$emit("primitivesUpdated",d))},null,512)]),_:1},512),[[a.vShow,n.isPointset]]),a.withDirectives(a.createVNode(l,{title:"Lines",name:"lControls"},{default:a.withCtx(()=>[a.createVNode(h,{class:"lines-controls",ref:"linesControls",createData:t.createData,onPrimitivesUpdated:e[1]||(e[1]=d=>n.$emit("primitivesUpdated",d))},null,8,["createData"])]),_:1},512),[[a.vShow,n.isLines]])]),_:1},8,["modelValue"])],2),a.createElementVNode("div",{class:a.normalizeClass(["drawer-button",{open:n.drawerOpen,close:!n.drawerOpen}]),onClick:e[3]||(e[3]=(...d)=>s.toggleDrawer&&s.toggleDrawer(...d))},[a.createVNode(p,null,{default:a.withCtx(()=>[a.createVNode(y)]),_:1})],2)],2)),[[a.vShow,n.material||n.isTextureSlides]])}const Dx=ki(_F,[["render",TF],["__scopeId","data-v-764a8efa"]]),EF=(n,e)=>{const t=n.label.toUpperCase(),i=e.label.toUpperCase();return t<i?-1:t>i?1:0},CF={name:"ScaffoldTreeControls",components:{ElIconArrowLeft:Wi,TreeControls:Ja.TreeControls},props:{showColourPicker:Boolean,isReady:Boolean},data:function(){return{treeData:[{label:"Root",regionPath:"",id:void 0,children:[]}],active:[],hover:[],drawerOpen:!0,nodeNumbers:0,module:void 0}},computed:{treeDataEntry:function(){return this.treeData[0].children}},watch:{treeDataEntry:{deep:!0,handler:function(n){this.isReady&&this.setColourField(n)}}},methods:{addTreeItem:function(n,e,t){n.some(i=>i.label===e.label)||(Object.assign(e,{activeColour:this.getColour(e)}),n.push(e),n.sort((i,r)=>EF(i,r)),this.nodeNumbers++,this.$nextTick(()=>{!this.$refs.treeControls.$refs.regionTree.getCheckedKeys().includes(e.id)&&t.getVisibility()&&this.$refs.treeControls.$refs.regionTree.setChecked(e.id,!0)}))},findOrCreateRegion:function(n,e,t){if(this.module&&this.module.scene&&(this.treeData[0].id=this.module.scene.getRootRegion().uuid,this.treeData[0].isRegion=!0),e.length>0){const i=[...e];let r=n.children.find(l=>l.label==i[0]);const s=t+"/"+e[0],o=this.module.scene.getRootRegion().findChildFromPath(s);return r||(r={label:i[0],id:o.uuid,children:[],regionPath:s,isRegion:!0},this.addTreeItem(n.children,r,o),s==="/_helper"&&this.$nextTick(()=>{this.$refs.treeControls.$refs.regionTree.setChecked(r.id,!1)})),i.shift(),this.findOrCreateRegion(r,i,s)}else return n},zincObjectAdded:function(n){const e=n.region;if(e){const t=e.getFullSeparatedPath(),i=this.findOrCreateRegion(this.treeData[0],t,"");if(n.groupName&&i){i.children||(i.children=[]);const r={label:n.groupName,id:e.uuid+"/"+n.uuid,isPrimitives:!0,regionPath:n.region.getFullPath(),isTextureSlides:!!n.isTextureSlides};this.addTreeItem(i.children,r,n)}}},zincObjectRemoved:function(n){const e=n.groupName;if(n.region.findObjectsWithGroupName(e,!1).length===0){const i=n.region.getFullSeparatedPath(),r=this.findOrCreateRegion(this.treeData[0],i,"");if(r.children){for(let s=0;s<r.children.length;s++)if(r.children[s].label===e){r.children.splice(s,1),this.nodeNumbers--;return}}}},checkChanged:function(n,e){const t=n.isRegion,i=n.isPrimitives,r=e.checkedKeys.includes(n.id),s=this.module.scene.getRootRegion().findChildFromPath(n.regionPath);t&&(r?s.showAllPrimitives():s.hideAllPrimitives()),i&&s.findObjectsWithGroupName(n.label).forEach(l=>{l.setVisibility(r)})},updateActiveUI:function(n){this.active.length=0,Tx(n,this.active)},changeActiveByPrimitives:function(n,e){n&&n.length>0?(this.updateActiveUI(n),this.$emit("object-selected",n,e)):this.removeActive(e),this.removeHover(e)},updateHoverUI:function(n){this.hover.length=0,Tx(n,this.hover)},changeHoverByPrimitives:function(n,e){n&&n.length>0?(this.updateHoverUI(n),this.$emit("object-hovered",n,e)):this.removeHover(e)},changeActiveByNames:function(n,e,t){const i=this.module.scene.getRootRegion(),r=Lo(i,n,e,!0);this.changeActiveByPrimitives(r,t)},changeHoverByNames:function(n,e,t){const i=this.module.scene.getRootRegion(),r=Lo(i,n,e,!0);this.changeHoverByPrimitives(r,t)},changeActiveByNode:function(n,e){if(n.isPrimitives||n.isRegion){const t=!!n.isRegion,i=this.getZincObjectsFromNode(n,t);this.changeActiveByPrimitives(i,e)}},changeHoverByNode:function(n,e){if(n.isPrimitives){const t=this.getZincObjectsFromNode(n,!1);this.changeHoverByPrimitives(t,e)}},removeActive:function(n){this.active=[],this.$emit("object-selected",[],n)},removeHover:function(n){this.hover=[],this.$emit("object-hovered",[],n)},clear:function(){this.active.length=0,this.hover.length=0,this.nodeNumbers=0,this.$refs.treeControls.$refs.regionTree.updateKeyChildren(this.treeData[0].id,[]),this.treeData[0].children.length=0,this.treeData[0].id=void 0,this.$emit("object-selected",[])},getColour:function(n){if(n){let t=this.getZincObjectsFromNode(n,!1)[0];if(t){let i=t.getColourHex();if(i)return"#"+i}}return"#FFFFFF"},getZincObjectsFromNode:function(n,e){const t=this.module.scene.getRootRegion();if(n.isPrimitives)return Lo(t,n.label,n.regionPath,e);if(n.isRegion&&n.regionPath){let i=t.findChildFromPath(n.regionPath);if(i)return i.getAllObjects(e)}return[]},setModule:function(n){this.module=a.markRaw(n),this.nodeNumbers=0,this.module.scene.getRootRegion().getAllObjects(!0).forEach(t=>{this.zincObjectAdded(t)}),this.module.addOrganPartAddedCallback(this.zincObjectAdded),this.module.addOrganPartRemovedCallback(this.zincObjectRemoved)},setColourField:function(n,e=void 0){n.filter(t=>e&&!t.children?t.id===e.id:!0).map(t=>{if(t.children)this.setColourField(t.children,e);else{const i=this.getColour(t);t.defaultColour||(t.defaultColour=i),t.activeColour=i}})},setColour:function(n,e){n&&n.isPrimitives&&this.getZincObjectsFromNode(n,!1).forEach(i=>{let s=(e||n.defaultColour).replace("#","0x");i.setColourHex(s),this.setColourField(this.treeData[0].children,n)})},visibilityToggle:function(n,e){this.module.changeOrganPartsVisibility(n,e),e==!1&&(this.activeRegion===n&&this.removeActive(!0),this.hoverRegion===n&&this.removeHover(!0))},toggleDrawer:function(){this.drawerOpen=!this.drawerOpen,this.$emit("drawer-toggled",this.drawerOpen)},setTreeVisibilityWithFullPaths:function(n,e,t,i){let r=!1,s="";n.isRegion&&(s=`__r${n.regionPath}`),n.isPrimitives&&(s=`${n.regionPath}/${n.label}`);const o=e.indexOf(s);o>-1&&(r=!0,e.splice(o,1),t.push(n.id));const l=this.module.scene.getRootRegion().findChildFromPath(n.regionPath);s&&s!=="__r"&&n.isPrimitives&&l.findObjectsWithGroupName(n.label).forEach(c=>c.setVisibility(r)),n.children&&n.children.forEach(u=>{this.setTreeVisibilityWithFullPaths(u,e,t,!0)})},checkAllKeys:function(){const n=[],e=[];Ex(this.treeData[0],n),this.setTreeVisibilityWithFullPaths(this.treeData[0],n,e,!0),this.$refs.treeControls.$refs.regionTree.setCheckedKeys(e)},getState:function(){let n=this.$refs.treeControls.$refs.regionTree.getCheckedKeys();return n.length===this.nodeNumbers?{checkAll:!0,version:"2.0"}:{checkedItems:lF(this.module.scene.getRootRegion(),n),version:"2.0"}},setState:function(n){if(n){if(n.checkAll)this.checkAllKeys();else if(n.checkedItems){let e=[];n.version!=="2.0"?(e=n.checkedItems.map(i=>"/"+i),e.shift("__r/")):e.push(...n.checkedItems);const t=[];this.setTreeVisibilityWithFullPaths(this.treeData[0],e,t,!0),this.$refs.treeControls.$refs.regionTree.setCheckedKeys(t)}}}}},AF={class:"traditional-container"};function LF(n,e,t,i,r,s){const o=a.resolveComponent("TreeControls"),l=Wi,u=yt;return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["tree-controls",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createElementVNode("div",AF,[a.createVNode(o,{mapType:"scaffold",title:"Regions",isReady:t.isReady,treeData:s.treeDataEntry,active:n.active,hover:n.hover,showColourPicker:t.showColourPicker,onSetColour:s.setColour,onCheckChanged:s.checkChanged,onChangeActive:s.changeActiveByNode,onChangeHover:s.changeHoverByNode,ref:"treeControls"},null,8,["isReady","treeData","active","hover","showColourPicker","onSetColour","onCheckChanged","onChangeActive","onChangeHover"])]),a.createElementVNode("div",{class:a.normalizeClass(["drawer-button",{open:n.drawerOpen,close:!n.drawerOpen}]),onClick:e[0]||(e[0]=(...c)=>s.toggleDrawer&&s.toggleDrawer(...c))},[a.createVNode(u,null,{default:a.withCtx(()=>[a.createVNode(l)]),_:1})],2)],2)}const Bx=ki(CF,[["render",LF],["__scopeId","data-v-13a8c030"]]);var RF=!1;function eu(n,e,t){return Array.isArray(n)?(n.length=Math.max(n.length,e),n.splice(e,1,t),t):(n[e]=t,t)}function Nf(n,e){if(Array.isArray(n)){n.splice(e,1);return}delete n[e]}/*!
3451
3451
  * pinia v2.2.1
3452
3452
  * (c) 2024 Eduardo San Martin Morote
3453
3453
  * @license MIT
@@ -3455,4 +3455,4 @@ void main() {
3455
3455
  state: () => new MyClass()
3456
3456
  Found in store "${w.$id}".`),p&&s&&t.hydrate&&t.hydrate(w.$state,p),c=!0,f=!0,w}function DF(n,e,t){let i,r;const s=typeof e=="function";i=n,r=s?t:e;function o(l,u){const c=a.hasInjectionContext();if(l=(process.env.NODE_ENV==="test"&&Ha&&Ha._testing?null:l)||(c?a.inject(PF,null):null),l&&tu(l),process.env.NODE_ENV!=="production"&&!Ha)throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
3457
3457
  See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
3458
- This will fail in production.`);l=Ha,l._s.has(i)||(s?Ff(i,e,r,l):Gx(i,r,l),process.env.NODE_ENV!=="production"&&(o._pinia=l));const f=l._s.get(i);if(process.env.NODE_ENV!=="production"&&u){const h="__hot:"+i,m=s?Ff(h,e,r,l,!0):Gx(h,Pn({},r),l,!0);u._hotUpdate(m),delete l.state.value[h],l._s.delete(h)}if(process.env.NODE_ENV!=="production"&&ja){const h=a.getCurrentInstance();if(h&&h.proxy&&!u){const m=h.proxy,y="_pStores"in m?m._pStores:m._pStores={};y[i]=f}}return f}return o.$id=i,o}function Hx(n,e){return Array.isArray(e)?e.reduce((t,i)=>(t[i]=function(){return n(this.$pinia)[i]},t),{}):Object.keys(e).reduce((t,i)=>(t[i]=function(){const r=n(this.$pinia),s=e[i];return typeof s=="function"?s.call(this,r):r[s]},t),{})}const Wx=DF("main",{state:()=>({userProfile:{token:""}}),getters:{userToken(n){return n.userProfile.token}},actions:{setUserToken(n){this.userProfile.token=n}}}),BF={name:"ScaffoldTooltip",components:{Col:Fn,CreateTooltipContent:Ja.CreateTooltipContent,ElIconDelete:cl,Icon:yt,Popover:Pl,Row:Qn,Tooltip:Ja.Tooltip},props:{createData:{type:Object,default:{toBeConfirmed:!1,points:[],shape:"",x:0,y:0}},label:{type:String,default:""},annotationDisplay:{type:Boolean,default:!1},region:{type:String,default:""},visible:{type:Boolean,default:!1},x:{type:Number,default:200},y:{type:Number,default:200}},inject:["scaffoldUrl"],provide(){return{userApiKey:this.userToken}},data:function(){return{display:!1,annotationEntry:{},ElIconDelete:a.shallowRef(cl)}},computed:{...Hx(Wx,["userToken"]),position:function(){let n=40;return this.region&&(n=55),{left:this.x-40+"px",top:this.y-n+"px"}}},methods:{checkForDisplay:function(){if(this.visible&&this.label&&this.label!==""){if(this.display=!0,this.annotationDisplay){const n=this.region?this.region+"/":"";this.annotationEntry={featureId:n+this.label,resourceId:this.scaffoldUrl,resource:this.scaffoldUrl}}}else this.display=!1,this.annotationEntry={}},hideTriggered:function(){this.$emit("tooltip-hide")}},watch:{label:{handler:function(){this.checkForDisplay()},immediate:!0},visible:{handler:function(){this.checkForDisplay()},immediate:!0},annotationDisplay:{handler:function(){this.checkForDisplay()},immediate:!0}}},FF={class:"tooltip-text"},VF={key:0,class:"tooltip-text"},kF={key:1,class:"delete-container"};function zF(n,e,t,i,r,s){const o=a.resolveComponent("CreateTooltipContent"),l=a.resolveComponent("Tooltip"),u=Fn,c=Cs,f=Qn,h=Pl;return a.openBlock(),a.createElementBlock("div",{style:a.normalizeStyle(s.position),class:"region-tooltip"},[a.createVNode(h,{ref:"tooltip",visible:t.visible,placement:"top","show-arrow":!1,teleported:!1,trigger:"manual","popper-class":"tooltip-popper non-selectable","virtual-triggering":"",onHide:s.hideTriggered},{default:a.withCtx(()=>[a.createElementVNode("div",FF,a.toDisplayString(t.label),1),t.region?(a.openBlock(),a.createElementBlock("div",VF,"Region: "+a.toDisplayString(t.region),1)):a.createCommentVNode("",!0),a.withDirectives(a.createVNode(o,{createData:t.createData,onConfirmCreate:e[0]||(e[0]=m=>n.$emit("confirm-create",m)),onCancelCreate:e[1]||(e[1]=m=>n.$emit("cancel-create"))},null,8,["createData"]),[[a.vShow,t.createData.toBeConfirmed]]),a.withDirectives(a.createVNode(l,{class:"p-tooltip",ref:"annotationTooltip",annotationDisplay:!0,annotationEntry:n.annotationEntry},null,8,["annotationEntry"]),[[a.vShow,t.annotationDisplay&&!t.createData.toBeConfirmed]]),t.createData.toBeDeleted?(a.openBlock(),a.createElementBlock("div",kF,[a.createVNode(f,null,{default:a.withCtx(()=>[a.createVNode(u,{span:10},{default:a.withCtx(()=>[a.createTextVNode("Delete this feature?")]),_:1}),a.createVNode(u,{span:7},{default:a.withCtx(()=>[a.createVNode(c,{class:"delete-button",icon:n.ElIconDelete,onClick:e[2]||(e[2]=m=>n.$emit("confirm-delete"))},{default:a.withCtx(()=>[a.createTextVNode(" Delete ")]),_:1},8,["icon"])]),_:1}),a.createVNode(u,{span:6},{default:a.withCtx(()=>[a.createVNode(c,{class:"delete-button",onClick:e[3]||(e[3]=m=>n.$emit("cancel-create"))},{default:a.withCtx(()=>[a.createTextVNode(" Dismiss ")]),_:1})]),_:1})]),_:1})])):a.createCommentVNode("",!0)]),_:1},8,["visible","onHide"])],4)}const jx=ki(BF,[["render",zF],["__scopeId","data-v-e665391a"]]);/*! js-cookie v3.0.5 | MIT */function nu(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)n[i]=t[i]}return n}var UF={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Vf(n,e){function t(r,s,o){if(!(typeof document>"u")){o=nu({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var l="";for(var u in o)o[u]&&(l+="; "+u,o[u]!==!0&&(l+="="+o[u].split(";")[0]));return document.cookie=r+"="+n.write(s,r)+l}}function i(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var s=document.cookie?document.cookie.split("; "):[],o={},l=0;l<s.length;l++){var u=s[l].split("="),c=u.slice(1).join("=");try{var f=decodeURIComponent(u[0]);if(o[f]=n.read(c,f),r===f)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:i,remove:function(r,s){t(r,"",nu({},s,{expires:-1}))},withAttributes:function(r){return Vf(this.converter,nu({},this.attributes,r))},withConverter:function(r){return Vf(nu({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(n)}})}var kf=Vf(UF,{path:"/"}),ci=function(n,e,t,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(n,t):r?r.value=t:e.set(n,t),t},St=function(n,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!i:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(n):i?i.value:e.get(n)},zi,$a,ui,rn,_r;const GF=1e4;class HF{constructor(e){zi.add(this),$a.set(this,void 0),ui.set(this,null),rn.set(this,null),e.slice(-1)==="/"?ci(this,$a,e.slice(0,-1),"f"):ci(this,$a,e,"f")}get currentUser(){return St(this,ui,"f")}get currentError(){return St(this,rn,"f")}async authenticate(e){ci(this,rn,null,"f"),ci(this,ui,null,"f");const t=await St(this,zi,"m",_r).call(this,e,"authenticate");return"error"in t?(kf.remove("annotation-key"),Promise.resolve(St(this,rn,"f"))):(kf.set("annotation-key",t.session,{secure:!0,expires:1}),ci(this,ui,t.data,"f"),Promise.resolve(St(this,ui,"f")))}async unauthenticate(e){ci(this,rn,null,"f"),ci(this,ui,null,"f");const t=await St(this,zi,"m",_r).call(this,e,"unauthenticate");return"success"in t?Promise.resolve(t):Promise.resolve(St(this,rn,"f"))}async annotatedItemIds(e,t,i,r){const s={resource:t};i!==void 0&&(s.user=i),r!==void 0&&(s.participated=r);const o=await St(this,zi,"m",_r).call(this,e,"items/","GET",s);return"error"in o?Promise.resolve(St(this,rn,"f")):Promise.resolve(o)}async drawnFeatures(e,t,i){const r={resource:t};i!==void 0&&(r.items=i);const s=await St(this,zi,"m",_r).call(this,e,"features/","GET",r);return"error"in s?Promise.resolve(St(this,rn,"f")):Promise.resolve(s)}async itemAnnotations(e,t,i){const r=await St(this,zi,"m",_r).call(this,e,"annotations/","GET",{resource:t,item:i});return"error"in r?Promise.resolve(St(this,rn,"f")):Promise.resolve(r)}async annotation(e,t){const i=await St(this,zi,"m",_r).call(this,e,"annotation/","GET",{annotation:t});return"error"in i?Promise.resolve(St(this,rn,"f")):Promise.resolve(i)}async addAnnotation(e,t){if(St(this,ui,"f")&&St(this,ui,"f").canUpdate){const i=Object.assign({creator:St(this,ui,"f"),created:new Date().toISOString()},t),r=await St(this,zi,"m",_r).call(this,e,"annotation/","POST",{data:i});if(!("error"in r))return Promise.resolve(r);ci(this,rn,r,"f")}else ci(this,rn,{error:"user cannot add annotation"},"f");return Promise.resolve(St(this,rn,"f"))}}$a=new WeakMap,ui=new WeakMap,rn=new WeakMap,zi=new WeakSet,_r=async function(e,t,i="GET",r={}){let s=!0;const o=new AbortController;setTimeout(()=>{s&&(console.log("Annotation server timeout..."),o.abort())},GF);const l={method:i,signal:o.signal};let u=`${St(this,$a,"f")}/${t}`;const c=kf.get("annotation-key")||"";if(i==="GET"){const h=[];for(const[m,y]of Object.entries(r))h.push(`${m}=${encodeURIComponent(JSON.stringify(y))}`);h.push(`key=${encodeURIComponent(e)}`),h.push(`session=${encodeURIComponent(c)}`),u+="?"+h.join("&"),l.headers={Accept:"application/json; charset=utf-8","Cache-Control":"no-store"}}else if(i==="POST"){const h=Object.assign({key:e,session:c},r);l.body=JSON.stringify(h),l.headers={Accept:"application/json; charset=utf-8","Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}}const f=await fetch(u,l);return s=!1,f.ok?Promise.resolve(await f.json()):(ci(this,rn,{error:`${f.status} ${f.statusText}`},"f"),Promise.resolve(St(this,rn,"f")))};const Za={ALL:0,SELECTED:1,HIGHLIGHTED:2,MOVE:3},WF=function(n,e,t){this.eventType=n,this.identifiers=e,this.zincObjects=t},jF=function(n,e,t){this.targetedID=[];const i=n,r=e;this.targetEventType=t;const s=this;t===void 0&&(this.targetEventType=Za.ALL),this.getEventType=function(){return t},this.notify=function(o,l,u,c){if(o!==i&&(s.targetEventType===Za.ALL||s.targetEventType===l)){const f=new WF(l,u,c);r(f)}}},$F=function(){const n=[];this.publish=function(e,t,i,r){for(let s=0;s<n.length;s++)n[s].notify(e,t,i,r)},this.subscribe=function(e,t,i){if(typeof t=="function"){const r=new jF(e,t,i);return n.push(r),r}},this.unsubscribe=function(e){for(let t=0;t<n.length;t++)if(e===n[t]){n.splice(t,1);return}}},$x={isWebGLAvailable:function(){try{var n=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(n.getContext("webgl")||n.getContext("experimental-webgl")))}catch{return!1}},isWebGL2Available:function(){try{var n=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&n.getContext("webgl2"))}catch{return!1}},getWebGLErrorMessage:function(){return this.getErrorMessage(1)},getWebGL2ErrorMessage:function(){return this.getErrorMessage(2)},getErrorMessage:function(n){var e={1:"WebGL",2:"WebGL 2"},t={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext},i='This module requires <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#008">$1</a> support but your $0 does not seem to support it.',r=document.createElement("div");return r.id="webglmessage",r.style.fontFamily="monospace",r.style.fontSize="20px",r.style.fontWeight="normal",r.style.textAlign="center",r.style.background="#fff",r.style.color="#000",r.style.padding="1.5em",r.style.width="400px",r.style.margin="5em auto 0",t[n]?i=i.replace("$0","graphics card"):i=i.replace("$0","browser"),i=i.replace("$1",e[n]),r.innerHTML=i,r}},zf={ALL:0,DESTROYED:1,NAME_CHANGED:2,SETTINGS_CHANGED:3},_n=function(){this.typeName="Base Module",this.instanceName="default",this.onChangedCallbacks=[],this.eventNotifiers=[]};_n.prototype.setName=function(n){if(n&&this.instanceName!==n){this.instanceName=n;const e=this.onChangedCallbacks.slice();for(let t=0;t<e.length;t++)e[t](this,zf.NAME_CHANGED)}},_n.prototype.settingsChanged=function(){const n=this.onChangedCallbacks.slice();for(let e=0;e<n.length;e++)n[e](this,zf.SETTINGS_CHANGED)},_n.prototype.exportSettings=function(){const n={};return n.dialog=this.typeName,n.name=this.instanceName,n},_n.prototype.importSettings=function(n){return n.dialog==this.typeName?(this.setName(n.name),!0):!1},_n.prototype.publishChanges=function(n,e,t){for(let i=0;i<this.eventNotifiers.length;i++)this.eventNotifiers[i].publish(this,e,n,t)},_n.prototype.getName=function(){return this.instanceName},_n.prototype.destroy=function(){const n=this.onChangedCallbacks.slice();for(let e=0;e<n.length;e++)n[e](this,zf.DESTROYED);delete this},_n.prototype.addChangedCallback=function(n){this.onChangedCallbacks.includes(n)==!1&&this.onChangedCallbacks.push(n)},_n.prototype.removeChangedCallback=function(n){const e=this.onChangedCallbacks.indexOf(n);e>-1&&this.onChangedCallbacks.splice(e,1)},_n.prototype.addNotifier=function(n){this.eventNotifiers.push(n)};const iu=(n,e,t)=>{for(let i=0;i<n.length;i++)if(n[i]&&n[i].material&&n[i].material.emissive){let r=n[i].userData;r&&r.isZincObject?r.setEmissiveRGB(e):n[i].material&&n[i].material.emissive&&n[i].material.emissive.setRGB(...e),t&&n[i].material.depthFunc&&(n[i].material.depthFunc=Sr.THREE.LessEqualDepth),n[i].children.forEach(s=>{const o=s.userData;o&&o.isZincObject&&s.material&&s.material.emissive&&s.material.emissive.setRGB(...e)})}},ZF=function(){let n=[],e=[];this.highlightColour=[1,0,0],this.selectColour=[0,1,0],this.originalColour=[0,0,0];const t=[],i=[],r=this,s=function(u,c){if(u.length==0&&c.length==0)return!1;for(let f=0;f<u.length;f++){let h=!1;for(let m=0;m<c.length;m++)u[f]===c[m]&&(h=!0);if(!h)return!0}for(let f=0;f<c.length;f++){let h=!1;for(let m=0;m<u.length;m++)c[f]===u[m]&&(h=!0);if(!h)return!0}return!1},o=function(u,c){if(t.length=0,c.length==0)return u;for(let f=0;f<u.length;f++){let h=!1;for(let m=0;m<c.length;m++)u[f]===c[m]&&(h=!0);h||t.push(u[f])}return t};this.setHighlighted=function(u){const c=[...n];r.resetHighlighted();const f=o(u,e),h=l(f);return iu(h,r.highlightColour,!1),n=f,s(n,c)},this.setSelected=function(u){const c=[...e];r.resetHighlighted(),r.resetSelected();const f=l(u);return iu(f,r.selectColour,!1),e=u,s(e,c)};const l=function(u){i.length=0;for(let c=0;c<u.length;c++)u[c].material&&i.push(u[c]);return i};this.resetHighlighted=function(){const u=l(n);iu(u,r.originalColour,!0),n=[]},this.resetSelected=function(){const u=l(e);iu(u,r.originalColour,!0),e=[]},this.getSelected=function(){return e},this.reset=function(){r.resetSelected(),r.resetHighlighted()}},Uf=Kc.THREE,XF=function(){const n=document.createElement("div");let e;if(n.style.height="100%",$x.isWebGLAvailable())e=new Kc.Renderer(n,window),Kc.defaultMaterialColor=16777116,e.initialiseVisualisation(),e.playAnimation=!1;else{const t=$x.getWebGLErrorMessage();n.appendChild(t)}return{Zinc:Kc,renderer:e,container:n}},_t=function(){_n.call(this),this.scene=void 0,this.rendererContainer=void 0,this.displayArea=void 0,this.graphicsHighlight=new ZF,this.selectObjectOnPick=!0,this.zincRenderer=null,this.selectedScreenCoordinates=new Uf.Vector3,this.selectedCenter=void 0,this.liveUpdatesObjects=void 0,this.ignorePreviousSelected=!1};_t.prototype=Object.create(_n.prototype),_t.prototype.getIntersectedObject=function(n){if(n){const e=n.map(i=>{if(i&&i.object&&i.object.userData){if(i.object.userData.isMarker)return 1;if(i.object.name&&i.object.userData.isZincObject)return 2}return 0});let t=e.indexOf(1);return t=t>-1?t:e.indexOf(2),n[t]}},_t.prototype.getAnnotationsFromObjects=function(n){const e=[];for(var t=0;t<n.length;t++){const i=n[t].userData;let r;if(i){if(i.isGlyph||i.isGlyphset){let s=i;i.isGlyph&&(s=i.getGlyphset()),r=s.userData?s.userData.annotation:void 0,r&&r.data&&(n[t].name&&n[t].name!=""?r.data.id=n[t].name:r.data.id=s.groupName)}else r=i.userData?i.userData.annotation:void 0,r&&r.data&&(r.data.id=n[t].name);r&&(r.data.zincObject=i)}r&&e.push(r)}return e},_t.prototype.setHighlightedByObjects=function(n,e,t,i){const r=this.graphicsHighlight.setHighlighted(n),s=this.objectsToZincObjects(n);if(i){let o=Za.MOVE;r&&(o=Za.HIGHLIGHTED);const l=this.getAnnotationsFromObjects(n);l.length>0&&(l[0].coords=e,l[0].extraData=t),this.publishChanges(l,o,s)}return r},_t.prototype.setHighlightedByZincObjects=function(n,e,t,i){let r=[];return n&&n.forEach(s=>{s&&s.getMorph()&&r.push(s.getMorph())}),this.setHighlightedByObjects(r,e,t,i)},_t.prototype.setupLiveCoordinates=function(n){if(this.liveUpdatesObjects=n,n&&n.length>0){const e=this.scene.getBoundingBoxOfZincObjects(n);let t=new Uf.Vector3;e?(e.getCenter(t),this.selectedCenter==null?this.selectedCenter=t:this.selectedCenter.copy(t)):this.selectedCenter=void 0}else this.selectedCenter=void 0},_t.prototype.objectsToZincObjects=function(n){const e=[];for(let t=0;t<n.length;t++){let i=n[t].userData;if(i)if(i.isGlyph||i.isGlyphset){let r=i;i.isGlyph&&(r=i.getGlyphset()),e.push(r)}else e.push(i)}return e},_t.prototype.setSelectedByObjects=function(n,e,t,i){let r=!1;if(this.selectObjectOnPick?r=this.graphicsHighlight.setSelected(n):r=!0,r||this.ignorePreviousSelected){const s=this.objectsToZincObjects(n);if(this.selectObjectOnPick&&this.setupLiveCoordinates(s),i){const o=Za.SELECTED,l=this.getAnnotationsFromObjects(n);l.length>0&&(l[0].coords=e,l[0].extraData=t),this.publishChanges(l,o,s)}}return r},_t.prototype.setSelectedByZincObjects=function(n,e,t,i){let r=[];return n&&n.forEach(s=>{if(s){const o=s.getMorph();o&&r.push(o)}}),this.setSelectedByObjects(r,e,t,i)},_t.prototype.findObjectsByGroupName=function(n){return this.scene.findObjectsWithGroupName(n)},_t.prototype.setHighlightedByGroupName=function(n,e){const t=this.findObjectsByGroupName(n);return this.setHighlightedByObjects(t,void 0,{},e)},_t.prototype.setSelectedByGroupName=function(n,e){const t=this.findObjectsByGroupName(n);return this.setSelectedByObjects(t,void 0,{},e)},_t.prototype.changeBackgroundColour=function(n){const e=new Uf.Color(n);this.zincRenderer&&this.zincRenderer.getThreeJSRenderer().setClearColor(e,1)},_t.prototype.resetView=function(){this.zincRenderer&&this.zincRenderer.resetView()},_t.prototype.viewAll=function(){this.zincRenderer&&this.zincRenderer.viewAll()},_t.prototype.playAnimation=function(n){this.zincRenderer&&(this.zincRenderer.playAnimation=n)},_t.prototype.setPlayRate=function(n){this.zincRenderer&&this.zincRenderer.setPlayRate(n)},_t.prototype.getPlayRate=function(n){return this.zincRenderer?this.zincRenderer.getPlayRate():0},_t.prototype.initialiseRenderer=function(n){if(this.zincRenderer===void 0||this.rendererContainer===void 0){let e=XF();this.Zinc=e.Zinc,this.zincRenderer=e.renderer,this.rendererContainer=e.container}n&&(this.displayArea=n,this.displayArea.appendChild(this.rendererContainer),this.zincRenderer&&this.zincRenderer.animate())},_t.prototype.destroy=function(){this.zincRenderer&&(this.zincRenderer.dispose(),this.zincRenderer.getThreeJSRenderer().dispose(),this.zincRenderer=void 0),_n.prototype.destroy.call(this)};const YF=function(){this.type="anatomical",this.data=void 0,this.isAnnotation=!0},JF=function(){this.currentName="",this.currentSystem="",this.currentPart="",this.currentSpecies="",this.metaURL="",this.viewURL="",this.timeVarying=!1,this.currentTime=0},Zx=function(n){_t.call(this);const e=this;let t;this.sceneData=new JF;const i=new Array,r=new Array,s=new Array,o=new Array;let l;const u=n;this.NDCCameraControl=void 0,e.typeName="Organ Viewer",this.getSceneData=function(){return e.sceneData},this.updateTime=function(T){let C=6e3;e.scene&&(C=e.scene.getDuration());const R=T/100*C;e.sceneData.nerveMapIsActive||e.scene&&e.scene.setMorphsTime(R),e.sceneData.currentTime=T};const c=function(){let T=3e3;e.scene&&(T=e.scene.getDuration());const C=e.zincRenderer.getCurrentTime();for(let R=0;R<i.length;R++)i[R](C);!e.sceneData.nerveMapIsActive&&t&&t.setMorphsTime(C),e.sceneData.nerveMap&&e.sceneData.nerveMap.additionalReader&&e.sceneData.nerveMap.additionalReader.setTime(C/T),e.sceneData.currentTime=C/T*100};this.getCurrentTime=function(){return e.sceneData.currentTime},this.toggleSyncControl=(T,C)=>{let R=this.scene.getZincCameraControls();T?(R.resetView(),this.NDCCameraControl=R.enableSyncControl(),R.setRotationMode(C)):(R.disableSyncControl(),this.NDCCameraControl=void 0,R.setRotationMode("free"))},this.isSyncControl=()=>this.NDCCameraControl!==void 0,this.setSyncControlZoomToBox=T=>{this.NDCCameraControl&&this.NDCCameraControl.zoomToBox(T,2)},this.setSyncControlCallback=T=>{this.NDCCameraControl&&this.NDCCameraControl.setEventCallback(T)},this.setSyncControlCenterZoom=(T,C)=>{this.NDCCameraControl&&this.NDCCameraControl.setCenterZoom(T,C)};const f=function(){if(e.zincRenderer.playAnimation&&e.liveUpdatesObjects&&e.setupLiveCoordinates(e.liveUpdatesObjects),e.selectedCenter){const T=new Sr.THREE.Vector3;T.copy(e.selectedCenter);const C=e.scene.vectorToScreenXY(T);e.selectedScreenCoordinates.x=C.x,e.selectedScreenCoordinates.y=C.y}},h=function(){return function(){c()}},m=function(){return function(){f()}};this.addTimeChangedCallback=function(T){i.push(T)},this.setTexturePos=function(T){e.sceneData.nerveMap&&e.sceneData.nerveMap.additionalReader&&e.sceneData.nerveMap.additionalReader.setSliderPos(T)},this.addSceneChangedCallback=function(T){r.push(T)},this.addOrganPartAddedCallback=function(T){s.push(T)},this.addOrganPartRemovedCallback=function(T){o.push(T)},this.setFinishDownloadCallback=function(T){l=T},this.unsetFinishDownloadCallback=function(){l=void 0},this.getNamedObjectsToScreenCoordinates=function(T,C){const R=new Sr.THREE.Vector3;R.setFromMatrixPosition(obj.matrixWorld);const P=width/2,L=height/2;return R.project(C),R.x=R.x*P+P,R.y=-(R.y*L)+L,R};const y=function(T){let C,R;if(T!==void 0){let P=!1;T.object.userData&&T.object.userData.isMarker?(P=!0,R=T.object.userData.parent.getMorph()):R=T.object;try{R.userData.userData.annotation.data.lastActionOnMarker=P}finally{}if(R)if(R.name)C=R.name;else{const L=e.getAnnotationsFromObjects([R]);L&&L[0]&&(C=L[0].data.group)}}return{id:C,object:R}},p=function(){return function(T,C,R){var O;const P=e.getIntersectedObject(T),L=y(P),A={worldCoords:[P?P.point.x:0,P?P.point.y:0,P?P.point.z:0],intersected:P,intersects:T},I={x:C,y:R};if(L.id){A.threeID=(O=L.object)==null?void 0:O.id,L.object.userData.isGlyph?L.object.name?e.setSelectedByObjects([L.object],I,A,!0):e.setSelectedByZincObjects(L.object.userData.getGlyphset(),I,A,!0):e.setSelectedByObjects([L.object],I,A,!0);return}else e.setSelectedByObjects([],I,A,!0)}},d=function(){return function(T,C,R){var O;const P=e.getIntersectedObject(T),L=y(P),A={worldCoords:[P?P.point.x:0,P?P.point.y:0,P?P.point.z:0]},I={x:C,y:R};if(L.id){A.threeID=(O=L.object)==null?void 0:O.id,e.displayArea.style.cursor="pointer",e.setHighlightedByObjects([L.object],I,A,!0);return}else e.displayArea.style.cursor="auto",e.setHighlightedByObjects([],I,A,!0)}},b=function(T,C,R,P){if(P=="all"||P=="geometries"){const L=T.findGeometriesWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}if(P=="all"||P=="glyphsets"){const L=T.findGlyphsetsWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}if(P=="all"||P=="pointsets"){const L=T.findPointsetsWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}if(P=="all"||P=="lines"){const L=T.findLinesWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}};this.changeGeometriesVisibility=function(T,C){b(e.scene,T,C,"geometries")},this.changeGlyphsetsVisibility=function(T,C){b(e.scene,T,C,"glyphsets")},this.changeLinesVisibility=function(T,C){b(e.scene,T,C,"lines")},this.changePointsetsVisibility=function(T,C){b(e.scene,T,C,"pointsets")},this.changeOrganPartsVisibility=function(T,C,R){let P="all";R!==void 0&&(P=R),b(e.scene,T,C,P)},this.changeOrganPartsVisibilityCallback=function(T){return function(C){e.changeOrganPartsVisibility(T,C)}},this.changeBackgroundColour=function(T){const C=new Sr.THREE.Color(T);e.zincRenderer&&e.zincRenderer.getThreeJSRenderer().setClearColor(C,1)};const v=function(T,C,R,P){for(let I=0;I<s.length;I++)s[I](P,e.scene.isTimeVarying());const L=new YF,A=P.region.getFullPath();L.data={species:e.sceneData.currentSpecies,system:T,part:C,group:P.groupName,region:A,uuid:P.uuid,lastActionOnMarker:!1},P.userData.annotation=L},g=function(T,C,R,P){for(let L=0;L<o.length;L++)o[L](P)},M=function(T,C,R){return function(P){v(T,C,R,P)}},_=function(T,C,R){return function(P){g(T,C,R,P)}},E=function(){return function(){e.settingsChanged(),e.sceneData.timeVarying=e.scene.isTimeVarying(),l&&l()}};this.updateFieldvisibility=function(T,C){for(let R=0;R<T.length;R++)if(C!=R){const P=T[R].PartName;e.changeOrganPartsVisibility(P,!1)}if(C>-1){const R=T[C].PartName;if(e.scene.findGeometriesWithGroupName(R).length>0||e.scene.findGlyphsetsWithGroupName(R).length>0)e.changeOrganPartsVisibility(R,!0);else{const P=getOrganDetails(T[C].SystemName,R);P!=null&&e.scene.loadMetadataURL(u.getOrgansDirectoryPrefix()+"/"+P.meta)}}},this.getAvailableSpecies=function(T,C,R){const P=new Array;P.push("none");const L=Object.keys(organsFileMap);for(index in L){const A=L[index];A!=T&&organsFileMap[A].hasOwnProperty(C)&&organsFileMap[A][C].hasOwnProperty(R)&&P.push(A)}return P},this.getCentreAndSize=function(){const T=new Sr.THREE.Vector3,C=this.scene.getBoundingBox();C.getCenter(T);const R=[T.x,T.y,T.z];C.getSize(T);const P=[T.x,T.y,T.z];return{centre:R,size:P}};const S=function(T,C,R,P){e.sceneData.nerveMapIsActive=!1,e.sceneData.nerveMap=void 0,e.sceneData.metaURL="",e.sceneData.viewURL="",e.sceneData.currentSpecies=T,e.sceneData.currentSystem=C,e.sceneData.currentPart=R,e.sceneData.currentTime=0,e.sceneData.timeVarying=!1;let L="";T&&(L=T+"/"),C&&(L=C+"/"),R&&(L=R),e.sceneData.currentName=L};this.loadOrgansFromURL=function(T,C,R,P,L,A){if(e.zincRenderer&&P&&e.sceneData.metaURL!==T){S(C,R,P);const I=e.sceneData.currentName;let O=e.zincRenderer.getSceneByName(I);O?A&&O.clearAll():O=e.zincRenderer.createScene(I),e.selectObjectOnPick=!0;for(let N=0;N<r.length;N++)r[N](e.sceneData);L&&L!=""?(e.sceneData.viewURL=L,O.loadViewURL(e.sceneData.viewURL)):e.sceneData.viewURL=void 0,e.sceneData.metaURL=T,O.addZincObjectAddedCallbacks(M(R,P,!1)),O.addZincObjectRemovedCallbacks(_(void 0,P,!1)),O.loadMetadataURL(T,void 0,E()),e.scene=O,e.zincRenderer.setCurrentScene(O),e.graphicsHighlight.reset();const x=O.getZincCameraControls();x.enableRaycaster(O,p(),d()),x.setMouseButtonAction("AUXILIARY","ZOOM"),x.setMouseButtonAction("SECONDARY","PAN")}},this.loadGLTFFromURL=function(T,C,R){if(e.zincRenderer&&C&&e.sceneData.metaURL!==T){S(void 0,void 0,C);const P=e.sceneData.currentName;let L=e.zincRenderer.getSceneByName(P);L?R&&L.clearAll():L=e.zincRenderer.createScene(P);for(let I=0;I<r.length;I++)r[I](e.sceneData);e.sceneData.viewURL=void 0,e.sceneData.metaURL=T,L.addZincObjectAddedCallbacks(M(void 0,C,!1)),L.addZincObjectRemovedCallbacks(_(void 0,C,!1)),L.loadGLTF(T,void 0,E()),e.scene=L,e.zincRenderer.setCurrentScene(L),e.graphicsHighlight.reset();const A=L.getZincCameraControls();A.enableRaycaster(L,p(),d()),A.setMouseButtonAction("AUXILIARY","ZOOM"),A.setMouseButtonAction("SECONDARY","PAN")}},this.alignCameraWithSelectedObject=function(T){const C=e.graphicsHighlight.getSelected();C&&C[0]&&C[0].userData&&e.scene.alignObjectToCameraView(C[0].userData,T)},this.exportSettings=function(){const T={};return T.name=e.instanceName,e.sceneData.currentSystem&&(T.system=e.sceneData.currentSystem),e.sceneData.currentSpecies&&(T.species=e.sceneData.currentSpecies),e.sceneData.currentPart&&(T.part=e.sceneData.currentPart),T.metaURL=e.sceneData.metaURL,e.sceneData.viewURL&&(T.viewURL=e.sceneData.viewURL),T.dialog="Organ Viewer",T},this.importSettings=function(T){return T&&T.dialog==this.typeName?(e.setName(T.name),T.metaURL!==void 0&&T.metaURL!=""?e.loadOrgansFromURL(T.metaURL,T.species,T.system,T.part,T.viewURL,!0):e.loadOrgans(T.species,T.system,T.part),!0):!1},function(){e.initialiseRenderer(void 0),e.zincRenderer&&(e.zincRenderer.addPreRenderCallbackFunction(h()),e.zincRenderer.addPostRenderCallbackFunction(m()))}()};Zx.prototype=Object.create(_t.prototype);var dt=function(){return dt=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},dt.apply(this,arguments)};function qF(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function l(f){try{c(i.next(f))}catch(h){o(h)}}function u(f){try{c(i.throw(f))}catch(h){o(h)}}function c(f){f.done?s(f.value):r(f.value).then(l,u)}c((i=i.apply(n,[])).next())})}function KF(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(c){return function(f){return u([c,f])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(t=0)),t;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(f){c=[6,f],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Ze(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Dt(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(l){o={error:l}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}typeof SuppressedError=="function"&&SuppressedError;var QF="ENTRIES",Xx="KEYS",Yx="VALUES",Qt="",Gf=function(){function n(e,t){var i=e._tree,r=Array.from(i.keys());this.set=e,this._type=t,this._path=r.length>0?[{node:i,keys:r}]:[]}return n.prototype.next=function(){var e=this.dive();return this.backtrack(),e},n.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var e=Po(this._path),t=e.node,i=e.keys;if(Po(i)===Qt)return{done:!1,value:this.result()};var r=t.get(Po(i));return this._path.push({node:r,keys:Array.from(r.keys())}),this.dive()},n.prototype.backtrack=function(){if(this._path.length!==0){var e=Po(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}},n.prototype.key=function(){return this.set._prefix+this._path.map(function(e){var t=e.keys;return Po(t)}).filter(function(e){return e!==Qt}).join("")},n.prototype.value=function(){return Po(this._path).node.get(Qt)},n.prototype.result=function(){switch(this._type){case Yx:return this.value();case Xx:return this.key();default:return[this.key(),this.value()]}},n.prototype[Symbol.iterator]=function(){return this},n}(),Po=function(n){return n[n.length-1]},eV=function(n,e,t){var i=new Map;if(e===void 0)return i;for(var r=e.length+1,s=r+t,o=new Uint8Array(s*r).fill(t+1),l=0;l<r;++l)o[l]=l;for(var u=1;u<s;++u)o[u*r]=u;return Jx(n,e,t,i,o,1,r,""),i},Jx=function(n,e,t,i,r,s,o,l){var u,c,f=s*o;try{e:for(var h=Ze(n.keys()),m=h.next();!m.done;m=h.next()){var y=m.value;if(y===Qt){var p=r[f-1];p<=t&&i.set(l,[n.get(y),p])}else{for(var d=s,b=0;b<y.length;++b,++d){for(var v=y[b],g=o*d,M=g-o,_=r[g],E=Math.max(0,d-t-1),S=Math.min(o-1,d+t),w=E;w<S;++w){var T=v!==e[w],C=r[M+w]+ +T,R=r[M+w+1]+1,P=r[g+w]+1,L=r[g+w+1]=Math.min(C,R,P);L<_&&(_=L)}if(_>t)continue e}Jx(n.get(y),e,t,i,r,d,o,l+y)}}}catch(A){u={error:A}}finally{try{m&&!m.done&&(c=h.return)&&c.call(h)}finally{if(u)throw u.error}}},Hf=function(){function n(e,t){e===void 0&&(e=new Map),t===void 0&&(t=""),this._size=void 0,this._tree=e,this._prefix=t}return n.prototype.atPrefix=function(e){var t,i;if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");var r=Dt(ru(this._tree,e.slice(this._prefix.length)),2),s=r[0],o=r[1];if(s===void 0){var l=Dt($f(o),2),u=l[0],c=l[1];try{for(var f=Ze(u.keys()),h=f.next();!h.done;h=f.next()){var m=h.value;if(m!==Qt&&m.startsWith(c)){var y=new Map;return y.set(m.slice(c.length),u.get(m)),new n(y,e)}}}catch(p){t={error:p}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(t)throw t.error}}}return new n(s,e)},n.prototype.clear=function(){this._size=void 0,this._tree.clear()},n.prototype.delete=function(e){return this._size=void 0,tV(this._tree,e)},n.prototype.entries=function(){return new Gf(this,QF)},n.prototype.forEach=function(e){var t,i;try{for(var r=Ze(this),s=r.next();!s.done;s=r.next()){var o=Dt(s.value,2),l=o[0],u=o[1];e(l,u,this)}}catch(c){t={error:c}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},n.prototype.fuzzyGet=function(e,t){return eV(this._tree,e,t)},n.prototype.get=function(e){var t=Wf(this._tree,e);return t!==void 0?t.get(Qt):void 0},n.prototype.has=function(e){var t=Wf(this._tree,e);return t!==void 0&&t.has(Qt)},n.prototype.keys=function(){return new Gf(this,Xx)},n.prototype.set=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var i=jf(this._tree,e);return i.set(Qt,t),this},Object.defineProperty(n.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var e=this.entries();!e.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),n.prototype.update=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var i=jf(this._tree,e);return i.set(Qt,t(i.get(Qt))),this},n.prototype.fetch=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var i=jf(this._tree,e),r=i.get(Qt);return r===void 0&&i.set(Qt,r=t()),r},n.prototype.values=function(){return new Gf(this,Yx)},n.prototype[Symbol.iterator]=function(){return this.entries()},n.from=function(e){var t,i,r=new n;try{for(var s=Ze(e),o=s.next();!o.done;o=s.next()){var l=Dt(o.value,2),u=l[0],c=l[1];r.set(u,c)}}catch(f){t={error:f}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return r},n.fromObject=function(e){return n.from(Object.entries(e))},n}(),ru=function(n,e,t){var i,r;if(t===void 0&&(t=[]),e.length===0||n==null)return[n,t];try{for(var s=Ze(n.keys()),o=s.next();!o.done;o=s.next()){var l=o.value;if(l!==Qt&&e.startsWith(l))return t.push([n,l]),ru(n.get(l),e.slice(l.length),t)}}catch(u){i={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return t.push([n,e]),ru(void 0,"",t)},Wf=function(n,e){var t,i;if(e.length===0||n==null)return n;try{for(var r=Ze(n.keys()),s=r.next();!s.done;s=r.next()){var o=s.value;if(o!==Qt&&e.startsWith(o))return Wf(n.get(o),e.slice(o.length))}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},jf=function(n,e){var t,i,r=e.length;e:for(var s=0;n&&s<r;){try{for(var o=(t=void 0,Ze(n.keys())),l=o.next();!l.done;l=o.next()){var u=l.value;if(u!==Qt&&e[s]===u[0]){for(var c=Math.min(r-s,u.length),f=1;f<c&&e[s+f]===u[f];)++f;var h=n.get(u);if(f===u.length)n=h;else{var m=new Map;m.set(u.slice(f),h),n.set(e.slice(s,s+f),m),n.delete(u),n=m}s+=f;continue e}}}catch(p){t={error:p}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}var y=new Map;return n.set(e.slice(s),y),y}return n},tV=function(n,e){var t=Dt(ru(n,e),2),i=t[0],r=t[1];if(i!==void 0){if(i.delete(Qt),i.size===0)qx(r);else if(i.size===1){var s=Dt(i.entries().next().value,2),o=s[0],l=s[1];Kx(r,o,l)}}},qx=function(n){if(n.length!==0){var e=Dt($f(n),2),t=e[0],i=e[1];if(t.delete(i),t.size===0)qx(n.slice(0,-1));else if(t.size===1){var r=Dt(t.entries().next().value,2),s=r[0],o=r[1];s!==Qt&&Kx(n.slice(0,-1),s,o)}}},Kx=function(n,e,t){if(n.length!==0){var i=Dt($f(n),2),r=i[0],s=i[1];r.set(s+e,t),r.delete(s)}},$f=function(n){return n[n.length-1]},Xa,Zf="or",Qx="and",nV="and_not",iV=function(){function n(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');var t=e.autoVacuum==null||e.autoVacuum===!0?Kf:e.autoVacuum;this._options=dt(dt(dt({},Yf),e),{autoVacuum:t,searchOptions:dt(dt({},ew),e.searchOptions||{}),autoSuggestOptions:dt(dt({},lV),e.autoSuggestOptions||{})}),this._index=new Hf,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=qf,this.addFields(this._options.fields)}return n.prototype.add=function(e){var t,i,r,s,o,l,u=this._options,c=u.extractField,f=u.tokenize,h=u.processTerm,m=u.fields,y=u.idField,p=c(e,y);if(p==null)throw new Error('MiniSearch: document does not have ID field "'.concat(y,'"'));if(this._idToShortId.has(p))throw new Error("MiniSearch: duplicate ID ".concat(p));var d=this.addDocumentId(p);this.saveStoredFields(d,e);try{for(var b=Ze(m),v=b.next();!v.done;v=b.next()){var g=v.value,M=c(e,g);if(M!=null){var _=f(M.toString(),g),E=this._fieldIds[g],S=new Set(_).size;this.addFieldLength(d,E,this._documentCount-1,S);try{for(var w=(r=void 0,Ze(_)),T=w.next();!T.done;T=w.next()){var C=T.value,R=h(C,g);if(Array.isArray(R))try{for(var P=(o=void 0,Ze(R)),L=P.next();!L.done;L=P.next()){var A=L.value;this.addTerm(E,d,A)}}catch(I){o={error:I}}finally{try{L&&!L.done&&(l=P.return)&&l.call(P)}finally{if(o)throw o.error}}else R&&this.addTerm(E,d,R)}}catch(I){r={error:I}}finally{try{T&&!T.done&&(s=w.return)&&s.call(w)}finally{if(r)throw r.error}}}}}catch(I){t={error:I}}finally{try{v&&!v.done&&(i=b.return)&&i.call(b)}finally{if(t)throw t.error}}},n.prototype.addAll=function(e){var t,i;try{for(var r=Ze(e),s=r.next();!s.done;s=r.next()){var o=s.value;this.add(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},n.prototype.addAllAsync=function(e,t){var i=this;t===void 0&&(t={});var r=t.chunkSize,s=r===void 0?10:r,o={chunk:[],promise:Promise.resolve()},l=e.reduce(function(f,h,m){var y=f.chunk,p=f.promise;return y.push(h),(m+1)%s===0?{chunk:[],promise:p.then(function(){return new Promise(function(d){return setTimeout(d,0)})}).then(function(){return i.addAll(y)})}:{chunk:y,promise:p}},o),u=l.chunk,c=l.promise;return c.then(function(){return i.addAll(u)})},n.prototype.remove=function(e){var t,i,r,s,o,l,u=this._options,c=u.tokenize,f=u.processTerm,h=u.extractField,m=u.fields,y=u.idField,p=h(e,y);if(p==null)throw new Error('MiniSearch: document does not have ID field "'.concat(y,'"'));var d=this._idToShortId.get(p);if(d==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(p,": it is not in the index"));try{for(var b=Ze(m),v=b.next();!v.done;v=b.next()){var g=v.value,M=h(e,g);if(M!=null){var _=c(M.toString(),g),E=this._fieldIds[g],S=new Set(_).size;this.removeFieldLength(d,E,this._documentCount,S);try{for(var w=(r=void 0,Ze(_)),T=w.next();!T.done;T=w.next()){var C=T.value,R=f(C,g);if(Array.isArray(R))try{for(var P=(o=void 0,Ze(R)),L=P.next();!L.done;L=P.next()){var A=L.value;this.removeTerm(E,d,A)}}catch(I){o={error:I}}finally{try{L&&!L.done&&(l=P.return)&&l.call(P)}finally{if(o)throw o.error}}else R&&this.removeTerm(E,d,R)}}catch(I){r={error:I}}finally{try{T&&!T.done&&(s=w.return)&&s.call(w)}finally{if(r)throw r.error}}}}}catch(I){t={error:I}}finally{try{v&&!v.done&&(i=b.return)&&i.call(b)}finally{if(t)throw t.error}}this._storedFields.delete(d),this._documentIds.delete(d),this._idToShortId.delete(p),this._fieldLength.delete(d),this._documentCount-=1},n.prototype.removeAll=function(e){var t,i;if(e)try{for(var r=Ze(e),s=r.next();!s.done;s=r.next()){var o=s.value;this.remove(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Hf,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},n.prototype.discard=function(e){var t=this,i=this._idToShortId.get(e);if(i==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(i),this._storedFields.delete(i),(this._fieldLength.get(i)||[]).forEach(function(r,s){t.removeFieldLength(i,s,t._documentCount,r)}),this._fieldLength.delete(i),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},n.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var e=this._options.autoVacuum,t=e.minDirtFactor,i=e.minDirtCount,r=e.batchSize,s=e.batchWait;this.conditionalVacuum({batchSize:r,batchWait:s},{minDirtCount:i,minDirtFactor:t})}},n.prototype.discardAll=function(e){var t,i,r=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var s=Ze(e),o=s.next();!o.done;o=s.next()){var l=o.value;this.discard(l)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}}finally{this._options.autoVacuum=r}this.maybeAutoVacuum()},n.prototype.replace=function(e){var t=this._options,i=t.idField,r=t.extractField,s=r(e,i);this.discard(s),this.add(e)},n.prototype.vacuum=function(e){return e===void 0&&(e={}),this.conditionalVacuum(e)},n.prototype.conditionalVacuum=function(e,t){var i=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var r=i._enqueuedVacuumConditions;return i._enqueuedVacuumConditions=qf,i.performVacuuming(e,r)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)},n.prototype.performVacuuming=function(e,t){return qF(this,void 0,void 0,function(){var i,r,s,o,l,u,c,f,h,m,y,p,d,b,v,g,M,_,E,S,w,T,C,R,P;return KF(this,function(L){switch(L.label){case 0:if(i=this._dirtCount,!this.vacuumConditionsMet(t))return[3,10];r=e.batchSize||Jf.batchSize,s=e.batchWait||Jf.batchWait,o=1,L.label=1;case 1:L.trys.push([1,7,8,9]),l=Ze(this._index),u=l.next(),L.label=2;case 2:if(u.done)return[3,6];c=Dt(u.value,2),f=c[0],h=c[1];try{for(m=(T=void 0,Ze(h)),y=m.next();!y.done;y=m.next()){p=Dt(y.value,2),d=p[0],b=p[1];try{for(v=(R=void 0,Ze(b)),g=v.next();!g.done;g=v.next())M=Dt(g.value,1),_=M[0],!this._documentIds.has(_)&&(b.size<=1?h.delete(d):b.delete(_))}catch(A){R={error:A}}finally{try{g&&!g.done&&(P=v.return)&&P.call(v)}finally{if(R)throw R.error}}}}catch(A){T={error:A}}finally{try{y&&!y.done&&(C=m.return)&&C.call(m)}finally{if(T)throw T.error}}return this._index.get(f).size===0&&this._index.delete(f),o%r!==0?[3,4]:[4,new Promise(function(A){return setTimeout(A,s)})];case 3:L.sent(),L.label=4;case 4:o+=1,L.label=5;case 5:return u=l.next(),[3,2];case 6:return[3,9];case 7:return E=L.sent(),S={error:E},[3,9];case 8:try{u&&!u.done&&(w=l.return)&&w.call(l)}finally{if(S)throw S.error}return[7];case 9:this._dirtCount-=i,L.label=10;case 10:return[4,null];case 11:return L.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},n.prototype.vacuumConditionsMet=function(e){if(e==null)return!0;var t=e.minDirtCount,i=e.minDirtFactor;return t=t||Kf.minDirtCount,i=i||Kf.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=i},Object.defineProperty(n.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),n.prototype.has=function(e){return this._idToShortId.has(e)},n.prototype.getStoredFields=function(e){var t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)},n.prototype.search=function(e,t){var i,r;t===void 0&&(t={});var s=this.executeQuery(e,t),o=[];try{for(var l=Ze(s),u=l.next();!u.done;u=l.next()){var c=Dt(u.value,2),f=c[0],h=c[1],m=h.score,y=h.terms,p=h.match,d=y.length||1,b={id:this._documentIds.get(f),score:m*d,terms:Object.keys(p),queryTerms:y,match:p};Object.assign(b,this._storedFields.get(f)),(t.filter==null||t.filter(b))&&o.push(b)}}catch(v){i={error:v}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(i)throw i.error}}return e===n.wildcard&&t.boostDocument==null&&this._options.searchOptions.boostDocument==null||o.sort(nw),o},n.prototype.autoSuggest=function(e,t){var i,r,s,o;t===void 0&&(t={}),t=dt(dt({},this._options.autoSuggestOptions),t);var l=new Map;try{for(var u=Ze(this.search(e,t)),c=u.next();!c.done;c=u.next()){var f=c.value,h=f.score,m=f.terms,y=m.join(" "),p=l.get(y);p!=null?(p.score+=h,p.count+=1):l.set(y,{score:h,terms:m,count:1})}}catch(E){i={error:E}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(i)throw i.error}}var d=[];try{for(var b=Ze(l),v=b.next();!v.done;v=b.next()){var g=Dt(v.value,2),p=g[0],M=g[1],h=M.score,m=M.terms,_=M.count;d.push({suggestion:p,terms:m,score:h/_})}}catch(E){s={error:E}}finally{try{v&&!v.done&&(o=b.return)&&o.call(b)}finally{if(s)throw s.error}}return d.sort(nw),d},Object.defineProperty(n.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),n.loadJSON=function(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),t)},n.getDefault=function(e){if(Yf.hasOwnProperty(e))return Xf(Yf,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))},n.loadJS=function(e,t){var i,r,s,o,l,u,c=e.index,f=e.documentCount,h=e.nextId,m=e.documentIds,y=e.fieldIds,p=e.fieldLength,d=e.averageFieldLength,b=e.storedFields,v=e.dirtCount,g=e.serializationVersion;if(g!==1&&g!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var M=new n(t);M._documentCount=f,M._nextId=h,M._documentIds=su(m),M._idToShortId=new Map,M._fieldIds=y,M._fieldLength=su(p),M._avgFieldLength=d,M._storedFields=su(b),M._dirtCount=v||0,M._index=new Hf;try{for(var _=Ze(M._documentIds),E=_.next();!E.done;E=_.next()){var S=Dt(E.value,2),w=S[0],T=S[1];M._idToShortId.set(T,w)}}catch(D){i={error:D}}finally{try{E&&!E.done&&(r=_.return)&&r.call(_)}finally{if(i)throw i.error}}try{for(var C=Ze(c),R=C.next();!R.done;R=C.next()){var P=Dt(R.value,2),L=P[0],A=P[1],I=new Map;try{for(var O=(l=void 0,Ze(Object.keys(A))),x=O.next();!x.done;x=O.next()){var N=x.value,B=A[N];g===1&&(B=B.ds),I.set(parseInt(N,10),su(B))}}catch(D){l={error:D}}finally{try{x&&!x.done&&(u=O.return)&&u.call(O)}finally{if(l)throw l.error}}M._index.set(L,I)}}catch(D){s={error:D}}finally{try{R&&!R.done&&(o=C.return)&&o.call(C)}finally{if(s)throw s.error}}return M},n.prototype.executeQuery=function(e,t){var i=this;if(t===void 0&&(t={}),e===n.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){var r=dt(dt(dt({},t),e),{queries:void 0}),s=e.queries.map(function(b){return i.executeQuery(b,r)});return this.combineResults(s,r.combineWith)}var o=this._options,l=o.tokenize,u=o.processTerm,c=o.searchOptions,f=dt(dt({tokenize:l,processTerm:u},c),t),h=f.tokenize,m=f.processTerm,y=h(e).flatMap(function(b){return m(b)}).filter(function(b){return!!b}),p=y.map(aV(f)),d=p.map(function(b){return i.executeQuerySpec(b,f)});return this.combineResults(d,f.combineWith)},n.prototype.executeQuerySpec=function(e,t){var i,r,s,o,l=dt(dt({},this._options.searchOptions),t),u=(l.fields||this._options.fields).reduce(function(N,B){var D;return dt(dt({},N),(D={},D[B]=Xf(l.boost,B)||1,D))},{}),c=l.boostDocument,f=l.weights,h=l.maxFuzzy,m=l.bm25,y=dt(dt({},ew.weights),f),p=y.fuzzy,d=y.prefix,b=this._index.get(e.term),v=this.termResults(e.term,e.term,1,b,u,c,m),g,M;if(e.prefix&&(g=this._index.atPrefix(e.term)),e.fuzzy){var _=e.fuzzy===!0?.2:e.fuzzy,E=_<1?Math.min(h,Math.round(e.term.length*_)):_;E&&(M=this._index.fuzzyGet(e.term,E))}if(g)try{for(var S=Ze(g),w=S.next();!w.done;w=S.next()){var T=Dt(w.value,2),C=T[0],R=T[1],P=C.length-e.term.length;if(P){M==null||M.delete(C);var L=d*C.length/(C.length+.3*P);this.termResults(e.term,C,L,R,u,c,m,v)}}}catch(N){i={error:N}}finally{try{w&&!w.done&&(r=S.return)&&r.call(S)}finally{if(i)throw i.error}}if(M)try{for(var A=Ze(M.keys()),I=A.next();!I.done;I=A.next()){var C=I.value,O=Dt(M.get(C),2),x=O[0],P=O[1];if(P){var L=p*C.length/(C.length+P);this.termResults(e.term,C,L,x,u,c,m,v)}}}catch(N){s={error:N}}finally{try{I&&!I.done&&(o=A.return)&&o.call(A)}finally{if(s)throw s.error}}return v},n.prototype.executeWildcardQuery=function(e){var t,i,r=new Map,s=dt(dt({},this._options.searchOptions),e);try{for(var o=Ze(this._documentIds),l=o.next();!l.done;l=o.next()){var u=Dt(l.value,2),c=u[0],f=u[1],h=s.boostDocument?s.boostDocument(f,"",this._storedFields.get(c)):1;r.set(c,{score:h,terms:[],match:{}})}}catch(m){t={error:m}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}return r},n.prototype.combineResults=function(e,t){if(t===void 0&&(t=Zf),e.length===0)return new Map;var i=t.toLowerCase();return e.reduce(rV[i])||new Map},n.prototype.toJSON=function(){var e,t,i,r,s=[];try{for(var o=Ze(this._index),l=o.next();!l.done;l=o.next()){var u=Dt(l.value,2),c=u[0],f=u[1],h={};try{for(var m=(i=void 0,Ze(f)),y=m.next();!y.done;y=m.next()){var p=Dt(y.value,2),d=p[0],b=p[1];h[d]=Object.fromEntries(b)}}catch(v){i={error:v}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(i)throw i.error}}s.push([c,h])}}catch(v){e={error:v}}finally{try{l&&!l.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:s,serializationVersion:2}},n.prototype.termResults=function(e,t,i,r,s,o,l,u){var c,f,h,m,y;if(u===void 0&&(u=new Map),r==null)return u;try{for(var p=Ze(Object.keys(s)),d=p.next();!d.done;d=p.next()){var b=d.value,v=s[b],g=this._fieldIds[b],M=r.get(g);if(M!=null){var _=M.size,E=this._avgFieldLength[g];try{for(var S=(h=void 0,Ze(M.keys())),w=S.next();!w.done;w=S.next()){var T=w.value;if(!this._documentIds.has(T)){this.removeTerm(g,T,t),_-=1;continue}var C=o?o(this._documentIds.get(T),t,this._storedFields.get(T)):1;if(C){var R=M.get(T),P=this._fieldLength.get(T)[g],L=oV(R,_,this._documentCount,P,E,l),A=i*v*C*L,I=u.get(T);if(I){I.score+=A,cV(I.terms,e);var O=Xf(I.match,t);O?O.push(b):I.match[t]=[b]}else u.set(T,{score:A,terms:[e],match:(y={},y[t]=[b],y)})}}}catch(x){h={error:x}}finally{try{w&&!w.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}}}}catch(x){c={error:x}}finally{try{d&&!d.done&&(f=p.return)&&f.call(p)}finally{if(c)throw c.error}}return u},n.prototype.addTerm=function(e,t,i){var r=this._index.fetch(i,iw),s=r.get(e);if(s==null)s=new Map,s.set(t,1),r.set(e,s);else{var o=s.get(t);s.set(t,(o||0)+1)}},n.prototype.removeTerm=function(e,t,i){if(!this._index.has(i)){this.warnDocumentChanged(t,e,i);return}var r=this._index.fetch(i,iw),s=r.get(e);s==null||s.get(t)==null?this.warnDocumentChanged(t,e,i):s.get(t)<=1?s.size<=1?r.delete(e):s.delete(t):s.set(t,s.get(t)-1),this._index.get(i).size===0&&this._index.delete(i)},n.prototype.warnDocumentChanged=function(e,t,i){var r,s;try{for(var o=Ze(Object.keys(this._fieldIds)),l=o.next();!l.done;l=o.next()){var u=l.value;if(this._fieldIds[u]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(i,'" was not present in field "').concat(u,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(c){r={error:c}}finally{try{l&&!l.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}},n.prototype.addDocumentId=function(e){var t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t},n.prototype.addFields=function(e){for(var t=0;t<e.length;t++)this._fieldIds[e[t]]=t},n.prototype.addFieldLength=function(e,t,i,r){var s=this._fieldLength.get(e);s==null&&this._fieldLength.set(e,s=[]),s[t]=r;var o=this._avgFieldLength[t]||0,l=o*i+r;this._avgFieldLength[t]=l/(i+1)},n.prototype.removeFieldLength=function(e,t,i,r){if(i===1){this._avgFieldLength[t]=0;return}var s=this._avgFieldLength[t]*i-r;this._avgFieldLength[t]=s/(i-1)},n.prototype.saveStoredFields=function(e,t){var i,r,s=this._options,o=s.storeFields,l=s.extractField;if(!(o==null||o.length===0)){var u=this._storedFields.get(e);u==null&&this._storedFields.set(e,u={});try{for(var c=Ze(o),f=c.next();!f.done;f=c.next()){var h=f.value,m=l(t,h);m!==void 0&&(u[h]=m)}}catch(y){i={error:y}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(i)throw i.error}}}},n.wildcard=Symbol("*"),n}(),Xf=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0},rV=(Xa={},Xa[Zf]=function(n,e){var t,i;try{for(var r=Ze(e.keys()),s=r.next();!s.done;s=r.next()){var o=s.value,l=n.get(o);if(l==null)n.set(o,e.get(o));else{var u=e.get(o),c=u.score,f=u.terms,h=u.match;l.score=l.score+c,l.match=Object.assign(l.match,h),tw(l.terms,f)}}}catch(m){t={error:m}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},Xa[Qx]=function(n,e){var t,i,r=new Map;try{for(var s=Ze(e.keys()),o=s.next();!o.done;o=s.next()){var l=o.value,u=n.get(l);if(u!=null){var c=e.get(l),f=c.score,h=c.terms,m=c.match;tw(u.terms,h),r.set(l,{score:u.score+f,terms:u.terms,match:Object.assign(u.match,m)})}}}catch(y){t={error:y}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return r},Xa[nV]=function(n,e){var t,i;try{for(var r=Ze(e.keys()),s=r.next();!s.done;s=r.next()){var o=s.value;n.delete(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},Xa),sV={k:1.2,b:.7,d:.5},oV=function(n,e,t,i,r,s){var o=s.k,l=s.b,u=s.d,c=Math.log(1+(t-e+.5)/(e+.5));return c*(u+n*(o+1)/(n+o*(1-l+l*i/r)))},aV=function(n){return function(e,t,i){var r=typeof n.fuzzy=="function"?n.fuzzy(e,t,i):n.fuzzy||!1,s=typeof n.prefix=="function"?n.prefix(e,t,i):n.prefix===!0;return{term:e,fuzzy:r,prefix:s}}},Yf={idField:"id",extractField:function(n,e){return n[e]},tokenize:function(n){return n.split(uV)},processTerm:function(n){return n.toLowerCase()},fields:void 0,searchOptions:void 0,storeFields:[],logger:function(n,e){typeof(console==null?void 0:console[n])=="function"&&console[n](e)},autoVacuum:!0},ew={combineWith:Zf,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:sV},lV={combineWith:Qx,prefix:function(n,e,t){return e===t.length-1}},Jf={batchSize:1e3,batchWait:10},qf={minDirtFactor:.1,minDirtCount:20},Kf=dt(dt({},Jf),qf),cV=function(n,e){n.includes(e)||n.push(e)},tw=function(n,e){var t,i;try{for(var r=Ze(e),s=r.next();!s.done;s=r.next()){var o=s.value;n.includes(o)||n.push(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},nw=function(n,e){var t=n.score,i=e.score;return i-t},iw=function(){return new Map},su=function(n){var e,t,i=new Map;try{for(var r=Ze(Object.keys(n)),s=r.next();!s.done;s=r.next()){var o=s.value;i.set(parseInt(o,10),n[o])}}catch(l){e={error:l}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i},uV=/[\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;const dV=["label","models","source"];class hV{constructor(){this._searchEngine=new iV({fields:["path","name"],storeFields:["path"],tokenize:(e,t)=>e.split('"')}),this._featureIds=[],this.zincObjects=[],this.regions=[]}indexMetadata(e,t){const i=[];for(const r of dV)if(r in t){const s=t[r];i.includes(s)||(this.addTerm_(e,s),i.push(s))}}addZincObject(e,t){const i=e.getRegion().getFullPath(),s={path:i?`${i}/${e.groupName}`:e.groupName,name:e.groupName,id:t};this._searchEngine.add(s,{fields:["path","name"]}),this.zincObjects.push(e)}removeZincObject(e,t){const i=e.getRegion().getFullPath(),s={path:i?`${i}/${e.groupName}`:e.groupName,name:e.groupName,id:t};this._searchEngine.remove(s,{fields:["path","name"]});for(let o=0;o<this.zincObjects.length;o++)if(t===this.zincObjects[o].uuid){this.zincObjects.splice(o,1);return}}addRegion(e,t){const i={path:e.getFullPath(),name:e.getName(),id:t};this._searchEngine.add(i,{fields:["path","name"]}),this.regions.push(e)}clearResults(){this._}removeAll(){this._searchEngine.removeAll(),this.zincObjects.length=0,this.regions.length=0}auto_suggest(e){return this._searchEngine.autoSuggest(e,{prefix:!0})}processResults(e,t){const i={regionPath:void 0,label:'Search Results for "'};return Array.isArray(t)?i.label+=",".join(t):i.label+=t,i.label+='"',e.length===1&&(e[0].isRegion?i.regionPath=e[0].getFullPath():e[0].isZincObject&&(i.regionPath=e[0].getRegion().getFullPath(),i.label=e[0].groupName)),i.zincObjects=cF(e),i}search(e){const t=this._searchEngine.search(e,{prefix:!0}),i=this.zincObjects.filter(s=>t.map(o=>o.id).includes(s.uuid)),r=this.regions.filter(s=>t.map(o=>o.id).includes(s.uuid));return i.push(...r),i}searchTerms(e){let t=[];return e.forEach(i=>{const r=this.search(i);t.push(...r)}),t}searchAndProcessResult(e){let t=[];return Array.isArray(e)?t=this.searchTerms(e):t=this.search(e),this.processResults(t,e)}}const fV={name:"ScaffoldVuer",components:{Button:Cs,Col:Fn,Loading:YL,Option:Ls,Popover:Pl,Row:Qn,Select:As,Slider:Ln,TabPane:jg,Tabs:Wg,MapSvgIcon:ep.MapSvgIcon,MapSvgSpriteColor:ep.MapSvgSpriteColor,PrimitiveControls:Dx,ScaffoldTooltip:jx,ElIconWarningFilled:lm,ElIconArrowDown:Lu,ElIconArrowLeft:Wi,DrawToolbar:Ja.DrawToolbar,ScaffoldTreeControls:Bx},setup(n){let e=a.inject("$annotator");return e||(e=a.markRaw(new HF(`${n.flatmapAPI}annotator`)),a.provide("$annotator",e)),{annotator:e}},props:{annotationSidebar:{type:Boolean,default:!1},url:{type:String,default:""},showColourPicker:{type:Boolean,default:!1},displayUI:{type:Boolean,default:!0},displayAtStartUp:{type:Boolean,default:!0},helpMode:{type:Boolean,default:!1},helpModeActiveItem:{type:Number,default:0},helpModeDialog:{type:Boolean,default:!1},helpModeLastItem:{type:Boolean,default:!1},helpModeInitialIndex:{type:Number,default:0},displayWarning:{type:Boolean,default:!0},warningMessage:{type:String,default:"Beta feature - under active development"},displayLatestChanges:{type:Boolean,default:!1},latestChangesMessage:{type:String,default:"New feature - Local search is now available"},displayMarkers:{type:Boolean,default:!1},markerCluster:{type:Boolean,default:!1},markerLabels:{type:Object,default:function(){return{}}},displayMinimap:{type:Boolean,default:!1},format:{type:String,default:"metadata"},minimapSettings:{type:Object,default:function(){return{x_offset:16,y_offset:16,width:128,height:128,align:"top-right"}}},enableOpenMapUI:{type:Boolean,default:!1},openMapOptions:{type:Array,default:function(){return[{display:"Open AC Map",key:"AC"},{display:"Open FC Map",key:"FC"},{display:"Open 3D Human Map",key:"3D"}]}},state:{type:Object,default:void 0},region:{type:String,default:""},viewURL:{type:String,default:""},render:{type:Boolean,default:!0},flatmapAPI:{type:String,default:"https://mapcore-demo.org/current/flatmap/v3/"},enableLocalAnnotations:{type:Boolean,default:!1}},provide(){return{flatmapAPI:this.flatmapAPI,scaffoldUrl:this.url,boundingDims:this.boundingDims}},data:function(){return{annotator:void 0,createData:{drawingBox:!1,toBeConfirmed:!1,points:[],shape:"",x:0,y:0,editingIndex:-1,faceIndex:-1,toBeDeleted:!1},currentTime:0,timeVarying:!1,isPlaying:!1,isReady:!1,isTransitioning:!1,tooltipAppendToBody:!1,hoverVisibilities:[{value:!1,ref:"zoomInPopover"},{value:!1,ref:"zoomOutPopover"},{value:!1,ref:"zoomFitPopover"},{value:!1,ref:"openMapPopover"},{value:!1,ref:"settingsPopover"},{value:!1,ref:"sliderPopover"},{value:!1,ref:"regionVisibilityPopover"},{value:!1,ref:"warningPopover"},{value:!1,ref:"whatsNewPopover"},{value:!1,refs:"toolbarPopover",ref:"editPopover"},{value:!1,refs:"toolbarPopover",ref:"pointPopover"},{value:!1,refs:"toolbarPopover",ref:"lineStringPopover"},{value:!1,refs:"toolbarPopover",ref:"deletePopover"}],inHelp:!1,helpModeActiveIndex:this.helpModeInitialIndex,loading:!1,duration:3e3,drawerOpen:!0,currentBackground:"white",availableBackground:["white","lightskyblue","black"],minimisedSlider:!1,sliderPosition:"",timeMax:100,orginalDuration:"",animateDuration:"6secs",playSpeed:[{value:.1,label:"0.1x"},{value:.5,label:"0.5x"},{value:1,label:"1x"},{value:2,label:"2x"},{value:5,label:"5x"},{value:10,label:"10x"}],currentSpeed:1,timeStamps:{},defaultCheckedKeys:[],tData:{label:"",region:"",visible:!1,x:200,y:200,active:!1},fileFormat:"metadata",previousMarkerLabels:a.markRaw({}),viewingMode:"Exploration",viewingModes:{Exploration:"View and explore detailed visualization of 3D scaffolds",Annotation:"View internal identifiers of features"},openMapRef:void 0,backgroundIconRef:void 0,userInformation:void 0,toolbarOptions:["Delete","Edit","Point","LineString"],activeDrawTool:void 0,activeDrawMode:void 0,localAnnotationsList:a.markRaw([]),boundingDims:{centre:[0,0,0],size:[1,1,1]}}},watch:{format:{handler:function(n){this.fileFormat=n},immediate:!0},url:{handler:function(n){(this.state===void 0||this.state.url===void 0)&&this.setURL(n)},immediate:!0},region:{handler:function(n){this.state||this.viewURL||this.setFocusedRegion(n)},immediate:!0},state:{handler:function(n){this.setState(n)},immediate:!0,deep:!0},viewURL:{handler:function(n){this.updateViewURL(n)},immediate:!0},helpMode:function(n,e){n!==e&&this.setHelpMode(n)},helpModeActiveItem:function(){this.helpMode&&(this.helpModeActiveIndex+=1,this.setHelpMode(this.helpMode))},displayMarkers:function(n){this.$module.scene.displayMarkers=n,this.$module.scene.forcePickableObjectsUpdate=!0},displayMinimap:function(n){this.$module.scene.displayMinimap=n},currentTime:{handler:function(){this.$emit("timeChanged",this.currentTime)}},duration:function(){this.$module.scene.setDuration(this.duration)},minimapSettings:{deep:!0,handler:"updateMinimapScissor"},render:function(n){this.toggleRendering(n)},markerCluster:{handler:function(n){this.$module.scene.enableMarkerCluster(n)},immediate:!0},markerLabels:function(n){for(const[e,t]of Object.entries(this.previousMarkerLabels))this.setMarkerModeForObjectsWithName(e,t,"off");for(const[e,t]of Object.entries(n))this.setMarkerModeForObjectsWithName(e,t,"on");this.previousMarkerLabels=a.markRaw({...n})},annotationDisplay:function(n){if(this.annotationSidebar)if(n){const t={featureId:(this.tData.region?this.tData.region+"/":"")+this.tData.label,resourceId:this.url,resource:this.url};this.$emit("annotation-open",{annotationEntry:t,commitCallback:this.commitAnnotationEvent})}else(!this.createData.toBeConfirmed||!this.createData.toBeDeleted)&&this.$emit("annotation-close")}},beforeCreate:function(){this.$module=new Zx,this.selectedObjects=[],this.hoveredObjects=[],this.currentBackground="white",this._currentURL=void 0,this.availableBackground=["white","black","lightskyblue"],this.$_searchIndex=new hV},mounted:function(){this.openMapRef=a.shallowRef(this.$refs.openMapRef),this.backgroundIconRef=a.shallowRef(this.$refs.backgroundIconRef),this.$refs.scaffoldTreeControls.setModule(this.$module);let n=new $F;n.subscribe(this,this.eventNotifierCallback),this.$module.addNotifier(n),this.$module.addOrganPartAddedCallback(this.zincObjectAdded),this.$module.addOrganPartRemovedCallback(this.zincObjectRemoved),this.$module.initialiseRenderer(this.$refs.display),this.toggleRendering(this.render),this.ro=new ResizeObserver(this.adjustLayout).observe(this.$refs.scaffoldContainer),this.helpTextWait=[],this.helpTextWait.length=this.hoverVisibilities.length,this.defaultRate=this.$module.getPlayRate(),this.$module.zincRenderer.addPreRenderCallbackFunction(()=>{this.currentTime=this.$module.getCurrentTime()})},beforeUnmount:function(){this.ro&&this.ro.disconnect(),this.$module.destroy(),this.$module=void 0},computed:{...Hx(Wx,["userToken"]),annotationDisplay:function(){return this.viewingMode==="Annotation"&&this.tData.active===!0&&this.activeDrawMode!=="Point"&&this.activeDrawMode!=="LineString"}},methods:{addZincObject:function(n){this.$module.scene&&this.$module.scene.addZincObject(n)},zincObjectAdded:function(n){this.loading=!1,this.$_searchIndex.addZincObject(n,n.uuid),this.timeVarying===!1&&n.isTimeVarying()&&(this.timeVarying=!0),this.$emit("zinc-object-added",n)},removeFromLocalAnnotationList:function(n,e){for(let t=0;t<this.localAnnotationsList.length;t++){const i=this.localAnnotationsList[t];if(i.region===n&&i.group===e){this.localAnnotationsList.splice(t,1);return}}},zincObjectRemoved:function(n){if(this.$module.scene){const e=n.region.getFullPath(),t=n.groupName;n.region.findObjectsWithGroupName(t,!1).length===0&&(this.$_searchIndex.removeZincObject(n,n.uuid),this.removeFromLocalAnnotationList(e,t))}},addRegionsToSearchIndex:function(){this.$module.scene.getRootRegion().getChildRegions(!0).forEach(t=>{this.$_searchIndex.addRegion(t,t.uuid)})},backgroundChangeCallback:function(n){this.currentBackground=n,this.$module.zincRenderer.getThreeJSRenderer().setClearColor(this.currentBackground,1)},captureScreenshotCallback:function(){this.$module.zincRenderer.removePostRenderCallbackFunction(this.captureID);let n=this.$module.zincRenderer.getThreeJSRenderer().domElement.toDataURL("image/png"),e=document.createElement("a");document.body.append(e),this.captureFilename?e.download=this.captureFilename:e.download="screenshot.png",e.href=n,e.click(),e.remove()},captureScreenshot:function(n){this.captureFilename=n,this.captureID=this.$module.zincRenderer.addPostRenderCallbackFunction(this.captureScreenshotCallback)},clearScene:function(){this.$refs.scaffoldTreeControls&&this.$refs.scaffoldTreeControls.clear(),this.$_searchIndex&&this.$_searchIndex.removeAll(),this.$module.scene&&this.$module.scene.clearAll()},addAndEditAnnotations:function(n,e,t,i){const r=Ax(this.annotator,this.userToken,t,n,e,this.url,i);if(this.enableLocalAnnotations){r.group=e;let s=n;s.slice(-1)==="/"&&(s=s.slice(0,-1)),r.region=s,this.removeFromLocalAnnotationList(s,e),this.localAnnotationsList.push(r)}this.$emit("userPrimitivesUpdated",{region:n,group:e,zincObject:t})},primitivesUpdated:function(n){if(n.isZincObject&&n.isEditable){const e=n.groupName,t=n.region.getFullPath();this.addAndEditAnnotations(t,e,n,"Position Updated")}},confirmCreate:function(n){if(n){let e;if(n.shape==="Point")e=this.$module.scene.createPoints(n.region,n.group,this.createData.points,n.group,8942);else if(n.shape==="LineString")e=this.$module.scene.createLines(n.region,n.group,[this.createData.points[0],this.createData.points[1]],60962);else if(n.editingIndex>-1&&this._editingZincObject){this._editingZincObject.editVertices([this.createData.points[1]],n.editingIndex);const t=this._editingZincObject.region.getFullPath()+"/",i=this._editingZincObject.groupName;this.addAndEditAnnotations(t,i,this._editingZincObject,"Position Updated")}e&&(this.addAndEditAnnotations(n.region,n.group,e.zincObject,"Create"),e.zincObject.isEditable=!0,this.tData.region=n.region,this.tData.label=n.group,this.changeActiveByName([n.group],n.region,!1))}this.cancelCreate()},cancelCreate:function(){this.createData.points.length=0,this.createData.toBeConfirmed=!1,this._editingZincObject=void 0,this.createData.editingIndex=-1,this.createData.faceIndex=-1,this.tData.visible=!1,this.createData.toBeDeleted=!1,this._tempLine&&(this.$module.scene.removeTemporaryPrimitive(this._tempLine),this._tempLine=void 0),this._tempPoint&&(this.$module.scene.removeTemporaryPrimitive(this._tempPoint),this._tempPoint=void 0),this.annotationSidebar&&this.$emit("annotation-close")},confirmDelete:function(){var n;if((n=this._editingZincObject)!=null&&n.isEditable){const e=this._editingZincObject.region.getFullPath()+"/",t=this._editingZincObject.groupName;Ax(this.annotator,this.userToken,this._editingZincObject,e,t,this.url,"Deleted")&&this.$module.scene.getRootRegion().findChildFromPath(e).removeZincObject(this._editingZincObject)}this.cancelCreate()},onTooltipHide:function(){this.createData.toBeConfirmed&&!this.annotationSidebar&&this.cancelCreate()},formatTooltip(n){if(this.timeMax>=1e3&&n){let e=(n%6e4/1e3).toFixed(2)+"s";return(n>6e4?(n/6e4).toFixed(0)+"m ":"")+e}return n?n.toFixed(2)+" ms":"0 ms"},fitWindow:function(){if(this.$module.scene){let n=!1;this._boundingBoxGeo&&(n=this._boundingBoxGeo.getVisibility(),this._boundingBoxGeo.setVisibility(!1)),this.$module.scene.viewAll(),this._boundingBoxGeo&&(aF(this._boundingBoxGeo,this.$module.scene),this._boundingBoxGeo.setVisibility(n))}},zoomIn:function(){this.$module.scene&&this.$module.scene.changeZoomByScrollRateUnit(-1)},zoomOut:function(){this.$module.scene&&this.$module.scene.changeZoomByScrollRateUnit(1)},speedChanged:function(n){this.currentSpeed=n,this.$module.setPlayRate(this.defaultRate*this.currentSpeed)},stopFreeSpin:function(){this.$module.scene.getZincCameraControls().stopAutoTumble(),this.isTransitioning=!1},findObjectsWithGroupName:function(n){let e=[];return n&&n!=""&&this.$module.scene&&(e=this.$module.scene.findObjectsWithGroupName(n)),e},toggleDrawing:function(n,e){this.createData.toBeDeleted=!1,n==="mode"?(this.activeDrawMode=e,this.createData.shape="",this.$module.selectObjectOnPick=!0):n==="tool"&&(this.activeDrawTool=e,this.createData.shape=this.activeDrawTool,this.$module.selectObjectOnPick=!1)},toggleDrawingBox:function(){this.createData.drawingBox=!this.createData.drawingBox},viewRegion:function(n){const e=this.$module.scene.getRootRegion(),t=Array.isArray(n)?n:[n],i=Lo(e,t,"",!0);let r=this.$module.scene.getBoundingBoxOfZincObjects(i);if(r){if(this.$module.isSyncControl())this.$module.setSyncControlZoomToBox(r);else{const s=this.$module.scene.camera.far-this.$module.scene.camera.near;this.$module.scene.viewAllWithBoundingBox(r),this.$module.scene.camera.far=this.$module.scene.camera.near+s,this.$module.scene.camera.updateProjectionMatrix()}return!0}return!1},setFocusedRegion:function(n){n&&(this.isReady?this.viewRegion(n):this.$module.setFinishDownloadCallback(this.setURLFinishCallback({region:n})))},updateViewURL:function(n){if(n)if(this.isReady){const e=new URL(n,this.url);this.$module.scene.loadViewURL(e)}else this.$module.setFinishDownloadCallback(this.setURLFinishCallback({viewURL:n}))},createEditTemporaryLines:function(n){const e=n[0].extraData.worldCoords;if(e&&(this.createData.shape==="LineString"||this.createData.editingIndex>-1)&&this.createData.points.length===1)if(this.showRegionTooltipWithAnnotations(n,!0,!1),this.tData.x=50,this.tData.y=200,this._tempLine){const t=this._tempLine.geometry.getAttribute("position");t.setXYZ(1,e[0],e[1],e[2]),t.needsUpdate=!0}else this._tempLine=this.$module.scene.addTemporaryLines([this.createData.points[0],e],65535)},draw:function(n){n&&n.length>0&&n[0].data.group&&n[0].extraData.worldCoords&&(this.createData.shape==="Point"?this.drawPoint(n[0].extraData.worldCoords,n):(this.createData.shape==="LineString"||this.createData.editingIndex>-1)&&this.drawLine(n[0].extraData.worldCoords,n))},drawPoint:function(n,e){this.createData.toBeConfirmed===!1&&(this.createData.points.length=0,this.createData.points.push(n),this.createData.toBeConfirmed=!0,this.showRegionTooltipWithAnnotations(e,!0,!1),this.tData.x=50,this.tData.y=200,this._tempPoint=this.$module.scene.addTemporaryPoints([n],16776960))},drawLine:function(n,e){this.createData.toBeConfirmed===!1&&(this.createData.points.length===1?(this.createData.points.push(n),this.createData.toBeConfirmed=!0,this.showRegionTooltipWithAnnotations(e,!0,!1),this.tData.x=50,this.tData.y=200):(this._tempPoint=this.$module.scene.addTemporaryPoints([n],16776960),this.createData.points.push(n)))},getRendererInfo:function(){if(this.$module.zincRenderer)return this.$module.zincRenderer.getThreeJSRenderer().info},freeSpin:function(){if(this.$module.scene){let n=this.$module.scene.getZincCameraControls();this.isTransitioning=!0,n.enableAutoTumble(),n.autoTumble([1,0],Math.PI,!0),setTimeout(this.stopFreeSpin,4e3)}},activateAnnotationMode:function(n,e){if(this.userInformation||this.enableLocalAnnotations)if(this.createData.toBeDeleted=!1,this.createData.shape!==""||this.createData.editingIndex>-1)n.length>0&&e.identifiers[0].coords&&(this.createData.x=e.identifiers[0].coords.x,this.createData.y=e.identifiers[0].coords.y,this.draw(e.identifiers));else{if(this.activeDrawMode==="Edit"){const t=rF(e);t&&this.activateEditingMode(t.zincObject,t.faceIndex,t.vertexIndex,t.point)}else if(this.activeDrawMode==="Delete"){const t=sF(e);t&&(this.createData.toBeDeleted=!0,this._editingZincObject=t)}this.activeDrawMode!=="Point"&&this.activeDrawMode!=="LineString"?this.showRegionTooltipWithAnnotations(e.identifiers,!0,!1):this.showRegionTooltipWithAnnotations(e.identifiers,!0,!0)}else this.showRegionTooltipWithAnnotations(e.identifiers,!0,!0)},activateEditingMode:function(n,e,t,i){this._editingZincObject=n,this.createData.faceIndex=e,this.createData.editingIndex=t,this.drawLine(i,void 0)},eventNotifierCallback:function(n){if(!(this.createData.toBeConfirmed||this.createData.toBeDeleted)){const e=[];let t=[];if((n.eventType==1||n.eventType==2)&&(n.identifiers.forEach(i=>{if(i){let r=i.data.id?i.data.id:i.data.group;e.push(r)}}),t=n.zincObjects),n.eventType==1)this.viewingMode==="Annotation"?this.activateAnnotationMode(e,n):(this.$refs.scaffoldTreeControls&&(e.length>0?(this.$refs.scaffoldTreeControls.updateActiveUI(t),this.updatePrimitiveControls(t)):(this.hideRegionTooltip(),this.$refs.scaffoldTreeControls.removeActive(!1))),this.$emit("scaffold-selected",n.identifiers));else if(n.eventType==2){if(this.selectedObjects.length===0){if(this.hideRegionTooltip(),this.$refs.scaffoldTreeControls&&(e.length>0?this.$refs.scaffoldTreeControls.updateHoverUI(t):this.$refs.scaffoldTreeControls.removeHover(!0)),n.identifiers.length>0&&n.identifiers[0]){let i=n.identifiers[0].data.id?n.identifiers[0].data.id:n.identifiers[0].data.group;n.identifiers[0].coords&&(this.tData.active=!1,this.tData.visible=!0,this.tData.label=i,n.identifiers[0].data.region?this.tData.region=n.identifiers[0].data.region:this.tData.region=void 0,this.tData.x=n.identifiers[0].coords.x,this.tData.y=n.identifiers[0].coords.y,this.createEditTemporaryLines(n.identifiers))}this.$emit("scaffold-highlighted",n.identifiers)}}else if(n.eventType==3&&n.identifiers.length>0&&n.identifiers[0]){if(n.identifiers[0].coords){const i=this.$refs.scaffoldContainer.getBoundingClientRect();this.tData.x=n.identifiers[0].coords.x-i.left,this.tData.y=n.identifiers[0].coords.y-i.top}this.createEditTemporaryLines(n.identifiers)}}},getCoordinatesOfSelected:function(){if(this.selectedObjects&&this.selectedObjects.length>0)return this.$module.scene.getObjectsScreenXY(this.selectedObjects)},getDynamicSelectedCoordinates:function(){return this.$module.selectedScreenCoordinates},timeChange:function(n){let e=n/this.timeMax*100;e!=this.currentTime&&this.$module.updateTime(e)},updatePrimitiveControls:function(n){this.selectedObjects=n,this.selectedObjects&&this.selectedObjects.length>0?this.$refs.primitiveControls.setObject(this.selectedObjects[0]):this.$refs.primitiveControls.setObject(void 0)},objectSelected:function(n,e){this.updatePrimitiveControls(n),this.$module.setSelectedByZincObjects(n,void 0,{},e)},objectHovered:function(n,e){this.hoveredObjects=n,this.$module.setHighlightedByZincObjects(n,void 0,{},e)},changeActiveByName:function(n,e,t){const i=Array.isArray(n);if(n===void 0||i&&n.length===0)this.$refs.scaffoldTreeControls.removeActive(t);else{let r=n;i||(r=[r]),this.$refs.scaffoldTreeControls.changeActiveByNames(r,e,t)}},changeHighlightedByName:function(n,e,t){const i=Array.isArray(n);if(n===void 0||i&&n.length===0)this.$refs.scaffoldTreeControls.removeHover(t);else{let r=n;i||(r=[r]),this.$refs.scaffoldTreeControls.changeHoverByNames(r,e,t)}},play:function(n){this.$module.playAnimation(n),this.isPlaying=n},setHelpMode:function(n){const e=this.hoverVisibilities.length,t=e-1,i=this.hoverVisibilities[this.helpModeActiveIndex];if(i){const r=i==null?void 0:i.refs,s=i==null?void 0:i.ref;this.$refs[r||s]||(this.helpModeActiveIndex+=1)}n||(this.helpModeActiveIndex=this.helpModeInitialIndex),n&&this.helpModeActiveIndex>=t&&this.$emit("help-mode-last-item",!0),n&&!this.helpModeDialog?(this.inHelp=!0,this.hoverVisibilities.forEach(r=>{r.value=!0})):n&&this.helpModeDialog&&e>this.helpModeActiveIndex?this.helpModeActiveIndex>-1&&setTimeout(()=>{this.inHelp=!1,this.hoverVisibilities.forEach(r=>{r.value=!1}),this.showHelpText(this.helpModeActiveIndex,200)},300):(this.inHelp=!1,this.hoverVisibilities.forEach(r=>{r.value=!1}))},displayTooltipOfObjectsCallback:function(n,e,t,i,r){const s=this;return function(){s.$module.zincRenderer.removePostRenderCallbackFunction(s.$_regionTooltipCallback),s.$_regionTooltipCallback=void 0,s.displayTooltipOfObjects(n,e,t,i,r)}},liveUpdateTooltipPosition:function(){this.$module.selectedCenter&&(this.tData.x=this.$module.selectedScreenCoordinates.x,this.tData.y=this.$module.selectedScreenCoordinates.y)},displayTooltipOfObjects:function(n,e,t,i,r){if(e.length>0){let s=e[0].getClosestVertexDOMElementCoords(this.$module.scene);if(s)return s.inView?(n.includes("Search Results for")?this.tData.active=!1:this.tData.active=!0,this.tData.visible=!0,this.tData.label=n,this.tData.x=s.position.x,this.tData.y=s.position.y,this.tData.region=t,this.$_liveCoordinatesUpdated&&this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_liveCoordinatesUpdated),r&&(this.$module.setupLiveCoordinates(e),this.$_liveCoordinatesUpdated=this.$module.zincRenderer.addPostRenderCallbackFunction(this.liveUpdateTooltipPosition))):(this.hideRegionTooltip(),i&&(this.$module.scene.viewAll(),this.$_regionTooltipCallback&&this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_regionTooltipCallback),this.$_regionTooltipCallback=this.$module.zincRenderer.addPostRenderCallbackFunction(this.displayTooltipOfObjectsCallback(n,e,t,i,r)))),!0}return this.hideRegionTooltip(),!1},showRegionTooltipWithObjects:function(n,e,t,i,r){return n&&e&&e.length>0&&this.$module.scene?this.displayTooltipOfObjects(n,e,t,i,r):(this.hideRegionTooltip(),!1)},showRegionTooltip:function(n,e,t){if(n&&this.$module.scene){const i=this.$module.scene.getRootRegion(),s=Lo(i,[n],"",!0);let o;return s&&s.length>0&&(o=s[0].getRegion().getFullPath()),this.showRegionTooltipWithObjects(n,s,o,e,t)}return this.hideRegionTooltip(),!1},showRegionTooltipWithAnnotations:function(n,e,t){if(this.$module.scene){const i=Cx(this.$module.scene,n);if(i&&i.objects.length>0)if(this.annotationSidebar){this.tData.visible=!1;const s={featureId:(this.tData.region?this.tData.region+"/":"")+this.tData.label,resourceId:this.url,resource:this.url};this.$emit("annotation-open",{annotationEntry:s,createData:this.createData,confirmCreate:this.confirmCreate,cancelCreate:this.cancelCreate,confirmDelete:this.confirmDelete});return}else return this.showRegionTooltipWithObjects(i.label,i.objects,i.regionPath,e,t)}return this.hideRegionTooltip(),!1},changeViewingMode:function(n){if(this.$module){if(n&&(this.viewingMode=n),this.viewingMode==="Annotation"){let e=!1;this.userInformation&&(e=!0),this.userInformation=void 0,this.annotator.authenticate(this.userToken).then(t=>{t.name&&t.email&&t.canUpdate&&(this.userInformation=t,e||(Lx(this.annotator,this.userToken,this.url).then(i=>{i&&i.features&&Of(this.$module.scene,i.features)}),Lx(this.annotator,this.userToken,encodeURIComponent(this.url)).then(i=>{i&&i.features&&Of(this.$module.scene,i.features)})))})}else this.viewingMode==="Exploration"&&(this.activeDrawTool=void 0,this.activeDrawMode=void 0,this.createData.shape="");this.viewingMode==="Exploration"||this.viewingMode==="Annotation"&&this.createData.shape===""?this.$module.selectObjectOnPick=!0:this.$module.selectObjectOnPick=!1,this.cancelCreate()}},hideRegionTooltip:function(){this.$_liveCoordinatesUpdated&&(this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_liveCoordinatesUpdated),this.$module.setupLiveCoordinates(void 0)),this.tData.active=!1,this.tData.visible=!1,this.tData.region=void 0},setMarkerModeForObjectsWithName:function(n,e,t){if(n&&this.$module.scene){let i=e;typeof e=="number"&&(i={number:e,imgURL:void 0});const r=this.$module.scene.getRootRegion();Lo(r,[n],"",!0).forEach(l=>l.setMarkerMode(t,i))}},setMarkerModeWithAnnotations:function(n,e){if(this.$module.scene){const t=Cx(this.$module.scene,n);t&&t.objects.length>0&&t.objects.forEach(i=>i.setMarkerMode(e))}},showHelpText:function(n,e=500){this.inHelp||(clearTimeout(this.helpTextWait[n]),this.helpTextWait[n]=setTimeout(()=>{this.hoverVisibilities[n].value=!0,this.$emit("shown-tooltip")},e))},hideHelpText:function(n,e=500){this.inHelp||(clearTimeout(this.helpTextWait[n]),this.helpTextWait[n]=setTimeout(()=>{this.hoverVisibilities[n].value=!1},e))},search:function(n,e){if(this.$_searchIndex){if(n===void 0||n===""||Array.isArray(n)&&n.length===0)return this.objectSelected([],!0),!1;{const t=this.$_searchIndex.searchAndProcessResult(n),i=t.zincObjects;if(i.length>0){if(this.objectSelected(i,!0),e)for(let r=0;r<i.length;r++)i[r]&&i[r].groupName&&this.showRegionTooltipWithObjects(t.label,i,t.regionPath,!0,!0);return!0}else this.objectSelected([],!0)}}return!1},fetchSuggestions:function(n){return this.$_searchIndex===void 0?[]:this.$_searchIndex.auto_suggest(n)},updateMinimapScissor:function(){Object.keys(this.minimapSettings).forEach(n=>{this.$module.scene.minimapScissor[n]=this.minimapSettings[n]}),this.$module.scene.minimapScissor.updateRequired=!0},updateSettingsfromScene:function(){this.currentSpeed=1,this.$module.setPlayRate(this.defaultRate),this.orginalDuration=this.$module.scene.getMetadataTag("OriginalDuration"),this.animateDuration=this.$module.scene.getMetadataTag("Duration");let n=this.$module.scene.getMetadataTag("TimeStamps");this.timeStamps={};for(const e in n)this.timeStamps[n[e]]=e;this.timeMax=this.$module.scene.getDuration()},setURLFinishCallback:function(n){return()=>{if(n){if(n.viewport)this.$module.scene.getZincCameraControls().setCurrentCameraSettings(n.viewport);else if(n.viewURL&&n.viewURL!==""){const i=new URL(n.viewURL,this.url);this.$module.scene.loadViewURL(i)}else n.region&&n.region!==""&&this.viewRegion(n.region);n.visibility&&this.$nextTick(()=>{this.$refs.scaffoldTreeControls.setState(n.visibility)})}this.localAnnotationsList.length=0,this.updateSettingsfromScene(),this.$module.updateTime(.01),this.$module.updateTime(0),this.$module.unsetFinishDownloadCallback(),this.addRegionsToSearchIndex(),this.$emit("on-ready"),this.setMarkers(),this._boundingBoxGeo=this.$module.scene.addBoundingBoxPrimitive("_helper","boundingBox",4251856,.15),this._slides=this.$module.scene.addSlicesPrimitive("_helper",["x-plane","y-plane","z-plane"],[16733525,5635925,5592575],.5);const{centre:e,size:t}=this.$module.getCentreAndSize();this.boundingDims.centre=e,this.boundingDims.size=t,this.isReady=!0}},getState:function(){let n={format:this.fileFormat,url:this._currentURL,viewport:void 0,visibility:void 0};if(this.$refs.scaffoldTreeControls&&(n.visibility=this.$refs.scaffoldTreeControls.getState()),this.$module.scene){let e=this.$module.scene.getZincCameraControls();n.viewport=e.getCurrentViewport()}return n},setState:function(n){n&&(n.url&&n.url!==this._currentURL?this.setURLAndState(n.url,{fileFormat:n.fileFormat,viewport:n.viewport,visibility:n.visibility}):(n.viewport||n.visibility)&&(this.isReady&&this.$module.scene?(n.viewport&&this.$module.scene.getZincCameraControls().setCurrentCameraSettings(n.viewport),n.visibility&&this.$refs.scaffoldTreeControls.setState(n.visibility)):this.$module.setFinishDownloadCallback(this.setURLFinishCallback({viewport:n.viewport,visibility:n.visibility}))))},exportGLTF:function(n){return this.$module.scene.exportGLTF(n)},getLocalAnnotations:function(){return[...this.localAnnotationsList]},importLocalAnnotations:function(n){if(this.enableLocalAnnotations){n.forEach(t=>{const i=t.group,r=t.region;let s=r.slice(-1)==="/"?r:r+"/";const o=s.slice(0,-1);t.region=o,s=s+i;const l=s;t.item.id=l,t.feature.id=l});const e=n.map(t=>t.feature);Of(this.$module.scene,e),n.forEach(t=>{this.localAnnotationsList.push({...t})})}},setURLAndState:function(n,e){if(n!=this._currentURL){e&&e.format&&(this.fileFormat=e.format);let t=e&&e.viewport?e.viewport:void 0,i=e&&e.visibility?e.visibility:void 0;this._currentURL=n,this.$refs.scaffoldTreeControls&&this.$refs.scaffoldTreeControls.clear(),this.loading=!0,this.timeVarying=!1,this.isReady=!1,this.$_searchIndex.removeAll(),this.hideRegionTooltip(),this.$module.setFinishDownloadCallback(this.setURLFinishCallback({viewport:t,region:this.region,viewURL:this.viewURL,visibility:i})),this.fileFormat==="gltf"?this.$module.loadGLTFFromURL(n,"scene",!0):this.$module.loadOrgansFromURL(n,void 0,void 0,"scene",void 0,!0),this.$module&&this.$module.scene&&(this.$module.scene.displayMarkers=this.displayMarkers,this.$module.scene.forcePickableObjectsUpdate=!0,this.$module.scene.displayMinimap=this.displayMinimap,this.updateMinimapScissor())}},setURL:function(n){this.setURLAndState(n,void 0)},drawerToggled:function(n){this.drawerOpen=n,this.adjustLayout()},adjustLayout:function(){if(this.$refs.scaffoldContainer){let n=this.$refs.scaffoldContainer.clientWidth;this.minimisedSlider=n<812,this.minimisedSlider?this.sliderPosition=this.drawerOpen?"right":"left":this.sliderPosition=""}},toggleRendering:function(n){this.$module.zincRenderer&&(n?this.$module.zincRenderer.animate():this.$module.zincRenderer.stopAnimate())},forceResize:function(){this.$module.zincRenderer&&this.$module.zincRenderer.onWindowResize()},syncControlCallback:function(){const n=this.$module.NDCCameraControl.getPanZoom();this.tData.visible&&this.showRegionTooltip(this.tData.label,!0,!0),this.$emit("scaffold-navigated",n)},toggleSyncControl:function(n,e){this.$module.toggleSyncControl(n,e),this.$module.setSyncControlCallback(this.syncControlCallback)},setMarkers:function(){for(const[n,e]of Object.entries(this.markerLabels))this.setMarkerModeForObjectsWithName(n,e,"on")}}},Qf=n=>(a.pushScopeId("data-v-05fa8c81"),n=n(),a.popScopeId(),n),pV={ref:"scaffoldContainer",class:"scaffold-container","element-loading-text":"Loading...","element-loading-background":"rgba(0, 0, 0, 0.3)"},mV=Qf(()=>a.createElementVNode("span",{class:"message-text"},"Beta",-1)),gV=Qf(()=>a.createElementVNode("span",{class:"message-text"},"What's new?",-1)),yV={class:"primitive-controls-box"},vV={class:"animation-data"},bV={class:"purple"},xV={class:"animation-data"},wV={class:"purple"},MV={class:"animation-data"},SV={class:"bottom-right-control"},_V=Qf(()=>a.createElementVNode("div",null,[a.createTextVNode(" Fit to "),a.createElementVNode("br"),a.createTextVNode(" window ")],-1)),TV={style:{"margin-bottom":"2px"}},EV={key:0,class:"viewing-mode-title"},CV=["onClick"],AV=["onClick"];function LV(n,e,t,i,r,s){const o=a.resolveComponent("map-svg-sprite-color"),l=jx,u=a.resolveComponent("DrawToolbar"),c=lm,f=yt,h=Pl,m=Bx,y=Dx,p=a.resolveComponent("map-svg-icon"),d=Ln,b=Qn,v=jg,g=Ls,M=As,_=Wg,E=Cs,S=pd;return a.withDirectives((a.openBlock(),a.createElementBlock("div",pV,[a.createVNode(o),a.createVNode(l,{createData:n.createData,label:n.tData.label,region:n.tData.region,visible:n.tData.visible,x:n.tData.x,y:n.tData.y,annotationDisplay:s.annotationDisplay,onConfirmCreate:e[0]||(e[0]=w=>s.confirmCreate(w)),onCancelCreate:e[1]||(e[1]=w=>s.cancelCreate()),onConfirmDelete:e[2]||(e[2]=w=>s.confirmDelete()),onTooltipHide:e[3]||(e[3]=w=>s.onTooltipHide())},null,8,["createData","label","region","visible","x","y","annotationDisplay"]),a.createElementVNode("div",{id:"organsDisplayArea",ref:"display",tabindex:"-1",style:{height:"100%",width:"100%"},onKeydown:e[4]||(e[4]=a.withKeys((...w)=>s.backgroundChangeCallback&&s.backgroundChangeCallback(...w),["66"]))},null,544),a.withDirectives(a.createElementVNode("div",null,[n.viewingMode==="Annotation"&&(n.userInformation||t.enableLocalAnnotations)?(a.openBlock(),a.createBlock(u,{key:0,toolbarOptions:n.toolbarOptions,activeDrawTool:n.activeDrawTool,activeDrawMode:n.activeDrawMode,hoverVisibilities:n.hoverVisibilities,onClickToolbar:s.toggleDrawing,onShowTooltip:s.showHelpText,onHideTooltip:s.hideHelpText,ref:"toolbarPopover"},null,8,["toolbarOptions","activeDrawTool","activeDrawMode","hoverVisibilities","onClickToolbar","onShowTooltip","onHideTooltip"])):a.createCommentVNode("",!0),t.displayWarning?(a.openBlock(),a.createBlock(h,{key:1,ref:"warningPopover",visible:n.hoverVisibilities[7].value,content:t.warningMessage,placement:"right",width:"max-content",teleported:!1,"popper-class":"scaffold-popper message-popper right-popper non-selectable"},{reference:a.withCtx(()=>[t.displayWarning?(a.openBlock(),a.createElementBlock("div",{key:0,class:"message-icon warning-icon",onMouseover:e[5]||(e[5]=w=>s.showHelpText(7)),onMouseout:e[6]||(e[6]=w=>s.hideHelpText(7))},[a.createVNode(f,null,{default:a.withCtx(()=>[a.createVNode(c)]),_:1}),mV],32)):a.createCommentVNode("",!0)]),_:1},8,["visible","content"])):a.createCommentVNode("",!0),t.displayLatestChanges?(a.openBlock(),a.createBlock(h,{key:2,visible:n.hoverVisibilities[8].value,content:t.latestChangesMessage,placement:"right",teleported:!1,trigger:"manual","popper-class":"scaffold-popper message-popper right-popper non-selectable",ref:"whatsNewPopover"},{reference:a.withCtx(()=>[t.displayLatestChanges&&t.latestChangesMessage?(a.openBlock(),a.createElementBlock("div",{key:0,class:"el-icon-warning message-icon latest-changesicon",onMouseover:e[7]||(e[7]=w=>s.showHelpText(8)),onMouseout:e[8]||(e[8]=w=>s.hideHelpText(8))},[a.createVNode(f,null,{default:a.withCtx(()=>[a.createVNode(c)]),_:1}),gV],32)):a.createCommentVNode("",!0)]),_:1},8,["visible","content"])):a.createCommentVNode("",!0),a.createVNode(h,{visible:n.hoverVisibilities[6].value,content:"Change region visibility",placement:"right",width:"max-content",teleported:!1,trigger:"manual","popper-class":"scaffold-popper right-popper non-selectable",ref:"regionVisibilityPopover"},{reference:a.withCtx(()=>[a.createVNode(m,{ref:"scaffoldTreeControls",isReady:n.isReady,"show-colour-picker":t.showColourPicker,onObjectSelected:s.objectSelected,onObjectHovered:s.objectHovered,onDrawerToggled:s.drawerToggled},null,8,["isReady","show-colour-picker","onObjectSelected","onObjectHovered","onDrawerToggled"])]),_:1},8,["visible"]),a.createElementVNode("div",yV,[a.createVNode(y,{ref:"primitiveControls",createData:n.createData,onPrimitivesUpdated:s.primitivesUpdated},null,8,["createData","onPrimitivesUpdated"])]),n.timeVarying?(a.openBlock(),a.createBlock(h,{key:3,ref:"sliderPopover",width:"max-content",visible:n.hoverVisibilities[5].value,content:"Move the slider to animate the region",placement:"top",teleported:!1,trigger:"manual","popper-class":"scaffold-popper top-popper non-selectable"},{reference:a.withCtx(()=>[n.timeVarying?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["time-slider-container",[n.minimisedSlider?"minimised":"",n.sliderPosition]])},[a.createVNode(_,{type:"card"},{default:a.withCtx(()=>[a.createVNode(v,{label:"Animate scaffold"},{default:a.withCtx(()=>[a.createVNode(b,{class:"tab-content"},{default:a.withCtx(()=>[n.isPlaying?(a.openBlock(),a.createBlock(p,{key:0,icon:"pause",class:"icon-button video-button",onClick:e[9]||(e[9]=w=>s.play(!1))})):(a.openBlock(),a.createBlock(p,{key:1,icon:"play",class:"video-button icon-button",onClick:e[10]||(e[10]=w=>s.play(!0))})),a.createVNode(d,{min:0,max:n.timeMax,"model-value":n.currentTime/100*n.timeMax,step:.1,"tooltip-class":"time-slider-tooltip",class:"slider","format-tooltip":s.formatTooltip,marks:n.timeStamps,onInput:e[11]||(e[11]=w=>s.timeChange(w))},null,8,["max","model-value","format-tooltip","marks"])]),_:1})]),_:1}),a.createVNode(v,{label:"Animation data"},{default:a.withCtx(()=>[a.createVNode(b,{class:"tab-content"},{default:a.withCtx(()=>[a.createElementVNode("div",vV,[a.createTextVNode(" Original duration: "),a.createElementVNode("div",bV,a.toDisplayString(n.orginalDuration),1)]),a.createElementVNode("div",xV,[a.createTextVNode(" Animation duration: "),a.createElementVNode("div",wV,a.toDisplayString(n.animateDuration),1)]),a.createElementVNode("div",MV,[a.createTextVNode(" Playback speed "),a.createVNode(M,{teleported:!0,"model-value":n.currentSpeed,placeholder:"Select",class:"scaffold-select-box speed","popper-class":"scaffold_viewer_dropdown",onChange:e[12]||(e[12]=w=>s.speedChanged(w))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.playSpeed,w=>(a.openBlock(),a.createBlock(g,{key:w.value,label:w.label,value:w.value},null,8,["label","value"]))),128))]),_:1},8,["model-value"])])]),_:1})]),_:1})]),_:1})],2)):a.createCommentVNode("",!0)]),_:1},8,["visible"])):a.createCommentVNode("",!0),a.createElementVNode("div",SV,[a.createVNode(h,{visible:n.hoverVisibilities[0].value,content:"Zoom in",width:"max-content",placement:"left",teleported:!1,trigger:"manual","popper-class":"scaffold-popper left-popper non-selectable",ref:"zoomInPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{icon:"zoomIn",class:"icon-button zoomIn",onClick:e[13]||(e[13]=w=>s.zoomIn()),onMouseover:e[14]||(e[14]=w=>s.showHelpText(0)),onMouseout:e[15]||(e[15]=w=>s.hideHelpText(0))})]),_:1},8,["visible"]),a.createVNode(h,{visible:n.hoverVisibilities[1].value,content:"Zoom out",placement:"top-end",width:"max-content",teleported:!1,trigger:"manual","popper-class":"scaffold-popper popper-zoomout non-selectable",ref:"zoomOutPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{icon:"zoomOut",class:"icon-button zoomOut",onClick:e[16]||(e[16]=w=>s.zoomOut()),onMouseover:e[17]||(e[17]=w=>s.showHelpText(1)),onMouseout:e[18]||(e[18]=w=>s.hideHelpText(1))})]),_:1},8,["visible"]),a.createVNode(h,{visible:n.hoverVisibilities[2].value,placement:"top",teleported:!1,trigger:"manual",width:"max-content","popper-class":"scaffold-popper non-selectable",ref:"zoomFitPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{icon:"fitWindow",class:"icon-button fitWindow",onClick:e[19]||(e[19]=w=>s.fitWindow()),onMouseover:e[20]||(e[20]=w=>s.showHelpText(2)),onMouseout:e[21]||(e[21]=w=>s.hideHelpText(2))})]),default:a.withCtx(()=>[_V]),_:1},8,["visible"])]),n.openMapRef?(a.openBlock(),a.createBlock(h,{key:4,ref:"open-map-popover","virtual-ref":n.openMapRef,placement:"top-start",width:"128",teleported:!1,trigger:"click","popper-class":"open-map-popper","virtual-triggering":""},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.openMapOptions,w=>(a.openBlock(),a.createBlock(b,{key:w.key},{default:a.withCtx(()=>[a.createVNode(E,{type:"primary",plain:"",onClick:T=>n.$emit("open-map",w.key)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(w.display),1)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1},8,["virtual-ref"])):a.createCommentVNode("",!0),a.createVNode(h,{ref:"backgroundPopover","virtual-ref":n.backgroundIconRef,placement:"top-start",width:"128",teleported:!1,trigger:"click","popper-class":"background-popper non-selectable h-auto","virtual-triggering":""},{default:a.withCtx(()=>[a.createElementVNode("div",null,[a.createVNode(b,{class:"backgroundText"},{default:a.withCtx(()=>[a.createTextVNode("Viewing Mode")]),_:1}),a.createVNode(b,{class:"backgroundControl"},{default:a.withCtx(()=>[a.createElementVNode("div",TV,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.viewingModes,(w,T,C)=>(a.openBlock(),a.createElementBlock(a.Fragment,{key:T},[T===n.viewingMode?(a.openBlock(),a.createElementBlock("span",EV,[a.createElementVNode("b",null,a.toDisplayString(T),1)])):(a.openBlock(),a.createElementBlock("span",{key:1,class:"viewing-mode-unselected",onClick:R=>s.changeViewingMode(T)},a.toDisplayString(T),9,CV))],64))),128))]),a.createVNode(b,{class:"viewing-mode-description"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(n.viewingModes[n.viewingMode]),1)]),_:1})]),_:1}),a.createVNode(b,{class:"backgroundSpacer"}),a.createVNode(b,{class:"backgroundText"},{default:a.withCtx(()=>[a.createTextVNode(" Change background ")]),_:1}),a.createVNode(b,{class:"backgroundChooser"},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.availableBackground,w=>(a.openBlock(),a.createElementBlock("div",{key:w,class:a.normalizeClass(["backgroundChoice",w,w==n.currentBackground?"active":""]),onClick:T=>s.backgroundChangeCallback(w)},null,10,AV))),128))]),_:1})])]),_:1},8,["virtual-ref"]),a.createElementVNode("div",{class:a.normalizeClass(["settings-group",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createVNode(b,null,{default:a.withCtx(()=>[a.createVNode(h,{visible:n.hoverVisibilities[3].value,content:"Open new map",placement:"right",teleported:!1,trigger:"manual",width:"max-content","popper-class":"scaffold-popper right-popper non-selectable",ref:"openMapPopover"},{reference:a.withCtx(()=>[t.enableOpenMapUI&&t.openMapOptions.length>0?(a.openBlock(),a.createBlock(p,{key:0,ref:"openMapRef",icon:"openMap",class:"icon-button open-map-button",onMouseover:e[22]||(e[22]=w=>s.showHelpText(3)),onMouseout:e[23]||(e[23]=w=>s.hideHelpText(3))},null,512)):a.createCommentVNode("",!0)]),_:1},8,["visible"])]),_:1}),a.createVNode(b,null,{default:a.withCtx(()=>[a.createVNode(h,{visible:n.hoverVisibilities[4].value,content:"Change background color",placement:"right",width:"max-content",teleported:!1,trigger:"manual","popper-class":"scaffold-popper right-popper non-selectable",ref:"settingsPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{ref:"backgroundIconRef",icon:"changeBckgd",class:"icon-button",onMouseover:e[24]||(e[24]=w=>s.showHelpText(4)),onMouseout:e[25]||(e[25]=w=>s.hideHelpText(4))},null,512)]),_:1},8,["visible"])]),_:1})],2)],512),[[a.vShow,t.displayUI&&!n.isTransitioning]])])),[[S,n.loading]])}const RV=ki(fV,[["render",LV],["__scopeId","data-v-05fa8c81"]]);Zt.ScaffoldVuer=RV,Object.defineProperty(Zt,Symbol.toStringTag,{value:"Module"})});
3458
+ This will fail in production.`);l=Ha,l._s.has(i)||(s?Ff(i,e,r,l):Gx(i,r,l),process.env.NODE_ENV!=="production"&&(o._pinia=l));const f=l._s.get(i);if(process.env.NODE_ENV!=="production"&&u){const h="__hot:"+i,m=s?Ff(h,e,r,l,!0):Gx(h,Pn({},r),l,!0);u._hotUpdate(m),delete l.state.value[h],l._s.delete(h)}if(process.env.NODE_ENV!=="production"&&ja){const h=a.getCurrentInstance();if(h&&h.proxy&&!u){const m=h.proxy,y="_pStores"in m?m._pStores:m._pStores={};y[i]=f}}return f}return o.$id=i,o}function Hx(n,e){return Array.isArray(e)?e.reduce((t,i)=>(t[i]=function(){return n(this.$pinia)[i]},t),{}):Object.keys(e).reduce((t,i)=>(t[i]=function(){const r=n(this.$pinia),s=e[i];return typeof s=="function"?s.call(this,r):r[s]},t),{})}const Wx=DF("main",{state:()=>({userProfile:{token:""}}),getters:{userToken(n){return n.userProfile.token}},actions:{setUserToken(n){this.userProfile.token=n}}}),BF={name:"ScaffoldTooltip",components:{Col:Fn,CreateTooltipContent:Ja.CreateTooltipContent,ElIconDelete:cl,Icon:yt,Popover:Pl,Row:Qn,Tooltip:Ja.Tooltip},props:{createData:{type:Object,default:{toBeConfirmed:!1,points:[],shape:"",x:0,y:0}},label:{type:String,default:""},annotationDisplay:{type:Boolean,default:!1},region:{type:String,default:""},visible:{type:Boolean,default:!1},x:{type:Number,default:200},y:{type:Number,default:200}},inject:["scaffoldUrl"],provide(){return{userApiKey:this.userToken}},data:function(){return{display:!1,annotationEntry:{},ElIconDelete:a.shallowRef(cl)}},computed:{...Hx(Wx,["userToken"]),position:function(){let n=40;return this.region&&(n=55),{left:this.x-40+"px",top:this.y-n+"px"}}},methods:{checkForDisplay:function(){if(this.visible&&this.label&&this.label!==""){if(this.display=!0,this.annotationDisplay){const n=this.region?this.region+"/":"";this.annotationEntry={featureId:n+this.label,resourceId:this.scaffoldUrl,resource:this.scaffoldUrl}}}else this.display=!1,this.annotationEntry={}},hideTriggered:function(){this.$emit("tooltip-hide")}},watch:{label:{handler:function(){this.checkForDisplay()},immediate:!0},visible:{handler:function(){this.checkForDisplay()},immediate:!0},annotationDisplay:{handler:function(){this.checkForDisplay()},immediate:!0}}},FF={class:"tooltip-text"},VF={key:0,class:"tooltip-text"},kF={key:1,class:"delete-container"};function zF(n,e,t,i,r,s){const o=a.resolveComponent("CreateTooltipContent"),l=a.resolveComponent("Tooltip"),u=Fn,c=Cs,f=Qn,h=Pl;return a.openBlock(),a.createElementBlock("div",{style:a.normalizeStyle(s.position),class:"region-tooltip"},[a.createVNode(h,{ref:"tooltip",visible:t.visible,placement:"top","show-arrow":!1,teleported:!1,trigger:"manual","popper-class":"tooltip-popper non-selectable","virtual-triggering":"",onHide:s.hideTriggered},{default:a.withCtx(()=>[a.createElementVNode("div",FF,a.toDisplayString(t.label),1),t.region?(a.openBlock(),a.createElementBlock("div",VF,"Region: "+a.toDisplayString(t.region),1)):a.createCommentVNode("",!0),a.withDirectives(a.createVNode(o,{createData:t.createData,onConfirmCreate:e[0]||(e[0]=m=>n.$emit("confirm-create",m)),onCancelCreate:e[1]||(e[1]=m=>n.$emit("cancel-create"))},null,8,["createData"]),[[a.vShow,t.createData.toBeConfirmed]]),a.withDirectives(a.createVNode(l,{class:"p-tooltip",ref:"annotationTooltip",annotationDisplay:!0,annotationEntry:n.annotationEntry},null,8,["annotationEntry"]),[[a.vShow,t.annotationDisplay&&!t.createData.toBeConfirmed]]),t.createData.toBeDeleted?(a.openBlock(),a.createElementBlock("div",kF,[a.createVNode(f,null,{default:a.withCtx(()=>[a.createVNode(u,{span:10},{default:a.withCtx(()=>[a.createTextVNode("Delete this feature?")]),_:1}),a.createVNode(u,{span:7},{default:a.withCtx(()=>[a.createVNode(c,{class:"delete-button",icon:n.ElIconDelete,onClick:e[2]||(e[2]=m=>n.$emit("confirm-delete"))},{default:a.withCtx(()=>[a.createTextVNode(" Delete ")]),_:1},8,["icon"])]),_:1}),a.createVNode(u,{span:6},{default:a.withCtx(()=>[a.createVNode(c,{class:"delete-button",onClick:e[3]||(e[3]=m=>n.$emit("cancel-create"))},{default:a.withCtx(()=>[a.createTextVNode(" Dismiss ")]),_:1})]),_:1})]),_:1})])):a.createCommentVNode("",!0)]),_:1},8,["visible","onHide"])],4)}const jx=ki(BF,[["render",zF],["__scopeId","data-v-e665391a"]]);/*! js-cookie v3.0.5 | MIT */function nu(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)n[i]=t[i]}return n}var UF={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Vf(n,e){function t(r,s,o){if(!(typeof document>"u")){o=nu({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var l="";for(var u in o)o[u]&&(l+="; "+u,o[u]!==!0&&(l+="="+o[u].split(";")[0]));return document.cookie=r+"="+n.write(s,r)+l}}function i(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var s=document.cookie?document.cookie.split("; "):[],o={},l=0;l<s.length;l++){var u=s[l].split("="),c=u.slice(1).join("=");try{var f=decodeURIComponent(u[0]);if(o[f]=n.read(c,f),r===f)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:i,remove:function(r,s){t(r,"",nu({},s,{expires:-1}))},withAttributes:function(r){return Vf(this.converter,nu({},this.attributes,r))},withConverter:function(r){return Vf(nu({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(n)}})}var kf=Vf(UF,{path:"/"}),ci=function(n,e,t,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(n,t):r?r.value=t:e.set(n,t),t},St=function(n,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!i:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(n):i?i.value:e.get(n)},zi,$a,ui,rn,_r;const GF=1e4;class HF{constructor(e){zi.add(this),$a.set(this,void 0),ui.set(this,null),rn.set(this,null),e.slice(-1)==="/"?ci(this,$a,e.slice(0,-1),"f"):ci(this,$a,e,"f")}get currentUser(){return St(this,ui,"f")}get currentError(){return St(this,rn,"f")}async authenticate(e){ci(this,rn,null,"f"),ci(this,ui,null,"f");const t=await St(this,zi,"m",_r).call(this,e,"authenticate");return"error"in t?(kf.remove("annotation-key"),Promise.resolve(St(this,rn,"f"))):(kf.set("annotation-key",t.session,{secure:!0,expires:1}),ci(this,ui,t.data,"f"),Promise.resolve(St(this,ui,"f")))}async unauthenticate(e){ci(this,rn,null,"f"),ci(this,ui,null,"f");const t=await St(this,zi,"m",_r).call(this,e,"unauthenticate");return"success"in t?Promise.resolve(t):Promise.resolve(St(this,rn,"f"))}async annotatedItemIds(e,t,i,r){const s={resource:t};i!==void 0&&(s.user=i),r!==void 0&&(s.participated=r);const o=await St(this,zi,"m",_r).call(this,e,"items/","GET",s);return"error"in o?Promise.resolve(St(this,rn,"f")):Promise.resolve(o)}async drawnFeatures(e,t,i){const r={resource:t};i!==void 0&&(r.items=i);const s=await St(this,zi,"m",_r).call(this,e,"features/","GET",r);return"error"in s?Promise.resolve(St(this,rn,"f")):Promise.resolve(s)}async itemAnnotations(e,t,i){const r=await St(this,zi,"m",_r).call(this,e,"annotations/","GET",{resource:t,item:i});return"error"in r?Promise.resolve(St(this,rn,"f")):Promise.resolve(r)}async annotation(e,t){const i=await St(this,zi,"m",_r).call(this,e,"annotation/","GET",{annotation:t});return"error"in i?Promise.resolve(St(this,rn,"f")):Promise.resolve(i)}async addAnnotation(e,t){if(St(this,ui,"f")&&St(this,ui,"f").canUpdate){const i=Object.assign({creator:St(this,ui,"f"),created:new Date().toISOString()},t),r=await St(this,zi,"m",_r).call(this,e,"annotation/","POST",{data:i});if(!("error"in r))return Promise.resolve(r);ci(this,rn,r,"f")}else ci(this,rn,{error:"user cannot add annotation"},"f");return Promise.resolve(St(this,rn,"f"))}}$a=new WeakMap,ui=new WeakMap,rn=new WeakMap,zi=new WeakSet,_r=async function(e,t,i="GET",r={}){let s=!0;const o=new AbortController;setTimeout(()=>{s&&(console.log("Annotation server timeout..."),o.abort())},GF);const l={method:i,signal:o.signal};let u=`${St(this,$a,"f")}/${t}`;const c=kf.get("annotation-key")||"";if(i==="GET"){const h=[];for(const[m,y]of Object.entries(r))h.push(`${m}=${encodeURIComponent(JSON.stringify(y))}`);h.push(`key=${encodeURIComponent(e)}`),h.push(`session=${encodeURIComponent(c)}`),u+="?"+h.join("&"),l.headers={Accept:"application/json; charset=utf-8","Cache-Control":"no-store"}}else if(i==="POST"){const h=Object.assign({key:e,session:c},r);l.body=JSON.stringify(h),l.headers={Accept:"application/json; charset=utf-8","Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}}const f=await fetch(u,l);return s=!1,f.ok?Promise.resolve(await f.json()):(ci(this,rn,{error:`${f.status} ${f.statusText}`},"f"),Promise.resolve(St(this,rn,"f")))};const Za={ALL:0,SELECTED:1,HIGHLIGHTED:2,MOVE:3},WF=function(n,e,t){this.eventType=n,this.identifiers=e,this.zincObjects=t},jF=function(n,e,t){this.targetedID=[];const i=n,r=e;this.targetEventType=t;const s=this;t===void 0&&(this.targetEventType=Za.ALL),this.getEventType=function(){return t},this.notify=function(o,l,u,c){if(o!==i&&(s.targetEventType===Za.ALL||s.targetEventType===l)){const f=new WF(l,u,c);r(f)}}},$F=function(){const n=[];this.publish=function(e,t,i,r){for(let s=0;s<n.length;s++)n[s].notify(e,t,i,r)},this.subscribe=function(e,t,i){if(typeof t=="function"){const r=new jF(e,t,i);return n.push(r),r}},this.unsubscribe=function(e){for(let t=0;t<n.length;t++)if(e===n[t]){n.splice(t,1);return}}},$x={isWebGLAvailable:function(){try{var n=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(n.getContext("webgl")||n.getContext("experimental-webgl")))}catch{return!1}},isWebGL2Available:function(){try{var n=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&n.getContext("webgl2"))}catch{return!1}},getWebGLErrorMessage:function(){return this.getErrorMessage(1)},getWebGL2ErrorMessage:function(){return this.getErrorMessage(2)},getErrorMessage:function(n){var e={1:"WebGL",2:"WebGL 2"},t={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext},i='This module requires <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#008">$1</a> support but your $0 does not seem to support it.',r=document.createElement("div");return r.id="webglmessage",r.style.fontFamily="monospace",r.style.fontSize="20px",r.style.fontWeight="normal",r.style.textAlign="center",r.style.background="#fff",r.style.color="#000",r.style.padding="1.5em",r.style.width="400px",r.style.margin="5em auto 0",t[n]?i=i.replace("$0","graphics card"):i=i.replace("$0","browser"),i=i.replace("$1",e[n]),r.innerHTML=i,r}},zf={ALL:0,DESTROYED:1,NAME_CHANGED:2,SETTINGS_CHANGED:3},_n=function(){this.typeName="Base Module",this.instanceName="default",this.onChangedCallbacks=[],this.eventNotifiers=[]};_n.prototype.setName=function(n){if(n&&this.instanceName!==n){this.instanceName=n;const e=this.onChangedCallbacks.slice();for(let t=0;t<e.length;t++)e[t](this,zf.NAME_CHANGED)}},_n.prototype.settingsChanged=function(){const n=this.onChangedCallbacks.slice();for(let e=0;e<n.length;e++)n[e](this,zf.SETTINGS_CHANGED)},_n.prototype.exportSettings=function(){const n={};return n.dialog=this.typeName,n.name=this.instanceName,n},_n.prototype.importSettings=function(n){return n.dialog==this.typeName?(this.setName(n.name),!0):!1},_n.prototype.publishChanges=function(n,e,t){for(let i=0;i<this.eventNotifiers.length;i++)this.eventNotifiers[i].publish(this,e,n,t)},_n.prototype.getName=function(){return this.instanceName},_n.prototype.destroy=function(){const n=this.onChangedCallbacks.slice();for(let e=0;e<n.length;e++)n[e](this,zf.DESTROYED);delete this},_n.prototype.addChangedCallback=function(n){this.onChangedCallbacks.includes(n)==!1&&this.onChangedCallbacks.push(n)},_n.prototype.removeChangedCallback=function(n){const e=this.onChangedCallbacks.indexOf(n);e>-1&&this.onChangedCallbacks.splice(e,1)},_n.prototype.addNotifier=function(n){this.eventNotifiers.push(n)};const iu=(n,e,t)=>{for(let i=0;i<n.length;i++)if(n[i]&&n[i].material&&n[i].material.emissive){let r=n[i].userData;r&&r.isZincObject?r.setEmissiveRGB(e):n[i].material&&n[i].material.emissive&&n[i].material.emissive.setRGB(...e),t&&n[i].material.depthFunc&&(n[i].material.depthFunc=Sr.THREE.LessEqualDepth),n[i].children.forEach(s=>{const o=s.userData;o&&o.isZincObject&&s.material&&s.material.emissive&&s.material.emissive.setRGB(...e)})}},ZF=function(){let n=[],e=[];this.highlightColour=[1,0,0],this.selectColour=[0,1,0],this.originalColour=[0,0,0];const t=[],i=[],r=this,s=function(u,c){if(u.length==0&&c.length==0)return!1;for(let f=0;f<u.length;f++){let h=!1;for(let m=0;m<c.length;m++)u[f]===c[m]&&(h=!0);if(!h)return!0}for(let f=0;f<c.length;f++){let h=!1;for(let m=0;m<u.length;m++)c[f]===u[m]&&(h=!0);if(!h)return!0}return!1},o=function(u,c){if(t.length=0,c.length==0)return u;for(let f=0;f<u.length;f++){let h=!1;for(let m=0;m<c.length;m++)u[f]===c[m]&&(h=!0);h||t.push(u[f])}return t};this.setHighlighted=function(u){const c=[...n];r.resetHighlighted();const f=o(u,e),h=l(f);return iu(h,r.highlightColour,!1),n=f,s(n,c)},this.setSelected=function(u){const c=[...e];r.resetHighlighted(),r.resetSelected();const f=l(u);return iu(f,r.selectColour,!1),e=u,s(e,c)};const l=function(u){i.length=0;for(let c=0;c<u.length;c++)u[c].material&&i.push(u[c]);return i};this.resetHighlighted=function(){const u=l(n);iu(u,r.originalColour,!0),n=[]},this.resetSelected=function(){const u=l(e);iu(u,r.originalColour,!0),e=[]},this.getSelected=function(){return e},this.reset=function(){r.resetSelected(),r.resetHighlighted()}},Uf=Kc.THREE,XF=function(){const n=document.createElement("div");let e;if(n.style.height="100%",$x.isWebGLAvailable())e=new Kc.Renderer(n,window),Kc.defaultMaterialColor=16777116,e.initialiseVisualisation(),e.playAnimation=!1;else{const t=$x.getWebGLErrorMessage();n.appendChild(t)}return{Zinc:Kc,renderer:e,container:n}},_t=function(){_n.call(this),this.scene=void 0,this.rendererContainer=void 0,this.displayArea=void 0,this.graphicsHighlight=new ZF,this.selectObjectOnPick=!0,this.zincRenderer=null,this.selectedScreenCoordinates=new Uf.Vector3,this.selectedCenter=void 0,this.liveUpdatesObjects=void 0,this.ignorePreviousSelected=!1};_t.prototype=Object.create(_n.prototype),_t.prototype.getIntersectedObject=function(n){if(n){const e=n.map(i=>{if(i&&i.object&&i.object.userData){if(i.object.userData.isMarker)return 1;if(i.object.name&&i.object.userData.isZincObject)return 2}return 0});let t=e.indexOf(1);return t=t>-1?t:e.indexOf(2),n[t]}},_t.prototype.getAnnotationsFromObjects=function(n){const e=[];for(var t=0;t<n.length;t++){const i=n[t].userData;let r;if(i){if(i.isGlyph||i.isGlyphset){let s=i;i.isGlyph&&(s=i.getGlyphset()),r=s.userData?s.userData.annotation:void 0,r&&r.data&&(n[t].name&&n[t].name!=""?r.data.id=n[t].name:r.data.id=s.groupName)}else r=i.userData?i.userData.annotation:void 0,r&&r.data&&(r.data.id=n[t].name);r&&(r.data.zincObject=i)}r&&e.push(r)}return e},_t.prototype.setHighlightedByObjects=function(n,e,t,i){const r=this.graphicsHighlight.setHighlighted(n),s=this.objectsToZincObjects(n);if(i){let o=Za.MOVE;r&&(o=Za.HIGHLIGHTED);const l=this.getAnnotationsFromObjects(n);l.length>0&&(l[0].coords=e,l[0].extraData=t),this.publishChanges(l,o,s)}return r},_t.prototype.setHighlightedByZincObjects=function(n,e,t,i){let r=[];return n&&n.forEach(s=>{s&&s.getMorph()&&r.push(s.getMorph())}),this.setHighlightedByObjects(r,e,t,i)},_t.prototype.setupLiveCoordinates=function(n){if(this.liveUpdatesObjects=n,n&&n.length>0){const e=this.scene.getBoundingBoxOfZincObjects(n);let t=new Uf.Vector3;e?(e.getCenter(t),this.selectedCenter==null?this.selectedCenter=t:this.selectedCenter.copy(t)):this.selectedCenter=void 0}else this.selectedCenter=void 0},_t.prototype.objectsToZincObjects=function(n){const e=[];for(let t=0;t<n.length;t++){let i=n[t].userData;if(i)if(i.isGlyph||i.isGlyphset){let r=i;i.isGlyph&&(r=i.getGlyphset()),e.push(r)}else e.push(i)}return e},_t.prototype.setSelectedByObjects=function(n,e,t,i){let r=!1;if(this.selectObjectOnPick?r=this.graphicsHighlight.setSelected(n):r=!0,r||this.ignorePreviousSelected){const s=this.objectsToZincObjects(n);if(this.selectObjectOnPick&&this.setupLiveCoordinates(s),i){const o=Za.SELECTED,l=this.getAnnotationsFromObjects(n);l.length>0&&(l[0].coords=e,l[0].extraData=t),this.publishChanges(l,o,s)}}return r},_t.prototype.setSelectedByZincObjects=function(n,e,t,i){let r=[];return n&&n.forEach(s=>{if(s){const o=s.getMorph();o&&r.push(o)}}),this.setSelectedByObjects(r,e,t,i)},_t.prototype.findObjectsByGroupName=function(n){return this.scene.findObjectsWithGroupName(n)},_t.prototype.setHighlightedByGroupName=function(n,e){const t=this.findObjectsByGroupName(n);return this.setHighlightedByObjects(t,void 0,{},e)},_t.prototype.setSelectedByGroupName=function(n,e){const t=this.findObjectsByGroupName(n);return this.setSelectedByObjects(t,void 0,{},e)},_t.prototype.changeBackgroundColour=function(n){const e=new Uf.Color(n);this.zincRenderer&&this.zincRenderer.getThreeJSRenderer().setClearColor(e,1)},_t.prototype.resetView=function(){this.zincRenderer&&this.zincRenderer.resetView()},_t.prototype.viewAll=function(){this.zincRenderer&&this.zincRenderer.viewAll()},_t.prototype.playAnimation=function(n){this.zincRenderer&&(this.zincRenderer.playAnimation=n)},_t.prototype.setPlayRate=function(n){this.zincRenderer&&this.zincRenderer.setPlayRate(n)},_t.prototype.getPlayRate=function(n){return this.zincRenderer?this.zincRenderer.getPlayRate():0},_t.prototype.initialiseRenderer=function(n){if(this.zincRenderer===void 0||this.rendererContainer===void 0){let e=XF();this.Zinc=e.Zinc,this.zincRenderer=e.renderer,this.rendererContainer=e.container}n&&(this.displayArea=n,this.displayArea.appendChild(this.rendererContainer),this.zincRenderer&&this.zincRenderer.animate())},_t.prototype.destroy=function(){this.zincRenderer&&(this.zincRenderer.dispose(),this.zincRenderer.getThreeJSRenderer().dispose(),this.zincRenderer=void 0),_n.prototype.destroy.call(this)};const YF=function(){this.type="anatomical",this.data=void 0,this.isAnnotation=!0},JF=function(){this.currentName="",this.currentSystem="",this.currentPart="",this.currentSpecies="",this.metaURL="",this.viewURL="",this.timeVarying=!1,this.currentTime=0},Zx=function(n){_t.call(this);const e=this;let t;this.sceneData=new JF;const i=new Array,r=new Array,s=new Array,o=new Array;let l;const u=n;this.NDCCameraControl=void 0,e.typeName="Organ Viewer",this.getSceneData=function(){return e.sceneData},this.updateTime=function(T){let C=6e3;e.scene&&(C=e.scene.getDuration());const R=T/100*C;e.sceneData.nerveMapIsActive||e.scene&&e.scene.setMorphsTime(R),e.sceneData.currentTime=T};const c=function(){let T=3e3;e.scene&&(T=e.scene.getDuration());const C=e.zincRenderer.getCurrentTime();for(let R=0;R<i.length;R++)i[R](C);!e.sceneData.nerveMapIsActive&&t&&t.setMorphsTime(C),e.sceneData.nerveMap&&e.sceneData.nerveMap.additionalReader&&e.sceneData.nerveMap.additionalReader.setTime(C/T),e.sceneData.currentTime=C/T*100};this.getCurrentTime=function(){return e.sceneData.currentTime},this.toggleSyncControl=(T,C)=>{let R=this.scene.getZincCameraControls();T?(R.resetView(),this.NDCCameraControl=R.enableSyncControl(),R.setRotationMode(C)):(R.disableSyncControl(),this.NDCCameraControl=void 0,R.setRotationMode("free"))},this.isSyncControl=()=>this.NDCCameraControl!==void 0,this.setSyncControlZoomToBox=T=>{this.NDCCameraControl&&this.NDCCameraControl.zoomToBox(T,2)},this.setSyncControlCallback=T=>{this.NDCCameraControl&&this.NDCCameraControl.setEventCallback(T)},this.setSyncControlCenterZoom=(T,C)=>{this.NDCCameraControl&&this.NDCCameraControl.setCenterZoom(T,C)};const f=function(){if(e.zincRenderer.playAnimation&&e.liveUpdatesObjects&&e.setupLiveCoordinates(e.liveUpdatesObjects),e.selectedCenter){const T=new Sr.THREE.Vector3;T.copy(e.selectedCenter);const C=e.scene.vectorToScreenXY(T);e.selectedScreenCoordinates.x=C.x,e.selectedScreenCoordinates.y=C.y}},h=function(){return function(){c()}},m=function(){return function(){f()}};this.addTimeChangedCallback=function(T){i.push(T)},this.setTexturePos=function(T){e.sceneData.nerveMap&&e.sceneData.nerveMap.additionalReader&&e.sceneData.nerveMap.additionalReader.setSliderPos(T)},this.addSceneChangedCallback=function(T){r.push(T)},this.addOrganPartAddedCallback=function(T){s.push(T)},this.addOrganPartRemovedCallback=function(T){o.push(T)},this.setFinishDownloadCallback=function(T){l=T},this.unsetFinishDownloadCallback=function(){l=void 0},this.getNamedObjectsToScreenCoordinates=function(T,C){const R=new Sr.THREE.Vector3;R.setFromMatrixPosition(obj.matrixWorld);const P=width/2,L=height/2;return R.project(C),R.x=R.x*P+P,R.y=-(R.y*L)+L,R};const y=function(T){let C,R;if(T!==void 0){let P=!1;T.object.userData&&T.object.userData.isMarker?(P=!0,R=T.object.userData.parent.getMorph()):R=T.object;try{R.userData.userData.annotation.data.lastActionOnMarker=P}finally{}if(R)if(R.name)C=R.name;else{const L=e.getAnnotationsFromObjects([R]);L&&L[0]&&(C=L[0].data.group)}}return{id:C,object:R}},p=function(){return function(T,C,R){var O;const P=e.getIntersectedObject(T),L=y(P),A={worldCoords:[P?P.point.x:0,P?P.point.y:0,P?P.point.z:0],intersected:P,intersects:T},I={x:C,y:R};if(L.id){A.threeID=(O=L.object)==null?void 0:O.id,L.object.userData.isGlyph?L.object.name?e.setSelectedByObjects([L.object],I,A,!0):e.setSelectedByZincObjects(L.object.userData.getGlyphset(),I,A,!0):e.setSelectedByObjects([L.object],I,A,!0);return}else e.setSelectedByObjects([],I,A,!0)}},d=function(){return function(T,C,R){var O;const P=e.getIntersectedObject(T),L=y(P),A={worldCoords:[P?P.point.x:0,P?P.point.y:0,P?P.point.z:0]},I={x:C,y:R};if(L.id){A.threeID=(O=L.object)==null?void 0:O.id,e.displayArea.style.cursor="pointer",e.setHighlightedByObjects([L.object],I,A,!0);return}else e.displayArea.style.cursor="auto",e.setHighlightedByObjects([],I,A,!0)}},b=function(T,C,R,P){if(P=="all"||P=="geometries"){const L=T.findGeometriesWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}if(P=="all"||P=="glyphsets"){const L=T.findGlyphsetsWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}if(P=="all"||P=="pointsets"){const L=T.findPointsetsWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}if(P=="all"||P=="lines"){const L=T.findLinesWithGroupName(C);for(let A=0;A<L.length;A++)L[A].setVisibility(R)}};this.changeGeometriesVisibility=function(T,C){b(e.scene,T,C,"geometries")},this.changeGlyphsetsVisibility=function(T,C){b(e.scene,T,C,"glyphsets")},this.changeLinesVisibility=function(T,C){b(e.scene,T,C,"lines")},this.changePointsetsVisibility=function(T,C){b(e.scene,T,C,"pointsets")},this.changeOrganPartsVisibility=function(T,C,R){let P="all";R!==void 0&&(P=R),b(e.scene,T,C,P)},this.changeOrganPartsVisibilityCallback=function(T){return function(C){e.changeOrganPartsVisibility(T,C)}},this.changeBackgroundColour=function(T){const C=new Sr.THREE.Color(T);e.zincRenderer&&e.zincRenderer.getThreeJSRenderer().setClearColor(C,1)};const v=function(T,C,R,P){for(let I=0;I<s.length;I++)s[I](P,e.scene.isTimeVarying());const L=new YF,A=P.region.getFullPath();L.data={species:e.sceneData.currentSpecies,system:T,part:C,group:P.groupName,region:A,uuid:P.uuid,lastActionOnMarker:!1},P.userData.annotation=L},g=function(T,C,R,P){for(let L=0;L<o.length;L++)o[L](P)},M=function(T,C,R){return function(P){v(T,C,R,P)}},_=function(T,C,R){return function(P){g(T,C,R,P)}},E=function(){return function(){e.settingsChanged(),e.sceneData.timeVarying=e.scene.isTimeVarying(),l&&l()}};this.updateFieldvisibility=function(T,C){for(let R=0;R<T.length;R++)if(C!=R){const P=T[R].PartName;e.changeOrganPartsVisibility(P,!1)}if(C>-1){const R=T[C].PartName;if(e.scene.findGeometriesWithGroupName(R).length>0||e.scene.findGlyphsetsWithGroupName(R).length>0)e.changeOrganPartsVisibility(R,!0);else{const P=getOrganDetails(T[C].SystemName,R);P!=null&&e.scene.loadMetadataURL(u.getOrgansDirectoryPrefix()+"/"+P.meta)}}},this.getAvailableSpecies=function(T,C,R){const P=new Array;P.push("none");const L=Object.keys(organsFileMap);for(index in L){const A=L[index];A!=T&&organsFileMap[A].hasOwnProperty(C)&&organsFileMap[A][C].hasOwnProperty(R)&&P.push(A)}return P},this.getCentreAndSize=function(){const T=new Sr.THREE.Vector3,C=this.scene.getBoundingBox();C.getCenter(T);const R=[T.x,T.y,T.z];C.getSize(T);const P=[T.x,T.y,T.z];return{centre:R,size:P}};const S=function(T,C,R,P){e.sceneData.nerveMapIsActive=!1,e.sceneData.nerveMap=void 0,e.sceneData.metaURL="",e.sceneData.viewURL="",e.sceneData.currentSpecies=T,e.sceneData.currentSystem=C,e.sceneData.currentPart=R,e.sceneData.currentTime=0,e.sceneData.timeVarying=!1;let L="";T&&(L=T+"/"),C&&(L=C+"/"),R&&(L=R),e.sceneData.currentName=L};this.loadOrgansFromURL=function(T,C,R,P,L,A){if(e.zincRenderer&&P&&e.sceneData.metaURL!==T){S(C,R,P);const I=e.sceneData.currentName;let O=e.zincRenderer.getSceneByName(I);O?A&&O.clearAll():O=e.zincRenderer.createScene(I),e.selectObjectOnPick=!0;for(let N=0;N<r.length;N++)r[N](e.sceneData);L&&L!=""?(e.sceneData.viewURL=L,O.loadViewURL(e.sceneData.viewURL)):e.sceneData.viewURL=void 0,e.sceneData.metaURL=T,O.addZincObjectAddedCallbacks(M(R,P,!1)),O.addZincObjectRemovedCallbacks(_(void 0,P,!1)),O.loadMetadataURL(T,void 0,E()),e.scene=O,e.zincRenderer.setCurrentScene(O),e.graphicsHighlight.reset();const x=O.getZincCameraControls();x.enableRaycaster(O,p(),d()),x.setMouseButtonAction("AUXILIARY","ZOOM"),x.setMouseButtonAction("SECONDARY","PAN")}},this.loadGLTFFromURL=function(T,C,R){if(e.zincRenderer&&C&&e.sceneData.metaURL!==T){S(void 0,void 0,C);const P=e.sceneData.currentName;let L=e.zincRenderer.getSceneByName(P);L?R&&L.clearAll():L=e.zincRenderer.createScene(P);for(let I=0;I<r.length;I++)r[I](e.sceneData);e.sceneData.viewURL=void 0,e.sceneData.metaURL=T,L.addZincObjectAddedCallbacks(M(void 0,C,!1)),L.addZincObjectRemovedCallbacks(_(void 0,C,!1)),L.loadGLTF(T,void 0,E()),e.scene=L,e.zincRenderer.setCurrentScene(L),e.graphicsHighlight.reset();const A=L.getZincCameraControls();A.enableRaycaster(L,p(),d()),A.setMouseButtonAction("AUXILIARY","ZOOM"),A.setMouseButtonAction("SECONDARY","PAN")}},this.alignCameraWithSelectedObject=function(T){const C=e.graphicsHighlight.getSelected();C&&C[0]&&C[0].userData&&e.scene.alignObjectToCameraView(C[0].userData,T)},this.exportSettings=function(){const T={};return T.name=e.instanceName,e.sceneData.currentSystem&&(T.system=e.sceneData.currentSystem),e.sceneData.currentSpecies&&(T.species=e.sceneData.currentSpecies),e.sceneData.currentPart&&(T.part=e.sceneData.currentPart),T.metaURL=e.sceneData.metaURL,e.sceneData.viewURL&&(T.viewURL=e.sceneData.viewURL),T.dialog="Organ Viewer",T},this.importSettings=function(T){return T&&T.dialog==this.typeName?(e.setName(T.name),T.metaURL!==void 0&&T.metaURL!=""?e.loadOrgansFromURL(T.metaURL,T.species,T.system,T.part,T.viewURL,!0):e.loadOrgans(T.species,T.system,T.part),!0):!1},function(){e.initialiseRenderer(void 0),e.zincRenderer&&(e.zincRenderer.addPreRenderCallbackFunction(h()),e.zincRenderer.addPostRenderCallbackFunction(m()))}()};Zx.prototype=Object.create(_t.prototype);var dt=function(){return dt=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},dt.apply(this,arguments)};function qF(n,e,t,i){function r(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function l(f){try{c(i.next(f))}catch(h){o(h)}}function u(f){try{c(i.throw(f))}catch(h){o(h)}}function c(f){f.done?s(f.value):r(f.value).then(l,u)}c((i=i.apply(n,[])).next())})}function KF(n,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(c){return function(f){return u([c,f])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(t=0)),t;)try{if(i=1,r&&(s=c[0]&2?r.return:c[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,c[1])).done)return s;switch(r=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,r=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){t.label=c[1];break}if(c[0]===6&&t.label<s[1]){t.label=s[1],s=c;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(c);break}s[2]&&t.ops.pop(),t.trys.pop();continue}c=e.call(n,t)}catch(f){c=[6,f],r=0}finally{i=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Ze(n){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&n[e],i=0;if(t)return t.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Dt(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),r,s=[],o;try{for(;(e===void 0||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(l){o={error:l}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}typeof SuppressedError=="function"&&SuppressedError;var QF="ENTRIES",Xx="KEYS",Yx="VALUES",Qt="",Gf=function(){function n(e,t){var i=e._tree,r=Array.from(i.keys());this.set=e,this._type=t,this._path=r.length>0?[{node:i,keys:r}]:[]}return n.prototype.next=function(){var e=this.dive();return this.backtrack(),e},n.prototype.dive=function(){if(this._path.length===0)return{done:!0,value:void 0};var e=Po(this._path),t=e.node,i=e.keys;if(Po(i)===Qt)return{done:!1,value:this.result()};var r=t.get(Po(i));return this._path.push({node:r,keys:Array.from(r.keys())}),this.dive()},n.prototype.backtrack=function(){if(this._path.length!==0){var e=Po(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}},n.prototype.key=function(){return this.set._prefix+this._path.map(function(e){var t=e.keys;return Po(t)}).filter(function(e){return e!==Qt}).join("")},n.prototype.value=function(){return Po(this._path).node.get(Qt)},n.prototype.result=function(){switch(this._type){case Yx:return this.value();case Xx:return this.key();default:return[this.key(),this.value()]}},n.prototype[Symbol.iterator]=function(){return this},n}(),Po=function(n){return n[n.length-1]},eV=function(n,e,t){var i=new Map;if(e===void 0)return i;for(var r=e.length+1,s=r+t,o=new Uint8Array(s*r).fill(t+1),l=0;l<r;++l)o[l]=l;for(var u=1;u<s;++u)o[u*r]=u;return Jx(n,e,t,i,o,1,r,""),i},Jx=function(n,e,t,i,r,s,o,l){var u,c,f=s*o;try{e:for(var h=Ze(n.keys()),m=h.next();!m.done;m=h.next()){var y=m.value;if(y===Qt){var p=r[f-1];p<=t&&i.set(l,[n.get(y),p])}else{for(var d=s,b=0;b<y.length;++b,++d){for(var v=y[b],g=o*d,M=g-o,_=r[g],E=Math.max(0,d-t-1),S=Math.min(o-1,d+t),w=E;w<S;++w){var T=v!==e[w],C=r[M+w]+ +T,R=r[M+w+1]+1,P=r[g+w]+1,L=r[g+w+1]=Math.min(C,R,P);L<_&&(_=L)}if(_>t)continue e}Jx(n.get(y),e,t,i,r,d,o,l+y)}}}catch(A){u={error:A}}finally{try{m&&!m.done&&(c=h.return)&&c.call(h)}finally{if(u)throw u.error}}},Hf=function(){function n(e,t){e===void 0&&(e=new Map),t===void 0&&(t=""),this._size=void 0,this._tree=e,this._prefix=t}return n.prototype.atPrefix=function(e){var t,i;if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");var r=Dt(ru(this._tree,e.slice(this._prefix.length)),2),s=r[0],o=r[1];if(s===void 0){var l=Dt($f(o),2),u=l[0],c=l[1];try{for(var f=Ze(u.keys()),h=f.next();!h.done;h=f.next()){var m=h.value;if(m!==Qt&&m.startsWith(c)){var y=new Map;return y.set(m.slice(c.length),u.get(m)),new n(y,e)}}}catch(p){t={error:p}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(t)throw t.error}}}return new n(s,e)},n.prototype.clear=function(){this._size=void 0,this._tree.clear()},n.prototype.delete=function(e){return this._size=void 0,tV(this._tree,e)},n.prototype.entries=function(){return new Gf(this,QF)},n.prototype.forEach=function(e){var t,i;try{for(var r=Ze(this),s=r.next();!s.done;s=r.next()){var o=Dt(s.value,2),l=o[0],u=o[1];e(l,u,this)}}catch(c){t={error:c}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},n.prototype.fuzzyGet=function(e,t){return eV(this._tree,e,t)},n.prototype.get=function(e){var t=Wf(this._tree,e);return t!==void 0?t.get(Qt):void 0},n.prototype.has=function(e){var t=Wf(this._tree,e);return t!==void 0&&t.has(Qt)},n.prototype.keys=function(){return new Gf(this,Xx)},n.prototype.set=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var i=jf(this._tree,e);return i.set(Qt,t),this},Object.defineProperty(n.prototype,"size",{get:function(){if(this._size)return this._size;this._size=0;for(var e=this.entries();!e.next().done;)this._size+=1;return this._size},enumerable:!1,configurable:!0}),n.prototype.update=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var i=jf(this._tree,e);return i.set(Qt,t(i.get(Qt))),this},n.prototype.fetch=function(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;var i=jf(this._tree,e),r=i.get(Qt);return r===void 0&&i.set(Qt,r=t()),r},n.prototype.values=function(){return new Gf(this,Yx)},n.prototype[Symbol.iterator]=function(){return this.entries()},n.from=function(e){var t,i,r=new n;try{for(var s=Ze(e),o=s.next();!o.done;o=s.next()){var l=Dt(o.value,2),u=l[0],c=l[1];r.set(u,c)}}catch(f){t={error:f}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return r},n.fromObject=function(e){return n.from(Object.entries(e))},n}(),ru=function(n,e,t){var i,r;if(t===void 0&&(t=[]),e.length===0||n==null)return[n,t];try{for(var s=Ze(n.keys()),o=s.next();!o.done;o=s.next()){var l=o.value;if(l!==Qt&&e.startsWith(l))return t.push([n,l]),ru(n.get(l),e.slice(l.length),t)}}catch(u){i={error:u}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return t.push([n,e]),ru(void 0,"",t)},Wf=function(n,e){var t,i;if(e.length===0||n==null)return n;try{for(var r=Ze(n.keys()),s=r.next();!s.done;s=r.next()){var o=s.value;if(o!==Qt&&e.startsWith(o))return Wf(n.get(o),e.slice(o.length))}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},jf=function(n,e){var t,i,r=e.length;e:for(var s=0;n&&s<r;){try{for(var o=(t=void 0,Ze(n.keys())),l=o.next();!l.done;l=o.next()){var u=l.value;if(u!==Qt&&e[s]===u[0]){for(var c=Math.min(r-s,u.length),f=1;f<c&&e[s+f]===u[f];)++f;var h=n.get(u);if(f===u.length)n=h;else{var m=new Map;m.set(u.slice(f),h),n.set(e.slice(s,s+f),m),n.delete(u),n=m}s+=f;continue e}}}catch(p){t={error:p}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}var y=new Map;return n.set(e.slice(s),y),y}return n},tV=function(n,e){var t=Dt(ru(n,e),2),i=t[0],r=t[1];if(i!==void 0){if(i.delete(Qt),i.size===0)qx(r);else if(i.size===1){var s=Dt(i.entries().next().value,2),o=s[0],l=s[1];Kx(r,o,l)}}},qx=function(n){if(n.length!==0){var e=Dt($f(n),2),t=e[0],i=e[1];if(t.delete(i),t.size===0)qx(n.slice(0,-1));else if(t.size===1){var r=Dt(t.entries().next().value,2),s=r[0],o=r[1];s!==Qt&&Kx(n.slice(0,-1),s,o)}}},Kx=function(n,e,t){if(n.length!==0){var i=Dt($f(n),2),r=i[0],s=i[1];r.set(s+e,t),r.delete(s)}},$f=function(n){return n[n.length-1]},Xa,Zf="or",Qx="and",nV="and_not",iV=function(){function n(e){if((e==null?void 0:e.fields)==null)throw new Error('MiniSearch: option "fields" must be provided');var t=e.autoVacuum==null||e.autoVacuum===!0?Kf:e.autoVacuum;this._options=dt(dt(dt({},Yf),e),{autoVacuum:t,searchOptions:dt(dt({},ew),e.searchOptions||{}),autoSuggestOptions:dt(dt({},lV),e.autoSuggestOptions||{})}),this._index=new Hf,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=qf,this.addFields(this._options.fields)}return n.prototype.add=function(e){var t,i,r,s,o,l,u=this._options,c=u.extractField,f=u.tokenize,h=u.processTerm,m=u.fields,y=u.idField,p=c(e,y);if(p==null)throw new Error('MiniSearch: document does not have ID field "'.concat(y,'"'));if(this._idToShortId.has(p))throw new Error("MiniSearch: duplicate ID ".concat(p));var d=this.addDocumentId(p);this.saveStoredFields(d,e);try{for(var b=Ze(m),v=b.next();!v.done;v=b.next()){var g=v.value,M=c(e,g);if(M!=null){var _=f(M.toString(),g),E=this._fieldIds[g],S=new Set(_).size;this.addFieldLength(d,E,this._documentCount-1,S);try{for(var w=(r=void 0,Ze(_)),T=w.next();!T.done;T=w.next()){var C=T.value,R=h(C,g);if(Array.isArray(R))try{for(var P=(o=void 0,Ze(R)),L=P.next();!L.done;L=P.next()){var A=L.value;this.addTerm(E,d,A)}}catch(I){o={error:I}}finally{try{L&&!L.done&&(l=P.return)&&l.call(P)}finally{if(o)throw o.error}}else R&&this.addTerm(E,d,R)}}catch(I){r={error:I}}finally{try{T&&!T.done&&(s=w.return)&&s.call(w)}finally{if(r)throw r.error}}}}}catch(I){t={error:I}}finally{try{v&&!v.done&&(i=b.return)&&i.call(b)}finally{if(t)throw t.error}}},n.prototype.addAll=function(e){var t,i;try{for(var r=Ze(e),s=r.next();!s.done;s=r.next()){var o=s.value;this.add(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},n.prototype.addAllAsync=function(e,t){var i=this;t===void 0&&(t={});var r=t.chunkSize,s=r===void 0?10:r,o={chunk:[],promise:Promise.resolve()},l=e.reduce(function(f,h,m){var y=f.chunk,p=f.promise;return y.push(h),(m+1)%s===0?{chunk:[],promise:p.then(function(){return new Promise(function(d){return setTimeout(d,0)})}).then(function(){return i.addAll(y)})}:{chunk:y,promise:p}},o),u=l.chunk,c=l.promise;return c.then(function(){return i.addAll(u)})},n.prototype.remove=function(e){var t,i,r,s,o,l,u=this._options,c=u.tokenize,f=u.processTerm,h=u.extractField,m=u.fields,y=u.idField,p=h(e,y);if(p==null)throw new Error('MiniSearch: document does not have ID field "'.concat(y,'"'));var d=this._idToShortId.get(p);if(d==null)throw new Error("MiniSearch: cannot remove document with ID ".concat(p,": it is not in the index"));try{for(var b=Ze(m),v=b.next();!v.done;v=b.next()){var g=v.value,M=h(e,g);if(M!=null){var _=c(M.toString(),g),E=this._fieldIds[g],S=new Set(_).size;this.removeFieldLength(d,E,this._documentCount,S);try{for(var w=(r=void 0,Ze(_)),T=w.next();!T.done;T=w.next()){var C=T.value,R=f(C,g);if(Array.isArray(R))try{for(var P=(o=void 0,Ze(R)),L=P.next();!L.done;L=P.next()){var A=L.value;this.removeTerm(E,d,A)}}catch(I){o={error:I}}finally{try{L&&!L.done&&(l=P.return)&&l.call(P)}finally{if(o)throw o.error}}else R&&this.removeTerm(E,d,R)}}catch(I){r={error:I}}finally{try{T&&!T.done&&(s=w.return)&&s.call(w)}finally{if(r)throw r.error}}}}}catch(I){t={error:I}}finally{try{v&&!v.done&&(i=b.return)&&i.call(b)}finally{if(t)throw t.error}}this._storedFields.delete(d),this._documentIds.delete(d),this._idToShortId.delete(p),this._fieldLength.delete(d),this._documentCount-=1},n.prototype.removeAll=function(e){var t,i;if(e)try{for(var r=Ze(e),s=r.next();!s.done;s=r.next()){var o=s.value;this.remove(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Hf,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}},n.prototype.discard=function(e){var t=this,i=this._idToShortId.get(e);if(i==null)throw new Error("MiniSearch: cannot discard document with ID ".concat(e,": it is not in the index"));this._idToShortId.delete(e),this._documentIds.delete(i),this._storedFields.delete(i),(this._fieldLength.get(i)||[]).forEach(function(r,s){t.removeFieldLength(i,s,t._documentCount,r)}),this._fieldLength.delete(i),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()},n.prototype.maybeAutoVacuum=function(){if(this._options.autoVacuum!==!1){var e=this._options.autoVacuum,t=e.minDirtFactor,i=e.minDirtCount,r=e.batchSize,s=e.batchWait;this.conditionalVacuum({batchSize:r,batchWait:s},{minDirtCount:i,minDirtFactor:t})}},n.prototype.discardAll=function(e){var t,i,r=this._options.autoVacuum;try{this._options.autoVacuum=!1;try{for(var s=Ze(e),o=s.next();!o.done;o=s.next()){var l=o.value;this.discard(l)}}catch(u){t={error:u}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}}finally{this._options.autoVacuum=r}this.maybeAutoVacuum()},n.prototype.replace=function(e){var t=this._options,i=t.idField,r=t.extractField,s=r(e,i);this.discard(s),this.add(e)},n.prototype.vacuum=function(e){return e===void 0&&(e={}),this.conditionalVacuum(e)},n.prototype.conditionalVacuum=function(e,t){var i=this;return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(function(){var r=i._enqueuedVacuumConditions;return i._enqueuedVacuumConditions=qf,i.performVacuuming(e,r)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)},n.prototype.performVacuuming=function(e,t){return qF(this,void 0,void 0,function(){var i,r,s,o,l,u,c,f,h,m,y,p,d,b,v,g,M,_,E,S,w,T,C,R,P;return KF(this,function(L){switch(L.label){case 0:if(i=this._dirtCount,!this.vacuumConditionsMet(t))return[3,10];r=e.batchSize||Jf.batchSize,s=e.batchWait||Jf.batchWait,o=1,L.label=1;case 1:L.trys.push([1,7,8,9]),l=Ze(this._index),u=l.next(),L.label=2;case 2:if(u.done)return[3,6];c=Dt(u.value,2),f=c[0],h=c[1];try{for(m=(T=void 0,Ze(h)),y=m.next();!y.done;y=m.next()){p=Dt(y.value,2),d=p[0],b=p[1];try{for(v=(R=void 0,Ze(b)),g=v.next();!g.done;g=v.next())M=Dt(g.value,1),_=M[0],!this._documentIds.has(_)&&(b.size<=1?h.delete(d):b.delete(_))}catch(A){R={error:A}}finally{try{g&&!g.done&&(P=v.return)&&P.call(v)}finally{if(R)throw R.error}}}}catch(A){T={error:A}}finally{try{y&&!y.done&&(C=m.return)&&C.call(m)}finally{if(T)throw T.error}}return this._index.get(f).size===0&&this._index.delete(f),o%r!==0?[3,4]:[4,new Promise(function(A){return setTimeout(A,s)})];case 3:L.sent(),L.label=4;case 4:o+=1,L.label=5;case 5:return u=l.next(),[3,2];case 6:return[3,9];case 7:return E=L.sent(),S={error:E},[3,9];case 8:try{u&&!u.done&&(w=l.return)&&w.call(l)}finally{if(S)throw S.error}return[7];case 9:this._dirtCount-=i,L.label=10;case 10:return[4,null];case 11:return L.sent(),this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null,[2]}})})},n.prototype.vacuumConditionsMet=function(e){if(e==null)return!0;var t=e.minDirtCount,i=e.minDirtFactor;return t=t||Kf.minDirtCount,i=i||Kf.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=i},Object.defineProperty(n.prototype,"isVacuuming",{get:function(){return this._currentVacuum!=null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dirtCount",{get:function(){return this._dirtCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dirtFactor",{get:function(){return this._dirtCount/(1+this._documentCount+this._dirtCount)},enumerable:!1,configurable:!0}),n.prototype.has=function(e){return this._idToShortId.has(e)},n.prototype.getStoredFields=function(e){var t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)},n.prototype.search=function(e,t){var i,r;t===void 0&&(t={});var s=this.executeQuery(e,t),o=[];try{for(var l=Ze(s),u=l.next();!u.done;u=l.next()){var c=Dt(u.value,2),f=c[0],h=c[1],m=h.score,y=h.terms,p=h.match,d=y.length||1,b={id:this._documentIds.get(f),score:m*d,terms:Object.keys(p),queryTerms:y,match:p};Object.assign(b,this._storedFields.get(f)),(t.filter==null||t.filter(b))&&o.push(b)}}catch(v){i={error:v}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(i)throw i.error}}return e===n.wildcard&&t.boostDocument==null&&this._options.searchOptions.boostDocument==null||o.sort(nw),o},n.prototype.autoSuggest=function(e,t){var i,r,s,o;t===void 0&&(t={}),t=dt(dt({},this._options.autoSuggestOptions),t);var l=new Map;try{for(var u=Ze(this.search(e,t)),c=u.next();!c.done;c=u.next()){var f=c.value,h=f.score,m=f.terms,y=m.join(" "),p=l.get(y);p!=null?(p.score+=h,p.count+=1):l.set(y,{score:h,terms:m,count:1})}}catch(E){i={error:E}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(i)throw i.error}}var d=[];try{for(var b=Ze(l),v=b.next();!v.done;v=b.next()){var g=Dt(v.value,2),p=g[0],M=g[1],h=M.score,m=M.terms,_=M.count;d.push({suggestion:p,terms:m,score:h/_})}}catch(E){s={error:E}}finally{try{v&&!v.done&&(o=b.return)&&o.call(b)}finally{if(s)throw s.error}}return d.sort(nw),d},Object.defineProperty(n.prototype,"documentCount",{get:function(){return this._documentCount},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"termCount",{get:function(){return this._index.size},enumerable:!1,configurable:!0}),n.loadJSON=function(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),t)},n.getDefault=function(e){if(Yf.hasOwnProperty(e))return Xf(Yf,e);throw new Error('MiniSearch: unknown option "'.concat(e,'"'))},n.loadJS=function(e,t){var i,r,s,o,l,u,c=e.index,f=e.documentCount,h=e.nextId,m=e.documentIds,y=e.fieldIds,p=e.fieldLength,d=e.averageFieldLength,b=e.storedFields,v=e.dirtCount,g=e.serializationVersion;if(g!==1&&g!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");var M=new n(t);M._documentCount=f,M._nextId=h,M._documentIds=su(m),M._idToShortId=new Map,M._fieldIds=y,M._fieldLength=su(p),M._avgFieldLength=d,M._storedFields=su(b),M._dirtCount=v||0,M._index=new Hf;try{for(var _=Ze(M._documentIds),E=_.next();!E.done;E=_.next()){var S=Dt(E.value,2),w=S[0],T=S[1];M._idToShortId.set(T,w)}}catch(D){i={error:D}}finally{try{E&&!E.done&&(r=_.return)&&r.call(_)}finally{if(i)throw i.error}}try{for(var C=Ze(c),R=C.next();!R.done;R=C.next()){var P=Dt(R.value,2),L=P[0],A=P[1],I=new Map;try{for(var O=(l=void 0,Ze(Object.keys(A))),x=O.next();!x.done;x=O.next()){var N=x.value,B=A[N];g===1&&(B=B.ds),I.set(parseInt(N,10),su(B))}}catch(D){l={error:D}}finally{try{x&&!x.done&&(u=O.return)&&u.call(O)}finally{if(l)throw l.error}}M._index.set(L,I)}}catch(D){s={error:D}}finally{try{R&&!R.done&&(o=C.return)&&o.call(C)}finally{if(s)throw s.error}}return M},n.prototype.executeQuery=function(e,t){var i=this;if(t===void 0&&(t={}),e===n.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){var r=dt(dt(dt({},t),e),{queries:void 0}),s=e.queries.map(function(b){return i.executeQuery(b,r)});return this.combineResults(s,r.combineWith)}var o=this._options,l=o.tokenize,u=o.processTerm,c=o.searchOptions,f=dt(dt({tokenize:l,processTerm:u},c),t),h=f.tokenize,m=f.processTerm,y=h(e).flatMap(function(b){return m(b)}).filter(function(b){return!!b}),p=y.map(aV(f)),d=p.map(function(b){return i.executeQuerySpec(b,f)});return this.combineResults(d,f.combineWith)},n.prototype.executeQuerySpec=function(e,t){var i,r,s,o,l=dt(dt({},this._options.searchOptions),t),u=(l.fields||this._options.fields).reduce(function(N,B){var D;return dt(dt({},N),(D={},D[B]=Xf(l.boost,B)||1,D))},{}),c=l.boostDocument,f=l.weights,h=l.maxFuzzy,m=l.bm25,y=dt(dt({},ew.weights),f),p=y.fuzzy,d=y.prefix,b=this._index.get(e.term),v=this.termResults(e.term,e.term,1,b,u,c,m),g,M;if(e.prefix&&(g=this._index.atPrefix(e.term)),e.fuzzy){var _=e.fuzzy===!0?.2:e.fuzzy,E=_<1?Math.min(h,Math.round(e.term.length*_)):_;E&&(M=this._index.fuzzyGet(e.term,E))}if(g)try{for(var S=Ze(g),w=S.next();!w.done;w=S.next()){var T=Dt(w.value,2),C=T[0],R=T[1],P=C.length-e.term.length;if(P){M==null||M.delete(C);var L=d*C.length/(C.length+.3*P);this.termResults(e.term,C,L,R,u,c,m,v)}}}catch(N){i={error:N}}finally{try{w&&!w.done&&(r=S.return)&&r.call(S)}finally{if(i)throw i.error}}if(M)try{for(var A=Ze(M.keys()),I=A.next();!I.done;I=A.next()){var C=I.value,O=Dt(M.get(C),2),x=O[0],P=O[1];if(P){var L=p*C.length/(C.length+P);this.termResults(e.term,C,L,x,u,c,m,v)}}}catch(N){s={error:N}}finally{try{I&&!I.done&&(o=A.return)&&o.call(A)}finally{if(s)throw s.error}}return v},n.prototype.executeWildcardQuery=function(e){var t,i,r=new Map,s=dt(dt({},this._options.searchOptions),e);try{for(var o=Ze(this._documentIds),l=o.next();!l.done;l=o.next()){var u=Dt(l.value,2),c=u[0],f=u[1],h=s.boostDocument?s.boostDocument(f,"",this._storedFields.get(c)):1;r.set(c,{score:h,terms:[],match:{}})}}catch(m){t={error:m}}finally{try{l&&!l.done&&(i=o.return)&&i.call(o)}finally{if(t)throw t.error}}return r},n.prototype.combineResults=function(e,t){if(t===void 0&&(t=Zf),e.length===0)return new Map;var i=t.toLowerCase();return e.reduce(rV[i])||new Map},n.prototype.toJSON=function(){var e,t,i,r,s=[];try{for(var o=Ze(this._index),l=o.next();!l.done;l=o.next()){var u=Dt(l.value,2),c=u[0],f=u[1],h={};try{for(var m=(i=void 0,Ze(f)),y=m.next();!y.done;y=m.next()){var p=Dt(y.value,2),d=p[0],b=p[1];h[d]=Object.fromEntries(b)}}catch(v){i={error:v}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(i)throw i.error}}s.push([c,h])}}catch(v){e={error:v}}finally{try{l&&!l.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:s,serializationVersion:2}},n.prototype.termResults=function(e,t,i,r,s,o,l,u){var c,f,h,m,y;if(u===void 0&&(u=new Map),r==null)return u;try{for(var p=Ze(Object.keys(s)),d=p.next();!d.done;d=p.next()){var b=d.value,v=s[b],g=this._fieldIds[b],M=r.get(g);if(M!=null){var _=M.size,E=this._avgFieldLength[g];try{for(var S=(h=void 0,Ze(M.keys())),w=S.next();!w.done;w=S.next()){var T=w.value;if(!this._documentIds.has(T)){this.removeTerm(g,T,t),_-=1;continue}var C=o?o(this._documentIds.get(T),t,this._storedFields.get(T)):1;if(C){var R=M.get(T),P=this._fieldLength.get(T)[g],L=oV(R,_,this._documentCount,P,E,l),A=i*v*C*L,I=u.get(T);if(I){I.score+=A,cV(I.terms,e);var O=Xf(I.match,t);O?O.push(b):I.match[t]=[b]}else u.set(T,{score:A,terms:[e],match:(y={},y[t]=[b],y)})}}}catch(x){h={error:x}}finally{try{w&&!w.done&&(m=S.return)&&m.call(S)}finally{if(h)throw h.error}}}}}catch(x){c={error:x}}finally{try{d&&!d.done&&(f=p.return)&&f.call(p)}finally{if(c)throw c.error}}return u},n.prototype.addTerm=function(e,t,i){var r=this._index.fetch(i,iw),s=r.get(e);if(s==null)s=new Map,s.set(t,1),r.set(e,s);else{var o=s.get(t);s.set(t,(o||0)+1)}},n.prototype.removeTerm=function(e,t,i){if(!this._index.has(i)){this.warnDocumentChanged(t,e,i);return}var r=this._index.fetch(i,iw),s=r.get(e);s==null||s.get(t)==null?this.warnDocumentChanged(t,e,i):s.get(t)<=1?s.size<=1?r.delete(e):s.delete(t):s.set(t,s.get(t)-1),this._index.get(i).size===0&&this._index.delete(i)},n.prototype.warnDocumentChanged=function(e,t,i){var r,s;try{for(var o=Ze(Object.keys(this._fieldIds)),l=o.next();!l.done;l=o.next()){var u=l.value;if(this._fieldIds[u]===t){this._options.logger("warn","MiniSearch: document with ID ".concat(this._documentIds.get(e),' has changed before removal: term "').concat(i,'" was not present in field "').concat(u,'". Removing a document after it has changed can corrupt the index!'),"version_conflict");return}}}catch(c){r={error:c}}finally{try{l&&!l.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}},n.prototype.addDocumentId=function(e){var t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t},n.prototype.addFields=function(e){for(var t=0;t<e.length;t++)this._fieldIds[e[t]]=t},n.prototype.addFieldLength=function(e,t,i,r){var s=this._fieldLength.get(e);s==null&&this._fieldLength.set(e,s=[]),s[t]=r;var o=this._avgFieldLength[t]||0,l=o*i+r;this._avgFieldLength[t]=l/(i+1)},n.prototype.removeFieldLength=function(e,t,i,r){if(i===1){this._avgFieldLength[t]=0;return}var s=this._avgFieldLength[t]*i-r;this._avgFieldLength[t]=s/(i-1)},n.prototype.saveStoredFields=function(e,t){var i,r,s=this._options,o=s.storeFields,l=s.extractField;if(!(o==null||o.length===0)){var u=this._storedFields.get(e);u==null&&this._storedFields.set(e,u={});try{for(var c=Ze(o),f=c.next();!f.done;f=c.next()){var h=f.value,m=l(t,h);m!==void 0&&(u[h]=m)}}catch(y){i={error:y}}finally{try{f&&!f.done&&(r=c.return)&&r.call(c)}finally{if(i)throw i.error}}}},n.wildcard=Symbol("*"),n}(),Xf=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0},rV=(Xa={},Xa[Zf]=function(n,e){var t,i;try{for(var r=Ze(e.keys()),s=r.next();!s.done;s=r.next()){var o=s.value,l=n.get(o);if(l==null)n.set(o,e.get(o));else{var u=e.get(o),c=u.score,f=u.terms,h=u.match;l.score=l.score+c,l.match=Object.assign(l.match,h),tw(l.terms,f)}}}catch(m){t={error:m}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},Xa[Qx]=function(n,e){var t,i,r=new Map;try{for(var s=Ze(e.keys()),o=s.next();!o.done;o=s.next()){var l=o.value,u=n.get(l);if(u!=null){var c=e.get(l),f=c.score,h=c.terms,m=c.match;tw(u.terms,h),r.set(l,{score:u.score+f,terms:u.terms,match:Object.assign(u.match,m)})}}}catch(y){t={error:y}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(t)throw t.error}}return r},Xa[nV]=function(n,e){var t,i;try{for(var r=Ze(e.keys()),s=r.next();!s.done;s=r.next()){var o=s.value;n.delete(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}return n},Xa),sV={k:1.2,b:.7,d:.5},oV=function(n,e,t,i,r,s){var o=s.k,l=s.b,u=s.d,c=Math.log(1+(t-e+.5)/(e+.5));return c*(u+n*(o+1)/(n+o*(1-l+l*i/r)))},aV=function(n){return function(e,t,i){var r=typeof n.fuzzy=="function"?n.fuzzy(e,t,i):n.fuzzy||!1,s=typeof n.prefix=="function"?n.prefix(e,t,i):n.prefix===!0;return{term:e,fuzzy:r,prefix:s}}},Yf={idField:"id",extractField:function(n,e){return n[e]},tokenize:function(n){return n.split(uV)},processTerm:function(n){return n.toLowerCase()},fields:void 0,searchOptions:void 0,storeFields:[],logger:function(n,e){typeof(console==null?void 0:console[n])=="function"&&console[n](e)},autoVacuum:!0},ew={combineWith:Zf,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:sV},lV={combineWith:Qx,prefix:function(n,e,t){return e===t.length-1}},Jf={batchSize:1e3,batchWait:10},qf={minDirtFactor:.1,minDirtCount:20},Kf=dt(dt({},Jf),qf),cV=function(n,e){n.includes(e)||n.push(e)},tw=function(n,e){var t,i;try{for(var r=Ze(e),s=r.next();!s.done;s=r.next()){var o=s.value;n.includes(o)||n.push(o)}}catch(l){t={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(t)throw t.error}}},nw=function(n,e){var t=n.score,i=e.score;return i-t},iw=function(){return new Map},su=function(n){var e,t,i=new Map;try{for(var r=Ze(Object.keys(n)),s=r.next();!s.done;s=r.next()){var o=s.value;i.set(parseInt(o,10),n[o])}}catch(l){e={error:l}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return i},uV=/[\n\r -#%-*,-/:;?@[-\]_{}\u00A0\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u1680\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2000-\u200A\u2010-\u2029\u202F-\u2043\u2045-\u2051\u2053-\u205F\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u3000-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]+/u;class dV{constructor(){this._searchEngine=new iV({fields:["path","name"],storeFields:["path"],tokenize:(e,t)=>e.split(/[\s/]+/)}),this.idMaps={}}addZincObject(e,t){const i=e.getRegion().getFullPath();let r=e.groupName,s=i?`${i}/${e.groupName}`:e.groupName;r=r.replaceAll('"',""),s=s.replaceAll('"',"");const o={path:s,name:r,id:t};this._searchEngine.add(o),this.idMaps[t]={path:s,zincObject:e}}removeZincObject(e,t){const i=e.getRegion().getFullPath();let r=e.groupName,s=i?`${i}/${e.groupName}`:e.groupName;r=r.replaceAll('"',""),s=s.replaceAll('"',"");const o={path:s,name:r,id:t};this._searchEngine.remove(o),delete this.idMaps[t]}addRegion(e,t){let i=e.getFullPath(),r=e.getName();i=i.replaceAll('"',""),r=r.replaceAll('"',"");const s={path:i,name:r,id:t};this._searchEngine.add(s),this.idMaps[t]={path:i,zincObject:e}}clearResults(){this._}removeAll(){this._searchEngine.removeAll(),this.idMaps={}}auto_suggest(e){let t=[];e.length>2&&["'",'"'].includes(e.slice(0,1))?(e=e.replaceAll(e.slice(0,1),""),t=this._searchEngine.search(e,{prefix:!0,combineWith:"AND"})):e.length>1&&(t=this._searchEngine.search(e,{prefix:!0}));const i=[];t.forEach(o=>{o.id in this.idMaps&&i.push(this.idMaps[o.id].path)});const r=[...new Set(i)],s=[];return r.forEach(o=>s.push({suggestion:'"'+o+'"'})),s}processResults(e,t){const i={regionPath:void 0,label:'Search Results for "'};return Array.isArray(t)?i.label+=",".join(t):i.label+=t,i.label+='"',e.length===1&&(e[0].isRegion?i.regionPath=e[0].getFullPath():e[0].isZincObject&&(i.regionPath=e[0].getRegion().getFullPath(),i.label=e[0].groupName)),i.zincObjects=cF(e),i}search(e){let t;e.length>2&&["'",'"'].includes(e.slice(0,1))?(e=e.replaceAll(e.slice(0,1),""),t=this._searchEngine.search(e,{prefix:!0,combineWith:"AND"})):e.length>1&&(t=this._searchEngine.search(e,{prefix:!0}));const i=[];return t.forEach(r=>{r.id in this.idMaps&&i.push(this.idMaps[r.id].zincObject)}),i}searchTerms(e){let t=[];return e.forEach(i=>{const r=this.search(i);t.push(...r)}),t}searchAndProcessResult(e){let t=[];return Array.isArray(e)?t=this.searchTerms(e):t=this.search(e),this.processResults(t,e)}}const hV={name:"ScaffoldVuer",components:{Button:Cs,Col:Fn,Loading:YL,Option:Ls,Popover:Pl,Row:Qn,Select:As,Slider:Ln,TabPane:jg,Tabs:Wg,MapSvgIcon:ep.MapSvgIcon,MapSvgSpriteColor:ep.MapSvgSpriteColor,PrimitiveControls:Dx,ScaffoldTooltip:jx,ElIconWarningFilled:lm,ElIconArrowDown:Lu,ElIconArrowLeft:Wi,DrawToolbar:Ja.DrawToolbar,ScaffoldTreeControls:Bx},setup(n){let e=a.inject("$annotator");return e||(e=a.markRaw(new HF(`${n.flatmapAPI}annotator`)),a.provide("$annotator",e)),{annotator:e}},props:{annotationSidebar:{type:Boolean,default:!1},url:{type:String,default:""},showColourPicker:{type:Boolean,default:!1},displayUI:{type:Boolean,default:!0},displayAtStartUp:{type:Boolean,default:!0},helpMode:{type:Boolean,default:!1},helpModeActiveItem:{type:Number,default:0},helpModeDialog:{type:Boolean,default:!1},helpModeLastItem:{type:Boolean,default:!1},helpModeInitialIndex:{type:Number,default:0},displayWarning:{type:Boolean,default:!0},warningMessage:{type:String,default:"Beta feature - under active development"},displayLatestChanges:{type:Boolean,default:!1},latestChangesMessage:{type:String,default:"New feature - Local search is now available"},displayMarkers:{type:Boolean,default:!1},markerCluster:{type:Boolean,default:!1},markerLabels:{type:Object,default:function(){return{}}},displayMinimap:{type:Boolean,default:!1},format:{type:String,default:"metadata"},minimapSettings:{type:Object,default:function(){return{x_offset:16,y_offset:16,width:128,height:128,align:"top-right"}}},enableOpenMapUI:{type:Boolean,default:!1},openMapOptions:{type:Array,default:function(){return[{display:"Open AC Map",key:"AC"},{display:"Open FC Map",key:"FC"},{display:"Open 3D Human Map",key:"3D"}]}},state:{type:Object,default:void 0},region:{type:String,default:""},viewURL:{type:String,default:""},render:{type:Boolean,default:!0},flatmapAPI:{type:String,default:"https://mapcore-demo.org/current/flatmap/v3/"},enableLocalAnnotations:{type:Boolean,default:!1}},provide(){return{flatmapAPI:this.flatmapAPI,scaffoldUrl:this.url,boundingDims:this.boundingDims}},data:function(){return{annotator:void 0,createData:{drawingBox:!1,toBeConfirmed:!1,points:[],shape:"",x:0,y:0,editingIndex:-1,faceIndex:-1,toBeDeleted:!1},currentTime:0,timeVarying:!1,isPlaying:!1,isReady:!1,isTransitioning:!1,tooltipAppendToBody:!1,hoverVisibilities:[{value:!1,ref:"zoomInPopover"},{value:!1,ref:"zoomOutPopover"},{value:!1,ref:"zoomFitPopover"},{value:!1,ref:"openMapPopover"},{value:!1,ref:"settingsPopover"},{value:!1,ref:"sliderPopover"},{value:!1,ref:"regionVisibilityPopover"},{value:!1,ref:"warningPopover"},{value:!1,ref:"whatsNewPopover"},{value:!1,refs:"toolbarPopover",ref:"editPopover"},{value:!1,refs:"toolbarPopover",ref:"pointPopover"},{value:!1,refs:"toolbarPopover",ref:"lineStringPopover"},{value:!1,refs:"toolbarPopover",ref:"deletePopover"}],inHelp:!1,helpModeActiveIndex:this.helpModeInitialIndex,loading:!1,duration:3e3,drawerOpen:!0,currentBackground:"white",availableBackground:["white","lightskyblue","black"],minimisedSlider:!1,sliderPosition:"",timeMax:100,orginalDuration:"",animateDuration:"6secs",playSpeed:[{value:.1,label:"0.1x"},{value:.5,label:"0.5x"},{value:1,label:"1x"},{value:2,label:"2x"},{value:5,label:"5x"},{value:10,label:"10x"}],currentSpeed:1,timeStamps:{},defaultCheckedKeys:[],tData:{label:"",region:"",visible:!1,x:200,y:200,active:!1},fileFormat:"metadata",previousMarkerLabels:a.markRaw({}),viewingMode:"Exploration",viewingModes:{Exploration:"View and explore detailed visualization of 3D scaffolds",Annotation:"View internal identifiers of features"},openMapRef:void 0,backgroundIconRef:void 0,userInformation:void 0,toolbarOptions:["Delete","Edit","Point","LineString"],activeDrawTool:void 0,activeDrawMode:void 0,localAnnotationsList:a.markRaw([]),boundingDims:{centre:[0,0,0],size:[1,1,1]},lastSelected:a.markRaw({region:"",group:"",isSearch:!1})}},watch:{format:{handler:function(n){this.fileFormat=n},immediate:!0},url:{handler:function(n){(this.state===void 0||this.state.url===void 0)&&this.setURL(n)},immediate:!0},region:{handler:function(n){this.state||this.viewURL||this.setFocusedRegion(n)},immediate:!0},state:{handler:function(n){this.setState(n)},immediate:!0,deep:!0},viewURL:{handler:function(n){this.updateViewURL(n)},immediate:!0},helpMode:function(n,e){n!==e&&this.setHelpMode(n)},helpModeActiveItem:function(){this.helpMode&&(this.helpModeActiveIndex+=1,this.setHelpMode(this.helpMode))},displayMarkers:function(n){this.$module.scene.displayMarkers=n,this.$module.scene.forcePickableObjectsUpdate=!0},displayMinimap:function(n){this.$module.scene.displayMinimap=n},currentTime:{handler:function(){this.$emit("timeChanged",this.currentTime)}},duration:function(){this.$module.scene.setDuration(this.duration)},minimapSettings:{deep:!0,handler:"updateMinimapScissor"},render:function(n){this.toggleRendering(n)},markerCluster:{handler:function(n){this.$module.scene.enableMarkerCluster(n)},immediate:!0},markerLabels:function(n){for(const[e,t]of Object.entries(this.previousMarkerLabels))this.setMarkerModeForObjectsWithName(e,t,"off");for(const[e,t]of Object.entries(n))this.setMarkerModeForObjectsWithName(e,t,"on");this.previousMarkerLabels=a.markRaw({...n})},annotationDisplay:function(n){if(this.annotationSidebar)if(n){const t={featureId:(this.tData.region?this.tData.region+"/":"")+this.tData.label,resourceId:this.url,resource:this.url};this.$emit("annotation-open",{annotationEntry:t,commitCallback:this.commitAnnotationEvent})}else(!this.createData.toBeConfirmed||!this.createData.toBeDeleted)&&this.$emit("annotation-close")}},beforeCreate:function(){this.$module=new Zx,this.selectedObjects=[],this.hoveredObjects=[],this.currentBackground="white",this._currentURL=void 0,this.availableBackground=["white","black","lightskyblue"],this.$_searchIndex=new dV},mounted:function(){this.openMapRef=a.shallowRef(this.$refs.openMapRef),this.backgroundIconRef=a.shallowRef(this.$refs.backgroundIconRef),this.$refs.scaffoldTreeControls.setModule(this.$module);let n=new $F;n.subscribe(this,this.eventNotifierCallback),this.$module.addNotifier(n),this.$module.addOrganPartAddedCallback(this.zincObjectAdded),this.$module.addOrganPartRemovedCallback(this.zincObjectRemoved),this.$module.initialiseRenderer(this.$refs.display),this.toggleRendering(this.render),this.ro=new ResizeObserver(this.adjustLayout).observe(this.$refs.scaffoldContainer),this.helpTextWait=[],this.helpTextWait.length=this.hoverVisibilities.length,this.defaultRate=this.$module.getPlayRate(),this.$module.zincRenderer.addPreRenderCallbackFunction(()=>{this.currentTime=this.$module.getCurrentTime()})},beforeUnmount:function(){this.ro&&this.ro.disconnect(),this.$module.destroy(),this.$module=void 0},computed:{...Hx(Wx,["userToken"]),annotationDisplay:function(){return this.viewingMode==="Annotation"&&this.tData.active===!0&&this.activeDrawMode!=="Point"&&this.activeDrawMode!=="LineString"}},methods:{addZincObject:function(n){this.$module.scene&&this.$module.scene.addZincObject(n)},zincObjectAdded:function(n){this.loading=!1,this.$_searchIndex.addZincObject(n,n.uuid),this.timeVarying===!1&&n.isTimeVarying()&&(this.timeVarying=!0),this.$emit("zinc-object-added",n)},removeFromLocalAnnotationList:function(n,e){for(let t=0;t<this.localAnnotationsList.length;t++){const i=this.localAnnotationsList[t];if(i.region===n&&i.group===e){this.localAnnotationsList.splice(t,1);return}}},zincObjectRemoved:function(n){if(this.$module.scene){const e=n.region.getFullPath(),t=n.groupName;n.region.findObjectsWithGroupName(t,!1).length===0&&(this.$_searchIndex.removeZincObject(n,n.uuid),this.removeFromLocalAnnotationList(e,t))}},addRegionsToSearchIndex:function(){this.$module.scene.getRootRegion().getChildRegions(!0).forEach(t=>{this.$_searchIndex.addRegion(t,t.uuid)})},backgroundChangeCallback:function(n){this.currentBackground=n,this.$module.zincRenderer.getThreeJSRenderer().setClearColor(this.currentBackground,1)},captureScreenshotCallback:function(){this.$module.zincRenderer.removePostRenderCallbackFunction(this.captureID);let n=this.$module.zincRenderer.getThreeJSRenderer().domElement.toDataURL("image/png"),e=document.createElement("a");document.body.append(e),this.captureFilename?e.download=this.captureFilename:e.download="screenshot.png",e.href=n,e.click(),e.remove()},captureScreenshot:function(n){this.captureFilename=n,this.captureID=this.$module.zincRenderer.addPostRenderCallbackFunction(this.captureScreenshotCallback)},clearScene:function(){this.$refs.scaffoldTreeControls&&this.$refs.scaffoldTreeControls.clear(),this.$_searchIndex&&this.$_searchIndex.removeAll(),this.$module.scene&&this.$module.scene.clearAll()},addAndEditAnnotations:function(n,e,t,i){const r=Ax(this.annotator,this.userToken,t,n,e,this.url,i);if(this.enableLocalAnnotations){r.group=e;let s=n;s.slice(-1)==="/"&&(s=s.slice(0,-1)),r.region=s,this.removeFromLocalAnnotationList(s,e),this.localAnnotationsList.push(r)}this.$emit("userPrimitivesUpdated",{region:n,group:e,zincObject:t})},primitivesUpdated:function(n){if(n.isZincObject&&n.isEditable){const e=n.groupName,t=n.region.getFullPath();this.addAndEditAnnotations(t,e,n,"Position Updated")}},confirmCreate:function(n){if(n){let e;if(n.shape==="Point")e=this.$module.scene.createPoints(n.region,n.group,this.createData.points,n.group,8942);else if(n.shape==="LineString")e=this.$module.scene.createLines(n.region,n.group,[this.createData.points[0],this.createData.points[1]],60962);else if(n.editingIndex>-1&&this._editingZincObject){this._editingZincObject.editVertices([this.createData.points[1]],n.editingIndex);const t=this._editingZincObject.region.getFullPath()+"/",i=this._editingZincObject.groupName;this.addAndEditAnnotations(t,i,this._editingZincObject,"Position Updated")}e&&(this.addAndEditAnnotations(n.region,n.group,e.zincObject,"Create"),e.zincObject.isEditable=!0,this.tData.region=n.region,this.tData.label=n.group,this.changeActiveByName([n.group],n.region,!1))}this.cancelCreate()},cancelCreate:function(){this.createData.points.length=0,this.createData.toBeConfirmed=!1,this._editingZincObject=void 0,this.createData.editingIndex=-1,this.createData.faceIndex=-1,this.tData.visible=!1,this.createData.toBeDeleted=!1,this._tempLine&&(this.$module.scene.removeTemporaryPrimitive(this._tempLine),this._tempLine=void 0),this._tempPoint&&(this.$module.scene.removeTemporaryPrimitive(this._tempPoint),this._tempPoint=void 0),this.annotationSidebar&&this.$emit("annotation-close")},confirmDelete:function(){var n;if((n=this._editingZincObject)!=null&&n.isEditable){const e=this._editingZincObject.region.getFullPath()+"/",t=this._editingZincObject.groupName;Ax(this.annotator,this.userToken,this._editingZincObject,e,t,this.url,"Deleted")&&this.$module.scene.getRootRegion().findChildFromPath(e).removeZincObject(this._editingZincObject)}this.cancelCreate()},onTooltipHide:function(){this.createData.toBeConfirmed&&!this.annotationSidebar&&this.cancelCreate()},formatTooltip(n){if(this.timeMax>=1e3&&n){let e=(n%6e4/1e3).toFixed(2)+"s";return(n>6e4?(n/6e4).toFixed(0)+"m ":"")+e}return n?n.toFixed(2)+" ms":"0 ms"},fitWindow:function(){if(this.$module.scene){let n=!1;this._boundingBoxGeo&&(n=this._boundingBoxGeo.getVisibility(),this._boundingBoxGeo.setVisibility(!1)),this.$module.scene.viewAll(),this._boundingBoxGeo&&(aF(this._boundingBoxGeo,this.$module.scene),this._boundingBoxGeo.setVisibility(n))}},zoomIn:function(){this.$module.scene&&this.$module.scene.changeZoomByScrollRateUnit(-1)},zoomOut:function(){this.$module.scene&&this.$module.scene.changeZoomByScrollRateUnit(1)},speedChanged:function(n){this.currentSpeed=n,this.$module.setPlayRate(this.defaultRate*this.currentSpeed)},stopFreeSpin:function(){this.$module.scene.getZincCameraControls().stopAutoTumble(),this.isTransitioning=!1},findObjectsWithGroupName:function(n){let e=[];return n&&n!=""&&this.$module.scene&&(e=this.$module.scene.findObjectsWithGroupName(n)),e},toggleDrawing:function(n,e){this.createData.toBeDeleted=!1,n==="mode"?(this.cancelCreate(),this.activeDrawMode=e,this.createData.shape="",this.$module.selectObjectOnPick=!0):n==="tool"&&(this.activeDrawTool=e,this.createData.shape=this.activeDrawTool?this.activeDrawTool:"",this.$module.selectObjectOnPick=!1)},toggleDrawingBox:function(){this.createData.drawingBox=!this.createData.drawingBox},viewRegion:function(n){const e=this.$module.scene.getRootRegion(),t=Array.isArray(n)?n:[n],i=Lo(e,t,"",!0);let r=this.$module.scene.getBoundingBoxOfZincObjects(i);if(r){if(this.$module.isSyncControl())this.$module.setSyncControlZoomToBox(r);else{const s=this.$module.scene.camera.far-this.$module.scene.camera.near;this.$module.scene.viewAllWithBoundingBox(r),this.$module.scene.camera.far=this.$module.scene.camera.near+s,this.$module.scene.camera.updateProjectionMatrix()}return!0}return!1},setFocusedRegion:function(n){n&&(this.isReady?this.viewRegion(n):this.$module.setFinishDownloadCallback(this.setURLFinishCallback({region:n})))},updateViewURL:function(n){if(n)if(this.isReady){const e=new URL(n,this.url);this.$module.scene.loadViewURL(e)}else this.$module.setFinishDownloadCallback(this.setURLFinishCallback({viewURL:n}))},createEditTemporaryLines:function(n){const e=n[0].extraData.worldCoords;if(e&&(this.createData.shape==="LineString"||this.createData.editingIndex>-1)&&this.createData.points.length===1)if(this.showRegionTooltipWithAnnotations(n,!0,!1),this.tData.x=50,this.tData.y=200,this._tempLine){const t=this._tempLine.geometry.getAttribute("position");t.setXYZ(1,e[0],e[1],e[2]),t.needsUpdate=!0}else this._tempLine=this.$module.scene.addTemporaryLines([this.createData.points[0],e],65535)},draw:function(n){n&&n.length>0&&n[0].data.group&&n[0].extraData.worldCoords&&(this.createData.shape==="Point"?this.drawPoint(n[0].extraData.worldCoords,n):(this.createData.shape==="LineString"||this.createData.editingIndex>-1)&&this.drawLine(n[0].extraData.worldCoords,n))},drawPoint:function(n,e){this.createData.toBeConfirmed===!1&&(this.createData.points.length=0,this.createData.points.push(n),this.createData.toBeConfirmed=!0,this.showRegionTooltipWithAnnotations(e,!0,!1),this.tData.x=50,this.tData.y=200,this._tempPoint=this.$module.scene.addTemporaryPoints([n],16776960))},drawLine:function(n,e){this.createData.toBeConfirmed===!1&&(this.createData.points.length===1?(this.createData.points.push(n),this.createData.toBeConfirmed=!0,this.showRegionTooltipWithAnnotations(e,!0,!1),this.tData.x=50,this.tData.y=200):(this._tempPoint=this.$module.scene.addTemporaryPoints([n],16776960),this.createData.points.push(n)))},getRendererInfo:function(){if(this.$module.zincRenderer)return this.$module.zincRenderer.getThreeJSRenderer().info},freeSpin:function(){if(this.$module.scene){let n=this.$module.scene.getZincCameraControls();this.isTransitioning=!0,n.enableAutoTumble(),n.autoTumble([1,0],Math.PI,!0),setTimeout(this.stopFreeSpin,4e3)}},activateAnnotationMode:function(n,e){if(this.userInformation||this.enableLocalAnnotations)if(this.createData.toBeDeleted=!1,this.createData.shape!==""||this.createData.editingIndex>-1)n.length>0&&e.identifiers[0].coords&&(this.createData.x=e.identifiers[0].coords.x,this.createData.y=e.identifiers[0].coords.y,this.draw(e.identifiers));else{if(this.activeDrawMode==="Edit"){const t=rF(e);t&&this.activateEditingMode(t.zincObject,t.faceIndex,t.vertexIndex,t.point)}else if(this.activeDrawMode==="Delete"){const t=sF(e);t&&(this.createData.toBeDeleted=!0,this._editingZincObject=t)}this.activeDrawMode!=="Point"&&this.activeDrawMode!=="LineString"?this.showRegionTooltipWithAnnotations(e.identifiers,!0,!1):this.showRegionTooltipWithAnnotations(e.identifiers,!0,!0)}else this.showRegionTooltipWithAnnotations(e.identifiers,!0,!0)},activateEditingMode:function(n,e,t,i){this._editingZincObject=n,this.createData.faceIndex=e,this.createData.editingIndex=t,this.drawLine(i,void 0)},eventNotifierCallback:function(n){if(!(this.createData.toBeConfirmed||this.createData.toBeDeleted)){const e=[];let t=[];(n.eventType==1||n.eventType==2)&&(n.identifiers.forEach(s=>{if(s){let o=s.data.id?s.data.id:s.data.group;e.push(o)}}),t=n.zincObjects);let i,r;if(n.identifiers.length>0&&n.identifiers[0]&&(i=n.identifiers[0].data.id?n.identifiers[0].data.id:n.identifiers[0].data.group,n.identifiers[0].data.region&&(r=n.identifiers[0].data.region)),n.eventType==1)this.viewingMode==="Annotation"?(this.tData.label=i,this.tData.region=r,this.activateAnnotationMode(e,n)):(this.$refs.scaffoldTreeControls&&(e.length>0?(this.$refs.scaffoldTreeControls.updateActiveUI(t),this.updatePrimitiveControls(t)):(this.hideRegionTooltip(),this.$refs.scaffoldTreeControls.removeActive(!1))),n.identifiers.length===1?(this.lastSelected.isSearch=!1,this.lastSelected.region=r,this.lastSelected.group=n.identifiers[0].data.group):n.identifiers.length===0&&(this.lastSelected.isSearch=!1,this.lastSelected.region="",this.lastSelected.group=""),this.$emit("scaffold-selected",n.identifiers));else if(n.eventType==2)this.selectedObjects.length===0&&(this.hideRegionTooltip(),this.$refs.scaffoldTreeControls&&(e.length>0?this.$refs.scaffoldTreeControls.updateHoverUI(t):this.$refs.scaffoldTreeControls.removeHover(!0)),n.identifiers.length>0&&n.identifiers[0]&&n.identifiers[0].coords&&(this.tData.active=!1,(!this.viewingMode!=="Annotation"||!this.annotationSidebar)&&(this.tData.visible=!0),this.tData.label=i,this.tData.region=r,this.tData.x=n.identifiers[0].coords.x,this.tData.y=n.identifiers[0].coords.y,this.createEditTemporaryLines(n.identifiers)),this.$emit("scaffold-highlighted",n.identifiers));else if(n.eventType==3&&n.identifiers.length>0&&n.identifiers[0]){if(n.identifiers[0].coords){const s=this.$refs.scaffoldContainer.getBoundingClientRect();this.tData.x=n.identifiers[0].coords.x-s.left,this.tData.y=n.identifiers[0].coords.y-s.top}this.createEditTemporaryLines(n.identifiers)}}},getCoordinatesOfSelected:function(){if(this.selectedObjects&&this.selectedObjects.length>0)return this.$module.scene.getObjectsScreenXY(this.selectedObjects)},getDynamicSelectedCoordinates:function(){return this.$module.selectedScreenCoordinates},timeChange:function(n){let e=n/this.timeMax*100;e!=this.currentTime&&this.$module.updateTime(e)},updatePrimitiveControls:function(n){this.selectedObjects=n,this.selectedObjects&&this.selectedObjects.length>0?this.$refs.primitiveControls.setObject(this.selectedObjects[0]):this.$refs.primitiveControls.setObject(void 0)},objectSelected:function(n,e){this.updatePrimitiveControls(n),this.$module.setSelectedByZincObjects(n,void 0,{},e)},objectHovered:function(n,e){this.hoveredObjects=n,this.$module.setHighlightedByZincObjects(n,void 0,{},e)},changeActiveByName:function(n,e,t){const i=Array.isArray(n);if(n===void 0||i&&n.length===0)this.$refs.scaffoldTreeControls.removeActive(t);else{let r=n;i||(r=[r]),this.$refs.scaffoldTreeControls.changeActiveByNames(r,e,t)}},changeHighlightedByName:function(n,e,t){const i=Array.isArray(n);if(n===void 0||i&&n.length===0)this.$refs.scaffoldTreeControls.removeHover(t);else{let r=n;i||(r=[r]),this.$refs.scaffoldTreeControls.changeHoverByNames(r,e,t)}},play:function(n){this.$module.playAnimation(n),this.isPlaying=n},setHelpMode:function(n){const e=this.hoverVisibilities.length,t=e-1,i=this.hoverVisibilities[this.helpModeActiveIndex];if(i){const r=i==null?void 0:i.refs,s=i==null?void 0:i.ref;this.$refs[r||s]||(this.helpModeActiveIndex+=1)}n||(this.helpModeActiveIndex=this.helpModeInitialIndex),n&&this.helpModeActiveIndex>=t&&this.$emit("help-mode-last-item",!0),n&&!this.helpModeDialog?(this.inHelp=!0,this.hoverVisibilities.forEach(r=>{r.value=!0})):n&&this.helpModeDialog&&e>this.helpModeActiveIndex?this.helpModeActiveIndex>-1&&setTimeout(()=>{this.inHelp=!1,this.hoverVisibilities.forEach(r=>{r.value=!1}),this.showHelpText(this.helpModeActiveIndex,200)},300):(this.inHelp=!1,this.hoverVisibilities.forEach(r=>{r.value=!1}))},displayTooltipOfObjectsCallback:function(n,e,t,i,r){const s=this;return function(){s.$module.zincRenderer.removePostRenderCallbackFunction(s.$_regionTooltipCallback),s.$_regionTooltipCallback=void 0,s.displayTooltipOfObjects(n,e,t,i,r)}},liveUpdateTooltipPosition:function(){this.$module.selectedCenter&&(this.tData.x=this.$module.selectedScreenCoordinates.x,this.tData.y=this.$module.selectedScreenCoordinates.y)},displayTooltipOfObjects:function(n,e,t,i,r){if(e.length>0){let s=e[0].getClosestVertexDOMElementCoords(this.$module.scene);if(s)return s.inView?(n.includes("Search Results for")?this.tData.active=!1:this.tData.active=!0,this.tData.visible=!0,this.tData.label=n,this.tData.x=s.position.x,this.tData.y=s.position.y,this.tData.region=t,this.$_liveCoordinatesUpdated&&this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_liveCoordinatesUpdated),r&&(this.$module.setupLiveCoordinates(e),this.$_liveCoordinatesUpdated=this.$module.zincRenderer.addPostRenderCallbackFunction(this.liveUpdateTooltipPosition))):(this.hideRegionTooltip(),i&&(this.$module.scene.viewAll(),this.$_regionTooltipCallback&&this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_regionTooltipCallback),this.$_regionTooltipCallback=this.$module.zincRenderer.addPostRenderCallbackFunction(this.displayTooltipOfObjectsCallback(n,e,t,i,r)))),!0}return this.hideRegionTooltip(),!1},showRegionTooltipWithObjects:function(n,e,t,i,r){return n&&e&&e.length>0&&this.$module.scene?this.displayTooltipOfObjects(n,e,t,i,r):(this.hideRegionTooltip(),!1)},showRegionTooltip:function(n,e,t){if(n&&this.$module.scene){const i=this.$module.scene.getRootRegion(),s=Lo(i,[n],"",!0);let o;return s&&s.length>0&&(o=s[0].getRegion().getFullPath()),this.showRegionTooltipWithObjects(n,s,o,e,t)}return this.hideRegionTooltip(),!1},showRegionTooltipWithAnnotations:function(n,e,t){if(this.$module.scene){const i=Cx(this.$module.scene,n);if(i&&i.objects.length>0)if(this.annotationSidebar){const s={featureId:(this.tData.region?this.tData.region+"/":"")+this.tData.label,resourceId:this.url,resource:this.url};this.$emit("annotation-open",{annotationEntry:s,createData:this.createData,confirmCreate:this.confirmCreate,cancelCreate:this.cancelCreate,confirmDelete:this.confirmDelete});return}else return this.showRegionTooltipWithObjects(i.label,i.objects,i.regionPath,e,t)}return this.hideRegionTooltip(),!1},changeViewingMode:function(n){if(this.$module){if(n&&(this.viewingMode=n),this.viewingMode==="Annotation"){let e=!1;this.userInformation&&(e=!0),this.userInformation=void 0,this.annotator.authenticate(this.userToken).then(t=>{t.name&&t.email&&t.canUpdate&&(this.userInformation=t,e||(Lx(this.annotator,this.userToken,this.url).then(i=>{i&&i.features&&Of(this.$module.scene,i.features)}),Lx(this.annotator,this.userToken,encodeURIComponent(this.url)).then(i=>{i&&i.features&&Of(this.$module.scene,i.features)})))})}else this.viewingMode==="Exploration"&&(this.activeDrawTool=void 0,this.activeDrawMode=void 0,this.createData.shape="");this.viewingMode==="Exploration"||this.viewingMode==="Annotation"&&this.createData.shape===""?this.$module.selectObjectOnPick=!0:this.$module.selectObjectOnPick=!1,this.cancelCreate()}},hideRegionTooltip:function(){this.$_liveCoordinatesUpdated&&(this.$module.zincRenderer.removePostRenderCallbackFunction(this.$_liveCoordinatesUpdated),this.$module.setupLiveCoordinates(void 0)),this.tData.active=!1,this.tData.visible=!1,this.tData.region=void 0},setMarkerModeForObjectsWithName:function(n,e,t){if(n&&this.$module.scene){let i=e;typeof e=="number"&&(i={number:e,imgURL:void 0});const r=this.$module.scene.getRootRegion();Lo(r,[n],"",!0).forEach(l=>l.setMarkerMode(t,i))}},setMarkerModeWithAnnotations:function(n,e){if(this.$module.scene){const t=Cx(this.$module.scene,n);t&&t.objects.length>0&&t.objects.forEach(i=>i.setMarkerMode(e))}},showHelpText:function(n,e=500){this.inHelp||(clearTimeout(this.helpTextWait[n]),this.helpTextWait[n]=setTimeout(()=>{this.hoverVisibilities[n].value=!0,this.$emit("shown-tooltip")},e))},hideHelpText:function(n,e=500){this.inHelp||(clearTimeout(this.helpTextWait[n]),this.helpTextWait[n]=setTimeout(()=>{this.hoverVisibilities[n].value=!1},e))},search:function(n,e){if(this.$_searchIndex){if(n===void 0||n===""||Array.isArray(n)&&n.length===0)return this.lastSelected.region="",this.lastSelected.group="",this.lastSelected.isSearch=!0,this.objectSelected([],!0),!1;{this.lastSelected.region="",this.lastSelected.group=n,this.lastSelected.isSearch=!0;const t=this.$_searchIndex.searchAndProcessResult(n),i=t.zincObjects;if(i.length>0){if(this.objectSelected(i,!0),e)for(let r=0;r<i.length;r++)i[r]&&i[r].groupName&&this.showRegionTooltipWithObjects(t.label,i,t.regionPath,!0,!0);return!0}else this.objectSelected([],!0)}}return!1},fetchSuggestions:function(n){return this.$_searchIndex===void 0?[]:this.$_searchIndex.auto_suggest(n)},updateMinimapScissor:function(){Object.keys(this.minimapSettings).forEach(n=>{this.$module.scene.minimapScissor[n]=this.minimapSettings[n]}),this.$module.scene.minimapScissor.updateRequired=!0},updateSettingsfromScene:function(){this.currentSpeed=1,this.$module.setPlayRate(this.defaultRate),this.orginalDuration=this.$module.scene.getMetadataTag("OriginalDuration"),this.animateDuration=this.$module.scene.getMetadataTag("Duration");let n=this.$module.scene.getMetadataTag("TimeStamps");this.timeStamps={};for(const e in n)this.timeStamps[n[e]]=e;this.timeMax=this.$module.scene.getDuration()},restoreSettings:function(n){if(n){if(n.viewport)this.$module.scene.getZincCameraControls().setCurrentCameraSettings(n.viewport);else if(n.viewURL&&n.viewURL!==""){const t=new URL(n.viewURL,this.url);this.$module.scene.loadViewURL(t)}else n.region&&n.region!==""&&this.viewRegion(n.region);n.visibility&&this.$nextTick(()=>{this.$refs.scaffoldTreeControls.setState(n.visibility)}),n.background&&this.backgroundChangeCallback(n.background),n.viewingMode&&this.changeViewingMode(n.viewingMode);const e=n.search;e&&e.group&&(e.isSearch?this.search(e.group,!0):this.changeActiveByName(e.group,e.region,!0))}},setURLFinishCallback:function(n){return()=>{this.localAnnotationsList.length=0,this.updateSettingsfromScene(),this.$module.updateTime(.01),this.$module.updateTime(0),this.$module.unsetFinishDownloadCallback(),this.addRegionsToSearchIndex(),this.$emit("on-ready"),this.setMarkers(),this._boundingBoxGeo=this.$module.scene.addBoundingBoxPrimitive("_helper","boundingBox",4251856,.15),this._slides=this.$module.scene.addSlicesPrimitive("_helper",["x-plane","y-plane","z-plane"],[16733525,5635925,5592575],.5);const{centre:e,size:t}=this.$module.getCentreAndSize();this.boundingDims.centre=e,this.boundingDims.size=t,this.$nextTick(()=>this.restoreSettings(n)),this.isReady=!0}},getState:function(){let n={format:this.fileFormat,url:this._currentURL,viewport:void 0,visibility:void 0,background:this.currentBackground,viewingMode:this.viewingMode};if(this.$refs.scaffoldTreeControls&&(n.visibility=this.$refs.scaffoldTreeControls.getState()),this.$module.scene){let e=this.$module.scene.getZincCameraControls();n.viewport=e.getCurrentViewport()}return this.lastSelected&&this.lastSelected.group&&(n.search={...this.lastSelected}),n},setState:function(n){n&&(n.url&&n.url!==this._currentURL?this.setURLAndState(n.url,{fileFormat:n.fileFormat,viewport:n.viewport,visibility:n.visibility,background:n.background,viewingMode:this.viewingMode,search:n.search}):(n.background||n.search||n.viewport||n.viewingMode||n.visibility)&&(this.isReady&&this.$module.scene?this.restoreSettings(n):this.$module.setFinishDownloadCallback(this.setURLFinishCallback({background:n.background,viewingMode:n.viewingMode,viewport:n.viewport,visibility:n.visibility,search:n.search}))))},exportGLTF:function(n){return this.$module.scene.exportGLTF(n)},getLocalAnnotations:function(){return[...this.localAnnotationsList]},importLocalAnnotations:function(n){if(this.enableLocalAnnotations){n.forEach(t=>{const i=t.group,r=t.region;let s=r.slice(-1)==="/"?r:r+"/";const o=s.slice(0,-1);t.region=o,s=s+i;const l=s;t.item.id=l,t.feature.id=l});const e=n.map(t=>t.feature);Of(this.$module.scene,e),n.forEach(t=>{this.localAnnotationsList.push({...t})})}},setURLAndState:function(n,e){n!=this._currentURL&&(e!=null&&e.format&&(this.fileFormat=e.format),this._currentURL=n,this.$refs.scaffoldTreeControls&&this.$refs.scaffoldTreeControls.clear(),this.loading=!0,this.timeVarying=!1,this.isReady=!1,this.$_searchIndex.removeAll(),this.hideRegionTooltip(),this.$module.setFinishDownloadCallback(this.setURLFinishCallback({background:e==null?void 0:e.background,region:this.region,search:e==null?void 0:e.search,viewingMode:e==null?void 0:e.viewingMode,viewURL:this.viewURL,viewport:e==null?void 0:e.viewport,visibility:e==null?void 0:e.visibility})),this.fileFormat==="gltf"?this.$module.loadGLTFFromURL(n,"scene",!0):this.$module.loadOrgansFromURL(n,void 0,void 0,"scene",void 0,!0),this.$module&&this.$module.scene&&(this.$module.scene.displayMarkers=this.displayMarkers,this.$module.scene.forcePickableObjectsUpdate=!0,this.$module.scene.displayMinimap=this.displayMinimap,this.updateMinimapScissor()))},setURL:function(n){this.setURLAndState(n,void 0)},drawerToggled:function(n){this.drawerOpen=n,this.adjustLayout()},adjustLayout:function(){if(this.$refs.scaffoldContainer){let n=this.$refs.scaffoldContainer.clientWidth;this.minimisedSlider=n<812,this.minimisedSlider?this.sliderPosition=this.drawerOpen?"right":"left":this.sliderPosition=""}},toggleRendering:function(n){this.$module.zincRenderer&&(n?this.$module.zincRenderer.animate():this.$module.zincRenderer.stopAnimate())},forceResize:function(){this.$module.zincRenderer&&this.$module.zincRenderer.onWindowResize()},syncControlCallback:function(){const n=this.$module.NDCCameraControl.getPanZoom();this.tData.visible&&this.showRegionTooltip(this.tData.label,!0,!0),this.$emit("scaffold-navigated",n)},toggleSyncControl:function(n,e){this.$module.toggleSyncControl(n,e),this.$module.setSyncControlCallback(this.syncControlCallback)},setMarkers:function(){for(const[n,e]of Object.entries(this.markerLabels))this.setMarkerModeForObjectsWithName(n,e,"on")}}},Qf=n=>(a.pushScopeId("data-v-421c0aa2"),n=n(),a.popScopeId(),n),fV={ref:"scaffoldContainer",class:"scaffold-container","element-loading-text":"Loading...","element-loading-background":"rgba(0, 0, 0, 0.3)"},pV=Qf(()=>a.createElementVNode("span",{class:"message-text"},"Beta",-1)),mV=Qf(()=>a.createElementVNode("span",{class:"message-text"},"What's new?",-1)),gV={class:"primitive-controls-box"},yV={class:"animation-data"},vV={class:"purple"},bV={class:"animation-data"},xV={class:"purple"},wV={class:"animation-data"},MV={class:"bottom-right-control"},SV=Qf(()=>a.createElementVNode("div",null,[a.createTextVNode(" Fit to "),a.createElementVNode("br"),a.createTextVNode(" window ")],-1)),_V={style:{"margin-bottom":"2px"}},TV={key:0,class:"viewing-mode-title"},EV=["onClick"],CV=["onClick"];function AV(n,e,t,i,r,s){const o=a.resolveComponent("map-svg-sprite-color"),l=jx,u=a.resolveComponent("DrawToolbar"),c=lm,f=yt,h=Pl,m=Bx,y=Dx,p=a.resolveComponent("map-svg-icon"),d=Ln,b=Qn,v=jg,g=Ls,M=As,_=Wg,E=Cs,S=pd;return a.withDirectives((a.openBlock(),a.createElementBlock("div",fV,[a.createVNode(o),a.createVNode(l,{createData:n.createData,label:n.tData.label,region:n.tData.region,visible:n.tData.visible,x:n.tData.x,y:n.tData.y,annotationDisplay:s.annotationDisplay,onConfirmCreate:e[0]||(e[0]=w=>s.confirmCreate(w)),onCancelCreate:e[1]||(e[1]=w=>s.cancelCreate()),onConfirmDelete:e[2]||(e[2]=w=>s.confirmDelete()),onTooltipHide:e[3]||(e[3]=w=>s.onTooltipHide())},null,8,["createData","label","region","visible","x","y","annotationDisplay"]),a.createElementVNode("div",{id:"organsDisplayArea",ref:"display",tabindex:"-1",style:{height:"100%",width:"100%"},onKeydown:e[4]||(e[4]=a.withKeys((...w)=>s.backgroundChangeCallback&&s.backgroundChangeCallback(...w),["66"]))},null,544),a.withDirectives(a.createElementVNode("div",null,[n.viewingMode==="Annotation"&&(n.userInformation||t.enableLocalAnnotations)?(a.openBlock(),a.createBlock(u,{key:0,toolbarOptions:n.toolbarOptions,activeDrawTool:n.activeDrawTool,activeDrawMode:n.activeDrawMode,hoverVisibilities:n.hoverVisibilities,onClickToolbar:s.toggleDrawing,onShowTooltip:s.showHelpText,onHideTooltip:s.hideHelpText,ref:"toolbarPopover"},null,8,["toolbarOptions","activeDrawTool","activeDrawMode","hoverVisibilities","onClickToolbar","onShowTooltip","onHideTooltip"])):a.createCommentVNode("",!0),t.displayWarning?(a.openBlock(),a.createBlock(h,{key:1,ref:"warningPopover",visible:n.hoverVisibilities[7].value,content:t.warningMessage,placement:"right",width:"max-content",teleported:!1,"popper-class":"scaffold-popper message-popper right-popper non-selectable"},{reference:a.withCtx(()=>[t.displayWarning?(a.openBlock(),a.createElementBlock("div",{key:0,class:"message-icon warning-icon",onMouseover:e[5]||(e[5]=w=>s.showHelpText(7)),onMouseout:e[6]||(e[6]=w=>s.hideHelpText(7))},[a.createVNode(f,null,{default:a.withCtx(()=>[a.createVNode(c)]),_:1}),pV],32)):a.createCommentVNode("",!0)]),_:1},8,["visible","content"])):a.createCommentVNode("",!0),t.displayLatestChanges?(a.openBlock(),a.createBlock(h,{key:2,visible:n.hoverVisibilities[8].value,content:t.latestChangesMessage,placement:"right",teleported:!1,trigger:"manual","popper-class":"scaffold-popper message-popper right-popper non-selectable",ref:"whatsNewPopover"},{reference:a.withCtx(()=>[t.displayLatestChanges&&t.latestChangesMessage?(a.openBlock(),a.createElementBlock("div",{key:0,class:"el-icon-warning message-icon latest-changesicon",onMouseover:e[7]||(e[7]=w=>s.showHelpText(8)),onMouseout:e[8]||(e[8]=w=>s.hideHelpText(8))},[a.createVNode(f,null,{default:a.withCtx(()=>[a.createVNode(c)]),_:1}),mV],32)):a.createCommentVNode("",!0)]),_:1},8,["visible","content"])):a.createCommentVNode("",!0),a.createVNode(h,{visible:n.hoverVisibilities[6].value,content:"Change region visibility",placement:"right",width:"max-content",teleported:!1,trigger:"manual","popper-class":"scaffold-popper right-popper non-selectable",ref:"regionVisibilityPopover"},{reference:a.withCtx(()=>[a.createVNode(m,{ref:"scaffoldTreeControls",isReady:n.isReady,"show-colour-picker":t.showColourPicker,onObjectSelected:s.objectSelected,onObjectHovered:s.objectHovered,onDrawerToggled:s.drawerToggled},null,8,["isReady","show-colour-picker","onObjectSelected","onObjectHovered","onDrawerToggled"])]),_:1},8,["visible"]),a.createElementVNode("div",gV,[a.createVNode(y,{ref:"primitiveControls",createData:n.createData,onPrimitivesUpdated:s.primitivesUpdated},null,8,["createData","onPrimitivesUpdated"])]),n.timeVarying?(a.openBlock(),a.createBlock(h,{key:3,ref:"sliderPopover",width:"max-content",visible:n.hoverVisibilities[5].value,content:"Move the slider to animate the region",placement:"top",teleported:!1,trigger:"manual","popper-class":"scaffold-popper top-popper non-selectable"},{reference:a.withCtx(()=>[n.timeVarying?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["time-slider-container",[n.minimisedSlider?"minimised":"",n.sliderPosition]])},[a.createVNode(_,{type:"card"},{default:a.withCtx(()=>[a.createVNode(v,{label:"Animate scaffold"},{default:a.withCtx(()=>[a.createVNode(b,{class:"tab-content"},{default:a.withCtx(()=>[n.isPlaying?(a.openBlock(),a.createBlock(p,{key:0,icon:"pause",class:"icon-button video-button",onClick:e[9]||(e[9]=w=>s.play(!1))})):(a.openBlock(),a.createBlock(p,{key:1,icon:"play",class:"video-button icon-button",onClick:e[10]||(e[10]=w=>s.play(!0))})),a.createVNode(d,{min:0,max:n.timeMax,"model-value":n.currentTime/100*n.timeMax,step:.1,"tooltip-class":"time-slider-tooltip",class:"slider","format-tooltip":s.formatTooltip,marks:n.timeStamps,onInput:e[11]||(e[11]=w=>s.timeChange(w))},null,8,["max","model-value","format-tooltip","marks"])]),_:1})]),_:1}),a.createVNode(v,{label:"Animation data"},{default:a.withCtx(()=>[a.createVNode(b,{class:"tab-content"},{default:a.withCtx(()=>[a.createElementVNode("div",yV,[a.createTextVNode(" Original duration: "),a.createElementVNode("div",vV,a.toDisplayString(n.orginalDuration),1)]),a.createElementVNode("div",bV,[a.createTextVNode(" Animation duration: "),a.createElementVNode("div",xV,a.toDisplayString(n.animateDuration),1)]),a.createElementVNode("div",wV,[a.createTextVNode(" Playback speed "),a.createVNode(M,{teleported:!0,"model-value":n.currentSpeed,placeholder:"Select",class:"scaffold-select-box speed","popper-class":"scaffold_viewer_dropdown",onChange:e[12]||(e[12]=w=>s.speedChanged(w))},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.playSpeed,w=>(a.openBlock(),a.createBlock(g,{key:w.value,label:w.label,value:w.value},null,8,["label","value"]))),128))]),_:1},8,["model-value"])])]),_:1})]),_:1})]),_:1})],2)):a.createCommentVNode("",!0)]),_:1},8,["visible"])):a.createCommentVNode("",!0),a.createElementVNode("div",MV,[a.createVNode(h,{visible:n.hoverVisibilities[0].value,content:"Zoom in",width:"max-content",placement:"left",teleported:!1,trigger:"manual","popper-class":"scaffold-popper left-popper non-selectable",ref:"zoomInPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{icon:"zoomIn",class:"icon-button zoomIn",onClick:e[13]||(e[13]=w=>s.zoomIn()),onMouseover:e[14]||(e[14]=w=>s.showHelpText(0)),onMouseout:e[15]||(e[15]=w=>s.hideHelpText(0))})]),_:1},8,["visible"]),a.createVNode(h,{visible:n.hoverVisibilities[1].value,content:"Zoom out",placement:"top-end",width:"max-content",teleported:!1,trigger:"manual","popper-class":"scaffold-popper popper-zoomout non-selectable",ref:"zoomOutPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{icon:"zoomOut",class:"icon-button zoomOut",onClick:e[16]||(e[16]=w=>s.zoomOut()),onMouseover:e[17]||(e[17]=w=>s.showHelpText(1)),onMouseout:e[18]||(e[18]=w=>s.hideHelpText(1))})]),_:1},8,["visible"]),a.createVNode(h,{visible:n.hoverVisibilities[2].value,placement:"top",teleported:!1,trigger:"manual",width:"max-content","popper-class":"scaffold-popper non-selectable",ref:"zoomFitPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{icon:"fitWindow",class:"icon-button fitWindow",onClick:e[19]||(e[19]=w=>s.fitWindow()),onMouseover:e[20]||(e[20]=w=>s.showHelpText(2)),onMouseout:e[21]||(e[21]=w=>s.hideHelpText(2))})]),default:a.withCtx(()=>[SV]),_:1},8,["visible"])]),n.openMapRef?(a.openBlock(),a.createBlock(h,{key:4,ref:"open-map-popover","virtual-ref":n.openMapRef,placement:"top-start",width:"128",teleported:!1,trigger:"click","popper-class":"open-map-popper","virtual-triggering":""},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.openMapOptions,w=>(a.openBlock(),a.createBlock(b,{key:w.key},{default:a.withCtx(()=>[a.createVNode(E,{type:"primary",plain:"",onClick:T=>n.$emit("open-map",w.key)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(w.display),1)]),_:2},1032,["onClick"])]),_:2},1024))),128))]),_:1},8,["virtual-ref"])):a.createCommentVNode("",!0),a.createVNode(h,{ref:"backgroundPopover","virtual-ref":n.backgroundIconRef,placement:"top-start",width:"128",teleported:!1,trigger:"click","popper-class":"background-popper non-selectable h-auto","virtual-triggering":""},{default:a.withCtx(()=>[a.createElementVNode("div",null,[a.createVNode(b,{class:"backgroundText"},{default:a.withCtx(()=>[a.createTextVNode("Viewing Mode")]),_:1}),a.createVNode(b,{class:"backgroundControl"},{default:a.withCtx(()=>[a.createElementVNode("div",_V,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.viewingModes,(w,T,C)=>(a.openBlock(),a.createElementBlock(a.Fragment,{key:T},[T===n.viewingMode?(a.openBlock(),a.createElementBlock("span",TV,[a.createElementVNode("b",null,a.toDisplayString(T),1)])):(a.openBlock(),a.createElementBlock("span",{key:1,class:"viewing-mode-unselected",onClick:R=>s.changeViewingMode(T)},a.toDisplayString(T),9,EV))],64))),128))]),a.createVNode(b,{class:"viewing-mode-description"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(n.viewingModes[n.viewingMode]),1)]),_:1})]),_:1}),a.createVNode(b,{class:"backgroundSpacer"}),a.createVNode(b,{class:"backgroundText"},{default:a.withCtx(()=>[a.createTextVNode(" Change background ")]),_:1}),a.createVNode(b,{class:"backgroundChooser"},{default:a.withCtx(()=>[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.availableBackground,w=>(a.openBlock(),a.createElementBlock("div",{key:w,class:a.normalizeClass(["backgroundChoice",w,w==n.currentBackground?"active":""]),onClick:T=>s.backgroundChangeCallback(w)},null,10,CV))),128))]),_:1})])]),_:1},8,["virtual-ref"]),a.createElementVNode("div",{class:a.normalizeClass(["settings-group",{open:n.drawerOpen,close:!n.drawerOpen}])},[a.createVNode(b,null,{default:a.withCtx(()=>[a.createVNode(h,{visible:n.hoverVisibilities[3].value,content:"Open new map",placement:"right",teleported:!1,trigger:"manual",width:"max-content","popper-class":"scaffold-popper right-popper non-selectable",ref:"openMapPopover"},{reference:a.withCtx(()=>[t.enableOpenMapUI&&t.openMapOptions.length>0?(a.openBlock(),a.createBlock(p,{key:0,ref:"openMapRef",icon:"openMap",class:"icon-button open-map-button",onMouseover:e[22]||(e[22]=w=>s.showHelpText(3)),onMouseout:e[23]||(e[23]=w=>s.hideHelpText(3))},null,512)):a.createCommentVNode("",!0)]),_:1},8,["visible"])]),_:1}),a.createVNode(b,null,{default:a.withCtx(()=>[a.createVNode(h,{visible:n.hoverVisibilities[4].value,content:"Change background color",placement:"right",width:"max-content",teleported:!1,trigger:"manual","popper-class":"scaffold-popper right-popper non-selectable",ref:"settingsPopover"},{reference:a.withCtx(()=>[a.createVNode(p,{ref:"backgroundIconRef",icon:"changeBckgd",class:"icon-button",onMouseover:e[24]||(e[24]=w=>s.showHelpText(4)),onMouseout:e[25]||(e[25]=w=>s.hideHelpText(4))},null,512)]),_:1},8,["visible"])]),_:1})],2)],512),[[a.vShow,t.displayUI&&!n.isTransitioning]])])),[[S,n.loading]])}const LV=ki(hV,[["render",AV],["__scopeId","data-v-421c0aa2"]]);Zt.ScaffoldVuer=LV,Object.defineProperty(Zt,Symbol.toStringTag,{value:"Module"})});