@abi-software/scaffoldvuer 2.0.0 → 2.0.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.
@@ -552,11 +552,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
552
552
  `),d=`${this.fontWeight} ${this.fontSize}px ${this.fontFace}`;n.font=d;var f=Math.max.apply(Math,NY(u.map(function(e){return n.measureText(e).width}))),p=this.fontSize*u.length,m=f+a[0]*2+c[0]*2,h=p+a[1]*2+c[1]*2;if(t.width=m+Math.abs(l[0]),t.height=h+Math.abs(l[1]),n.translate.apply(n,NY(l.map(function(e){return Math.max(0,e)}))),this.borderWidth){if(n.strokeStyle=this.borderColor,a[0]){var g=a[0]/2;n.lineWidth=a[0],n.beginPath(),n.moveTo(g,o[0]),n.lineTo(g,h-o[3]),n.moveTo(m-g,o[1]),n.lineTo(m-g,h-o[2]),n.stroke()}if(a[1]){var _=a[1]/2;n.lineWidth=a[1],n.beginPath(),n.moveTo(Math.max(a[0],o[0]),_),n.lineTo(m-Math.max(a[0],o[1]),_),n.moveTo(Math.max(a[0],o[3]),h-_),n.lineTo(m-Math.max(a[0],o[2]),h-_),n.stroke()}if(this.borderRadius){var v=Math.max.apply(Math,NY(a)),y=v/2;n.lineWidth=v,n.beginPath(),[!!o[0]&&[o[0],y,y,o[0]],!!o[1]&&[m-o[1],m-y,y,o[1]],!!o[2]&&[m-o[2],m-y,h-y,h-o[2]],!!o[3]&&[o[3],y,h-y,h-o[3]]].filter(function(e){return e}).forEach(function(e){var t=MY(e,4),r=t[0],i=t[1],a=t[2],o=t[3];n.moveTo(r,a),n.quadraticCurveTo(i,a,i,o)}),n.stroke()}}this.backgroundColor&&(n.fillStyle=this.backgroundColor,this.borderRadius?(n.beginPath(),n.moveTo(a[0],o[0]),[[a[0],o[0],m-o[1],a[1],a[1],a[1]],[m-a[0],m-a[0],m-a[0],a[1],o[1],h-o[2]],[m-a[0],m-o[2],o[3],h-a[1],h-a[1],h-a[1]],[a[0],a[0],a[0],h-a[1],h-o[3],o[0]]].forEach(function(e){var t=MY(e,6),r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5];n.quadraticCurveTo(r,o,i,s),n.lineTo(a,c)}),n.closePath(),n.fill()):n.fillRect(a[0],a[1],m-a[0]*2,h-a[1]*2)),n.translate.apply(n,NY(a)),n.translate.apply(n,NY(c)),n.font=d,n.fillStyle=this.color,n.textBaseline=`bottom`;var b=this.strokeWidth>0;b&&(n.lineWidth=this.strokeWidth*this.fontSize/10,n.strokeStyle=this.strokeColor),u.forEach(function(t,r){var i=(f-n.measureText(t).width)/2,a=(r+1)*e.fontSize;b&&n.strokeText(t,i,a),n.fillText(t,i,a)}),this.material.map&&this.material.map.dispose();var x=this.material.map=new FY.CanvasTexture(t);x.colorSpace=FY.SRGBColorSpace;var S=this.textHeight*u.length+i[1]*2+s[1]*2+Math.abs(this.offsetY);this.scale.set(S*t.width/t.height,S,0)}},{key:`clone`,value:function(){return new this.constructor(this.text,this.textHeight,this.color).copy(this)}},{key:`copy`,value:function(e){return FY.Sprite.prototype.copy.call(this,e),this.color=e.color,this.backgroundColor=e.backgroundColor,this.padding=e.padding,this.borderWidth=e.borderWidth,this.borderColor=e.borderColor,this.offsetX=e.offsetX,this.offsetY=e.offsetY,this.fontFace=e.fontFace,this.fontSize=e.fontSize,this.fontWeight=e.fontWeight,this.strokeWidth=e.strokeWidth,this.strokeColor=e.strokeColor,this}}])}(FY.Sprite)})),Oue=h({BRDF_GGX:()=>LY,BRDF_Lambert:()=>RY,BasicPointShadowFilter:()=>zY,BasicShadowFilter:()=>BY,Break:()=>VY,Const:()=>HY,Continue:()=>UY,DFGLUT:()=>WY,D_GGX:()=>GY,Discard:()=>KY,EPSILON:()=>qY,F_Schlick:()=>JY,Fn:()=>YY,HALF_PI:()=>cX,INFINITY:()=>XY,If:()=>ZY,Loop:()=>QY,NodeAccess:()=>$Y,NodeShaderStage:()=>eX,NodeType:()=>tX,NodeUpdateType:()=>nX,OnBeforeMaterialUpdate:()=>p4,OnBeforeObjectUpdate:()=>f4,OnMaterialUpdate:()=>h4,OnObjectUpdate:()=>m4,PCFShadowFilter:()=>rX,PCFSoftShadowFilter:()=>iX,PI:()=>aX,PI2:()=>oX,PointShadowFilter:()=>lX,Return:()=>uX,Schlick_to_F0:()=>dX,ShaderNode:()=>fX,Stack:()=>pX,Switch:()=>mX,TBNViewMatrix:()=>hX,TWO_PI:()=>sX,VSMShadowFilter:()=>gX,V_GGX_SmithCorrelated:()=>_X,Var:()=>vX,VarIntent:()=>yX,abs:()=>bX,acesFilmicToneMapping:()=>xX,acos:()=>SX,acosh:()=>CX,add:()=>wX,addMethodChaining:()=>TX,addNodeElement:()=>EX,agxToneMapping:()=>DX,all:()=>OX,alphaT:()=>kX,ambientOcclusion:()=>AX,and:()=>jX,anisotropy:()=>MX,anisotropyB:()=>NX,anisotropyT:()=>PX,any:()=>FX,append:()=>IX,array:()=>LX,asin:()=>RX,asinh:()=>zX,assign:()=>BX,atan:()=>VX,atanh:()=>HX,atomicAdd:()=>UX,atomicAnd:()=>WX,atomicFunc:()=>GX,atomicLoad:()=>KX,atomicMax:()=>qX,atomicMin:()=>JX,atomicOr:()=>YX,atomicStore:()=>XX,atomicSub:()=>ZX,atomicXor:()=>QX,attenuationColor:()=>$X,attenuationDistance:()=>eZ,attribute:()=>tZ,attributeArray:()=>nZ,backgroundBlurriness:()=>rZ,backgroundIntensity:()=>iZ,backgroundRotation:()=>aZ,batch:()=>oZ,bentNormalView:()=>sZ,billboarding:()=>cZ,bitAnd:()=>lZ,bitNot:()=>uZ,bitOr:()=>dZ,bitXor:()=>fZ,bitangentGeometry:()=>pZ,bitangentLocal:()=>mZ,bitangentView:()=>hZ,bitangentWorld:()=>gZ,bitcast:()=>_Z,blendBurn:()=>vZ,blendColor:()=>yZ,blendDodge:()=>bZ,blendOverlay:()=>xZ,blendScreen:()=>SZ,blur:()=>CZ,bool:()=>wZ,buffer:()=>TZ,bufferAttribute:()=>EZ,builtin:()=>OZ,builtinAOContext:()=>kZ,builtinShadowContext:()=>AZ,bumpMap:()=>DZ,bvec2:()=>jZ,bvec3:()=>MZ,bvec4:()=>NZ,bypass:()=>PZ,cache:()=>FZ,call:()=>IZ,cameraFar:()=>LZ,cameraIndex:()=>RZ,cameraNear:()=>zZ,cameraNormalMatrix:()=>BZ,cameraPosition:()=>VZ,cameraProjectionMatrix:()=>HZ,cameraProjectionMatrixInverse:()=>UZ,cameraViewMatrix:()=>WZ,cameraViewport:()=>GZ,cameraWorldMatrix:()=>KZ,cbrt:()=>qZ,cdl:()=>JZ,ceil:()=>YZ,checker:()=>XZ,cineonToneMapping:()=>ZZ,clamp:()=>QZ,clearcoat:()=>$Z,clearcoatNormalView:()=>eQ,clearcoatRoughness:()=>tQ,clipSpace:()=>nQ,code:()=>rQ,color:()=>iQ,colorSpaceToWorking:()=>aQ,colorToDirection:()=>oQ,compute:()=>sQ,computeKernel:()=>cQ,computeSkinning:()=>lQ,context:()=>uQ,convert:()=>dQ,convertColorSpace:()=>fQ,convertToTexture:()=>pQ,cos:()=>_Q,cosh:()=>vQ,countLeadingZeros:()=>mQ,countOneBits:()=>hQ,countTrailingZeros:()=>gQ,cross:()=>yQ,cubeTexture:()=>bQ,cubeTextureBase:()=>xQ,dFdx:()=>SQ,dFdy:()=>CQ,dashSize:()=>wQ,debug:()=>TQ,decrement:()=>EQ,decrementBefore:()=>DQ,defaultBuildStages:()=>OQ,defaultShaderStages:()=>kQ,defined:()=>AQ,degrees:()=>jQ,deltaTime:()=>MQ,densityFog:()=>NQ,densityFogFactor:()=>PQ,depth:()=>FQ,depthPass:()=>IQ,determinant:()=>LQ,difference:()=>RQ,diffuseColor:()=>zQ,directPointLight:()=>BQ,directionToColor:()=>VQ,directionToFaceDirection:()=>HQ,dispersion:()=>UQ,distance:()=>WQ,div:()=>GQ,dot:()=>KQ,drawIndex:()=>qQ,dynamicBufferAttribute:()=>JQ,element:()=>YQ,emissive:()=>XQ,equal:()=>ZQ,equirectDirection:()=>QQ,equirectUV:()=>$Q,exp:()=>e$,exp2:()=>t$,exponentialHeightFogFactor:()=>n$,expression:()=>r$,faceDirection:()=>i$,faceForward:()=>a$,faceforward:()=>o$,float:()=>s$,floatBitsToInt:()=>c$,floatBitsToUint:()=>l$,floor:()=>u$,fog:()=>d$,fract:()=>f$,frameGroup:()=>p$,frameId:()=>m$,frontFacing:()=>h$,fwidth:()=>g$,gain:()=>_$,gapSize:()=>v$,getConstNodeType:()=>y$,getCurrentStack:()=>b$,getDirection:()=>x$,getDistanceAttenuation:()=>S$,getGeometryRoughness:()=>C$,getNormalFromDepth:()=>w$,getParallaxCorrectNormal:()=>D$,getRoughness:()=>O$,getScreenPosition:()=>k$,getShIrradianceAt:()=>A$,getShadowMaterial:()=>j$,getShadowRenderObjectFunction:()=>M$,getTextureIndex:()=>N$,getViewPosition:()=>P$,globalId:()=>F$,glsl:()=>I$,glslFn:()=>L$,grayscale:()=>R$,greaterThan:()=>z$,greaterThanEqual:()=>B$,hash:()=>V$,highpModelNormalViewMatrix:()=>H$,highpModelViewMatrix:()=>U$,hue:()=>W$,increment:()=>G$,incrementBefore:()=>K$,instance:()=>q$,instanceIndex:()=>J$,instancedArray:()=>Y$,instancedBufferAttribute:()=>X$,instancedDynamicBufferAttribute:()=>Z$,instancedMesh:()=>Q$,int:()=>e1,intBitsToFloat:()=>t1,interleavedGradientNoise:()=>T$,inverse:()=>n1,inverseSqrt:()=>r1,inversesqrt:()=>i1,invocationLocalIndex:()=>a1,invocationSubgroupIndex:()=>o1,ior:()=>s1,iridescence:()=>c1,iridescenceIOR:()=>l1,iridescenceThickness:()=>u1,ivec2:()=>d1,ivec3:()=>f1,ivec4:()=>p1,js:()=>m1,label:()=>h1,length:()=>g1,lengthSq:()=>_1,lessThan:()=>v1,lessThanEqual:()=>y1,lightPosition:()=>b1,lightProjectionUV:()=>x1,lightShadowMatrix:()=>S1,lightTargetDirection:()=>C1,lightTargetPosition:()=>w1,lightViewPosition:()=>T1,lightingContext:()=>E1,lights:()=>D1,linearDepth:()=>O1,linearToneMapping:()=>k1,localId:()=>A1,log:()=>j1,log2:()=>M1,logarithmicDepthToViewZ:()=>N1,luminance:()=>P1,mat2:()=>F1,mat3:()=>I1,mat4:()=>L1,matcapUV:()=>R1,materialAO:()=>z1,materialAlphaTest:()=>B1,materialAnisotropy:()=>V1,materialAnisotropyVector:()=>H1,materialAttenuationColor:()=>U1,materialAttenuationDistance:()=>W1,materialClearcoat:()=>G1,materialClearcoatNormal:()=>K1,materialClearcoatRoughness:()=>q1,materialColor:()=>J1,materialDispersion:()=>Y1,materialEmissive:()=>X1,materialEnvIntensity:()=>Z1,materialEnvRotation:()=>Q1,materialIOR:()=>$1,materialIridescence:()=>e0,materialIridescenceIOR:()=>t0,materialIridescenceThickness:()=>n0,materialLightMap:()=>r0,materialLineDashOffset:()=>i0,materialLineDashSize:()=>a0,materialLineGapSize:()=>o0,materialLineScale:()=>s0,materialLineWidth:()=>c0,materialMetalness:()=>l0,materialNormal:()=>u0,materialOpacity:()=>d0,materialPointSize:()=>f0,materialReference:()=>p0,materialReflectivity:()=>m0,materialRefractionRatio:()=>h0,materialRotation:()=>g0,materialRoughness:()=>_0,materialSheen:()=>v0,materialSheenRoughness:()=>y0,materialShininess:()=>b0,materialSpecular:()=>x0,materialSpecularColor:()=>S0,materialSpecularIntensity:()=>C0,materialSpecularStrength:()=>w0,materialThickness:()=>T0,materialTransmission:()=>E0,max:()=>D0,maxMipLevel:()=>O0,mediumpModelViewMatrix:()=>k0,metalness:()=>A0,min:()=>j0,mix:()=>M0,mixElement:()=>N0,mod:()=>P0,modelDirection:()=>F0,modelNormalMatrix:()=>I0,modelPosition:()=>L0,modelRadius:()=>R0,modelScale:()=>z0,modelViewMatrix:()=>B0,modelViewPosition:()=>V0,modelViewProjection:()=>H0,modelWorldMatrix:()=>U0,modelWorldMatrixInverse:()=>W0,morphReference:()=>G0,mrt:()=>K0,mul:()=>q0,mx_aastep:()=>J0,mx_add:()=>Y0,mx_atan2:()=>X0,mx_cell_noise_float:()=>Z0,mx_contrast:()=>Q0,mx_divide:()=>$0,mx_fractal_noise_float:()=>e2,mx_fractal_noise_vec2:()=>t2,mx_fractal_noise_vec3:()=>n2,mx_fractal_noise_vec4:()=>r2,mx_frame:()=>i2,mx_heighttonormal:()=>a2,mx_hsvtorgb:()=>o2,mx_ifequal:()=>s2,mx_ifgreater:()=>c2,mx_ifgreatereq:()=>l2,mx_invert:()=>u2,mx_modulo:()=>d2,mx_multiply:()=>f2,mx_noise_float:()=>p2,mx_noise_vec3:()=>m2,mx_noise_vec4:()=>h2,mx_place2d:()=>g2,mx_power:()=>_2,mx_ramp4:()=>v2,mx_ramplr:()=>y2,mx_ramptb:()=>b2,mx_rgbtohsv:()=>x2,mx_rotate2d:()=>S2,mx_rotate3d:()=>C2,mx_safepower:()=>w2,mx_separate:()=>T2,mx_splitlr:()=>E2,mx_splittb:()=>D2,mx_srgb_texture_to_lin_rec709:()=>O2,mx_subtract:()=>k2,mx_timer:()=>A2,mx_transform_uv:()=>j2,mx_unifiednoise2d:()=>M2,mx_unifiednoise3d:()=>N2,mx_worley_noise_float:()=>P2,mx_worley_noise_vec2:()=>F2,mx_worley_noise_vec3:()=>I2,negate:()=>L2,negateOnBackSide:()=>R2,neutralToneMapping:()=>z2,nodeArray:()=>B2,nodeImmutable:()=>V2,nodeObject:()=>H2,nodeObjectIntent:()=>U2,nodeObjects:()=>W2,nodeProxy:()=>G2,nodeProxyIntent:()=>K2,normalFlat:()=>q2,normalGeometry:()=>J2,normalLocal:()=>Y2,normalMap:()=>X2,normalView:()=>Z2,normalViewGeometry:()=>Q2,normalWorld:()=>$2,normalWorldGeometry:()=>e4,normalize:()=>t4,not:()=>n4,notEqual:()=>r4,numWorkgroups:()=>i4,objectDirection:()=>a4,objectGroup:()=>o4,objectPosition:()=>s4,objectRadius:()=>c4,objectScale:()=>l4,objectViewPosition:()=>u4,objectWorldMatrix:()=>d4,oneMinus:()=>g4,or:()=>_4,orthographicDepthToViewZ:()=>v4,oscSawtooth:()=>y4,oscSine:()=>b4,oscSquare:()=>x4,oscTriangle:()=>S4,output:()=>C4,outputStruct:()=>w4,overloadingFn:()=>T4,overrideNode:()=>E4,overrideNodes:()=>D4,packHalf2x16:()=>O4,packNormalToRGB:()=>j4,packSnorm2x16:()=>k4,packUnorm2x16:()=>A4,parabola:()=>M4,parallaxDirection:()=>N4,parallaxUV:()=>P4,parameter:()=>F4,pass:()=>I4,passTexture:()=>L4,pcurve:()=>R4,perspectiveDepthToViewZ:()=>z4,pmremTexture:()=>B4,pointShadow:()=>V4,pointUV:()=>H4,pointWidth:()=>U4,positionGeometry:()=>W4,positionLocal:()=>G4,positionPrevious:()=>K4,positionView:()=>q4,positionViewDirection:()=>J4,positionWorld:()=>Y4,positionWorldDirection:()=>X4,posterize:()=>Z4,pow:()=>Q4,pow2:()=>$4,pow3:()=>e3,pow4:()=>t3,premultiplyAlpha:()=>n3,property:()=>r3,radians:()=>i3,rand:()=>a3,range:()=>o3,rangeFog:()=>s3,rangeFogFactor:()=>c3,reciprocal:()=>l3,reference:()=>u3,referenceBuffer:()=>d3,reflect:()=>f3,reflectVector:()=>p3,reflectView:()=>m3,reflector:()=>h3,refract:()=>g3,refractVector:()=>_3,refractView:()=>v3,reinhardToneMapping:()=>y3,remap:()=>b3,remapClamp:()=>x3,renderGroup:()=>S3,renderOutput:()=>C3,rendererReference:()=>w3,replaceDefaultUV:()=>T3,rotate:()=>E3,rotateUV:()=>D3,roughness:()=>O3,round:()=>k3,rtt:()=>A3,sRGBTransferEOTF:()=>j3,sRGBTransferOETF:()=>M3,sample:()=>N3,sampler:()=>P3,samplerComparison:()=>F3,saturate:()=>I3,saturation:()=>L3,screen:()=>R3,screenCoordinate:()=>z3,screenDPR:()=>B3,screenSize:()=>V3,screenUV:()=>H3,select:()=>U3,setCurrentStack:()=>W3,setName:()=>G3,shaderStages:()=>K3,shadow:()=>q3,shadowPositionWorld:()=>J3,shapeCircle:()=>Y3,sharedUniformGroup:()=>X3,sheen:()=>Z3,sheenRoughness:()=>Q3,shiftLeft:()=>$3,shiftRight:()=>e6,shininess:()=>t6,sign:()=>n6,sin:()=>r6,sinc:()=>a6,sinh:()=>i6,skinning:()=>o6,smoothstep:()=>s6,smoothstepElement:()=>c6,specularColor:()=>l6,specularF90:()=>u6,spherizeUV:()=>d6,split:()=>f6,spritesheetUV:()=>p6,sqrt:()=>m6,stack:()=>h6,step:()=>g6,stepElement:()=>_6,storage:()=>v6,storageBarrier:()=>y6,storageTexture:()=>b6,storageTexture3D:()=>x6,struct:()=>S6,sub:()=>C6,subBuild:()=>j6,subgroupAdd:()=>w6,subgroupAll:()=>T6,subgroupAnd:()=>E6,subgroupAny:()=>D6,subgroupBallot:()=>O6,subgroupBroadcast:()=>k6,subgroupBroadcastFirst:()=>A6,subgroupElect:()=>M6,subgroupExclusiveAdd:()=>N6,subgroupExclusiveMul:()=>P6,subgroupInclusiveAdd:()=>F6,subgroupInclusiveMul:()=>I6,subgroupIndex:()=>L6,subgroupMax:()=>R6,subgroupMin:()=>z6,subgroupMul:()=>B6,subgroupOr:()=>V6,subgroupShuffle:()=>H6,subgroupShuffleDown:()=>U6,subgroupShuffleUp:()=>W6,subgroupShuffleXor:()=>G6,subgroupSize:()=>K6,subgroupXor:()=>q6,tan:()=>J6,tangentGeometry:()=>X6,tangentLocal:()=>Z6,tangentView:()=>Q6,tangentWorld:()=>$6,tanh:()=>Y6,texture:()=>e8,texture3D:()=>t8,textureBarrier:()=>n8,textureBicubic:()=>r8,textureBicubicLevel:()=>i8,textureCubeUV:()=>a8,textureLevel:()=>c8,textureLoad:()=>o8,textureSize:()=>s8,textureStore:()=>l8,thickness:()=>u8,time:()=>d8,toneMapping:()=>f8,toneMappingExposure:()=>p8,toonOutlinePass:()=>m8,transformDirection:()=>h8,transformNormal:()=>g8,transformNormalByInverseViewMatrix:()=>_8,transformNormalByViewMatrix:()=>v8,transformNormalToView:()=>y8,transformedClearcoatNormalView:()=>b8,transformedNormalView:()=>x8,transformedNormalWorld:()=>S8,transmission:()=>C8,transpose:()=>w8,triNoise3D:()=>T8,triplanarTexture:()=>E8,triplanarTextures:()=>D8,trunc:()=>O8,uint:()=>k8,uintBitsToFloat:()=>A8,uniform:()=>j8,uniformArray:()=>M8,uniformCubeTexture:()=>N8,uniformFlow:()=>F8,uniformGroup:()=>P8,uniformTexture:()=>I8,unpackHalf2x16:()=>L8,unpackRGBToNormal:()=>B8,unpackSnorm2x16:()=>R8,unpackUnorm2x16:()=>z8,unpremultiplyAlpha:()=>V8,userData:()=>H8,uv:()=>U8,uvec2:()=>W8,uvec3:()=>G8,uvec4:()=>K8,varying:()=>q8,varyingProperty:()=>J8,vec2:()=>Y8,vec3:()=>X8,vec4:()=>Z8,vectorComponents:()=>Q8,velocity:()=>$8,vertexColor:()=>e5,vertexIndex:()=>t5,vertexStage:()=>n5,vibrance:()=>r5,viewZToLogarithmicDepth:()=>i5,viewZToOrthographicDepth:()=>a5,viewZToPerspectiveDepth:()=>o5,viewZToReversedOrthographicDepth:()=>s5,viewZToReversedPerspectiveDepth:()=>c5,viewport:()=>l5,viewportCoordinate:()=>u5,viewportDepthTexture:()=>d5,viewportLinearDepth:()=>f5,viewportMipTexture:()=>p5,viewportOpaqueMipTexture:()=>m5,viewportResolution:()=>h5,viewportSafeUV:()=>g5,viewportSharedTexture:()=>_5,viewportSize:()=>v5,viewportTexture:()=>y5,viewportUV:()=>b5,vogelDiskSample:()=>E$,wgsl:()=>x5,wgslFn:()=>S5,workgroupArray:()=>C5,workgroupBarrier:()=>w5,workgroupId:()=>T5,workingToColorSpace:()=>E5,xor:()=>D5}),LY,RY,zY,BY,VY,HY,UY,WY,GY,KY,qY,JY,YY,XY,ZY,QY,$Y,eX,tX,nX,rX,iX,aX,oX,sX,cX,lX,uX,dX,fX,pX,mX,hX,gX,_X,vX,yX,bX,xX,SX,CX,wX,TX,EX,DX,OX,kX,AX,jX,MX,NX,PX,FX,IX,LX,RX,zX,BX,VX,HX,UX,WX,GX,KX,qX,JX,YX,XX,ZX,QX,$X,eZ,tZ,nZ,rZ,iZ,aZ,oZ,sZ,cZ,lZ,uZ,dZ,fZ,pZ,mZ,hZ,gZ,_Z,vZ,yZ,bZ,xZ,SZ,CZ,wZ,TZ,EZ,DZ,OZ,kZ,AZ,jZ,MZ,NZ,PZ,FZ,IZ,LZ,RZ,zZ,BZ,VZ,HZ,UZ,WZ,GZ,KZ,qZ,JZ,YZ,XZ,ZZ,QZ,$Z,eQ,tQ,nQ,rQ,iQ,aQ,oQ,sQ,cQ,lQ,uQ,dQ,fQ,pQ,mQ,hQ,gQ,_Q,vQ,yQ,bQ,xQ,SQ,CQ,wQ,TQ,EQ,DQ,OQ,kQ,AQ,jQ,MQ,NQ,PQ,FQ,IQ,LQ,RQ,zQ,BQ,VQ,HQ,UQ,WQ,GQ,KQ,qQ,JQ,YQ,XQ,ZQ,QQ,$Q,e$,t$,n$,r$,i$,a$,o$,s$,c$,l$,u$,d$,f$,p$,m$,h$,g$,_$,v$,y$,b$,x$,S$,C$,w$,T$,E$,D$,O$,k$,A$,j$,M$,N$,P$,F$,I$,L$,R$,z$,B$,V$,H$,U$,W$,G$,K$,q$,J$,Y$,X$,Z$,Q$,e1,t1,n1,r1,i1,a1,o1,s1,c1,l1,u1,d1,f1,p1,m1,h1,g1,_1,v1,y1,b1,x1,S1,C1,w1,T1,E1,D1,O1,k1,A1,j1,M1,N1,P1,F1,I1,L1,R1,z1,B1,V1,H1,U1,W1,G1,K1,q1,J1,Y1,X1,Z1,Q1,$1,e0,t0,n0,r0,i0,a0,o0,s0,c0,l0,u0,d0,f0,p0,m0,h0,g0,_0,v0,y0,b0,x0,S0,C0,w0,T0,E0,D0,O0,k0,A0,j0,M0,N0,P0,F0,I0,L0,R0,z0,B0,V0,H0,U0,W0,G0,K0,q0,J0,Y0,X0,Z0,Q0,$0,e2,t2,n2,r2,i2,a2,o2,s2,c2,l2,u2,d2,f2,p2,m2,h2,g2,_2,v2,y2,b2,x2,S2,C2,w2,T2,E2,D2,O2,k2,A2,j2,M2,N2,P2,F2,I2,L2,R2,z2,B2,V2,H2,U2,W2,G2,K2,q2,J2,Y2,X2,Z2,Q2,$2,e4,t4,n4,r4,i4,a4,o4,s4,c4,l4,u4,d4,f4,p4,m4,h4,g4,_4,v4,y4,b4,x4,S4,C4,w4,T4,E4,D4,O4,k4,A4,j4,M4,N4,P4,F4,I4,L4,R4,z4,B4,V4,H4,U4,W4,G4,K4,q4,J4,Y4,X4,Z4,Q4,$4,e3,t3,n3,r3,i3,a3,o3,s3,c3,l3,u3,d3,f3,p3,m3,h3,g3,_3,v3,y3,b3,x3,S3,C3,w3,T3,E3,D3,O3,k3,A3,j3,M3,N3,P3,F3,I3,L3,R3,z3,B3,V3,H3,U3,W3,G3,K3,q3,J3,Y3,X3,Z3,Q3,$3,e6,t6,n6,r6,i6,a6,o6,s6,c6,l6,u6,d6,f6,p6,m6,h6,g6,_6,v6,y6,b6,x6,S6,C6,w6,T6,E6,D6,O6,k6,A6,j6,M6,N6,P6,F6,I6,L6,R6,z6,B6,V6,H6,U6,W6,G6,K6,q6,J6,Y6,X6,Z6,Q6,$6,e8,t8,n8,r8,i8,a8,o8,s8,c8,l8,u8,d8,f8,p8,m8,h8,g8,_8,v8,y8,b8,x8,S8,C8,w8,T8,E8,D8,O8,k8,A8,j8,M8,N8,P8,F8,I8,L8,R8,z8,B8,V8,H8,U8,W8,G8,K8,q8,J8,Y8,X8,Z8,Q8,$8,e5,t5,n5,r5,i5,a5,o5,s5,c5,l5,u5,d5,f5,p5,m5,h5,g5,_5,v5,y5,b5,x5,S5,C5,w5,T5,E5,D5,kue=p((()=>{EY(),LY=Q.BRDF_GGX,RY=Q.BRDF_Lambert,zY=Q.BasicPointShadowFilter,BY=Q.BasicShadowFilter,VY=Q.Break,HY=Q.Const,UY=Q.Continue,WY=Q.DFGLUT,GY=Q.D_GGX,KY=Q.Discard,qY=Q.EPSILON,JY=Q.F_Schlick,YY=Q.Fn,XY=Q.INFINITY,ZY=Q.If,QY=Q.Loop,$Y=Q.NodeAccess,eX=Q.NodeShaderStage,tX=Q.NodeType,nX=Q.NodeUpdateType,rX=Q.PCFShadowFilter,iX=Q.PCFSoftShadowFilter,aX=Q.PI,oX=Q.PI2,sX=Q.TWO_PI,cX=Q.HALF_PI,lX=Q.PointShadowFilter,uX=Q.Return,dX=Q.Schlick_to_F0,fX=Q.ShaderNode,pX=Q.Stack,mX=Q.Switch,hX=Q.TBNViewMatrix,gX=Q.VSMShadowFilter,_X=Q.V_GGX_SmithCorrelated,vX=Q.Var,yX=Q.VarIntent,bX=Q.abs,xX=Q.acesFilmicToneMapping,SX=Q.acos,CX=Q.acosh,wX=Q.add,TX=Q.addMethodChaining,EX=Q.addNodeElement,DX=Q.agxToneMapping,OX=Q.all,kX=Q.alphaT,AX=Q.ambientOcclusion,jX=Q.and,MX=Q.anisotropy,NX=Q.anisotropyB,PX=Q.anisotropyT,FX=Q.any,IX=Q.append,LX=Q.array,RX=Q.asin,zX=Q.asinh,BX=Q.assign,VX=Q.atan,HX=Q.atanh,UX=Q.atomicAdd,WX=Q.atomicAnd,GX=Q.atomicFunc,KX=Q.atomicLoad,qX=Q.atomicMax,JX=Q.atomicMin,YX=Q.atomicOr,XX=Q.atomicStore,ZX=Q.atomicSub,QX=Q.atomicXor,$X=Q.attenuationColor,eZ=Q.attenuationDistance,tZ=Q.attribute,nZ=Q.attributeArray,rZ=Q.backgroundBlurriness,iZ=Q.backgroundIntensity,aZ=Q.backgroundRotation,oZ=Q.batch,sZ=Q.bentNormalView,cZ=Q.billboarding,lZ=Q.bitAnd,uZ=Q.bitNot,dZ=Q.bitOr,fZ=Q.bitXor,pZ=Q.bitangentGeometry,mZ=Q.bitangentLocal,hZ=Q.bitangentView,gZ=Q.bitangentWorld,_Z=Q.bitcast,vZ=Q.blendBurn,yZ=Q.blendColor,bZ=Q.blendDodge,xZ=Q.blendOverlay,SZ=Q.blendScreen,CZ=Q.blur,wZ=Q.bool,TZ=Q.buffer,EZ=Q.bufferAttribute,DZ=Q.bumpMap,OZ=Q.builtin,kZ=Q.builtinAOContext,AZ=Q.builtinShadowContext,jZ=Q.bvec2,MZ=Q.bvec3,NZ=Q.bvec4,PZ=Q.bypass,FZ=Q.cache,IZ=Q.call,LZ=Q.cameraFar,RZ=Q.cameraIndex,zZ=Q.cameraNear,BZ=Q.cameraNormalMatrix,VZ=Q.cameraPosition,HZ=Q.cameraProjectionMatrix,UZ=Q.cameraProjectionMatrixInverse,WZ=Q.cameraViewMatrix,GZ=Q.cameraViewport,KZ=Q.cameraWorldMatrix,qZ=Q.cbrt,JZ=Q.cdl,YZ=Q.ceil,XZ=Q.checker,ZZ=Q.cineonToneMapping,QZ=Q.clamp,$Z=Q.clearcoat,eQ=Q.clearcoatNormalView,tQ=Q.clearcoatRoughness,nQ=Q.clipSpace,rQ=Q.code,iQ=Q.color,aQ=Q.colorSpaceToWorking,oQ=Q.colorToDirection,sQ=Q.compute,cQ=Q.computeKernel,lQ=Q.computeSkinning,uQ=Q.context,dQ=Q.convert,fQ=Q.convertColorSpace,pQ=Q.convertToTexture,mQ=Q.countLeadingZeros,hQ=Q.countOneBits,gQ=Q.countTrailingZeros,_Q=Q.cos,vQ=Q.cosh,yQ=Q.cross,bQ=Q.cubeTexture,xQ=Q.cubeTextureBase,SQ=Q.dFdx,CQ=Q.dFdy,wQ=Q.dashSize,TQ=Q.debug,EQ=Q.decrement,DQ=Q.decrementBefore,OQ=Q.defaultBuildStages,kQ=Q.defaultShaderStages,AQ=Q.defined,jQ=Q.degrees,MQ=Q.deltaTime,NQ=Q.densityFog,PQ=Q.densityFogFactor,FQ=Q.depth,IQ=Q.depthPass,LQ=Q.determinant,RQ=Q.difference,zQ=Q.diffuseColor,BQ=Q.directPointLight,VQ=Q.directionToColor,HQ=Q.directionToFaceDirection,UQ=Q.dispersion,WQ=Q.distance,GQ=Q.div,KQ=Q.dot,qQ=Q.drawIndex,JQ=Q.dynamicBufferAttribute,YQ=Q.element,XQ=Q.emissive,ZQ=Q.equal,QQ=Q.equirectDirection,$Q=Q.equirectUV,e$=Q.exp,t$=Q.exp2,n$=Q.exponentialHeightFogFactor,r$=Q.expression,i$=Q.faceDirection,a$=Q.faceForward,o$=Q.faceforward,s$=Q.float,c$=Q.floatBitsToInt,l$=Q.floatBitsToUint,u$=Q.floor,d$=Q.fog,f$=Q.fract,p$=Q.frameGroup,m$=Q.frameId,h$=Q.frontFacing,g$=Q.fwidth,_$=Q.gain,v$=Q.gapSize,y$=Q.getConstNodeType,b$=Q.getCurrentStack,x$=Q.getDirection,S$=Q.getDistanceAttenuation,C$=Q.getGeometryRoughness,w$=Q.getNormalFromDepth,T$=Q.interleavedGradientNoise,E$=Q.vogelDiskSample,D$=Q.getParallaxCorrectNormal,O$=Q.getRoughness,k$=Q.getScreenPosition,A$=Q.getShIrradianceAt,j$=Q.getShadowMaterial,M$=Q.getShadowRenderObjectFunction,N$=Q.getTextureIndex,P$=Q.getViewPosition,F$=Q.globalId,I$=Q.glsl,L$=Q.glslFn,R$=Q.grayscale,z$=Q.greaterThan,B$=Q.greaterThanEqual,V$=Q.hash,H$=Q.highpModelNormalViewMatrix,U$=Q.highpModelViewMatrix,W$=Q.hue,G$=Q.increment,K$=Q.incrementBefore,q$=Q.instance,J$=Q.instanceIndex,Y$=Q.instancedArray,X$=Q.instancedBufferAttribute,Z$=Q.instancedDynamicBufferAttribute,Q$=Q.instancedMesh,e1=Q.int,t1=Q.intBitsToFloat,n1=Q.inverse,r1=Q.inverseSqrt,i1=Q.inversesqrt,a1=Q.invocationLocalIndex,o1=Q.invocationSubgroupIndex,s1=Q.ior,c1=Q.iridescence,l1=Q.iridescenceIOR,u1=Q.iridescenceThickness,d1=Q.ivec2,f1=Q.ivec3,p1=Q.ivec4,m1=Q.js,h1=Q.label,g1=Q.length,_1=Q.lengthSq,v1=Q.lessThan,y1=Q.lessThanEqual,b1=Q.lightPosition,x1=Q.lightProjectionUV,S1=Q.lightShadowMatrix,C1=Q.lightTargetDirection,w1=Q.lightTargetPosition,T1=Q.lightViewPosition,E1=Q.lightingContext,D1=Q.lights,O1=Q.linearDepth,k1=Q.linearToneMapping,A1=Q.localId,j1=Q.log,M1=Q.log2,N1=Q.logarithmicDepthToViewZ,P1=Q.luminance,F1=Q.mat2,I1=Q.mat3,L1=Q.mat4,R1=Q.matcapUV,z1=Q.materialAO,B1=Q.materialAlphaTest,V1=Q.materialAnisotropy,H1=Q.materialAnisotropyVector,U1=Q.materialAttenuationColor,W1=Q.materialAttenuationDistance,G1=Q.materialClearcoat,K1=Q.materialClearcoatNormal,q1=Q.materialClearcoatRoughness,J1=Q.materialColor,Y1=Q.materialDispersion,X1=Q.materialEmissive,Z1=Q.materialEnvIntensity,Q1=Q.materialEnvRotation,$1=Q.materialIOR,e0=Q.materialIridescence,t0=Q.materialIridescenceIOR,n0=Q.materialIridescenceThickness,r0=Q.materialLightMap,i0=Q.materialLineDashOffset,a0=Q.materialLineDashSize,o0=Q.materialLineGapSize,s0=Q.materialLineScale,c0=Q.materialLineWidth,l0=Q.materialMetalness,u0=Q.materialNormal,d0=Q.materialOpacity,f0=Q.materialPointSize,p0=Q.materialReference,m0=Q.materialReflectivity,h0=Q.materialRefractionRatio,g0=Q.materialRotation,_0=Q.materialRoughness,v0=Q.materialSheen,y0=Q.materialSheenRoughness,b0=Q.materialShininess,x0=Q.materialSpecular,S0=Q.materialSpecularColor,C0=Q.materialSpecularIntensity,w0=Q.materialSpecularStrength,T0=Q.materialThickness,E0=Q.materialTransmission,D0=Q.max,O0=Q.maxMipLevel,k0=Q.mediumpModelViewMatrix,A0=Q.metalness,j0=Q.min,M0=Q.mix,N0=Q.mixElement,P0=Q.mod,F0=Q.modelDirection,I0=Q.modelNormalMatrix,L0=Q.modelPosition,R0=Q.modelRadius,z0=Q.modelScale,B0=Q.modelViewMatrix,V0=Q.modelViewPosition,H0=Q.modelViewProjection,U0=Q.modelWorldMatrix,W0=Q.modelWorldMatrixInverse,G0=Q.morphReference,K0=Q.mrt,q0=Q.mul,J0=Q.mx_aastep,Y0=Q.mx_add,X0=Q.mx_atan2,Z0=Q.mx_cell_noise_float,Q0=Q.mx_contrast,$0=Q.mx_divide,e2=Q.mx_fractal_noise_float,t2=Q.mx_fractal_noise_vec2,n2=Q.mx_fractal_noise_vec3,r2=Q.mx_fractal_noise_vec4,i2=Q.mx_frame,a2=Q.mx_heighttonormal,o2=Q.mx_hsvtorgb,s2=Q.mx_ifequal,c2=Q.mx_ifgreater,l2=Q.mx_ifgreatereq,u2=Q.mx_invert,d2=Q.mx_modulo,f2=Q.mx_multiply,p2=Q.mx_noise_float,m2=Q.mx_noise_vec3,h2=Q.mx_noise_vec4,g2=Q.mx_place2d,_2=Q.mx_power,v2=Q.mx_ramp4,y2=Q.mx_ramplr,b2=Q.mx_ramptb,x2=Q.mx_rgbtohsv,S2=Q.mx_rotate2d,C2=Q.mx_rotate3d,w2=Q.mx_safepower,T2=Q.mx_separate,E2=Q.mx_splitlr,D2=Q.mx_splittb,O2=Q.mx_srgb_texture_to_lin_rec709,k2=Q.mx_subtract,A2=Q.mx_timer,j2=Q.mx_transform_uv,M2=Q.mx_unifiednoise2d,N2=Q.mx_unifiednoise3d,P2=Q.mx_worley_noise_float,F2=Q.mx_worley_noise_vec2,I2=Q.mx_worley_noise_vec3,L2=Q.negate,R2=Q.negateOnBackSide,z2=Q.neutralToneMapping,B2=Q.nodeArray,V2=Q.nodeImmutable,H2=Q.nodeObject,U2=Q.nodeObjectIntent,W2=Q.nodeObjects,G2=Q.nodeProxy,K2=Q.nodeProxyIntent,q2=Q.normalFlat,J2=Q.normalGeometry,Y2=Q.normalLocal,X2=Q.normalMap,Z2=Q.normalView,Q2=Q.normalViewGeometry,$2=Q.normalWorld,e4=Q.normalWorldGeometry,t4=Q.normalize,n4=Q.not,r4=Q.notEqual,i4=Q.numWorkgroups,a4=Q.objectDirection,o4=Q.objectGroup,s4=Q.objectPosition,c4=Q.objectRadius,l4=Q.objectScale,u4=Q.objectViewPosition,d4=Q.objectWorldMatrix,f4=Q.OnBeforeObjectUpdate,p4=Q.OnBeforeMaterialUpdate,m4=Q.OnObjectUpdate,h4=Q.OnMaterialUpdate,g4=Q.oneMinus,_4=Q.or,v4=Q.orthographicDepthToViewZ,y4=Q.oscSawtooth,b4=Q.oscSine,x4=Q.oscSquare,S4=Q.oscTriangle,C4=Q.output,w4=Q.outputStruct,T4=Q.overloadingFn,E4=Q.overrideNode,D4=Q.overrideNodes,O4=Q.packHalf2x16,k4=Q.packSnorm2x16,A4=Q.packUnorm2x16,j4=Q.packNormalToRGB,M4=Q.parabola,N4=Q.parallaxDirection,P4=Q.parallaxUV,F4=Q.parameter,I4=Q.pass,L4=Q.passTexture,R4=Q.pcurve,z4=Q.perspectiveDepthToViewZ,B4=Q.pmremTexture,V4=Q.pointShadow,H4=Q.pointUV,U4=Q.pointWidth,W4=Q.positionGeometry,G4=Q.positionLocal,K4=Q.positionPrevious,q4=Q.positionView,J4=Q.positionViewDirection,Y4=Q.positionWorld,X4=Q.positionWorldDirection,Z4=Q.posterize,Q4=Q.pow,$4=Q.pow2,e3=Q.pow3,t3=Q.pow4,n3=Q.premultiplyAlpha,r3=Q.property,i3=Q.radians,a3=Q.rand,o3=Q.range,s3=Q.rangeFog,c3=Q.rangeFogFactor,l3=Q.reciprocal,u3=Q.reference,d3=Q.referenceBuffer,f3=Q.reflect,p3=Q.reflectVector,m3=Q.reflectView,h3=Q.reflector,g3=Q.refract,_3=Q.refractVector,v3=Q.refractView,y3=Q.reinhardToneMapping,b3=Q.remap,x3=Q.remapClamp,S3=Q.renderGroup,C3=Q.renderOutput,w3=Q.rendererReference,T3=Q.replaceDefaultUV,E3=Q.rotate,D3=Q.rotateUV,O3=Q.roughness,k3=Q.round,A3=Q.rtt,j3=Q.sRGBTransferEOTF,M3=Q.sRGBTransferOETF,N3=Q.sample,P3=Q.sampler,F3=Q.samplerComparison,I3=Q.saturate,L3=Q.saturation,R3=Q.screen,z3=Q.screenCoordinate,B3=Q.screenDPR,V3=Q.screenSize,H3=Q.screenUV,U3=Q.select,W3=Q.setCurrentStack,G3=Q.setName,K3=Q.shaderStages,q3=Q.shadow,J3=Q.shadowPositionWorld,Y3=Q.shapeCircle,X3=Q.sharedUniformGroup,Z3=Q.sheen,Q3=Q.sheenRoughness,$3=Q.shiftLeft,e6=Q.shiftRight,t6=Q.shininess,n6=Q.sign,r6=Q.sin,i6=Q.sinh,a6=Q.sinc,o6=Q.skinning,s6=Q.smoothstep,c6=Q.smoothstepElement,l6=Q.specularColor,u6=Q.specularF90,d6=Q.spherizeUV,f6=Q.split,p6=Q.spritesheetUV,m6=Q.sqrt,h6=Q.stack,g6=Q.step,_6=Q.stepElement,v6=Q.storage,y6=Q.storageBarrier,b6=Q.storageTexture,x6=Q.storageTexture3D,S6=Q.struct,C6=Q.sub,w6=Q.subgroupAdd,T6=Q.subgroupAll,E6=Q.subgroupAnd,D6=Q.subgroupAny,O6=Q.subgroupBallot,k6=Q.subgroupBroadcast,A6=Q.subgroupBroadcastFirst,j6=Q.subBuild,M6=Q.subgroupElect,N6=Q.subgroupExclusiveAdd,P6=Q.subgroupExclusiveMul,F6=Q.subgroupInclusiveAdd,I6=Q.subgroupInclusiveMul,L6=Q.subgroupIndex,R6=Q.subgroupMax,z6=Q.subgroupMin,B6=Q.subgroupMul,V6=Q.subgroupOr,H6=Q.subgroupShuffle,U6=Q.subgroupShuffleDown,W6=Q.subgroupShuffleUp,G6=Q.subgroupShuffleXor,K6=Q.subgroupSize,q6=Q.subgroupXor,J6=Q.tan,Y6=Q.tanh,X6=Q.tangentGeometry,Z6=Q.tangentLocal,Q6=Q.tangentView,$6=Q.tangentWorld,e8=Q.texture,t8=Q.texture3D,n8=Q.textureBarrier,r8=Q.textureBicubic,i8=Q.textureBicubicLevel,a8=Q.textureCubeUV,o8=Q.textureLoad,s8=Q.textureSize,c8=Q.textureLevel,l8=Q.textureStore,u8=Q.thickness,d8=Q.time,f8=Q.toneMapping,p8=Q.toneMappingExposure,m8=Q.toonOutlinePass,h8=Q.transformDirection,g8=Q.transformNormal,_8=Q.transformNormalByInverseViewMatrix,v8=Q.transformNormalByViewMatrix,y8=Q.transformNormalToView,b8=Q.transformedClearcoatNormalView,x8=Q.transformedNormalView,S8=Q.transformedNormalWorld,C8=Q.transmission,w8=Q.transpose,T8=Q.triNoise3D,E8=Q.triplanarTexture,D8=Q.triplanarTextures,O8=Q.trunc,k8=Q.uint,A8=Q.uintBitsToFloat,j8=Q.uniform,M8=Q.uniformArray,N8=Q.uniformCubeTexture,P8=Q.uniformGroup,F8=Q.uniformFlow,I8=Q.uniformTexture,L8=Q.unpackHalf2x16,R8=Q.unpackSnorm2x16,z8=Q.unpackUnorm2x16,B8=Q.unpackRGBToNormal,V8=Q.unpremultiplyAlpha,H8=Q.userData,U8=Q.uv,W8=Q.uvec2,G8=Q.uvec3,K8=Q.uvec4,q8=Q.varying,J8=Q.varyingProperty,Y8=Q.vec2,X8=Q.vec3,Z8=Q.vec4,Q8=Q.vectorComponents,$8=Q.velocity,e5=Q.vertexColor,t5=Q.vertexIndex,n5=Q.vertexStage,r5=Q.vibrance,i5=Q.viewZToLogarithmicDepth,a5=Q.viewZToOrthographicDepth,o5=Q.viewZToPerspectiveDepth,s5=Q.viewZToReversedOrthographicDepth,c5=Q.viewZToReversedPerspectiveDepth,l5=Q.viewport,u5=Q.viewportCoordinate,d5=Q.viewportDepthTexture,f5=Q.viewportLinearDepth,p5=Q.viewportMipTexture,m5=Q.viewportOpaqueMipTexture,h5=Q.viewportResolution,g5=Q.viewportSafeUV,_5=Q.viewportSharedTexture,v5=Q.viewportSize,y5=Q.viewportTexture,b5=Q.viewportUV,x5=Q.wgsl,S5=Q.wgslFn,C5=Q.workgroupArray,w5=Q.workgroupBarrier,T5=Q.workgroupId,E5=Q.workingToColorSpace,D5=Q.xor})),O5=m(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define(r):typeof e==`object`?t.exports=r():n.ResizeSensor=r()})(typeof window<`u`?window:e,function(){if(typeof window>`u`)return null;var e=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)(),t=e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame||function(t){return e.setTimeout(t,20)},n=e.cancelAnimationFrame||e.mozCancelAnimationFrame||e.webkitCancelAnimationFrame||function(t){e.clearTimeout(t)};function r(e,t){var n=Object.prototype.toString.call(e),r=n===`[object Array]`||n===`[object NodeList]`||n===`[object HTMLCollection]`||n===`[object Object]`||typeof jQuery<`u`&&e instanceof jQuery||typeof Elements<`u`&&e instanceof Elements,i=0,a=e.length;if(r)for(;i<a;i++)t(e[i]);else t(e)}function i(e){if(!e.getBoundingClientRect)return{width:e.offsetWidth,height:e.offsetHeight};var t=e.getBoundingClientRect();return{width:Math.round(t.width),height:Math.round(t.height)}}function a(e,t){Object.keys(t).forEach(function(n){e.style[n]=t[n]})}var o=function(e,s){var c=0;function l(){var e=[];this.add=function(t){e.push(t)};var t,n;this.call=function(r){for(t=0,n=e.length;t<n;t++)e[t].call(this,r)},this.remove=function(r){var i=[];for(t=0,n=e.length;t<n;t++)e[t]!==r&&i.push(e[t]);e=i},this.length=function(){return e.length}}function u(e,n){if(e){if(e.resizedAttached){e.resizedAttached.add(n);return}e.resizedAttached=new l,e.resizedAttached.add(n),e.resizeSensor=document.createElement(`div`),e.resizeSensor.dir=`ltr`,e.resizeSensor.className=`resize-sensor`;var r={pointerEvents:`none`,position:`absolute`,left:`0px`,top:`0px`,right:`0px`,bottom:`0px`,overflow:`hidden`,zIndex:`-1`,visibility:`hidden`,maxWidth:`100%`},o={position:`absolute`,left:`0px`,top:`0px`,transition:`0s`};a(e.resizeSensor,r);var s=document.createElement(`div`);s.className=`resize-sensor-expand`,a(s,r);var u=document.createElement(`div`);a(u,o),s.appendChild(u);var d=document.createElement(`div`);d.className=`resize-sensor-shrink`,a(d,r);var f=document.createElement(`div`);a(f,o),a(f,{width:`200%`,height:`200%`}),d.appendChild(f),e.resizeSensor.appendChild(s),e.resizeSensor.appendChild(d),e.appendChild(e.resizeSensor);var p=window.getComputedStyle(e),m=p?p.getPropertyValue(`position`):null;m!==`absolute`&&m!==`relative`&&m!==`fixed`&&m!==`sticky`&&(e.style.position=`relative`);var h=!1,g=0,_=i(e),v=0,y=0,b=!0;c=0;var x=function(){var t=e.offsetWidth,n=e.offsetHeight;u.style.width=t+10+`px`,u.style.height=n+10+`px`,s.scrollLeft=t+10,s.scrollTop=n+10,d.scrollLeft=t+10,d.scrollTop=n+10},S=function(){if(b){if(e.offsetWidth===0&&e.offsetHeight===0){c||=t(function(){c=0,S()});return}b=!1}x()};e.resizeSensor.resetSensor=S;var C=function(){g=0,h&&(v=_.width,y=_.height,e.resizedAttached&&e.resizedAttached.call(_))},w=function(){_=i(e),h=_.width!==v||_.height!==y,h&&!g&&(g=t(C)),S()},T=function(e,t,n){e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener(t,n)};T(s,`scroll`,w),T(d,`scroll`,w),c=t(function(){c=0,S()})}}r(e,function(e){u(e,s)}),this.detach=function(t){c||=(n(c),0),o.detach(e,t)},this.reset=function(){e.resizeSensor.resetSensor()}};if(o.reset=function(e){r(e,function(e){e.resizeSensor.resetSensor()})},o.detach=function(e,t){r(e,function(e){e&&(e.resizedAttached&&typeof t==`function`&&(e.resizedAttached.remove(t),e.resizedAttached.length())||e.resizeSensor&&(e.contains(e.resizeSensor)&&e.removeChild(e.resizeSensor),delete e.resizeSensor,delete e.resizedAttached))})},typeof MutationObserver<`u`){var s=new MutationObserver(function(e){for(var t in e)if(e.hasOwnProperty(t))for(var n=e[t].addedNodes,r=0;r<n.length;r++)n[r].resizeSensor&&o.reset(n[r])});document.addEventListener(`DOMContentLoaded`,function(e){s.observe(document.body,{childList:!0,subtree:!0})})}return o})})),Aue=m(((e,t)=>{(function(n,r){typeof define==`function`&&define.amd?define([`./ResizeSensor.js`],r):typeof e==`object`?t.exports=r(O5()):(n.ElementQueries=r(n.ResizeSensor),n.ElementQueries.listen())})(typeof window<`u`?window:e,function(e){var t=function(){var t,n={},r=[];function i(e){e||=document.documentElement;var t=window.getComputedStyle(e,null).fontSize;return parseFloat(t)||16}function a(e){if(!e.getBoundingClientRect)return{width:e.offsetWidth,height:e.offsetHeight};var t=e.getBoundingClientRect();return{width:Math.round(t.width),height:Math.round(t.height)}}function o(e,t){var n=t.split(/\d/),r=n[n.length-1];switch(t=parseFloat(t),r){case`px`:return t;case`em`:return t*i(e);case`rem`:return t*i();case`vw`:return t*document.documentElement.clientWidth/100;case`vh`:return t*document.documentElement.clientHeight/100;case`vmin`:case`vmax`:var a=document.documentElement.clientWidth/100,o=document.documentElement.clientHeight/100,s=Math[r===`vmin`?`min`:`max`];return t*s(a,o);default:return t}}function s(e,t){this.element=e;var r,i,s,c,l,u,d,f,p=[`min-width`,`min-height`,`max-width`,`max-height`];this.call=function(){for(r in s=a(this.element),u={},n[t])n[t].hasOwnProperty(r)&&(i=n[t][r],c=o(this.element,i.value),l=i.property===`width`?s.width:s.height,f=i.mode+`-`+i.property,d=``,i.mode===`min`&&l>=c&&(d+=i.value),i.mode===`max`&&l<=c&&(d+=i.value),u[f]||(u[f]=``),d&&(` `+u[f]+` `).indexOf(` `+d+` `)===-1&&(u[f]+=` `+d));for(var e in p)p.hasOwnProperty(e)&&(u[p[e]]?this.element.setAttribute(p[e],u[p[e]].substr(1)):this.element.removeAttribute(p[e]))}}function c(t,n){t.elementQueriesSetupInformation||=new s(t,n),t.elementQueriesSensor||=new e(t,function(){t.elementQueriesSetupInformation.call()})}function l(e,i,a,o){if(n[e]===void 0){n[e]=[];var s=r.length;t.innerHTML+=`
553
553
  `+e+` {animation: 0.1s element-queries;}`,t.innerHTML+=`
554
554
  `+e+` > .resize-sensor {min-width: `+s+`px;}`,r.push(e)}n[e].push({mode:i,property:a,value:o})}function u(e){var t;if(document.querySelectorAll&&(t=e?e.querySelectorAll.bind(e):document.querySelectorAll.bind(document)),!t&&typeof $$<`u`&&(t=$$),!t&&typeof jQuery<`u`&&(t=jQuery),!t)throw`No document.querySelectorAll, jQuery or Mootools's $$ found.`;return t}function d(e){var t=u(e);for(var r in n)if(n.hasOwnProperty(r))for(var i=t(r,e),a=0,o=i.length;a<o;a++)c(i[a],r)}function f(t){var n=[],r=[],i=[],a=0,o=-1,s=[];for(var c in t.children)if(t.children.hasOwnProperty(c)&&t.children[c].tagName&&t.children[c].tagName.toLowerCase()===`img`){n.push(t.children[c]);var l=t.children[c].getAttribute(`min-width`)||t.children[c].getAttribute(`data-min-width`),u=t.children[c].getAttribute(`data-src`)||t.children[c].getAttribute(`url`);i.push(u);var d={minWidth:l};r.push(d),l?t.children[c].style.display=`none`:(a=n.length-1,t.children[c].style.display=`block`)}o=a;function f(){var e=!1,c;for(c in n)n.hasOwnProperty(c)&&r[c].minWidth&&t.offsetWidth>r[c].minWidth&&(e=c);if(e||=a,o!==e){if(s[e])n[o].style.display=`none`,n[e].style.display=`block`,o=e;else{var l=new Image;l.onload=function(){n[e].src=i[e],n[o].style.display=`none`,n[e].style.display=`block`,s[e]=!0,o=e},l.src=i[e]}}else n[e].src=i[e]}t.resizeSensorInstance=new e(t,f),f()}function p(){for(var e=u()(`[data-responsive-image],[responsive-image]`),t=0,n=e.length;t<n;t++)f(e[t])}var m=/,?[\s\t]*([^,\n]*?)((?:\[[\s\t]*?(?:min|max)-(?:width|height)[\s\t]*?[~$\^]?=[\s\t]*?"[^"]*?"[\s\t]*?])+)([^,\n\s\{]*)/gim,h=/\[[\s\t]*?(min|max)-(width|height)[\s\t]*?[~$\^]?=[\s\t]*?"([^"]*?)"[\s\t]*?]/gim;function g(e){var t,n,r,i;for(e=e.replace(/'/g,`"`);(t=m.exec(e))!==null;)for(n=t[1]+t[3],r=t[2];(i=h.exec(r))!==null;)l(n,i[1],i[2],i[3])}function _(e){var t=``;if(e){if(typeof e==`string`)e=e.toLowerCase(),(e.indexOf(`min-width`)!==-1||e.indexOf(`max-width`)!==-1)&&g(e);else for(var n=0,r=e.length;n<r;n++)e[n].type===1?(t=e[n].selectorText||e[n].cssText,(t.indexOf(`min-height`)!==-1||t.indexOf(`max-height`)!==-1||t.indexOf(`min-width`)!==-1||t.indexOf(`max-width`)!==-1)&&g(t)):e[n].type===4?_(e[n].cssRules||e[n].rules):e[n].type===3&&e[n].styleSheet.hasOwnProperty(`cssRules`)&&_(e[n].styleSheet.cssRules)}}var v=!1;this.init=function(){var n=`animationstart`;document.documentElement.style.webkitAnimationName===void 0?document.documentElement.style.MozAnimationName===void 0?document.documentElement.style.OAnimationName!==void 0&&(n=`oanimationstart`):n=`mozanimationstart`:n=`webkitAnimationStart`,document.body.addEventListener(n,function(t){var n=t.target,i=n&&window.getComputedStyle(n,null),a=i&&i.getPropertyValue(`animation-name`);if(a&&a.indexOf(`element-queries`)!==-1){n.elementQueriesSensor=new e(n,function(){n.elementQueriesSetupInformation&&n.elementQueriesSetupInformation.call()});var o=window.getComputedStyle(n.resizeSensor,null).getPropertyValue(`min-width`);o=parseInt(o.replace(`px`,``)),c(t.target,r[o])}}),v||=(t=document.createElement(`style`),t.type=`text/css`,t.innerHTML=`[responsive-image] > img, [data-responsive-image] {overflow: hidden; padding: 0; } [responsive-image] > img, [data-responsive-image] > img {width: 100%;}`,t.innerHTML+=`
555
- @keyframes element-queries { 0% { visibility: inherit; } }`,document.getElementsByTagName(`head`)[0].appendChild(t),!0);for(var i=0,a=document.styleSheets.length;i<a;i++)try{document.styleSheets[i].href&&document.styleSheets[i].href.indexOf(`file://`)===0&&console.warn(`CssElementQueries: unable to parse local css files, `+document.styleSheets[i].href),_(document.styleSheets[i].cssRules||document.styleSheets[i].rules||document.styleSheets[i].cssText)}catch{}p()},this.findElementQueriesElements=function(e){d(e)},this.update=function(){this.init()}};t.update=function(){t.instance.update()},t.detach=function(e){e.elementQueriesSetupInformation?(e.elementQueriesSensor.detach(),delete e.elementQueriesSetupInformation,delete e.elementQueriesSensor):e.resizeSensorInstance&&(e.resizeSensorInstance.detach(),delete e.resizeSensorInstance)},t.init=function(){t.instance||=new t,t.instance.init()};var n=function(e){if(document.addEventListener)document.addEventListener(`DOMContentLoaded`,e,!1);else if(/KHTML|WebKit|iCab/i.test(navigator.userAgent))var t=setInterval(function(){/loaded|complete/i.test(document.readyState)&&(e(),clearInterval(t))},10);else window.onload=e};return t.findElementQueriesElements=function(e){t.instance.findElementQueriesElements(e)},t.listen=function(){n(t.init)},t})})),jue=m(((e,t)=>{t.exports={ResizeSensor:O5(),ElementQueries:Aue()}})),Mue=h({GLTFExporter:()=>P5});function k5(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function Nue(e){return new TextEncoder().encode(e).buffer}function Pue(e){return k5(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Fue(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:(t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),e.normalized===!0&&(n=Tp.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function A5(e){return Math.ceil(e/4)*4}function j5(e,t=0){let n=A5(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}function M5(){return typeof document>`u`&&typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)}function Iue(e,t){if(typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas){let n;return t===`image/jpeg`?n=.92:t===`image/webp`&&(n=.8),e.convertToBlob({type:t,quality:n})}return new Promise(n=>e.toBlob(n,t))}var N5,P5,F5,I5,L5,R5,z5,B5,V5,H5,U5,W5,G5,K5,q5,J5,Y5,X5,Z5,Q5,$5,e7,t7,n7,r7,i7,a7,o7,Lue=p((()=>{DY(),N5={POSITION:[`byte`,`byte normalized`,`unsigned byte`,`unsigned byte normalized`,`short`,`short normalized`,`unsigned short`,`unsigned short normalized`],NORMAL:[`byte normalized`,`short normalized`],TANGENT:[`byte normalized`,`short normalized`],TEXCOORD:[`byte`,`byte normalized`,`unsigned byte`,`short`,`short normalized`,`unsigned short`]},P5=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new q5(e)}),this.register(function(e){return new J5(e)}),this.register(function(e){return new Q5(e)}),this.register(function(e){return new $5(e)}),this.register(function(e){return new e7(e)}),this.register(function(e){return new t7(e)}),this.register(function(e){return new Y5(e)}),this.register(function(e){return new X5(e)}),this.register(function(e){return new Z5(e)}),this.register(function(e){return new n7(e)}),this.register(function(e){return new r7(e)}),this.register(function(e){return new i7(e)}),this.register(function(e){return new a7(e)}),this.register(function(e){return new o7(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new K5,a=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)a.push(this.pluginCallbacks[e](i));i.setPlugins(a),i.setTextureUtils(this.textureUtils),i.writeAsync(e,t,r).catch(n)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,r,i,t)})}},F5={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},I5=`KHR_mesh_quantization`,L5={},L5[ud]=F5.NEAREST,L5[dd]=F5.NEAREST_MIPMAP_NEAREST,L5[pd]=F5.NEAREST_MIPMAP_LINEAR,L5[hd]=F5.LINEAR,L5[gd]=F5.LINEAR_MIPMAP_NEAREST,L5[vd]=F5.LINEAR_MIPMAP_LINEAR,L5[cd]=F5.CLAMP_TO_EDGE,L5[sd]=F5.REPEAT,L5[ld]=F5.MIRRORED_REPEAT,R5={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},z5=new Om,B5=12,V5=1179937895,H5=2,U5=8,W5=1313821514,G5=5130562,K5=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter r185`}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this,i=r.buffers,a=r.json;n=r.options;let o=r.extensionsUsed,s=r.extensionsRequired,c=new Blob(i,{type:`application/octet-stream`}),l=Object.keys(o),u=Object.keys(s);if(l.length>0&&(a.extensionsUsed=l),u.length>0&&(a.extensionsRequired=u),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=c.size),n.binary===!0){let e=new FileReader;e.readAsArrayBuffer(c),e.onloadend=function(){let n=j5(e.result),r=new DataView(new ArrayBuffer(U5));r.setUint32(0,n.byteLength,!0),r.setUint32(4,G5,!0);let i=j5(Nue(JSON.stringify(a)),32),o=new DataView(new ArrayBuffer(U5));o.setUint32(0,i.byteLength,!0),o.setUint32(4,W5,!0);let s=new ArrayBuffer(B5),c=new DataView(s);c.setUint32(0,V5,!0),c.setUint32(4,H5,!0);let l=B5+o.byteLength+i.byteLength+r.byteLength+n.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,i,r,n],{type:`application/octet-stream`}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(c),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new B;for(let n=0,r=e.count;n<r;n++)if(Math.abs(t.fromBufferAttribute(e,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new B;for(let e=0,t=n.count;e<t;e++)r.fromBufferAttribute(n,e),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),n.setXYZ(e,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,t){if(e===t)return e;function n(e){return e.colorSpace===`srgb`?function(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}:function(e){return e}}e instanceof B_&&(e=await this.decompressTextureAsync(e)),t instanceof B_&&(t=await this.decompressTextureAsync(t));let r=e?e.image:null,i=t?t.image:null,a=Math.max(r?r.width:0,i?i.width:0),o=Math.max(r?r.height:0,i?i.height:0),s=M5();s.width=a,s.height=o;let c=s.getContext(`2d`,{willReadFrequently:!0});c.fillStyle=`#00ffff`,c.fillRect(0,0,a,o);let l=c.getImageData(0,0,a,o);if(r){c.drawImage(r,0,0,a,o);let t=n(e),i=c.getImageData(0,0,a,o).data;for(let e=2;e<i.length;e+=4)l.data[e]=t(i[e]/256)*256}if(i){c.drawImage(i,0,0,a,o);let e=n(t),r=c.getImageData(0,0,a,o).data;for(let t=1;t<r.length;t+=4)l.data[t]=e(r[t]/256)*256}c.putImageData(l,0,0);let u=(e||t).clone();return u.source=new Lp(s),u.colorSpace=``,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn(`THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.`),console.warn(`THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.`),u}async buildNormalMapTextureAsync(e,t,n){e instanceof B_&&(e=await this.decompressTextureAsync(e));let r=e.image,i=M5();i.width=r.width,i.height=r.height;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(r,0,0,i.width,i.height);let o=a.getImageData(0,0,i.width,i.height),s=o.data;for(let e=0;e<s.length;e+=4)t&&(s[e+0]=255-s[e+0]),n&&(s[e+1]=255-s[e+1]);a.putImageData(o,0,0);let c=e.clone();return c.source=new Lp(i),c}async decompressTextureAsync(e,t=1/0){if(this.textureUtils===null)throw Error(`THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.`);return await this.textureUtils.decompress(e,t)}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;switch(t){case F5.BYTE:case F5.UNSIGNED_BYTE:o=1;break;case F5.SHORT:case F5.UNSIGNED_SHORT:o=2;break;default:o=4}let s=e.itemSize*o;i===F5.ARRAY_BUFFER&&(s=Math.ceil(s/4)*4);let c=A5(r*s),l=new DataView(new ArrayBuffer(c)),u=0;for(let i=n;i<n+r;i++){for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:(n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),e.normalized===!0&&(r=Tp.normalize(r,e.array))),t===F5.FLOAT?l.setFloat32(u,r,!0):t===F5.INT?l.setInt32(u,r,!0):t===F5.UNSIGNED_INT?l.setUint32(u,r,!0):t===F5.SHORT?l.setInt16(u,r,!0):t===F5.UNSIGNED_SHORT?l.setUint16(u,r,!0):t===F5.BYTE?l.setInt8(u,r):t===F5.UNSIGNED_BYTE&&l.setUint8(u,r),u+=o}u%s!==0&&(u+=s-u%s)}let d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:c};return i!==void 0&&(d.target=i),i===F5.ARRAY_BUFFER&&(d.byteStride=s),this.byteOffset+=c,a.bufferViews.push(d),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=j5(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.json,a={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,9:`MAT3`,16:`MAT4`},o;if(e.array.constructor===Float32Array)o=F5.FLOAT;else if(e.array.constructor===Int32Array)o=F5.INT;else if(e.array.constructor===Uint32Array)o=F5.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=F5.SHORT;else if(e.array.constructor===Uint16Array)o=F5.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=F5.BYTE;else if(e.array.constructor===Uint8Array)o=F5.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type: `+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;let s=Fue(e,n,r),c;t!==void 0&&(c=e===t.index?F5.ELEMENT_ARRAY_BUFFER:F5.ARRAY_BUFFER);let l=this.processBufferView(e,o,n,r,c),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:o,count:r,max:s.max,min:s.min,type:a[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||=[],i.accessors.push(u)-1}processImage(e,t,n,r=`image/png`){if(e!==null){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(e)||a.images.set(e,{});let l=a.images.get(e),u=r+`:flipY/`+n.toString();if(l[u]!==void 0)return l[u];o.images||=[];let d={mimeType:r},f=M5();f.width=Math.min(e.width,s.maxTextureSize),f.height=Math.min(e.height,s.maxTextureSize);let p=f.getContext(`2d`,{willReadFrequently:!0});if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){t!==1023&&console.error(`GLTFExporter: Only RGBAFormat is supported.`,t),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)p.drawImage(e,0,0,f.width,f.height);else throw Error(`THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.`);s.binary===!0?c.push(Iue(f,r).then(e=>i.processBufferViewImage(e)).then(e=>{d.bufferView=e})):d.uri=Fp.getDataURL(f,r);let m=o.images.push(d)-1;return l[u]=m,m}throw Error(`THREE.GLTFExporter: No valid image data found. Unable to process texture.`)}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:L5[e.magFilter],minFilter:L5[e.minFilter],wrapS:L5[e.wrapS],wrapT:L5[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||=[],e instanceof B_&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let i=e.userData.mimeType,a=this.processImage(e.image,e.format,e.flipY,i),o={sampler:this.processSampler(e)};i===`image/webp`?(o.extensions=o.extensions||{},o.extensions.EXT_texture_webp={source:a},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):o.source=a,e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}async processMaterialAsync(e,t){let n=this.cache,r=this.json,i=t!==void 0&&t.hasAttribute(`tangent`),a=e.normalMap?e.uuid+`:`+i:e.uuid;if(n.materials.has(a))return n.materials.get(a);if(e.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;r.materials||=[];let o={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let s=e.color.toArray().concat([e.opacity]);if(k5(s,[1,1,1,1])||(o.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(o.pbrMetallicRoughness.metallicFactor=e.metalness,o.pbrMetallicRoughness.roughnessFactor=e.roughness):(o.pbrMetallicRoughness.metallicFactor=0,o.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),o.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),o.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(o.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),o.emissiveTexture=t}}if(e.normalMap){let t=e.normalScale,n=t.x<0,r=i?t.y<0:t.y>0,a=e.normalMap;(n||r)&&(a=await this.buildNormalMapTextureAsync(e.normalMap,n,r));let s={index:await this.processTextureAsync(a),texCoord:e.normalMap.channel};Math.abs(t.x)!==1&&(s.scale=Math.abs(t.x)),this.applyTextureTransform(s,e.normalMap),o.normalTexture=s}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),o.occlusionTexture=t}e.transparent?o.alphaMode=`BLEND`:e.alphaTest>0&&(o.alphaMode=`MASK`,o.alphaCutoff=e.alphaTest),e.side===2&&(o.doubleSided=!0),e.name!==``&&(o.name=e.name),this.serializeUserData(e,o),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,o)});let c=r.materials.push(o)-1;return n.materials.set(a,c),c}async processMeshAsync(e){let t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);let i=r.join(`:`);if(t.meshes.has(i))return t.meshes.get(i);let a=e.geometry,o;o=e.isLineSegments?F5.LINES:e.isLineLoop?F5.LINE_LOOP:e.isLine?F5.LINE_STRIP:e.isPoints?F5.POINTS:e.material.wireframe?F5.LINES:F5.TRIANGLES;let s={},c={},l=[],u=[],d={uv:`TEXCOORD_0`,uv1:`TEXCOORD_1`,uv2:`TEXCOORD_2`,uv3:`TEXCOORD_3`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},f=a.getAttribute(`normal`);f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),a.setAttribute(`normal`,this.createNormalizedNormalAttribute(f)));let p=null;for(let e in a.attributes){if(e.slice(0,5)===`morph`)continue;let n=a.attributes[e];if(e=d[e]||e.toUpperCase(),!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)&&!e.startsWith(`_`)&&(e=`_`+e),t.attributes.has(this.getUID(n))){c[e]=t.attributes.get(this.getUID(n));continue}p=null;let r=n.array;e===`JOINTS_0`&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)?(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),p=P5.Utils.toTypedBufferAttribute(n,Uint16Array)):(r instanceof Uint32Array||r instanceof Int32Array)&&!e.startsWith(`_`)&&(console.warn(`GLTFExporter: Attribute "${e}" converted to type FLOAT.`),p=P5.Utils.toTypedBufferAttribute(n,Float32Array));let i=this.processAccessor(p||n,a);i!==null&&(e.startsWith(`_`)||this.detectMeshQuantization(e,n),c[e]=i,t.attributes.set(this.getUID(n),i))}if(f!==void 0&&a.setAttribute(`normal`,f),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let n=[],r=[],i={};if(e.morphTargetDictionary!==void 0)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){let s={},c=!1;for(let e in a.morphAttributes){if(e!==`position`&&e!==`normal`){c||=(console.warn(`GLTFExporter: Only POSITION and NORMAL morph are supported.`),!0);continue}let n=a.morphAttributes[e][o],r=e.toUpperCase(),i=a.attributes[e];if(t.attributes.has(this.getUID(n,!0))){s[r]=t.attributes.get(this.getUID(n,!0));continue}let l=n.clone();if(!a.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)t===0&&l.setX(e,n.getX(e)-i.getX(e)),t===1&&l.setY(e,n.getY(e)-i.getY(e)),t===2&&l.setZ(e,n.getZ(e)-i.getZ(e)),t===3&&l.setW(e,n.getW(e)-i.getW(e));s[r]=this.processAccessor(l,a),t.attributes.set(this.getUID(i,!0),s[r])}u.push(s),n.push(e.morphTargetInfluences[o]),e.morphTargetDictionary!==void 0&&r.push(i[o])}s.weights=n,r.length>0&&(s.extras={},s.extras.targetNames=r)}let m=Array.isArray(e.material);if(m&&a.groups.length===0)return null;let h=!1;if(m&&a.index===null){let e=[];for(let t=0,n=a.attributes.position.count;t<n;t++)e[t]=t;a.setIndex(e),h=!0}let g=m?e.material:[e.material],_=m?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=_.length;e<n;e++){let n={mode:o,attributes:c};if(this.serializeUserData(a,n),u.length>0&&(n.targets=u),a.index!==null){let r=this.getUID(a.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),t.attributes.has(r)?n.indices=t.attributes.get(r):(n.indices=this.processAccessor(a.index,a,_[e].start,_[e].count),t.attributes.set(r,n.indices)),n.indices===null&&delete n.indices}let r=await this.processMaterialAsync(g[_[e].materialIndex],a);r!==null&&(n.material=r),l.push(n)}h===!0&&a.setIndex(null),s.primitives=l,n.meshes||=[],await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,s)});let v=n.meshes.push(s)-1;return t.meshes.set(i,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[I5])return;let n;switch(t.array.constructor){case Int8Array:n=`byte`;break;case Uint8Array:n=`unsigned byte`;break;case Int16Array:n=`short`;break;case Uint16Array:n=`unsigned short`;break;default:return}t.normalized&&(n+=` normalized`);let r=e.split(`_`,1)[0];N5[r]&&N5[r].includes(n)&&(this.extensionsUsed[I5]=!0,this.extensionsRequired[I5]=!0)}processCamera(e){let t=this.json;t.cameras||=[];let n=e.isOrthographicCamera,r={type:n?`orthographic`:`perspective`};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:Tp.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==``&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||=[],e=P5.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,a=[],o=[];for(let e=0;e<i.length;++e){let n=i[e],s=ex.parseTrackName(n.name),c=ex.findNode(t,s.nodeName),l=R5[s.propertyName];if(s.objectName===`bones`&&(c=c.isSkinnedMesh===!0?c.skeleton.getBoneByName(s.objectIndex):void 0),!c||!l){console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,n.name);continue}let u=n.values.length/n.times.length;l===R5.morphTargetInfluences&&(u/=c.morphTargetInfluences.length);let d;n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(d=`CUBICSPLINE`,u/=3):d=n.getInterpolation()===2300?`STEP`:`LINEAR`,o.push({input:this.processAccessor(new fh(n.times,1)),output:this.processAccessor(new fh(n.values,u)),interpolation:d}),a.push({sampler:o.length-1,target:{node:r.get(c),path:l}})}let s={name:e.name||`clip_`+n.animations.length,samplers:o,channels:a};return this.serializeUserData(e,s),n.animations.push(s),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;let a=e.skeleton.bones[0];if(a===void 0)return null;let o=[],s=new Float32Array(i.bones.length*16),c=new Jp;for(let t=0;t<i.bones.length;++t)o.push(n.get(i.bones[t])),c.copy(i.boneInverses[t]),c.multiply(e.bindMatrix).toArray(s,t*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new fh(s,16)),joints:o,skeleton:n.get(a)}),r.skin=t.skins.length-1}async processNodeAsync(e){let t=this.json,n=this.options,r=this.nodeMap;if(t.nodes||=[],e.pivot!==null)return await this._processNodeWithPivotAsync(e);let i={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();k5(t,[0,0,0,1])||(i.rotation=t),k5(n,[0,0,0])||(i.translation=n),k5(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),Pue(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==``&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=await this.processMeshAsync(e);t!==null&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let a=t.nodes.push(i)-1;if(r.set(e,a),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(i);e!==null&&t.push(e)}}t.length>0&&(i.children=t)}return await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)}),a}async _processNodeWithPivotAsync(e){let t=this.json,n=this.options,r=this.nodeMap,i=e.pivot,a={},o=e.quaternion.toArray(),s=[e.position.x+i.x,e.position.y+i.y,e.position.z+i.z],c=e.scale.toArray();k5(o,[0,0,0,1])||(a.rotation=o),k5(s,[0,0,0])||(a.translation=s),k5(c,[1,1,1])||(a.scale=c),a.extras={pivot:i.toArray()},e.name!==``&&(a.name=String(e.name)),this.serializeUserData(e,a);let l=t.nodes.push(a)-1;r.set(e,l);let u={},d=[-i.x,-i.y,-i.z];if(k5(d,[0,0,0])||(u.translation=d),e.isMesh||e.isLine||e.isPoints){let t=await this.processMeshAsync(e);t!==null&&(u.mesh=t)}else e.isCamera&&(u.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let f=[t.nodes.push(u)-1];if(e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(i);e!==null&&t.push(e)}}t.length>0&&(u.children=t)}return a.children=f,await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,a)}),l}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new Mm;t.name=`AuxScene`;for(let n=0;n<e.length;n++)t.children.push(e[n]);await this.processSceneAsync(t)}async processInputAsync(e){let t=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});let n=[];for(let t=0;t<e.length;t++)e[t]instanceof Mm?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);if(e.length===1)for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);else for(let n=0;n<e.length;n++){let r=t.animations[n]||[];for(let t=0;t<r.length;++t)this.processAnimation(r[t],e[n])}await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let t=0,n=this.plugins.length;t<n;t++)await e(this.plugins[t])}},q5=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},J5=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Y5=class{constructor(e){this.writer=e,this.name=`KHR_materials_clearcoat`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},X5=class{constructor(e){this.writer=e,this.name=`KHR_materials_dispersion`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},Z5=class{constructor(e){this.writer=e,this.name=`KHR_materials_iridescence`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},Q5=class{constructor(e){this.writer=e,this.name=`KHR_materials_transmission`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},$5=class{constructor(e){this.writer=e,this.name=`KHR_materials_volume`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},e7=class{constructor(e){this.writer=e,this.name=`KHR_materials_ior`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},t7=class{constructor(e){this.writer=e,this.name=`KHR_materials_specular`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(z5)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},n7=class{constructor(e){this.writer=e,this.name=`KHR_materials_sheen`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},r7=class{constructor(e){this.writer=e,this.name=`KHR_materials_anisotropy`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},i7=class{constructor(e){this.writer=e,this.name=`KHR_materials_emissive_strength`}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},a7=class{constructor(e){this.writer=e,this.name=`EXT_materials_bump`}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},o7=class{constructor(e){this.writer=e,this.name=`EXT_mesh_gpu_instancing`}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=e,i=new Float32Array(r.count*3),a=new Float32Array(r.count*4),o=new Float32Array(r.count*3),s=new Jp,c=new B,l=new Ep,u=new B;for(let e=0;e<r.count;e++)r.getMatrixAt(e,s),s.decompose(c,l,u),c.toArray(i,e*3),l.toArray(a,e*4),u.toArray(o,e*3);let d={TRANSLATION:n.processAccessor(new fh(i,3)),ROTATION:n.processAccessor(new fh(a,4)),SCALE:n.processAccessor(new fh(o,3))};r.instanceColor&&(d._COLOR_0=n.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:d},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}},P5.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e<i.length;++e){let a=i[e],o=ex.parseTrackName(a.name),s=ex.findNode(t,o.nodeName);if(o.propertyName!==`morphTargetInfluences`||o.propertyIndex===void 0){n.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),a=a.clone(),a.setInterpolation(jf)}let c=s.morphTargetInfluences.length,l=s.morphTargetDictionary[o.propertyIndex];if(l===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+o.propertyIndex);let u;if(r[s.uuid]===void 0){u=a.clone();let e=new u.ValueBufferType(c*u.times.length);for(let t=0;t<u.times.length;t++)e[t*c+l]=u.values[t];u.name=(o.nodeName||``)+`.morphTargetInfluences`,u.values=e,r[s.uuid]=u,n.push(u);continue}let d=a.createInterpolant(new a.ValueBufferType(1));u=r[s.uuid];for(let e=0;e<u.times.length;e++)u.values[e*c+l]=d.evaluate(u.times[e]);for(let e=0;e<a.times.length;e++){let t=this.insertKeyframe(u,a.times[e]);u.values[t*c+l]=a.values[e]}}return e.tracks=n,e},toTypedBufferAttribute:function(e,t){let n=new fh(new t(e.count*e.itemSize),e.itemSize,!1);if(!e.normalized&&!e.isInterleavedBufferAttribute)return n.array.set(e.array),n;for(let t=0,r=e.count;t<r;t++)for(let r=0;r<e.itemSize;r++)n.setComponent(t,r,e.getComponent(t,r));return n}}}));function s7(e,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===2||t===1){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,i=[];if(t===2)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let a=e.clone();return a.setIndex(i),a.clearGroups(),a}return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}var Rue=p((()=>{DY()}));function zue(e){let t=new Map,n=new Map,r=e.clone();return c7(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function c7(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)c7(e.children[r],t.children[r],n)}var Bue=p((()=>{})),Vue=h({GLTFLoader:()=>h7});function Hue(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function l7(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}function Uue(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Yv({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function u7(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function d7(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function Wue(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function Gue(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function Kue(e){let t,n=e.extensions&&e.extensions[g7.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+f7(n.attributes):e.indices+`:`+f7(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+f7(e.targets[n]);return t}function f7(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function p7(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function que(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}function Jue(e,t,n){let r=t.attributes,i=new qm;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new B(t[0],t[1],t[2]),new B(a[0],a[1],a[2])),e.normalized){let t=p7(K7[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new B,t=new B;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=p7(K7[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new Th;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function m7(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=X7[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return Np.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Np.workingColorSpace}" not supported.`),d7(e,t),Jue(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:Wue(e,t.targets,n)})}var h7,g7,_7,v7,y7,b7,x7,S7,C7,w7,T7,E7,D7,O7,k7,A7,j7,M7,N7,P7,F7,I7,L7,R7,z7,B7,V7,H7,U7,W7,G7,K7,q7,J7,Y7,X7,Z7,Q7,$7,e9,t9,Yue=p((()=>{DY(),Rue(),Bue(),h7=class extends Cy{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new b7(e)}),this.register(function(e){return new x7(e)}),this.register(function(e){return new A7(e)}),this.register(function(e){return new j7(e)}),this.register(function(e){return new M7(e)}),this.register(function(e){return new C7(e)}),this.register(function(e){return new w7(e)}),this.register(function(e){return new T7(e)}),this.register(function(e){return new E7(e)}),this.register(function(e){return new y7(e)}),this.register(function(e){return new D7(e)}),this.register(function(e){return new S7(e)}),this.register(function(e){return new k7(e)}),this.register(function(e){return new O7(e)}),this.register(function(e){return new _7(e)}),this.register(function(e){return new N7(e,g7.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new N7(e,g7.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new P7(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=sb.extractUrlBase(e);a=sb.resolveURL(t,this.path)}else a=sb.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Ey(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===F7){try{a[g7.KHR_BINARY_GLTF]=new R7(e)}catch(e){r&&r(e);return}i=JSON.parse(a[g7.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new t9(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case g7.KHR_MATERIALS_UNLIT:a[t]=new v7;break;case g7.KHR_DRACO_MESH_COMPRESSION:a[t]=new z7(i,this.dracoLoader);break;case g7.KHR_TEXTURE_TRANSFORM:a[t]=new B7;break;case g7.KHR_MESH_QUANTIZATION:a[t]=new V7;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}},g7={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},_7=class{constructor(e){this.parser=e,this.name=g7.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new Om(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Wf);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new eb(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new Zy(s),o.distance=c;break;case`spot`:o=new Yy(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),d7(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},v7=class{constructor(){this.name=g7.KHR_MATERIALS_UNLIT}getMaterialType(){return dg}extendParams(e,t,n){let r=[];e.color=new Om(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Wf),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Uf))}return Promise.all(r)}},y7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},b7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new z(e,e)}return Promise.all(r)}},x7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_DISPERSION}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},S7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},C7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_SHEEN}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new Om(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Wf)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Uf)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},w7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},T7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_VOLUME}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new Om().setRGB(i[0],i[1],i[2],Wf),Promise.all(r)}},E7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_IOR}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);return n===null?Promise.resolve():(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3),Promise.resolve())}},D7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_SPECULAR}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new Om().setRGB(i[0],i[1],i[2],Wf),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Uf)),Promise.all(r)}},O7=class{constructor(e){this.parser=e,this.name=g7.EXT_MATERIALS_BUMP}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},k7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},A7=class{constructor(e){this.parser=e,this.name=g7.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},j7=class{constructor(e){this.parser=e,this.name=g7.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},M7=class{constructor(e){this.parser=e,this.name=g7.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},N7=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},P7=class{constructor(e){this.name=g7.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==G7.TRIANGLES&&e.mode!==G7.TRIANGLE_STRIP&&e.mode!==G7.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Jp,n=new B,a=new Ep,s=new B(1,1,1),c=new qg(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));for(let t in o)if(t===`_COLOR_0`){let e=o[t];c.instanceColor=new zg(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);xm.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},F7=`glTF`,I7=12,L7={JSON:1313821514,BIN:5130562},R7=class{constructor(e){this.name=g7.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,I7),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==F7)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-I7,i=new DataView(e,I7),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===L7.JSON){let r=new Uint8Array(e,I7+a,t);this.content=n.decode(r)}else if(r===L7.BIN){let n=I7+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},z7=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=g7.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=X7[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=X7[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=K7[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Wf,n)})})}},B7=class{constructor(){this.name=g7.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},V7=class{constructor(){this.name=g7.KHR_MESH_QUANTIZATION}},H7=class extends oy{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},U7=new Ep,W7=class extends H7{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return U7.fromArray(i).normalize().toArray(i),i}},G7={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},K7={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},q7={9728:ud,9729:hd,9984:dd,9985:gd,9986:pd,9987:vd},J7={33071:cd,33648:ld,10497:sd},Y7={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X7={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},Z7={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},Q7={CUBICSPLINE:void 0,LINEAR:jf,STEP:Af},$7={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`},e9=new Jp,t9=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Hue,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}this.textureLoader=typeof createImageBitmap>`u`||n&&r<17||i&&a<98?new Ny(this.options.manager):new gb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ey(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return u7(i,a,r),d7(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[g7.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(sb.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=Y7[r.type],t=K7[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new fh(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=Y7[r.type],o=K7[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new Ph(f,u/s),t.cache.add(n,c)),p=new Ih(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new fh(f,a,d);if(r.sparse!==void 0){let t=Y7.SCALAR,n=K7[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new fh(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=q7[n.magFilter]||1006,t.minFilter=q7[n.minFilter]||1008,t.wrapS=J7[n.wrapS]||1e3,t.wrapT=J7[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new Bp(e);t.needsUpdate=!0,n(t)}),t.load(sb.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),d7(e,a),e.userData.mimeType=a.mimeType||que(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[g7.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[g7.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[g7.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new j_,Rh.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new v_,Rh.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Yv}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[g7.KHR_MATERIALS_UNLIT]){let e=r[g7.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new Om(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Wf),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Uf)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||$7.OPAQUE;if(l===$7.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===$7.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==dg&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new z(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==dg&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==dg){let e=i.emissiveFactor;o.emissive=new Om().setRGB(e[0],e[1],e[2],Wf)}return i.emissiveTexture!==void 0&&a!==dg&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Uf)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),d7(n,i),t.associations.set(n,{materials:e}),i.extensions&&u7(r,n,i),n})}createUniqueName(e){let t=ex.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[g7.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return m7(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=Kue(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[g7.KHR_DRACO_MESH_COMPRESSION]?i(o):m7(new Nh,o,t),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?Uue(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===G7.TRIANGLES||u.mode===G7.TRIANGLE_STRIP||u.mode===G7.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Ng(l,f):new Cg(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===G7.TRIANGLE_STRIP?d.geometry=s7(d.geometry,1):u.mode===G7.TRIANGLE_FAN&&(d.geometry=s7(d.geometry,2));else if(u.mode===G7.LINES)d=new k_(l,f);else if(u.mode===G7.LINE_STRIP)d=new E_(l,f);else if(u.mode===G7.LINE_LOOP)d=new A_(l,f);else if(u.mode===G7.POINTS)d=new I_(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&Gue(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),d7(d,i),u.extensions&&u7(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&u7(r,c[0],i),c[0];let l=new Sm;i.extensions&&u7(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return n.type===`perspective`?t=new qy(Tp.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new Qy(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),d7(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new Jp;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new Rg(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new yy(i,void 0,l);return d7(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,e9)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new B().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Pg:t.length>1?new Sm:t.length===1?t[0]:new xm,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),d7(o,i),i.extensions&&u7(n,o,i),i.matrix!==void 0){let e=new Jp;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new Sm;n.name&&(i.name=r.createUniqueName(n.name)),d7(i,n),n.extensions&&u7(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(zue(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof Rh||e instanceof Bp)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}Z7[i.path]===Z7.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(Z7[i.path]){case Z7.weights:l=my;break;case Z7.rotation:l=gy;break;case Z7.translation:case Z7.scale:l=vy;break;default:switch(n.itemSize){case 1:l=my;break;default:l=vy}}let u=r.interpolation===void 0?jf:Q7[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new l(s[e]+`.`+Z7[i.path],t.array,d,u);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=p7(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof gy?W7:H7)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}})),Xue=m((e=>{e.deflate=Ue,e.deflateSync=We,e.inflate=qe,e.inflateSync=Je,e.gzip=Ze,e.compress=Ze,e.gzipSync=Qe,e.compressSync=Qe,e.gunzip=tt,e.gunzipSync=nt,e.zlib=it,e.zlibSync=at,e.unzlib=ct,e.unzlibSync=lt,e.gzip=Ze,e.compress=Ze,e.decompress=dt,e.decompressSync=ft,e.strToU8=vt,e.strFromU8=yt,e.zip=Ot,e.zipSync=kt,e.unzip=Mt,e.unzipSync=Nt;var t={},n={};n.default=(function(e,n,r,i,a){var o=new Worker(t[n]||(t[n]=URL.createObjectURL(new Blob([e+`;addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return o.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],a(r,null)}else a(null,t)},o.postMessage(r,i),o});var r=Uint8Array,i=Uint16Array,a=Int32Array,o=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),c=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=function(e,t){for(var n=new i(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new a(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return{b:n,r:o}},u=l(o,2),d=u.b,f=u.r;d[28]=258,f[258]=28;for(var p=l(s,0),m=p.b,h=p.r,g=new i(32768),_=0;_<32768;++_){var v=(_&43690)>>1|(_&21845)<<1;v=(v&52428)>>2|(v&13107)<<2,v=(v&61680)>>4|(v&3855)<<4,g[_]=((v&65280)>>8|(v&255)<<8)>>1}for(var y=(function(e,t,n){for(var r=e.length,a=0,o=new i(t);a<r;++a)e[a]&&++o[e[a]-1];var s=new i(t);for(a=1;a<t;++a)s[a]=s[a-1]+o[a-1]<<1;var c;if(n){c=new i(1<<t);var l=15-t;for(a=0;a<r;++a)if(e[a])for(var u=a<<4|e[a],d=t-e[a],f=s[e[a]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)c[g[f]>>l]=u}else for(c=new i(r),a=0;a<r;++a)e[a]&&(c[a]=g[s[e[a]-1]++]>>15-e[a]);return c}),b=new r(288),_=0;_<144;++_)b[_]=8;for(var _=144;_<256;++_)b[_]=9;for(var _=256;_<280;++_)b[_]=7;for(var _=280;_<288;++_)b[_]=8;for(var x=new r(32),_=0;_<32;++_)x[_]=5;var S=y(b,9,0),C=y(b,9,1),w=y(x,5,0),T=y(x,5,1),E=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},D=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},O=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},k=function(e){return(e+7)/8|0},A=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new r(e.subarray(t,n))};e.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var j=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],M=function(e,t,n){var r=Error(t||j[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,M),!n)throw r;return r},N=function(e,t,n,i){var a=e.length,l=i?i.length:0;if(!a||t.f&&!t.l)return n||new r(0);var u=!n,f=u||t.i!=2,p=t.i;u&&(n=new r(a*3));var h=function(e){var t=n.length;if(e>t){var i=new r(Math.max(t*2,e));i.set(n),n=i}},g=t.f||0,_=t.p||0,v=t.b||0,b=t.l,x=t.d,S=t.m,w=t.n,j=a*8;do{if(!b){g=D(e,_,1);var N=D(e,_+1,3);if(_+=3,!N){var P=k(_)+4,ee=e[P-4]|e[P-3]<<8,te=P+ee;if(te>a){p&&M(0);break}f&&h(v+ee),n.set(e.subarray(P,te),v),t.b=v+=ee,t.p=_=te*8,t.f=g;continue}if(N==1)b=C,x=T,S=9,w=5;else if(N==2){var ne=D(e,_,31)+257,re=D(e,_+10,15)+4,ie=ne+D(e,_+5,31)+1;_+=14;for(var ae=new r(ie),oe=new r(19),se=0;se<re;++se)oe[c[se]]=D(e,_+se*3,7);_+=re*3;for(var ce=E(oe),le=(1<<ce)-1,ue=y(oe,ce,1),se=0;se<ie;){var de=ue[D(e,_,le)];_+=de&15;var P=de>>4;if(P<16)ae[se++]=P;else{var fe=0,pe=0;for(P==16?(pe=3+D(e,_,3),_+=2,fe=ae[se-1]):P==17?(pe=3+D(e,_,7),_+=3):P==18&&(pe=11+D(e,_,127),_+=7);pe--;)ae[se++]=fe}}var me=ae.subarray(0,ne),he=ae.subarray(ne);S=E(me),w=E(he),b=y(me,S,1),x=y(he,w,1)}else M(1);if(_>j){p&&M(0);break}}f&&h(v+131072);for(var ge=(1<<S)-1,_e=(1<<w)-1,ve=_;;ve=_){var fe=b[O(e,_)&ge],ye=fe>>4;if(_+=fe&15,_>j){p&&M(0);break}if(fe||M(2),ye<256)n[v++]=ye;else if(ye==256){ve=_,b=null;break}else{var be=ye-254;if(ye>264){var se=ye-257,xe=o[se];be=D(e,_,(1<<xe)-1)+d[se],_+=xe}var Se=x[O(e,_)&_e],Ce=Se>>4;Se||M(3),_+=Se&15;var he=m[Ce];if(Ce>3){var xe=s[Ce];he+=O(e,_)&(1<<xe)-1,_+=xe}if(_>j){p&&M(0);break}f&&h(v+131072);var we=v+be;if(v<he){var Te=l-he,Ee=Math.min(he,we);for(Te+v<0&&M(3);v<Ee;++v)n[v]=i[Te+v]}for(;v<we;++v)n[v]=n[v-he]}}t.l=b,t.p=ve,t.b=v,t.f=g,b&&(g=1,t.m=S,t.d=x,t.n=w)}while(!g);return v!=n.length&&u?A(n,0,v):n.subarray(0,v)},P=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},ee=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},te=function(e,t){for(var n=[],a=0;a<e.length;++a)e[a]&&n.push({s:a,f:e[a]});var o=n.length,s=n.slice();if(!o)return{t:ce,l:0};if(o==1){var c=new r(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],u=n[1],d=0,f=1,p=2;for(n[0]={s:-1,f:l.f+u.f,l,r:u};f!=o-1;)l=n[n[d].f<n[p].f?d++:p++],u=n[d!=f&&n[d].f<n[p].f?d++:p++],n[f++]={s:-1,f:l.f+u.f,l,r:u};for(var m=s[0].s,a=1;a<o;++a)s[a].s>m&&(m=s[a].s);var h=new i(m+1),g=ne(n[f-1],h,0);if(g>t){var a=0,_=0,v=g-t,y=1<<v;for(s.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});a<o;++a){var b=s[a].s;if(h[b]>t)_+=y-(1<<g-h[b]),h[b]=t;else break}for(_>>=v;_>0;){var x=s[a].s;h[x]<t?_-=1<<t-h[x]++-1:++a}for(;a>=0&&_;--a){var S=s[a].s;h[S]==t&&(--h[S],++_)}g=t}return{t:new r(h),l:g}},ne=function(e,t,n){return e.s==-1?Math.max(ne(e.l,t,n+1),ne(e.r,t,n+1)):t[e.s]=n},re=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new i(++t),r=0,a=e[0],o=1,s=function(e){n[r++]=e},c=1;c<=t;++c)if(e[c]==a&&c!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(a),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(a);o=1,a=e[c]}return{c:n.subarray(0,r),n:t}},ie=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},ae=function(e,t,n){var r=n.length,i=k(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},oe=function(e,t,n,r,a,l,u,d,f,p,m){P(t,m++,n),++a[256];for(var h=te(a,15),g=h.t,_=h.l,v=te(l,15),C=v.t,T=v.l,E=re(g),D=E.c,O=E.n,k=re(C),A=k.c,j=k.n,M=new i(19),N=0;N<D.length;++N)++M[D[N]&31];for(var N=0;N<A.length;++N)++M[A[N]&31];for(var ne=te(M,7),oe=ne.t,se=ne.l,ce=19;ce>4&&!oe[c[ce-1]];--ce);var le=p+5<<3,ue=ie(a,b)+ie(l,x)+u,de=ie(a,g)+ie(l,C)+u+14+3*ce+ie(M,oe)+2*M[16]+3*M[17]+7*M[18];if(f>=0&&le<=ue&&le<=de)return ae(t,m,e.subarray(f,f+p));var fe,pe,me,he;if(P(t,m,1+(de<ue)),m+=2,de<ue){fe=y(g,_,0),pe=g,me=y(C,T,0),he=C;var ge=y(oe,se,0);P(t,m,O-257),P(t,m+5,j-1),P(t,m+10,ce-4),m+=14;for(var N=0;N<ce;++N)P(t,m+3*N,oe[c[N]]);m+=3*ce;for(var _e=[D,A],ve=0;ve<2;++ve)for(var ye=_e[ve],N=0;N<ye.length;++N){var be=ye[N]&31;P(t,m,ge[be]),m+=oe[be],be>15&&(P(t,m,ye[N]>>5&127),m+=ye[N]>>12)}}else fe=S,pe=b,me=w,he=x;for(var N=0;N<d;++N){var xe=r[N];if(xe>255){var be=xe>>18&31;ee(t,m,fe[be+257]),m+=pe[be+257],be>7&&(P(t,m,xe>>23&31),m+=o[be]);var Se=xe&31;ee(t,m,me[Se]),m+=he[Se],Se>3&&(ee(t,m,xe>>5&8191),m+=s[Se])}else ee(t,m,fe[xe]),m+=pe[xe]}return ee(t,m,fe[256]),m+pe[256]},se=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ce=new r(0),le=function(e,t,n,c,l,u){var d=u.z||e.length,p=new r(c+d+5*(1+Math.ceil(d/7e3))+l),m=p.subarray(c,p.length-l),g=u.l,_=(u.r||0)&7;if(t){_&&(m[0]=u.r>>3);for(var v=se[t-1],y=v>>13,b=v&8191,x=(1<<n)-1,S=u.p||new i(32768),C=u.h||new i(x+1),w=Math.ceil(n/3),T=2*w,E=function(t){return(e[t]^e[t+1]<<w^e[t+2]<<T)&x},D=new a(25e3),O=new i(288),j=new i(32),M=0,N=0,P=u.i||0,ee=0,te=u.w||0,ne=0;P+2<d;++P){var re=E(P),ie=P&32767,ce=C[re];if(S[ie]=ce,C[re]=ie,te<=P){var le=d-P;if((M>7e3||ee>24576)&&(le>423||!g)){_=oe(e,m,0,D,O,j,N,ee,ne,P-ne,_),ee=M=N=0,ne=P;for(var ue=0;ue<286;++ue)O[ue]=0;for(var ue=0;ue<30;++ue)j[ue]=0}var de=2,fe=0,pe=b,me=ie-ce&32767;if(le>2&&re==E(P-me))for(var he=Math.min(y,le)-1,ge=Math.min(32767,P),_e=Math.min(258,le);me<=ge&&--pe&&ie!=ce;){if(e[P+de]==e[P+de-me]){for(var ve=0;ve<_e&&e[P+ve]==e[P+ve-me];++ve);if(ve>de){if(de=ve,fe=me,ve>he)break;for(var ye=Math.min(me,ve-2),be=0,ue=0;ue<ye;++ue){var xe=P-me+ue&32767,Se=xe-S[xe]&32767;Se>be&&(be=Se,ce=xe)}}}ie=ce,ce=S[ie],me+=ie-ce&32767}if(fe){D[ee++]=268435456|f[de]<<18|h[fe];var Ce=f[de]&31,we=h[fe]&31;N+=o[Ce]+s[we],++O[257+Ce],++j[we],te=P+de,++M}else D[ee++]=e[P],++O[e[P]]}}for(P=Math.max(P,te);P<d;++P)D[ee++]=e[P],++O[e[P]];_=oe(e,m,g,D,O,j,N,ee,ne,P-ne,_),g||(u.r=_&7|m[_/8|0]<<3,_-=7,u.h=C,u.p=S,u.i=P,u.w=te)}else{for(var P=u.w||0;P<d+g;P+=65535){var Te=P+65535;Te>=d&&(m[_/8|0]=g,Te=d),_=ae(m,_+1,e.subarray(P,Te))}u.i=d}return A(p,0,c+k(_)+l)},ue=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),de=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=ue[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},fe=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},pe=function(e,t,n,i,a){if(!a&&(a={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),s=new r(o.length+e.length);s.set(o),s.set(e,o.length),e=s,a.w=o.length}return le(e,t.level==null?6:t.level,t.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,a)},me=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},he=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype){if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString()}else t+=l}else n[c]=s}return t},ge=[],_e=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},ve=function(e,t,r,i){if(!ge[r]){for(var a=``,o={},s=e.length-1,c=0;c<s;++c)a=he(e[c],a,o);ge[r]={c:he(e[s],a,o),e:o}}var l=me({},ge[r].e);return(0,n.default)(ge[r].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,r,l,_e(l),i)},ye=function(){return[r,i,a,o,s,c,d,m,C,T,g,j,y,E,D,O,k,A,M,N,Je,Te,Ee]},be=function(){return[r,i,a,o,s,c,f,h,S,b,w,x,g,se,ce,y,P,ee,te,ne,re,ie,ae,oe,k,A,le,pe,We,Te]},xe=function(){return[Pe,Le,Ne,de,ue]},Se=function(){return[Fe,Ie]},Ce=function(){return[Re,Ne,fe]},we=function(){return[ze]},Te=function(e){return postMessage(e,[e.buffer])},Ee=function(e){return e&&{out:e.size&&new r(e.size),dictionary:e.dictionary}},De=function(e,t,n,r,i,a){var o=ve(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},Oe=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){t.data[0]?(e.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):e.flush(t.data[1])}},ke=function(e,t,n,r,i,a,o){var s,c=ve(e,r,i,function(e,n){e?(c.terminate(),t.ondata.call(t,e)):Array.isArray(n)?n.length==1?(t.queuedSize-=n[0],t.ondrain&&t.ondrain(n[0])):(n[1]&&c.terminate(),t.ondata.call(t,e,n[0],n[1])):o(n)});c.postMessage(n),t.queuedSize=0,t.push=function(e,n){t.ondata||M(5),s&&t.ondata(M(4,0,1),null,!!n),t.queuedSize+=e.length,c.postMessage([e,s=n],e.buffer instanceof ArrayBuffer?[e.buffer]:[])},t.terminate=function(){c.terminate()},a&&(t.flush=function(e){c.postMessage([0,e])})},Ae=function(e,t){return e[t]|e[t+1]<<8},je=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Me=function(e,t){return je(e,t)+je(e,t+4)*4294967296},Ne=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Pe=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Ne(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},Fe=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&M(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Ie=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Le=function(e){return 10+(e.filename?e.filename.length+1:0)},Re=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=fe();i.p(t.dictionary),Ne(e,2,i.d())}},ze=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&M(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&M(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function Be(e,t){return typeof e==`function`&&(t=e,e={}),this.ondata=t,e}var Ve=function(){function e(e,t){if(typeof e==`function`&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new r(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return e.prototype.p=function(e,t){this.ondata(pe(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||M(5),this.s.l&&M(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var i=new r(n&-32768);i.set(this.b.subarray(0,this.s.z)),this.b=i}var a=this.b.length-this.s.z;this.b.set(e.subarray(0,a),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(a),32768),this.s.z=e.length-a+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=t&1,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2),t&&(this.s=this.o={},this.b=ce)},e.prototype.flush=function(e){if(this.ondata||M(5),this.s.l&&M(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2,e){var t=new r(6);t[0]=this.s.r>>3;var n=ae(t,this.s.r,ce);this.s.r=0,this.ondata(t.subarray(0,n>>3),!1)}},e}();e.Deflate=Ve;var He=function(){function e(e,t){ke([be,function(){return[Oe,Ve]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new Ve(e.data))},6,1)}return e}();e.AsyncDeflate=He;function Ue(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[be],function(e){return Te(We(e.data[0],e.data[1]))},0,n)}function We(e,t){return pe(e,t||{},0,0)}var Ge=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new r(32768),this.p=new r(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||M(5),this.d&&M(4),!this.p.length)this.p=e;else if(e.length){var t=new r(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=N(this.p,this.s,this.o);this.ondata(A(n,t,this.s.b),this.d),this.o=A(n,this.s.b-32768),this.s.b=this.o.length,this.p=A(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();e.Inflate=Ge;var Ke=function(){function e(e,t){ke([ye,function(){return[Oe,Ge]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new Ge(e.data))},7,0)}return e}();e.AsyncInflate=Ke;function qe(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[ye],function(e){return Te(Je(e.data[0],Ee(e.data[1])))},1,n)}function Je(e,t){return N(e,{i:2},t&&t.out,t&&t.dictionary)}var Ye=function(){function e(e,t){this.c=de(),this.l=0,this.v=1,Ve.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,Ve.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=pe(e,this.o,this.v&&Le(this.o),t&&8,this.s);this.v&&=(Pe(n,this.o),0),t&&(Ne(n,n.length-8,this.c.d()),Ne(n,n.length-4,this.l)),this.ondata(n,t)},e.prototype.flush=function(e){Ve.prototype.flush.call(this,e)},e}();e.Gzip=Ye,e.Compress=Ye;var Xe=function(){function e(e,t){ke([be,xe,function(){return[Oe,Ve,Ye]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new Ye(e.data))},8,1)}return e}();e.AsyncGzip=Xe,e.AsyncCompress=Xe;function Ze(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[be,xe,function(){return[Qe]}],function(e){return Te(Qe(e.data[0],e.data[1]))},2,n)}function Qe(e,t){t||={};var n=de(),r=e.length;n.p(e);var i=pe(e,t,Le(t),8),a=i.length;return Pe(i,t),Ne(i,a-8,n.d()),Ne(i,a-4,r),i}var $e=function(){function e(e,t){this.v=1,this.r=0,Ge.call(this,e,t)}return e.prototype.push=function(e,t){if(Ge.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),i=n.length>3?Fe(n):4;if(i>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(i),this.v=0}Ge.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=k(this.s.p)+9,this.s={i:0},this.o=new r(0),this.push(new r(0),t)):t&&Ge.prototype.c.call(this,t)},e}();e.Gunzip=$e;var et=function(){function e(e,t){var n=this;ke([ye,Se,function(){return[Oe,Ge,$e]}],this,Be.call(this,e,t),function(e){var t=new $e(e.data);t.onmember=function(e){return postMessage(e)},onmessage=Oe(t)},9,0,function(e){return n.onmember&&n.onmember(e)})}return e}();e.AsyncGunzip=et;function tt(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[ye,Se,function(){return[nt]}],function(e){return Te(nt(e.data[0],e.data[1]))},3,n)}function nt(e,t){var n=Fe(e);return n+8>e.length&&M(6,`invalid gzip data`),N(e.subarray(n,-8),{i:2},t&&t.out||new r(Ie(e)),t&&t.dictionary)}var rt=function(){function e(e,t){this.c=fe(),this.v=1,Ve.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),Ve.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=pe(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&=(Re(n,this.o),0),t&&Ne(n,n.length-4,this.c.d()),this.ondata(n,t)},e.prototype.flush=function(e){Ve.prototype.flush.call(this,e)},e}();e.Zlib=rt,e.AsyncZlib=function(){function e(e,t){ke([be,Ce,function(){return[Oe,Ve,rt]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new rt(e.data))},10,1)}return e}();function it(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[be,Ce,function(){return[at]}],function(e){return Te(at(e.data[0],e.data[1]))},4,n)}function at(e,t){t||={};var n=fe();n.p(e);var r=pe(e,t,t.dictionary?6:2,4);return Re(r,t),Ne(r,r.length-4,n.d()),r}var ot=function(){function e(e,t){Ge.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(Ge.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(ze(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&M(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),Ge.prototype.c.call(this,t)},e}();e.Unzlib=ot;var st=function(){function e(e,t){ke([ye,we,function(){return[Oe,Ge,ot]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new ot(e.data))},11,0)}return e}();e.AsyncUnzlib=st;function ct(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[ye,we,function(){return[lt]}],function(e){return Te(lt(e.data[0],Ee(e.data[1])))},5,n)}function lt(e,t){return N(e.subarray(ze(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var ut=function(){function e(e,t){this.o=Be.call(this,e,t)||{},this.G=$e,this.I=Ge,this.Z=ot}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,n){e.ondata(t,n)}},e.prototype.push=function(e,t){if(this.ondata||M(5),this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new r(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;this.p.length>2&&(this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(this.o):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},e}();e.Decompress=ut,e.AsyncDecompress=function(){function e(e,t){ut.call(this,e,t),this.queuedSize=0,this.G=et,this.I=Ke,this.Z=st}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,n,r){e.ondata(t,n,r)},this.s.ondrain=function(t){e.queuedSize-=t,e.ondrain&&e.ondrain(t)}},e.prototype.push=function(e,t){this.queuedSize+=e.length,ut.prototype.push.call(this,e,t)},e}();function dt(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),e[0]==31&&e[1]==139&&e[2]==8?tt(e,t,n):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?qe(e,t,n):ct(e,t,n)}function ft(e,t){return e[0]==31&&e[1]==139&&e[2]==8?nt(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?Je(e,t):lt(e,t)}var pt=function(e,t,n,i){for(var a in e){var o=e[a],s=t+a,c=i;Array.isArray(o)&&(c=me(i,o[1]),o=o[0]),ArrayBuffer.isView(o)?n[s]=[o,c]:(n[s+=`/`]=[new r(0),c],pt(o,s,n,i))}},mt=typeof TextEncoder<`u`&&new TextEncoder,ht=typeof TextDecoder<`u`&&new TextDecoder,gt=0;try{ht.decode(ce,{stream:!0}),gt=1}catch{}var _t=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:A(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};e.DecodeUTF8=function(){function e(e){this.ondata=e,gt?this.t=new TextDecoder:this.p=ce}return e.prototype.push=function(e,t){if(this.ondata||M(5),t=!!t,this.t){this.ondata(this.t.decode(e,{stream:!0}),t),t&&(this.t.decode().length&&M(8),this.t=null);return}this.p||M(4);var n=new r(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=_t(n),a=i.s,o=i.r;t?(o.length&&M(8),this.p=null):this.p=o,this.ondata(a,t)},e}(),e.EncodeUTF8=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){this.ondata||M(5),this.d&&M(4),this.ondata(vt(e),this.d=t||!1)},e}();function vt(e,t){if(t){for(var n=new r(e.length),i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(mt)return mt.encode(e);for(var a=e.length,o=new r(e.length+(e.length>>1)),s=0,c=function(e){o[s++]=e},i=0;i<a;++i){if(s+5>o.length){var l=new r(s+8+(a-i<<1));l.set(o),o=l}var u=e.charCodeAt(i);u<128||t?c(u):u<2048?(c(192|u>>6),c(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|e.charCodeAt(++i)&1023,c(240|u>>18),c(128|u>>12&63),c(128|u>>6&63),c(128|u&63)):(c(224|u>>12),c(128|u>>6&63),c(128|u&63))}return A(o,0,s)}function yt(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(ht)return ht.decode(e);var i=_t(e),a=i.s,n=i.r;return n.length&&M(8),a}var bt=function(e){return e==1?3:e<6?2:+(e==9)},xt=function(e,t){return t+30+Ae(e,t+26)+Ae(e,t+28)},St=function(e,t,n){var r=Ae(e,t+28),i=Ae(e,t+30),a=yt(e.subarray(t+46,t+46+r),!(Ae(e,t+8)&2048)),o=t+46+r,s=Ct(e,o,i,n,je(e,t+20),je(e,t+24),je(e,t+42)),c=s[0],l=s[1],u=s[2];return[Ae(e,t+10),c,l,a,o+i+Ae(e,t+32),u]},Ct=function(e,t,n,r,i,a,o){var s=i==4294967295,c=a==4294967295,l=o==4294967295,u=t+n,d=s+c+l;if(r&&d){for(;t+4<u;t+=4+Ae(e,t+2))if(Ae(e,t)==1)return[s?Me(e,t+4+8*c):i,c?Me(e,t+4):a,l?Me(e,t+4+8*(c+s)):o,1];r<2&&M(13)}return[i,a,o,0]},wt=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&M(9),t+=r+4}return t},Tt=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=wt(l);Ne(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&M(10),Ne(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Ne(e,t,n.crc),Ne(e,t+4,a<0?-a-2:a),Ne(e,t+8,n.size)),Ne(e,t+12,c),Ne(e,t+14,d),t+=16,o!=null&&(Ne(e,t,u),Ne(e,t+6,n.attrs),Ne(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;Ne(e,t,+m),Ne(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},Et=function(e,t,n,r,i){Ne(e,t,101010256),Ne(e,t+8,n),Ne(e,t+10,n),Ne(e,t+12,r),Ne(e,t+16,i)},Dt=function(){function e(e){this.filename=e,this.c=de(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){this.ondata||M(5),this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();e.ZipPassThrough=Dt,e.ZipDeflate=function(){function e(e,t){var n=this;t||={},Dt.call(this,e),this.d=new Ve(t,function(e,t){n.ondata(null,e,t)}),this.compression=8,this.flag=bt(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){Dt.prototype.push.call(this,e,t)},e}(),e.AsyncZipDeflate=function(){function e(e,t){var n=this;t||={},Dt.call(this,e),this.d=new He(t,function(e,t,r){n.ondata(e,t,r)}),this.compression=8,this.flag=bt(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){Dt.prototype.push.call(this,e,t)},e}(),e.Zip=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(this.ondata||M(5),this.d&2)this.ondata(M(4+(this.d&1)*8,0,1),null,!1);else{var n=vt(e.filename),i=n.length,a=e.comment,o=a&&vt(a),s=i!=e.filename.length||o&&a.length!=o.length,c=i+wt(e.extra)+30;i>65535&&this.ondata(M(11,0,1),null,!1);var l=new r(c);Tt(l,0,e,n,s,-1);var u=[l],d=function(){for(var e=0,n=u;e<n.length;e++){var r=n[e];t.ondata(null,r,!1)}u=[]},f=this.d;this.d=0;var p=this.u.length,m=me(e,{f:n,u:s,o,t:function(){e.terminate&&e.terminate()},r:function(){if(d(),f){var e=t.u[p+1];e?e.r():t.d=1}f=1}}),h=0;e.ondata=function(n,i,a){if(n)t.ondata(n,i,a),t.terminate();else if(h+=i.length,u.push(i),a){var o=new r(16);Ne(o,0,134695760),Ne(o,4,e.crc),Ne(o,8,h),Ne(o,12,e.size),u.push(o),m.c=h,m.b=c+h+16,m.crc=e.crc,m.size=e.size,f&&m.r(),f=1}else f&&d()},this.u.push(m)}},e.prototype.end=function(){var e=this;if(this.d&2){this.ondata(M(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){e.d&1&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,i=0,a=this.u;i<a.length;i++){var o=a[i];n+=46+o.f.length+wt(o.extra)+(o.o?o.o.length:0)}for(var s=new r(n+22),c=0,l=this.u;c<l.length;c++){var o=l[c];Tt(s,e,o,o.f,o.u,-o.c-2,t,o.o),e+=46+o.f.length+wt(o.extra)+(o.o?o.o.length:0),t+=o.b}Et(s,e,this.u.length,n,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2},e}();function Ot(e,t,n){n||(n=t,t={}),typeof n!=`function`&&M(7);var i={};pt(e,``,i,t);var a=Object.keys(i),o=a.length,s=0,c=0,l=o,u=Array(o),d=[],f=function(){for(var e=0;e<d.length;++e)d[e]()},p=function(e,t){jt(function(){n(e,t)})};jt(function(){p=n});var m=function(){var e=new r(c+22),t=s,n=c-s;c=0;for(var i=0;i<l;++i){var a=u[i];try{var o=a.c.length;Tt(e,c,a,a.f,a.u,o);var d=30+a.f.length+wt(a.extra),f=c+d;e.set(a.c,f),Tt(e,s,a,a.f,a.u,o,c,a.m),s+=16+d+(a.m?a.m.length:0),c=f+o}catch(e){return p(e,null)}}Et(e,s,u.length,n,t),p(null,e)};o||m();for(var h=function(e){var t=a[e],n=i[t],r=n[0],l=n[1],h=de(),g=r.length;h.p(r);var _=vt(t),v=_.length,y=l.comment,b=y&&vt(y),x=b&&b.length,S=wt(l.extra),C=l.level==0?0:8,w=function(n,r){if(n)f(),p(n,null);else{var i=r.length;u[e]=me(l,{size:g,crc:h.d(),c:r,f:_,m:b,u:v!=t.length||b&&y.length!=x,compression:C}),s+=30+v+S+i,c+=76+2*(v+S)+(x||0)+i,--o||m()}};if(v>65535&&w(M(11,0,1),null),!C)w(null,r);else if(g<16e4)try{w(null,We(r,l))}catch(e){w(e,null)}else d.push(Ue(r,l,w))},g=0;g<l;++g)h(g);return f}function kt(e,t){t||={};var n={},i=[];pt(e,``,n,t);var a=0,o=0;for(var s in n){var c=n[s],l=c[0],u=c[1],d=u.level==0?0:8,f=vt(s),p=f.length,m=u.comment,h=m&&vt(m),g=h&&h.length,_=wt(u.extra);p>65535&&M(11);var v=d?We(l,u):l,y=v.length,b=de();b.p(l),i.push(me(u,{size:l.length,crc:b.d(),c:v,f,m:h,u:p!=s.length||h&&m.length!=g,o:a,compression:d})),a+=30+p+_+y,o+=76+2*(p+_)+(g||0)+y}for(var x=new r(o+22),S=a,C=o-a,w=0;w<i.length;++w){var f=i[w];Tt(x,f.o,f,f.f,f.u,f.c.length);var T=30+f.f.length+wt(f.extra);x.set(f.c,f.o+T),Tt(x,a,f,f.f,f.u,f.c.length,f.o,f.m),a+=16+T+(f.m?f.m.length:0)}return Et(x,a,i.length,C,S),x}var At=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}();e.UnzipPassThrough=At,e.UnzipInflate=function(){function e(){var e=this;this.i=new Ge(function(t,n){e.ondata(null,t,n)})}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(e){this.ondata(e,null,t)}},e.compression=8,e}(),e.AsyncUnzipInflate=function(){function e(e,t){var n=this;t<32e4?this.i=new Ge(function(e,t){n.ondata(null,e,t)}):(this.i=new Ke(function(e,t,r){n.ondata(e,t,r)}),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=A(e,0)),this.i.push(e,t)},e.compression=8,e}(),e.Unzip=function(){function e(e){this.onfile=e,this.k=[],this.o={0:At},this.p=ce}return e.prototype.push=function(e,t){var n=this;if(this.onfile||M(5),this.p||M(4),this.c>0){var i=Math.min(this.c,e.length),a=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(a,!this.c):this.k[0].push(a),e=e.subarray(i),e.length)return this.push(e,t)}else{var o=0,s=0,c=void 0,l=void 0;this.p.length?e.length?(l=new r(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,d=this.c,f=d&&this.d,p=function(){var e=je(l,s);if(e==67324752){o=1,c=s,m.d=null,m.c=0;var t=Ae(l,s+6),r=Ae(l,s+8),i=t&2048,a=t&8,f=Ae(l,s+26),p=Ae(l,s+28);if(u>s+30+f+p){var h=[];m.k.unshift(h),o=2;var g=je(l,s+18),_=je(l,s+22),v=yt(l.subarray(s+30,s+=30+f),!i),y=Ct(l,s,p,2,g,_,0),b=y[0],x=y[1],S=y[3];a&&(b=-1-S),s+=p,m.c=b;var C,w={name:v,compression:r,start:function(){if(w.ondata||M(5),!b)w.ondata(null,ce,!0);else{var e=n.o[r];e||w.ondata(M(14,`unknown compression type `+r,1),null,!1),C=b<0?new e(v):new e(v,b,x),C.ondata=function(e,t,n){w.ondata(e,t,n)};for(var t=0,i=h;t<i.length;t++){var a=i[t];C.push(a,!1)}n.k[0]==h&&n.c?n.d=C:C.push(ce,!0)}},terminate:function(){C&&C.terminate&&C.terminate()}};b>=0&&(w.size=b,w.originalSize=x),m.onfile(w)}return`break`}if(d){if(e==134695760)return c=s+=12+(d==-2&&8),o=3,m.c=0,`break`;if(e==33639248)return c=s-=4,o=3,m.c=0,`break`}},m=this;s<u-4&&p()!==`break`;++s);if(this.p=ce,d<0){var h=o?l.subarray(0,c-12-(d==-2&&8)-(je(l,c-16)==134695760&&4)):l.subarray(0,s);f?f.push(h,!!o):this.k[+(o==2)].push(h)}if(o&2)return this.push(l.subarray(s),t);this.p=l.subarray(s)}t&&(this.c&&M(13),this.p=null)},e.prototype.register=function(e){this.o[e.compression]=e},e}();var jt=typeof queueMicrotask==`function`?queueMicrotask:typeof setTimeout==`function`?setTimeout:function(e){e()};function Mt(e,t,n){n||(n=t,t={}),typeof n!=`function`&&M(7);var i=[],a=function(){for(var e=0;e<i.length;++e)i[e]()},o={},s=function(e,t){jt(function(){n(e,t)})};jt(function(){s=n});for(var c=e.length-22;je(e,c)!=101010256;--c)if(!c||e.length-c>65558)return s(M(13,0,1),null),a;var l=Ae(e,c+8);if(l){var u=l,d=je(e,c+16),f=je(e,c-20)==117853008;if(f){var p=je(e,c-12);f=je(e,p)==101075792,f&&(u=l=je(e,p+32),d=je(e,p+48))}for(var m=t&&t.filter,h=function(t){var n=St(e,d,f),c=n[0],u=n[1],p=n[2],h=n[3],g=n[4],_=n[5],v=xt(e,_);d=g;var y=function(e,t){e?(a(),s(e,null)):(t&&(o[h]=t),--l||s(null,o))};if(!m||m({name:h,size:u,originalSize:p,compression:c})){if(!c)y(null,A(e,v,v+u));else if(c==8){var b=e.subarray(v,v+u);if(p<524288||u>.8*p)try{y(null,Je(b,{out:new r(p)}))}catch(e){y(e,null)}else i.push(qe(b,{size:p},y))}else y(M(14,`unknown compression type `+c,1),null)}else y(null,null)},g=0;g<u;++g)h(g)}else s(null,{});return a}function Nt(e,t){for(var n={},i=e.length-22;je(e,i)!=101010256;--i)(!i||e.length-i>65558)&&M(13);var a=Ae(e,i+8);if(!a)return{};var o=je(e,i+16),s=je(e,i-20)==117853008;if(s){var c=je(e,i-12);s=je(e,c)==101075792,s&&(a=je(e,c+32),o=je(e,c+48))}for(var l=t&&t.filter,u=0;u<a;++u){var d=St(e,o,s),f=d[0],p=d[1],m=d[2],h=d[3],g=d[4],_=d[5],v=xt(e,_);o=g,(!l||l({name:h,size:p,originalSize:m,compression:f}))&&(f?f==8?n[h]=Je(e.subarray(v,v+p),{out:new r(m)}):M(14,`unknown compression type `+f):n[h]=A(e,v,v+p))}return n}})),n9=_(m(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t<`u`?t.exports=r((EY(),v(Ple)),(Due(),v(due)),(kue(),v(Oue)),jue(),(Lue(),v(Mue)),(Yue(),v(Vue)),Xue()):typeof define==`function`&&define.amd?define([`three/webgpu`,`three-spritetext`,`three/tsl`,`css-element-queries`,`three/examples/jsm/exporters/GLTFExporter`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],r):(n=typeof globalThis<`u`?globalThis:n||self,n.Zinc=r(n.THREE,n.SpriteText,n.THREE,n.cssElememtQueries,n.GLTFExporter,n.GLTFLoader,n.fflate))})(e,function(e,t,n,r,i,a,o){var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule||!f.call(e,`default`)?c(n,`default`,{value:e,enumerable:!0}):n,e));e=m(e,1),t=m(t,1);var h={name:`zincjs`,version:`3.0.0`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,engines:{node:`^24.20.0`},directories:{doc:`docs`},files:[`package.json`,`LICENSE`,`README.md`,`src/*`,`build/zinc.js`,`build/zinc.js.map`,`vite.config.js`],scripts:{"build-bundle":`vite build`,"test-watch":`vitest`,test:`vitest run --reporter=junit --outputFile=test-results.xml`,"test-standard":`vitest run`,changelog:`auto-changelog -p --output CHANGELOG.md --template keepachangelog`,jsdoc:`jsdoc -c jsdoc_conf.json`,version:`npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs`,"release:beta":`npm version prerelease --preid=beta; npm publish --tag beta`,"release:major":`npm version major; npm publish`,"release:minor":`npm version minor; npm publish`,"release:patch":`npm version patch; npm publish`},repository:{type:`git`,url:`git+https://github.com/alan-wu/ZincJS.git`},keywords:[`library`,`webgl`,`3d`,`zincjs`],author:`Alan Wu <alan.wu@auckland.ac.nz>`,license:`MIT`,bugs:{url:`https://github.com/alan-wu/ZincJS/issues`},homepage:`http://alan-wu.github.io/ZincJS/`,allowScripts:{"msw@2.14.6":!0,"webgpu@0.4.0":!0},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,"happy-dom":`^20.10.6`,jsdoc:`^4.0.2`,msw:`^2.14.6`,vite:`^8.2.1`,"vite-plugin-node-polyfills":`^0.28.0`,vitest:`^4.1.11`,webgpu:`^0.4.0`},dependencies:{"css-element-queries":`^1.2.2`,lodash:`^4.17.19`,"nifti-reader-js":`0.8.0`,three:`^0.185.1`,"three-spritetext":`1.10.0`}},g=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,_=new Set,v=e=>{_.add(e)},y=e=>{_.delete(e)},b=()=>{_.forEach(e=>e())},x=t.default.default||t.default,S=1.5,C=16,w=256,T=.1,E=1e3/(2*Math.tan(20*Math.PI/180)),D=new Set,O=!1,k=e=>{let t=Math.round(e*E*S);return Math.min(Math.max(t,C),w)},A=t=>{let n=t.material?.map;n&&(n.generateMipmaps=!1,n.minFilter=e.LinearFilter,n.magFilter=e.LinearFilter,n.anisotropy=1)},j=(e,t,n,r)=>{`_fontFace`in e&&typeof e._genCanvas==`function`?(e._fontFace=t,e._fontSize=n,e._fontWeight=r,e._genCanvas()):(e.fontFace=t,e.fontSize=n,e.fontWeight=r)},M=(e,t=!1)=>{let n=k(e.textHeight);(t||n!==e.fontSize)&&(j(e,e.fontFace,n,e.fontWeight),A(e))},N=e=>{D.forEach(t=>{let n=t.deref();n?e(n):D.delete(t)})},P=()=>{N(e=>M(e,!0)),b()},ee=e=>{if(typeof document>`u`||!document.fonts)return;!O&&document.fonts.addEventListener&&(document.fonts.addEventListener(`loadingdone`,P),O=!0);let t=`${e.fontWeight} ${e.fontSize}px ${e.fontFace}`;try{document.fonts.check(t)||document.fonts.load(t).then(()=>{M(e,!0),b()}).catch(()=>{})}catch{}},te=e=>{D.add(new WeakRef(e))},ne=e=>{D.forEach(t=>{let n=t.deref();(!n||n===e)&&D.delete(t)})},re=(t,n,r,i,a)=>{let o=r?new x(t,n,r):new x(t,n);j(o,i,k(n),a);let s=o.material;return o.material=new e.SpriteNodeMaterial({map:s.map}),s.map=null,s.dispose(),o.material.sizeAttenuation=!1,A(o),te(o),ee(o),o},ie=(e,t)=>{`_textHeight`in e?(e._textHeight=t,M(e,!0)):(e.textHeight=t,M(e))},ae=e=>{!(e>0)||!isFinite(e)||Math.abs(e/E-1)>T&&(E=e,N(e=>M(e)),b())};function oe(e,t){let n=(e,t)=>{try{let n=new URL(e,t).href;if(e&&e.split(`?`).length<2){let e=t.split(`?`);e.length===2&&(n=n+`?`+e[1])}return n}catch{console.error(`There is an issue creating the url link with: ${e}.`)}};if(Array.isArray(e)){let r=[];return e.forEach(e=>{r.push(n(e,t))}),r}return n(e,t)}function se(e){return e.parent&&se(e.parent),e.matrixAutoUpdate&&e.updateMatrix(),e.matrixWorldAutoUpdate!==!1&&(e.parent?e.matrixWorld.multiplyMatrices(e.parent.matrixWorld,e.matrix):e.matrixWorld.copy(e.matrix)),e.matrixWorld}function ce(e,t,n,r,i){let a=e.morphTargetInfluences,o;e.geometry&&(o=e.geometry.morphAttributes);let s=!1;if(a&&o&&o.position){r.set(0,0,0),i.set(0,0,0);for(let e=0;e<a.length;e++)a[e]>0&&(s=!0,n.setFromArray(o.position[e].array),r.add(n.min.multiplyScalar(a[e])),i.add(n.max.multiplyScalar(a[e])));s&&t.set(r,i)}s||t.setFromBufferAttribute(e.geometry.attributes.position),t.applyMatrix4(se(e))}function le(e,t,n,r){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{n(e,t)}).catch(t=>{console.error(`Fetch string payload retrieval failed for: ${requestURL}`,t),r(e)})}function ue(e,t,n){let r=e.length,i=0,a=[];function o(e,n){a[n]=e,i++,i==r&&t(a)}for(let t=0;t<r;t++)le(e[t],t,o,n)}var de=(t,n)=>{let r=Math.floor(n/3),i=n%3,a=0;i==0?a=t[r].r:i==1?a=t[r].g:i==2&&(a=t[r].b);let o=new e.Color(a);return[o.r,o.g,o.b]},fe=new WeakMap,pe=function(t,n){if(n&&t&&t.morphAttributes&&t.morphAttributes.color){let r=t.morphAttributes.color,i=n.morphTargetInfluences,a=i.length,o=0,s=0,c=0,l=0,u=0;for(let e=0;e<a&&o<2;e++)i[e]>0&&(o===0?(s=c=e,l=i[e]):(c=e,u=i[e]),o++);let d=0;if(o>=2){let e=l+u;d=e>0?u/e:0}let f=t.getAttribute(`morphColor0`),p=t.getAttribute(`morphColor1`);(!f||!p)&&(f=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),p=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),f.setUsage(e.DynamicDrawUsage),p.setUsage(e.DynamicDrawUsage),t.setAttribute(`morphColor0`,f),t.setAttribute(`morphColor1`,p));let m=r[s],h=r[c];fe.get(f)!==m&&(f.array.set(m.array),f.needsUpdate=!0,fe.set(f,m)),fe.get(p)!==h&&(p.array.set(h.array),p.needsUpdate=!0,fe.set(p,h));let g=n.material&&n.material.userData&&n.material.userData.uniforms&&n.material.userData.uniforms.morphColorMix;g&&(g.value=d)}},me=e=>{let t=e.clone();return t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),e._video&&(t._video=e._video),t};function he(t){let n,r,i,a=-1,o=0;for(let e=0;e<t.length;++e){let s=t[e];if(n===void 0&&(n=s.array.constructor),n!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(r===void 0&&(r=s.itemSize),r!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*r}let s=new n(o),c=new e.BufferAttribute(s,r,i),l=0;for(let e=0;e<t.length;++e){let n=t[e];if(n.isInterleavedBufferAttribute){let e=l/r;for(let t=0,i=n.count;t<i;t++)for(let i=0;i<r;i++){let r=n.getComponent(t,i);c.setComponent(t+e,i,r)}}else s.set(n.array,l);l+=n.count*r}return a!==void 0&&(c.gpuType=a),c}var ge=(t,n=!1)=>{let r=t[0].index!==null,i=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),o={},s={},c=t[0].morphTargetsRelative,l=new e.BufferGeometry,u=0;for(let e=0;e<t.length;++e){let d=t[e],f=0;if(r!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let t in d.attributes){if(!i.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure "`+t+`" attribute exists among all geometries, or in none of them.`),null;o[t]===void 0&&(o[t]=[]),o[t].push(d.attributes[t]),f++}if(f!==i.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. Make sure all geometries have the same number of attributes.`),null;if(c!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let t in d.morphAttributes){if(!a.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphAttributes must be consistent throughout all geometries.`),null;s[t]===void 0&&(s[t]=[]),s[t].push(d.morphAttributes[t])}if(n){let t;if(r)t=d.index.count;else if(d.attributes.position!==void 0)t=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. The geometry must have either an index or a position attribute`),null;l.addGroup(u,t,e),u+=t}}if(r){let e=0,n=[];for(let r=0;r<t.length;++r){let i=t[r].index;for(let t=0;t<i.count;++t)n.push(i.getX(t)+e);e+=t[r].attributes.position.count}l.setIndex(n)}for(let e in o){let t=he(o[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;l.setAttribute(e,t)}for(let e in s){let t=s[e][0].length;if(t===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<s[e].length;++r)t.push(s[e][r][n]);let r=he(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;l.morphAttributes[e].push(r)}}return l};function _e(t,n){if(n&&t>=n.length){let r=new e.BufferGeometry,i=new Float32Array(t*3),a=0;return n.forEach(e=>{i[a++]=e[0],i[a++]=e[1],i[a++]=e[2]}),r.setAttribute(`position`,new e.BufferAttribute(i,3)),r.setDrawRange(0,n.length),r}}var ve=class extends Uint16Array{};function ye(e){let t=e?.index;if(t&&t.array.constructor===Uint16Array){let e=t.array;t.array=new ve(e.buffer,e.byteOffset,e.length)}}function be(e){let t=[];return e.traverse(e=>{let n=e.geometry?.index;if(n&&n.array instanceof ve){let e=n.array;n.array=new Uint16Array(e.buffer,e.byteOffset,e.length),t.push([n,e,n.array])}}),()=>{t.forEach(([e,t,n])=>{e.array===n&&(e.array=t)})}}var xe=void 0;function Se(){if(xe)return xe;let t=new Image,n=new e.Texture;return n.image=t,t.onload=()=>{n.needsUpdate=!0,b()},t.src=g,t.complete&&t.naturalWidth>0&&(n.needsUpdate=!0),xe=n,n}function Ce(e,t,n,r,i,a){let o=re(e,t,n,r,a);return o.material.alphaTest=.05,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=10001,o}function we(e,t,n){if(n){let r=e||``,i=t||``,a=n.lastIndexOf(`/`);if(a>-1){let e,t;if(e=n.substring(0,a),t=n.substring(a+1),(e===`*`||e===`**`||e.toLowerCase()===r.toLowerCase())&&(t===`*`||t===`**`||t.toLowerCase()===i.toLowerCase()))return!0}else if(r.toLowerCase()===n.toLowerCase()||i.toLowerCase()===n.toLowerCase())return!0}return!1}function Te(t,n,r){let i=t.getAttribute(`position`),a=t.getAttribute(`normal`);if(!i)return;let o=i.itemSize,s=n*o,c=o,l=!1,u=(n,i)=>{let a=n.array;if(a.length<s+c)return!1;if(r)a.copyWithin(s,s+c),a.fill(0,a.length-c),n.needsUpdate=!0;else{let n=new a.constructor(a.length-c);n.set(a.subarray(0,s)),n.set(a.subarray(s+c),s),t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return!0};return l=u(i,`position`),a&&u(a,`normal`),t.index!==null&&console.warn(`Removing vertices from indexed geometry requires index buffer recalculation.`),l}function Ee(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y,n[r++]=i.z}return e.needsUpdate=!0,e}var De={MeshBasicMaterial:e.MeshBasicNodeMaterial,MeshLambertMaterial:e.MeshLambertNodeMaterial,MeshPhongMaterial:e.MeshPhongNodeMaterial,MeshStandardMaterial:e.MeshStandardNodeMaterial,LineBasicMaterial:e.LineBasicNodeMaterial},Oe=t=>{let r=t;r.isNodeMaterial||(r=new(De[t.type]||e.MeshBasicNodeMaterial),r.copy(t));let i=(0,n.uniform)(0);return r.colorNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`morphColor0`,`vec3`),t=(0,n.attribute)(`morphColor1`,`vec3`),r=(0,n.mix)(e,t,i);return(0,n.vec4)(r.mul(n.materialColor),n.materialOpacity)})(),r.userData.uniforms={...r.userData.uniforms,morphColorMix:i},r},ke=new e.Vector3,Ae=new e.Vector3,je=new e.Matrix4,Me=new e.Ray,Ne=new e.Sphere,Pe=new e.Vector3,Fe=new e.Vector3,Ie=new e.Vector3,Le=new e.Vector3,Re=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.LineBasicMaterial){super(),this.type=`Line`,this.geometry=t,this.material=n,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[0];for(let e=1,t=n.count;e<t;e++)ke.fromBufferAttribute(n,e-1),Ae.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=ke.distanceTo(Ae);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}raycast(t,n){let r=this.geometry,i=this.matrixWorld,a=t.params.Line.threshold,o=r.drawRange,s=r.morphAttributes.position;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ne.copy(r.boundingSphere),Ne.applyMatrix4(i),Ne.radius+=a,t.ray.intersectsSphere(Ne)===!1)return;je.copy(i).invert(),Me.copy(t.ray).applyMatrix4(je);let c=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=c*c,u=new e.Vector3,d=new e.Vector3,f=new e.Vector3,p=new e.Vector3,m=this.isLineSegments?2:1;if(r.isBufferGeometry){let e=r.index,i=r.attributes.position;if(e!==null){let r=Math.max(0,o.start),a=Math.min(e.count,o.start+o.count);for(let o=r,c=a-1;o<c;o+=m){let r=e.getX(o),a=e.getX(o+1);if(ze(u,d,this,i,s,r,a),Me.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let c=t.ray.origin.distanceTo(p);c<t.near||c>t.far||n.push({distance:c,point:f.clone().applyMatrix4(this.matrixWorld),index:o,face:null,faceIndex:null,object:this})}}else{let e=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count);for(let a=e,o=r-1;a<o;a+=m){if(ze(u,d,this,i,s,a,a+1),Me.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let e=t.ray.origin.distanceTo(p);e<t.near||e>t.far||n.push({distance:e,point:f.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error(`THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};function ze(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(i&&s){Pe.set(0,0,0),Fe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(Ie.fromBufferAttribute(d,a),Le.fromBufferAttribute(d,o),Pe.addScaledVector(Ie.sub(e),u),Fe.addScaledVector(Le.sub(t),u))}e.add(Pe),t.add(Fe)}}Re.prototype.isLine=!0;var Be=new e.Vector3,Ve=new e.Vector3,He=class extends Re{constructor(e,t){super(e,t),this.type=`LineSegments`}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[];for(let e=0,t=n.count;e<t;e+=2)Be.fromBufferAttribute(n,e),Ve.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+Be.distanceTo(Ve);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}};He.prototype.isLineSegments=!0;var Ue=function(t){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=t,this._disposed=!1,this.addLevel=(e,t)=>{if(e){ye(e.geometry);let n=Math.abs(t),r;for(r=0;r<this.levels.length&&!(n<this.levels[r].distance);r++);let i={distance:n,morph:e,loaded:!0,loading:!1,url:``};this.levels.splice(r,0,i),e.renderOrder=this._renderOrder}},this.levelLoaded=(e,t)=>{if(e){ye(e.geometry);let n=Math.abs(t);for(let t=0;t<this.levels.length;t++)if(n===this.levels[t].distance){this._parent.group.add(e),this.levels[t].morph=e,this.levels[t].loaded=!0,this.levels[t].loading=!1;break}this.checkTransparentMesh(),this._parent?.requestRender?.()}},this.addLevelFromURL=(e,t,n,r,i)=>{this._loader=e;let a=this.calculateDistance(t),o={distance:a,morph:void 0,loaded:!1,loading:!1,url:n,index:r},s;for(s=0;s<this.levels.length&&!(a<this.levels[s].distance);s++);this.levels.splice(s,0,o),i&&this.loadLevel(s)},this.loadLevel=e=>{let t=this.levels[e];return!t.morph&&!t.loaded&&!t.loading&&(t.loading=!0,this._loader.load(t.url,this.lodLoader(t.distance),void 0,void 0,{index:t.index})),t.morph===void 0},this.calculateDistance=function(e){this._parent.getBoundingBox();let t=this._parent.radius,n=0;return e===`far`?n=t*4.5:e===`medium`?n=t*2.5:e===`close`&&(n=0),n},this.containsLevels=()=>!!(this.levels&&this.levels.length>1),this.checkTransparentMesh=()=>{let t=this.levels[this._currentLevel];this._material&&(this._material.transparent?(this._secondaryMaterial||(this._secondaryMaterial=this._material.clone(),this._secondaryMaterial.side=e.FrontSide),this._secondaryMaterial.opacity=this._material.opacity,this._secondaryMaterial.emissive&&this._secondaryMaterial.emissive.copy(this._material.emissive),this._secondaryMaterial.needsUpdate=!0,t.secondaryMesh||(t.secondaryMesh=new e.Mesh(t.morph.geometry,this._secondaryMaterial),t.secondaryMesh.renderOrder=t.morph.renderOrder+1,t.secondaryMesh.userData=t.morph.userData,t.secondaryMesh.name=t.morph.name),this._material.side=e.BackSide,this._material.needsUpdate=!0,t.secondaryMesh.parent||(t.morph.add(t.secondaryMesh),this._parent.animationGroup&&this._parent.animationGroup.add(t.secondaryMesh))):(t.secondaryMesh&&(t.morph.remove(t.secondaryMesh),this._parent.animationGroup&&(this._parent.animationGroup.uncache(t.secondaryMesh),this._parent.animationGroup.remove(t.secondaryMesh))),this._material.side=e.DoubleSide,this._material.needsUpdate=!0))},this.dispose=()=>{this._disposed=!0,this.levels.forEach(e=>{e.morph&&e.morph.geometry&&e.morph.geometry.dispose()}),this._material&&this._material.dispose(),this._secondaryMaterial&&this._secondaryMaterial.dispose()},this.getCurrentLevel=()=>this._currentLevel,this.getCurrentMorph=()=>{let e=this.levels[this._currentLevel];return e&&e.morph?e.morph:this._parent.morph},this.lodLoader=function(t){return n=>{if(this._disposed){n.dispose();return}let r=this._material,i=me(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour,isLines:this._parent.isLines}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new He(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=e=>{if(this._material&&this._material.userData&&this._material.userData.uniforms&&this._material.userData.uniforms.morphColorMix){if(e){let e=this.getCurrentMorph();pe(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&pe(e.morph.geometry,e.morph)})}},this.setColour=e=>{this._material.color=e,this._secondaryMaterial&&(this._secondaryMaterial.color=e),n()},this.setFrustumCulled=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.frustumCulled=e),t.secondaryMesh&&(t.secondaryMesh.frustumCulled=e)})},this.setMaterial=t=>{t&&(!this._material||this._material.id!==t.id)&&(this._material=t,this._secondaryMaterial&&=(this._secondaryMaterial.dispose(),void 0),(t.transparent||this.levels.some(e=>e.secondaryMesh))&&(this._secondaryMaterial=t.clone(),this._secondaryMaterial.side=e.FrontSide,this._secondaryMaterial.transparent=!0),this.levels.forEach(e=>{e.morph&&(e.morph.material=this._material,e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)),e.secondaryMesh&&(e.secondaryMesh.material=this._secondaryMaterial)}))},this.setName=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.name=e),t.secondaryMesh&&(t.secondaryMesh.name=e)})},this.setRenderOrder=e=>{this._renderOrder=e,this.levels.forEach(t=>{t.morph&&(t.morph.renderOrder=e),t.secondaryMesh&&(t.secondaryMesh.renderOrder=e)})},this.setVertexColors=e=>{this._material.vertexColors=e,n(),this._secondaryMaterial&&(this._secondaryMaterial.vertexColors=e)},this.update=(e,t)=>{let n=this.levels;if(n.length>1){let r=e.cameraObject.position.distanceTo(t),i=-1,a=-1,o,s;for(o=0,s=n.length;o<s&&r>=n[o].distance;o++)n[o].morph?(i>-1&&n[i].morph&&(n[i].morph.visible=!1),i=o,n[o].morph.visible=!0,a=-1):a=o;for(a>-1&&this.loadLevel(a);o<s;o++)n[o].morph&&(i>-1?n[o].morph.visible=!1:(n[o].morph.visible=!0,i=o));this._currentLevel!=i&&(this._currentLevel=i,this.checkTransparentMesh(),this._parent?.requestRender?.())}},this.toggleMarker=(e,t)=>{this.levels.forEach(n=>{n.morph&&(t?n.morph.add(e):n.morph.remove(e))})};let n=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)})}},We=new e.TextureLoader().load(`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(0,89,116);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,b);We.colorSpace=e.SRGBColorSpace;var Ge=[.02,.03,1],Ke=new e.SpriteMaterial({map:We,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),qe=function(t){Object.getPrototypeOf(this)!==Xe.prototype&&Object.setPrototypeOf(qe.prototype,Xe.prototype),Xe.call(this),this.texture=We;let n,r,i,a,o,s=!0;this.morph=new e.Group,this.group=this.morph,this.parent=t,this.isMarker=!0;let c=!1;this.ndc=new e.Vector3;let l,u,d=()=>{n=new e.Sprite(Ke),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(Ge[0],Ge[1],Ge[2]),n.userData=this};this.updateVisual=(e,t)=>{let n=1,r=0;e!==t&&(r=1-(this.ndc.z-e)/(t-e),n=.6+r*.4),this.setSpriteSize(n)},this.updateNDC=e=>(this.ndc.copy(this.morph.position),this.ndc.project(e),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(e,t,n)=>{this.morph.position.set(e,t,n)},this.setSpriteSize=e=>{n.scale.set(.015,.02,1),n.scale.multiplyScalar(e)},this.setUserSprite=()=>{a&&(this.morph.add(a),s&&=(this.morph.remove(n),u&&this.morph.remove(u),!1))},this.setImageForUserSprite=(t,n)=>{a&&=(this.morph.remove(a),void 0),r&&r.dispose(),i&&i.dispose(),r=new e.Texture,r.image=t,r.needsUpdate=!0,i=new e.SpriteMaterial({map:r,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),n||=[.05,.05,1],a=new e.Sprite(i),a.center.set(.5,0),a.scale.set(n[0],n[1],n[2]),a.userData=this,this.setUserSprite()},this.setDefaultSprite=()=>{s||(s=!0,this.morph.add(n),a&&this.morph.remove(a),u&&this.morph.add(u))},this.loadUserSprite=(e,t)=>{if(e){if(e!==o){o=e;let n=new Image(128,128);n.crossOrigin=`anonymous`,n.onload=()=>{this.setImageForUserSprite(n,t),this.parent?.requestRender?.()},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(ne(u),u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),ne(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=Ce(e,.012,`black`,`Asap`,120,700),u.renderOrder=10001,this.morph.add(u)),l=e},this.getNumber=()=>l||1,this.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.parent.region&&(this.parent.region.pickableUpdateRequired=!0))},this.enable=()=>{c=!0,this.morph.visible=!0,this.visible=!0},this.disable=()=>{c=!1,this.morph.visible=!1,this.visible=!1},d()},Je=0,Ye=function(){return`pr`+Je++},Xe=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new Ue(this),this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData={},this.marker=void 0,this.markerNumber=void 0,this.markerUpdateRequired=!0,this.closestVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new e.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode=`inherited`,this.uuid=Ye(),this._v1=new e.Vector3,this._v2=new e.Vector3,this._b1=new e.Box3,this.center=new e.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};Xe.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},Xe.prototype.getDuration=function(){return this.duration},Xe.prototype.setRegion=function(e){this.region=e},Xe.prototype.getRegion=function(){return this.region},Xe.prototype.requestRender=function(){this.region?.getScene?.()?.invalidate?.()},Xe.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},Xe.prototype.getGroup=function(){return this.group},Xe.prototype.setMorph=function(e){this.morph=e,this.group.add(this.morph);let t=this._lod.calculateDistance(`far`);this._lod.addLevel(e,t),this._lod.setMaterial(e.material)},Xe.prototype.checkTransparentMesh=function(){},Xe.prototype.setMesh=function(t,n,r){this.requestRender(),this.animationGroup=new e.AnimationObjectGroup(t),this.mixer=new e.AnimationMixer(this.animationGroup);let i=t.geometry;if(this.geometry=t.geometry,this.clipAction=void 0,i&&i.morphAttributes){let t=i.morphAttributes.position;t||=i.morphAttributes.color?i.morphAttributes.color:i.morphAttributes.normal,t&&(this.animationClip=e.AnimationClip.CreateClipsFromMorphTargetSequences(t,10,!0),this.animationClip&&this.animationClip[0]!=null&&(this.clipAction=this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration),this.clipAction.loop=e.LoopRepeat,this.clipAction.clampWhenFinished=!0,this.clipAction.play(),this.mixer.update(0)))}this.timeEnabled=n,this.morphColour=r,t.userData=this,t.matrixAutoUpdate=!1,this.setMorph(t),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(i.setAttribute(`morphTarget0`,i.getAttribute(`position`)),i.setAttribute(`morphTarget1`,i.getAttribute(`position`))),this.morphColour&&this.initiateMorphColor(),this.boundingBoxUpdateRequired=!0},Xe.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},Xe.prototype.setAnatomicalId=function(e){this.anatomicalId=e},Xe.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},Xe.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},Xe.prototype.setMorphTime=function(e){this.requestRender();let t=!1;if(this.clipAction){let n=e/this.duration*this.clipAction._clip.duration;n!=this.clipAction.time&&(this.clipAction.time=n,t=!0),t&&this.isTimeVarying()&&this.mixer.update(0)}else{let n=e;n=e>this.duration?this.duration:0>e?0:e,n!=this.inbuildTime&&(this.inbuildTime=n,t=!0)}t&&(this.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},Xe.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},Xe.prototype.getVisibility=function(){return this.visible},Xe.prototype.setVisibility=function(e){this.requestRender(),e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},Xe.prototype.setAlpha=function(e){this.requestRender();let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},Xe.prototype.setFrustumCulled=function(e){this.requestRender(),this._lod.setFrustumCulled(e)},Xe.prototype.setVertexColors=function(e){this.requestRender(),this._lod.setVertexColors(e)},Xe.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},Xe.prototype.setColour=function(e){this.requestRender(),this._lod.setColour(e)},Xe.prototype.setGreyScale=function(t){if(this.requestRender(),t){if(!this.origColour&&this._lod._material)return this.origColour=this._lod._material.color,this.origVertexColors=this._lod._material.vertexColors,this._lod.setVertexColors(!1),this._lod.setColour(new e.Color().setHex(12303291)),!0}else if(this.origColour)return this._lod.setColour(this.origColour),this._lod.setVertexColors(this.origVertexColors),this.origColour=void 0,!0;return!1},Xe.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},Xe.prototype.setColourHex=function(e){this.requestRender(),this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},Xe.prototype.setEmissiveRGB=function(e){this.requestRender(),this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},Xe.prototype.setMaterial=function(e){this.requestRender(),this._lod.setMaterial(e)},Xe.prototype.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&t.geometry){let n=t.geometry.attributes.position;if(n){this._b1.setFromBufferAttribute(n),this._b1.getCenter(this._v1);let t=-1,r=0;for(let i=0;i<n.count;i++)this._v2.fromArray(n.array,i*3),r=this._v2.distanceToSquared(this._v1),(t==-1||t>r)&&(t=r,e=i)}}return e},Xe.prototype.getClosestVertex=function(t){let n=new e.Vector3;this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=this.getMorph();if(r&&r.geometry&&this.closestVertexIndex>=0){let e=r.morphTargetInfluences,i=r.geometry.morphAttributes;if(e&&i&&i.position){let a=!1;for(let t=0;t<e.length;t++)e[t]>0&&(a=!0,this._v1.fromArray(i.position[t].array,this.closestVertexIndex*3),n.add(this._v1.multiplyScalar(e[t])));if(a)return t?n.applyMatrix4(r.matrixWorld):n}else return n.fromArray(r.geometry.attributes.position.array,this.closestVertexIndex*3),t?n.applyMatrix4(r.matrixWorld):n}return this.getBoundingBox(),n.copy(this.center),n},Xe.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(ce(e,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox}},Xe.prototype.dispose=function(){this._lod.dispose(),this.marker&&=(this.marker.dispose(),void 0),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},Xe.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))};var Ze=new WeakMap;Xe.prototype.hasMorphPositions=function(){let e=this.getMorph()?.geometry,t=e?.morphAttributes?.position;if(!t||t.length===0)return!1;let n=Ze.get(e);if(n&&n.morphPositions===t)return n.result;let r=e.getAttribute(`position`)?.array,i=!1;for(let e=0;e<t.length&&!i;e++){let n=t[e].array;if(!r||n.length!==r.length)i=!0;else if(n!==r){for(let e=0;e<n.length;e++)if(n[e]!==r[e]){i=!0;break}}}return Ze.set(e,{morphPositions:t,result:i}),i},Xe.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new qe(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){let t=this.getClosestVertex(!1);t&&(this.marker.setPosition(t.x,t.y,t.z),this.markerUpdateRequired=!1,e=!0)}this.marker.isEnabled()||(t.markersList&&!(this.marker.uuid in t.markersList)&&(e=!0,t.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),t&&t.camera&&e&&(this.marker.updateNDC(t.camera.cameraObject),t.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),t?.markersList&&this.marker.uuid in t.markersList&&(t.markerCluster.markerUpdateRequired=!0,delete t.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},Xe.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},Xe.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},Xe.prototype.setRenderOrder=function(e){this.requestRender(),this._lod.setRenderOrder(e)},Xe.prototype.getClosestVertexDOMElementCoords=function(e){if(e&&e.camera){let t=!0,n=this.getClosestVertex(!0);return n.project(e.camera),n.z=Math.min(Math.max(n.z,0),1),(n.x>1||n.x<-1||n.y>1||n.y<-1)&&(t=!1),e.getZincCameraControls().getRelativeCoordsFromNDC(n.x,n.y,n),{position:n,inView:t}}},Xe.prototype.setMarkerMode=function(e,t){this.requestRender(),e!==this.markerMode&&(this.markerMode=e===`on`||e===`off`?e:`inherited`,this.region&&(this.region.pickableUpdateRequired=!0)),t&&(this.markerNumber=t.number,this.markerImgURL=t.imgURL)},Xe.prototype.render=function(e,t,n,r){if(this.visible&&!(this.timeEnabled&&t)&&this._lod.update(n,this.center),t==1){if(this.clipAction&&this.isTimeVarying())this.mixer.update(e);else{let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t}this.visible&&e!=0&&(this.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},Xe.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},Xe.prototype.addVertices=function(e){this.requestRender();let t=this.getMorph(),n;if(!t)n=_e(500,e),this.drawRange=e.length;else if(this.drawRange>-1){let r=t.geometry.getAttribute(`position`);e.forEach(e=>{r.setXYZ(this.drawRange,e[0],e[1],e[2]),++this.drawRange}),r.needsUpdate=!0,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n=t.geoemtry,this.boundingBoxUpdateRequired=!0}return n},Xe.prototype.deleteVertices=function(e){this.requestRender();let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&Te(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},Xe.prototype.setPosition=function(e,t,n){this.requestRender();let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},Xe.prototype.loadAdditionalSources=function(e,t){e.load(filename,meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},Xe.prototype.setScaleAll=function(e){this.requestRender();let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Qe=(t,n,r)=>{let i=me(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0)o=n||new e.MeshPhongMaterial({color:r.colour,vertexColors:!1,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.vertexColors=!1,o=Oe(o));else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide})}return new e.Mesh(i,o)},$e=function(){Xe.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(e,t,n)=>{if(this.morph&&this.morph.geometry&&e!=null)return;let r=Qe(e,t,n);this.videoHandler=r.geometry._video,this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.requestRender(),this.morph.material.wireframe=e},this.editVertices=function(e,t){if(this.requestRender(),e&&e.length){let n=this.getMorph(),r=n.geometry.getAttribute(`position`);if(!n||0>t)return;{let i=t*3;e.forEach(e=>{r.array[i++]=e[0],r.array[i++]=e[1],r.array[i++]=e[2]}),r.needsUpdate=!0,n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour||this.videoHandler)}};$e.prototype=Object.create(Xe.prototype);var et=function(e,t){let n=e,r,i=1,a=500,o=.012;r=re(n,o,t?t.getStyle():void 0,`Asap`,a),r.center.x=-.05,r.center.y=0;let s=()=>{A(r)};this.getPosition=()=>r?[r.position.x,r.position.y,r.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{r&&r.position.set(e,t,n)},this.setColour=e=>{if(e){let t=e.getStyle();t!==r.color&&(r.color=t,s())}},this.setScale=e=>{r&&e>0&&r.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==r.material.depthTest&&(r.material.depthTest=e)},this.setSize=e=>{e>0&&(ie(r,o*e),i=e)},this.setFontWeight=e=>{e&&e!==a&&(r.fontWeight=e,s(),a=e)},this.setText=e=>{if(e&&e!==r.text){if(r._canvas,r.material&&r.material.map&&r.material.map.dispose(),r._canvas){let e=r._canvas.getContext(`2d`);e&&e.clearRect(0,0,r._canvas.width,r._canvas.height),r._canvas.width=1,r._canvas.height=1}r.text=e,ie(r,o*i),n=e,r.material&&r.material.map&&(s(),r.material.map.needsUpdate=!0)}},this.setVisibility=e=>{r.visible=e},this.dispose=()=>{r&&(ne(r),r.removeFromParent(),r.material&&(r.material.map?.dispose(),r.material.dispose()),r._canvas&&(r._canvas.width=0,r._canvas.height=0))},this.getSprite=()=>r,this.getString=()=>n},tt=function(t,n,r,i){Xe.call(this);let a;n&&(a=n.clone(),a.vertexColors=e.FaceColors);let o=i;this.id=r;let s,c;this.isGlyph=!0;let l=[0,0,0],u;this.fromMesh=e=>e&&e.isMesh?(this.morph=e.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,t&&a&&this.fromMesh(new e.Mesh(t,a)),this.getGlyphset=function(){return o},this.setLabel=e=>{o?.requestRender?.(),e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(o?.requestRender?.(),s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new et(c,u||e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.05,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{o?.requestRender?.(),s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0)},this.getLabel=()=>c,this.getMesh=()=>this.morph,this.setTransformation=(e,t,n,r)=>{o?.requestRender?.(),this.morph&&(this.morph.matrix.elements[0]=t[0],this.morph.matrix.elements[1]=t[1],this.morph.matrix.elements[2]=t[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=n[0],this.morph.matrix.elements[5]=n[1],this.morph.matrix.elements[6]=n[2],this.morph.matrix.elements[7]=0,this.morph.matrix.elements[8]=r[0],this.morph.matrix.elements[9]=r[1],this.morph.matrix.elements[10]=r[2],this.morph.matrix.elements[11]=0,this.morph.matrix.elements[12]=e[0],this.morph.matrix.elements[13]=e[1],this.morph.matrix.elements[14]=e[2],this.morph.matrix.elements[15]=1,this.morph.matrixAutoUpdate=!1),l=[...e],s&&s.setPosition(e[0],e[1],e[2])},this.setColour=e=>{o?.requestRender?.(),u=e?e.clone():void 0,s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=e),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.getColour=()=>u,this.dispose=()=>{s&&=(s.dispose(),void 0),this.material&&this.material.dispose(),this.morph=void 0}};tt.prototype=Object.create(Xe.prototype);function nt(){}nt.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,n=0,r=t.length;n<r;n+=2){var i=t[n],a=t[n+1];if(i.test(e))return a}return null}},Object.assign(nt.prototype,{crossOrigin:`anonymous`,onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,n){for(var r=[],i=0;i<e.length;++i)r[i]=this.createMaterial(e[i],t,n);return r},createMaterial:(function(){var t={NoBlending:e.NoBlending,NormalBlending:e.NormalBlending,AdditiveBlending:e.AdditiveBlending,SubtractiveBlending:e.SubtractiveBlending,MultiplyBlending:e.MultiplyBlending,CustomBlending:e.CustomBlending},n=new e.Color,r=new e.TextureLoader,i=new e.MaterialLoader;return function(a,o,s){var c={};function l(t,n,i,a,l){var u=o+t,d=nt.Handlers.get(u),f;d===null?(r.setCrossOrigin(s),f=r.load(u)):f=d.load(u),n!==void 0&&(f.repeat.fromArray(n),n[0]!==1&&(f.wrapS=e.RepeatWrapping),n[1]!==1&&(f.wrapT=e.RepeatWrapping)),i!==void 0&&f.offset.fromArray(i),a!==void 0&&(a[0]===`repeat`&&(f.wrapS=e.RepeatWrapping),a[0]===`mirror`&&(f.wrapS=e.MirroredRepeatWrapping),a[1]===`repeat`&&(f.wrapT=e.RepeatWrapping),a[1]===`mirror`&&(f.wrapT=e.MirroredRepeatWrapping)),l!==void 0&&(f.anisotropy=l);var p=e.MathUtils.generateUUID();return c[p]=f,p}var u={uuid:e.MathUtils.generateUUID(),type:`MeshLambertMaterial`};for(var d in a){var f=a[d];switch(d){case`DbgColor`:case`DbgIndex`:case`opticalDensity`:case`illumination`:break;case`DbgName`:u.name=f;break;case`blending`:u.blending=t[f];break;case`colorAmbient`:case`mapAmbient`:console.warn(`THREE.Loader.createMaterial:`,d,`is no longer supported.`);break;case`colorDiffuse`:u.color=n.fromArray(f).getHex();break;case`colorSpecular`:u.specular=n.fromArray(f).getHex();break;case`colorEmissive`:u.emissive=n.fromArray(f).getHex();break;case`specularCoef`:u.shininess=f;break;case`shading`:f.toLowerCase()===`basic`&&(u.type=`MeshBasicMaterial`),f.toLowerCase()===`phong`&&(u.type=`MeshPhongMaterial`),f.toLowerCase()===`standard`&&(u.type=`MeshStandardMaterial`);break;case`mapDiffuse`:u.map=l(f,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);break;case`mapDiffuseRepeat`:case`mapDiffuseOffset`:case`mapDiffuseWrap`:case`mapDiffuseAnisotropy`:break;case`mapEmissive`:u.emissiveMap=l(f,a.mapEmissiveRepeat,a.mapEmissiveOffset,a.mapEmissiveWrap,a.mapEmissiveAnisotropy);break;case`mapEmissiveRepeat`:case`mapEmissiveOffset`:case`mapEmissiveWrap`:case`mapEmissiveAnisotropy`:break;case`mapLight`:u.lightMap=l(f,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);break;case`mapLightRepeat`:case`mapLightOffset`:case`mapLightWrap`:case`mapLightAnisotropy`:break;case`mapAO`:u.aoMap=l(f,a.mapAORepeat,a.mapAOOffset,a.mapAOWrap,a.mapAOAnisotropy);break;case`mapAORepeat`:case`mapAOOffset`:case`mapAOWrap`:case`mapAOAnisotropy`:break;case`mapBump`:u.bumpMap=l(f,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);break;case`mapBumpScale`:u.bumpScale=f;break;case`mapBumpRepeat`:case`mapBumpOffset`:case`mapBumpWrap`:case`mapBumpAnisotropy`:break;case`mapNormal`:u.normalMap=l(f,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);break;case`mapNormalFactor`:u.normalScale=f;break;case`mapNormalRepeat`:case`mapNormalOffset`:case`mapNormalWrap`:case`mapNormalAnisotropy`:break;case`mapSpecular`:u.specularMap=l(f,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);break;case`mapSpecularRepeat`:case`mapSpecularOffset`:case`mapSpecularWrap`:case`mapSpecularAnisotropy`:break;case`mapMetalness`:u.metalnessMap=l(f,a.mapMetalnessRepeat,a.mapMetalnessOffset,a.mapMetalnessWrap,a.mapMetalnessAnisotropy);break;case`mapMetalnessRepeat`:case`mapMetalnessOffset`:case`mapMetalnessWrap`:case`mapMetalnessAnisotropy`:break;case`mapRoughness`:u.roughnessMap=l(f,a.mapRoughnessRepeat,a.mapRoughnessOffset,a.mapRoughnessWrap,a.mapRoughnessAnisotropy);break;case`mapRoughnessRepeat`:case`mapRoughnessOffset`:case`mapRoughnessWrap`:case`mapRoughnessAnisotropy`:break;case`mapAlpha`:u.alphaMap=l(f,a.mapAlphaRepeat,a.mapAlphaOffset,a.mapAlphaWrap,a.mapAlphaAnisotropy);break;case`mapAlphaRepeat`:case`mapAlphaOffset`:case`mapAlphaWrap`:case`mapAlphaAnisotropy`:break;case`flipSided`:u.side=e.BackSide;break;case`doubleSided`:u.side=e.DoubleSide;break;case`transparency`:console.warn(`THREE.Loader.createMaterial: transparency has been renamed to opacity`),u.opacity=f;break;case`depthTest`:case`depthWrite`:case`colorWrite`:case`opacity`:case`reflectivity`:case`transparent`:case`video`:case`visible`:case`wireframe`:u[d]=f;break;case`vertexColors`:f===!0&&(u.vertexColors=e.VertexColors),f===`face`&&(u.vertexColors=e.FaceColors);break;default:console.error(`THREE.Loader.createMaterial: Unsupported`,d,f)}}return u.type===`MeshBasicMaterial`&&delete u.emissive,u.type!==`MeshPhongMaterial`&&delete u.specular,u.opacity<1&&(u.transparent=!0),i.setTextures(c),i.parse(u)}})()});var rt=function(t){var n=this;this.video=void 0,this.videoTexture=void 0;var r=t,i=function(){document&&(n.video=document.createElement(`video`),n.video.crossOrigin=`anonymous`,n.video.src=r,n.video.load(),n.video.loop=!0)};this.setMorphTime=function(e,t){let r=e/t*n.video.duration;Number.isFinite(r)||(r=0),n.video.currentTime=r},this.getVideoDuration=function(){return n.video.duration},this.createCanvasVideoTexture=function(){return n.videoTexture=new e.VideoTexture(n.video),n.videoTexture.minFilter=e.LinearFilter,n.videoTexture.magFilter=e.LinearFilter,n.video.currentTime=0,n.videoTexture},this.getCurrentTime=function(e){return n.video?e*(n.video.currentTime/n.video.duration):0},this.isReadyToPlay=function(){return!!(n.video&&n.video.readyState>=3)},i()},it=e.BufferAttribute,at=e.BufferGeometry,ot=e.Color,st=e.DefaultLoadingManager,ct=e.FileLoader,lt=e.Float32BufferAttribute,ut=e.LoaderUtils;function dt(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?st:e,this.withCredentials=!1,this.paramsString=``}Object.assign(dt.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:ut.extractUrlBase(e),o=new ct(this.manager);e.split(`?`),this.paramsString=e.length===2?paramsStrings[1]:``,o.setWithCredentials(this.withCredentials),o.load(e,function(n){var o=void 0;try{o=JSON.parse(n)}catch{if(console.error(`The loader has encountered an error while parsing the content of a resource.`),r){r({responseURL:e});return}}var s=o.metadata;if(s!==void 0){var c=s.type;if(c!==void 0&&c.toLowerCase()===`object`){console.error(`THREE.JSONLoader: `+e+` should be loaded with THREE.ObjectLoader instead.`);return}}if(i&&i.parse)try{var l=i.parse(o,a);t(l.geometry,l.materials)}catch(t){if(console.error(`The loader has encountered aon loading the geometry`),console.error(t),r){r({responseURL:e});return}}},n,r)},setTexturePath:function(e){this.texturePath=e},parse:(function(){function t(e,t){return e&1<<t}function n(e){let n=e.faces,r=0;if(e.uvs!==void 0)for(let t=0;t<e.uvs.length;t++)e.uvs[t].length&&r++;let i=[],a=[],o=0,s=n.length;for(;o<s;){let e=n[o++],s=t(e,0),c=t(e,1),l=t(e,3),u=t(e,4),d=t(e,5),f=t(e,6),p=t(e,7),m,h,g;if(s){let e=n[o],t=n[o+1],s=n[o+2],m=n[o+3];o+=4;let h=0;c&&(h=n[o++]),l&&(o+=r*4),u&&(o+=1),d&&(o+=4),f&&(o+=1),p&&(o+=4),i.push(e,t,m),a.push(h),i.push(t,s,m),a.push(h);continue}m=n[o++],h=n[o++],g=n[o++],h||=m,g||=h;let _=0;c&&(_=n[o++]),l&&(o+=r*3),u&&(o+=1),d&&(o+=3),f&&(o+=1),p&&(o+=3),i.push(m,h,g),a.push(_)}return{indices:i,materialIndices:a}}function r(e){let t=[],n,r;for(let i=0;i<e.length;i++)e[i]!==r&&(r=e[i],n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:r});return n!==void 0&&(n.count=e.length*3-n.start,t.push(n)),t}function i(e,t){let n=new at;n.setIndex(t),n.setAttribute(`position`,e),n.computeVertexNormals();let r=n.getAttribute(`normal`);return r.name=e.name,r}function a(e,t){let n=[];if(e.morphTargets!==void 0)for(let r=0,i=e.morphTargets.length;r<i;r++){let i=e.morphTargets[r].vertices,a=new Float32Array(i.length);for(let e=0,n=i.length;e<n;e++)a[e]=i[e]*t;let o=new it(a,3);o.name=e.morphTargets[r].name,n.push(o)}let r=[];if(e.morphNormals!==void 0){for(let t=0,i=e.morphNormals.length;t<i;t++)if(n[t]){let i=e.morphNormals[t].normals,a=new it(Float32Array.from(i),3);a.name=n[t].name,r[t]=a}}return{morphPositions:n,morphNormals:r}}function o(e){if(e.morphColors===void 0)return;let t=[];for(let n=0,r=e.morphColors.length;n<r;n++){let r=e.morphColors[n].colors,i=[];for(let e=0,t=r.length;e<t;e+=3){let t=new ot(16755200);t.setRGB(r[e],r[e+1],r[e+2]),i.push(t)}let a=[];for(let e=0,t=i.length*3;e<t;e++){let t=de(i,e);a.push(t[0],t[1],t[2])}let o=new lt(a,3);o.name=e.morphColors[n].name,t.push(o)}return t}return function(t,s){t.data!==void 0&&(t=t.data);let c=t.scale===void 0?1:1/t.scale,l=t.vertices,u=l.length/3,d=new Float32Array(l.length);for(let e=0,t=l.length;e<t;e++)d[e]=l[e]*c;let f=new at;if(f.setAttribute(`position`,new it(d,3)),t.normals!==void 0&&t.normals.length>0&&f.setAttribute(`normal`,new it(Float32Array.from(t.normals),3)),t.uvs!==void 0&&(t.uvs[0]&&t.uvs[0].length>0&&f.setAttribute(`uv`,new it(Float32Array.from(t.uvs[0]),2)),t.uvs[1]&&t.uvs[1].length>0&&f.setAttribute(`uv2`,new it(Float32Array.from(t.uvs[1]),2))),t.colors!==void 0&&t.colors.length>0){let e=new Float32Array(t.colors.length*3);for(let n=0,r=t.colors.length;n<r;n++){let r=new ot(t.colors[n]);e[n*3]=r.r,e[n*3+1]=r.g,e[n*3+2]=r.b}f.setAttribute(`color`,new it(e,3))}else{let e=new Float32Array(u*3).fill(1);f.setAttribute(`color`,new it(e,3))}let{indices:p,materialIndices:m}=n(t);p.length>0&&(f.setIndex(p),f.groups=r(m));let{morphPositions:h,morphNormals:g}=a(t,c);if(h.length>0){f.morphAttributes.position=h;let e=[];for(let t=0;t<h.length;t++)g[t]?e.push(g[t]):p.length>0&&e.push(i(h[t],p));e.length>0&&(f.morphAttributes.normal=e)}let _=o(t);if(_!==void 0&&(f.morphAttributes.color=_,f.morphAttributes.position===void 0)){let e=f.getAttribute(`position`);f.morphAttributes.position=_.map(t=>{let n=new it(e.array,e.itemSize);return n.name=t.name,n})}if(f.computeBoundingBox(),f.computeBoundingSphere(),t.materials===void 0||t.materials.length===0)return{geometry:f};var v=nt.prototype.initMaterials(t.materials,s,`Anonymous`);if(t.materials[0].video){var y=s+t.materials[0].video;this.paramsString&&(y+=`?${this.paramsString}`),f._video=new rt(y)}return v&&v.length>0&&(t.materials[0].singleSided?v[0].side=e.FrontSide:t.materials[0].flipSided?v[0].side=e.BackSide:v[0].side=e.DoubleSide,t.materials[0].specularCoef&&(v[0].shininess=Math.floor(t.materials[0].specularCoef/3))),{geometry:f,materials:v}}})()});var ft={NONE:0,MIRROR:1,AXES_2D:2,AXES_3D:3},pt=e=>{switch(e){case`MIRROR`:return ft.MIRROR;case`AXES_2D`:return ft.AXES_2D;case`AXES_3D`:return ft.AXES_3D;default:return ft.NONE}},mt={position:0,axis1:1,axis2:2,axis3:3,color:4},ht=e=>e==`AXES_2D`||e==`MIRROR`?2:e==`AXES_3D`?3:1;function gt({baseCount:t,outputCount:r,repeat_mode:i,positionsData:a,axis1Data:o,axis2Data:s,axis3Data:c,scaleData:l,colorData:u,baseSize:d,offset:f,scaleFactors:p,globalScale:m}){let h=ht(i),g=!!u,_=[a,o,s,c,l];g&&_.push(u);let v=_.length,y=g?mt.color+1:mt.axis3+1,b=a.length/3,x=new Float32Array(b*v*4);for(let e=0;e<b;e++)for(let t=0;t<v;t++){let n=_[t],r=(e*v+t)*4;x[r]=n[e*3],x[r+1]=n[e*3+1],x[r+2]=n[e*3+2]}let S=(0,n.attributeArray)(x,`vec4`),C=(0,n.attributeArray)(r*y,`vec4`),w=(e,t)=>S.element(e.mul((0,n.int)(v)).add((0,n.int)(t))).xyz,T=(e,t,r)=>C.element(e.mul((0,n.int)(y)).add((0,n.int)(t))).assign((0,n.vec4)(r,0)),E=e=>({element:t=>C.element((0,n.int)(t).mul((0,n.int)(y)).add((0,n.int)(e))).xyz}),D={bottomFrame:(0,n.uniform)(0,`int`),topFrame:(0,n.uniform)(0,`int`),proportion:(0,n.uniform)(1),repeatMode:(0,n.uniform)(pt(i),`int`),baseSize:(0,n.uniform)(new e.Vector3(...d)),offset:(0,n.uniform)(new e.Vector3(...f)),scaleFactors:(0,n.uniform)(new e.Vector3(...p)),globalScale:(0,n.uniform)(m)};return{uniforms:D,compute:(0,n.Fn)(()=>{let e=(0,n.int)(n.instanceIndex),r=e.div((0,n.int)(h)),i=e.mod((0,n.int)(h)),a=D.bottomFrame.mul((0,n.int)(t)).add(r),o=D.topFrame.mul((0,n.int)(t)).add(r),s=(0,n.mix)(w(o,0),w(a,0),D.proportion),c=(0,n.mix)(w(o,1),w(a,1),D.proportion),l=(0,n.mix)(w(o,2),w(a,2),D.proportion),u=(0,n.mix)(w(o,3),w(a,3),D.proportion),d=(0,n.mix)(w(o,4),w(a,4),D.proportion),f=D.repeatMode.equal((0,n.int)(ft.NONE)).or(D.repeatMode.equal((0,n.int)(ft.MIRROR)));if((0,n.If)(f,()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize).add(d.mul(D.scaleFactors)).mul(D.globalScale),r=c.mul(t.x),a=l.mul(t.y),o=u.mul(t.z),f=s.add(r.mul(D.offset.x)).add(a.mul(D.offset.y)).add(o.mul(D.offset.z)),p=D.repeatMode.equal((0,n.int)(ft.MIRROR)).and(i.equal((0,n.int)(1))),m=(0,n.select)(p,r.negate(),r).toVar(),h=(0,n.select)(p,a.negate(),a).toVar(),g=(0,n.select)(p,o.negate(),o).toVar(),_=f.toVar();(0,n.If)(D.repeatMode.equal((0,n.int)(ft.MIRROR)).and(d.x.lessThan(0)),()=>{_.subAssign(m)});let v=g.dot(m.cross(h));(0,n.If)(v.lessThan(0),()=>{g.assign(g.negate())}),T(e,mt.position,_),T(e,mt.axis1,m),T(e,mt.axis2,h),T(e,mt.axis3,g)}).Else(()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize.x).add(d.mul(D.scaleFactors.x)).mul(D.globalScale),r=s.add(c.mul(t.x).mul(D.offset.x)).add(l.mul(t.y).mul(D.offset.y)).add(u.mul(t.z).mul(D.offset.z)),a=(0,n.select)(i.equal((0,n.int)(0)),d.x,(0,n.select)(i.equal((0,n.int)(1)),d.y,d.z)),o=D.repeatMode.equal((0,n.int)(ft.AXES_2D)),f=(0,n.select)(i.equal((0,n.int)(0)),c,(0,n.select)(i.equal((0,n.int)(1)),l,u)),p=(0,n.select)(i.equal((0,n.int)(0)),l,(0,n.select)(i.equal((0,n.int)(1)),(0,n.select)(o,c,u),c)),m=D.baseSize.x.add(a.mul(D.scaleFactors.x)).mul(D.globalScale),h=f.mul(m),g=h.cross(p),_=g.length(),v=D.baseSize.z.add(a.mul(D.scaleFactors.z)).mul(D.globalScale).div((0,n.max)(_,1e-8));v=(0,n.select)(o.and(i.greaterThan((0,n.int)(0))),v.mul(-1),v);let y=(0,n.select)(_.greaterThan(0),g.mul(v),g),b=y.cross(h),x=b.length(),S=D.baseSize.y.add(a.mul(D.scaleFactors.y)).mul(D.globalScale).div((0,n.max)(x,1e-8)),C=(0,n.select)(x.greaterThan(0),b.mul(S),b);T(e,mt.position,r),T(e,mt.axis1,h),T(e,mt.axis2,C),T(e,mt.axis3,y)}),g){let t=(0,n.mix)(w(o,5),w(a,5),D.proportion);T(e,mt.color,t)}})().compute(r),outputs:{buffer:C,stride:y,count:r,position:E(mt.position),axis1:E(mt.axis1),axis2:E(mt.axis2),axis3:E(mt.axis3),color:g?E(mt.color):void 0}}}async function _t(e,t){let{buffer:n,stride:r,count:i,color:a}=t.outputs,o=new Float32Array(await e.getArrayBufferAsync(n.value)),s=e=>{let t=new Float32Array(i*4);for(let n=0;n<i;n++){let i=(n*r+e)*4;t[n*4]=o[i],t[n*4+1]=o[i+1],t[n*4+2]=o[i+2]}return t};return{position:s(mt.position),axis1:s(mt.axis1),axis2:s(mt.axis2),axis3:s(mt.axis3),color:a?s(mt.color):void 0}}async function vt(e,t){return e.compute(t.compute),_t(e,t)}var yt=!0,bt=e=>{yt=!!e},xt=()=>yt;function St(t,r){let i=t;(!i||!i.isNodeMaterial)&&(i=new(t&&De[t.type]||e.MeshPhongNodeMaterial),t&&i.copy(t));let{position:a,axis1:o,axis2:s,axis3:c,color:l}=r.outputs;return i.positionNode=(0,n.Fn)(()=>{let e=n.instanceIndex;return a.element(e).add(o.element(e).mul(n.positionGeometry.x)).add(s.element(e).mul(n.positionGeometry.y)).add(c.element(e).mul(n.positionGeometry.z))})(),l&&(i.colorNode=(0,n.Fn)(()=>(0,n.vec4)(l.element(n.instanceIndex).mul(n.materialColor),n.materialOpacity))()),i}var Ct=function(){Xe.call(this);let t=[],n,r,i,a,o=!1,s,c,l,u=0,d=0,f=[0,0,0],p=[0,0,0],m=!1,h=[0,0,0],g=`NONE`;this.ready=!1;let _=!1,v=!1;this.isGlyphset=!0;let y=new e.Matrix4,b=new e.Color,x=new e.Color,S=new e.Box3,C=new e.Box3,w=new e.Box3,T=[],E=[],D=[],O=[],k=[],A=[],j=[],M=[];this.globalScale=1;let N,P=!1,ee=!0,te=!1,ne=!1,re,ie,ae=!1;for(let t=0;t<8;t++)T[t]=new e.Vector3;let oe=(e,t)=>{e.elements[0]=t[1][0],e.elements[1]=t[1][1],e.elements[2]=t[1][2],e.elements[3]=0,e.elements[4]=t[2][0],e.elements[5]=t[2][1],e.elements[6]=t[2][2],e.elements[7]=0,e.elements[8]=t[3][0],e.elements[9]=t[3][1],e.elements[10]=t[3][2],e.elements[11]=0,e.elements[12]=t[0][0],e.elements[13]=t[0][1],e.elements[14]=t[0][2],e.elements[15]=1},ce=(e,t,n)=>{let r=new Float32Array(t*n*3);for(let i=0;i<t;i++){let t=e[i.toString()];t&&r.set(t,i*n*3)}return r},le=(t,n,r)=>{let i=new Float32Array(n*r*3),a=new e.Color;for(let e=0;e<n;e++){let n=t[e.toString()];if(n)for(let t=0;t<r;t++){a.setHex(n[t]);let o=(e*r+t)*3;i[o]=a.r,i[o+1]=a.g,i[o+2]=a.b}}return i};this.load=(t,m,y,b,x)=>{if(o=!1,n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,s=t.scale,c=t.colors,l=t.label,_=t.metadata.MorphColours,v=t.metadata.MorphVertices,u=t.metadata.number_of_time_steps,g=t.metadata.repeat_mode,d=t.metadata.number_of_vertices,g==`AXES_2D`||g==`MIRROR`?d*=2:g==`AXES_3D`&&(d*=3),f=t.metadata.base_size,p=t.metadata.offset,h=t.metadata.scale_factors,N=void 0,v&&u>1&&a&&a[0]&&xt()){let e=a[0].length/3;try{N=gt({baseCount:e,outputCount:d,repeat_mode:g,positionsData:ce(a,u,e),axis1Data:ce(n,u,e),axis2Data:ce(r,u,e),axis3Data:ce(i,u,e),scaleData:ce(s,u,e),colorData:_&&c?le(c,u,e):void 0,baseSize:f,offset:p,scaleFactors:h,globalScale:this.globalScale})}catch(e){console.error(`Failed to set up GPU glyph transform compute, falling back to CPU animation.`,e),N=void 0}}let S=new dt;this.geometry=new e.BufferGeometry;let C=new e.InstancedMesh(this.geometry,void 0,d);if(this.setMorph(C),b){var w=S.parse(m);Se(y,x)(w.geometry,w.materials),w.geometry.dispose()}else S.crossOrigin=`Anonymous`,S.load(m,Se(y,x))};let ue=(e,t,n,r,i,a)=>{if(g==`NONE`||g==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],d=[0,0,0],m=[0,0,0],_=[0,0,0],v=[0,0,0],y=[0,0,0],b=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;c[o]=(s*f[o]+i[o]*h[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],d[o]=r[o]*c[2],m[o]=e[o]+p[0]*l[o]+p[1]*u[o]+p[2]*d[o],g==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-d[o],b[o]=m[o],i[0]<0&&(m[o]-=l[o],b[o]-=_[o]));0>d[0]*(l[1]*u[2]-l[2]*u[1])+d[1]*(l[2]*u[0]-l[0]*u[2])+d[2]*(l[0]*u[1]-l[1]*u[0])&&(d[0]=-d[0],d[1]=-d[1],d[2]=-d[2]),a[0]=[m,l,u,d],g==`MIRROR`&&(0>y[0]*(_[1]*v[2]-_[2]*v[1])+y[1]*(_[2]*v[0]-_[0]*v[2])+y[2]*(_[0]*v[1]-_[1]*v[0])&&(y[0]=-y[0],y[1]=-y[1],y[2]=-y[2]),a[1]=[b,_,v,y])}else if(g==`AXES_2D`||g==`AXES_3D`){let l=[0,0,0],u=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;l[o]=(s*f[0]+i[o]*h[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+p[0]*l[0]*t[o]+p[1]*l[1]*n[o]+p[2]*l[2]*r[o];let d=g==`AXES_2D`?2:3;for(let e=0;e<d;e++){let o,s,l=i[e],d=[0,0,0],p=[0,0,0],m=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=g==`AXES_2D`?t:r):(o=r,s=t);let _=(f[0]+l*h[0])*this.globalScale;d[0]=o[0]*_,d[1]=o[1]*_,d[2]=o[2]*_,m[0]=d[1]*s[2]-s[1]*d[2],m[1]=d[2]*s[0]-s[2]*d[0],m[2]=d[0]*s[1]-d[1]*s[0];let v=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);if(0<v){let t=(f[2]+l*h[2])*this.globalScale/v;g==`AXES_2D`&&e>0&&(t*=-1),m[0]*=t,m[1]*=t,m[2]*=t}if(p[0]=m[1]*d[2]-d[1]*m[2],p[1]=m[2]*d[0]-d[2]*m[0],p[2]=m[0]*d[1]-m[1]*d[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(f[1]+l*h[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,d,p,m]}}return a},de=(e,n,r,i,a)=>{let o=1;g==`AXES_2D`||g==`MIRROR`?o=2:g==`AXES_3D`&&(o=3);let s=e.length/3,c=0;M.length=o;for(let l=0;l<s;l++){let s=l*3,u=[e[s],e[s+1],e[s+2]],d=[n[s],n[s+1],n[s+2]],f=[r[s],r[s+1],r[s+2]],p=[i[s],i[s+1],i[s+2]],m=[a[s],a[s+1],a[s+2]],h=ue(u,d,f,p,m,M);if(h.length==o)for(let e=0;e<o;e++){oe(y,h[e]),this.morph.setMatrixAt(c,y);let n=t[c];n&&n.setTransformation(h[e][0],h[e][1],h[e][2],h[e][3]),c++}}this.morph.instanceMatrix.needsUpdate=!0,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere()},fe=(e,n)=>{let r=1;g==`AXES_2D`||g==`MIRROR`?r=2:g==`AXES_3D`&&(r=3);let i=e.length,a=0;for(let o=0;o<i;o++){let i=e[o];for(let e=0;e<r;e++){b.setHex(i),n||this.morph.setColorAt(a,b);let e=t[a];e&&e.setColour(b),a++}}n||(this.morph.instanceColor.needsUpdate=!0)},pe=e=>{this.requestRender();let n=this.morph.instanceMatrix.array,r=this.canShowLabel();for(let i=0;i<d;i++){let a=i*4,o=i*16;if(n[o]=e.axis1[a],n[o+1]=e.axis1[a+1],n[o+2]=e.axis1[a+2],n[o+3]=0,n[o+4]=e.axis2[a],n[o+5]=e.axis2[a+1],n[o+6]=e.axis2[a+2],n[o+7]=0,n[o+8]=e.axis3[a],n[o+9]=e.axis3[a+1],n[o+10]=e.axis3[a+2],n[o+11]=0,n[o+12]=e.position[a],n[o+13]=e.position[a+1],n[o+14]=e.position[a+2],n[o+15]=1,r){let n=t[i];n&&n.setTransformation([e.position[a],e.position[a+1],e.position[a+2]],[e.axis1[a],e.axis1[a+1],e.axis1[a+2]],[e.axis2[a],e.axis2[a+1],e.axis2[a+2]],[e.axis3[a],e.axis3[a+1],e.axis3[a+2]])}}if(this.morph.instanceMatrix.needsUpdate=!0,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere(),e.color){let n=this.morph.instanceColor?this.morph.instanceColor.array:void 0;for(let i=0;i<d;i++){let a=i*4;if(n){let t=i*3;n[t]=e.color[a],n[t+1]=e.color[a+1],n[t+2]=e.color[a+2]}if(r){let n=t[i];n&&(b.setRGB(e.color[a],e.color[a+1],e.color[a+2]),n.setColour(b))}}n&&(this.morph.instanceColor.needsUpdate=!0)}},me=(e,t,n)=>{if(P)return;let r=this.region?.getScene?.()?.getRenderer?.();r&&(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,P=!0,ee=!1,vt(r,N).then(e=>{P=!1,pe(e),ee=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},he=(e,t,n)=>{this.requestRender();let r=this.region?.getScene?.()?.getRenderer?.();return r?(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,r.compute(N.compute),ee=!1,this.morph.raycast=()=>{},te=!0,!0):!1},ge=()=>{if(P)return;let e=this.region?.getScene?.()?.getRenderer?.();e&&(P=!0,_t(e,N).then(e=>{P=!1,pe(e),ee=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},_e=()=>{ie!==void 0&&(clearTimeout(ie),ie=void 0)},ve=()=>{_e(),ie=setTimeout(()=>{ie=void 0,ge()},500)},ye=e=>{let t=this.inbuildTime/this.duration*(u-1),o=Math.floor(t),l=1-(t-o),d=Math.ceil(t);if(v&&N){e?(he(o,d,l),ve()):(_e(),me(o,d,l));return}let f=E,p=D,m=O,h=k,g=A,y=j;if(v){let e=a[o.toString()],t=a[d.toString()],c=n[o.toString()],u=n[d.toString()],_=r[o.toString()],v=r[d.toString()],y=i[o.toString()],b=i[d.toString()],x=s[o.toString()],S=s[d.toString()];E.length=e.length,D.length=e.length,O.length=e.length,k.length=e.length,A.length=e.length;for(let n=0;n<e.length;n++)f[n]=l*e[n]+(1-l)*t[n],p[n]=l*c[n]+(1-l)*u[n],m[n]=l*_[n]+(1-l)*v[n],h[n]=l*y[n]+(1-l)*b[n],g[n]=l*x[n]+(1-l)*S[n]}else f=a[0],p=n[0],m=r[0],h=i[0],g=s[0];if((v||!ae)&&(de(f,p,m,h,g),ae=!v),c!=null){if(_){let e=c[o.toString()],t=c[d.toString()];y.length=e.length;for(let n=0;n<e.length;n++)b.setHex(e[n]),x.setHex(t[n]),b.setRGB(b.r*l+x.r*(1-l),b.g*l+x.g*(1-l),b.b*l+x.b*(1-l)),y[n]=b.getHex()}else y=c[0];fe(y,!1)}};this.isUsingGPUCompute=()=>N!==void 0,this.getLabel=e=>{if(l&&l.length>e)return l[e]},this.isLabelDisplayed=()=>m,this.canShowLabel=()=>t?.length&&(l?.length||this.groupName),this.showLabel=()=>{if(this.requestRender(),t?.length){m=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{this.requestRender();for(let e=0;e<t.length;e++)t[e].hideLabel();m=!1};let be=()=>{let t=new e.Box3().setFromBufferAttribute(this.geometry.attributes.position),o=new e.Matrix4,c=new e.Box3,l=[],d=new e.Box3,f=!0;for(let e=0;e<u;e++){let u=a[e.toString()],p=n[e.toString()],m=r[e.toString()],h=i[e.toString()],g=s[e.toString()];if(!u)continue;let _=u.length/3;for(let e=0;e<_;e++){let n=e*3,r=[u[n],u[n+1],u[n+2]],i=[p[n],p[n+1],p[n+2]],a=[m[n],m[n+1],m[n+2]],s=[h[n],h[n+1],h[n+2]],_=[g[n],g[n+1],g[n+2]],v=ue(r,i,a,s,_,l);for(let e=0;e<v.length;e++)oe(o,v[e]),c.copy(t).applyMatrix4(o),f?(d.copy(c),f=!1):d.union(c)}}return f?void 0:d},xe=e=>{for(let e=0;e<d;e++){let n=new tt(void 0,void 0,e,this),r=l?l[e]:void 0;r||=this.groupName,r&&n.setLabel(r),u>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}l&&l.length>0&&e&&this.showLabel(),de(a[0],n[0],r[0],i[0],s[0]),ae=!0,c!=null&&fe(c[0],!!(N&&N.outputs.color)),N&&(re=be()),this.ready=!0};this.addCustomGlyph=e=>{this.requestRender(),e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(this.requestRender(),e.isMesh){let r=new tt(void 0,void 0,n,this);return r.fromMesh(e),t.push(r),this.morph.add(r.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,r}},this.forEachGlyph=e=>{for(let n=0;n<t.length;n++)e(t[n])};var Se=(e,t)=>(n,r)=>{if(o){n.dispose();return}this.geometry.copy(n),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),r&&r[0]&&(this.morph.material=r[0]),N&&(this.morph.material=St(this.morph.material,N)),xe(t),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),n.dispose(),e!=null&&typeof e==`function`&&e(this)};this.getClosestVertexIndex=function(){let e=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let t=a[0],n=t.length/3,r=-1,i=0;for(let a=0;a<n;a++){let n=a*3;this._v2.set(t[n],t[n+1],t[n+2]),i=this._v1.distanceTo(this._v2),(r==-1||r>i)&&(r=i,e=a)}}return e},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let t=new e.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,y),t.setFromMatrixPosition(y),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(N&&!ee&&re)return this.cachedBoundingBox.copy(re),this.cachedBoundingBox.applyMatrix4(se(this.morph)),this.cachedBoundingBox;if(this.boundingBoxUpdateRequired){S.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<d;e++)this.morph.getMatrixAt(e,y),C.copy(S).applyMatrix4(y),e==0?w.copy(C):w.union(C);if(w)this.cachedBoundingBox.copy(w),this.cachedBoundingBox.applyMatrix4(se(this.morph)),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(_||v)&&(ye(!0),v&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||u>0)&&(_||v)),this.getCurrentTime=()=>this.inbuildTime,this.prepareColorForExport=async()=>{if(!(N&&N.outputs.color))return;let e=this.region?.getScene?.()?.getRenderer?.();if(!e)return;e.compute(N.compute);let t=(await _t(e,N)).color;this.morph.setColorAt(0,b);let n=this.morph.instanceColor.array;for(let e=0;e<d;e++){let r=e*4,i=e*3;n[i]=t[r],n[i+1]=t[r+1],n[i+2]=t[r+2]}this.morph.instanceColor.needsUpdate=!0},this.clearColorExportState=()=>{N&&N.outputs.color&&this.morph.instanceColor&&(this.morph.instanceColor=null,this.morph.material&&(this.morph.material.needsUpdate=!0))},this.setScaleAll=function(e){this.requestRender(),this.globalScale=e,ae=!1,ye(!1)},this.dispose=()=>{o=!0;for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),_e(),n=void 0,r=void 0,i=void 0,a=void 0,s=void 0,c=void 0,N=void 0,P=!1,ee=!0,te=!1,ne=!1,re=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n,r)=>{if(N&&!te){let e=this.region?.getScene?.()?.getRenderer?.();e&&(e.compute(N.compute),te=!0,this.requestRender())}if(t==1){let t=this.inbuildTime+e;if(t>this.duration&&(t-=this.duration),this.inbuildTime=t,v&&N){_e();let e=this.inbuildTime/this.duration*(u-1),t=Math.floor(e),n=1-(e-t);he(t,Math.ceil(e),n)}else(_||v)&&ye(!1);ne=!0}else ne&&N&&ye(!1),ne=!1;this.updateMarker(t,r)}};Ct.prototype=Object.create(Xe.prototype);var wt=new e.Matrix4,Tt=new e.Ray,Et=new e.Vector3,Dt=class extends e.InstancedMesh{constructor(e,t,n){super(e,t,n),this.type=`InstancedPoints`,this.isInstancedPoints=!0,this.frustumCulled=!1,this.pointSize=10,this.sizePerPixel=1,this.pointPositions=new Float32Array}raycast(t,n){let r=this.matrixWorld,i=t.params.Points?t.params.Points.threshold:1,a=this.count,o=this.pointPositions;if(!a||!o||o.length<a*3)return;wt.copy(r).invert(),Tt.copy(t.ray).applyMatrix4(wt);let s=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.pointSize*this.sizePerPixel,c=s*s;for(let i=0;i<a;i++){Et.fromArray(o,i*3);let a=Tt.distanceSqToPoint(Et);if(a<c){let o=new e.Vector3;Tt.closestPointToPoint(Et,o),o.applyMatrix4(r);let s=t.ray.origin.distanceTo(o);if(s<t.near||s>t.far)continue;n.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:i,face:null,object:this})}}}},Ot=new e.Vector2,kt=t=>{let r=new e.MeshBasicNodeMaterial,i={pointSize:(0,n.uniform)(10),sizeAttenuation:(0,n.uniform)(0),viewportScale:(0,n.uniform)(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(Ot);this.value=.5*t.y})};return r.vertexNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`instancePosition`,`vec3`),t=n.modelViewMatrix.mul((0,n.vec4)(e,1)),r=i.pointSize.mul(n.screenDPR),a=r.mul(i.viewportScale.div(t.z.negate()));r=(0,n.mix)(r,a,i.sizeAttenuation);let o=n.positionGeometry.xy.mul(r);o=o.div(n.viewportSize.div(2));let s=n.cameraProjectionMatrix.mul(t);return o=o.mul(s.w),(0,n.vec4)(s.xy.add(o),s.z,s.w)})(),r.colorNode=(0,n.Fn)(()=>{let e=(0,n.texture)(t,(0,n.uv)());return(0,n.vec4)(e.rgb.mul(n.materialColor),e.a.mul(n.materialOpacity))})(),r.userData.uniforms=i,r.size=i.pointSize.value,r.sizeAttenuation=!!i.sizeAttenuation.value,r},At=500,jt=t=>{let n=new e.PlaneGeometry(1,1),r=new e.InstancedBufferAttribute(new Float32Array(t*3),3);return r.setUsage(e.DynamicDrawUsage),n.setAttribute(`instancePosition`,r),n},Mt=(e,t)=>{let n=e.getAttribute(`position`),r=e.morphAttributes.position;if(t&&r&&r.length>0){let t=e.morphTargetsRelative;return r.map(e=>{if(!t)return Float32Array.from(e.array);let r=new Float32Array(n.array.length);for(let t=0;t<r.length;t++)r[t]=n.array[t]+e.array[t];return r})}return[Float32Array.from(n.array)]},Nt=(e,t)=>{let n=e.morphAttributes.color;if(t&&n&&n.length>0)return n.map(e=>Float32Array.from(e.array))},Pt=e=>{let t=e.getAttribute(`color`);return t?Float32Array.from(t.array):void 0},Ft=function(){Xe.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0,o=[],s,c=!1,l=!1,u=new e.Color,d=()=>{let e=this.getMorph();if(!e||o.length===0)return;let t=e.count,n=o.length,r=0,i=0,a=1;if(n>1){let e=this.inbuildTime/this.duration*(n-1);r=Math.floor(e),i=Math.ceil(e),a=1-(e-r)}if(c){let n=o[r],s=o[i],c=e.pointPositions,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*s[e];e.geometry.getAttribute(`instancePosition`).needsUpdate=!0,this.boundingBoxUpdateRequired=!0}if(l&&s){let n=s[Math.min(r,s.length-1)],o=s[Math.min(i,s.length-1)];e.instanceColor||e.setColorAt(0,u);let c=e.instanceColor.array,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*o[e];e.instanceColor.needsUpdate=!0}};this.createMesh=(e,t,n)=>{if(!e||!t)return;let r=me(e,n);o=Mt(r,n.localTimeEnabled),s=Nt(r,n.localMorphColour),c=o.length>1,l=!!s,this.timeEnabled=c,this.morphColour=l;let i=o[0].length/3,a=jt(i),d=kt(Se());t.color&&d.color.copy(t.color),t.opacity!==void 0&&(d.opacity=t.opacity),d.transparent=!!t.transparent,d.alphaTest=t.alphaTest===void 0?.5:t.alphaTest;let f=new Dt(a,d,i);f.count=i;let p=a.getAttribute(`instancePosition`);p.array.set(o[0]),p.needsUpdate=!0,f.pointPositions=p.array,f.userData=this,this.drawRange=i;let m=s?s[0]:Pt(r);if(m)for(let e=0;e<i;e++)u.setRGB(m[e*3],m[e*3+1],m[e*3+2]),f.setColorAt(e,u);this.setMorph(f),r.dispose(),this.boundingBoxUpdateRequired=!0},this.setMesh=(e,t,n)=>{this.createMesh(e.geometry,e.material,{localTimeEnabled:t,localMorphColour:n});let r=this.getMorph();r&&(r.name=e.name)};let f=(o,s,c,l)=>{if(c){let u=new et(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.05,d.material.transparent=!0,d.material.depthWrite=!1,d.material.depthTest=r,u.setFontWeight(i),u.setSize(n),u.setVisibility(a),this.group.add(d),t[o]=u}},p=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(e,t,n)=>{if(this.requestRender(),e&&e.length>0){let r=this.getMorph(),i=this.drawRange;if(!r){i=0,this.drawRange=0;let e=jt(At),t=kt(Se());t.color.set(n),t.alphaTest=.5,r=new Dt(e,t,At),r.pointPositions=e.getAttribute(`instancePosition`).array,r.count=0,r.userData=this,this.setMorph(r)}let a=r.geometry.getAttribute(`instancePosition`);e.forEach(e=>{this.drawRange<At&&(a.setXYZ(this.drawRange,e[0],e[1],e[2]),this.drawRange++)}),a.needsUpdate=!0,r.count=this.drawRange;let o=i+e.length,s=0;if(Array.isArray(t)&&t.length===e.length||typeof t==`string`)for(;i+s<o;){let n=typeof t==`string`?t:t[s];f(i+s,e[s],n,this._lod._material.color),s++}this.boundingBoxUpdateRequired=!0,this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this.requestRender(),this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setColour=e=>{this.requestRender(),this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{this.requestRender(),r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{this.requestRender(),i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{this.requestRender(),n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{this.requestRender(),a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.userData.uniforms.pointSize.value=e,this.morph.pointSize=e)},this.setSizeAttenuation=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.userData.uniforms.sizeAttenuation.value=+!!e)},this.getVerticesByIndex=function(e){let t=this.getMorph();if(t&&e>=0&&this.drawRange>e)return[t.pointPositions[e*3],t.pointPositions[e*3+1],t.pointPositions[e*3+2]]},this.editVertices=function(e,n){if(this.requestRender(),e&&e.length){let r=this.getMorph(),i=n+e.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=r.geometry.getAttribute(`instancePosition`),a=n;e.forEach(e=>{let n=t[a];n&&n.setPosition(e[0],e[1],e[2]),i.setXYZ(a,e[0],e[1],e[2]),o[0]&&(o[0][a*3]=e[0],o[0][a*3+1]=e[1],o[0][a*3+2]=e[2]),a++}),i.needsUpdate=!0,this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){this.requestRender();let t=this.getMorph();if(!t||0>e||e>=this.drawRange)return this.drawRange;let n=t.geometry.getAttribute(`instancePosition`),r=this.drawRange-1;return n.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.pointPositions!==n.array&&t.pointPositions.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor&&(t.instanceColor.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor.needsUpdate=!0),n.needsUpdate=!0,this.drawRange=r,t.count=this.drawRange,p(e),this.boundingBoxUpdateRequired=!0,this.drawRange},this.setName=function(e){let n=this.groupName;Ft.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&this.drawRange>0){this._b1.setFromArray(t.pointPositions.subarray(0,this.drawRange*3)),this._b1.getCenter(this._v1);let n=-1;for(let r=0;r<this.drawRange;r++){this._v2.fromArray(t.pointPositions,r*3);let i=this._v1.distanceTo(this._v2);(n===-1||i<n)&&(n=i,e=r)}}return e},this.getClosestVertex=function(t){let n=this.getMorph();this.closestVertexIndex===-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=new e.Vector3;return n&&this.closestVertexIndex>=0?(r.fromArray(n.pointPositions,this.closestVertexIndex*3),t?r.applyMatrix4(n.matrixWorld):r):(this.getBoundingBox(),r.copy(this.center),r)},this.getBoundingBox=function(){let e=this.getMorph();if(this.visible&&e&&e.visible&&this.drawRange>0)return this.boundingBoxUpdateRequired&&=(this._b1.setFromArray(e.pointPositions.subarray(0,this.drawRange*3)),this.cachedBoundingBox.copy(this._b1),this.cachedBoundingBox.applyMatrix4(se(e)),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox},this.isTimeVarying=()=>c||l,this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(c||l)&&d()},this.render=(e,t,n,r)=>{if(this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),this.visible&&this._lod.update(n,this.center),t===!0&&(c||l)){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,d()}this.updateMarker(t,r)}};Ft.prototype=Object.create(Xe.prototype);var It=function(){Xe.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=me(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!1,t=Oe(t));let i=new He(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(this.requestRender(),t&&t.length>0){let r=this.addVertices(t);if(!this.getMorph()){let t=new e.LineBasicMaterial({color:n});r.colorsNeedUpdate=!0,this.createLineSegment(r,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};It.prototype=Object.create(Xe.prototype);var Lt=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Lt.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Lt.prototype.imageToUint8Array=async function(e,t,n,r){await e.loadImage(t,n),r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);return i.drawImage(t,0,0),{array:new Uint8Array(i.getImageData(0,0,r.width,r.height).data.buffer),width:r.width,height:r.height}},Lt.prototype.loadFromImages=async function(e){},Lt.prototype.dispose=function(){this.impl&&=(this.impl.dispose(),void 0)},Lt.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Lt.prototype.getMaterial=function(){if(this.impl)return new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide})};var Rt=function(){Lt.call(this),this.isTextureArray=!0,this.imageData=void 0,this.setDataTexture=e=>{this.impl=e,console.log(`setDataTexture`,e),this.imageData=e.image.data},this.loadFromImages=async t=>{let n=1,r=1,i=0;if(t&&t.length){this.isLoading=!0;let a=new Image;a.crossOrigin=`Anonymous`;let o=document.createElement(`canvas`),s=0,c=Array(t.length);for(let e=0;e<t.length;e++){let l=await this.imageToUint8Array(this,a,t[e],o);l&&l.array&&(n=l.width,r=l.height,c[i]=l.array,s+=c[i].length,i++)}let l=new Uint8Array(s);s=0,c.forEach(e=>{l.set(e,s),s+=e.length}),this.impl=new e.Data3DTexture(l,n,r,i),this.size={width:n,height:r,depth:i},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=t=>{if(this.impl){let n;if(t){if(t.vs&&t.fs){let r=!0;`transparent`in t&&(r=t.transparent);let i=e.FrontSide;t.side&&(i=t.side),n=new e.ShaderMaterial({transparent:r,uniforms:t.uniforms,vertexShader:t.vs,fragmentShader:t.fs,side:i}),t.glslVersion&&(n.glslVersion=t.glslVersion)}}else n=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide});if(n)return n.needsUpdate=!0,n}}};Rt.prototype=Object.create(Lt.prototype),Rt.prototype.dispose=function(){Lt.prototype.dispose.call(this),this.imageData=void 0};function zt(){let t=new e.MeshBasicNodeMaterial({side:e.DoubleSide}),r=new Uint8Array(32),i=new e.Data3DTexture(r,2,2,2);i.image={data:r,width:2,height:2,depth:2},i.format=e.RGBAFormat,i.type=e.UnsignedByteType,i.minFilter=e.LinearFilter,i.magFilter=e.LinearFilter,i.generateMipmaps=!1,i.unpackAlignment=1,i.needsUpdate=!0;let a={brightness:(0,n.uniform)(0),contrast:(0,n.uniform)(1),depth:(0,n.uniform)(1),discardAlpha:(0,n.uniform)(!0),direction:(0,n.uniform)(1),flipY:(0,n.uniform)(!0),flipZ:(0,n.uniform)(!1),nChannels:(0,n.uniform)(1),maskEnabled:(0,n.uniform)(!1),slide:(0,n.uniform)(new e.Vector3(0,0,1)),time:(0,n.uniform)(0)},o=(0,n.varying)((0,n.vec3)(0),`vUw`);a.diffuse0=(0,n.texture3D)(i,o),a.diffuse1=(0,n.texture3D)(i,o),a.mask=(0,n.texture3D)(i,o);let s=(0,n.Fn)(()=>{let e=(0,n.vec3)(n.positionLocal).toVar();return(0,n.If)(a.direction.equal(1),()=>{e.assign((0,n.vec3)(a.slide.x,n.positionLocal.y,n.positionLocal.x))}),(0,n.If)(a.direction.equal(2),()=>{e.assign((0,n.vec3)(n.positionLocal.x,a.slide.y,n.positionLocal.y))}),(0,n.If)(a.direction.equal(3),()=>{e.assign((0,n.vec3)(n.positionLocal.x,n.positionLocal.y,a.slide.z))}),(0,n.If)(a.flipY,()=>{e.y.assign((0,n.float)(1).sub(e.y))}),(0,n.If)(a.flipZ,()=>{e.z.assign((0,n.float)(1).sub(e.z))}),o.assign((0,n.vec3)(e.x,e.y,e.z)),n.positionLocal}),c=(0,n.Fn)(()=>{let e=a.diffuse0.r,t=a.diffuse1.r,r=(0,n.mix)(e,t,a.time).toVar();(0,n.If)(a.maskEnabled.and(a.discardAlpha),()=>{let e=a.mask.r;(0,n.If)(e.equal(0),()=>{(0,n.Discard)()})});let i=(0,n.vec3)(r).add((0,n.vec3)(a.brightness)).sub((0,n.vec3)(.5)).mul(a.contrast).add((0,n.vec3)(.5));return(0,n.vec4)((0,n.sRGBTransferEOTF)(i),1)});return t.positionNode=s(),t.colorNode=c(),t.userData.uniforms=a,t}var Bt=function(e){Xe.call(this),this.isTexturePrimitive=!0,this.texture=e,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,n)=>{if(e&&e.images&&e.images.source){let n=new Rt,r=[];e.images.source.forEach(e=>{r.push(e)});let i=this;n.loadFromImages(r).then(()=>{i.texture=n,i.textureList.push(this.texture),i.initialise(e,t)})}},this.addTextureArray=e=>{this.textureList.length===0&&this.texture&&this.textureList.push(this.texture),e&&e.isTextureArray&&this.textureList.push(e)},this.initialise=(e,t)=>{t!=null&&typeof t==`function`&&t(this)}};Bt.prototype=Object.create(Xe.prototype),Bt.prototype.constructor=Bt,Bt.prototype.dispose=function(){let e=new Set(this.textureList);this.texture&&e.add(this.texture),e.forEach(e=>e.dispose()),this.texture=void 0,this.textureList=[],Xe.prototype.dispose.call(this)};var Vt=t=>{let n=t.image,r=n.width,i=n.height,a=n.depth,o=n.data,s=new e.Data3DTexture(o,r,i,a);return s.format=t.format,s.type=t.type,s.minFilter=t.minFilter,s.magFilter=t.magFilter,s.wrapS=t.wrapS,s.wrapT=t.wrapT,s.wrapR=t.wrapR,s.colorSpace=t.colorSpace,s.anisotropy=t.anisotropy,s.needsUpdate=!0,s},Ht=function(t){Bt.call(this,t),this.isTextureSlides=!0;let n=[],r={};this.morph=new e.Group,this.group=this.morph,this.morph.userData=this;let i,a=!0,o=!1,s=0,c=1,l=1,u,d=!1,f=!0,p=0,m=0,h=-.1;this.createSlides=e=>{this.requestRender(),e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material.userData.uniforms;switch(e.rotation.x=0,e.rotation.y=0,e.rotation.z=0,e.position.x=0,e.position.y=0,e.position.z=0,t.direction){case`x`:let r=-Math.PI/2;e.rotation.y=r,n.direction.value=1,n.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,n.direction.value=2,n.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:n.direction.value=3,n.slide.value.set(0,0,t.value),e.position.z=t.value}this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{this.requestRender(),e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.requestRender(),this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&t&&t.direction&&t.value!==void 0){let i=new e.PlaneGeometry(1,1);i.translate(.5,.5,0);let p=zt();p.userData.uniforms.brightness.value=s,p.userData.uniforms.contrast.value=c,p.userData.uniforms.diffuse0.value=Vt(this.texture.impl),p.userData.uniforms.diffuse1.value=Vt(this.texture.impl),p.userData.uniforms.discardAlpha.value=f,p.userData.uniforms.depth.value=this.texture.size.depth,p.userData.uniforms.flipY.value=a,p.userData.uniforms.flipZ.value=o,u&&(p.userData.uniforms.mask.value=u),p.userData.uniforms.maskEnabled.value=d,p.userData.uniforms.nChannels.value=l;let m=new e.Mesh(i,p);m.name=this.groupName,m.userData=this;let h={value:t.value,direction:t.direction,id:m.id};return n.push(h),g(m,h),r[m.id]=m,this.morph.add(m),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),h}},this.getTextureSettings=()=>[...n],this.getTextureSettingsWithId=e=>{for(let t=0;t<n.length;t++)if(e===n[t].id)return{...n[t]}},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=e=>{this.requestRender(),e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.requestRender(),this.morph&&e in r&&r[e]){if(this.morph.getObjectById(e)){let t=r[e];this.morph.remove(t),t.clear(),t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),this.boundingBoxUpdateRequired=!0}let t=n.findIndex(t=>t.id===e);t>-1&&n.splice(t,1)}},this.dispose=()=>{this.morph.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),u&&(u.dispose(),u=void 0,d=!1),Bt.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};let _=(e,t,n)=>{if(t)switch(t.direction.value){case 1:n.copy(t.slide.value),e.expandByPoint(n),n.setY(1),n.setZ(1),e.expandByPoint(n);break;case 2:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setZ(1),e.expandByPoint(n);break;case 3:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setY(1),e.expandByPoint(n)}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();let t=new e.Vector3(0,0,0);this.morph.children.forEach(e=>{_(this.cachedBoundingBox,e.material.userData.uniforms,t)}),this.cachedBoundingBox.applyMatrix4(se(this.morph)),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{this.requestRender();let i=new e.Matrix4;i.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,0);let a=new e.Quaternion().setFromRotationMatrix(i);this.morph.position.set(...n),this.morph.quaternion.copy(a),this.morph.scale.set(...r),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=e=>{this.requestRender(),this.morph.renderOrder=e},this.initialise=(e,t)=>{if(e){let n=e.locations;n&&n.length>0&&(this.applyTransformation(n[0].orientation,n[0].position,n[0].scale),`flipY`in n[0]&&(a=n[0].flipY),`flipZ`in n[0]&&(o=n[0].flipZ)),this.createSlides(e.settings.slides),t!=null&&typeof t==`function`&&t(this)}},this.showEdges=t=>{if(this.requestRender(),i)i.material.color=t;else{let n=new e.BoxGeometry(1,1,1);n.translate(.5,.5,.5);let r=new e.EdgesGeometry(n);i=new e.LineSegments(r,new e.LineBasicMaterial({color:t})),this.group.add(i)}i.visible=!0},this.setUniformsValue=(e,t)=>{this.requestRender(),this.morph.children.forEach(n=>{let r=n.material;if(r.userData.uniforms){let n=r.userData.uniforms;n[e].value=t}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{this.requestRender(),f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{this.requestRender(),s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{this.requestRender(),c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{this.requestRender(),l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{this.requestRender(),u=e,d=!!u,this.morph.children.forEach(e=>{let t=e.material;if(t.userData.uniforms){let e=t.userData.uniforms;u&&(e.mask.value=u)}}),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{this.requestRender(),i&&(i.visible=!1)},this.updateTimeTexture=()=>{let e=this.textureList.length-1,t=this.inbuildTime/this.duration;if(this.timeEnabled&&e>0&&h!==t){let n=t*e,r=Math.floor(n),i=Math.ceil(n),a=n-r;this.morph.children.forEach(e=>{let t=e.material;if(t.userData.uniforms){let e=t.userData.uniforms;p!==r&&(e.diffuse0.value.image.data=this.textureList[r].imageData,e.diffuse0.value.needsUpdate=!0),m!==i&&(e.diffuse1.value.image.data=this.textureList[i].imageData,e.diffuse1.value.needsUpdate=!0),e.time.value=a}}),p=r,m=i,h=t}},this.setMorphTime=e=>{this.requestRender();let t=e;t=e>this.duration?this.duration:0>e?0:e,t!=this.inbuildTime&&(this.inbuildTime=t,this.updateTimeTexture())},this.render=(e,t,n,r)=>{if(t==1&&this.timeEnabled&&this.textureList.length>1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,this.updateTimeTexture()}}};Ht.prototype=Object.create(Bt.prototype),Ht.prototype.constructor=Ht;var Ut=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];let e=this;this.setFromObject=({nearPlane:t,farPlane:n,eyePosition:r,targetPosition:i,upVector:a})=>{e.nearPlane=t,e.farPlane=n,e.eyePosition=r,e.targetPosition=i,e.upVector=a}},Wt=function(t,n,r,i){let a={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},o={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},s={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},c={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},l={};l.MAIN=o.ROTATE,l.AUXILIARY=o.ZOOM,l.SECONDARY=o.PAN,this.cameraObject=t,this.domElement=n===void 0?document:n,this.renderer=r,this.scene=i,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.zoomRate=50,this.rotateRate=50,this.panRate=100,this.pixelHeight=1;let u=6e3,d=!0,f=0,p,m,h=!1,g=500,_,v=`default`,y=a.DEFAULT,b,x,S,C=0,w=s.FREE;this._state=o.NONE;let T;this.targetTouchId=-1;let E,D=new e.Vector3,O=new e.Vector3,k=new e.Vector3,A=new e.Vector3,j=new e.Vector3,M=new e.Vector3,N=new e.Vector3,P=new e.Vector3,ee=new e.Sphere,te=new e.Vector3,ne=!1,re,ie=0,ae={default:new Ut};ae.default.nearPlane=.1,ae.default.farPlane=2e3,ae.default.eyePosition=[0,0,0],ae.default.targetPosition=[0,0,-1],ae.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...ae.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(ee),ie=ee.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(ee.center)),ie=e>ie?e*1.5:ie}else ie=0};let oe=e=>{D.copy(this.cameraObject.position);let t=D.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,t*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(e,t)=>{e&&t&&(ae[e]=t)},this.setDefaultViewport=e=>e&&e in ae?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>ae[e],this.setCurrentViewport=e=>e in ae&&(this.setCurrentCameraSettings(ae[e]),!0),this.setRotationMode=e=>{switch(e){case`none`:w=s.NONE;break;case`horizontal`:w=s.HORIZONTAL;break;case`vertical`:w=s.VERTICAL;break;default:w=s.FREE}},this.onResize=()=>{ne=!0,E&&=void 0,re&&re.setCurrentCameraSettings(this.cameraObject,ae[v])},this.getVisibleHeightAtZDepth=e=>{let t=this.cameraObject.position.distanceTo(this.cameraObject.target);e<t?e-=t:e+=t;let n=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(e)},this.calculateHeightPerPixelAtZeroDepth=e=>{let t=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=t/e,this.pixelHeight},this.getNDCFromDocumentCoords=(t,n,r)=>{ve(!1);let i=r||new e.Vector2,a=(t-E.left)/E.width*2-1,o=-((n-E.top)/E.height)*2+1;return i.set(a,o)},this.getRelativeCoordsFromNDC=(t,n,r)=>{ve(!1);let i=r||new e.Vector2;return i.x=(t+1)*E.width/2,i.y=(1-n)*E.height/2,i},this.setMouseButtonAction=(e,t)=>{l[e]=o[t]};let se=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},ce=()=>{if(ie>0){let e=te.distanceTo(ee.center);return ie>e||this.cameraObject.position.distanceTo(ee.center)>e}return!0},le=e=>{ne=!0,te.copy(this.cameraObject.position).add(e),ce()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},ue=e=>{ve(!1);let t;if(y===a.DEFAULT&&(t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e)),!t)e.button==0?this._state=e.ctrlKey?l.AUXILIARY:e.shiftKey?l.SECONDARY:l.MAIN:e.button==1?(e.preventDefault(),this._state=l.AUXILIARY):e.button==2&&(this._state=l.SECONDARY),this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{y=a.MINIMAP;let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);le(e)}},de=e=>{if(ve(!1),E){if(this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,y===a.MINIMAP){let t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e);if(t){let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);le(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},fe=e=>{this._state=o.NONE,y==a.MINIMAP&&(y=a.DEFAULT),T!==void 0&&this.pointer_x_start==e.clientX-E.left&&this.pointer_y_start==e.clientY-E.top&&T.pick(this,e.clientX,e.clientY,this.renderer)},pe=e=>{this._state=o.NONE},me=e=>{ve(!1);let t=e.touches.length;if(t==1)this._state=o.TOUCH_ROTATE,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(t==2){this._state=o.TOUCH_ZOOM;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(t*t+n*n)}else t==3&&(this._state=o.TOUCH_PAN,this.targetTouchId=e.touches[0].identifier,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},he=e=>{e.preventDefault(),e.stopPropagation();let t=e.touches.length;if(t==1)this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top;else if(t==2){if(this._state===o.TOUCH_ZOOM){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(t*t+n*n)}}else if(t==3&&this._state===o.TOUCH_PAN)for(let t=0;t<3;t++)e.touches[t].identifier==this.targetTouchId&&(this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top)},ge=e=>{let t=this._state;if(this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t===o.TOUCH_ROTATE&&e.touches.length===0&&e.changedTouches&&e.changedTouches.length===1&&E&&T!==void 0){let t=e.changedTouches[0];this.pointer_x_start==t.clientX-E.left&&this.pointer_y_start==t.clientY-E.top&&T.pick(this,t.clientX,t.clientY,this.renderer)}},_e=()=>{ve(!0)},ve=e=>{if(e||E===void 0){let e=new IntersectionObserver(t=>{for(let e of t)E=e.boundingClientRect;e.disconnect()});e.observe(this.domElement)}},ye=e=>{ve(!1),this._state=o.SCROLL;let t=0;e.deltaY>0?t=this.zoomRate:e.deltaY<0&&(t=this.zoomRate*-1),C+=t,e.preventDefault(),e.stopImmediatePropagation()},be=e=>{ve(!1);let t=0;if(e.keyCode===c.EQUAL||e.keyCode===c.MINUS||e.keyCode===c.NUMPADADD||e.keyCode===c.NUMPADSUBTRACT){this._state=o.KEYBOARD_ZOOM;let n=1;e.shiftKey&&(n*=2),e.keyCode===c.EQUAL||e.keyCode===c.NUMPADADD?t=this.zoomRate*n*-1:(e.keyCode===c.MINUS||e.keyCode===c.NUMPADSUBTRACT)&&(t=this.zoomRate*n),C+=t}else(e.keyCode===c.ARROWLEFT||e.keyCode===c.ARROWUP||e.keyCode===c.ARROWRIGHT||e.keyCode===c.ARROWDOWN)&&(e.shiftKey?(this._state=o.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,t=this.rotateRate):(this._state=o.KEYBOARD_PAN,t=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,e.keyCode===c.ARROWLEFT?this.pointer_x-=t:e.keyCode===c.ARROWUP?this.pointer_y-=t:e.keyCode===c.ARROWRIGHT?this.pointer_x+=t:e.keyCode===c.ARROWDOWN&&(this.pointer_y+=t));Object.values(c).includes(e.keyCode)&&e.preventDefault()},xe=e=>{this._state=o.NONE},Se=()=>{if(this.cameraObject!==void 0){let e=E.height,t=this.cameraObject.position.distanceTo(this.cameraObject.target),n=0;this.cameraObject.far>this.cameraObject.near&&t>=this.cameraObject.near&&t<=this.cameraObject.far&&(n=(t-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),O.set(this.previous_pointer_x,e-this.previous_pointer_y,0),k.set(this.previous_pointer_x,e-this.previous_pointer_y,1),A.set(this.pointer_x,e-this.pointer_y,0),j.set(this.pointer_x,e-this.pointer_y,1),O.unproject(this.cameraObject),k.unproject(this.cameraObject),A.unproject(this.cameraObject),j.unproject(this.cameraObject),A.sub(O).multiplyScalar(1-n),j.sub(k).multiplyScalar(n),A.add(j).multiplyScalar(-.002),le(A)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(e,t)=>{e.normalize(),N.copy(this.cameraObject.position).sub(this.cameraObject.target),P.copy(N),N.normalize(),.8<Math.abs(N.dot(e))&&N.copy(this.cameraObject.up),O.crossVectors(e,N).normalize(),k.crossVectors(e,O);let n=e.dot(P),r=O.dot(P),i=k.dot(P),a=e.dot(this.cameraObject.up),o=O.dot(this.cameraObject.up),s=k.dot(this.cameraObject.up),c=Math.cos(t),l=Math.sin(t);return A.set(c*O.x+l*k.x,c*O.y+l*k.y,c*O.z+l*k.z),j.set(c*k.x-l*O.x,c*k.y-l*O.y,c*k.z-l*O.z),N.copy(this.cameraObject.target),N.x=N.x+e.x*n+A.x*r+j.x*i,N.y=N.y+e.y*n+A.y*r+j.y*i,N.z=N.z+e.z*n+A.z*r+j.z*i,D.set(e.x*a+A.x*o+j.x*s,e.y*a+A.y*o+j.y*s,e.z*a+A.z*o+j.z*s),{position:N,up:D}},this.rotateAboutLookAtpoint=(e,t)=>{ne=!0;let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let Ce=()=>{if(this.cameraObject!==void 0){let e=E?.width,t=E?.height;if(0<e&&0<t){let n=.25*(e+t),r=0,i=0;(w===s.FREE||w===s.HORIZONTAL)&&(r=this.pointer_x-this.previous_pointer_x),(w===s.FREE||w===s.VERTICAL)&&(i=this.previous_pointer_y-this.pointer_y);let a=Math.sqrt(r*r+i*i);if(a>0){let o=-i*1/a,c=r*1/a;if(w===s.FREE){let r=o*(this.pointer_x-.5*(e-1))+c*(.5*(t-1)-this.pointer_y);r>n?r=n:r<-n&&(r=-n)}let l=Math.acos(0/n)-.5*Math.PI,u=this.tumble_rate*a/n;D.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),O.copy(this.cameraObject.up).normalize(),k.copy(O).cross(D).normalize().multiplyScalar(o),O.multiplyScalar(c),M.addVectors(k,O).multiplyScalar(Math.cos(l)),D.multiplyScalar(Math.sin(l)),M.add(D),this.rotateAboutLookAtpoint(M,-u)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},we=()=>{let e=0;return this._state===o.ZOOM?e=this.previous_pointer_y-this.pointer_y:this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM?e=C:(e=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),e};this.changeZoomByScrollRateUnit=e=>{let t=e*this.zoomRate;this.changeZoomByValue(t)},this.changeZoomByValue=e=>{if(this.cameraObject!==void 0){let t=E.height,n=N.copy(this.cameraObject.position);n.sub(this.cameraObject.target);let r=n.length(),i=r*(1.5*e/t);r+i>.01&&(n.normalize(),te.copy(this.cameraObject.position),te.x+=n.x*i,te.y+=n.y*i,te.z+=n.z*i,ce()&&(this.cameraObject.position.copy(te),this.updateDirectionalLight(),oe(i),ne=!0))}};let Te=()=>{let e=we();this.changeZoomByValue(e),this._state===o.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(C=0,this._state=o.NONE)};this.setDirectionalLight=e=>{this.directionalLight=e},this.updateDirectionalLight=()=>{ne=!0,this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){d=!0,this.domElement&&this.domElement.addEventListener&&(se(this.domElement,0),this.domElement.addEventListener(`mousedown`,ue,!1),this.domElement.addEventListener(`mousemove`,de,!1),this.domElement.addEventListener(`mouseup`,fe,!1),this.domElement.addEventListener(`mouseleave`,pe,!1),this.domElement.addEventListener(`touchstart`,me,!1),this.domElement.addEventListener(`touchmove`,he,!1),this.domElement.addEventListener(`touchend`,ge,!1),this.domElement.addEventListener(`wheel`,ye,!1),this.domElement.addEventListener(`mouseenter`,_e,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,be,!1),this.domElement.addEventListener(`keyup`,xe,!1))},this.disable=function(){d=!1,this._state=o.NONE,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,ue,!1),this.domElement.removeEventListener(`mousemove`,de,!1),this.domElement.removeEventListener(`mouseup`,fe,!1),this.domElement.removeEventListener(`mouseleave`,pe,!1),this.domElement.removeEventListener(`touchstart`,me,!1),this.domElement.removeEventListener(`touchmove`,he,!1),this.domElement.removeEventListener(`touchend`,ge,!1),this.domElement.removeEventListener(`wheel`,ye,!1),this.domElement.removeEventListener(`mouseenter`,_e,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,be,!1),this.domElement.removeEventListener(`keyup`,xe,!1),se(this.domElement,-1))},this.loadPath=e=>{p=e.CameraPath,m=e.NumberOfPoints},this.loadPathURL=(e,t)=>{let n=e;fetch(n).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{this.loadPath(e),t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Failed to load path asset from: ${n}`,e)})},this.setPathDuration=e=>{u=e,b&&b.setDuration(u),x&&x.setDuration(u)},this.getPlayRate=()=>g,this.setPlayRate=e=>{g=e};let Ee=e=>{let t=f+e;t>u&&(t-=u),f=t};this.getTime=()=>f,this.setTime=e=>{f=e>u?u:e<0?0:e},this.getNumberOfTimeFrame=()=>m,this.getCurrentTimeFrame=()=>{if(m>2){let e=f/u*(m-1),t=Math.floor(e),n=1-(e-t),r=Math.ceil(e);return t==r?t==m-1?[t-1,r,0]:[t,r+1,1]:[t,r,n]}if(m==1)return[0,0,0]},this.setCurrentTimeFrame=e=>{ne=!0,m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let De=e=>{if(y===a.PATH&&(Ee(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=t*3,a=n*3,o=r*p[i]+(1-r)*p[a],s=r*p[i+1]+(1-r)*p[a+1],c=r*p[i+2]+(1-r)*p[a+2];this.cameraObject.position.set(o,s,c),this.cameraObject.target.set(p[a],p[a+1],p[a+2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o,s,c),this.directionalLight.target.position.set(p[a],p[a+1],p[a+2]))}};this.calculatePathNow=()=>{ne=!0,De(0)};let Oe=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?Ce():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(Se(),re.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(re.zoom(we()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(this._state=o.NONE),C=0,re.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?De(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(b=void 0,y=a.DEFAULT),n=!1):y===a.ROTATE_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(x=void 0,y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&re?(Oe(),n=!1):r=!1,n&&(this._state!==o.NONE&&(r=!0),this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?Ce():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?Se():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&Te(),this._state!==o.NONE&&y===a.AUTO_TUMBLE&&S&&S.stopOnCameraInput,this._state===o.SCROLL&&(this._state=o.NONE)),_?(r=!0,_.update()):this.cameraObject.lookAt(this.cameraObject.target),r||=ne,ne=!1,r},this.playPath=()=>{y=a.PATH},this.stopPath=()=>{y=a.DEFAULT},this.isPlayingPath=()=>y===a.PATH,this.enableDirectionalLightUpdateWithPath=e=>{h=e},this.enableDeviceOrientation=()=>{_||=new Zt(this.cameraObject)},this.disableDeviceOrientation=()=>{_&&=(_.dispose(),void 0)},this.isDeviceOrientationEnabled=()=>!!_,this.resetView=()=>{ne=!0;let e=ae[v];this.cameraObject.near=e.nearPlane,this.cameraObject.far=e.farPlane,this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=e=>{e.nearPlane&&(this.cameraObject.near=e.nearPlane),e.farPlane&&(this.cameraObject.far=e.farPlane),e.eyePosition&&this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),e.targetPosition&&this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),e.upVector&&this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),ne=!0},this.getViewportFromCentreAndRadius=(e,t,n,r,i,a)=>{D.copy(this.cameraObject.position),D.sub(this.cameraObject.target),D.normalize();let o=[e,t,n],s=r/Math.tan(i*Math.PI/360),c=[e+D.x*s,t+D.y*s,n+D.z*s],l=s+a,u=0;u=a>.95*s?.050000000000000044*s:s-a;let d=new Ut;return d.nearPlane=u,d.farPlane=l,d.eyePosition=c,d.targetPosition=o,d.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],d},this.getViewportFromBoundingBox=(e,t)=>{let n=e.min.distanceTo(e.max)/2*t,r=(e.min.x+e.max.x)/2,i=(e.min.y+e.max.y)/2,a=(e.min.z+e.max.z)/2;return this.getViewportFromCentreAndRadius(r,i,a,n,40,n*4)},this.getCurrentViewport=()=>{let e=new Ut;return e.nearPlane=this.cameraObject.near,e.farPlane=this.cameraObject.far,e.eyePosition[0]=this.cameraObject.position.x,e.eyePosition[1]=this.cameraObject.position.y,e.eyePosition[2]=this.cameraObject.position.z,e.targetPosition[0]=this.cameraObject.target.x,e.targetPosition[1]=this.cameraObject.target.y,e.targetPosition[2]=this.cameraObject.target.z,e.upVector[0]=this.cameraObject.up.x,e.upVector[1]=this.cameraObject.up.y,e.upVector[2]=this.cameraObject.up.z,e},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(e,t,n)=>{x??(b=new Gt(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new Kt(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_TRANSITION)},this.pauseCameraTransition=()=>{y=a.DEFAULT},this.stopCameraTransition=()=>{y=a.DEFAULT,b=void 0,x=void 0},this.isTransitioningCamera=()=>y===a.SMOOTH_CAMERA_TRANSITION||y===a.ROTATE_TRANSITION,this.autoTumble=(e,t,n)=>{S=new Jt(e,t,n,this)},this.enableAutoTumble=()=>{y=a.AUTO_TUMBLE},this.stopAutoTumble=()=>{y=a.DEFAULT,S=void 0},this.updateAutoTumble=()=>{S&&(S.requireUpdate=!0)},this.isAutoTumble=()=>y===a.AUTO_TUMBLE,this.enableRaycaster=(e,t,n)=>{T??=new qt(e,this.scene,t,n,this.renderer)},this.disableRaycaster=()=>{T.disable(),T=void 0},this.isSyncControl=()=>currentMpde===a.SYNC_CONTROL,this.enableSyncControl=()=>(y=a.SYNC_CONTROL,re||=new Qt,re.setCurrentCameraSettings(this.cameraObject,ae[v]),re),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},Gt=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=t.eyePosition,s=t.targetPosition,c=n,l=r,u=0,d=!1;c.near=Math.min(e.nearPlane,t.nearPlane),c.far=Math.max(e.farPlane,t.farPlane),c.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{l=e};let f=e=>{let t=u+e;t>l&&(t=l),u=t},p=()=>{let e=u/l,t=1-e;c.cameraObject.position.set(i[0]*t+o[0]*e,i[1]*t+o[1]*e,i[2]*t+o[2]*e),c.cameraObject.target.set(a[0]*t+s[0]*e,a[1]*t+s[1]*e,a[2]*t+s[2]*e)};this.update=e=>{this.enabled!==!1&&(f(e),p(),u==l&&(d=!0))},this.isTransitionCompleted=()=>d},Kt=function(e,t,n,r){let i=e,a=t,o=n,s=r,c=0;c/s;let l=!1;this.setDuration=e=>{s=e};let u=e=>{let t=c,n=c+e;n>s&&(n=s),c=n;let r=(c-t)/s*a;o.rotateAboutLookAtpoint(i,r)};this.update=e=>{this.enabled!==!1&&(u(e),c==s&&(l=!0))},this.isTransitionCompleted=()=>l},qt=function(t,n,r,i,a){let o=t,s=n,c=a,l=r,u=i,d=!0,f=new e.Raycaster;f.params.Line.threshold=.1,f.params.Points.threshold=1;let p=new e.Vector2,m=!1,h=new Date,g=!1,_=0,v=[],y={zincCamera:void 0,x:-1,y:-1},b=!1,x;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{s!==o&&o.getThreeJSScene().updateMatrixWorld();let t=x||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?x=void 0:(x=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&x.push(e.getGroup())}))},this.getIntersectsObjectWithOrigin=(e,t,n)=>(f.set(t,n),this.getIntersectsObject(e)),this.getIntersectsObjectWithCamera=(e,t,n)=>(e.getNDCFromDocumentCoords(t,n,p),f.setFromCamera(p,e.cameraObject),this.getIntersectsObject(e)),this.pick=(e,t,n)=>{if(d&&c&&o&&e&&l){this.getIntersectsObjectWithCamera(e,t,n);let r=v.length;for(let e=0;e<r;e++){let t=v[e].object?v[e].object.userData:void 0;if(t&&t.isMarkerCluster&&t.visible&&t.clusterIsVisible(v[e].object.clusterIndex)&&t.zoomToCluster(v[e].object.clusterIndex))return}l(v,t,n),s?.invalidate?.()}};let S=(e,t,n)=>{if(d&&c&&o&&e&&u){if(this.getIntersectsObjectWithCamera(e,t,n),h.setTime(Date.now()),v.length===0){if(g)return;g=!0}else g=!1;u(v,t,n),s?.invalidate?.()}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(y.zincCamera=e,y.x=t,y.y=n,o.displayMarkers?typeof requestAnimationFrame==`function`?b||(b=!0,requestAnimationFrame(()=>{b=!1,S(y.zincCamera,y.x,y.y)})):S(e,t,n):m||(_=h?Date.now()-h.getTime():250,_>=250?S(e,t,n):(m=!0,setTimeout(C(y),250-_))))};let C=e=>function(){m=!1,S(e.zincCamera,e.x,e.y)}},Jt=function(t,n,r,i){let a=new e.Vector3,o=-n,s=i,c=t;this.stopOnCameraInput=r,this.requireUpdate=!0;let l=new e.Vector3,u=new e.Vector3,d=e=>{let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=.25*(Math.abs(e[0])*4+Math.abs(e[1])*4),r=-e[1]/t,i=e[0]/t,o=r*e[0]+i*-e[1];o>n?o=n:o<-n&&(o=-n);let c=Math.acos(o/n)-.5*Math.PI;a.copy(s.cameraObject.position).sub(s.cameraObject.target).normalize(),l.copy(s.cameraObject.up).normalize(),u.crossVectors(l,a).normalize().multiplyScalar(r),l.multiplyScalar(i),l.add(u).multiplyScalar(Math.cos(c)),a.multiplyScalar(Math.sin(c)).add(l)};this.update=e=>{this.enabled!==!1&&(this.requireUpdate&&=(d(c),!1),s.rotateAboutLookAtpoint(a,o*e/1e3))}},Yt=function(){this.type=`StereoCamera`,this.aspect=1,this.cameraL=new e.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new e.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(Yt.prototype,{update:(()=>{let t,n,r,i,a,o,s=new e.Matrix4,c=new e.Matrix4;return function(l){if(t!==l.focus||n!==l.fov||r!==l.aspect*this.aspect||i!==l.near||a!==l.far||o!==l.zoom){t=l.focus,n=l.fov,r=l.aspect*this.aspect,i=l.near,a=l.far,o=l.zoom;let u=l.projectionMatrix.clone(),d=.064/2,f=d*i/t,p=i*Math.tan(e.MathUtils.DEG2RAD*n*.5)/l.zoom,m,h;c.elements[12]=-.032,s.elements[12]=d,m=-p*r+f,h=p*r+f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraL.projectionMatrix.copy(u),m=-p*r-f,h=p*r-f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraR.projectionMatrix.copy(u)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(c),this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(s)}})()});var Xt=function(e){let t=new Yt;t.aspect=.5,this.setSize=(t,n)=>{e.setSize(t,n)},this.render=(n,r)=>{n.updateMatrixWorld(),r.parent===null&&r.updateMatrixWorld(),t.update(r);let i=e.getSize();e.setScissorTest(!0),e.clear(),e.setScissor(0,0,i.width/2,i.height),e.setViewport(0,0,i.width/2,i.height),e.render(n,t.cameraL),e.setScissor(i.width/2,0,i.width/2,i.height),e.setViewport(i.width/2,0,i.width/2,i.height),e.render(n,t.cameraR),e.setScissorTest(!1)}},Zt=function(t){let n=this;this.object=t,this.object.rotation.reorder(`YXZ`),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;let r=e=>{n.deviceOrientation=e},i=()=>{typeof window<`u`&&(n.screenOrientation=window.orientation||0)},a=(()=>{let t=new e.Vector3(0,0,1),n=new e.Euler,r=new e.Quaternion,i=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),a=new e.Vector3,o=new e.Quaternion;return(e,s,c,l,u)=>{a.subVectors(e.target,e.position),n.set(c,s,-l,`YXZ`),o.setFromEuler(n),o.multiply(i),o.multiply(r.setFromAxisAngle(t,-u)),a.applyQuaternion(o),a.addVectors(e.position,a),e.lookAt(a)}})();this.connect=()=>{i(),typeof window<`u`&&(window.addEventListener(`orientationchange`,i,!1),window.addEventListener(`deviceorientation`,r,!1)),n.enabled=!0},this.disconnect=()=>{typeof window<`u`&&(window.removeEventListener(`orientationchange`,i,!1),window.removeEventListener(`deviceorientation`,r,!1)),n.enabled=!1},this.update=()=>{if(n.enabled===!1)return;let t=n.deviceOrientation.alpha?e.MathUtils.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.MathUtils.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.MathUtils.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.MathUtils.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},Qt=function(){let t,n,r,i=new e.Vector3,a=new e.Vector3,o=new e.Vector3,s=new e.Vector3,c;this.setCurrentCameraSettings=(o,s)=>{this.near_plane_fly_debt,t=o.clone(),n=o,r=s,t.near=r.nearPlane,r.farPlane&&(t.far=r.farPlane),r.eyePosition&&t.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&t.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&(t.target=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),t.lookAt(t.target)),t.updateProjectionMatrix(),i.copy(t.position).project(t),a.copy(t.target).project(t)},this.getCurrentPosition=()=>(a.copy(n.target).project(t),[a.x,a.y]),this.zoom=e=>{let t=e*.002,r=Math.max(n.zoom-t,1);n.zoom=r,n.updateProjectionMatrix()},this.zoomToBox=(e,n)=>{e.getCenter(o),o.project(t),this.setCenterZoom([o.x,o.y],n)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:n.zoom}),this.setCenterZoom=(e,r)=>{o.set(e[0],e[1],a.z).unproject(t),s.copy(o).sub(n.target),n.target.copy(o),n.lookAt(n.target),n.position.add(s),n.zoom=r,n.updateProjectionMatrix()},this.setEventCallback=e=>{(e===void 0||typeof e==`function`)&&(c=e)},this.triggerCallback=()=>{c!==void 0&&typeof c==`function`&&c()}},$t=new e.TextureLoader().load(`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,165,0);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,b);$t.colorSpace=e.SRGBColorSpace;var en=[.02,.03,1],tn=new e.SpriteMaterial({map:$t,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),nn=function(t){Xe.call(this),this.texture=$t;let n=t;this.morph=new e.Group,this.group=this.morph,this.isMarkerCluster=!0;let r=!0,i=[];this.markers={};let a=new e.Vector2,o=new e.Vector2,s=Date.now();this.setSpriteSize=e=>{(void 0).scale.set(.015,.02,1),(void 0).scale.multiplyScalar(e)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};let c=t=>{let n=new e.Group,r=new e.Sprite(tn);return r.clusterIndex=t,r.center.set(.5,0),r.position.set(0,0,0),r.renderOrder=1e4,r.scale.set(en[0],en[1],en[2]),r.userData=this,n.add(r),this.group.add(n),{group:n,marker:r,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},l=(e,t,n)=>{e.group.visible=!0,e.group.position.set(t.coords[0],t.coords[1],t.coords[2]),(e.label===void 0||n!==e.number)&&(e.label&&(e.group.remove(e.label),ne(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=Ce(n,.012,`black`,`Asap`,120,700),e.label.renderOrder=10001,e.number=n,e.group.add(e.label)),e.min=t.min,e.max=t.max},u=e=>{let t=0;for(e.forEach(e=>{let n=e.members.length,r=0;n===1?e.members[0].setVisibility(!0):(e.members.forEach(e=>{r+=e.getNumber(),e.setVisibility(!1)}),i[t]||i.push(c(t)),l(i[t],e,r),t++)});t<i.length;t++)i[t].group.visible=!1},d=(e,t)=>{let n=!0,r={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},i=0;for(let s in e)n?(a.set(e[s].ndc.x,e[s].ndc.y),this._b1.setFromPoints([e[s].morph.position]),n=!1,r.members.push(e[s]),r.coords=[e[s].morph.position.x,e[s].morph.position.y,e[s].morph.position.z],t.push(r),delete e[s]):(o.set(e[s].ndc.x,e[s].ndc.y),i=a.distanceTo(o),.1>i&&(r.members.push(e[s]),this._b1.expandByPoint(e[s].morph.position),delete e[s]));r.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],r.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],n!==!0&&d(e,t)};this.calculate=()=>{if(r&&Date.now()-s>500){let e=[];d({...this.markers},e),u(e),n?.invalidate?.(),s=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>r,this.enable=()=>{r=!0,this.morph.visible=!0},this.disable=()=>{r=!1,this.morph.visible=!1;for(let e in this.markers)this.markers[e]?.isMarker&&this.markers[e].isEnabled()&&this.markers[e].setVisibility(!0)},this.zoomToCluster=e=>e!==void 0&&e>-1&&(this._v1.set(...i[e].min),this._v2.set(...i[e].max),Math.abs(this._v1.distanceTo(this._v2)>0))?(this._b1.set(this._v1,this._v2),n.translateBoundingBoxToCameraView(this._b1,3,300),this.markerUpdateRequired=!0,!0):!1,this.clusterIsVisible=e=>e!==void 0&&e>-1&&i[e]?i[e].group?.visible:!1};nn.prototype=Object.create(Xe.prototype);var rn=function(t){let n=t;this.camera=new e.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let r=new e.BufferGeometry;var i=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]);let a=new e.BufferAttribute(i,3);r.setAttribute(`position`,a);var o=new e.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new e.Mesh(r,o);let s=new e.Box3,c=new e.Vector3,l=new e.Vector3,u=new e.Vector3,d=new e.Vector3,f=[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],p=[f[0],f[1],f[2],f[2],f[3],f[0]],m=new e.Box3,h=new e.Matrix4,g=new e.Matrix4,_,v=!1,y=(e,t)=>{for(let n=0;n<16;n++)if(!Object.is(e.elements[n],t.elements[n]))return!1;return!0};this.getDiffFromNormalised=(t,n)=>(s.setFromBufferAttribute(a).getCenter(c),l.copy(c).project(this.camera),new e.Vector3(t,n,l.z).unproject(this.camera).sub(c));let b=(e,t)=>{n.camera.near&&(this.camera.near=n.camera.near),t.farPlane&&(this.camera.far=t.farPlane),t.eyePosition&&this.camera.position.set(t.eyePosition[0],t.eyePosition[1],t.eyePosition[2]),t.upVector&&this.camera.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),t.targetPosition&&this.camera.lookAt(u.set(t.targetPosition[0],t.targetPosition[1],t.targetPosition[2])),this.camera.zoom=1/e,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let e=n.camera;d.copy(e.target).project(e),f[0].set(-1,-1,d.z).unproject(e),f[1].set(1,-1,d.z).unproject(e),f[2].set(1,1,d.z).unproject(e),f[3].set(-1,1,d.z).unproject(e),Ee(a,p)},this.updateCamera=()=>{let e=n.camera,t=n.getBoundingBox();if(v&&t&&t.equals(m)&&_===e.near&&y(h,e.matrixWorld)&&y(g,e.projectionMatrix))return;this.getBoundary(),h.copy(e.matrixWorld),g.copy(e.projectionMatrix),_=e.near,v=!1;let r=n.getZincCameraControls();if(t){m.copy(t),v=!0;let e=t.min.distanceTo(t.max),n=e/2,i=(t.min.x+t.max.x)/2,a=(t.min.y+t.max.y)/2,o=(t.min.z+t.max.z)/2,s=r.getViewportFromCentreAndRadius(i,a,o,n,40,n*4);b(e,s)}}},an=new e.Box3,on=new e.Vector3,sn=class extends e.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new e.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new e.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceEnd`,new e.InterleavedBufferAttribute(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceColorStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceColorEnd`,new e.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new e.Box3);let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;t!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(t),an.setFromBufferAttribute(n),this.boundingBox.union(an))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingBox===null&&this.computeBoundingBox();let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(t!==void 0&&n!==void 0){let e=this.boundingSphere.center;this.boundingBox.getCenter(e);let r=0;for(let i=0,a=t.count;i<a;i++)on.fromBufferAttribute(t,i),r=Math.max(r,e.distanceToSquared(on)),on.fromBufferAttribute(n,i),r=Math.max(r,e.distanceToSquared(on));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}},cn=new e.Vector3,ln=new e.Vector3,un=new e.Vector4,dn=new e.Vector4,fn=new e.Vector4,pn=new e.Vector3,mn=new e.Matrix4,hn=new e.Line3,gn=new e.Vector3,_n=new e.Box3,vn=new e.Sphere,yn=new e.Vector4,bn=new e.Vector4,xn,Sn;function Cn(e,t,n){return yn.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),yn.multiplyScalar(1/yn.w),yn.x=Sn/n.width,yn.y=Sn/n.height,yn.applyMatrix4(e.projectionMatrixInverse),yn.multiplyScalar(1/yn.w),Math.abs(Math.max(yn.x,yn.y))}function wn(t,n){let r=t.matrixWorld,i=t.geometry,a=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=Math.min(i.instanceCount,a.count);for(let i=0,c=s;i<c;i++){hn.start.fromBufferAttribute(a,i),hn.end.fromBufferAttribute(o,i),hn.applyMatrix4(r);let s=new e.Vector3,c=new e.Vector3;xn.distanceSqToSegment(hn.start,hn.end,c,s),c.distanceTo(s)<Sn*.5&&n.push({point:c,pointOnLine:s,distance:xn.origin.distanceTo(c),object:t,face:null,faceIndex:i,uv:null,uv1:null})}}function Tn(t,n,r){let i=n.projectionMatrix,a=t.matrixWorld,o=t._resolution,s=t.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;xn.at(1,fn),fn.w=1,fn.applyMatrix4(n.matrixWorldInverse),fn.applyMatrix4(i),fn.multiplyScalar(1/fn.w),fn.x*=o.x/2,fn.y*=o.y/2,fn.z=0,pn.copy(fn),mn.multiplyMatrices(n.matrixWorldInverse,a);for(let n=0,s=u;n<s;n++){if(un.fromBufferAttribute(c,n),dn.fromBufferAttribute(l,n),un.w=1,dn.w=1,un.applyMatrix4(mn),dn.applyMatrix4(mn),un.z>d&&dn.z>d)continue;if(un.z>d){let e=un.z-dn.z,t=(un.z-d)/e;un.lerp(dn,t)}else if(dn.z>d){let e=dn.z-un.z,t=(dn.z-d)/e;dn.lerp(un,t)}un.applyMatrix4(i),dn.applyMatrix4(i),un.multiplyScalar(1/un.w),dn.multiplyScalar(1/dn.w),un.x*=o.x/2,un.y*=o.y/2,dn.x*=o.x/2,dn.y*=o.y/2,hn.start.copy(un),hn.start.z=0,hn.end.copy(dn),hn.end.z=0;let s=hn.closestPointToPointParameter(pn,!0);hn.at(s,gn);let u=e.MathUtils.lerp(un.z,dn.z,s),f=u>=-1&&u<=1,p=pn.distanceTo(gn)<Sn*.5;if(f&&p){hn.start.fromBufferAttribute(c,n),hn.end.fromBufferAttribute(l,n),hn.start.applyMatrix4(a),hn.end.applyMatrix4(a);let i=new e.Vector3,o=new e.Vector3;xn.distanceSqToSegment(hn.start,hn.end,o,i),r.push({point:o,pointOnLine:i,distance:xn.origin.distanceTo(o),object:t,face:null,faceIndex:n,uv:null,uv1:null})}}}var En=class extends e.Mesh{constructor(t=new sn,n=new e.Line2NodeMaterial({color:Math.random()*16777215})){super(t,n),this.isLineSegments2=!0,this.type=`LineSegments2`,this._resolution=new e.Vector2}computeLineDistances(){let t=this.geometry,n=t.attributes.instanceStart,r=t.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let e=0,t=0,a=n.count;e<a;e++,t+=2)cn.fromBufferAttribute(n,e),ln.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+cn.distanceTo(ln);let a=new e.InstancedInterleavedBuffer(i,2,1);return t.setAttribute(`instanceDistanceStart`,new e.InterleavedBufferAttribute(a,1,0)),t.setAttribute(`instanceDistanceEnd`,new e.InterleavedBufferAttribute(a,1,1)),this}onBeforeRender(e){e.getViewport(bn),this._resolution.set(bn.z,bn.w)}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this._resolution.x===0||this._resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;xn=e.ray;let a=this.matrixWorld,o=this.geometry;Sn=this.material.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),vn.copy(o.boundingSphere).applyMatrix4(a);let s;if(s=n?Sn*.5:Cn(r,Math.max(r.near,vn.distanceToPoint(xn.origin)),this._resolution),vn.radius+=s,xn.intersectsSphere(vn)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),_n.copy(o.boundingBox).applyMatrix4(a);let c;c=n?Sn*.5:Cn(r,Math.max(r.near,_n.distanceToPoint(xn.origin)),this._resolution),_n.expandByScalar(c),xn.intersectsBox(_n)!==!1&&(n?wn(this,t):Tn(this,r,t))}},Dn=function(){It.call(this),this.isLines2=!0;let t=new Float32Array(300),n=e=>{if(e>t.length){let n=Math.ceil(Math.max(t.length*2,e)/6)*6,r=new Float32Array(n);return r.set(t),t=r,!0}return!1},r=(e,n)=>{for(let r=e;r+2<t.length;r+=3)t[r]=n[0],t[r+1]=n[1],t[r+2]=n[2]},i=e=>{let n=e.geometry,r=n.attributes.instanceDistanceStart,i=n.attributes.instanceStart;if(!r||r.data.array.length!==i.count*2){e.computeLineDistances();return}let a=r.data.array,o=0;for(let e=0;e<i.count;e++){let n=e*6,r=t[n+3]-t[n],i=t[n+4]-t[n+1],s=t[n+5]-t[n+2];a[e*2]=o,o+=Math.sqrt(r*r+i*i+s*s),a[e*2+1]=o}r.data.needsUpdate=!0},a=(e,n)=>{let r=e.geometry.getAttribute(`instanceStart`);n||!r||r.data.array!==t?(e.geometry.setPositions(t),e.computeLineDistances()):(r.data.needsUpdate=!0,i(e),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere()),this.boundingBoxUpdateRequired=!0};this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new sn;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new En(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(e){if(this.requestRender(),e&&e.length){let i=this.getMorph();i||(this.drawRange=0);let o=this.drawRange*3,s=n(o+e.length*3);e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2],this.drawRange++}),i?(s&&r(o,e[0]),a(i,s)):r(o,e[0])}return t},this.getVerticesByFaceIndex=function(e){let t=e*2*3,n=this.getMorph();if(n&&this.drawRange*3>t){let e=n.geometry.getAttribute(`instanceStart`);return[[e.data.array[t],e.data.array[++t],e.data.array[++t]],[e.data.array[++t],e.data.array[++t],e.data.array[++t]]]}return[]},this.editVertices=function(e,n){if(this.requestRender(),e&&e.length){let i=this.getMorph(),o=n+e.length-1;if(!i||0>n||o>=this.drawRange)return;{let o=n*3;e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2]}),r(this.drawRange*3,e[0]),a(i,!1)}}return t},this.addLines=(n,r)=>{if(this.requestRender(),n&&n.length>0){if(this.addVertices(n),!this.getMorph()){let n=new e.Line2NodeMaterial({color:r,linewidth:1,vertexColors:!1,worldUnits:!1});this.createLineSegment(t,n,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};Dn.prototype=Object.create(It.prototype),Dn.prototype.constructor=Dn;var On=0,kn=function(){return`re`+On++},An=function(t,n){let r=t,i=new e.Group;i.matrixAutoUpdate=!1,i.userData=this;let a=[],o=``,s=[],c=n,l=new e.Matrix4,u=3e3;l.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=kn();let d=()=>{c?.invalidate?.()};this.hideAllPrimitives=()=>{a.forEach(e=>e.hideAllPrimitives()),s.forEach(e=>e.setVisibility(!1))},this.showAllPrimitives=()=>{a.forEach(e=>e.showAllPrimitives()),s.forEach(e=>e.setVisibility(!0))},this.setVisibility=e=>{d(),e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{d(),l.set(...e),i.matrix.copy(l),se(i),i.updateMatrixWorld(!0),this.getAllObjects(!0).forEach(e=>{e.boundingBoxUpdateRequired=!0})},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getScene=()=>c,this.getFullSeparatedPath=()=>{let e=[];if(o!==``){e.push(o);for(let t=r;t!==void 0;){let n=t.getName();n!==``&&e.unshift(n),t=t.getParent()}}return e},this.getFullPath=()=>{let e=this.getFullSeparatedPath();if(e.length>0){let t=e.shift();return e.forEach(e=>{t=t.concat(`/`,e)}),t}return``},this.createChild=e=>{d();let t=new An(this,c);return t.setName(e),a.push(t),i.add(t.getGroup()),t},this.getChildWithName=e=>{if(e){let t=e.toLowerCase();for(let e=0;e<a.length;e++)if(a[e].getName().toLowerCase()===t)return a[e]}},this.findChildFromSeparatedPath=e=>{if(e&&e.length>0&&e[0]===``&&e.shift(),e&&e.length>0){let t=this.getChildWithName(e[0]);return t?(e.shift(),t.findChildFromSeparatedPath(e)):void 0}return this},this.findChildFromPath=e=>{let t=e.split(`/`);return this.findChildFromSeparatedPath(t)},this.createChildFromSeparatedPath=e=>{if(e.length>0&&e[0]===``&&e.shift(),e.length>0){let t=this.getChildWithName(e[0]);return t||=this.createChild(e[0]),e.shift(),t.createChildFromSeparatedPath(e)}return this},this.createChildFromPath=e=>{let t=e.split(`/`);return this.createChildFromSeparatedPath(t)},this.findOrCreateChildFromPath=e=>{let t=this.findChildFromPath(e);return t||=this.createChildFromPath(e),t},this.addZincObject=e=>{d(),e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{d();for(let t=0;t<s.length;t++)if(e===s[t]){i.remove(e.getGroup()),s.splice(t,1),c&&c.triggerObjectRemovedCallback(e),e.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=e=>{if(this.pickableUpdateRequired)return!0;if(e){let t=!1;for(let n=0;n<a.length;n++)if(t=a[n].checkPickableUpdateRequred(e),t)return!0}return!1},this.clearPickableUpdateRequired=e=>{this.pickableUpdateRequired=!1,e&&a.forEach(t=>{t.clearPickableUpdateRequired(e)})},this.getPickableThreeJSObjects=(e,t)=>(i.visible?(s.forEach(t=>{if(t.isPickable&&t.getGroup()&&t.getGroup().visible){let n=t.marker;n&&n.isEnabled()&&e.push(n.getMorph()),e.push(t.getGroup())}}),t&&a.forEach(n=>{n.getPickableThreeJSObjects(e,t)}),this.pickableUpdateRequired=!1):this.clearPickableUpdateRequired(t),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=t=>{let n=new e.Box3;if(this.accumulateBoundingBox(n,t))return n},this.accumulateBoundingBox=(e,t)=>{let n=!1;for(let t=0;t<s.length;t++){let r=s[t].getBoundingBox();r&&(e.union(r),n=!0)}if(t)for(let r=0;r<a.length;r++)a[r].accumulateBoundingBox(e,t)&&(n=!0);return n},this.clear=e=>{d(),e&&a.forEach(t=>{t.clear(e),i.remove(t.getGroup())}),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),e&&(a=[]),s=[]},this.objectIsInRegion=(e,t)=>{for(let t=0;t<s.length;t++)if(e===s[t])return!0;if(t){for(let n=0;n<a.length;n++)if(a[n].objectIsInRegion(e,t))return!0}return!1},this.forEachGeometry=(e,t)=>{s.forEach(t=>{t.isGeometry&&e(t)}),t&&a.forEach(n=>n.forEachGeometry(e,t))},this.forEachGlyphset=(e,t)=>{s.forEach(t=>{t.isGlyphset&&e(t)}),t&&a.forEach(n=>n.forEachGlyphset(e,t))},this.forEachPointset=(e,t)=>{s.forEach(t=>{t.isPointset&&e(t)}),t&&a.forEach(n=>n.forEachPointset(e,t))},this.forEachLine=(e,t)=>{s.forEach(t=>{t.isLines&&e(t)}),t&&a.forEach(n=>n.forEachLine(e,t))},this.findObjectsWithAnatomicalId=(e,t)=>{let n=[];return s.forEach(t=>{t.anatomicalId===e&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithAnatomicalId(e,t);n.push(...i)}),n},this.findObjectsWithGroupName=(e,t)=>{let n=[];return s.forEach(t=>{(t.groupName?t.groupName.toLowerCase():t.groupName)===(e&&e.toLowerCase())&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithGroupName(e,t);n.push(...i)}),n},this.findGeometriesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGeometry),this.findPointsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isPointset),this.findGlyphsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGlyphset),this.findLinesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isLines),this.getAllObjects=(e,t=[])=>{for(let e=0;e<s.length;e++)t.push(s[e]);if(e)for(let n=0;n<a.length;n++)a[n].getAllObjects(e,t);return t},this.getChildRegions=e=>{let t=[...a];return e&&a.forEach(n=>{let r=n.getChildRegions(e);t.push(...r)}),t},this.getCurrentTime=()=>{if(s[0]!=null)return s[0].getCurrentTime();for(let e=0;e<a.length;e++){let t=a[e].getCurrentTime();if(t!==-1)return t}return-1},this.setMorphTime=(e,t)=>{s.forEach(t=>{t.setMorphTime(e)}),t&&a.forEach(n=>{n.setMorphTime(e,t)})},this.isTimeVarying=()=>{for(let e=0;e<s.length;e++)if(s[e].isTimeVarying())return!0;for(let e=0;e<a.length;e++)if(a[e].isTimeVarying())return!0;return!1},this.renderObjects=(e,t,n,r,i)=>{for(let i=0;i<s.length;i++)s[i].render(e,t,n,r);if(i)for(let o=0;o<a.length;o++)a[o].renderObjects(e,t,n,r,i)},this.renderGeometries=(e,t,n,r,i,a)=>{this.renderObjects(e*t,n,r,i,a),i&&n===!1&&i.markerCluster?.markerUpdateRequired&&i.markerCluster.calculate()},this.createPoints=(e,t,n,r)=>{let i=!1,a=this.findObjectsWithGroupName(e,!1),o=a.findIndex(e=>e.isPointset),s=o>-1?a[o]:new Ft;return s.addPoints(t,n,r),o===-1?(s.setName(e),this.addZincObject(s),i=!0):this.pickableUpdateRequired=!0,{zincObject:s,isNew:i}},this.createLines=(e,t,n)=>{let r=!1,i=this.findObjectsWithGroupName(e,!1),a=i.findIndex(e=>e.isLines),o=a>-1?i[a]:new Dn;return o.addLines(t,n),a===-1?(o.setName(e),this.addZincObject(o),r=!0):this.pickableUpdateRequired=!0,{zincObject:o,isNew:r}},this.createGeometryFromThreeJSGeometry=(t,n,r,i,a,o)=>{let s=new $e,c=new e.MeshPhongMaterial({color:r,transparent:!0,opacity:i,side:e.DoubleSide});if(s.createMesh(n,c,{localTimeEnabled:!1,localMorphColour:!1}),s.getMorph())return s.setVisibility(!1),s.setName(t),s.setRenderOrder(o),this.addZincObject(s),s}},jn=class{constructor(e){this.writer=e,this.name=`ZINC_morph_colour`}writeMesh(t,n){let r=t.geometry,i=r&&r.morphAttributes?r.morphAttributes.color:void 0,a=r?r.attributes.color:void 0,o=n.primitives?n.primitives[0]:void 0;if(!i||!a||!o||!o.targets)return;let s=o.targets,c=a.itemSize,l=a.count;for(let t=0;t<s.length&&t<i.length;t++){let n=i[t];if(n.itemSize!==c||n.count<l){console.warn(`GLTFExporter: Colour morph target does not match the base colour, skipped.`);return}let o=new Float32Array(l*c);for(let e=0;e<l;e++)for(let t=0;t<c;t++){let i=n.getComponent(e,t);o[e*c+t]=r.morphTargetsRelative?i:i-a.getComponent(e,t)}s[t].COLOR_0=this.writer.processAccessor(new e.BufferAttribute(o,c),r)}}},Mn=function(e){let t=e,n=e=>{for(let t=e;t;t=t.parent)if(t.visible===!1)return!1;return!0};this.exportGLTF=async e=>{let r=t.getRootRegion().getAllObjects(!0),a=[],o=[];for(let e of r){if(e.animationClip&&e.animationClip[0]){let t=e.getMorph();if(t&&n(t)){let n=e.animationClip[0].clone();n.tracks.forEach(e=>{e.name=t.uuid+e.name}),a.push(n)}}e.isGlyphset&&e.prepareColorForExport&&(await e.prepareColorForExport(),o.push(e))}let s=be(t.getThreeJSScene()),c=new i.GLTFExporter;c.register(e=>new jn(e));let l={binary:e,animations:a,onlyVisible:!0};try{return await new Promise((e,n)=>{c.parse(t.getThreeJSScene(),function(t){e(t)},function(e){console.error(`Unable to export GLTF.`,e),n(e)},l)})}finally{s(),o.forEach(e=>e.clearColorExportState())}}},Nn=function(){let e=this,t=e=>{let t=e.geometry;if(!t||!t.morphAttributes)return;let n=[];if(e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let e in t.morphAttributes){let r=t.attributes[e];t.morphAttributes[e].forEach((e,i)=>{if(t.morphTargetsRelative&&r){let t=e.array,n=r.array,i=Math.min(t.length,n.length);for(let e=0;e<i;e++)t[e]+=n[e];e.needsUpdate=!0}n[i]!==void 0&&(e.name=n[i])})}t.morphTargetsRelative=!1},n=e=>{let t=e=>(e.vertexColors=!1,Oe(e));e.material=Array.isArray(e.material)?e.material.map(t):t(e.material)};this.parseGLTFObjects=(r,i,a,o)=>{let s=i;if(a!==0){if(r.type===`Object3D`){if(r.name!==``&&(i&&(s=i.findOrCreateChildFromPath(r.name)),s)){let e=s.getGroup();e.position.copy(r.position),e.rotation.copy(r.rotation),e.quaternion.copy(r.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(r.type===`Mesh`?e=new $e:r.type===`LineSegments`?e=new It:r.type===`Points`&&(e=new Ft),e){let a=!1,s=!1;r.geometry&&r.geometry.morphAttributes&&(t(r),a=!!r.geometry.morphAttributes.position,s=!!r.geometry.morphAttributes.color);let c=r.clone();s&&!e.isPointset&&n(c),e.setMesh(c,a,s);let l=e.getMorph();e.groupName=l.name,l.matrixAutoUpdate=!0,i.addZincObject(e),o!=null&&typeof o==`function`&&o(e)}}}a++,r.children.forEach(t=>{e.parseGLTFObjects(t,s,a,o)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,r,i,o,s,c)=>{let l=r.substring(0,r.lastIndexOf(`/`)+1),u=r.substring(r.lastIndexOf(`/`)+1,r.length);new a.GLTFLoader().setPath(l).load(u,function(r){c&&c()||(console.log(r),e.parseGLTFObjects(r.scene,n,0,i),e.setCamera(t),o!=null&&typeof o==`function`&&o())})}},Pn=/^[og]\s*(.+)?/,Fn=/^mtllib /,In=/^usemtl /,Ln=/^usemap /,Rn=new e.Vector3,zn=new e.Vector3,Bn=new e.Vector3,Vn=new e.Vector3,Hn=new e.Vector3;function Un(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;Rn.fromArray(r,e),zn.fromArray(r,t),Bn.fromArray(r,n),Hn.subVectors(Bn,zn),Vn.subVectors(Rn,zn),Hn.cross(Vn),Hn.normalize(),i.push(Hn.x,Hn.y,Hn.z),i.push(Hn.x,Hn.y,Hn.z),i.push(Hn.x,Hn.y,Hn.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var Wn=class extends e.Loader{constructor(e){super(e),this.materials=null}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}setMaterials(e){return this.materials=e,this}parse(t){let n=new Un;t.indexOf(`\r
555
+ @keyframes element-queries { 0% { visibility: inherit; } }`,document.getElementsByTagName(`head`)[0].appendChild(t),!0);for(var i=0,a=document.styleSheets.length;i<a;i++)try{document.styleSheets[i].href&&document.styleSheets[i].href.indexOf(`file://`)===0&&console.warn(`CssElementQueries: unable to parse local css files, `+document.styleSheets[i].href),_(document.styleSheets[i].cssRules||document.styleSheets[i].rules||document.styleSheets[i].cssText)}catch{}p()},this.findElementQueriesElements=function(e){d(e)},this.update=function(){this.init()}};t.update=function(){t.instance.update()},t.detach=function(e){e.elementQueriesSetupInformation?(e.elementQueriesSensor.detach(),delete e.elementQueriesSetupInformation,delete e.elementQueriesSensor):e.resizeSensorInstance&&(e.resizeSensorInstance.detach(),delete e.resizeSensorInstance)},t.init=function(){t.instance||=new t,t.instance.init()};var n=function(e){if(document.addEventListener)document.addEventListener(`DOMContentLoaded`,e,!1);else if(/KHTML|WebKit|iCab/i.test(navigator.userAgent))var t=setInterval(function(){/loaded|complete/i.test(document.readyState)&&(e(),clearInterval(t))},10);else window.onload=e};return t.findElementQueriesElements=function(e){t.instance.findElementQueriesElements(e)},t.listen=function(){n(t.init)},t})})),jue=m(((e,t)=>{t.exports={ResizeSensor:O5(),ElementQueries:Aue()}})),Mue=h({GLTFExporter:()=>P5});function k5(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function Nue(e){return new TextEncoder().encode(e).buffer}function Pue(e){return k5(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Fue(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:(t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),e.normalized===!0&&(n=Tp.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function A5(e){return Math.ceil(e/4)*4}function j5(e,t=0){let n=A5(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}function M5(){return typeof document>`u`&&typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)}function Iue(e,t){if(typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas){let n;return t===`image/jpeg`?n=.92:t===`image/webp`&&(n=.8),e.convertToBlob({type:t,quality:n})}return new Promise(n=>e.toBlob(n,t))}var N5,P5,F5,I5,L5,R5,z5,B5,V5,H5,U5,W5,G5,K5,q5,J5,Y5,X5,Z5,Q5,$5,e7,t7,n7,r7,i7,a7,o7,Lue=p((()=>{DY(),N5={POSITION:[`byte`,`byte normalized`,`unsigned byte`,`unsigned byte normalized`,`short`,`short normalized`,`unsigned short`,`unsigned short normalized`],NORMAL:[`byte normalized`,`short normalized`],TANGENT:[`byte normalized`,`short normalized`],TEXCOORD:[`byte`,`byte normalized`,`unsigned byte`,`short`,`short normalized`,`unsigned short`]},P5=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new q5(e)}),this.register(function(e){return new J5(e)}),this.register(function(e){return new Q5(e)}),this.register(function(e){return new $5(e)}),this.register(function(e){return new e7(e)}),this.register(function(e){return new t7(e)}),this.register(function(e){return new Y5(e)}),this.register(function(e){return new X5(e)}),this.register(function(e){return new Z5(e)}),this.register(function(e){return new n7(e)}),this.register(function(e){return new r7(e)}),this.register(function(e){return new i7(e)}),this.register(function(e){return new a7(e)}),this.register(function(e){return new o7(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,t,n,r){let i=new K5,a=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)a.push(this.pluginCallbacks[e](i));i.setPlugins(a),i.setTextureUtils(this.textureUtils),i.writeAsync(e,t,r).catch(n)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,r,i,t)})}},F5={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},I5=`KHR_mesh_quantization`,L5={},L5[ud]=F5.NEAREST,L5[dd]=F5.NEAREST_MIPMAP_NEAREST,L5[pd]=F5.NEAREST_MIPMAP_LINEAR,L5[hd]=F5.LINEAR,L5[gd]=F5.LINEAR_MIPMAP_NEAREST,L5[vd]=F5.LINEAR_MIPMAP_LINEAR,L5[cd]=F5.CLAMP_TO_EDGE,L5[sd]=F5.REPEAT,L5[ld]=F5.MIRRORED_REPEAT,R5={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},z5=new Om,B5=12,V5=1179937895,H5=2,U5=8,W5=1313821514,G5=5130562,K5=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter r185`}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this,i=r.buffers,a=r.json;n=r.options;let o=r.extensionsUsed,s=r.extensionsRequired,c=new Blob(i,{type:`application/octet-stream`}),l=Object.keys(o),u=Object.keys(s);if(l.length>0&&(a.extensionsUsed=l),u.length>0&&(a.extensionsRequired=u),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=c.size),n.binary===!0){let e=new FileReader;e.readAsArrayBuffer(c),e.onloadend=function(){let n=j5(e.result),r=new DataView(new ArrayBuffer(U5));r.setUint32(0,n.byteLength,!0),r.setUint32(4,G5,!0);let i=j5(Nue(JSON.stringify(a)),32),o=new DataView(new ArrayBuffer(U5));o.setUint32(0,i.byteLength,!0),o.setUint32(4,W5,!0);let s=new ArrayBuffer(B5),c=new DataView(s);c.setUint32(0,V5,!0),c.setUint32(4,H5,!0);let l=B5+o.byteLength+i.byteLength+r.byteLength+n.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,i,r,n],{type:`application/octet-stream`}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(c),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new B;for(let n=0,r=e.count;n<r;n++)if(Math.abs(t.fromBufferAttribute(e,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new B;for(let e=0,t=n.count;e<t;e++)r.fromBufferAttribute(n,e),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),n.setXYZ(e,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,t){if(e===t)return e;function n(e){return e.colorSpace===`srgb`?function(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}:function(e){return e}}e instanceof B_&&(e=await this.decompressTextureAsync(e)),t instanceof B_&&(t=await this.decompressTextureAsync(t));let r=e?e.image:null,i=t?t.image:null,a=Math.max(r?r.width:0,i?i.width:0),o=Math.max(r?r.height:0,i?i.height:0),s=M5();s.width=a,s.height=o;let c=s.getContext(`2d`,{willReadFrequently:!0});c.fillStyle=`#00ffff`,c.fillRect(0,0,a,o);let l=c.getImageData(0,0,a,o);if(r){c.drawImage(r,0,0,a,o);let t=n(e),i=c.getImageData(0,0,a,o).data;for(let e=2;e<i.length;e+=4)l.data[e]=t(i[e]/256)*256}if(i){c.drawImage(i,0,0,a,o);let e=n(t),r=c.getImageData(0,0,a,o).data;for(let t=1;t<r.length;t+=4)l.data[t]=e(r[t]/256)*256}c.putImageData(l,0,0);let u=(e||t).clone();return u.source=new Lp(s),u.colorSpace=``,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn(`THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.`),console.warn(`THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.`),u}async buildNormalMapTextureAsync(e,t,n){e instanceof B_&&(e=await this.decompressTextureAsync(e));let r=e.image,i=M5();i.width=r.width,i.height=r.height;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(r,0,0,i.width,i.height);let o=a.getImageData(0,0,i.width,i.height),s=o.data;for(let e=0;e<s.length;e+=4)t&&(s[e+0]=255-s[e+0]),n&&(s[e+1]=255-s[e+1]);a.putImageData(o,0,0);let c=e.clone();return c.source=new Lp(i),c}async decompressTextureAsync(e,t=1/0){if(this.textureUtils===null)throw Error(`THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.`);return await this.textureUtils.decompress(e,t)}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;switch(t){case F5.BYTE:case F5.UNSIGNED_BYTE:o=1;break;case F5.SHORT:case F5.UNSIGNED_SHORT:o=2;break;default:o=4}let s=e.itemSize*o;i===F5.ARRAY_BUFFER&&(s=Math.ceil(s/4)*4);let c=A5(r*s),l=new DataView(new ArrayBuffer(c)),u=0;for(let i=n;i<n+r;i++){for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:(n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),e.normalized===!0&&(r=Tp.normalize(r,e.array))),t===F5.FLOAT?l.setFloat32(u,r,!0):t===F5.INT?l.setInt32(u,r,!0):t===F5.UNSIGNED_INT?l.setUint32(u,r,!0):t===F5.SHORT?l.setInt16(u,r,!0):t===F5.UNSIGNED_SHORT?l.setUint16(u,r,!0):t===F5.BYTE?l.setInt8(u,r):t===F5.UNSIGNED_BYTE&&l.setUint8(u,r),u+=o}u%s!==0&&(u+=s-u%s)}let d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:c};return i!==void 0&&(d.target=i),i===F5.ARRAY_BUFFER&&(d.byteStride=s),this.byteOffset+=c,a.bufferViews.push(d),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=j5(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.json,a={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,9:`MAT3`,16:`MAT4`},o;if(e.array.constructor===Float32Array)o=F5.FLOAT;else if(e.array.constructor===Int32Array)o=F5.INT;else if(e.array.constructor===Uint32Array)o=F5.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=F5.SHORT;else if(e.array.constructor===Uint16Array)o=F5.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=F5.BYTE;else if(e.array.constructor===Uint8Array)o=F5.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type: `+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;let s=Fue(e,n,r),c;t!==void 0&&(c=e===t.index?F5.ELEMENT_ARRAY_BUFFER:F5.ARRAY_BUFFER);let l=this.processBufferView(e,o,n,r,c),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:o,count:r,max:s.max,min:s.min,type:a[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||=[],i.accessors.push(u)-1}processImage(e,t,n,r=`image/png`){if(e!==null){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(e)||a.images.set(e,{});let l=a.images.get(e),u=r+`:flipY/`+n.toString();if(l[u]!==void 0)return l[u];o.images||=[];let d={mimeType:r},f=M5();f.width=Math.min(e.width,s.maxTextureSize),f.height=Math.min(e.height,s.maxTextureSize);let p=f.getContext(`2d`,{willReadFrequently:!0});if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){t!==1023&&console.error(`GLTFExporter: Only RGBAFormat is supported.`,t),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)p.drawImage(e,0,0,f.width,f.height);else throw Error(`THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.`);s.binary===!0?c.push(Iue(f,r).then(e=>i.processBufferViewImage(e)).then(e=>{d.bufferView=e})):d.uri=Fp.getDataURL(f,r);let m=o.images.push(d)-1;return l[u]=m,m}throw Error(`THREE.GLTFExporter: No valid image data found. Unable to process texture.`)}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:L5[e.magFilter],minFilter:L5[e.minFilter],wrapS:L5[e.wrapS],wrapT:L5[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||=[],e instanceof B_&&(e=await this.decompressTextureAsync(e,t.maxTextureSize));let i=e.userData.mimeType,a=this.processImage(e.image,e.format,e.flipY,i),o={sampler:this.processSampler(e)};i===`image/webp`?(o.extensions=o.extensions||{},o.extensions.EXT_texture_webp={source:a},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):o.source=a,e.name&&(o.name=e.name),await this._invokeAllAsync(async function(t){t.writeTexture&&await t.writeTexture(e,o)});let s=r.textures.push(o)-1;return n.textures.set(e,s),s}async processMaterialAsync(e,t){let n=this.cache,r=this.json,i=t!==void 0&&t.hasAttribute(`tangent`),a=e.normalMap?e.uuid+`:`+i:e.uuid;if(n.materials.has(a))return n.materials.get(a);if(e.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;r.materials||=[];let o={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let s=e.color.toArray().concat([e.opacity]);if(k5(s,[1,1,1,1])||(o.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(o.pbrMetallicRoughness.metallicFactor=e.metalness,o.pbrMetallicRoughness.roughnessFactor=e.roughness):(o.pbrMetallicRoughness.metallicFactor=0,o.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),o.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),o.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(o.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),o.emissiveTexture=t}}if(e.normalMap){let t=e.normalScale,n=t.x<0,r=i?t.y<0:t.y>0,a=e.normalMap;(n||r)&&(a=await this.buildNormalMapTextureAsync(e.normalMap,n,r));let s={index:await this.processTextureAsync(a),texCoord:e.normalMap.channel};Math.abs(t.x)!==1&&(s.scale=Math.abs(t.x)),this.applyTextureTransform(s,e.normalMap),o.normalTexture=s}if(e.aoMap){let t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),o.occlusionTexture=t}e.transparent?o.alphaMode=`BLEND`:e.alphaTest>0&&(o.alphaMode=`MASK`,o.alphaCutoff=e.alphaTest),e.side===2&&(o.doubleSided=!0),e.name!==``&&(o.name=e.name),this.serializeUserData(e,o),await this._invokeAllAsync(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,o)});let c=r.materials.push(o)-1;return n.materials.set(a,c),c}async processMeshAsync(e){let t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)r.push(e.material[t].uuid);else r.push(e.material.uuid);let i=r.join(`:`);if(t.meshes.has(i))return t.meshes.get(i);let a=e.geometry,o;o=e.isLineSegments?F5.LINES:e.isLineLoop?F5.LINE_LOOP:e.isLine?F5.LINE_STRIP:e.isPoints?F5.POINTS:e.material.wireframe?F5.LINES:F5.TRIANGLES;let s={},c={},l=[],u=[],d={uv:`TEXCOORD_0`,uv1:`TEXCOORD_1`,uv2:`TEXCOORD_2`,uv3:`TEXCOORD_3`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},f=a.getAttribute(`normal`);f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),a.setAttribute(`normal`,this.createNormalizedNormalAttribute(f)));let p=null;for(let e in a.attributes){if(e.slice(0,5)===`morph`)continue;let n=a.attributes[e];if(e=d[e]||e.toUpperCase(),!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)&&!e.startsWith(`_`)&&(e=`_`+e),t.attributes.has(this.getUID(n))){c[e]=t.attributes.get(this.getUID(n));continue}p=null;let r=n.array;e===`JOINTS_0`&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)?(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),p=P5.Utils.toTypedBufferAttribute(n,Uint16Array)):(r instanceof Uint32Array||r instanceof Int32Array)&&!e.startsWith(`_`)&&(console.warn(`GLTFExporter: Attribute "${e}" converted to type FLOAT.`),p=P5.Utils.toTypedBufferAttribute(n,Float32Array));let i=this.processAccessor(p||n,a);i!==null&&(e.startsWith(`_`)||this.detectMeshQuantization(e,n),c[e]=i,t.attributes.set(this.getUID(n),i))}if(f!==void 0&&a.setAttribute(`normal`,f),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let n=[],r=[],i={};if(e.morphTargetDictionary!==void 0)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){let s={},c=!1;for(let e in a.morphAttributes){if(e!==`position`&&e!==`normal`){c||=(console.warn(`GLTFExporter: Only POSITION and NORMAL morph are supported.`),!0);continue}let n=a.morphAttributes[e][o],r=e.toUpperCase(),i=a.attributes[e];if(t.attributes.has(this.getUID(n,!0))){s[r]=t.attributes.get(this.getUID(n,!0));continue}let l=n.clone();if(!a.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)t===0&&l.setX(e,n.getX(e)-i.getX(e)),t===1&&l.setY(e,n.getY(e)-i.getY(e)),t===2&&l.setZ(e,n.getZ(e)-i.getZ(e)),t===3&&l.setW(e,n.getW(e)-i.getW(e));s[r]=this.processAccessor(l,a),t.attributes.set(this.getUID(i,!0),s[r])}u.push(s),n.push(e.morphTargetInfluences[o]),e.morphTargetDictionary!==void 0&&r.push(i[o])}s.weights=n,r.length>0&&(s.extras={},s.extras.targetNames=r)}let m=Array.isArray(e.material);if(m&&a.groups.length===0)return null;let h=!1;if(m&&a.index===null){let e=[];for(let t=0,n=a.attributes.position.count;t<n;t++)e[t]=t;a.setIndex(e),h=!0}let g=m?e.material:[e.material],_=m?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=_.length;e<n;e++){let n={mode:o,attributes:c};if(this.serializeUserData(a,n),u.length>0&&(n.targets=u),a.index!==null){let r=this.getUID(a.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),t.attributes.has(r)?n.indices=t.attributes.get(r):(n.indices=this.processAccessor(a.index,a,_[e].start,_[e].count),t.attributes.set(r,n.indices)),n.indices===null&&delete n.indices}let r=await this.processMaterialAsync(g[_[e].materialIndex],a);r!==null&&(n.material=r),l.push(n)}h===!0&&a.setIndex(null),s.primitives=l,n.meshes||=[],await this._invokeAllAsync(function(t){t.writeMesh&&t.writeMesh(e,s)});let v=n.meshes.push(s)-1;return t.meshes.set(i,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[I5])return;let n;switch(t.array.constructor){case Int8Array:n=`byte`;break;case Uint8Array:n=`unsigned byte`;break;case Int16Array:n=`short`;break;case Uint16Array:n=`unsigned short`;break;default:return}t.normalized&&(n+=` normalized`);let r=e.split(`_`,1)[0];N5[r]&&N5[r].includes(n)&&(this.extensionsUsed[I5]=!0,this.extensionsRequired[I5]=!0)}processCamera(e){let t=this.json;t.cameras||=[];let n=e.isOrthographicCamera,r={type:n?`orthographic`:`perspective`};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:Tp.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==``&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||=[],e=P5.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,a=[],o=[];for(let e=0;e<i.length;++e){let n=i[e],s=ex.parseTrackName(n.name),c=ex.findNode(t,s.nodeName),l=R5[s.propertyName];if(s.objectName===`bones`&&(c=c.isSkinnedMesh===!0?c.skeleton.getBoneByName(s.objectIndex):void 0),!c||!l){console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,n.name);continue}let u=n.values.length/n.times.length;l===R5.morphTargetInfluences&&(u/=c.morphTargetInfluences.length);let d;n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(d=`CUBICSPLINE`,u/=3):d=n.getInterpolation()===2300?`STEP`:`LINEAR`,o.push({input:this.processAccessor(new fh(n.times,1)),output:this.processAccessor(new fh(n.values,u)),interpolation:d}),a.push({sampler:o.length-1,target:{node:r.get(c),path:l}})}let s={name:e.name||`clip_`+n.animations.length,samplers:o,channels:a};return this.serializeUserData(e,s),n.animations.push(s),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;let a=e.skeleton.bones[0];if(a===void 0)return null;let o=[],s=new Float32Array(i.bones.length*16),c=new Jp;for(let t=0;t<i.bones.length;++t)o.push(n.get(i.bones[t])),c.copy(i.boneInverses[t]),c.multiply(e.bindMatrix).toArray(s,t*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new fh(s,16)),joints:o,skeleton:n.get(a)}),r.skin=t.skins.length-1}async processNodeAsync(e){let t=this.json,n=this.options,r=this.nodeMap;if(t.nodes||=[],e.pivot!==null)return await this._processNodeWithPivotAsync(e);let i={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();k5(t,[0,0,0,1])||(i.rotation=t),k5(n,[0,0,0])||(i.translation=n),k5(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),Pue(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==``&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=await this.processMeshAsync(e);t!==null&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let a=t.nodes.push(i)-1;if(r.set(e,a),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(i);e!==null&&t.push(e)}}t.length>0&&(i.children=t)}return await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,i)}),a}async _processNodeWithPivotAsync(e){let t=this.json,n=this.options,r=this.nodeMap,i=e.pivot,a={},o=e.quaternion.toArray(),s=[e.position.x+i.x,e.position.y+i.y,e.position.z+i.z],c=e.scale.toArray();k5(o,[0,0,0,1])||(a.rotation=o),k5(s,[0,0,0])||(a.translation=s),k5(c,[1,1,1])||(a.scale=c),a.extras={pivot:i.toArray()},e.name!==``&&(a.name=String(e.name)),this.serializeUserData(e,a);let l=t.nodes.push(a)-1;r.set(e,l);let u={},d=[-i.x,-i.y,-i.z];if(k5(d,[0,0,0])||(u.translation=d),e.isMesh||e.isLine||e.isPoints){let t=await this.processMeshAsync(e);t!==null&&(u.mesh=t)}else e.isCamera&&(u.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let f=[t.nodes.push(u)-1];if(e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(i);e!==null&&t.push(e)}}t.length>0&&(u.children=t)}return a.children=f,await this._invokeAllAsync(function(t){t.writeNode&&t.writeNode(e,a)}),l}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=await this.processNodeAsync(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new Mm;t.name=`AuxScene`;for(let n=0;n<e.length;n++)t.children.push(e[n]);await this.processSceneAsync(t)}async processInputAsync(e){let t=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});let n=[];for(let t=0;t<e.length;t++)e[t]instanceof Mm?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);if(e.length===1)for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);else for(let n=0;n<e.length;n++){let r=t.animations[n]||[];for(let t=0;t<r.length;++t)this.processAnimation(r[t],e[n])}await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let t=0,n=this.plugins.length;t<n;t++)await e(this.plugins[t])}},q5=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},J5=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Y5=class{constructor(e){this.writer=e,this.name=`KHR_materials_clearcoat`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},X5=class{constructor(e){this.writer=e,this.name=`KHR_materials_dispersion`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},Z5=class{constructor(e){this.writer=e,this.name=`KHR_materials_iridescence`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},Q5=class{constructor(e){this.writer=e,this.name=`KHR_materials_transmission`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},$5=class{constructor(e){this.writer=e,this.name=`KHR_materials_volume`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},e7=class{constructor(e){this.writer=e,this.name=`KHR_materials_ior`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},t7=class{constructor(e){this.writer=e,this.name=`KHR_materials_specular`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(z5)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},n7=class{constructor(e){this.writer=e,this.name=`KHR_materials_sheen`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},r7=class{constructor(e){this.writer=e,this.name=`KHR_materials_anisotropy`}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},i7=class{constructor(e){this.writer=e,this.name=`KHR_materials_emissive_strength`}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},a7=class{constructor(e){this.writer=e,this.name=`EXT_materials_bump`}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},o7=class{constructor(e){this.writer=e,this.name=`EXT_mesh_gpu_instancing`}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=e,i=new Float32Array(r.count*3),a=new Float32Array(r.count*4),o=new Float32Array(r.count*3),s=new Jp,c=new B,l=new Ep,u=new B;for(let e=0;e<r.count;e++)r.getMatrixAt(e,s),s.decompose(c,l,u),c.toArray(i,e*3),l.toArray(a,e*4),u.toArray(o,e*3);let d={TRANSLATION:n.processAccessor(new fh(i,3)),ROTATION:n.processAccessor(new fh(a,4)),SCALE:n.processAccessor(new fh(o,3))};r.instanceColor&&(d._COLOR_0=n.processAccessor(r.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:d},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}},P5.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e<i.length;++e){let a=i[e],o=ex.parseTrackName(a.name),s=ex.findNode(t,o.nodeName);if(o.propertyName!==`morphTargetInfluences`||o.propertyIndex===void 0){n.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),a=a.clone(),a.setInterpolation(jf)}let c=s.morphTargetInfluences.length,l=s.morphTargetDictionary[o.propertyIndex];if(l===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+o.propertyIndex);let u;if(r[s.uuid]===void 0){u=a.clone();let e=new u.ValueBufferType(c*u.times.length);for(let t=0;t<u.times.length;t++)e[t*c+l]=u.values[t];u.name=(o.nodeName||``)+`.morphTargetInfluences`,u.values=e,r[s.uuid]=u,n.push(u);continue}let d=a.createInterpolant(new a.ValueBufferType(1));u=r[s.uuid];for(let e=0;e<u.times.length;e++)u.values[e*c+l]=d.evaluate(u.times[e]);for(let e=0;e<a.times.length;e++){let t=this.insertKeyframe(u,a.times[e]);u.values[t*c+l]=a.values[e]}}return e.tracks=n,e},toTypedBufferAttribute:function(e,t){let n=new fh(new t(e.count*e.itemSize),e.itemSize,!1);if(!e.normalized&&!e.isInterleavedBufferAttribute)return n.array.set(e.array),n;for(let t=0,r=e.count;t<r;t++)for(let r=0;r<e.itemSize;r++)n.setComponent(t,r,e.getComponent(t,r));return n}}}));function s7(e,t){if(t===0)return console.warn(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.`),e;if(t===2||t===1){let n=e.getIndex();if(n===null){let t=[],r=e.getAttribute(`position`);if(r!==void 0){for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}else return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.`),e}let r=n.count-2,i=[];if(t===2)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.`);let a=e.clone();return a.setIndex(i),a.clearGroups(),a}return console.error(`THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:`,t),e}var Rue=p((()=>{DY()}));function zue(e){let t=new Map,n=new Map,r=e.clone();return c7(e,r,function(e,r){t.set(r,e),n.set(e,r)}),r.traverse(function(e){if(!e.isSkinnedMesh)return;let r=e,i=t.get(e),a=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=a.map(function(e){return n.get(e)}),r.bind(r.skeleton,r.bindMatrix)}),r}function c7(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)c7(e.children[r],t.children[r],n)}var Bue=p((()=>{})),Vue=h({GLTFLoader:()=>h7});function Hue(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function l7(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}function Uue(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new Yv({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function u7(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function d7(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function Wue(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function Gue(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function Kue(e){let t,n=e.extensions&&e.extensions[g7.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+f7(n.attributes):e.indices+`:`+f7(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+f7(e.targets[n]);return t}function f7(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function p7(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function que(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}function Jue(e,t,n){let r=t.attributes,i=new qm;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new B(t[0],t[1],t[2]),new B(a[0],a[1],a[2])),e.normalized){let t=p7(K7[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new B,t=new B;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=p7(K7[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new Th;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function m7(e,t,n){let r=t.attributes,i=[];function a(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in r){let n=X7[t]||t.toLowerCase();n in e.attributes||i.push(a(r[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});i.push(r)}return Np.workingColorSpace!==`srgb-linear`&&`COLOR_0`in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Np.workingColorSpace}" not supported.`),d7(e,t),Jue(e,t,n),Promise.all(i).then(function(){return t.targets===void 0?e:Wue(e,t.targets,n)})}var h7,g7,_7,v7,y7,b7,x7,S7,C7,w7,T7,E7,D7,O7,k7,A7,j7,M7,N7,P7,F7,I7,L7,R7,z7,B7,V7,H7,U7,W7,G7,K7,q7,J7,Y7,X7,Z7,Q7,$7,e9,t9,Yue=p((()=>{DY(),Rue(),Bue(),h7=class extends Cy{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new b7(e)}),this.register(function(e){return new x7(e)}),this.register(function(e){return new A7(e)}),this.register(function(e){return new j7(e)}),this.register(function(e){return new M7(e)}),this.register(function(e){return new C7(e)}),this.register(function(e){return new w7(e)}),this.register(function(e){return new T7(e)}),this.register(function(e){return new E7(e)}),this.register(function(e){return new y7(e)}),this.register(function(e){return new D7(e)}),this.register(function(e){return new S7(e)}),this.register(function(e){return new k7(e)}),this.register(function(e){return new O7(e)}),this.register(function(e){return new _7(e)}),this.register(function(e){return new N7(e,g7.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new N7(e,g7.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new P7(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=sb.extractUrlBase(e);a=sb.resolveURL(t,this.path)}else a=sb.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new Ey(this.manager);s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===F7){try{a[g7.KHR_BINARY_GLTF]=new R7(e)}catch(e){r&&r(e);return}i=JSON.parse(a[g7.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new t9(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case g7.KHR_MATERIALS_UNLIT:a[t]=new v7;break;case g7.KHR_DRACO_MESH_COMPRESSION:a[t]=new z7(i,this.dracoLoader);break;case g7.KHR_TEXTURE_TRANSFORM:a[t]=new B7;break;case g7.KHR_MESH_QUANTIZATION:a[t]=new V7;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}},g7={KHR_BINARY_GLTF:`KHR_binary_glTF`,KHR_DRACO_MESH_COMPRESSION:`KHR_draco_mesh_compression`,KHR_LIGHTS_PUNCTUAL:`KHR_lights_punctual`,KHR_MATERIALS_CLEARCOAT:`KHR_materials_clearcoat`,KHR_MATERIALS_DISPERSION:`KHR_materials_dispersion`,KHR_MATERIALS_IOR:`KHR_materials_ior`,KHR_MATERIALS_SHEEN:`KHR_materials_sheen`,KHR_MATERIALS_SPECULAR:`KHR_materials_specular`,KHR_MATERIALS_TRANSMISSION:`KHR_materials_transmission`,KHR_MATERIALS_IRIDESCENCE:`KHR_materials_iridescence`,KHR_MATERIALS_ANISOTROPY:`KHR_materials_anisotropy`,KHR_MATERIALS_UNLIT:`KHR_materials_unlit`,KHR_MATERIALS_VOLUME:`KHR_materials_volume`,KHR_TEXTURE_BASISU:`KHR_texture_basisu`,KHR_TEXTURE_TRANSFORM:`KHR_texture_transform`,KHR_MESH_QUANTIZATION:`KHR_mesh_quantization`,KHR_MATERIALS_EMISSIVE_STRENGTH:`KHR_materials_emissive_strength`,EXT_MATERIALS_BUMP:`EXT_materials_bump`,EXT_TEXTURE_WEBP:`EXT_texture_webp`,EXT_TEXTURE_AVIF:`EXT_texture_avif`,EXT_MESHOPT_COMPRESSION:`EXT_meshopt_compression`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},_7=class{constructor(e){this.parser=e,this.name=g7.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new Om(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],Wf);let c=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new eb(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new Zy(s),o.distance=c;break;case`spot`:o=new Yy(s),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),d7(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},v7=class{constructor(){this.name=g7.KHR_MATERIALS_UNLIT}getMaterialType(){return dg}extendParams(e,t,n){let r=[];e.color=new Om(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],Wf),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,Uf))}return Promise.all(r)}},y7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},b7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new z(e,e)}return Promise.all(r)}},x7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_DISPERSION}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},S7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},C7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_SHEEN}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new Om(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],Wf)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,Uf)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},w7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},T7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_VOLUME}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new Om().setRGB(i[0],i[1],i[2],Wf),Promise.all(r)}},E7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_IOR}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);return n===null?Promise.resolve():(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3),Promise.resolve())}},D7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_SPECULAR}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new Om().setRGB(i[0],i[1],i[2],Wf),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,Uf)),Promise.all(r)}},O7=class{constructor(e){this.parser=e,this.name=g7.EXT_MATERIALS_BUMP}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},k7=class{constructor(e){this.parser=e,this.name=g7.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return l7(this.parser,e,this.name)===null?null:Xv}extendMaterialParams(e,t){let n=l7(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},A7=class{constructor(e){this.parser=e,this.name=g7.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},j7=class{constructor(e){this.parser=e,this.name=g7.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},M7=class{constructor(e){this.parser=e,this.name=g7.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},N7=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},P7=class{constructor(e){this.name=g7.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==G7.TRIANGLES&&e.mode!==G7.TRIANGLE_STRIP&&e.mode!==G7.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],o={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(o[e]=t,o[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new Jp,n=new B,a=new Ep,s=new B(1,1,1),c=new qg(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&a.fromBufferAttribute(o.ROTATION,e),o.SCALE&&s.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,a,s));for(let t in o)if(t===`_COLOR_0`){let e=o[t];c.instanceColor=new zg(e.array,e.itemSize,e.normalized)}else t!==`TRANSLATION`&&t!==`ROTATION`&&t!==`SCALE`&&e.geometry.setAttribute(t,o[t]);xm.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),i.push(c)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},F7=`glTF`,I7=12,L7={JSON:1313821514,BIN:5130562},R7=class{constructor(e){this.name=g7.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,I7),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==F7)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-I7,i=new DataView(e,I7),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===L7.JSON){let r=new Uint8Array(e,I7+a,t);this.content=n.decode(r)}else if(r===L7.BIN){let n=I7+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},z7=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=g7.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=X7[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=X7[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=K7[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,Wf,n)})})}},B7=class{constructor(){this.name=g7.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0?e:(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e)}},V7=class{constructor(){this.name=g7.KHR_MESH_QUANTIZATION}},H7=class extends oy{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},U7=new Ep,W7=class extends H7{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return U7.fromArray(i).normalize().toArray(i),i}},G7={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},K7={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},q7={9728:ud,9729:hd,9984:dd,9985:gd,9986:pd,9987:vd},J7={33071:cd,33648:ld,10497:sd},Y7={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X7={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`,COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},Z7={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},Q7={CUBICSPLINE:void 0,LINEAR:jf,STEP:Af},$7={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`},e9=new Jp,t9=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Hue,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,i=!1,a=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,a=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}this.textureLoader=typeof createImageBitmap>`u`||n&&r<17||i&&a<98?new Ny(this.options.manager):new gb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ey(this.options.manager),this.fileLoader.setResponseType(`arraybuffer`),this.options.crossOrigin===`use-credentials`&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return u7(i,a,r),d7(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[g7.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(sb.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=Y7[r.type],t=K7[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new fh(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=Y7[r.type],o=K7[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new Ph(f,u/s),t.cache.add(n,c)),p=new Ih(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new fh(f,a,d);if(r.sparse!==void 0){let t=Y7.SCALAR,n=K7[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new fh(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=q7[n.magFilter]||1006,t.minFilter=q7[n.minFilter]||1008,t.wrapS=J7[n.wrapS]||1e3,t.wrapT=J7[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1;if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);let l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new Bp(e);t.needsUpdate=!0,n(t)}),t.load(sb.resolveURL(e,i.path),a,void 0,r)})}).then(function(e){return c===!0&&o.revokeObjectURL(s),d7(e,a),e.userData.mimeType=a.mimeType||que(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[g7.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[g7.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[g7.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new j_,Rh.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new v_,Rh.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Yv}loadMaterial(e){let t=this,n=this.json,r=this.extensions,i=n.materials[e],a,o={},s=i.extensions||{},c=[];if(s[g7.KHR_MATERIALS_UNLIT]){let e=r[g7.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),c.push(e.extendParams(o,i,t))}else{let n=i.pbrMetallicRoughness||{};if(o.color=new Om(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],Wf),o.opacity=e[3]}n.baseColorTexture!==void 0&&c.push(t.assignTexture(o,`map`,n.baseColorTexture,Uf)),o.metalness=n.metallicFactor===void 0?1:n.metallicFactor,o.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,`metalnessMap`,n.metallicRoughnessTexture)),c.push(t.assignTexture(o,`roughnessMap`,n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}i.doubleSided===!0&&(o.side=2);let l=i.alphaMode||$7.OPAQUE;if(l===$7.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,l===$7.MASK&&(o.alphaTest=i.alphaCutoff===void 0?.5:i.alphaCutoff)),i.normalTexture!==void 0&&a!==dg&&(c.push(t.assignTexture(o,`normalMap`,i.normalTexture)),o.normalScale=new z(1,1),i.normalTexture.scale!==void 0)){let e=i.normalTexture.scale;o.normalScale.set(e,e)}if(i.occlusionTexture!==void 0&&a!==dg&&(c.push(t.assignTexture(o,`aoMap`,i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&a!==dg){let e=i.emissiveFactor;o.emissive=new Om().setRGB(e[0],e[1],e[2],Wf)}return i.emissiveTexture!==void 0&&a!==dg&&c.push(t.assignTexture(o,`emissiveMap`,i.emissiveTexture,Uf)),Promise.all(c).then(function(){let n=new a(o);return i.name&&(n.name=i.name),d7(n,i),t.associations.set(n,{materials:e}),i.extensions&&u7(r,n,i),n})}createUniqueName(e){let t=ex.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[g7.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return m7(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=Kue(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[g7.KHR_DRACO_MESH_COMPRESSION]?i(o):m7(new Nh,o,t),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?Uue(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===G7.TRIANGLES||u.mode===G7.TRIANGLE_STRIP||u.mode===G7.TRIANGLE_FAN||u.mode===void 0)d=i.isSkinnedMesh===!0?new Ng(l,f):new Cg(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights(),u.mode===G7.TRIANGLE_STRIP?d.geometry=s7(d.geometry,1):u.mode===G7.TRIANGLE_FAN&&(d.geometry=s7(d.geometry,2));else if(u.mode===G7.LINES)d=new k_(l,f);else if(u.mode===G7.LINE_STRIP)d=new E_(l,f);else if(u.mode===G7.LINE_LOOP)d=new A_(l,f);else if(u.mode===G7.POINTS)d=new I_(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&Gue(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),d7(d,i),u.extensions&&u7(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&u7(r,c[0],i),c[0];let l=new Sm;i.extensions&&u7(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn(`THREE.GLTFLoader: Missing camera parameters.`);return}return n.type===`perspective`?t=new qy(Tp.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new Qy(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),d7(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new Jp;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new Rg(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new yy(i,void 0,l);return d7(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,e9)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new B().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,o=[],s=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return s&&o.push(s),i.camera!==void 0&&o.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if(o=i.isBone===!0?new Pg:t.length>1?new Sm:t.length===1?t[0]:new xm,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=a),d7(o,i),i.extensions&&u7(n,o,i),i.matrix!==void 0){let e=new Jp;e.fromArray(i.matrix),o.applyMatrix4(e)}else i.translation!==void 0&&o.position.fromArray(i.translation),i.rotation!==void 0&&o.quaternion.fromArray(i.rotation),i.scale!==void 0&&o.scale.fromArray(i.scale);if(!r.associations.has(o))r.associations.set(o,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(o);r.associations.set(o,{...e})}return r.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new Sm;n.name&&(i.name=r.createUniqueName(n.name)),d7(i,n),n.extensions&&u7(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(zue(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof Rh||e instanceof Bp)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,n,r,i){let a=[],o=e.name?e.name:e.uuid,s=[];function c(e){e.morphTargetInfluences&&s.push(e.name?e.name:e.uuid)}Z7[i.path]===Z7.weights?(c(e),e.isGroup&&e.children.forEach(c)):s.push(o);let l;switch(Z7[i.path]){case Z7.weights:l=my;break;case Z7.rotation:l=gy;break;case Z7.translation:case Z7.scale:l=vy;break;default:switch(n.itemSize){case 1:l=my;break;default:l=vy}}let u=r.interpolation===void 0?jf:Q7[r.interpolation],d=this._getArrayFromAccessor(n);for(let e=0,n=s.length;e<n;e++){let n=new l(s[e]+`.`+Z7[i.path],t.array,d,u);r.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),a.push(n)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=p7(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof gy?W7:H7)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}})),Xue=m((e=>{e.deflate=Ue,e.deflateSync=We,e.inflate=qe,e.inflateSync=Je,e.gzip=Ze,e.compress=Ze,e.gzipSync=Qe,e.compressSync=Qe,e.gunzip=tt,e.gunzipSync=nt,e.zlib=it,e.zlibSync=at,e.unzlib=ct,e.unzlibSync=lt,e.gzip=Ze,e.compress=Ze,e.decompress=dt,e.decompressSync=ft,e.strToU8=vt,e.strFromU8=yt,e.zip=Ot,e.zipSync=kt,e.unzip=Mt,e.unzipSync=Nt;var t={},n={};n.default=(function(e,n,r,i,a){var o=new Worker(t[n]||(t[n]=URL.createObjectURL(new Blob([e+`;addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return o.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],a(r,null)}else a(null,t)},o.postMessage(r,i),o});var r=Uint8Array,i=Uint16Array,a=Int32Array,o=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),c=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),l=function(e,t){for(var n=new i(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new a(n[30]),r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return{b:n,r:o}},u=l(o,2),d=u.b,f=u.r;d[28]=258,f[258]=28;for(var p=l(s,0),m=p.b,h=p.r,g=new i(32768),_=0;_<32768;++_){var v=(_&43690)>>1|(_&21845)<<1;v=(v&52428)>>2|(v&13107)<<2,v=(v&61680)>>4|(v&3855)<<4,g[_]=((v&65280)>>8|(v&255)<<8)>>1}for(var y=(function(e,t,n){for(var r=e.length,a=0,o=new i(t);a<r;++a)e[a]&&++o[e[a]-1];var s=new i(t);for(a=1;a<t;++a)s[a]=s[a-1]+o[a-1]<<1;var c;if(n){c=new i(1<<t);var l=15-t;for(a=0;a<r;++a)if(e[a])for(var u=a<<4|e[a],d=t-e[a],f=s[e[a]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)c[g[f]>>l]=u}else for(c=new i(r),a=0;a<r;++a)e[a]&&(c[a]=g[s[e[a]-1]++]>>15-e[a]);return c}),b=new r(288),_=0;_<144;++_)b[_]=8;for(var _=144;_<256;++_)b[_]=9;for(var _=256;_<280;++_)b[_]=7;for(var _=280;_<288;++_)b[_]=8;for(var x=new r(32),_=0;_<32;++_)x[_]=5;var S=y(b,9,0),C=y(b,9,1),w=y(x,5,0),T=y(x,5,1),E=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},D=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},O=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},k=function(e){return(e+7)/8|0},A=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new r(e.subarray(t,n))};e.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var j=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],M=function(e,t,n){var r=Error(t||j[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,M),!n)throw r;return r},N=function(e,t,n,i){var a=e.length,l=i?i.length:0;if(!a||t.f&&!t.l)return n||new r(0);var u=!n,f=u||t.i!=2,p=t.i;u&&(n=new r(a*3));var h=function(e){var t=n.length;if(e>t){var i=new r(Math.max(t*2,e));i.set(n),n=i}},g=t.f||0,_=t.p||0,v=t.b||0,b=t.l,x=t.d,S=t.m,w=t.n,j=a*8;do{if(!b){g=D(e,_,1);var N=D(e,_+1,3);if(_+=3,!N){var P=k(_)+4,ee=e[P-4]|e[P-3]<<8,te=P+ee;if(te>a){p&&M(0);break}f&&h(v+ee),n.set(e.subarray(P,te),v),t.b=v+=ee,t.p=_=te*8,t.f=g;continue}if(N==1)b=C,x=T,S=9,w=5;else if(N==2){var ne=D(e,_,31)+257,re=D(e,_+10,15)+4,ie=ne+D(e,_+5,31)+1;_+=14;for(var ae=new r(ie),oe=new r(19),se=0;se<re;++se)oe[c[se]]=D(e,_+se*3,7);_+=re*3;for(var ce=E(oe),le=(1<<ce)-1,ue=y(oe,ce,1),se=0;se<ie;){var de=ue[D(e,_,le)];_+=de&15;var P=de>>4;if(P<16)ae[se++]=P;else{var fe=0,pe=0;for(P==16?(pe=3+D(e,_,3),_+=2,fe=ae[se-1]):P==17?(pe=3+D(e,_,7),_+=3):P==18&&(pe=11+D(e,_,127),_+=7);pe--;)ae[se++]=fe}}var me=ae.subarray(0,ne),he=ae.subarray(ne);S=E(me),w=E(he),b=y(me,S,1),x=y(he,w,1)}else M(1);if(_>j){p&&M(0);break}}f&&h(v+131072);for(var ge=(1<<S)-1,_e=(1<<w)-1,ve=_;;ve=_){var fe=b[O(e,_)&ge],ye=fe>>4;if(_+=fe&15,_>j){p&&M(0);break}if(fe||M(2),ye<256)n[v++]=ye;else if(ye==256){ve=_,b=null;break}else{var be=ye-254;if(ye>264){var se=ye-257,xe=o[se];be=D(e,_,(1<<xe)-1)+d[se],_+=xe}var Se=x[O(e,_)&_e],Ce=Se>>4;Se||M(3),_+=Se&15;var he=m[Ce];if(Ce>3){var xe=s[Ce];he+=O(e,_)&(1<<xe)-1,_+=xe}if(_>j){p&&M(0);break}f&&h(v+131072);var we=v+be;if(v<he){var Te=l-he,Ee=Math.min(he,we);for(Te+v<0&&M(3);v<Ee;++v)n[v]=i[Te+v]}for(;v<we;++v)n[v]=n[v-he]}}t.l=b,t.p=ve,t.b=v,t.f=g,b&&(g=1,t.m=S,t.d=x,t.n=w)}while(!g);return v!=n.length&&u?A(n,0,v):n.subarray(0,v)},P=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},ee=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},te=function(e,t){for(var n=[],a=0;a<e.length;++a)e[a]&&n.push({s:a,f:e[a]});var o=n.length,s=n.slice();if(!o)return{t:ce,l:0};if(o==1){var c=new r(n[0].s+1);return c[n[0].s]=1,{t:c,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var l=n[0],u=n[1],d=0,f=1,p=2;for(n[0]={s:-1,f:l.f+u.f,l,r:u};f!=o-1;)l=n[n[d].f<n[p].f?d++:p++],u=n[d!=f&&n[d].f<n[p].f?d++:p++],n[f++]={s:-1,f:l.f+u.f,l,r:u};for(var m=s[0].s,a=1;a<o;++a)s[a].s>m&&(m=s[a].s);var h=new i(m+1),g=ne(n[f-1],h,0);if(g>t){var a=0,_=0,v=g-t,y=1<<v;for(s.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});a<o;++a){var b=s[a].s;if(h[b]>t)_+=y-(1<<g-h[b]),h[b]=t;else break}for(_>>=v;_>0;){var x=s[a].s;h[x]<t?_-=1<<t-h[x]++-1:++a}for(;a>=0&&_;--a){var S=s[a].s;h[S]==t&&(--h[S],++_)}g=t}return{t:new r(h),l:g}},ne=function(e,t,n){return e.s==-1?Math.max(ne(e.l,t,n+1),ne(e.r,t,n+1)):t[e.s]=n},re=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new i(++t),r=0,a=e[0],o=1,s=function(e){n[r++]=e},c=1;c<=t;++c)if(e[c]==a&&c!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(a),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(a);o=1,a=e[c]}return{c:n.subarray(0,r),n:t}},ie=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},ae=function(e,t,n){var r=n.length,i=k(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},oe=function(e,t,n,r,a,l,u,d,f,p,m){P(t,m++,n),++a[256];for(var h=te(a,15),g=h.t,_=h.l,v=te(l,15),C=v.t,T=v.l,E=re(g),D=E.c,O=E.n,k=re(C),A=k.c,j=k.n,M=new i(19),N=0;N<D.length;++N)++M[D[N]&31];for(var N=0;N<A.length;++N)++M[A[N]&31];for(var ne=te(M,7),oe=ne.t,se=ne.l,ce=19;ce>4&&!oe[c[ce-1]];--ce);var le=p+5<<3,ue=ie(a,b)+ie(l,x)+u,de=ie(a,g)+ie(l,C)+u+14+3*ce+ie(M,oe)+2*M[16]+3*M[17]+7*M[18];if(f>=0&&le<=ue&&le<=de)return ae(t,m,e.subarray(f,f+p));var fe,pe,me,he;if(P(t,m,1+(de<ue)),m+=2,de<ue){fe=y(g,_,0),pe=g,me=y(C,T,0),he=C;var ge=y(oe,se,0);P(t,m,O-257),P(t,m+5,j-1),P(t,m+10,ce-4),m+=14;for(var N=0;N<ce;++N)P(t,m+3*N,oe[c[N]]);m+=3*ce;for(var _e=[D,A],ve=0;ve<2;++ve)for(var ye=_e[ve],N=0;N<ye.length;++N){var be=ye[N]&31;P(t,m,ge[be]),m+=oe[be],be>15&&(P(t,m,ye[N]>>5&127),m+=ye[N]>>12)}}else fe=S,pe=b,me=w,he=x;for(var N=0;N<d;++N){var xe=r[N];if(xe>255){var be=xe>>18&31;ee(t,m,fe[be+257]),m+=pe[be+257],be>7&&(P(t,m,xe>>23&31),m+=o[be]);var Se=xe&31;ee(t,m,me[Se]),m+=he[Se],Se>3&&(ee(t,m,xe>>5&8191),m+=s[Se])}else ee(t,m,fe[xe]),m+=pe[xe]}return ee(t,m,fe[256]),m+pe[256]},se=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ce=new r(0),le=function(e,t,n,c,l,u){var d=u.z||e.length,p=new r(c+d+5*(1+Math.ceil(d/7e3))+l),m=p.subarray(c,p.length-l),g=u.l,_=(u.r||0)&7;if(t){_&&(m[0]=u.r>>3);for(var v=se[t-1],y=v>>13,b=v&8191,x=(1<<n)-1,S=u.p||new i(32768),C=u.h||new i(x+1),w=Math.ceil(n/3),T=2*w,E=function(t){return(e[t]^e[t+1]<<w^e[t+2]<<T)&x},D=new a(25e3),O=new i(288),j=new i(32),M=0,N=0,P=u.i||0,ee=0,te=u.w||0,ne=0;P+2<d;++P){var re=E(P),ie=P&32767,ce=C[re];if(S[ie]=ce,C[re]=ie,te<=P){var le=d-P;if((M>7e3||ee>24576)&&(le>423||!g)){_=oe(e,m,0,D,O,j,N,ee,ne,P-ne,_),ee=M=N=0,ne=P;for(var ue=0;ue<286;++ue)O[ue]=0;for(var ue=0;ue<30;++ue)j[ue]=0}var de=2,fe=0,pe=b,me=ie-ce&32767;if(le>2&&re==E(P-me))for(var he=Math.min(y,le)-1,ge=Math.min(32767,P),_e=Math.min(258,le);me<=ge&&--pe&&ie!=ce;){if(e[P+de]==e[P+de-me]){for(var ve=0;ve<_e&&e[P+ve]==e[P+ve-me];++ve);if(ve>de){if(de=ve,fe=me,ve>he)break;for(var ye=Math.min(me,ve-2),be=0,ue=0;ue<ye;++ue){var xe=P-me+ue&32767,Se=xe-S[xe]&32767;Se>be&&(be=Se,ce=xe)}}}ie=ce,ce=S[ie],me+=ie-ce&32767}if(fe){D[ee++]=268435456|f[de]<<18|h[fe];var Ce=f[de]&31,we=h[fe]&31;N+=o[Ce]+s[we],++O[257+Ce],++j[we],te=P+de,++M}else D[ee++]=e[P],++O[e[P]]}}for(P=Math.max(P,te);P<d;++P)D[ee++]=e[P],++O[e[P]];_=oe(e,m,g,D,O,j,N,ee,ne,P-ne,_),g||(u.r=_&7|m[_/8|0]<<3,_-=7,u.h=C,u.p=S,u.i=P,u.w=te)}else{for(var P=u.w||0;P<d+g;P+=65535){var Te=P+65535;Te>=d&&(m[_/8|0]=g,Te=d),_=ae(m,_+1,e.subarray(P,Te))}u.i=d}return A(p,0,c+k(_)+l)},ue=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),de=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=ue[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},fe=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,a=n.length|0,o=0;o!=a;){for(var s=Math.min(o+2655,a);o<s;++o)i+=r+=n[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}e=r,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},pe=function(e,t,n,i,a){if(!a&&(a={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),s=new r(o.length+e.length);s.set(o),s.set(e,o.length),e=s,a.w=o.length}return le(e,t.level==null?6:t.level,t.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,a)},me=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},he=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype){if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString()}else t+=l}else n[c]=s}return t},ge=[],_e=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},ve=function(e,t,r,i){if(!ge[r]){for(var a=``,o={},s=e.length-1,c=0;c<s;++c)a=he(e[c],a,o);ge[r]={c:he(e[s],a,o),e:o}}var l=me({},ge[r].e);return(0,n.default)(ge[r].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,r,l,_e(l),i)},ye=function(){return[r,i,a,o,s,c,d,m,C,T,g,j,y,E,D,O,k,A,M,N,Je,Te,Ee]},be=function(){return[r,i,a,o,s,c,f,h,S,b,w,x,g,se,ce,y,P,ee,te,ne,re,ie,ae,oe,k,A,le,pe,We,Te]},xe=function(){return[Pe,Le,Ne,de,ue]},Se=function(){return[Fe,Ie]},Ce=function(){return[Re,Ne,fe]},we=function(){return[ze]},Te=function(e){return postMessage(e,[e.buffer])},Ee=function(e){return e&&{out:e.size&&new r(e.size),dictionary:e.dictionary}},De=function(e,t,n,r,i,a){var o=ve(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},Oe=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){t.data[0]?(e.push(t.data[0],t.data[1]),postMessage([t.data[0].length])):e.flush(t.data[1])}},ke=function(e,t,n,r,i,a,o){var s,c=ve(e,r,i,function(e,n){e?(c.terminate(),t.ondata.call(t,e)):Array.isArray(n)?n.length==1?(t.queuedSize-=n[0],t.ondrain&&t.ondrain(n[0])):(n[1]&&c.terminate(),t.ondata.call(t,e,n[0],n[1])):o(n)});c.postMessage(n),t.queuedSize=0,t.push=function(e,n){t.ondata||M(5),s&&t.ondata(M(4,0,1),null,!!n),t.queuedSize+=e.length,c.postMessage([e,s=n],e.buffer instanceof ArrayBuffer?[e.buffer]:[])},t.terminate=function(){c.terminate()},a&&(t.flush=function(e){c.postMessage([0,e])})},Ae=function(e,t){return e[t]|e[t+1]<<8},je=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Me=function(e,t){return je(e,t)+je(e,t+4)*4294967296},Ne=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Pe=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Ne(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},Fe=function(e){(e[0]!=31||e[1]!=139||e[2]!=8)&&M(6,`invalid gzip data`);var t=e[3],n=10;t&4&&(n+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(t&2)},Ie=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Le=function(e){return 10+(e.filename?e.filename.length+1:0)},Re=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=fe();i.p(t.dictionary),Ne(e,2,i.d())}},ze=function(e,t){return((e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&M(6,`invalid zlib data`),(e[1]>>5&1)==+!t&&M(6,`invalid zlib data: `+(e[1]&32?`need`:`unexpected`)+` dictionary`),(e[1]>>3&4)+2};function Be(e,t){return typeof e==`function`&&(t=e,e={}),this.ondata=t,e}var Ve=function(){function e(e,t){if(typeof e==`function`&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new r(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return e.prototype.p=function(e,t){this.ondata(pe(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||M(5),this.s.l&&M(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var i=new r(n&-32768);i.set(this.b.subarray(0,this.s.z)),this.b=i}var a=this.b.length-this.s.z;this.b.set(e.subarray(0,a),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(a),32768),this.s.z=e.length-a+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=t&1,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2),t&&(this.s=this.o={},this.b=ce)},e.prototype.flush=function(e){if(this.ondata||M(5),this.s.l&&M(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2,e){var t=new r(6);t[0]=this.s.r>>3;var n=ae(t,this.s.r,ce);this.s.r=0,this.ondata(t.subarray(0,n>>3),!1)}},e}();e.Deflate=Ve;var He=function(){function e(e,t){ke([be,function(){return[Oe,Ve]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new Ve(e.data))},6,1)}return e}();e.AsyncDeflate=He;function Ue(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[be],function(e){return Te(We(e.data[0],e.data[1]))},0,n)}function We(e,t){return pe(e,t||{},0,0)}var Ge=function(){function e(e,t){typeof e==`function`&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new r(32768),this.p=new r(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||M(5),this.d&&M(4),!this.p.length)this.p=e;else if(e.length){var t=new r(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=N(this.p,this.s,this.o);this.ondata(A(n,t,this.s.b),this.d),this.o=A(n,this.s.b-32768),this.s.b=this.o.length,this.p=A(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();e.Inflate=Ge;var Ke=function(){function e(e,t){ke([ye,function(){return[Oe,Ge]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new Ge(e.data))},7,0)}return e}();e.AsyncInflate=Ke;function qe(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[ye],function(e){return Te(Je(e.data[0],Ee(e.data[1])))},1,n)}function Je(e,t){return N(e,{i:2},t&&t.out,t&&t.dictionary)}var Ye=function(){function e(e,t){this.c=de(),this.l=0,this.v=1,Ve.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,Ve.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=pe(e,this.o,this.v&&Le(this.o),t&&8,this.s);this.v&&=(Pe(n,this.o),0),t&&(Ne(n,n.length-8,this.c.d()),Ne(n,n.length-4,this.l)),this.ondata(n,t)},e.prototype.flush=function(e){Ve.prototype.flush.call(this,e)},e}();e.Gzip=Ye,e.Compress=Ye;var Xe=function(){function e(e,t){ke([be,xe,function(){return[Oe,Ve,Ye]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new Ye(e.data))},8,1)}return e}();e.AsyncGzip=Xe,e.AsyncCompress=Xe;function Ze(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[be,xe,function(){return[Qe]}],function(e){return Te(Qe(e.data[0],e.data[1]))},2,n)}function Qe(e,t){t||={};var n=de(),r=e.length;n.p(e);var i=pe(e,t,Le(t),8),a=i.length;return Pe(i,t),Ne(i,a-8,n.d()),Ne(i,a-4,r),i}var $e=function(){function e(e,t){this.v=1,this.r=0,Ge.call(this,e,t)}return e.prototype.push=function(e,t){if(Ge.prototype.e.call(this,e),this.r+=e.length,this.v){var n=this.p.subarray(this.v-1),i=n.length>3?Fe(n):4;if(i>n.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-n.length);this.p=n.subarray(i),this.v=0}Ge.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=k(this.s.p)+9,this.s={i:0},this.o=new r(0),this.push(new r(0),t)):t&&Ge.prototype.c.call(this,t)},e}();e.Gunzip=$e;var et=function(){function e(e,t){var n=this;ke([ye,Se,function(){return[Oe,Ge,$e]}],this,Be.call(this,e,t),function(e){var t=new $e(e.data);t.onmember=function(e){return postMessage(e)},onmessage=Oe(t)},9,0,function(e){return n.onmember&&n.onmember(e)})}return e}();e.AsyncGunzip=et;function tt(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[ye,Se,function(){return[nt]}],function(e){return Te(nt(e.data[0],e.data[1]))},3,n)}function nt(e,t){var n=Fe(e);return n+8>e.length&&M(6,`invalid gzip data`),N(e.subarray(n,-8),{i:2},t&&t.out||new r(Ie(e)),t&&t.dictionary)}var rt=function(){function e(e,t){this.c=fe(),this.v=1,Ve.call(this,e,t)}return e.prototype.push=function(e,t){this.c.p(e),Ve.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var n=pe(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&=(Re(n,this.o),0),t&&Ne(n,n.length-4,this.c.d()),this.ondata(n,t)},e.prototype.flush=function(e){Ve.prototype.flush.call(this,e)},e}();e.Zlib=rt,e.AsyncZlib=function(){function e(e,t){ke([be,Ce,function(){return[Oe,Ve,rt]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new rt(e.data))},10,1)}return e}();function it(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[be,Ce,function(){return[at]}],function(e){return Te(at(e.data[0],e.data[1]))},4,n)}function at(e,t){t||={};var n=fe();n.p(e);var r=pe(e,t,t.dictionary?6:2,4);return Re(r,t),Ne(r,r.length-4,n.d()),r}var ot=function(){function e(e,t){Ge.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(Ge.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(ze(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&M(6,`invalid zlib data`),this.p=this.p.subarray(0,-4)),Ge.prototype.c.call(this,t)},e}();e.Unzlib=ot;var st=function(){function e(e,t){ke([ye,we,function(){return[Oe,Ge,ot]}],this,Be.call(this,e,t),function(e){onmessage=Oe(new ot(e.data))},11,0)}return e}();e.AsyncUnzlib=st;function ct(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),De(e,t,[ye,we,function(){return[lt]}],function(e){return Te(lt(e.data[0],Ee(e.data[1])))},5,n)}function lt(e,t){return N(e.subarray(ze(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var ut=function(){function e(e,t){this.o=Be.call(this,e,t)||{},this.G=$e,this.I=Ge,this.Z=ot}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,n){e.ondata(t,n)}},e.prototype.push=function(e,t){if(this.ondata||M(5),this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new r(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;this.p.length>2&&(this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(this.o):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},e}();e.Decompress=ut,e.AsyncDecompress=function(){function e(e,t){ut.call(this,e,t),this.queuedSize=0,this.G=et,this.I=Ke,this.Z=st}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,n,r){e.ondata(t,n,r)},this.s.ondrain=function(t){e.queuedSize-=t,e.ondrain&&e.ondrain(t)}},e.prototype.push=function(e,t){this.queuedSize+=e.length,ut.prototype.push.call(this,e,t)},e}();function dt(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&M(7),e[0]==31&&e[1]==139&&e[2]==8?tt(e,t,n):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?qe(e,t,n):ct(e,t,n)}function ft(e,t){return e[0]==31&&e[1]==139&&e[2]==8?nt(e,t):(e[0]&15)!=8||e[0]>>4>7||(e[0]<<8|e[1])%31?Je(e,t):lt(e,t)}var pt=function(e,t,n,i){for(var a in e){var o=e[a],s=t+a,c=i;Array.isArray(o)&&(c=me(i,o[1]),o=o[0]),ArrayBuffer.isView(o)?n[s]=[o,c]:(n[s+=`/`]=[new r(0),c],pt(o,s,n,i))}},mt=typeof TextEncoder<`u`&&new TextEncoder,ht=typeof TextDecoder<`u`&&new TextDecoder,gt=0;try{ht.decode(ce,{stream:!0}),gt=1}catch{}var _t=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:A(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};e.DecodeUTF8=function(){function e(e){this.ondata=e,gt?this.t=new TextDecoder:this.p=ce}return e.prototype.push=function(e,t){if(this.ondata||M(5),t=!!t,this.t){this.ondata(this.t.decode(e,{stream:!0}),t),t&&(this.t.decode().length&&M(8),this.t=null);return}this.p||M(4);var n=new r(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=_t(n),a=i.s,o=i.r;t?(o.length&&M(8),this.p=null):this.p=o,this.ondata(a,t)},e}(),e.EncodeUTF8=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){this.ondata||M(5),this.d&&M(4),this.ondata(vt(e),this.d=t||!1)},e}();function vt(e,t){if(t){for(var n=new r(e.length),i=0;i<e.length;++i)n[i]=e.charCodeAt(i);return n}if(mt)return mt.encode(e);for(var a=e.length,o=new r(e.length+(e.length>>1)),s=0,c=function(e){o[s++]=e},i=0;i<a;++i){if(s+5>o.length){var l=new r(s+8+(a-i<<1));l.set(o),o=l}var u=e.charCodeAt(i);u<128||t?c(u):u<2048?(c(192|u>>6),c(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|e.charCodeAt(++i)&1023,c(240|u>>18),c(128|u>>12&63),c(128|u>>6&63),c(128|u&63)):(c(224|u>>12),c(128|u>>6&63),c(128|u&63))}return A(o,0,s)}function yt(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(ht)return ht.decode(e);var i=_t(e),a=i.s,n=i.r;return n.length&&M(8),a}var bt=function(e){return e==1?3:e<6?2:+(e==9)},xt=function(e,t){return t+30+Ae(e,t+26)+Ae(e,t+28)},St=function(e,t,n){var r=Ae(e,t+28),i=Ae(e,t+30),a=yt(e.subarray(t+46,t+46+r),!(Ae(e,t+8)&2048)),o=t+46+r,s=Ct(e,o,i,n,je(e,t+20),je(e,t+24),je(e,t+42)),c=s[0],l=s[1],u=s[2];return[Ae(e,t+10),c,l,a,o+i+Ae(e,t+32),u]},Ct=function(e,t,n,r,i,a,o){var s=i==4294967295,c=a==4294967295,l=o==4294967295,u=t+n,d=s+c+l;if(r&&d){for(;t+4<u;t+=4+Ae(e,t+2))if(Ae(e,t)==1)return[s?Me(e,t+4+8*c):i,c?Me(e,t+4):a,l?Me(e,t+4+8*(c+s)):o,1];r<2&&M(13)}return[i,a,o,0]},wt=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&M(9),t+=r+4}return t},Tt=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=wt(l);Ne(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&M(10),Ne(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(Ne(e,t,n.crc),Ne(e,t+4,a<0?-a-2:a),Ne(e,t+8,n.size)),Ne(e,t+12,c),Ne(e,t+14,d),t+=16,o!=null&&(Ne(e,t,u),Ne(e,t+6,n.attrs),Ne(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;Ne(e,t,+m),Ne(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},Et=function(e,t,n,r,i){Ne(e,t,101010256),Ne(e,t+8,n),Ne(e,t+10,n),Ne(e,t+12,r),Ne(e,t+16,i)},Dt=function(){function e(e){this.filename=e,this.c=de(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){this.ondata||M(5),this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();e.ZipPassThrough=Dt,e.ZipDeflate=function(){function e(e,t){var n=this;t||={},Dt.call(this,e),this.d=new Ve(t,function(e,t){n.ondata(null,e,t)}),this.compression=8,this.flag=bt(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){Dt.prototype.push.call(this,e,t)},e}(),e.AsyncZipDeflate=function(){function e(e,t){var n=this;t||={},Dt.call(this,e),this.d=new He(t,function(e,t,r){n.ondata(e,t,r)}),this.compression=8,this.flag=bt(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){Dt.prototype.push.call(this,e,t)},e}(),e.Zip=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(this.ondata||M(5),this.d&2)this.ondata(M(4+(this.d&1)*8,0,1),null,!1);else{var n=vt(e.filename),i=n.length,a=e.comment,o=a&&vt(a),s=i!=e.filename.length||o&&a.length!=o.length,c=i+wt(e.extra)+30;i>65535&&this.ondata(M(11,0,1),null,!1);var l=new r(c);Tt(l,0,e,n,s,-1);var u=[l],d=function(){for(var e=0,n=u;e<n.length;e++){var r=n[e];t.ondata(null,r,!1)}u=[]},f=this.d;this.d=0;var p=this.u.length,m=me(e,{f:n,u:s,o,t:function(){e.terminate&&e.terminate()},r:function(){if(d(),f){var e=t.u[p+1];e?e.r():t.d=1}f=1}}),h=0;e.ondata=function(n,i,a){if(n)t.ondata(n,i,a),t.terminate();else if(h+=i.length,u.push(i),a){var o=new r(16);Ne(o,0,134695760),Ne(o,4,e.crc),Ne(o,8,h),Ne(o,12,e.size),u.push(o),m.c=h,m.b=c+h+16,m.crc=e.crc,m.size=e.size,f&&m.r(),f=1}else f&&d()},this.u.push(m)}},e.prototype.end=function(){var e=this;if(this.d&2){this.ondata(M(4+(this.d&1)*8,0,1),null,!0);return}this.d?this.e():this.u.push({r:function(){e.d&1&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,i=0,a=this.u;i<a.length;i++){var o=a[i];n+=46+o.f.length+wt(o.extra)+(o.o?o.o.length:0)}for(var s=new r(n+22),c=0,l=this.u;c<l.length;c++){var o=l[c];Tt(s,e,o,o.f,o.u,-o.c-2,t,o.o),e+=46+o.f.length+wt(o.extra)+(o.o?o.o.length:0),t+=o.b}Et(s,e,this.u.length,n,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2},e}();function Ot(e,t,n){n||(n=t,t={}),typeof n!=`function`&&M(7);var i={};pt(e,``,i,t);var a=Object.keys(i),o=a.length,s=0,c=0,l=o,u=Array(o),d=[],f=function(){for(var e=0;e<d.length;++e)d[e]()},p=function(e,t){jt(function(){n(e,t)})};jt(function(){p=n});var m=function(){var e=new r(c+22),t=s,n=c-s;c=0;for(var i=0;i<l;++i){var a=u[i];try{var o=a.c.length;Tt(e,c,a,a.f,a.u,o);var d=30+a.f.length+wt(a.extra),f=c+d;e.set(a.c,f),Tt(e,s,a,a.f,a.u,o,c,a.m),s+=16+d+(a.m?a.m.length:0),c=f+o}catch(e){return p(e,null)}}Et(e,s,u.length,n,t),p(null,e)};o||m();for(var h=function(e){var t=a[e],n=i[t],r=n[0],l=n[1],h=de(),g=r.length;h.p(r);var _=vt(t),v=_.length,y=l.comment,b=y&&vt(y),x=b&&b.length,S=wt(l.extra),C=l.level==0?0:8,w=function(n,r){if(n)f(),p(n,null);else{var i=r.length;u[e]=me(l,{size:g,crc:h.d(),c:r,f:_,m:b,u:v!=t.length||b&&y.length!=x,compression:C}),s+=30+v+S+i,c+=76+2*(v+S)+(x||0)+i,--o||m()}};if(v>65535&&w(M(11,0,1),null),!C)w(null,r);else if(g<16e4)try{w(null,We(r,l))}catch(e){w(e,null)}else d.push(Ue(r,l,w))},g=0;g<l;++g)h(g);return f}function kt(e,t){t||={};var n={},i=[];pt(e,``,n,t);var a=0,o=0;for(var s in n){var c=n[s],l=c[0],u=c[1],d=u.level==0?0:8,f=vt(s),p=f.length,m=u.comment,h=m&&vt(m),g=h&&h.length,_=wt(u.extra);p>65535&&M(11);var v=d?We(l,u):l,y=v.length,b=de();b.p(l),i.push(me(u,{size:l.length,crc:b.d(),c:v,f,m:h,u:p!=s.length||h&&m.length!=g,o:a,compression:d})),a+=30+p+_+y,o+=76+2*(p+_)+(g||0)+y}for(var x=new r(o+22),S=a,C=o-a,w=0;w<i.length;++w){var f=i[w];Tt(x,f.o,f,f.f,f.u,f.c.length);var T=30+f.f.length+wt(f.extra);x.set(f.c,f.o+T),Tt(x,a,f,f.f,f.u,f.c.length,f.o,f.m),a+=16+T+(f.m?f.m.length:0)}return Et(x,a,i.length,C,S),x}var At=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}();e.UnzipPassThrough=At,e.UnzipInflate=function(){function e(){var e=this;this.i=new Ge(function(t,n){e.ondata(null,t,n)})}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(e){this.ondata(e,null,t)}},e.compression=8,e}(),e.AsyncUnzipInflate=function(){function e(e,t){var n=this;t<32e4?this.i=new Ge(function(e,t){n.ondata(null,e,t)}):(this.i=new Ke(function(e,t,r){n.ondata(e,t,r)}),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=A(e,0)),this.i.push(e,t)},e.compression=8,e}(),e.Unzip=function(){function e(e){this.onfile=e,this.k=[],this.o={0:At},this.p=ce}return e.prototype.push=function(e,t){var n=this;if(this.onfile||M(5),this.p||M(4),this.c>0){var i=Math.min(this.c,e.length),a=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(a,!this.c):this.k[0].push(a),e=e.subarray(i),e.length)return this.push(e,t)}else{var o=0,s=0,c=void 0,l=void 0;this.p.length?e.length?(l=new r(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var u=l.length,d=this.c,f=d&&this.d,p=function(){var e=je(l,s);if(e==67324752){o=1,c=s,m.d=null,m.c=0;var t=Ae(l,s+6),r=Ae(l,s+8),i=t&2048,a=t&8,f=Ae(l,s+26),p=Ae(l,s+28);if(u>s+30+f+p){var h=[];m.k.unshift(h),o=2;var g=je(l,s+18),_=je(l,s+22),v=yt(l.subarray(s+30,s+=30+f),!i),y=Ct(l,s,p,2,g,_,0),b=y[0],x=y[1],S=y[3];a&&(b=-1-S),s+=p,m.c=b;var C,w={name:v,compression:r,start:function(){if(w.ondata||M(5),!b)w.ondata(null,ce,!0);else{var e=n.o[r];e||w.ondata(M(14,`unknown compression type `+r,1),null,!1),C=b<0?new e(v):new e(v,b,x),C.ondata=function(e,t,n){w.ondata(e,t,n)};for(var t=0,i=h;t<i.length;t++){var a=i[t];C.push(a,!1)}n.k[0]==h&&n.c?n.d=C:C.push(ce,!0)}},terminate:function(){C&&C.terminate&&C.terminate()}};b>=0&&(w.size=b,w.originalSize=x),m.onfile(w)}return`break`}if(d){if(e==134695760)return c=s+=12+(d==-2&&8),o=3,m.c=0,`break`;if(e==33639248)return c=s-=4,o=3,m.c=0,`break`}},m=this;s<u-4&&p()!==`break`;++s);if(this.p=ce,d<0){var h=o?l.subarray(0,c-12-(d==-2&&8)-(je(l,c-16)==134695760&&4)):l.subarray(0,s);f?f.push(h,!!o):this.k[+(o==2)].push(h)}if(o&2)return this.push(l.subarray(s),t);this.p=l.subarray(s)}t&&(this.c&&M(13),this.p=null)},e.prototype.register=function(e){this.o[e.compression]=e},e}();var jt=typeof queueMicrotask==`function`?queueMicrotask:typeof setTimeout==`function`?setTimeout:function(e){e()};function Mt(e,t,n){n||(n=t,t={}),typeof n!=`function`&&M(7);var i=[],a=function(){for(var e=0;e<i.length;++e)i[e]()},o={},s=function(e,t){jt(function(){n(e,t)})};jt(function(){s=n});for(var c=e.length-22;je(e,c)!=101010256;--c)if(!c||e.length-c>65558)return s(M(13,0,1),null),a;var l=Ae(e,c+8);if(l){var u=l,d=je(e,c+16),f=je(e,c-20)==117853008;if(f){var p=je(e,c-12);f=je(e,p)==101075792,f&&(u=l=je(e,p+32),d=je(e,p+48))}for(var m=t&&t.filter,h=function(t){var n=St(e,d,f),c=n[0],u=n[1],p=n[2],h=n[3],g=n[4],_=n[5],v=xt(e,_);d=g;var y=function(e,t){e?(a(),s(e,null)):(t&&(o[h]=t),--l||s(null,o))};if(!m||m({name:h,size:u,originalSize:p,compression:c})){if(!c)y(null,A(e,v,v+u));else if(c==8){var b=e.subarray(v,v+u);if(p<524288||u>.8*p)try{y(null,Je(b,{out:new r(p)}))}catch(e){y(e,null)}else i.push(qe(b,{size:p},y))}else y(M(14,`unknown compression type `+c,1),null)}else y(null,null)},g=0;g<u;++g)h(g)}else s(null,{});return a}function Nt(e,t){for(var n={},i=e.length-22;je(e,i)!=101010256;--i)(!i||e.length-i>65558)&&M(13);var a=Ae(e,i+8);if(!a)return{};var o=je(e,i+16),s=je(e,i-20)==117853008;if(s){var c=je(e,i-12);s=je(e,c)==101075792,s&&(a=je(e,c+32),o=je(e,c+48))}for(var l=t&&t.filter,u=0;u<a;++u){var d=St(e,o,s),f=d[0],p=d[1],m=d[2],h=d[3],g=d[4],_=d[5],v=xt(e,_);o=g,(!l||l({name:h,size:p,originalSize:m,compression:f}))&&(f?f==8?n[h]=Je(e.subarray(v,v+p),{out:new r(m)}):M(14,`unknown compression type `+f):n[h]=A(e,v,v+p))}return n}})),n9=_(m(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t<`u`?t.exports=r((EY(),v(Ple)),(Due(),v(due)),(kue(),v(Oue)),jue(),(Lue(),v(Mue)),(Yue(),v(Vue)),Xue()):typeof define==`function`&&define.amd?define([`three/webgpu`,`three-spritetext`,`three/tsl`,`css-element-queries`,`three/examples/jsm/exporters/GLTFExporter`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],r):(n=typeof globalThis<`u`?globalThis:n||self,n.Zinc=r(n.THREE,n.SpriteText,n.THREE,n.cssElememtQueries,n.GLTFExporter,n.GLTFLoader,n.fflate))})(e,function(e,t,n,r,i,a,o){var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule||!f.call(e,`default`)?c(n,`default`,{value:e,enumerable:!0}):n,e));e=m(e,1),t=m(t,1);var h={name:`zincjs`,version:`3.0.1`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,engines:{node:`^24.20.0`},directories:{doc:`docs`},files:[`package.json`,`LICENSE`,`README.md`,`src/*`,`build/zinc.js`,`build/zinc.js.map`,`vite.config.js`],scripts:{"build-bundle":`vite build`,format:`prettier --write .`,"format:check":`prettier --check .`,"test-watch":`vitest`,test:`vitest run --reporter=junit --outputFile=test-results.xml`,"test-standard":`vitest run`,changelog:`auto-changelog -p --output CHANGELOG.md --template keepachangelog`,jsdoc:`jsdoc -c jsdoc_conf.json`,version:`npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs`,"release:beta":`npm version prerelease --preid=beta; npm publish --tag beta`,"release:major":`npm version major; npm publish`,"release:minor":`npm version minor; npm publish`,"release:patch":`npm version patch; npm publish`},repository:{type:`git`,url:`git+https://github.com/alan-wu/ZincJS.git`},keywords:[`library`,`webgl`,`3d`,`zincjs`],author:`Alan Wu <alan.wu@auckland.ac.nz>`,license:`MIT`,bugs:{url:`https://github.com/alan-wu/ZincJS/issues`},homepage:`http://alan-wu.github.io/ZincJS/`,allowScripts:{"msw@2.14.6":!0,"webgpu@0.4.0":!0},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,"happy-dom":`^20.10.6`,jsdoc:`^4.0.2`,msw:`^2.14.6`,prettier:`3.9.6`,vite:`^8.2.1`,"vite-plugin-node-polyfills":`^0.28.0`,vitest:`^4.1.11`,webgpu:`^0.4.0`},dependencies:{"css-element-queries":`^1.2.2`,lodash:`^4.17.19`,"nifti-reader-js":`0.8.0`,three:`^0.185.1`,"three-spritetext":`1.10.0`}},g=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,_=new Set,v=e=>{_.add(e)},y=e=>{_.delete(e)},b=()=>{_.forEach(e=>e())},x=t.default.default||t.default,S=1.5,C=16,w=256,T=.1,E=1e3/(2*Math.tan(20*Math.PI/180)),D=new Set,O=!1,k=e=>{let t=Math.round(e*E*S);return Math.min(Math.max(t,C),w)},A=t=>{let n=t.material?.map;n&&(n.generateMipmaps=!1,n.minFilter=e.LinearFilter,n.magFilter=e.LinearFilter,n.anisotropy=1)},j=(e,t,n,r)=>{`_fontFace`in e&&typeof e._genCanvas==`function`?(e._fontFace=t,e._fontSize=n,e._fontWeight=r,e._genCanvas()):(e.fontFace=t,e.fontSize=n,e.fontWeight=r)},M=(e,t=!1)=>{let n=k(e.textHeight);(t||n!==e.fontSize)&&(j(e,e.fontFace,n,e.fontWeight),A(e))},N=e=>{D.forEach(t=>{let n=t.deref();n?e(n):D.delete(t)})},P=()=>{N(e=>M(e,!0)),b()},ee=e=>{if(typeof document>`u`||!document.fonts)return;!O&&document.fonts.addEventListener&&(document.fonts.addEventListener(`loadingdone`,P),O=!0);let t=`${e.fontWeight} ${e.fontSize}px ${e.fontFace}`;try{document.fonts.check(t)||document.fonts.load(t).then(()=>{M(e,!0),b()}).catch(()=>{})}catch{}},te=e=>{D.add(new WeakRef(e))},ne=e=>{D.forEach(t=>{let n=t.deref();(!n||n===e)&&D.delete(t)})},re=(t,n,r,i,a)=>{let o=r?new x(t,n,r):new x(t,n);j(o,i,k(n),a);let s=o.material;return o.material=new e.SpriteNodeMaterial({map:s.map}),s.map=null,s.dispose(),o.material.sizeAttenuation=!1,A(o),te(o),ee(o),o},ie=(e,t)=>{`_textHeight`in e?(e._textHeight=t,M(e,!0)):(e.textHeight=t,M(e))},ae=e=>{!(e>0)||!isFinite(e)||Math.abs(e/E-1)>T&&(E=e,N(e=>M(e)),b())};function oe(e,t){let n=(e,t)=>{try{let n=new URL(e,t).href;if(e&&e.split(`?`).length<2){let e=t.split(`?`);e.length===2&&(n=n+`?`+e[1])}return n}catch{console.error(`There is an issue creating the url link with: ${e}.`)}};if(Array.isArray(e)){let r=[];return e.forEach(e=>{r.push(n(e,t))}),r}return n(e,t)}function se(e){return e.parent&&se(e.parent),e.matrixAutoUpdate&&e.updateMatrix(),e.matrixWorldAutoUpdate!==!1&&(e.parent?e.matrixWorld.multiplyMatrices(e.parent.matrixWorld,e.matrix):e.matrixWorld.copy(e.matrix)),e.matrixWorld}function ce(e,t,n,r,i){let a=e.morphTargetInfluences,o;e.geometry&&(o=e.geometry.morphAttributes);let s=!1;if(a&&o&&o.position){r.set(0,0,0),i.set(0,0,0);for(let e=0;e<a.length;e++)a[e]>0&&(s=!0,n.setFromArray(o.position[e].array),r.add(n.min.multiplyScalar(a[e])),i.add(n.max.multiplyScalar(a[e])));s&&t.set(r,i)}s||t.setFromBufferAttribute(e.geometry.attributes.position),t.applyMatrix4(se(e))}function le(e,t,n,r){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{n(e,t)}).catch(t=>{console.error(`Fetch string payload retrieval failed for: ${requestURL}`,t),r(e)})}function ue(e,t,n){let r=e.length,i=0,a=[];function o(e,n){a[n]=e,i++,i==r&&t(a)}for(let t=0;t<r;t++)le(e[t],t,o,n)}var de=(t,n)=>{let r=Math.floor(n/3),i=n%3,a=0;i==0?a=t[r].r:i==1?a=t[r].g:i==2&&(a=t[r].b);let o=new e.Color(a);return[o.r,o.g,o.b]},fe=new WeakMap,pe=function(t,n){if(n&&t&&t.morphAttributes&&t.morphAttributes.color){let r=t.morphAttributes.color,i=n.morphTargetInfluences,a=i.length,o=0,s=0,c=0,l=0,u=0;for(let e=0;e<a&&o<2;e++)i[e]>0&&(o===0?(s=c=e,l=i[e]):(c=e,u=i[e]),o++);let d=0;if(o>=2){let e=l+u;d=e>0?u/e:0}let f=t.getAttribute(`morphColor0`),p=t.getAttribute(`morphColor1`);(!f||!p)&&(f=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),p=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),f.setUsage(e.DynamicDrawUsage),p.setUsage(e.DynamicDrawUsage),t.setAttribute(`morphColor0`,f),t.setAttribute(`morphColor1`,p));let m=r[s],h=r[c];fe.get(f)!==m&&(f.array.set(m.array),f.needsUpdate=!0,fe.set(f,m)),fe.get(p)!==h&&(p.array.set(h.array),p.needsUpdate=!0,fe.set(p,h));let g=n.material&&n.material.userData&&n.material.userData.uniforms&&n.material.userData.uniforms.morphColorMix;g&&(g.value=d)}},me=e=>{let t=e.clone();return t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),e._video&&(t._video=e._video),t};function he(t){let n,r,i,a=-1,o=0;for(let e=0;e<t.length;++e){let s=t[e];if(n===void 0&&(n=s.array.constructor),n!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(r===void 0&&(r=s.itemSize),r!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*r}let s=new n(o),c=new e.BufferAttribute(s,r,i),l=0;for(let e=0;e<t.length;++e){let n=t[e];if(n.isInterleavedBufferAttribute){let e=l/r;for(let t=0,i=n.count;t<i;t++)for(let i=0;i<r;i++){let r=n.getComponent(t,i);c.setComponent(t+e,i,r)}}else s.set(n.array,l);l+=n.count*r}return a!==void 0&&(c.gpuType=a),c}var ge=(t,n=!1)=>{let r=t[0].index!==null,i=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),o={},s={},c=t[0].morphTargetsRelative,l=new e.BufferGeometry,u=0;for(let e=0;e<t.length;++e){let d=t[e],f=0;if(r!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let t in d.attributes){if(!i.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure "`+t+`" attribute exists among all geometries, or in none of them.`),null;o[t]===void 0&&(o[t]=[]),o[t].push(d.attributes[t]),f++}if(f!==i.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. Make sure all geometries have the same number of attributes.`),null;if(c!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let t in d.morphAttributes){if(!a.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphAttributes must be consistent throughout all geometries.`),null;s[t]===void 0&&(s[t]=[]),s[t].push(d.morphAttributes[t])}if(n){let t;if(r)t=d.index.count;else if(d.attributes.position!==void 0)t=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. The geometry must have either an index or a position attribute`),null;l.addGroup(u,t,e),u+=t}}if(r){let e=0,n=[];for(let r=0;r<t.length;++r){let i=t[r].index;for(let t=0;t<i.count;++t)n.push(i.getX(t)+e);e+=t[r].attributes.position.count}l.setIndex(n)}for(let e in o){let t=he(o[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;l.setAttribute(e,t)}for(let e in s){let t=s[e][0].length;if(t===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<s[e].length;++r)t.push(s[e][r][n]);let r=he(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;l.morphAttributes[e].push(r)}}return l};function _e(t,n){if(n&&t>=n.length){let r=new e.BufferGeometry,i=new Float32Array(t*3),a=0;return n.forEach(e=>{i[a++]=e[0],i[a++]=e[1],i[a++]=e[2]}),r.setAttribute(`position`,new e.BufferAttribute(i,3)),r.setDrawRange(0,n.length),r}}var ve=class extends Uint16Array{};function ye(e){let t=e?.index;if(t&&t.array.constructor===Uint16Array){let e=t.array;t.array=new ve(e.buffer,e.byteOffset,e.length)}}function be(e){let t=[];return e.traverse(e=>{let n=e.geometry?.index;if(n&&n.array instanceof ve){let e=n.array;n.array=new Uint16Array(e.buffer,e.byteOffset,e.length),t.push([n,e,n.array])}}),()=>{t.forEach(([e,t,n])=>{e.array===n&&(e.array=t)})}}var xe=void 0;function Se(){if(xe)return xe;let t=new Image,n=new e.Texture;return n.image=t,t.onload=()=>{n.needsUpdate=!0,b()},t.src=g,t.complete&&t.naturalWidth>0&&(n.needsUpdate=!0),xe=n,n}function Ce(e,t,n,r,i,a){let o=re(e,t,n,r,a);return o.material.alphaTest=.05,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=10001,o}function we(e,t,n){if(n){let r=e||``,i=t||``,a=n.lastIndexOf(`/`);if(a>-1){let e,t;if(e=n.substring(0,a),t=n.substring(a+1),(e===`*`||e===`**`||e.toLowerCase()===r.toLowerCase())&&(t===`*`||t===`**`||t.toLowerCase()===i.toLowerCase()))return!0}else if(r.toLowerCase()===n.toLowerCase()||i.toLowerCase()===n.toLowerCase())return!0}return!1}function Te(t,n,r){let i=t.getAttribute(`position`),a=t.getAttribute(`normal`);if(!i)return;let o=i.itemSize,s=n*o,c=o,l=!1,u=(n,i)=>{let a=n.array;if(a.length<s+c)return!1;if(r)a.copyWithin(s,s+c),a.fill(0,a.length-c),n.needsUpdate=!0;else{let n=new a.constructor(a.length-c);n.set(a.subarray(0,s)),n.set(a.subarray(s+c),s),t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return!0};return l=u(i,`position`),a&&u(a,`normal`),t.index!==null&&console.warn(`Removing vertices from indexed geometry requires index buffer recalculation.`),l}function Ee(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y,n[r++]=i.z}return e.needsUpdate=!0,e}var De={MeshBasicMaterial:e.MeshBasicNodeMaterial,MeshLambertMaterial:e.MeshLambertNodeMaterial,MeshPhongMaterial:e.MeshPhongNodeMaterial,MeshStandardMaterial:e.MeshStandardNodeMaterial,LineBasicMaterial:e.LineBasicNodeMaterial},Oe=t=>{let r=t;r.isNodeMaterial||(r=new(De[t.type]||e.MeshBasicNodeMaterial),r.copy(t));let i=(0,n.uniform)(0);return r.colorNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`morphColor0`,`vec3`),t=(0,n.attribute)(`morphColor1`,`vec3`),r=(0,n.mix)(e,t,i);return(0,n.vec4)(r.mul(n.materialColor),n.materialOpacity)})(),r.userData.uniforms={...r.userData.uniforms,morphColorMix:i},r},ke=new e.Vector3,Ae=new e.Vector3,je=new e.Matrix4,Me=new e.Ray,Ne=new e.Sphere,Pe=new e.Vector3,Fe=new e.Vector3,Ie=new e.Vector3,Le=new e.Vector3,Re=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.LineBasicMaterial){super(),this.type=`Line`,this.geometry=t,this.material=n,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[0];for(let e=1,t=n.count;e<t;e++)ke.fromBufferAttribute(n,e-1),Ae.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=ke.distanceTo(Ae);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}raycast(t,n){let r=this.geometry,i=this.matrixWorld,a=t.params.Line.threshold,o=r.drawRange,s=r.morphAttributes.position;if(r.boundingSphere===null&&r.computeBoundingSphere(),Ne.copy(r.boundingSphere),Ne.applyMatrix4(i),Ne.radius+=a,t.ray.intersectsSphere(Ne)===!1)return;je.copy(i).invert(),Me.copy(t.ray).applyMatrix4(je);let c=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=c*c,u=new e.Vector3,d=new e.Vector3,f=new e.Vector3,p=new e.Vector3,m=this.isLineSegments?2:1;if(r.isBufferGeometry){let e=r.index,i=r.attributes.position;if(e!==null){let r=Math.max(0,o.start),a=Math.min(e.count,o.start+o.count);for(let o=r,c=a-1;o<c;o+=m){let r=e.getX(o),a=e.getX(o+1);if(ze(u,d,this,i,s,r,a),Me.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let c=t.ray.origin.distanceTo(p);c<t.near||c>t.far||n.push({distance:c,point:f.clone().applyMatrix4(this.matrixWorld),index:o,face:null,faceIndex:null,object:this})}}else{let e=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count);for(let a=e,o=r-1;a<o;a+=m){if(ze(u,d,this,i,s,a,a+1),Me.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let e=t.ray.origin.distanceTo(p);e<t.near||e>t.far||n.push({distance:e,point:f.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error(`THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};function ze(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(i&&s){Pe.set(0,0,0),Fe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(Ie.fromBufferAttribute(d,a),Le.fromBufferAttribute(d,o),Pe.addScaledVector(Ie.sub(e),u),Fe.addScaledVector(Le.sub(t),u))}e.add(Pe),t.add(Fe)}}Re.prototype.isLine=!0;var Be=new e.Vector3,Ve=new e.Vector3,He=class extends Re{constructor(e,t){super(e,t),this.type=`LineSegments`}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[];for(let e=0,t=n.count;e<t;e+=2)Be.fromBufferAttribute(n,e),Ve.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+Be.distanceTo(Ve);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}};He.prototype.isLineSegments=!0;var Ue=function(t){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=t,this._disposed=!1,this.addLevel=(e,t)=>{if(e){ye(e.geometry);let n=Math.abs(t),r;for(r=0;r<this.levels.length&&!(n<this.levels[r].distance);r++);let i={distance:n,morph:e,loaded:!0,loading:!1,url:``};this.levels.splice(r,0,i),e.renderOrder=this._renderOrder}},this.levelLoaded=(e,t)=>{if(e){ye(e.geometry);let n=Math.abs(t);for(let t=0;t<this.levels.length;t++)if(n===this.levels[t].distance){this._parent.group.add(e),this.levels[t].morph=e,this.levels[t].loaded=!0,this.levels[t].loading=!1;break}this.checkTransparentMesh(),this._parent?.requestRender?.()}},this.addLevelFromURL=(e,t,n,r,i)=>{this._loader=e;let a=this.calculateDistance(t),o={distance:a,morph:void 0,loaded:!1,loading:!1,url:n,index:r},s;for(s=0;s<this.levels.length&&!(a<this.levels[s].distance);s++);this.levels.splice(s,0,o),i&&this.loadLevel(s)},this.loadLevel=e=>{let t=this.levels[e];return!t.morph&&!t.loaded&&!t.loading&&(t.loading=!0,this._loader.load(t.url,this.lodLoader(t.distance),void 0,void 0,{index:t.index})),t.morph===void 0},this.calculateDistance=function(e){this._parent.getBoundingBox();let t=this._parent.radius,n=0;return e===`far`?n=t*4.5:e===`medium`?n=t*2.5:e===`close`&&(n=0),n},this.containsLevels=()=>!!(this.levels&&this.levels.length>1),this.checkTransparentMesh=()=>{let t=this.levels[this._currentLevel];this._material&&(this._material.transparent?(this._secondaryMaterial||(this._secondaryMaterial=this._material.clone(),this._secondaryMaterial.side=e.FrontSide),this._secondaryMaterial.opacity=this._material.opacity,this._secondaryMaterial.emissive&&this._secondaryMaterial.emissive.copy(this._material.emissive),this._secondaryMaterial.needsUpdate=!0,t.secondaryMesh||(t.secondaryMesh=new e.Mesh(t.morph.geometry,this._secondaryMaterial),t.secondaryMesh.renderOrder=t.morph.renderOrder+1,t.secondaryMesh.userData=t.morph.userData,t.secondaryMesh.name=t.morph.name),this._material.side=e.BackSide,this._material.needsUpdate=!0,t.secondaryMesh.parent||(t.morph.add(t.secondaryMesh),this._parent.animationGroup&&this._parent.animationGroup.add(t.secondaryMesh))):(t.secondaryMesh&&(t.morph.remove(t.secondaryMesh),this._parent.animationGroup&&(this._parent.animationGroup.uncache(t.secondaryMesh),this._parent.animationGroup.remove(t.secondaryMesh))),this._material.side=e.DoubleSide,this._material.needsUpdate=!0))},this.dispose=()=>{this._disposed=!0,this.levels.forEach(e=>{e.morph&&e.morph.geometry&&e.morph.geometry.dispose()}),this._material&&this._material.dispose(),this._secondaryMaterial&&this._secondaryMaterial.dispose()},this.getCurrentLevel=()=>this._currentLevel,this.getCurrentMorph=()=>{let e=this.levels[this._currentLevel];return e&&e.morph?e.morph:this._parent.morph},this.lodLoader=function(t){return n=>{if(this._disposed){n.dispose();return}let r=this._material,i=me(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour,isLines:this._parent.isLines}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new He(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=e=>{if(this._material&&this._material.userData&&this._material.userData.uniforms&&this._material.userData.uniforms.morphColorMix){if(e){let e=this.getCurrentMorph();pe(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&pe(e.morph.geometry,e.morph)})}},this.setColour=e=>{this._material.color=e,this._secondaryMaterial&&(this._secondaryMaterial.color=e),n()},this.setFrustumCulled=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.frustumCulled=e),t.secondaryMesh&&(t.secondaryMesh.frustumCulled=e)})},this.setMaterial=t=>{t&&(!this._material||this._material.id!==t.id)&&(this._material=t,this._secondaryMaterial&&=(this._secondaryMaterial.dispose(),void 0),(t.transparent||this.levels.some(e=>e.secondaryMesh))&&(this._secondaryMaterial=t.clone(),this._secondaryMaterial.side=e.FrontSide,this._secondaryMaterial.transparent=!0),this.levels.forEach(e=>{e.morph&&(e.morph.material=this._material,e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)),e.secondaryMesh&&(e.secondaryMesh.material=this._secondaryMaterial)}))},this.setName=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.name=e),t.secondaryMesh&&(t.secondaryMesh.name=e)})},this.setRenderOrder=e=>{this._renderOrder=e,this.levels.forEach(t=>{t.morph&&(t.morph.renderOrder=e),t.secondaryMesh&&(t.secondaryMesh.renderOrder=e)})},this.setVertexColors=e=>{this._material.vertexColors=e,n(),this._secondaryMaterial&&(this._secondaryMaterial.vertexColors=e)},this.update=(e,t)=>{let n=this.levels;if(n.length>1){let r=e.cameraObject.position.distanceTo(t),i=-1,a=-1,o,s;for(o=0,s=n.length;o<s&&r>=n[o].distance;o++)n[o].morph?(i>-1&&n[i].morph&&(n[i].morph.visible=!1),i=o,n[o].morph.visible=!0,a=-1):a=o;for(a>-1&&this.loadLevel(a);o<s;o++)n[o].morph&&(i>-1?n[o].morph.visible=!1:(n[o].morph.visible=!0,i=o));this._currentLevel!=i&&(this._currentLevel=i,this.checkTransparentMesh(),this._parent?.requestRender?.())}},this.toggleMarker=(e,t)=>{this.levels.forEach(n=>{n.morph&&(t?n.morph.add(e):n.morph.remove(e))})};let n=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)})}},We=new e.TextureLoader().load(`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(0,89,116);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,b);We.colorSpace=e.SRGBColorSpace;var Ge=[.02,.03,1],Ke=new e.SpriteMaterial({map:We,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),qe=function(t){Object.getPrototypeOf(this)!==Xe.prototype&&Object.setPrototypeOf(qe.prototype,Xe.prototype),Xe.call(this),this.texture=We;let n,r,i,a,o,s=!0;this.morph=new e.Group,this.group=this.morph,this.parent=t,this.isMarker=!0;let c=!1;this.ndc=new e.Vector3;let l,u,d=()=>{n=new e.Sprite(Ke),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(Ge[0],Ge[1],Ge[2]),n.userData=this};this.updateVisual=(e,t)=>{let n=1,r=0;e!==t&&(r=1-(this.ndc.z-e)/(t-e),n=.6+r*.4),this.setSpriteSize(n)},this.updateNDC=e=>(this.ndc.copy(this.morph.position),this.ndc.project(e),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(e,t,n)=>{this.morph.position.set(e,t,n)},this.setSpriteSize=e=>{n.scale.set(.015,.02,1),n.scale.multiplyScalar(e)},this.setUserSprite=()=>{a&&(this.morph.add(a),s&&=(this.morph.remove(n),u&&this.morph.remove(u),!1))},this.setImageForUserSprite=(t,n)=>{a&&=(this.morph.remove(a),void 0),r&&r.dispose(),i&&i.dispose(),r=new e.Texture,r.image=t,r.needsUpdate=!0,i=new e.SpriteMaterial({map:r,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),n||=[.05,.05,1],a=new e.Sprite(i),a.center.set(.5,0),a.scale.set(n[0],n[1],n[2]),a.userData=this,this.setUserSprite()},this.setDefaultSprite=()=>{s||(s=!0,this.morph.add(n),a&&this.morph.remove(a),u&&this.morph.add(u))},this.loadUserSprite=(e,t)=>{if(e){if(e!==o){o=e;let n=new Image(128,128);n.crossOrigin=`anonymous`,n.onload=()=>{this.setImageForUserSprite(n,t),this.parent?.requestRender?.()},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(ne(u),u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),ne(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=Ce(e,.012,`black`,`Asap`,120,700),u.renderOrder=10001,this.morph.add(u)),l=e},this.getNumber=()=>l||1,this.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.parent.region&&(this.parent.region.pickableUpdateRequired=!0))},this.enable=()=>{c=!0,this.morph.visible=!0,this.visible=!0},this.disable=()=>{c=!1,this.morph.visible=!1,this.visible=!1},d()},Je=0,Ye=function(){return`pr`+Je++},Xe=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new Ue(this),this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData={},this.marker=void 0,this.markerNumber=void 0,this.markerUpdateRequired=!0,this.closestVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new e.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode=`inherited`,this.uuid=Ye(),this._v1=new e.Vector3,this._v2=new e.Vector3,this._b1=new e.Box3,this.center=new e.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};Xe.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},Xe.prototype.getDuration=function(){return this.duration},Xe.prototype.setRegion=function(e){this.region=e},Xe.prototype.getRegion=function(){return this.region},Xe.prototype.requestRender=function(){this.region?.getScene?.()?.invalidate?.()},Xe.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},Xe.prototype.getGroup=function(){return this.group},Xe.prototype.setMorph=function(e){this.morph=e,this.group.add(this.morph);let t=this._lod.calculateDistance(`far`);this._lod.addLevel(e,t),this._lod.setMaterial(e.material)},Xe.prototype.checkTransparentMesh=function(){},Xe.prototype.setMesh=function(t,n,r){this.requestRender(),this.animationGroup=new e.AnimationObjectGroup(t),this.mixer=new e.AnimationMixer(this.animationGroup);let i=t.geometry;if(this.geometry=t.geometry,this.clipAction=void 0,i&&i.morphAttributes){let t=i.morphAttributes.position;t||=i.morphAttributes.color?i.morphAttributes.color:i.morphAttributes.normal,t&&(this.animationClip=e.AnimationClip.CreateClipsFromMorphTargetSequences(t,10,!0),this.animationClip&&this.animationClip[0]!=null&&(this.clipAction=this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration),this.clipAction.loop=e.LoopRepeat,this.clipAction.clampWhenFinished=!0,this.clipAction.play(),this.mixer.update(0)))}this.timeEnabled=n,this.morphColour=r,t.userData=this,t.matrixAutoUpdate=!1,this.setMorph(t),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(i.setAttribute(`morphTarget0`,i.getAttribute(`position`)),i.setAttribute(`morphTarget1`,i.getAttribute(`position`))),this.morphColour&&this.initiateMorphColor(),this.boundingBoxUpdateRequired=!0},Xe.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},Xe.prototype.setAnatomicalId=function(e){this.anatomicalId=e},Xe.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},Xe.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},Xe.prototype.setMorphTime=function(e){this.requestRender();let t=!1;if(this.clipAction){let n=e/this.duration*this.clipAction._clip.duration;n!=this.clipAction.time&&(this.clipAction.time=n,t=!0),t&&this.isTimeVarying()&&this.mixer.update(0)}else{let n=e;n=e>this.duration?this.duration:0>e?0:e,n!=this.inbuildTime&&(this.inbuildTime=n,t=!0)}t&&(this.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},Xe.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},Xe.prototype.getVisibility=function(){return this.visible},Xe.prototype.setVisibility=function(e){this.requestRender(),e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},Xe.prototype.setAlpha=function(e){this.requestRender();let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},Xe.prototype.setFrustumCulled=function(e){this.requestRender(),this._lod.setFrustumCulled(e)},Xe.prototype.setVertexColors=function(e){this.requestRender(),this._lod.setVertexColors(e)},Xe.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},Xe.prototype.setColour=function(e){this.requestRender(),this._lod.setColour(e)},Xe.prototype.setGreyScale=function(t){if(this.requestRender(),t){if(!this.origColour&&this._lod._material)return this.origColour=this._lod._material.color,this.origVertexColors=this._lod._material.vertexColors,this._lod.setVertexColors(!1),this._lod.setColour(new e.Color().setHex(12303291)),!0}else if(this.origColour)return this._lod.setColour(this.origColour),this._lod.setVertexColors(this.origVertexColors),this.origColour=void 0,!0;return!1},Xe.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},Xe.prototype.setColourHex=function(e){this.requestRender(),this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},Xe.prototype.setEmissiveRGB=function(e){this.requestRender(),this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},Xe.prototype.setMaterial=function(e){this.requestRender(),this._lod.setMaterial(e)},Xe.prototype.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&t.geometry){let n=t.geometry.attributes.position;if(n){this._b1.setFromBufferAttribute(n),this._b1.getCenter(this._v1);let t=-1,r=0;for(let i=0;i<n.count;i++)this._v2.fromArray(n.array,i*3),r=this._v2.distanceToSquared(this._v1),(t==-1||t>r)&&(t=r,e=i)}}return e},Xe.prototype.getClosestVertex=function(t){let n=new e.Vector3;this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=this.getMorph();if(r&&r.geometry&&this.closestVertexIndex>=0){let e=r.morphTargetInfluences,i=r.geometry.morphAttributes;if(e&&i&&i.position){let a=!1;for(let t=0;t<e.length;t++)e[t]>0&&(a=!0,this._v1.fromArray(i.position[t].array,this.closestVertexIndex*3),n.add(this._v1.multiplyScalar(e[t])));if(a)return t?n.applyMatrix4(r.matrixWorld):n}else return n.fromArray(r.geometry.attributes.position.array,this.closestVertexIndex*3),t?n.applyMatrix4(r.matrixWorld):n}return this.getBoundingBox(),n.copy(this.center),n},Xe.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(ce(e,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox}},Xe.prototype.dispose=function(){this._lod.dispose(),this.marker&&=(this.marker.dispose(),void 0),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},Xe.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))};var Ze=new WeakMap;Xe.prototype.hasMorphPositions=function(){let e=this.getMorph()?.geometry,t=e?.morphAttributes?.position;if(!t||t.length===0)return!1;let n=Ze.get(e);if(n&&n.morphPositions===t)return n.result;let r=e.getAttribute(`position`)?.array,i=!1;for(let e=0;e<t.length&&!i;e++){let n=t[e].array;if(!r||n.length!==r.length)i=!0;else if(n!==r){for(let e=0;e<n.length;e++)if(n[e]!==r[e]){i=!0;break}}}return Ze.set(e,{morphPositions:t,result:i}),i},Xe.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new qe(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){let t=this.getClosestVertex(!1);t&&(this.marker.setPosition(t.x,t.y,t.z),this.markerUpdateRequired=!1,e=!0)}this.marker.isEnabled()||(t.markersList&&!(this.marker.uuid in t.markersList)&&(e=!0,t.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),t&&t.camera&&e&&(this.marker.updateNDC(t.camera.cameraObject),t.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),t?.markersList&&this.marker.uuid in t.markersList&&(t.markerCluster.markerUpdateRequired=!0,delete t.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},Xe.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},Xe.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},Xe.prototype.setRenderOrder=function(e){this.requestRender(),this._lod.setRenderOrder(e)},Xe.prototype.getClosestVertexDOMElementCoords=function(e){if(e&&e.camera){let t=!0,n=this.getClosestVertex(!0);return n.project(e.camera),n.z=Math.min(Math.max(n.z,0),1),(n.x>1||n.x<-1||n.y>1||n.y<-1)&&(t=!1),e.getZincCameraControls().getRelativeCoordsFromNDC(n.x,n.y,n),{position:n,inView:t}}},Xe.prototype.setMarkerMode=function(e,t){this.requestRender(),e!==this.markerMode&&(this.markerMode=e===`on`||e===`off`?e:`inherited`,this.region&&(this.region.pickableUpdateRequired=!0)),t&&(this.markerNumber=t.number,this.markerImgURL=t.imgURL)},Xe.prototype.render=function(e,t,n,r){if(this.visible&&!(this.timeEnabled&&t)&&this._lod.update(n,this.center),t==1){if(this.clipAction&&this.isTimeVarying())this.mixer.update(e);else{let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t}this.visible&&e!=0&&(this.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},Xe.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},Xe.prototype.addVertices=function(e){this.requestRender();let t=this.getMorph(),n;if(!t)n=_e(500,e),this.drawRange=e.length;else if(this.drawRange>-1){let r=t.geometry.getAttribute(`position`);e.forEach(e=>{r.setXYZ(this.drawRange,e[0],e[1],e[2]),++this.drawRange}),r.needsUpdate=!0,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n=t.geoemtry,this.boundingBoxUpdateRequired=!0}return n},Xe.prototype.deleteVertices=function(e){this.requestRender();let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&Te(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},Xe.prototype.setPosition=function(e,t,n){this.requestRender();let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},Xe.prototype.loadAdditionalSources=function(e,t){e.load(filename,meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},Xe.prototype.setScaleAll=function(e){this.requestRender();let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Qe=(t,n,r)=>{let i=me(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0)o=n||new e.MeshPhongMaterial({color:r.colour,vertexColors:!1,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.vertexColors=!1,o=Oe(o));else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide})}return new e.Mesh(i,o)},$e=function(){Xe.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(e,t,n)=>{if(this.morph&&this.morph.geometry&&e!=null)return;let r=Qe(e,t,n);this.videoHandler=r.geometry._video,this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.requestRender(),this.morph.material.wireframe=e},this.editVertices=function(e,t){if(this.requestRender(),e&&e.length){let n=this.getMorph(),r=n.geometry.getAttribute(`position`);if(!n||0>t)return;{let i=t*3;e.forEach(e=>{r.array[i++]=e[0],r.array[i++]=e[1],r.array[i++]=e[2]}),r.needsUpdate=!0,n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour||this.videoHandler)}};$e.prototype=Object.create(Xe.prototype);var et=function(e,t){let n=e,r,i=1,a=500,o=.012;r=re(n,o,t?t.getStyle():void 0,`Asap`,a),r.center.x=-.05,r.center.y=0;let s=()=>{A(r)};this.getPosition=()=>r?[r.position.x,r.position.y,r.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{r&&r.position.set(e,t,n)},this.setColour=e=>{if(e){let t=e.getStyle();t!==r.color&&(r.color=t,s())}},this.setScale=e=>{r&&e>0&&r.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==r.material.depthTest&&(r.material.depthTest=e)},this.setSize=e=>{e>0&&(ie(r,o*e),i=e)},this.setFontWeight=e=>{e&&e!==a&&(r.fontWeight=e,s(),a=e)},this.setText=e=>{if(e&&e!==r.text){if(r._canvas,r.material&&r.material.map&&r.material.map.dispose(),r._canvas){let e=r._canvas.getContext(`2d`);e&&e.clearRect(0,0,r._canvas.width,r._canvas.height),r._canvas.width=1,r._canvas.height=1}r.text=e,ie(r,o*i),n=e,r.material&&r.material.map&&(s(),r.material.map.needsUpdate=!0)}},this.setVisibility=e=>{r.visible=e},this.dispose=()=>{r&&(ne(r),r.removeFromParent(),r.material&&(r.material.map?.dispose(),r.material.dispose()),r._canvas&&(r._canvas.width=0,r._canvas.height=0))},this.getSprite=()=>r,this.getString=()=>n},tt=function(t,n,r,i){Xe.call(this);let a;n&&(a=n.clone(),a.vertexColors=e.FaceColors);let o=i;this.id=r;let s,c;this.isGlyph=!0;let l=[0,0,0],u;this.fromMesh=e=>e&&e.isMesh?(this.morph=e.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,t&&a&&this.fromMesh(new e.Mesh(t,a)),this.getGlyphset=function(){return o},this.setLabel=e=>{o?.requestRender?.(),e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(o?.requestRender?.(),s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new et(c,u||e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.05,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{o?.requestRender?.(),s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0)},this.getLabel=()=>c,this.getMesh=()=>this.morph,this.setTransformation=(e,t,n,r)=>{o?.requestRender?.(),this.morph&&(this.morph.matrix.elements[0]=t[0],this.morph.matrix.elements[1]=t[1],this.morph.matrix.elements[2]=t[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=n[0],this.morph.matrix.elements[5]=n[1],this.morph.matrix.elements[6]=n[2],this.morph.matrix.elements[7]=0,this.morph.matrix.elements[8]=r[0],this.morph.matrix.elements[9]=r[1],this.morph.matrix.elements[10]=r[2],this.morph.matrix.elements[11]=0,this.morph.matrix.elements[12]=e[0],this.morph.matrix.elements[13]=e[1],this.morph.matrix.elements[14]=e[2],this.morph.matrix.elements[15]=1,this.morph.matrixAutoUpdate=!1),l=[...e],s&&s.setPosition(e[0],e[1],e[2])},this.setColour=e=>{o?.requestRender?.(),u=e?e.clone():void 0,s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=e),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.getColour=()=>u,this.dispose=()=>{s&&=(s.dispose(),void 0),this.material&&this.material.dispose(),this.morph=void 0}};tt.prototype=Object.create(Xe.prototype);function nt(){}nt.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,n=0,r=t.length;n<r;n+=2){var i=t[n],a=t[n+1];if(i.test(e))return a}return null}},Object.assign(nt.prototype,{crossOrigin:`anonymous`,onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,n){for(var r=[],i=0;i<e.length;++i)r[i]=this.createMaterial(e[i],t,n);return r},createMaterial:(function(){var t={NoBlending:e.NoBlending,NormalBlending:e.NormalBlending,AdditiveBlending:e.AdditiveBlending,SubtractiveBlending:e.SubtractiveBlending,MultiplyBlending:e.MultiplyBlending,CustomBlending:e.CustomBlending},n=new e.Color,r=new e.TextureLoader,i=new e.MaterialLoader;return function(a,o,s){var c={};function l(t,n,i,a,l){var u=o+t,d=nt.Handlers.get(u),f;d===null?(r.setCrossOrigin(s),f=r.load(u)):f=d.load(u),n!==void 0&&(f.repeat.fromArray(n),n[0]!==1&&(f.wrapS=e.RepeatWrapping),n[1]!==1&&(f.wrapT=e.RepeatWrapping)),i!==void 0&&f.offset.fromArray(i),a!==void 0&&(a[0]===`repeat`&&(f.wrapS=e.RepeatWrapping),a[0]===`mirror`&&(f.wrapS=e.MirroredRepeatWrapping),a[1]===`repeat`&&(f.wrapT=e.RepeatWrapping),a[1]===`mirror`&&(f.wrapT=e.MirroredRepeatWrapping)),l!==void 0&&(f.anisotropy=l);var p=e.MathUtils.generateUUID();return c[p]=f,p}var u={uuid:e.MathUtils.generateUUID(),type:`MeshLambertMaterial`};for(var d in a){var f=a[d];switch(d){case`DbgColor`:case`DbgIndex`:case`opticalDensity`:case`illumination`:break;case`DbgName`:u.name=f;break;case`blending`:u.blending=t[f];break;case`colorAmbient`:case`mapAmbient`:console.warn(`THREE.Loader.createMaterial:`,d,`is no longer supported.`);break;case`colorDiffuse`:u.color=n.fromArray(f).getHex();break;case`colorSpecular`:u.specular=n.fromArray(f).getHex();break;case`colorEmissive`:u.emissive=n.fromArray(f).getHex();break;case`specularCoef`:u.shininess=f;break;case`shading`:f.toLowerCase()===`basic`&&(u.type=`MeshBasicMaterial`),f.toLowerCase()===`phong`&&(u.type=`MeshPhongMaterial`),f.toLowerCase()===`standard`&&(u.type=`MeshStandardMaterial`);break;case`mapDiffuse`:u.map=l(f,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);break;case`mapDiffuseRepeat`:case`mapDiffuseOffset`:case`mapDiffuseWrap`:case`mapDiffuseAnisotropy`:break;case`mapEmissive`:u.emissiveMap=l(f,a.mapEmissiveRepeat,a.mapEmissiveOffset,a.mapEmissiveWrap,a.mapEmissiveAnisotropy);break;case`mapEmissiveRepeat`:case`mapEmissiveOffset`:case`mapEmissiveWrap`:case`mapEmissiveAnisotropy`:break;case`mapLight`:u.lightMap=l(f,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);break;case`mapLightRepeat`:case`mapLightOffset`:case`mapLightWrap`:case`mapLightAnisotropy`:break;case`mapAO`:u.aoMap=l(f,a.mapAORepeat,a.mapAOOffset,a.mapAOWrap,a.mapAOAnisotropy);break;case`mapAORepeat`:case`mapAOOffset`:case`mapAOWrap`:case`mapAOAnisotropy`:break;case`mapBump`:u.bumpMap=l(f,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);break;case`mapBumpScale`:u.bumpScale=f;break;case`mapBumpRepeat`:case`mapBumpOffset`:case`mapBumpWrap`:case`mapBumpAnisotropy`:break;case`mapNormal`:u.normalMap=l(f,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);break;case`mapNormalFactor`:u.normalScale=f;break;case`mapNormalRepeat`:case`mapNormalOffset`:case`mapNormalWrap`:case`mapNormalAnisotropy`:break;case`mapSpecular`:u.specularMap=l(f,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);break;case`mapSpecularRepeat`:case`mapSpecularOffset`:case`mapSpecularWrap`:case`mapSpecularAnisotropy`:break;case`mapMetalness`:u.metalnessMap=l(f,a.mapMetalnessRepeat,a.mapMetalnessOffset,a.mapMetalnessWrap,a.mapMetalnessAnisotropy);break;case`mapMetalnessRepeat`:case`mapMetalnessOffset`:case`mapMetalnessWrap`:case`mapMetalnessAnisotropy`:break;case`mapRoughness`:u.roughnessMap=l(f,a.mapRoughnessRepeat,a.mapRoughnessOffset,a.mapRoughnessWrap,a.mapRoughnessAnisotropy);break;case`mapRoughnessRepeat`:case`mapRoughnessOffset`:case`mapRoughnessWrap`:case`mapRoughnessAnisotropy`:break;case`mapAlpha`:u.alphaMap=l(f,a.mapAlphaRepeat,a.mapAlphaOffset,a.mapAlphaWrap,a.mapAlphaAnisotropy);break;case`mapAlphaRepeat`:case`mapAlphaOffset`:case`mapAlphaWrap`:case`mapAlphaAnisotropy`:break;case`flipSided`:u.side=e.BackSide;break;case`doubleSided`:u.side=e.DoubleSide;break;case`transparency`:console.warn(`THREE.Loader.createMaterial: transparency has been renamed to opacity`),u.opacity=f;break;case`depthTest`:case`depthWrite`:case`colorWrite`:case`opacity`:case`reflectivity`:case`transparent`:case`video`:case`visible`:case`wireframe`:u[d]=f;break;case`vertexColors`:f===!0&&(u.vertexColors=e.VertexColors),f===`face`&&(u.vertexColors=e.FaceColors);break;default:console.error(`THREE.Loader.createMaterial: Unsupported`,d,f)}}return u.type===`MeshBasicMaterial`&&delete u.emissive,u.type!==`MeshPhongMaterial`&&delete u.specular,u.opacity<1&&(u.transparent=!0),i.setTextures(c),i.parse(u)}})()});var rt=function(t){var n=this;this.video=void 0,this.videoTexture=void 0;var r=t,i=function(){document&&(n.video=document.createElement(`video`),n.video.crossOrigin=`anonymous`,n.video.src=r,n.video.load(),n.video.loop=!0)};this.setMorphTime=function(e,t){let r=e/t*n.video.duration;Number.isFinite(r)||(r=0),n.video.currentTime=r},this.getVideoDuration=function(){return n.video.duration},this.createCanvasVideoTexture=function(){return n.videoTexture=new e.VideoTexture(n.video),n.videoTexture.minFilter=e.LinearFilter,n.videoTexture.magFilter=e.LinearFilter,n.video.currentTime=0,n.videoTexture},this.getCurrentTime=function(e){return n.video?e*(n.video.currentTime/n.video.duration):0},this.isReadyToPlay=function(){return!!(n.video&&n.video.readyState>=3)},i()},it=e.BufferAttribute,at=e.BufferGeometry,ot=e.Color,st=e.DefaultLoadingManager,ct=e.FileLoader,lt=e.Float32BufferAttribute,ut=e.LoaderUtils;function dt(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?st:e,this.withCredentials=!1,this.paramsString=``}Object.assign(dt.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:ut.extractUrlBase(e),o=new ct(this.manager);e.split(`?`),this.paramsString=e.length===2?paramsStrings[1]:``,o.setWithCredentials(this.withCredentials),o.load(e,function(n){var o=void 0;try{o=JSON.parse(n)}catch{if(console.error(`The loader has encountered an error while parsing the content of a resource.`),r){r({responseURL:e});return}}var s=o.metadata;if(s!==void 0){var c=s.type;if(c!==void 0&&c.toLowerCase()===`object`){console.error(`THREE.JSONLoader: `+e+` should be loaded with THREE.ObjectLoader instead.`);return}}if(i&&i.parse)try{var l=i.parse(o,a);t(l.geometry,l.materials)}catch(t){if(console.error(`The loader has encountered aon loading the geometry`),console.error(t),r){r({responseURL:e});return}}},n,r)},setTexturePath:function(e){this.texturePath=e},parse:(function(){function t(e,t){return e&1<<t}function n(e){let n=e.faces,r=0;if(e.uvs!==void 0)for(let t=0;t<e.uvs.length;t++)e.uvs[t].length&&r++;let i=[],a=[],o=0,s=n.length;for(;o<s;){let e=n[o++],s=t(e,0),c=t(e,1),l=t(e,3),u=t(e,4),d=t(e,5),f=t(e,6),p=t(e,7),m,h,g;if(s){let e=n[o],t=n[o+1],s=n[o+2],m=n[o+3];o+=4;let h=0;c&&(h=n[o++]),l&&(o+=r*4),u&&(o+=1),d&&(o+=4),f&&(o+=1),p&&(o+=4),i.push(e,t,m),a.push(h),i.push(t,s,m),a.push(h);continue}m=n[o++],h=n[o++],g=n[o++],h||=m,g||=h;let _=0;c&&(_=n[o++]),l&&(o+=r*3),u&&(o+=1),d&&(o+=3),f&&(o+=1),p&&(o+=3),i.push(m,h,g),a.push(_)}return{indices:i,materialIndices:a}}function r(e){let t=[],n,r;for(let i=0;i<e.length;i++)e[i]!==r&&(r=e[i],n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:r});return n!==void 0&&(n.count=e.length*3-n.start,t.push(n)),t}function i(e,t){let n=new at;n.setIndex(t),n.setAttribute(`position`,e),n.computeVertexNormals();let r=n.getAttribute(`normal`);return r.name=e.name,r}function a(e,t){let n=[];if(e.morphTargets!==void 0)for(let r=0,i=e.morphTargets.length;r<i;r++){let i=e.morphTargets[r].vertices,a=new Float32Array(i.length);for(let e=0,n=i.length;e<n;e++)a[e]=i[e]*t;let o=new it(a,3);o.name=e.morphTargets[r].name,n.push(o)}let r=[];if(e.morphNormals!==void 0){for(let t=0,i=e.morphNormals.length;t<i;t++)if(n[t]){let i=e.morphNormals[t].normals,a=new it(Float32Array.from(i),3);a.name=n[t].name,r[t]=a}}return{morphPositions:n,morphNormals:r}}function o(e){if(e.morphColors===void 0)return;let t=[];for(let n=0,r=e.morphColors.length;n<r;n++){let r=e.morphColors[n].colors,i=[];for(let e=0,t=r.length;e<t;e+=3){let t=new ot(16755200);t.setRGB(r[e],r[e+1],r[e+2]),i.push(t)}let a=[];for(let e=0,t=i.length*3;e<t;e++){let t=de(i,e);a.push(t[0],t[1],t[2])}let o=new lt(a,3);o.name=e.morphColors[n].name,t.push(o)}return t}return function(t,s){t.data!==void 0&&(t=t.data);let c=t.scale===void 0?1:1/t.scale,l=t.vertices,u=l.length/3,d=new Float32Array(l.length);for(let e=0,t=l.length;e<t;e++)d[e]=l[e]*c;let f=new at;if(f.setAttribute(`position`,new it(d,3)),t.normals!==void 0&&t.normals.length>0&&f.setAttribute(`normal`,new it(Float32Array.from(t.normals),3)),t.uvs!==void 0&&(t.uvs[0]&&t.uvs[0].length>0&&f.setAttribute(`uv`,new it(Float32Array.from(t.uvs[0]),2)),t.uvs[1]&&t.uvs[1].length>0&&f.setAttribute(`uv2`,new it(Float32Array.from(t.uvs[1]),2))),t.colors!==void 0&&t.colors.length>0){let e=new Float32Array(t.colors.length*3);for(let n=0,r=t.colors.length;n<r;n++){let r=new ot(t.colors[n]);e[n*3]=r.r,e[n*3+1]=r.g,e[n*3+2]=r.b}f.setAttribute(`color`,new it(e,3))}else{let e=new Float32Array(u*3).fill(1);f.setAttribute(`color`,new it(e,3))}let{indices:p,materialIndices:m}=n(t);p.length>0&&(f.setIndex(p),f.groups=r(m));let{morphPositions:h,morphNormals:g}=a(t,c);if(h.length>0){f.morphAttributes.position=h;let e=[];for(let t=0;t<h.length;t++)g[t]?e.push(g[t]):p.length>0&&e.push(i(h[t],p));e.length>0&&(f.morphAttributes.normal=e)}let _=o(t);if(_!==void 0&&(f.morphAttributes.color=_,f.morphAttributes.position===void 0)){let e=f.getAttribute(`position`);f.morphAttributes.position=_.map(t=>{let n=new it(e.array,e.itemSize);return n.name=t.name,n})}if(f.computeBoundingBox(),f.computeBoundingSphere(),t.materials===void 0||t.materials.length===0)return{geometry:f};var v=nt.prototype.initMaterials(t.materials,s,`Anonymous`);if(t.materials[0].video){var y=s+t.materials[0].video;this.paramsString&&(y+=`?${this.paramsString}`),f._video=new rt(y)}return v&&v.length>0&&(t.materials[0].singleSided?v[0].side=e.FrontSide:t.materials[0].flipSided?v[0].side=e.BackSide:v[0].side=e.DoubleSide,t.materials[0].specularCoef&&(v[0].shininess=Math.floor(t.materials[0].specularCoef/3))),{geometry:f,materials:v}}})()});var ft={NONE:0,MIRROR:1,AXES_2D:2,AXES_3D:3},pt=e=>{switch(e){case`MIRROR`:return ft.MIRROR;case`AXES_2D`:return ft.AXES_2D;case`AXES_3D`:return ft.AXES_3D;default:return ft.NONE}},mt={position:0,axis1:1,axis2:2,axis3:3,color:4},ht=e=>e==`AXES_2D`||e==`MIRROR`?2:e==`AXES_3D`?3:1;function gt({baseCount:t,outputCount:r,repeat_mode:i,positionsData:a,axis1Data:o,axis2Data:s,axis3Data:c,scaleData:l,colorData:u,baseSize:d,offset:f,scaleFactors:p,globalScale:m}){let h=ht(i),g=!!u,_=[a,o,s,c,l];g&&_.push(u);let v=_.length,y=g?mt.color+1:mt.axis3+1,b=a.length/3,x=new Float32Array(b*v*4);for(let e=0;e<b;e++)for(let t=0;t<v;t++){let n=_[t],r=(e*v+t)*4;x[r]=n[e*3],x[r+1]=n[e*3+1],x[r+2]=n[e*3+2]}let S=(0,n.attributeArray)(x,`vec4`),C=(0,n.attributeArray)(r*y,`vec4`),w=(e,t)=>S.element(e.mul((0,n.int)(v)).add((0,n.int)(t))).xyz,T=(e,t,r)=>C.element(e.mul((0,n.int)(y)).add((0,n.int)(t))).assign((0,n.vec4)(r,0)),E=e=>({element:t=>C.element((0,n.int)(t).mul((0,n.int)(y)).add((0,n.int)(e))).xyz}),D={bottomFrame:(0,n.uniform)(0,`int`),topFrame:(0,n.uniform)(0,`int`),proportion:(0,n.uniform)(1),repeatMode:(0,n.uniform)(pt(i),`int`),baseSize:(0,n.uniform)(new e.Vector3(...d)),offset:(0,n.uniform)(new e.Vector3(...f)),scaleFactors:(0,n.uniform)(new e.Vector3(...p)),globalScale:(0,n.uniform)(m)};return{uniforms:D,compute:(0,n.Fn)(()=>{let e=(0,n.int)(n.instanceIndex),r=e.div((0,n.int)(h)),i=e.mod((0,n.int)(h)),a=D.bottomFrame.mul((0,n.int)(t)).add(r),o=D.topFrame.mul((0,n.int)(t)).add(r),s=(0,n.mix)(w(o,0),w(a,0),D.proportion),c=(0,n.mix)(w(o,1),w(a,1),D.proportion),l=(0,n.mix)(w(o,2),w(a,2),D.proportion),u=(0,n.mix)(w(o,3),w(a,3),D.proportion),d=(0,n.mix)(w(o,4),w(a,4),D.proportion),f=D.repeatMode.equal((0,n.int)(ft.NONE)).or(D.repeatMode.equal((0,n.int)(ft.MIRROR)));if((0,n.If)(f,()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize).add(d.mul(D.scaleFactors)).mul(D.globalScale),r=c.mul(t.x),a=l.mul(t.y),o=u.mul(t.z),f=s.add(r.mul(D.offset.x)).add(a.mul(D.offset.y)).add(o.mul(D.offset.z)),p=D.repeatMode.equal((0,n.int)(ft.MIRROR)).and(i.equal((0,n.int)(1))),m=(0,n.select)(p,r.negate(),r).toVar(),h=(0,n.select)(p,a.negate(),a).toVar(),g=(0,n.select)(p,o.negate(),o).toVar(),_=f.toVar();(0,n.If)(D.repeatMode.equal((0,n.int)(ft.MIRROR)).and(d.x.lessThan(0)),()=>{_.subAssign(m)});let v=g.dot(m.cross(h));(0,n.If)(v.lessThan(0),()=>{g.assign(g.negate())}),T(e,mt.position,_),T(e,mt.axis1,m),T(e,mt.axis2,h),T(e,mt.axis3,g)}).Else(()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize.x).add(d.mul(D.scaleFactors.x)).mul(D.globalScale),r=s.add(c.mul(t.x).mul(D.offset.x)).add(l.mul(t.y).mul(D.offset.y)).add(u.mul(t.z).mul(D.offset.z)),a=(0,n.select)(i.equal((0,n.int)(0)),d.x,(0,n.select)(i.equal((0,n.int)(1)),d.y,d.z)),o=D.repeatMode.equal((0,n.int)(ft.AXES_2D)),f=(0,n.select)(i.equal((0,n.int)(0)),c,(0,n.select)(i.equal((0,n.int)(1)),l,u)),p=(0,n.select)(i.equal((0,n.int)(0)),l,(0,n.select)(i.equal((0,n.int)(1)),(0,n.select)(o,c,u),c)),m=D.baseSize.x.add(a.mul(D.scaleFactors.x)).mul(D.globalScale),h=f.mul(m),g=h.cross(p),_=g.length(),v=D.baseSize.z.add(a.mul(D.scaleFactors.z)).mul(D.globalScale).div((0,n.max)(_,1e-8));v=(0,n.select)(o.and(i.greaterThan((0,n.int)(0))),v.mul(-1),v);let y=(0,n.select)(_.greaterThan(0),g.mul(v),g),b=y.cross(h),x=b.length(),S=D.baseSize.y.add(a.mul(D.scaleFactors.y)).mul(D.globalScale).div((0,n.max)(x,1e-8)),C=(0,n.select)(x.greaterThan(0),b.mul(S),b);T(e,mt.position,r),T(e,mt.axis1,h),T(e,mt.axis2,C),T(e,mt.axis3,y)}),g){let t=(0,n.mix)(w(o,5),w(a,5),D.proportion);T(e,mt.color,t)}})().compute(r),outputs:{buffer:C,stride:y,count:r,position:E(mt.position),axis1:E(mt.axis1),axis2:E(mt.axis2),axis3:E(mt.axis3),color:g?E(mt.color):void 0}}}async function _t(e,t){let{buffer:n,stride:r,count:i,color:a}=t.outputs,o=new Float32Array(await e.getArrayBufferAsync(n.value)),s=e=>{let t=new Float32Array(i*4);for(let n=0;n<i;n++){let i=(n*r+e)*4;t[n*4]=o[i],t[n*4+1]=o[i+1],t[n*4+2]=o[i+2]}return t};return{position:s(mt.position),axis1:s(mt.axis1),axis2:s(mt.axis2),axis3:s(mt.axis3),color:a?s(mt.color):void 0}}async function vt(e,t){return e.compute(t.compute),_t(e,t)}var yt=!0,bt=e=>{yt=!!e},xt=()=>yt;function St(t,r){let i=t;(!i||!i.isNodeMaterial)&&(i=new(t&&De[t.type]||e.MeshPhongNodeMaterial),t&&i.copy(t));let{position:a,axis1:o,axis2:s,axis3:c,color:l}=r.outputs;return i.positionNode=(0,n.Fn)(()=>{let e=n.instanceIndex;return a.element(e).add(o.element(e).mul(n.positionGeometry.x)).add(s.element(e).mul(n.positionGeometry.y)).add(c.element(e).mul(n.positionGeometry.z))})(),l&&(i.colorNode=(0,n.Fn)(()=>(0,n.vec4)(l.element(n.instanceIndex).mul(n.materialColor),n.materialOpacity))()),i}var Ct=function(){Xe.call(this);let t=[],n,r,i,a,o=!1,s,c,l,u=0,d=0,f=[0,0,0],p=[0,0,0],m=!1,h=[0,0,0],g=`NONE`;this.ready=!1;let _=!1,v=!1;this.isGlyphset=!0;let y=new e.Matrix4,b=new e.Color,x=new e.Color,S=new e.Box3,C=new e.Box3,w=new e.Box3,T=[],E=[],D=[],O=[],k=[],A=[],j=[],M=[];this.globalScale=1;let N,P=!1,ee=!0,te=!1,ne=!1,re,ie,ae=!1;for(let t=0;t<8;t++)T[t]=new e.Vector3;let oe=(e,t)=>{e.elements[0]=t[1][0],e.elements[1]=t[1][1],e.elements[2]=t[1][2],e.elements[3]=0,e.elements[4]=t[2][0],e.elements[5]=t[2][1],e.elements[6]=t[2][2],e.elements[7]=0,e.elements[8]=t[3][0],e.elements[9]=t[3][1],e.elements[10]=t[3][2],e.elements[11]=0,e.elements[12]=t[0][0],e.elements[13]=t[0][1],e.elements[14]=t[0][2],e.elements[15]=1},ce=(e,t,n)=>{let r=new Float32Array(t*n*3);for(let i=0;i<t;i++){let t=e[i.toString()];t&&r.set(t,i*n*3)}return r},le=(t,n,r)=>{let i=new Float32Array(n*r*3),a=new e.Color;for(let e=0;e<n;e++){let n=t[e.toString()];if(n)for(let t=0;t<r;t++){a.setHex(n[t]);let o=(e*r+t)*3;i[o]=a.r,i[o+1]=a.g,i[o+2]=a.b}}return i};this.load=(t,m,y,b,x)=>{if(o=!1,n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,s=t.scale,c=t.colors,l=t.label,_=t.metadata.MorphColours,v=t.metadata.MorphVertices,u=t.metadata.number_of_time_steps,g=t.metadata.repeat_mode,d=t.metadata.number_of_vertices,g==`AXES_2D`||g==`MIRROR`?d*=2:g==`AXES_3D`&&(d*=3),f=t.metadata.base_size,p=t.metadata.offset,h=t.metadata.scale_factors,N=void 0,v&&u>1&&a&&a[0]&&xt()){let e=a[0].length/3;try{N=gt({baseCount:e,outputCount:d,repeat_mode:g,positionsData:ce(a,u,e),axis1Data:ce(n,u,e),axis2Data:ce(r,u,e),axis3Data:ce(i,u,e),scaleData:ce(s,u,e),colorData:_&&c?le(c,u,e):void 0,baseSize:f,offset:p,scaleFactors:h,globalScale:this.globalScale})}catch(e){console.error(`Failed to set up GPU glyph transform compute, falling back to CPU animation.`,e),N=void 0}}let S=new dt;this.geometry=new e.BufferGeometry;let C=new e.InstancedMesh(this.geometry,void 0,d);if(this.setMorph(C),b){var w=S.parse(m);Se(y,x)(w.geometry,w.materials),w.geometry.dispose()}else S.crossOrigin=`Anonymous`,S.load(m,Se(y,x))};let ue=(e,t,n,r,i,a)=>{if(g==`NONE`||g==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],d=[0,0,0],m=[0,0,0],_=[0,0,0],v=[0,0,0],y=[0,0,0],b=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;c[o]=(s*f[o]+i[o]*h[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],d[o]=r[o]*c[2],m[o]=e[o]+p[0]*l[o]+p[1]*u[o]+p[2]*d[o],g==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-d[o],b[o]=m[o],i[0]<0&&(m[o]-=l[o],b[o]-=_[o]));0>d[0]*(l[1]*u[2]-l[2]*u[1])+d[1]*(l[2]*u[0]-l[0]*u[2])+d[2]*(l[0]*u[1]-l[1]*u[0])&&(d[0]=-d[0],d[1]=-d[1],d[2]=-d[2]),a[0]=[m,l,u,d],g==`MIRROR`&&(0>y[0]*(_[1]*v[2]-_[2]*v[1])+y[1]*(_[2]*v[0]-_[0]*v[2])+y[2]*(_[0]*v[1]-_[1]*v[0])&&(y[0]=-y[0],y[1]=-y[1],y[2]=-y[2]),a[1]=[b,_,v,y])}else if(g==`AXES_2D`||g==`AXES_3D`){let l=[0,0,0],u=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;l[o]=(s*f[0]+i[o]*h[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+p[0]*l[0]*t[o]+p[1]*l[1]*n[o]+p[2]*l[2]*r[o];let d=g==`AXES_2D`?2:3;for(let e=0;e<d;e++){let o,s,l=i[e],d=[0,0,0],p=[0,0,0],m=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=g==`AXES_2D`?t:r):(o=r,s=t);let _=(f[0]+l*h[0])*this.globalScale;d[0]=o[0]*_,d[1]=o[1]*_,d[2]=o[2]*_,m[0]=d[1]*s[2]-s[1]*d[2],m[1]=d[2]*s[0]-s[2]*d[0],m[2]=d[0]*s[1]-d[1]*s[0];let v=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);if(0<v){let t=(f[2]+l*h[2])*this.globalScale/v;g==`AXES_2D`&&e>0&&(t*=-1),m[0]*=t,m[1]*=t,m[2]*=t}if(p[0]=m[1]*d[2]-d[1]*m[2],p[1]=m[2]*d[0]-d[2]*m[0],p[2]=m[0]*d[1]-m[1]*d[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(f[1]+l*h[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,d,p,m]}}return a},de=(e,n,r,i,a)=>{let o=1;g==`AXES_2D`||g==`MIRROR`?o=2:g==`AXES_3D`&&(o=3);let s=e.length/3,c=0;M.length=o;for(let l=0;l<s;l++){let s=l*3,u=[e[s],e[s+1],e[s+2]],d=[n[s],n[s+1],n[s+2]],f=[r[s],r[s+1],r[s+2]],p=[i[s],i[s+1],i[s+2]],m=[a[s],a[s+1],a[s+2]],h=ue(u,d,f,p,m,M);if(h.length==o)for(let e=0;e<o;e++){oe(y,h[e]),this.morph.setMatrixAt(c,y);let n=t[c];n&&n.setTransformation(h[e][0],h[e][1],h[e][2],h[e][3]),c++}}this.morph.instanceMatrix.needsUpdate=!0,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere()},fe=(e,n)=>{let r=1;g==`AXES_2D`||g==`MIRROR`?r=2:g==`AXES_3D`&&(r=3);let i=e.length,a=0;for(let o=0;o<i;o++){let i=e[o];for(let e=0;e<r;e++){b.setHex(i),n||this.morph.setColorAt(a,b);let e=t[a];e&&e.setColour(b),a++}}n||(this.morph.instanceColor.needsUpdate=!0)},pe=e=>{this.requestRender();let n=this.morph.instanceMatrix.array,r=this.canShowLabel();for(let i=0;i<d;i++){let a=i*4,o=i*16;if(n[o]=e.axis1[a],n[o+1]=e.axis1[a+1],n[o+2]=e.axis1[a+2],n[o+3]=0,n[o+4]=e.axis2[a],n[o+5]=e.axis2[a+1],n[o+6]=e.axis2[a+2],n[o+7]=0,n[o+8]=e.axis3[a],n[o+9]=e.axis3[a+1],n[o+10]=e.axis3[a+2],n[o+11]=0,n[o+12]=e.position[a],n[o+13]=e.position[a+1],n[o+14]=e.position[a+2],n[o+15]=1,r){let n=t[i];n&&n.setTransformation([e.position[a],e.position[a+1],e.position[a+2]],[e.axis1[a],e.axis1[a+1],e.axis1[a+2]],[e.axis2[a],e.axis2[a+1],e.axis2[a+2]],[e.axis3[a],e.axis3[a+1],e.axis3[a+2]])}}if(this.morph.instanceMatrix.needsUpdate=!0,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere(),e.color){let n=this.morph.instanceColor?this.morph.instanceColor.array:void 0;for(let i=0;i<d;i++){let a=i*4;if(n){let t=i*3;n[t]=e.color[a],n[t+1]=e.color[a+1],n[t+2]=e.color[a+2]}if(r){let n=t[i];n&&(b.setRGB(e.color[a],e.color[a+1],e.color[a+2]),n.setColour(b))}}n&&(this.morph.instanceColor.needsUpdate=!0)}},me=(e,t,n)=>{if(P)return;let r=this.region?.getScene?.()?.getRenderer?.();r&&(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,P=!0,ee=!1,vt(r,N).then(e=>{P=!1,pe(e),ee=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},he=(e,t,n)=>{this.requestRender();let r=this.region?.getScene?.()?.getRenderer?.();return r?(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,r.compute(N.compute),ee=!1,this.morph.raycast=()=>{},te=!0,!0):!1},ge=()=>{if(P)return;let e=this.region?.getScene?.()?.getRenderer?.();e&&(P=!0,_t(e,N).then(e=>{P=!1,pe(e),ee=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},_e=()=>{ie!==void 0&&(clearTimeout(ie),ie=void 0)},ve=()=>{_e(),ie=setTimeout(()=>{ie=void 0,ge()},500)},ye=e=>{let t=this.inbuildTime/this.duration*(u-1),o=Math.floor(t),l=1-(t-o),d=Math.ceil(t);if(v&&N){e?(he(o,d,l),ve()):(_e(),me(o,d,l));return}let f=E,p=D,m=O,h=k,g=A,y=j;if(v){let e=a[o.toString()],t=a[d.toString()],c=n[o.toString()],u=n[d.toString()],_=r[o.toString()],v=r[d.toString()],y=i[o.toString()],b=i[d.toString()],x=s[o.toString()],S=s[d.toString()];E.length=e.length,D.length=e.length,O.length=e.length,k.length=e.length,A.length=e.length;for(let n=0;n<e.length;n++)f[n]=l*e[n]+(1-l)*t[n],p[n]=l*c[n]+(1-l)*u[n],m[n]=l*_[n]+(1-l)*v[n],h[n]=l*y[n]+(1-l)*b[n],g[n]=l*x[n]+(1-l)*S[n]}else f=a[0],p=n[0],m=r[0],h=i[0],g=s[0];if((v||!ae)&&(de(f,p,m,h,g),ae=!v),c!=null){if(_){let e=c[o.toString()],t=c[d.toString()];y.length=e.length;for(let n=0;n<e.length;n++)b.setHex(e[n]),x.setHex(t[n]),b.setRGB(b.r*l+x.r*(1-l),b.g*l+x.g*(1-l),b.b*l+x.b*(1-l)),y[n]=b.getHex()}else y=c[0];fe(y,!1)}};this.isUsingGPUCompute=()=>N!==void 0,this.getLabel=e=>{if(l&&l.length>e)return l[e]},this.isLabelDisplayed=()=>m,this.canShowLabel=()=>t?.length&&(l?.length||this.groupName),this.showLabel=()=>{if(this.requestRender(),t?.length){m=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{this.requestRender();for(let e=0;e<t.length;e++)t[e].hideLabel();m=!1};let be=()=>{let t=new e.Box3().setFromBufferAttribute(this.geometry.attributes.position),o=new e.Matrix4,c=new e.Box3,l=[],d=new e.Box3,f=!0;for(let e=0;e<u;e++){let u=a[e.toString()],p=n[e.toString()],m=r[e.toString()],h=i[e.toString()],g=s[e.toString()];if(!u)continue;let _=u.length/3;for(let e=0;e<_;e++){let n=e*3,r=[u[n],u[n+1],u[n+2]],i=[p[n],p[n+1],p[n+2]],a=[m[n],m[n+1],m[n+2]],s=[h[n],h[n+1],h[n+2]],_=[g[n],g[n+1],g[n+2]],v=ue(r,i,a,s,_,l);for(let e=0;e<v.length;e++)oe(o,v[e]),c.copy(t).applyMatrix4(o),f?(d.copy(c),f=!1):d.union(c)}}return f?void 0:d},xe=e=>{for(let e=0;e<d;e++){let n=new tt(void 0,void 0,e,this),r=l?l[e]:void 0;r||=this.groupName,r&&n.setLabel(r),u>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}l&&l.length>0&&e&&this.showLabel(),de(a[0],n[0],r[0],i[0],s[0]),ae=!0,c!=null&&fe(c[0],!!(N&&N.outputs.color)),N&&(re=be()),this.ready=!0};this.addCustomGlyph=e=>{this.requestRender(),e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(this.requestRender(),e.isMesh){let r=new tt(void 0,void 0,n,this);return r.fromMesh(e),t.push(r),this.morph.add(r.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,r}},this.forEachGlyph=e=>{for(let n=0;n<t.length;n++)e(t[n])};var Se=(e,t)=>(n,r)=>{if(o){n.dispose();return}this.geometry.copy(n),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),r&&r[0]&&(this.morph.material=r[0]),N&&(this.morph.material=St(this.morph.material,N)),xe(t),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),n.dispose(),e!=null&&typeof e==`function`&&e(this)};this.getClosestVertexIndex=function(){let e=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let t=a[0],n=t.length/3,r=-1,i=0;for(let a=0;a<n;a++){let n=a*3;this._v2.set(t[n],t[n+1],t[n+2]),i=this._v1.distanceTo(this._v2),(r==-1||r>i)&&(r=i,e=a)}}return e},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let t=new e.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,y),t.setFromMatrixPosition(y),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(N&&!ee&&re)return this.cachedBoundingBox.copy(re),this.cachedBoundingBox.applyMatrix4(se(this.morph)),this.cachedBoundingBox;if(this.boundingBoxUpdateRequired){S.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<d;e++)this.morph.getMatrixAt(e,y),C.copy(S).applyMatrix4(y),e==0?w.copy(C):w.union(C);if(w)this.cachedBoundingBox.copy(w),this.cachedBoundingBox.applyMatrix4(se(this.morph)),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(_||v)&&(ye(!0),v&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||u>0)&&(_||v)),this.getCurrentTime=()=>this.inbuildTime,this.prepareColorForExport=async()=>{if(!(N&&N.outputs.color))return;let e=this.region?.getScene?.()?.getRenderer?.();if(!e)return;e.compute(N.compute);let t=(await _t(e,N)).color;this.morph.setColorAt(0,b);let n=this.morph.instanceColor.array;for(let e=0;e<d;e++){let r=e*4,i=e*3;n[i]=t[r],n[i+1]=t[r+1],n[i+2]=t[r+2]}this.morph.instanceColor.needsUpdate=!0},this.clearColorExportState=()=>{N&&N.outputs.color&&this.morph.instanceColor&&(this.morph.instanceColor=null,this.morph.material&&(this.morph.material.needsUpdate=!0))},this.setScaleAll=function(e){this.requestRender(),this.globalScale=e,ae=!1,ye(!1)},this.dispose=()=>{o=!0;for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),_e(),n=void 0,r=void 0,i=void 0,a=void 0,s=void 0,c=void 0,N=void 0,P=!1,ee=!0,te=!1,ne=!1,re=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n,r)=>{if(N&&!te){let e=this.region?.getScene?.()?.getRenderer?.();e&&(e.compute(N.compute),te=!0,this.requestRender())}if(t==1){let t=this.inbuildTime+e;if(t>this.duration&&(t-=this.duration),this.inbuildTime=t,v&&N){_e();let e=this.inbuildTime/this.duration*(u-1),t=Math.floor(e),n=1-(e-t);he(t,Math.ceil(e),n)}else(_||v)&&ye(!1);ne=!0}else ne&&N&&ye(!1),ne=!1;this.updateMarker(t,r)}};Ct.prototype=Object.create(Xe.prototype);var wt=new e.Matrix4,Tt=new e.Ray,Et=new e.Vector3,Dt=class extends e.InstancedMesh{constructor(e,t,n){super(e,t,n),this.type=`InstancedPoints`,this.isInstancedPoints=!0,this.frustumCulled=!1,this.pointSize=10,this.sizePerPixel=1,this.pointPositions=new Float32Array}raycast(t,n){let r=this.matrixWorld,i=t.params.Points?t.params.Points.threshold:1,a=this.count,o=this.pointPositions;if(!a||!o||o.length<a*3)return;wt.copy(r).invert(),Tt.copy(t.ray).applyMatrix4(wt);let s=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.pointSize*this.sizePerPixel,c=s*s;for(let i=0;i<a;i++){Et.fromArray(o,i*3);let a=Tt.distanceSqToPoint(Et);if(a<c){let o=new e.Vector3;Tt.closestPointToPoint(Et,o),o.applyMatrix4(r);let s=t.ray.origin.distanceTo(o);if(s<t.near||s>t.far)continue;n.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:i,face:null,object:this})}}}},Ot=new e.Vector2,kt=t=>{let r=new e.MeshBasicNodeMaterial,i={pointSize:(0,n.uniform)(10),sizeAttenuation:(0,n.uniform)(0),viewportScale:(0,n.uniform)(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(Ot);this.value=.5*t.y})};return r.vertexNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`instancePosition`,`vec3`),t=n.modelViewMatrix.mul((0,n.vec4)(e,1)),r=i.pointSize.mul(n.screenDPR),a=r.mul(i.viewportScale.div(t.z.negate()));r=(0,n.mix)(r,a,i.sizeAttenuation);let o=n.positionGeometry.xy.mul(r);o=o.div(n.viewportSize.div(2));let s=n.cameraProjectionMatrix.mul(t);return o=o.mul(s.w),(0,n.vec4)(s.xy.add(o),s.z,s.w)})(),r.colorNode=(0,n.Fn)(()=>{let e=(0,n.texture)(t,(0,n.uv)());return(0,n.vec4)(e.rgb.mul(n.materialColor),e.a.mul(n.materialOpacity))})(),r.userData.uniforms=i,r.size=i.pointSize.value,r.sizeAttenuation=!!i.sizeAttenuation.value,r},At=500,jt=t=>{let n=new e.PlaneGeometry(1,1),r=new e.InstancedBufferAttribute(new Float32Array(t*3),3);return r.setUsage(e.DynamicDrawUsage),n.setAttribute(`instancePosition`,r),n},Mt=(e,t)=>{let n=e.getAttribute(`position`),r=e.morphAttributes.position;if(t&&r&&r.length>0){let t=e.morphTargetsRelative;return r.map(e=>{if(!t)return Float32Array.from(e.array);let r=new Float32Array(n.array.length);for(let t=0;t<r.length;t++)r[t]=n.array[t]+e.array[t];return r})}return[Float32Array.from(n.array)]},Nt=(e,t)=>{let n=e.morphAttributes.color;if(t&&n&&n.length>0)return n.map(e=>Float32Array.from(e.array))},Pt=e=>{let t=e.getAttribute(`color`);return t?Float32Array.from(t.array):void 0},Ft=function(){Xe.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0,o=[],s,c=!1,l=!1,u=new e.Color,d=()=>{let e=this.getMorph();if(!e||o.length===0)return;let t=e.count,n=o.length,r=0,i=0,a=1;if(n>1){let e=this.inbuildTime/this.duration*(n-1);r=Math.floor(e),i=Math.ceil(e),a=1-(e-r)}if(c){let n=o[r],s=o[i],c=e.pointPositions,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*s[e];e.geometry.getAttribute(`instancePosition`).needsUpdate=!0,this.boundingBoxUpdateRequired=!0}if(l&&s){let n=s[Math.min(r,s.length-1)],o=s[Math.min(i,s.length-1)];e.instanceColor||e.setColorAt(0,u);let c=e.instanceColor.array,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*o[e];e.instanceColor.needsUpdate=!0}};this.createMesh=(e,t,n)=>{if(!e||!t)return;let r=me(e,n);o=Mt(r,n.localTimeEnabled),s=Nt(r,n.localMorphColour),c=o.length>1,l=!!s,this.timeEnabled=c,this.morphColour=l;let i=o[0].length/3,a=jt(i),d=kt(Se());t.color&&d.color.copy(t.color),t.opacity!==void 0&&(d.opacity=t.opacity),d.transparent=!!t.transparent,d.alphaTest=t.alphaTest===void 0?.5:t.alphaTest;let f=new Dt(a,d,i);f.count=i;let p=a.getAttribute(`instancePosition`);p.array.set(o[0]),p.needsUpdate=!0,f.pointPositions=p.array,f.userData=this,this.drawRange=i;let m=s?s[0]:Pt(r);if(m)for(let e=0;e<i;e++)u.setRGB(m[e*3],m[e*3+1],m[e*3+2]),f.setColorAt(e,u);this.setMorph(f),r.dispose(),this.boundingBoxUpdateRequired=!0},this.setMesh=(e,t,n)=>{this.createMesh(e.geometry,e.material,{localTimeEnabled:t,localMorphColour:n});let r=this.getMorph();r&&(r.name=e.name)};let f=(o,s,c,l)=>{if(c){let u=new et(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.05,d.material.transparent=!0,d.material.depthWrite=!1,d.material.depthTest=r,u.setFontWeight(i),u.setSize(n),u.setVisibility(a),this.group.add(d),t[o]=u}},p=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(e,t,n)=>{if(this.requestRender(),e&&e.length>0){let r=this.getMorph(),i=this.drawRange;if(!r){i=0,this.drawRange=0;let e=jt(At),t=kt(Se());t.color.set(n),t.alphaTest=.5,r=new Dt(e,t,At),r.pointPositions=e.getAttribute(`instancePosition`).array,r.count=0,r.userData=this,this.setMorph(r)}let a=r.geometry.getAttribute(`instancePosition`);e.forEach(e=>{this.drawRange<At&&(a.setXYZ(this.drawRange,e[0],e[1],e[2]),this.drawRange++)}),a.needsUpdate=!0,r.count=this.drawRange;let o=i+e.length,s=0;if(Array.isArray(t)&&t.length===e.length||typeof t==`string`)for(;i+s<o;){let n=typeof t==`string`?t:t[s];f(i+s,e[s],n,this._lod._material.color),s++}this.boundingBoxUpdateRequired=!0,this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this.requestRender(),this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setColour=e=>{this.requestRender(),this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{this.requestRender(),r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{this.requestRender(),i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{this.requestRender(),n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{this.requestRender(),a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.userData.uniforms.pointSize.value=e,this.morph.pointSize=e)},this.setSizeAttenuation=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.userData.uniforms.sizeAttenuation.value=+!!e)},this.getVerticesByIndex=function(e){let t=this.getMorph();if(t&&e>=0&&this.drawRange>e)return[t.pointPositions[e*3],t.pointPositions[e*3+1],t.pointPositions[e*3+2]]},this.editVertices=function(e,n){if(this.requestRender(),e&&e.length){let r=this.getMorph(),i=n+e.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=r.geometry.getAttribute(`instancePosition`),a=n;e.forEach(e=>{let n=t[a];n&&n.setPosition(e[0],e[1],e[2]),i.setXYZ(a,e[0],e[1],e[2]),o[0]&&(o[0][a*3]=e[0],o[0][a*3+1]=e[1],o[0][a*3+2]=e[2]),a++}),i.needsUpdate=!0,this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){this.requestRender();let t=this.getMorph();if(!t||0>e||e>=this.drawRange)return this.drawRange;let n=t.geometry.getAttribute(`instancePosition`),r=this.drawRange-1;return n.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.pointPositions!==n.array&&t.pointPositions.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor&&(t.instanceColor.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor.needsUpdate=!0),n.needsUpdate=!0,this.drawRange=r,t.count=this.drawRange,p(e),this.boundingBoxUpdateRequired=!0,this.drawRange},this.setName=function(e){let n=this.groupName;Ft.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&this.drawRange>0){this._b1.setFromArray(t.pointPositions.subarray(0,this.drawRange*3)),this._b1.getCenter(this._v1);let n=-1;for(let r=0;r<this.drawRange;r++){this._v2.fromArray(t.pointPositions,r*3);let i=this._v1.distanceTo(this._v2);(n===-1||i<n)&&(n=i,e=r)}}return e},this.getClosestVertex=function(t){let n=this.getMorph();this.closestVertexIndex===-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=new e.Vector3;return n&&this.closestVertexIndex>=0?(r.fromArray(n.pointPositions,this.closestVertexIndex*3),t?r.applyMatrix4(n.matrixWorld):r):(this.getBoundingBox(),r.copy(this.center),r)},this.getBoundingBox=function(){let e=this.getMorph();if(this.visible&&e&&e.visible&&this.drawRange>0)return this.boundingBoxUpdateRequired&&=(this._b1.setFromArray(e.pointPositions.subarray(0,this.drawRange*3)),this.cachedBoundingBox.copy(this._b1),this.cachedBoundingBox.applyMatrix4(se(e)),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox},this.isTimeVarying=()=>c||l,this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(c||l)&&d()},this.render=(e,t,n,r)=>{if(this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),this.visible&&this._lod.update(n,this.center),t===!0&&(c||l)){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,d()}this.updateMarker(t,r)}};Ft.prototype=Object.create(Xe.prototype);var It=function(){Xe.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=me(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!1,t=Oe(t));let i=new He(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(this.requestRender(),t&&t.length>0){let r=this.addVertices(t);if(!this.getMorph()){let t=new e.LineBasicMaterial({color:n});r.colorsNeedUpdate=!0,this.createLineSegment(r,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};It.prototype=Object.create(Xe.prototype);var Lt=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Lt.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Lt.prototype.imageToUint8Array=async function(e,t,n,r){await e.loadImage(t,n),r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);return i.drawImage(t,0,0),{array:new Uint8Array(i.getImageData(0,0,r.width,r.height).data.buffer),width:r.width,height:r.height}},Lt.prototype.loadFromImages=async function(e){},Lt.prototype.dispose=function(){this.impl&&=(this.impl.dispose(),void 0)},Lt.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Lt.prototype.getMaterial=function(){if(this.impl)return new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide})};var Rt=function(){Lt.call(this),this.isTextureArray=!0,this.imageData=void 0,this.setDataTexture=e=>{this.impl=e,console.log(`setDataTexture`,e),this.imageData=e.image.data},this.loadFromImages=async t=>{let n=1,r=1,i=0;if(t&&t.length){this.isLoading=!0;let a=new Image;a.crossOrigin=`Anonymous`;let o=document.createElement(`canvas`),s=0,c=Array(t.length);for(let e=0;e<t.length;e++){let l=await this.imageToUint8Array(this,a,t[e],o);l&&l.array&&(n=l.width,r=l.height,c[i]=l.array,s+=c[i].length,i++)}let l=new Uint8Array(s);s=0,c.forEach(e=>{l.set(e,s),s+=e.length}),this.impl=new e.Data3DTexture(l,n,r,i),this.size={width:n,height:r,depth:i},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=t=>{if(this.impl){let n;if(t){if(t.vs&&t.fs){let r=!0;`transparent`in t&&(r=t.transparent);let i=e.FrontSide;t.side&&(i=t.side),n=new e.ShaderMaterial({transparent:r,uniforms:t.uniforms,vertexShader:t.vs,fragmentShader:t.fs,side:i}),t.glslVersion&&(n.glslVersion=t.glslVersion)}}else n=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide});if(n)return n.needsUpdate=!0,n}}};Rt.prototype=Object.create(Lt.prototype),Rt.prototype.dispose=function(){Lt.prototype.dispose.call(this),this.imageData=void 0};function zt(){let t=new e.MeshBasicNodeMaterial({side:e.DoubleSide}),r=new Uint8Array(32),i=new e.Data3DTexture(r,2,2,2);i.image={data:r,width:2,height:2,depth:2},i.format=e.RGBAFormat,i.type=e.UnsignedByteType,i.minFilter=e.LinearFilter,i.magFilter=e.LinearFilter,i.generateMipmaps=!1,i.unpackAlignment=1,i.needsUpdate=!0;let a={brightness:(0,n.uniform)(0),contrast:(0,n.uniform)(1),depth:(0,n.uniform)(1),discardAlpha:(0,n.uniform)(!0),direction:(0,n.uniform)(1),flipY:(0,n.uniform)(!0),flipZ:(0,n.uniform)(!1),nChannels:(0,n.uniform)(1),maskEnabled:(0,n.uniform)(!1),slide:(0,n.uniform)(new e.Vector3(0,0,1)),time:(0,n.uniform)(0)},o=(0,n.varying)((0,n.vec3)(0),`vUw`);a.diffuse0=(0,n.texture3D)(i,o),a.diffuse1=(0,n.texture3D)(i,o),a.mask=(0,n.texture3D)(i,o);let s=(0,n.Fn)(()=>{let e=(0,n.vec3)(n.positionLocal).toVar();return(0,n.If)(a.direction.equal(1),()=>{e.assign((0,n.vec3)(a.slide.x,n.positionLocal.y,n.positionLocal.x))}),(0,n.If)(a.direction.equal(2),()=>{e.assign((0,n.vec3)(n.positionLocal.x,a.slide.y,n.positionLocal.y))}),(0,n.If)(a.direction.equal(3),()=>{e.assign((0,n.vec3)(n.positionLocal.x,n.positionLocal.y,a.slide.z))}),(0,n.If)(a.flipY,()=>{e.y.assign((0,n.float)(1).sub(e.y))}),(0,n.If)(a.flipZ,()=>{e.z.assign((0,n.float)(1).sub(e.z))}),o.assign((0,n.vec3)(e.x,e.y,e.z)),n.positionLocal}),c=(0,n.Fn)(()=>{let e=a.diffuse0.r,t=a.diffuse1.r,r=(0,n.mix)(e,t,a.time).toVar();(0,n.If)(a.maskEnabled.and(a.discardAlpha),()=>{let e=a.mask.r;(0,n.If)(e.equal(0),()=>{(0,n.Discard)()})});let i=(0,n.vec3)(r).add((0,n.vec3)(a.brightness)).sub((0,n.vec3)(.5)).mul(a.contrast).add((0,n.vec3)(.5));return(0,n.vec4)((0,n.sRGBTransferEOTF)(i),1)});return t.positionNode=s(),t.colorNode=c(),t.userData.uniforms=a,t}var Bt=function(e){Xe.call(this),this.isTexturePrimitive=!0,this.texture=e,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,n)=>{if(e&&e.images&&e.images.source){let n=new Rt,r=[];e.images.source.forEach(e=>{r.push(e)});let i=this;n.loadFromImages(r).then(()=>{i.texture=n,i.textureList.push(this.texture),i.initialise(e,t)})}},this.addTextureArray=e=>{this.textureList.length===0&&this.texture&&this.textureList.push(this.texture),e&&e.isTextureArray&&this.textureList.push(e)},this.initialise=(e,t)=>{t!=null&&typeof t==`function`&&t(this)}};Bt.prototype=Object.create(Xe.prototype),Bt.prototype.constructor=Bt,Bt.prototype.dispose=function(){let e=new Set(this.textureList);this.texture&&e.add(this.texture),e.forEach(e=>e.dispose()),this.texture=void 0,this.textureList=[],Xe.prototype.dispose.call(this)};var Vt=t=>{let n=t.image,r=n.width,i=n.height,a=n.depth,o=n.data,s=new e.Data3DTexture(o,r,i,a);return s.format=t.format,s.type=t.type,s.minFilter=t.minFilter,s.magFilter=t.magFilter,s.wrapS=t.wrapS,s.wrapT=t.wrapT,s.wrapR=t.wrapR,s.colorSpace=t.colorSpace,s.anisotropy=t.anisotropy,s.needsUpdate=!0,s},Ht=function(t){Bt.call(this,t),this.isTextureSlides=!0;let n=[],r={};this.morph=new e.Group,this.group=this.morph,this.morph.userData=this;let i,a=!0,o=!1,s=0,c=1,l=1,u,d=!1,f=!0,p=0,m=0,h=-.1;this.createSlides=e=>{this.requestRender(),e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material.userData.uniforms;switch(e.rotation.x=0,e.rotation.y=0,e.rotation.z=0,e.position.x=0,e.position.y=0,e.position.z=0,t.direction){case`x`:let r=-Math.PI/2;e.rotation.y=r,n.direction.value=1,n.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,n.direction.value=2,n.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:n.direction.value=3,n.slide.value.set(0,0,t.value),e.position.z=t.value}this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{this.requestRender(),e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.requestRender(),this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&t&&t.direction&&t.value!==void 0){let i=new e.PlaneGeometry(1,1);i.translate(.5,.5,0);let p=zt();p.userData.uniforms.brightness.value=s,p.userData.uniforms.contrast.value=c,p.userData.uniforms.diffuse0.value=Vt(this.texture.impl),p.userData.uniforms.diffuse1.value=Vt(this.texture.impl),p.userData.uniforms.discardAlpha.value=f,p.userData.uniforms.depth.value=this.texture.size.depth,p.userData.uniforms.flipY.value=a,p.userData.uniforms.flipZ.value=o,u&&(p.userData.uniforms.mask.value=u),p.userData.uniforms.maskEnabled.value=d,p.userData.uniforms.nChannels.value=l;let m=new e.Mesh(i,p);m.name=this.groupName,m.userData=this;let h={value:t.value,direction:t.direction,id:m.id};return n.push(h),g(m,h),r[m.id]=m,this.morph.add(m),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),h}},this.getTextureSettings=()=>[...n],this.getTextureSettingsWithId=e=>{for(let t=0;t<n.length;t++)if(e===n[t].id)return{...n[t]}},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=e=>{this.requestRender(),e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.requestRender(),this.morph&&e in r&&r[e]){if(this.morph.getObjectById(e)){let t=r[e];this.morph.remove(t),t.clear(),t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),this.boundingBoxUpdateRequired=!0}let t=n.findIndex(t=>t.id===e);t>-1&&n.splice(t,1)}},this.dispose=()=>{this.morph.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),u&&(u.dispose(),u=void 0,d=!1),Bt.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};let _=(e,t,n)=>{if(t)switch(t.direction.value){case 1:n.copy(t.slide.value),e.expandByPoint(n),n.setY(1),n.setZ(1),e.expandByPoint(n);break;case 2:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setZ(1),e.expandByPoint(n);break;case 3:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setY(1),e.expandByPoint(n)}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();let t=new e.Vector3(0,0,0);this.morph.children.forEach(e=>{_(this.cachedBoundingBox,e.material.userData.uniforms,t)}),this.cachedBoundingBox.applyMatrix4(se(this.morph)),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{this.requestRender();let i=new e.Matrix4;i.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,0);let a=new e.Quaternion().setFromRotationMatrix(i);this.morph.position.set(...n),this.morph.quaternion.copy(a),this.morph.scale.set(...r),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=e=>{this.requestRender(),this.morph.renderOrder=e},this.initialise=(e,t)=>{if(e){let n=e.locations;n&&n.length>0&&(this.applyTransformation(n[0].orientation,n[0].position,n[0].scale),`flipY`in n[0]&&(a=n[0].flipY),`flipZ`in n[0]&&(o=n[0].flipZ)),this.createSlides(e.settings.slides),t!=null&&typeof t==`function`&&t(this)}},this.showEdges=t=>{if(this.requestRender(),i)i.material.color=t;else{let n=new e.BoxGeometry(1,1,1);n.translate(.5,.5,.5);let r=new e.EdgesGeometry(n);i=new e.LineSegments(r,new e.LineBasicMaterial({color:t})),this.group.add(i)}i.visible=!0},this.setUniformsValue=(e,t)=>{this.requestRender(),this.morph.children.forEach(n=>{let r=n.material;if(r.userData.uniforms){let n=r.userData.uniforms;n[e].value=t}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{this.requestRender(),f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{this.requestRender(),s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{this.requestRender(),c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{this.requestRender(),l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{this.requestRender(),u=e,d=!!u,this.morph.children.forEach(e=>{let t=e.material;if(t.userData.uniforms){let e=t.userData.uniforms;u&&(e.mask.value=u)}}),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{this.requestRender(),i&&(i.visible=!1)},this.updateTimeTexture=()=>{let e=this.textureList.length-1,t=this.inbuildTime/this.duration;if(this.timeEnabled&&e>0&&h!==t){let n=t*e,r=Math.floor(n),i=Math.ceil(n),a=n-r;this.morph.children.forEach(e=>{let t=e.material;if(t.userData.uniforms){let e=t.userData.uniforms;p!==r&&(e.diffuse0.value.image.data=this.textureList[r].imageData,e.diffuse0.value.needsUpdate=!0),m!==i&&(e.diffuse1.value.image.data=this.textureList[i].imageData,e.diffuse1.value.needsUpdate=!0),e.time.value=a}}),p=r,m=i,h=t}},this.setMorphTime=e=>{this.requestRender();let t=e;t=e>this.duration?this.duration:0>e?0:e,t!=this.inbuildTime&&(this.inbuildTime=t,this.updateTimeTexture())},this.render=(e,t,n,r)=>{if(t==1&&this.timeEnabled&&this.textureList.length>1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,this.updateTimeTexture()}}};Ht.prototype=Object.create(Bt.prototype),Ht.prototype.constructor=Ht;var Ut=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];let e=this;this.setFromObject=({nearPlane:t,farPlane:n,eyePosition:r,targetPosition:i,upVector:a})=>{e.nearPlane=t,e.farPlane=n,e.eyePosition=r,e.targetPosition=i,e.upVector=a}},Wt=function(t,n,r,i){let a={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},o={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},s={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},c={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},l={};l.MAIN=o.ROTATE,l.AUXILIARY=o.ZOOM,l.SECONDARY=o.PAN,this.cameraObject=t,this.domElement=n===void 0?document:n,this.renderer=r,this.scene=i,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.zoomRate=50,this.rotateRate=50,this.panRate=100,this.pixelHeight=1;let u=6e3,d=!0,f=0,p,m,h=!1,g=500,_,v=`default`,y=a.DEFAULT,b,x,S,C=0,w=s.FREE;this._state=o.NONE;let T;this.targetTouchId=-1;let E,D=new e.Vector3,O=new e.Vector3,k=new e.Vector3,A=new e.Vector3,j=new e.Vector3,M=new e.Vector3,N=new e.Vector3,P=new e.Vector3,ee=new e.Sphere,te=new e.Vector3,ne=!1,re,ie=0,ae={default:new Ut};ae.default.nearPlane=.1,ae.default.farPlane=2e3,ae.default.eyePosition=[0,0,0],ae.default.targetPosition=[0,0,-1],ae.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...ae.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(ee),ie=ee.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(ee.center)),ie=e>ie?e*1.5:ie}else ie=0};let oe=e=>{D.copy(this.cameraObject.position);let t=D.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,t*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(e,t)=>{e&&t&&(ae[e]=t)},this.setDefaultViewport=e=>e&&e in ae?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>ae[e],this.setCurrentViewport=e=>e in ae&&(this.setCurrentCameraSettings(ae[e]),!0),this.setRotationMode=e=>{switch(e){case`none`:w=s.NONE;break;case`horizontal`:w=s.HORIZONTAL;break;case`vertical`:w=s.VERTICAL;break;default:w=s.FREE}},this.onResize=()=>{ne=!0,E&&=void 0,re&&re.setCurrentCameraSettings(this.cameraObject,ae[v])},this.getVisibleHeightAtZDepth=e=>{let t=this.cameraObject.position.distanceTo(this.cameraObject.target);e<t?e-=t:e+=t;let n=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(e)},this.calculateHeightPerPixelAtZeroDepth=e=>{let t=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=t/e,this.pixelHeight},this.getNDCFromDocumentCoords=(t,n,r)=>{ve(!1);let i=r||new e.Vector2,a=(t-E.left)/E.width*2-1,o=-((n-E.top)/E.height)*2+1;return i.set(a,o)},this.getRelativeCoordsFromNDC=(t,n,r)=>{ve(!1);let i=r||new e.Vector2;return i.x=(t+1)*E.width/2,i.y=(1-n)*E.height/2,i},this.setMouseButtonAction=(e,t)=>{l[e]=o[t]};let se=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},ce=()=>{if(ie>0){let e=te.distanceTo(ee.center);return ie>e||this.cameraObject.position.distanceTo(ee.center)>e}return!0},le=e=>{ne=!0,te.copy(this.cameraObject.position).add(e),ce()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},ue=e=>{ve(!1);let t;if(y===a.DEFAULT&&(t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e)),!t)e.button==0?this._state=e.ctrlKey?l.AUXILIARY:e.shiftKey?l.SECONDARY:l.MAIN:e.button==1?(e.preventDefault(),this._state=l.AUXILIARY):e.button==2&&(this._state=l.SECONDARY),this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{y=a.MINIMAP;let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);le(e)}},de=e=>{if(ve(!1),E){if(this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,y===a.MINIMAP){let t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e);if(t){let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);le(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},fe=e=>{this._state=o.NONE,y==a.MINIMAP&&(y=a.DEFAULT),T!==void 0&&this.pointer_x_start==e.clientX-E.left&&this.pointer_y_start==e.clientY-E.top&&T.pick(this,e.clientX,e.clientY,this.renderer)},pe=e=>{this._state=o.NONE},me=e=>{ve(!1);let t=e.touches.length;if(t==1)this._state=o.TOUCH_ROTATE,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(t==2){this._state=o.TOUCH_ZOOM;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(t*t+n*n)}else t==3&&(this._state=o.TOUCH_PAN,this.targetTouchId=e.touches[0].identifier,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},he=e=>{e.preventDefault(),e.stopPropagation();let t=e.touches.length;if(t==1)this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top;else if(t==2){if(this._state===o.TOUCH_ZOOM){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(t*t+n*n)}}else if(t==3&&this._state===o.TOUCH_PAN)for(let t=0;t<3;t++)e.touches[t].identifier==this.targetTouchId&&(this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top)},ge=e=>{let t=this._state;if(this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t===o.TOUCH_ROTATE&&e.touches.length===0&&e.changedTouches&&e.changedTouches.length===1&&E&&T!==void 0){let t=e.changedTouches[0];this.pointer_x_start==t.clientX-E.left&&this.pointer_y_start==t.clientY-E.top&&T.pick(this,t.clientX,t.clientY,this.renderer)}},_e=()=>{ve(!0)},ve=e=>{if(e||E===void 0){let e=new IntersectionObserver(t=>{for(let e of t)E=e.boundingClientRect;e.disconnect()});e.observe(this.domElement)}},ye=e=>{ve(!1),this._state=o.SCROLL;let t=0;e.deltaY>0?t=this.zoomRate:e.deltaY<0&&(t=this.zoomRate*-1),C+=t,e.preventDefault(),e.stopImmediatePropagation()},be=e=>{ve(!1);let t=0;if(e.keyCode===c.EQUAL||e.keyCode===c.MINUS||e.keyCode===c.NUMPADADD||e.keyCode===c.NUMPADSUBTRACT){this._state=o.KEYBOARD_ZOOM;let n=1;e.shiftKey&&(n*=2),e.keyCode===c.EQUAL||e.keyCode===c.NUMPADADD?t=this.zoomRate*n*-1:(e.keyCode===c.MINUS||e.keyCode===c.NUMPADSUBTRACT)&&(t=this.zoomRate*n),C+=t}else(e.keyCode===c.ARROWLEFT||e.keyCode===c.ARROWUP||e.keyCode===c.ARROWRIGHT||e.keyCode===c.ARROWDOWN)&&(e.shiftKey?(this._state=o.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,t=this.rotateRate):(this._state=o.KEYBOARD_PAN,t=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,e.keyCode===c.ARROWLEFT?this.pointer_x-=t:e.keyCode===c.ARROWUP?this.pointer_y-=t:e.keyCode===c.ARROWRIGHT?this.pointer_x+=t:e.keyCode===c.ARROWDOWN&&(this.pointer_y+=t));Object.values(c).includes(e.keyCode)&&e.preventDefault()},xe=e=>{this._state=o.NONE},Se=()=>{if(this.cameraObject!==void 0){let e=E.height,t=this.cameraObject.position.distanceTo(this.cameraObject.target),n=0;this.cameraObject.far>this.cameraObject.near&&t>=this.cameraObject.near&&t<=this.cameraObject.far&&(n=(t-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),O.set(this.previous_pointer_x,e-this.previous_pointer_y,0),k.set(this.previous_pointer_x,e-this.previous_pointer_y,1),A.set(this.pointer_x,e-this.pointer_y,0),j.set(this.pointer_x,e-this.pointer_y,1),O.unproject(this.cameraObject),k.unproject(this.cameraObject),A.unproject(this.cameraObject),j.unproject(this.cameraObject),A.sub(O).multiplyScalar(1-n),j.sub(k).multiplyScalar(n),A.add(j).multiplyScalar(-.002),le(A)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(e,t)=>{e.normalize(),N.copy(this.cameraObject.position).sub(this.cameraObject.target),P.copy(N),N.normalize(),.8<Math.abs(N.dot(e))&&N.copy(this.cameraObject.up),O.crossVectors(e,N).normalize(),k.crossVectors(e,O);let n=e.dot(P),r=O.dot(P),i=k.dot(P),a=e.dot(this.cameraObject.up),o=O.dot(this.cameraObject.up),s=k.dot(this.cameraObject.up),c=Math.cos(t),l=Math.sin(t);return A.set(c*O.x+l*k.x,c*O.y+l*k.y,c*O.z+l*k.z),j.set(c*k.x-l*O.x,c*k.y-l*O.y,c*k.z-l*O.z),N.copy(this.cameraObject.target),N.x=N.x+e.x*n+A.x*r+j.x*i,N.y=N.y+e.y*n+A.y*r+j.y*i,N.z=N.z+e.z*n+A.z*r+j.z*i,D.set(e.x*a+A.x*o+j.x*s,e.y*a+A.y*o+j.y*s,e.z*a+A.z*o+j.z*s),{position:N,up:D}},this.rotateAboutLookAtpoint=(e,t)=>{ne=!0;let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let Ce=()=>{if(this.cameraObject!==void 0){let e=E?.width,t=E?.height;if(0<e&&0<t){let n=.25*(e+t),r=0,i=0;(w===s.FREE||w===s.HORIZONTAL)&&(r=this.pointer_x-this.previous_pointer_x),(w===s.FREE||w===s.VERTICAL)&&(i=this.previous_pointer_y-this.pointer_y);let a=Math.sqrt(r*r+i*i);if(a>0){let o=-i*1/a,c=r*1/a;if(w===s.FREE){let r=o*(this.pointer_x-.5*(e-1))+c*(.5*(t-1)-this.pointer_y);r>n?r=n:r<-n&&(r=-n)}let l=Math.acos(0/n)-.5*Math.PI,u=this.tumble_rate*a/n;D.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),O.copy(this.cameraObject.up).normalize(),k.copy(O).cross(D).normalize().multiplyScalar(o),O.multiplyScalar(c),M.addVectors(k,O).multiplyScalar(Math.cos(l)),D.multiplyScalar(Math.sin(l)),M.add(D),this.rotateAboutLookAtpoint(M,-u)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},we=()=>{let e=0;return this._state===o.ZOOM?e=this.previous_pointer_y-this.pointer_y:this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM?e=C:(e=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),e};this.changeZoomByScrollRateUnit=e=>{let t=e*this.zoomRate;this.changeZoomByValue(t)},this.changeZoomByValue=e=>{if(this.cameraObject!==void 0){let t=E.height,n=N.copy(this.cameraObject.position);n.sub(this.cameraObject.target);let r=n.length(),i=r*(1.5*e/t);r+i>.01&&(n.normalize(),te.copy(this.cameraObject.position),te.x+=n.x*i,te.y+=n.y*i,te.z+=n.z*i,ce()&&(this.cameraObject.position.copy(te),this.updateDirectionalLight(),oe(i),ne=!0))}};let Te=()=>{let e=we();this.changeZoomByValue(e),this._state===o.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(C=0,this._state=o.NONE)};this.setDirectionalLight=e=>{this.directionalLight=e},this.updateDirectionalLight=()=>{ne=!0,this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){d=!0,this.domElement&&this.domElement.addEventListener&&(se(this.domElement,0),this.domElement.addEventListener(`mousedown`,ue,!1),this.domElement.addEventListener(`mousemove`,de,!1),this.domElement.addEventListener(`mouseup`,fe,!1),this.domElement.addEventListener(`mouseleave`,pe,!1),this.domElement.addEventListener(`touchstart`,me,!1),this.domElement.addEventListener(`touchmove`,he,!1),this.domElement.addEventListener(`touchend`,ge,!1),this.domElement.addEventListener(`wheel`,ye,!1),this.domElement.addEventListener(`mouseenter`,_e,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,be,!1),this.domElement.addEventListener(`keyup`,xe,!1))},this.disable=function(){d=!1,this._state=o.NONE,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,ue,!1),this.domElement.removeEventListener(`mousemove`,de,!1),this.domElement.removeEventListener(`mouseup`,fe,!1),this.domElement.removeEventListener(`mouseleave`,pe,!1),this.domElement.removeEventListener(`touchstart`,me,!1),this.domElement.removeEventListener(`touchmove`,he,!1),this.domElement.removeEventListener(`touchend`,ge,!1),this.domElement.removeEventListener(`wheel`,ye,!1),this.domElement.removeEventListener(`mouseenter`,_e,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,be,!1),this.domElement.removeEventListener(`keyup`,xe,!1),se(this.domElement,-1))},this.loadPath=e=>{p=e.CameraPath,m=e.NumberOfPoints},this.loadPathURL=(e,t)=>{let n=e;fetch(n).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{this.loadPath(e),t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Failed to load path asset from: ${n}`,e)})},this.setPathDuration=e=>{u=e,b&&b.setDuration(u),x&&x.setDuration(u)},this.getPlayRate=()=>g,this.setPlayRate=e=>{g=e};let Ee=e=>{let t=f+e;t>u&&(t-=u),f=t};this.getTime=()=>f,this.setTime=e=>{f=e>u?u:e<0?0:e},this.getNumberOfTimeFrame=()=>m,this.getCurrentTimeFrame=()=>{if(m>2){let e=f/u*(m-1),t=Math.floor(e),n=1-(e-t),r=Math.ceil(e);return t==r?t==m-1?[t-1,r,0]:[t,r+1,1]:[t,r,n]}if(m==1)return[0,0,0]},this.setCurrentTimeFrame=e=>{ne=!0,m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let De=e=>{if(y===a.PATH&&(Ee(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=t*3,a=n*3,o=r*p[i]+(1-r)*p[a],s=r*p[i+1]+(1-r)*p[a+1],c=r*p[i+2]+(1-r)*p[a+2];this.cameraObject.position.set(o,s,c),this.cameraObject.target.set(p[a],p[a+1],p[a+2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o,s,c),this.directionalLight.target.position.set(p[a],p[a+1],p[a+2]))}};this.calculatePathNow=()=>{ne=!0,De(0)};let Oe=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?Ce():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(Se(),re.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(re.zoom(we()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(this._state=o.NONE),C=0,re.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?De(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(b=void 0,y=a.DEFAULT),n=!1):y===a.ROTATE_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(x=void 0,y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&re?(Oe(),n=!1):r=!1,n&&(this._state!==o.NONE&&(r=!0),this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?Ce():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?Se():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&Te(),this._state!==o.NONE&&y===a.AUTO_TUMBLE&&S&&S.stopOnCameraInput,this._state===o.SCROLL&&(this._state=o.NONE)),_?(r=!0,_.update()):this.cameraObject.lookAt(this.cameraObject.target),r||=ne,ne=!1,r},this.playPath=()=>{y=a.PATH},this.stopPath=()=>{y=a.DEFAULT},this.isPlayingPath=()=>y===a.PATH,this.enableDirectionalLightUpdateWithPath=e=>{h=e},this.enableDeviceOrientation=()=>{_||=new Zt(this.cameraObject)},this.disableDeviceOrientation=()=>{_&&=(_.dispose(),void 0)},this.isDeviceOrientationEnabled=()=>!!_,this.resetView=()=>{ne=!0;let e=ae[v];this.cameraObject.near=e.nearPlane,this.cameraObject.far=e.farPlane,this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=e=>{e.nearPlane&&(this.cameraObject.near=e.nearPlane),e.farPlane&&(this.cameraObject.far=e.farPlane),e.eyePosition&&this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),e.targetPosition&&this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),e.upVector&&this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),ne=!0},this.getViewportFromCentreAndRadius=(e,t,n,r,i,a)=>{D.copy(this.cameraObject.position),D.sub(this.cameraObject.target),D.normalize();let o=[e,t,n],s=r/Math.tan(i*Math.PI/360),c=[e+D.x*s,t+D.y*s,n+D.z*s],l=s+a,u=0;u=a>.95*s?.050000000000000044*s:s-a;let d=new Ut;return d.nearPlane=u,d.farPlane=l,d.eyePosition=c,d.targetPosition=o,d.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],d},this.getViewportFromBoundingBox=(e,t)=>{let n=e.min.distanceTo(e.max)/2*t,r=(e.min.x+e.max.x)/2,i=(e.min.y+e.max.y)/2,a=(e.min.z+e.max.z)/2;return this.getViewportFromCentreAndRadius(r,i,a,n,40,n*4)},this.getCurrentViewport=()=>{let e=new Ut;return e.nearPlane=this.cameraObject.near,e.farPlane=this.cameraObject.far,e.eyePosition[0]=this.cameraObject.position.x,e.eyePosition[1]=this.cameraObject.position.y,e.eyePosition[2]=this.cameraObject.position.z,e.targetPosition[0]=this.cameraObject.target.x,e.targetPosition[1]=this.cameraObject.target.y,e.targetPosition[2]=this.cameraObject.target.z,e.upVector[0]=this.cameraObject.up.x,e.upVector[1]=this.cameraObject.up.y,e.upVector[2]=this.cameraObject.up.z,e},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(e,t,n)=>{x??(b=new Gt(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new Kt(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_TRANSITION)},this.pauseCameraTransition=()=>{y=a.DEFAULT},this.stopCameraTransition=()=>{y=a.DEFAULT,b=void 0,x=void 0},this.isTransitioningCamera=()=>y===a.SMOOTH_CAMERA_TRANSITION||y===a.ROTATE_TRANSITION,this.autoTumble=(e,t,n)=>{S=new Jt(e,t,n,this)},this.enableAutoTumble=()=>{y=a.AUTO_TUMBLE},this.stopAutoTumble=()=>{y=a.DEFAULT,S=void 0},this.updateAutoTumble=()=>{S&&(S.requireUpdate=!0)},this.isAutoTumble=()=>y===a.AUTO_TUMBLE,this.enableRaycaster=(e,t,n)=>{T??=new qt(e,this.scene,t,n,this.renderer)},this.disableRaycaster=()=>{T.disable(),T=void 0},this.isSyncControl=()=>currentMpde===a.SYNC_CONTROL,this.enableSyncControl=()=>(y=a.SYNC_CONTROL,re||=new Qt,re.setCurrentCameraSettings(this.cameraObject,ae[v]),re),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},Gt=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=t.eyePosition,s=t.targetPosition,c=n,l=r,u=0,d=!1;c.near=Math.min(e.nearPlane,t.nearPlane),c.far=Math.max(e.farPlane,t.farPlane),c.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{l=e};let f=e=>{let t=u+e;t>l&&(t=l),u=t},p=()=>{let e=u/l,t=1-e;c.cameraObject.position.set(i[0]*t+o[0]*e,i[1]*t+o[1]*e,i[2]*t+o[2]*e),c.cameraObject.target.set(a[0]*t+s[0]*e,a[1]*t+s[1]*e,a[2]*t+s[2]*e)};this.update=e=>{this.enabled!==!1&&(f(e),p(),u==l&&(d=!0))},this.isTransitionCompleted=()=>d},Kt=function(e,t,n,r){let i=e,a=t,o=n,s=r,c=0;c/s;let l=!1;this.setDuration=e=>{s=e};let u=e=>{let t=c,n=c+e;n>s&&(n=s),c=n;let r=(c-t)/s*a;o.rotateAboutLookAtpoint(i,r)};this.update=e=>{this.enabled!==!1&&(u(e),c==s&&(l=!0))},this.isTransitionCompleted=()=>l},qt=function(t,n,r,i,a){let o=t,s=n,c=a,l=r,u=i,d=!0,f=new e.Raycaster;f.params.Line.threshold=.1,f.params.Points.threshold=1;let p=new e.Vector2,m=!1,h=new Date,g=!1,_=0,v=[],y={zincCamera:void 0,x:-1,y:-1},b=!1,x;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{s!==o&&o.getThreeJSScene().updateMatrixWorld();let t=x||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?x=void 0:(x=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&x.push(e.getGroup())}))},this.getIntersectsObjectWithOrigin=(e,t,n)=>(f.set(t,n),this.getIntersectsObject(e)),this.getIntersectsObjectWithCamera=(e,t,n)=>(e.getNDCFromDocumentCoords(t,n,p),f.setFromCamera(p,e.cameraObject),this.getIntersectsObject(e)),this.pick=(e,t,n)=>{if(d&&c&&o&&e&&l){this.getIntersectsObjectWithCamera(e,t,n);let r=v.length;for(let e=0;e<r;e++){let t=v[e].object?v[e].object.userData:void 0;if(t&&t.isMarkerCluster&&t.visible&&t.clusterIsVisible(v[e].object.clusterIndex)&&t.zoomToCluster(v[e].object.clusterIndex))return}l(v,t,n),s?.invalidate?.()}};let S=(e,t,n)=>{if(d&&c&&o&&e&&u){if(this.getIntersectsObjectWithCamera(e,t,n),h.setTime(Date.now()),v.length===0){if(g)return;g=!0}else g=!1;u(v,t,n),s?.invalidate?.()}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(y.zincCamera=e,y.x=t,y.y=n,o.displayMarkers?typeof requestAnimationFrame==`function`?b||(b=!0,requestAnimationFrame(()=>{b=!1,S(y.zincCamera,y.x,y.y)})):S(e,t,n):m||(_=h?Date.now()-h.getTime():250,_>=250?S(e,t,n):(m=!0,setTimeout(C(y),250-_))))};let C=e=>function(){m=!1,S(e.zincCamera,e.x,e.y)}},Jt=function(t,n,r,i){let a=new e.Vector3,o=-n,s=i,c=t;this.stopOnCameraInput=r,this.requireUpdate=!0;let l=new e.Vector3,u=new e.Vector3,d=e=>{let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=.25*(Math.abs(e[0])*4+Math.abs(e[1])*4),r=-e[1]/t,i=e[0]/t,o=r*e[0]+i*-e[1];o>n?o=n:o<-n&&(o=-n);let c=Math.acos(o/n)-.5*Math.PI;a.copy(s.cameraObject.position).sub(s.cameraObject.target).normalize(),l.copy(s.cameraObject.up).normalize(),u.crossVectors(l,a).normalize().multiplyScalar(r),l.multiplyScalar(i),l.add(u).multiplyScalar(Math.cos(c)),a.multiplyScalar(Math.sin(c)).add(l)};this.update=e=>{this.enabled!==!1&&(this.requireUpdate&&=(d(c),!1),s.rotateAboutLookAtpoint(a,o*e/1e3))}},Yt=function(){this.type=`StereoCamera`,this.aspect=1,this.cameraL=new e.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new e.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(Yt.prototype,{update:(()=>{let t,n,r,i,a,o,s=new e.Matrix4,c=new e.Matrix4;return function(l){if(t!==l.focus||n!==l.fov||r!==l.aspect*this.aspect||i!==l.near||a!==l.far||o!==l.zoom){t=l.focus,n=l.fov,r=l.aspect*this.aspect,i=l.near,a=l.far,o=l.zoom;let u=l.projectionMatrix.clone(),d=.064/2,f=d*i/t,p=i*Math.tan(e.MathUtils.DEG2RAD*n*.5)/l.zoom,m,h;c.elements[12]=-.032,s.elements[12]=d,m=-p*r+f,h=p*r+f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraL.projectionMatrix.copy(u),m=-p*r-f,h=p*r-f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraR.projectionMatrix.copy(u)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(c),this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(s)}})()});var Xt=function(e){let t=new Yt;t.aspect=.5,this.setSize=(t,n)=>{e.setSize(t,n)},this.render=(n,r)=>{n.updateMatrixWorld(),r.parent===null&&r.updateMatrixWorld(),t.update(r);let i=e.getSize();e.setScissorTest(!0),e.clear(),e.setScissor(0,0,i.width/2,i.height),e.setViewport(0,0,i.width/2,i.height),e.render(n,t.cameraL),e.setScissor(i.width/2,0,i.width/2,i.height),e.setViewport(i.width/2,0,i.width/2,i.height),e.render(n,t.cameraR),e.setScissorTest(!1)}},Zt=function(t){let n=this;this.object=t,this.object.rotation.reorder(`YXZ`),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;let r=e=>{n.deviceOrientation=e},i=()=>{typeof window<`u`&&(n.screenOrientation=window.orientation||0)},a=(()=>{let t=new e.Vector3(0,0,1),n=new e.Euler,r=new e.Quaternion,i=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),a=new e.Vector3,o=new e.Quaternion;return(e,s,c,l,u)=>{a.subVectors(e.target,e.position),n.set(c,s,-l,`YXZ`),o.setFromEuler(n),o.multiply(i),o.multiply(r.setFromAxisAngle(t,-u)),a.applyQuaternion(o),a.addVectors(e.position,a),e.lookAt(a)}})();this.connect=()=>{i(),typeof window<`u`&&(window.addEventListener(`orientationchange`,i,!1),window.addEventListener(`deviceorientation`,r,!1)),n.enabled=!0},this.disconnect=()=>{typeof window<`u`&&(window.removeEventListener(`orientationchange`,i,!1),window.removeEventListener(`deviceorientation`,r,!1)),n.enabled=!1},this.update=()=>{if(n.enabled===!1)return;let t=n.deviceOrientation.alpha?e.MathUtils.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.MathUtils.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.MathUtils.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.MathUtils.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},Qt=function(){let t,n,r,i=new e.Vector3,a=new e.Vector3,o=new e.Vector3,s=new e.Vector3,c;this.setCurrentCameraSettings=(o,s)=>{this.near_plane_fly_debt,t=o.clone(),n=o,r=s,t.near=r.nearPlane,r.farPlane&&(t.far=r.farPlane),r.eyePosition&&t.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&t.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&(t.target=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),t.lookAt(t.target)),t.updateProjectionMatrix(),i.copy(t.position).project(t),a.copy(t.target).project(t)},this.getCurrentPosition=()=>(a.copy(n.target).project(t),[a.x,a.y]),this.zoom=e=>{let t=e*.002,r=Math.max(n.zoom-t,1);n.zoom=r,n.updateProjectionMatrix()},this.zoomToBox=(e,n)=>{e.getCenter(o),o.project(t),this.setCenterZoom([o.x,o.y],n)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:n.zoom}),this.setCenterZoom=(e,r)=>{o.set(e[0],e[1],a.z).unproject(t),s.copy(o).sub(n.target),n.target.copy(o),n.lookAt(n.target),n.position.add(s),n.zoom=r,n.updateProjectionMatrix()},this.setEventCallback=e=>{(e===void 0||typeof e==`function`)&&(c=e)},this.triggerCallback=()=>{c!==void 0&&typeof c==`function`&&c()}},$t=new e.TextureLoader().load(`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,165,0);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,b);$t.colorSpace=e.SRGBColorSpace;var en=[.02,.03,1],tn=new e.SpriteMaterial({map:$t,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),nn=function(t){Xe.call(this),this.texture=$t;let n=t;this.morph=new e.Group,this.group=this.morph,this.isMarkerCluster=!0;let r=!0,i=[];this.markers={};let a=new e.Vector2,o=new e.Vector2,s=Date.now();this.setSpriteSize=e=>{(void 0).scale.set(.015,.02,1),(void 0).scale.multiplyScalar(e)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};let c=t=>{let n=new e.Group,r=new e.Sprite(tn);return r.clusterIndex=t,r.center.set(.5,0),r.position.set(0,0,0),r.renderOrder=1e4,r.scale.set(en[0],en[1],en[2]),r.userData=this,n.add(r),this.group.add(n),{group:n,marker:r,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},l=(e,t,n)=>{e.group.visible=!0,e.group.position.set(t.coords[0],t.coords[1],t.coords[2]),(e.label===void 0||n!==e.number)&&(e.label&&(e.group.remove(e.label),ne(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=Ce(n,.012,`black`,`Asap`,120,700),e.label.renderOrder=10001,e.number=n,e.group.add(e.label)),e.min=t.min,e.max=t.max},u=e=>{let t=0;for(e.forEach(e=>{let n=e.members.length,r=0;n===1?e.members[0].setVisibility(!0):(e.members.forEach(e=>{r+=e.getNumber(),e.setVisibility(!1)}),i[t]||i.push(c(t)),l(i[t],e,r),t++)});t<i.length;t++)i[t].group.visible=!1},d=(e,t)=>{let n=!0,r={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},i=0;for(let s in e)n?(a.set(e[s].ndc.x,e[s].ndc.y),this._b1.setFromPoints([e[s].morph.position]),n=!1,r.members.push(e[s]),r.coords=[e[s].morph.position.x,e[s].morph.position.y,e[s].morph.position.z],t.push(r),delete e[s]):(o.set(e[s].ndc.x,e[s].ndc.y),i=a.distanceTo(o),.1>i&&(r.members.push(e[s]),this._b1.expandByPoint(e[s].morph.position),delete e[s]));r.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],r.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],n!==!0&&d(e,t)};this.calculate=()=>{if(r&&Date.now()-s>500){let e=[];d({...this.markers},e),u(e),n?.invalidate?.(),s=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>r,this.enable=()=>{r=!0,this.morph.visible=!0},this.disable=()=>{r=!1,this.morph.visible=!1;for(let e in this.markers)this.markers[e]?.isMarker&&this.markers[e].isEnabled()&&this.markers[e].setVisibility(!0)},this.zoomToCluster=e=>e!==void 0&&e>-1&&(this._v1.set(...i[e].min),this._v2.set(...i[e].max),Math.abs(this._v1.distanceTo(this._v2)>0))?(this._b1.set(this._v1,this._v2),n.translateBoundingBoxToCameraView(this._b1,3,300),this.markerUpdateRequired=!0,!0):!1,this.clusterIsVisible=e=>e!==void 0&&e>-1&&i[e]?i[e].group?.visible:!1};nn.prototype=Object.create(Xe.prototype);var rn=function(t){let n=t;this.camera=new e.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let r=new e.BufferGeometry;var i=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]);let a=new e.BufferAttribute(i,3);r.setAttribute(`position`,a);var o=new e.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new e.Mesh(r,o);let s=new e.Box3,c=new e.Vector3,l=new e.Vector3,u=new e.Vector3,d=new e.Vector3,f=[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],p=[f[0],f[1],f[2],f[2],f[3],f[0]],m=new e.Box3,h=new e.Matrix4,g=new e.Matrix4,_,v=!1,y=(e,t)=>{for(let n=0;n<16;n++)if(!Object.is(e.elements[n],t.elements[n]))return!1;return!0};this.getDiffFromNormalised=(t,n)=>(s.setFromBufferAttribute(a).getCenter(c),l.copy(c).project(this.camera),new e.Vector3(t,n,l.z).unproject(this.camera).sub(c));let b=(e,t)=>{n.camera.near&&(this.camera.near=n.camera.near),t.farPlane&&(this.camera.far=t.farPlane),t.eyePosition&&this.camera.position.set(t.eyePosition[0],t.eyePosition[1],t.eyePosition[2]),t.upVector&&this.camera.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),t.targetPosition&&this.camera.lookAt(u.set(t.targetPosition[0],t.targetPosition[1],t.targetPosition[2])),this.camera.zoom=1/e,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let e=n.camera;d.copy(e.target).project(e),f[0].set(-1,-1,d.z).unproject(e),f[1].set(1,-1,d.z).unproject(e),f[2].set(1,1,d.z).unproject(e),f[3].set(-1,1,d.z).unproject(e),Ee(a,p)},this.updateCamera=()=>{let e=n.camera,t=n.getBoundingBox();if(v&&t&&t.equals(m)&&_===e.near&&y(h,e.matrixWorld)&&y(g,e.projectionMatrix))return;this.getBoundary(),h.copy(e.matrixWorld),g.copy(e.projectionMatrix),_=e.near,v=!1;let r=n.getZincCameraControls();if(t){m.copy(t),v=!0;let e=t.min.distanceTo(t.max),n=e/2,i=(t.min.x+t.max.x)/2,a=(t.min.y+t.max.y)/2,o=(t.min.z+t.max.z)/2,s=r.getViewportFromCentreAndRadius(i,a,o,n,40,n*4);b(e,s)}}},an=new e.Box3,on=new e.Vector3,sn=class extends e.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new e.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new e.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceEnd`,new e.InterleavedBufferAttribute(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceColorStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceColorEnd`,new e.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new e.Box3);let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;t!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(t),an.setFromBufferAttribute(n),this.boundingBox.union(an))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingBox===null&&this.computeBoundingBox();let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(t!==void 0&&n!==void 0){let e=this.boundingSphere.center;this.boundingBox.getCenter(e);let r=0;for(let i=0,a=t.count;i<a;i++)on.fromBufferAttribute(t,i),r=Math.max(r,e.distanceToSquared(on)),on.fromBufferAttribute(n,i),r=Math.max(r,e.distanceToSquared(on));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}},cn=new e.Vector3,ln=new e.Vector3,un=new e.Vector4,dn=new e.Vector4,fn=new e.Vector4,pn=new e.Vector3,mn=new e.Matrix4,hn=new e.Line3,gn=new e.Vector3,_n=new e.Box3,vn=new e.Sphere,yn=new e.Vector4,bn=new e.Vector4,xn,Sn;function Cn(e,t,n){return yn.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),yn.multiplyScalar(1/yn.w),yn.x=Sn/n.width,yn.y=Sn/n.height,yn.applyMatrix4(e.projectionMatrixInverse),yn.multiplyScalar(1/yn.w),Math.abs(Math.max(yn.x,yn.y))}function wn(t,n){let r=t.matrixWorld,i=t.geometry,a=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=Math.min(i.instanceCount,a.count);for(let i=0,c=s;i<c;i++){hn.start.fromBufferAttribute(a,i),hn.end.fromBufferAttribute(o,i),hn.applyMatrix4(r);let s=new e.Vector3,c=new e.Vector3;xn.distanceSqToSegment(hn.start,hn.end,c,s),c.distanceTo(s)<Sn*.5&&n.push({point:c,pointOnLine:s,distance:xn.origin.distanceTo(c),object:t,face:null,faceIndex:i,uv:null,uv1:null})}}function Tn(t,n,r){let i=n.projectionMatrix,a=t.matrixWorld,o=t._resolution,s=t.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;xn.at(1,fn),fn.w=1,fn.applyMatrix4(n.matrixWorldInverse),fn.applyMatrix4(i),fn.multiplyScalar(1/fn.w),fn.x*=o.x/2,fn.y*=o.y/2,fn.z=0,pn.copy(fn),mn.multiplyMatrices(n.matrixWorldInverse,a);for(let n=0,s=u;n<s;n++){if(un.fromBufferAttribute(c,n),dn.fromBufferAttribute(l,n),un.w=1,dn.w=1,un.applyMatrix4(mn),dn.applyMatrix4(mn),un.z>d&&dn.z>d)continue;if(un.z>d){let e=un.z-dn.z,t=(un.z-d)/e;un.lerp(dn,t)}else if(dn.z>d){let e=dn.z-un.z,t=(dn.z-d)/e;dn.lerp(un,t)}un.applyMatrix4(i),dn.applyMatrix4(i),un.multiplyScalar(1/un.w),dn.multiplyScalar(1/dn.w),un.x*=o.x/2,un.y*=o.y/2,dn.x*=o.x/2,dn.y*=o.y/2,hn.start.copy(un),hn.start.z=0,hn.end.copy(dn),hn.end.z=0;let s=hn.closestPointToPointParameter(pn,!0);hn.at(s,gn);let u=e.MathUtils.lerp(un.z,dn.z,s),f=u>=-1&&u<=1,p=pn.distanceTo(gn)<Sn*.5;if(f&&p){hn.start.fromBufferAttribute(c,n),hn.end.fromBufferAttribute(l,n),hn.start.applyMatrix4(a),hn.end.applyMatrix4(a);let i=new e.Vector3,o=new e.Vector3;xn.distanceSqToSegment(hn.start,hn.end,o,i),r.push({point:o,pointOnLine:i,distance:xn.origin.distanceTo(o),object:t,face:null,faceIndex:n,uv:null,uv1:null})}}}var En=class extends e.Mesh{constructor(t=new sn,n=new e.Line2NodeMaterial({color:Math.random()*16777215})){super(t,n),this.isLineSegments2=!0,this.type=`LineSegments2`,this._resolution=new e.Vector2}computeLineDistances(){let t=this.geometry,n=t.attributes.instanceStart,r=t.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let e=0,t=0,a=n.count;e<a;e++,t+=2)cn.fromBufferAttribute(n,e),ln.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+cn.distanceTo(ln);let a=new e.InstancedInterleavedBuffer(i,2,1);return t.setAttribute(`instanceDistanceStart`,new e.InterleavedBufferAttribute(a,1,0)),t.setAttribute(`instanceDistanceEnd`,new e.InterleavedBufferAttribute(a,1,1)),this}onBeforeRender(e){e.getViewport(bn),this._resolution.set(bn.z,bn.w)}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this._resolution.x===0||this._resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;xn=e.ray;let a=this.matrixWorld,o=this.geometry;Sn=this.material.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),vn.copy(o.boundingSphere).applyMatrix4(a);let s;if(s=n?Sn*.5:Cn(r,Math.max(r.near,vn.distanceToPoint(xn.origin)),this._resolution),vn.radius+=s,xn.intersectsSphere(vn)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),_n.copy(o.boundingBox).applyMatrix4(a);let c;c=n?Sn*.5:Cn(r,Math.max(r.near,_n.distanceToPoint(xn.origin)),this._resolution),_n.expandByScalar(c),xn.intersectsBox(_n)!==!1&&(n?wn(this,t):Tn(this,r,t))}},Dn=function(){It.call(this),this.isLines2=!0;let t=new Float32Array(300),n=e=>{if(e>t.length){let n=Math.ceil(Math.max(t.length*2,e)/6)*6,r=new Float32Array(n);return r.set(t),t=r,!0}return!1},r=(e,n)=>{for(let r=e;r+2<t.length;r+=3)t[r]=n[0],t[r+1]=n[1],t[r+2]=n[2]},i=e=>{let n=e.geometry,r=n.attributes.instanceDistanceStart,i=n.attributes.instanceStart;if(!r||r.data.array.length!==i.count*2){e.computeLineDistances();return}let a=r.data.array,o=0;for(let e=0;e<i.count;e++){let n=e*6,r=t[n+3]-t[n],i=t[n+4]-t[n+1],s=t[n+5]-t[n+2];a[e*2]=o,o+=Math.sqrt(r*r+i*i+s*s),a[e*2+1]=o}r.data.needsUpdate=!0},a=(e,n)=>{let r=e.geometry.getAttribute(`instanceStart`);n||!r||r.data.array!==t?(e.geometry.setPositions(t),e.computeLineDistances()):(r.data.needsUpdate=!0,i(e),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere()),this.boundingBoxUpdateRequired=!0};this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new sn;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new En(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(e){if(this.requestRender(),e&&e.length){let i=this.getMorph();i||(this.drawRange=0);let o=this.drawRange*3,s=n(o+e.length*3);e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2],this.drawRange++}),i?(s&&r(o,e[0]),a(i,s)):r(o,e[0])}return t},this.getVerticesByFaceIndex=function(e){let t=e*2*3,n=this.getMorph();if(n&&this.drawRange*3>t){let e=n.geometry.getAttribute(`instanceStart`);return[[e.data.array[t],e.data.array[++t],e.data.array[++t]],[e.data.array[++t],e.data.array[++t],e.data.array[++t]]]}return[]},this.editVertices=function(e,n){if(this.requestRender(),e&&e.length){let i=this.getMorph(),o=n+e.length-1;if(!i||0>n||o>=this.drawRange)return;{let o=n*3;e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2]}),r(this.drawRange*3,e[0]),a(i,!1)}}return t},this.addLines=(n,r)=>{if(this.requestRender(),n&&n.length>0){if(this.addVertices(n),!this.getMorph()){let n=new e.Line2NodeMaterial({color:r,linewidth:1,vertexColors:!1,worldUnits:!1});this.createLineSegment(t,n,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};Dn.prototype=Object.create(It.prototype),Dn.prototype.constructor=Dn;var On=0,kn=function(){return`re`+On++},An=function(t,n){let r=t,i=new e.Group;i.matrixAutoUpdate=!1,i.userData=this;let a=[],o=``,s=[],c=n,l=new e.Matrix4,u=3e3;l.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=kn();let d=()=>{c?.invalidate?.()};this.hideAllPrimitives=()=>{a.forEach(e=>e.hideAllPrimitives()),s.forEach(e=>e.setVisibility(!1))},this.showAllPrimitives=()=>{a.forEach(e=>e.showAllPrimitives()),s.forEach(e=>e.setVisibility(!0))},this.setVisibility=e=>{d(),e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{d(),l.set(...e),i.matrix.copy(l),se(i),i.updateMatrixWorld(!0),this.getAllObjects(!0).forEach(e=>{e.boundingBoxUpdateRequired=!0})},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getScene=()=>c,this.getFullSeparatedPath=()=>{let e=[];if(o!==``){e.push(o);for(let t=r;t!==void 0;){let n=t.getName();n!==``&&e.unshift(n),t=t.getParent()}}return e},this.getFullPath=()=>{let e=this.getFullSeparatedPath();if(e.length>0){let t=e.shift();return e.forEach(e=>{t=t.concat(`/`,e)}),t}return``},this.createChild=e=>{d();let t=new An(this,c);return t.setName(e),a.push(t),i.add(t.getGroup()),t},this.getChildWithName=e=>{if(e){let t=e.toLowerCase();for(let e=0;e<a.length;e++)if(a[e].getName().toLowerCase()===t)return a[e]}},this.findChildFromSeparatedPath=e=>{if(e&&e.length>0&&e[0]===``&&e.shift(),e&&e.length>0){let t=this.getChildWithName(e[0]);return t?(e.shift(),t.findChildFromSeparatedPath(e)):void 0}return this},this.findChildFromPath=e=>{let t=e.split(`/`);return this.findChildFromSeparatedPath(t)},this.createChildFromSeparatedPath=e=>{if(e.length>0&&e[0]===``&&e.shift(),e.length>0){let t=this.getChildWithName(e[0]);return t||=this.createChild(e[0]),e.shift(),t.createChildFromSeparatedPath(e)}return this},this.createChildFromPath=e=>{let t=e.split(`/`);return this.createChildFromSeparatedPath(t)},this.findOrCreateChildFromPath=e=>{let t=this.findChildFromPath(e);return t||=this.createChildFromPath(e),t},this.addZincObject=e=>{d(),e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{d();for(let t=0;t<s.length;t++)if(e===s[t]){i.remove(e.getGroup()),s.splice(t,1),c&&c.triggerObjectRemovedCallback(e),e.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=e=>{if(this.pickableUpdateRequired)return!0;if(e){let t=!1;for(let n=0;n<a.length;n++)if(t=a[n].checkPickableUpdateRequred(e),t)return!0}return!1},this.clearPickableUpdateRequired=e=>{this.pickableUpdateRequired=!1,e&&a.forEach(t=>{t.clearPickableUpdateRequired(e)})},this.getPickableThreeJSObjects=(e,t)=>(i.visible?(s.forEach(t=>{if(t.isPickable&&t.getGroup()&&t.getGroup().visible){let n=t.marker;n&&n.isEnabled()&&e.push(n.getMorph()),e.push(t.getGroup())}}),t&&a.forEach(n=>{n.getPickableThreeJSObjects(e,t)}),this.pickableUpdateRequired=!1):this.clearPickableUpdateRequired(t),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=t=>{let n=new e.Box3;if(this.accumulateBoundingBox(n,t))return n},this.accumulateBoundingBox=(e,t)=>{let n=!1;for(let t=0;t<s.length;t++){let r=s[t].getBoundingBox();r&&(e.union(r),n=!0)}if(t)for(let r=0;r<a.length;r++)a[r].accumulateBoundingBox(e,t)&&(n=!0);return n},this.clear=e=>{d(),e&&a.forEach(t=>{t.clear(e),i.remove(t.getGroup())}),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),e&&(a=[]),s=[]},this.objectIsInRegion=(e,t)=>{for(let t=0;t<s.length;t++)if(e===s[t])return!0;if(t){for(let n=0;n<a.length;n++)if(a[n].objectIsInRegion(e,t))return!0}return!1},this.forEachGeometry=(e,t)=>{s.forEach(t=>{t.isGeometry&&e(t)}),t&&a.forEach(n=>n.forEachGeometry(e,t))},this.forEachGlyphset=(e,t)=>{s.forEach(t=>{t.isGlyphset&&e(t)}),t&&a.forEach(n=>n.forEachGlyphset(e,t))},this.forEachPointset=(e,t)=>{s.forEach(t=>{t.isPointset&&e(t)}),t&&a.forEach(n=>n.forEachPointset(e,t))},this.forEachLine=(e,t)=>{s.forEach(t=>{t.isLines&&e(t)}),t&&a.forEach(n=>n.forEachLine(e,t))},this.findObjectsWithAnatomicalId=(e,t)=>{let n=[];return s.forEach(t=>{t.anatomicalId===e&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithAnatomicalId(e,t);n.push(...i)}),n},this.findObjectsWithGroupName=(e,t)=>{let n=[];return s.forEach(t=>{(t.groupName?t.groupName.toLowerCase():t.groupName)===(e&&e.toLowerCase())&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithGroupName(e,t);n.push(...i)}),n},this.findGeometriesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGeometry),this.findPointsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isPointset),this.findGlyphsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGlyphset),this.findLinesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isLines),this.getAllObjects=(e,t=[])=>{for(let e=0;e<s.length;e++)t.push(s[e]);if(e)for(let n=0;n<a.length;n++)a[n].getAllObjects(e,t);return t},this.getChildRegions=e=>{let t=[...a];return e&&a.forEach(n=>{let r=n.getChildRegions(e);t.push(...r)}),t},this.getCurrentTime=()=>{if(s[0]!=null)return s[0].getCurrentTime();for(let e=0;e<a.length;e++){let t=a[e].getCurrentTime();if(t!==-1)return t}return-1},this.setMorphTime=(e,t)=>{s.forEach(t=>{t.setMorphTime(e)}),t&&a.forEach(n=>{n.setMorphTime(e,t)})},this.isTimeVarying=()=>{for(let e=0;e<s.length;e++)if(s[e].isTimeVarying())return!0;for(let e=0;e<a.length;e++)if(a[e].isTimeVarying())return!0;return!1},this.renderObjects=(e,t,n,r,i)=>{for(let i=0;i<s.length;i++)s[i].render(e,t,n,r);if(i)for(let o=0;o<a.length;o++)a[o].renderObjects(e,t,n,r,i)},this.renderGeometries=(e,t,n,r,i,a)=>{this.renderObjects(e*t,n,r,i,a),i&&n===!1&&i.markerCluster?.markerUpdateRequired&&i.markerCluster.calculate()},this.createPoints=(e,t,n,r)=>{let i=!1,a=this.findObjectsWithGroupName(e,!1),o=a.findIndex(e=>e.isPointset),s=o>-1?a[o]:new Ft;return s.addPoints(t,n,r),o===-1?(s.setName(e),this.addZincObject(s),i=!0):this.pickableUpdateRequired=!0,{zincObject:s,isNew:i}},this.createLines=(e,t,n)=>{let r=!1,i=this.findObjectsWithGroupName(e,!1),a=i.findIndex(e=>e.isLines),o=a>-1?i[a]:new Dn;return o.addLines(t,n),a===-1?(o.setName(e),this.addZincObject(o),r=!0):this.pickableUpdateRequired=!0,{zincObject:o,isNew:r}},this.createGeometryFromThreeJSGeometry=(t,n,r,i,a,o)=>{let s=new $e,c=new e.MeshPhongMaterial({color:r,transparent:!0,opacity:i,side:e.DoubleSide});if(s.createMesh(n,c,{localTimeEnabled:!1,localMorphColour:!1}),s.getMorph())return s.setVisibility(!1),s.setName(t),s.setRenderOrder(o),this.addZincObject(s),s}},jn=class{constructor(e){this.writer=e,this.name=`ZINC_morph_colour`}writeMesh(t,n){let r=t.geometry,i=r&&r.morphAttributes?r.morphAttributes.color:void 0,a=r?r.attributes.color:void 0,o=n.primitives?n.primitives[0]:void 0;if(!i||!a||!o||!o.targets)return;let s=o.targets,c=a.itemSize,l=a.count;for(let t=0;t<s.length&&t<i.length;t++){let n=i[t];if(n.itemSize!==c||n.count<l){console.warn(`GLTFExporter: Colour morph target does not match the base colour, skipped.`);return}let o=new Float32Array(l*c);for(let e=0;e<l;e++)for(let t=0;t<c;t++){let i=n.getComponent(e,t);o[e*c+t]=r.morphTargetsRelative?i:i-a.getComponent(e,t)}s[t].COLOR_0=this.writer.processAccessor(new e.BufferAttribute(o,c),r)}}},Mn=function(e){let t=e,n=e=>{for(let t=e;t;t=t.parent)if(t.visible===!1)return!1;return!0};this.exportGLTF=async e=>{let r=t.getRootRegion().getAllObjects(!0),a=[],o=[];for(let e of r){if(e.animationClip&&e.animationClip[0]){let t=e.getMorph();if(t&&n(t)){let n=e.animationClip[0].clone();n.tracks.forEach(e=>{e.name=t.uuid+e.name}),a.push(n)}}e.isGlyphset&&e.prepareColorForExport&&(await e.prepareColorForExport(),o.push(e))}let s=be(t.getThreeJSScene()),c=new i.GLTFExporter;c.register(e=>new jn(e));let l={binary:e,animations:a,onlyVisible:!0};try{return await new Promise((e,n)=>{c.parse(t.getThreeJSScene(),function(t){e(t)},function(e){console.error(`Unable to export GLTF.`,e),n(e)},l)})}finally{s(),o.forEach(e=>e.clearColorExportState())}}},Nn=function(){let e=this,t=e=>{let t=e.geometry;if(!t||!t.morphAttributes)return;let n=[];if(e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let e in t.morphAttributes){let r=t.attributes[e];t.morphAttributes[e].forEach((e,i)=>{if(t.morphTargetsRelative&&r){let t=e.array,n=r.array,i=Math.min(t.length,n.length);for(let e=0;e<i;e++)t[e]+=n[e];e.needsUpdate=!0}n[i]!==void 0&&(e.name=n[i])})}t.morphTargetsRelative=!1},n=e=>{let t=e=>(e.vertexColors=!1,Oe(e));e.material=Array.isArray(e.material)?e.material.map(t):t(e.material)};this.parseGLTFObjects=(r,i,a,o)=>{let s=i;if(a!==0){if(r.type===`Object3D`){if(r.name!==``&&(i&&(s=i.findOrCreateChildFromPath(r.name)),s)){let e=s.getGroup();e.position.copy(r.position),e.rotation.copy(r.rotation),e.quaternion.copy(r.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(r.type===`Mesh`?e=new $e:r.type===`LineSegments`?e=new It:r.type===`Points`&&(e=new Ft),e){let a=!1,s=!1;r.geometry&&r.geometry.morphAttributes&&(t(r),a=!!r.geometry.morphAttributes.position,s=!!r.geometry.morphAttributes.color);let c=r.clone();s&&!e.isPointset&&n(c),e.setMesh(c,a,s);let l=e.getMorph();e.groupName=l.name,l.matrixAutoUpdate=!0,i.addZincObject(e),o!=null&&typeof o==`function`&&o(e)}}}a++,r.children.forEach(t=>{e.parseGLTFObjects(t,s,a,o)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,r,i,o,s,c)=>{let l=r.substring(0,r.lastIndexOf(`/`)+1),u=r.substring(r.lastIndexOf(`/`)+1,r.length);new a.GLTFLoader().setPath(l).load(u,function(r){c&&c()||(console.log(r),e.parseGLTFObjects(r.scene,n,0,i),e.setCamera(t),o!=null&&typeof o==`function`&&o())})}},Pn=/^[og]\s*(.+)?/,Fn=/^mtllib /,In=/^usemtl /,Ln=/^usemap /,Rn=new e.Vector3,zn=new e.Vector3,Bn=new e.Vector3,Vn=new e.Vector3,Hn=new e.Vector3;function Un(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;Rn.fromArray(r,e),zn.fromArray(r,t),Bn.fromArray(r,n),Hn.subVectors(Bn,zn),Vn.subVectors(Rn,zn),Hn.cross(Vn),Hn.normalize(),i.push(Hn.x,Hn.y,Hn.z),i.push(Hn.x,Hn.y,Hn.z),i.push(Hn.x,Hn.y,Hn.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var Wn=class extends e.Loader{constructor(e){super(e),this.materials=null}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}setMaterials(e){return this.materials=e,this}parse(t){let n=new Un;t.indexOf(`\r
556
556
  `)!==-1&&(t=t.replace(/\r\n/g,`
557
557
  `)),t.indexOf(`\\
558
558
  `)!==-1&&(t=t.replace(/\\\n/g,``));let r=t.split(`
559
- `),i=``,a=``,o=0,s=[],c=typeof``.trimLeft==`function`;for(let e=0,t=r.length;e<t;e++)if(i=r[e],i=c?i.trimLeft():i.trim(),o=i.length,o!==0&&(a=i.charAt(0),a!==`#`)){if(a===`v`){let e=i.split(/\s+/);switch(e[0]){case`v`:n.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?n.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):n.colors.push(void 0,void 0,void 0);break;case`vn`:n.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:n.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(a===`f`){let e=i.substr(1).trim().split(/\s+/),t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.length>0){let e=r.split(`/`);t.push(e)}}let r=t[0];for(let e=1,i=t.length-1;e<i;e++){let i=t[e],a=t[e+1];n.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a===`l`){let e=i.substring(1).trim().split(` `),t=[],r=[];if(i.indexOf(`/`)===-1)t=e;else for(let n=0,i=e.length;n<i;n++){let i=e[n].split(`/`);i[0]!==``&&t.push(i[0]),i[1]!==``&&r.push(i[1])}n.addLineGeometry(t,r)}else if(a===`p`){let e=i.substr(1).trim().split(` `);n.addPointGeometry(e)}else if((s=Pn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(In.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(Fn.test(i))n.materialLibraries.push(i.substring(7).trim());else if(Ln.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(s=i.split(` `),s.length>1){let e=s[1].trim().toLowerCase();n.object.smooth=e!==`0`&&e!==`off`}else n.object.smooth=!0;let e=n.object.currentMaterial();e&&(e.smooth=n.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}n.finalize();let l=new e.Group;if(l.materialLibraries=[].concat(n.materialLibraries),n.objects.length!==1||n.objects[0].geometry.vertices.length!==0)for(let t=0,r=n.objects.length;t<r;t++){let r=n.objects[t],i=r.geometry,a=r.materials,o=i.type===`Line`,s=i.type===`Points`,c=!1;if(i.vertices.length===0)continue;let u=new e.BufferGeometry;u.setAttribute(`position`,new e.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&u.setAttribute(`normal`,new e.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(c=!0,u.setAttribute(`color`,new e.Float32BufferAttribute(i.colors,3))),i.hasUVIndices===!0&&u.setAttribute(`uv`,new e.Float32BufferAttribute(i.uvs,2));let d=[];for(let t=0,r=a.length;t<r;t++){let r=a[t],i=r.name+`_`+r.smooth+`_`+c,l=n.materials[i];if(this.materials!==null){if(l=this.materials.create(r.name),o&&l&&!(l instanceof e.LineBasicMaterial)){let t=new e.LineBasicMaterial;e.Material.prototype.copy.call(t,l),t.color.copy(l.color),l=t}else if(s&&l&&!(l instanceof e.PointsMaterial)){let t=new e.PointsMaterial({size:10,sizeAttenuation:!1});e.Material.prototype.copy.call(t,l),t.color.copy(l.color),t.map=l.map,l=t}}l===void 0&&(l=o?new e.LineBasicMaterial:s?new e.PointsMaterial({size:1,sizeAttenuation:!1}):new e.MeshPhongMaterial,l.name=r.name,l.flatShading=!r.smooth,l.vertexColors=c,n.materials[i]=l),d.push(l)}let f;if(d.length>1){for(let e=0,t=a.length;e<t;e++){let t=a[e];u.addGroup(t.groupStart,t.groupCount,e)}f=o?new e.LineSegments(u,d):s?new e.Points(u,d):new e.Mesh(u,d)}else f=o?new e.LineSegments(u,d[0]):s?new e.Points(u,d[0]):new e.Mesh(u,d[0]);f.name=r.name,l.add(f)}else if(n.vertices.length>0){let t=new e.PointsMaterial({size:1,sizeAttenuation:!1}),r=new e.BufferGeometry;r.setAttribute(`position`,new e.Float32BufferAttribute(n.vertices,3)),n.colors.length>0&&n.colors[0]!==void 0&&(r.setAttribute(`color`,new e.Float32BufferAttribute(n.colors,3)),t.vertexColors=!0);let i=new e.Points(r,t);l.add(i)}return l}},Gn=e.FileLoader,Kn=e=>{let t=(e,t)=>{if(e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&t.labels){let n=t.labels;for(let t=0;t<n.length;t++)e.labels.push(n[t])}[`axis1`,`axis2`,`axis3`,`colors`,`positions`,`scale`].forEach(n=>{n in e&&Object.keys(e[n]).forEach(r=>{let i=t[n][r].length;for(let a=0;a<i;a++)e[n][r].push(t[n][r][a])})})};if(e&&e.length>0)for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}},qn=e=>{if(e&&e.length>0){if(e.length===1)return e[0];let t=ge(e);return e.forEach(e=>e.dispose()),t}},Jn=function(e,t,n,r){let i=new Gn,a=new dt;i.crossOrigin=t;let o=e,s=n,c=r,l,u=!1,d=!1,f,p=[],m=e=>{let t=l[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=a.parse(t);e.onLoad(n.geometry,n.materials)}}else h(e,{responseURL:o})},h=e=>{e.onError&&(f||={responseURL:o},e.onError(f))};this.downloadCompleted=e=>{try{l=JSON.parse(e[0]),u=!1,d=!0,Array.isArray(l)?p.forEach(e=>m(e)):p.forEach(e=>h(e))}catch{p.forEach(e=>h(e))}};let g=()=>e=>{f=e,d=!0,u=!1,p.forEach(e=>{h(e)}),c&&c(e)},_=()=>e=>{p.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,r)=>{let a={index:e,onLoad:t,onProgress:n,onError:r};d?l?m(a):h(a):u?p.push(a):(p.push(a),u=!0,i.load(o,s,_(),g()))}},Yn=function(e,t,n,r){let i=[],a=e,o=t,s=n,c=0,l,u=r?.isGlyphsets,d=()=>{u||i.forEach(e=>{e&&(e[0]?.dispose?.(),e[1]?.forEach(e=>e.dispose()))}),s&&s(...l)};this.itemFailed=(e,t)=>{l||=t,c++,c==a&&d()},this.itemDownloaded=(e,t)=>{if(i[e]=t,c++,c==a){if(l)d();else if(i.length>0){if(u){let e=i.map(e=>JSON.parse(e[0]));Kn(e),o(e[0])}else{let e=i[0][1],t=qn(i.map(e=>e[0]));for(let e=1;e<a;e++)i[e][1]?.forEach(e=>e.dispose());o(t,e)}}}}},Xn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new dt,n=new Gn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new Yn(a,t,r,i),c=0;e.forEach(e=>{let a=i?{...i}:{};a.msHandler=o,a.order=c,c++,s(e,t,n,r,a)})},o=(t,n,a,o,s)=>{let l=s?{...s}:{},u=i[t];if(!u){if(20>e){let n=new c(void 0,this,l),r=new c(void 0,this,{});++e,u=new Jn(t,this.crossOrigin,n,r),i[t]=u}else r.push({url:t,onLoad:n,onProgress:a,onError:o,options:s})}u&&(l.isHandler=u,u.load(s.index,n,a,o))},s=(i,a,s,l,u)=>{if(u&&u.index!==void 0)o(i,a,s,l,u);else if(20>e){++e;let r=new c(a,this,u),o=new c(l,this,u,!0);u?.isGlyphsets?n.load(i,r,s,o):(t.crossOrigin=this.crossOrigin,t.load(i,r,s,o))}else r.push({url:i,onLoad:a,onProgress:s,onError:l,options:u})};this.load=(e,t,n,r,i)=>{Array.isArray(e)?a(e,t,n,r,i):s(e,t,n,r,i)},this.loadFromWaitingList=()=>{for(;20>e;){let e=r.shift();if(e)this.load(e.url,e.onLoad,e.onProgress,e.onError,e.options);else return}},this.itemRemainingCheck=()=>{if(r.length===0&&e===0)for(let e in i)i.hasOwnProperty(e)&&delete i[e]};let c=function(t,n,r,i=!1){return(...a)=>{--e,r?.msHandler?i?r.msHandler.itemFailed(r.order,a):r.msHandler.itemDownloaded(r.order,a):r?.isHandler?r.isHandler.downloadCompleted(a):t&&t(...a),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>t.parse(e)},Zn=class extends e.Loader{constructor(e){super(e)}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}parse(t){function n(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let n=[115,111,108,105,100];for(let e=0;e<5;e++)if(r(n,t,e))return!1;return!0}function r(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r,!1))return!1;return!0}function i(t){let n=new DataView(t),r=n.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)n.getUint32(e,!1)==1129270351&&n.getUint8(e+4)==82&&n.getUint8(e+5)==61&&(s=!0,c=new Float32Array(r*3*3),l=n.getUint8(e+6)/255,u=n.getUint8(e+7)/255,d=n.getUint8(e+8)/255,f=n.getUint8(e+9)/255);let p=new e.BufferGeometry,m=new Float32Array(r*3*3),h=new Float32Array(r*3*3);for(let e=0;e<r;e++){let t=84+e*50,r=n.getFloat32(t,!0),f=n.getFloat32(t+4,!0),p=n.getFloat32(t+8,!0);if(s){let e=n.getUint16(t+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=t+l*12,d=e*3*3+(l-1)*3;m[d]=n.getFloat32(u,!0),m[d+1]=n.getFloat32(u+4,!0),m[d+2]=n.getFloat32(u+8,!0),h[d]=r,h[d+1]=f,h[d+2]=p,s&&(c[d]=i,c[d+1]=a,c[d+2]=o)}}return p.setAttribute(`position`,new e.BufferAttribute(m,3)),p.setAttribute(`normal`,new e.BufferAttribute(h,3)),s&&(p.setAttribute(`color`,new e.BufferAttribute(c,3)),p.hasColors=!0,p.alpha=f),p}function a(t){let n=new e.BufferGeometry,r=/solid([\s\S]*?)endsolid/g,i=/facet([\s\S]*?)endfacet/g,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=new e.Vector3,f,p=0,m=0,h=0;for(;(f=r.exec(t))!==null;){m=h;let e=f[0];for(;(f=i.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=c.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=s.exec(n))!==null;)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let t=m,r=h-m;n.addGroup(t,r,p),p++}return n.setAttribute(`position`,new e.Float32BufferAttribute(l,3)),n.setAttribute(`normal`,new e.Float32BufferAttribute(u,3)),n}function o(t){return typeof t==`string`?t:e.LoaderUtils.decodeText(new Uint8Array(t))}function s(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let c=s(t);return n(c)?i(c):a(o(t))}},Qn=function(){Xe.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,a,o)=>{if(n&&a){t={geometryIn:n,materialIn:a,options:o};let s=i(r(n)),c=new e.MeshStandardMaterial({color:a.color}),l=new e.Mesh(s,c);this.setMesh(l,o.localTimeEnabled,o.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){this.requestRender();let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{this.requestRender();let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,a)=>{if(this.requestRender(),e&&a){let{geometryIn:o}=t,s=this.getMorph();s.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:a}),s.geometry=i(r(o))}};let r=t=>{let n=t.getAttribute(`position`),r=[];for(let t=0;t<n.count;t++)r.push(new e.Vector3().fromBufferAttribute(n,t));return r},i=t=>{let{radius:r,radialSegments:i,smooth:a}=n,o;if(a){let n=new e.CatmullRomCurve3(t);o=new e.TubeGeometry(n,t.length,r,i,!1)}else{let n=[];for(let a=0;a+1<t.length;a+=2){let o=new e.LineCurve3(t[a],t[a+1]),s=new e.TubeGeometry(o,1,r,i,!1);n.push(s)}o=ge(n,!0),n.forEach(e=>e.dispose())}return o}};Qn.prototype=Object.create(Xe.prototype);var $n=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=0,o=new Xn;this.cancelPendingLoads=()=>{a++,this.toBeDownloaded=0,this.progressMap={},r=!1,i=!1};let s=()=>{let e=a;return()=>e!==a};this.getDownloadProgress=()=>{let e=0,t=0,n=!1;for(let r in this.progressMap){let i=this.progressMap[r];e+=i[1],t+=i[0],i[1]==0&&(n=!0)}return n&&(e=0),[e,t,i]},this.onProgress=e=>t=>{this.progressMap[e]=[t.loaded,t.total]},this.onError=e=>{let t=s();return n=>{t()||(--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${n?.responseURL?`: `+n?.responseURL:``}.`),e&&e({type:`Error`,xhr:n}))}};let c=(e,t)=>{let i=t.Default;if(t.Inline)n.setupMultipleViews(i,t.Entries);else{let a=[];for(let[n,r]of Object.entries(t.Entries))if(e){let t=oe(r,e);a.push(new Promise((e,r)=>{fetch(t).then(e=>e.json()).then(t=>e({key:n,data:t})).catch(e=>r(e))}))}Promise.all(a).then(e=>{let t={};e.forEach(e=>{t[e.key]=e.data}),n.setupMultipleViews(i,t);let a=n.getZincCameraControls();a&&a.setCurrentViewport(i),r=!0})}};this.loadViewURL=(e,t)=>{this.toBeDownloaded+=1;let i=e,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{a()||(n.setupMultipleViews(`default`,{default:e}),n.resetView(),r=!0,--this.toBeDownloaded,t!==void 0&&typeof t==`function`&&t())}).catch(e=>{console.error(`Fetch failed for URL: ${i}`,e),this.onError(t)({responseURL:i})})},this.loadModelsURL=(e,t,n,r,i,a,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=Ar.defaultMaterialColor,d=Ar.defaultOpacity;n!=null&&n[l]!=null&&(u=!!n[l]),r!=null&&r[l]!=null&&(d=r[l]);let f=0;i!=null&&i[l]!=null&&(f=!!i[l]);let p=!1;a!=null&&a[l]!=null&&(p=!!a[l]),o.load(c,g(e,u,d,f,p,void 0,void 0,void 0,void 0,s),this.onProgress(c),this.onError(s))}},this.loadFromViewURL=(e,t,r)=>{let i=t+`_view.json`,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{if(a())return;n.loadView(i);let o=[],s=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=s+(e+1)+`.json`;o.push(t)}this.loadModelsURL(e,o,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let l=(t,r,i,a,c,l,u,d,f)=>{let p=s();return(s,m)=>{if(p()){s.dispose();return}let h=d?new Qn:new It,g;m&&m[0]&&(g=new e.LineBasicMaterial({color:m[0].color.clone()}),1>m[0].opacity&&(g.transparent=!0),g.opacity=m[0].opacity,g.vertexColors=m[0].vertexColors);let _={};if(_.localTimeEnabled=r,_.localMorphColour=i,h&&(h.createLineSegment(s,g,_),h.setName(a),h.setAnatomicalId(c),h.setRenderOrder(l),t.addZincObject(h),h.setDuration(n.getDuration()),u&&u.levels))for(let[e,t]of Object.entries(u.levels))h.addLOD(o,e,t.URL,t.Index,u.preload);--this.toBeDownloaded,s.dispose(),f!=null&&typeof f==`function`&&f(h)}};this.loadLinesURL=(e,t,n,r,i,a,s)=>{let c=0;this.toBeDownloaded+=1;let u=s?.isInline?s.isInline:!1,d=s?.anatomicalId?s.anatomicalId:void 0,f=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(c=!!n);let p=0;r!=null&&(p=!!r);let m=s.tubeLines&&!c&&!p;if(u){let n=o.parse(t);l(e,c,p,i,d,f,s.lod,m,a)(n.geometry,n.materials)}else o.load(t,l(e,c,p,i,d,f,s.lod,m,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let u=(e,t,r,i,a)=>{let o=s();return s=>{if(o())return;let c=s;(typeof c==`string`||c instanceof String)&&(c=JSON.parse(s));let l=a&&a.isInline?a.isInline:void 0,u=a&&a.anatomicalId?a.anatomicalId:void 0,d=a?.displayLabels;d===void 0&&(d=!0);let f=a&&`renderOrder`in a?a.renderOrder:void 0,p=new Ct;p.setDuration(n.getDuration()),p.groupName=r,++this.toBeDownloaded,p.load(c,t,()=>{o()||(--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(p))},l,d),p.setAnatomicalId(u),p.setRenderOrder(f),e.addZincObject(p)}};this.loadGlyphsetURL=(e,t,n,r,i,a)=>{a&&a.isInline&&a.isInline?u(e,n,r,i,a)(t):o.load(t,u(e,n,r,i,a),this.onProgress(t),this.onError(i),a.loaderOptions)};let d=(t,r,i,a,o,c,l)=>{let u=s();return(s,d)=>{if(u()){s.dispose();return}let f=new Ft,p=new e.PointsMaterial({alphaTest:.05,size:10,sizeAttenuation:!1});d&&d[0]&&(1>d[0].opacity&&(p.transparent=!0),p.opacity=d[0].opacity,p.color=d[0].color,p.vertexColors=!1);let m={};m.localTimeEnabled=r,m.localMorphColour=i,f&&(f.createMesh(s,p,m),f.setName(a),f.setAnatomicalId(o),t.addZincObject(f),f.setDuration(n.getDuration()),f.setRenderOrder(c)),s.dispose(),--this.toBeDownloaded,l!=null&&typeof l==`function`&&l(f)}};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=Ar.defaultMaterialColor,a=Ar.defaultOpacity,o=new Zn;o.crossOrigin=`Anonymous`,o.load(t,g(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=Ar.defaultMaterialColor,a=Ar.defaultOpacity,o=new Wn;o.crossOrigin=`Anonymous`,o.load(t,_(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))};let f=(e,t,n,r,i,a,s)=>{this.toBeDownloaded+=1;let c=Ar.defaultMaterialColor,l=Ar.defaultOpacity,u=0,d=s&&s.isInline?s.isInline:!1,f=s&&s.fileFormat?s.fileFormat:void 0,p=s&&s.anatomicalId?s.anatomicalId:void 0,m=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let h=0;r!=null&&(h=!!r);let v=o;if(f==`STL`||f==`OBJ`){let n=f==`STL`?g:_;v=f==`STL`?new Zn:new Wn,v.crossOrigin=`Anonymous`,v.load(t,n(e,c,l,u,h,i,p,m,s||{},a),this.onProgress(t),this.onError(a));return}if(d){let n=o.parse(t);g(e,c,l,u,h,i,p,m,s,a)(n.geometry,n.materials)}else v.crossOrigin=`Anonymous`,o.load(t,g(e,c,l,u,h,i,p,m,s,a),this.onProgress(t),this.onError(a),s.loaderOptions)},p=function(e,t,i){let a=0;return o=>{if(a+=1,o&&t!=null&&typeof t==`function`&&t(o),a==e&&(r===!1&&n.viewAll(),i!=null&&typeof i==`function`)){i();let e=n.getZincCameraControls();e&&e.calculateMaxAllowedDistance(n)}}};this.loadPointsetURL=(e,t,n,r,i,a,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let l=0;r!=null&&(l=!!r);let u=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(u){let n=o.parse(t);d(e,c,l,i,f,p,a)(n.geometry,n.materials)}else o.load(t,d(e,c,l,i,f,p,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let m=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,c=a&&a.anatomicalId?a.anatomicalId:void 0,l=a&&`renderOrder`in a?a.renderOrder:void 0,u;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=oe(e[r],t);n.images.source[r]=i}}if(n.type===`slides`&&(u=new Ht),u){u.groupName=r;let t=s();++this.toBeDownloaded,u.load(n,()=>{if(t()){u.dispose();return}e.addZincObject(u),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(u)},o),u.setAnatomicalId(c),u.setRenderOrder(l)}}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)m(e,void 0,t,n,r,i);else{let a=t,o=s();fetch(a).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(a).href;return e.json().then(e=>({textureData:e,referenceURL:t}))}).then(({textureData:t,referenceURL:a})=>{o()||m(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let h=(e,t,r,i,a,o,s,c,l,u,d)=>{let f={};f.colour=r,f.opacity=i,f.localTimeEnabled=a,f.localMorphColour=o;let p=new $e;if(p.createMesh(t,c,f),p.getMorph())return p.setName(l),p.setRenderOrder(u),p.setAnatomicalId(d),e&&e.addZincObject(p),p.setDuration(n.getDuration()),s!=null&&typeof s==`function`&&s(p),p.videoHandler&&n.setVideoHandler(p.videoHandler),p},g=(e,t,n,r,i,a,c,l,u,d)=>{let f=s();return(s,p)=>{if(f()){s.dispose();return}let m;p&&p[0]&&(m=p[0]);let g=h(e,s,t,n,r,i,void 0,m,a,l,c);if(u?.lod?.levels)for(let[e,t]of Object.entries(u.lod.levels))g.addLOD(o,e,t.URL,t.Index,u.lod.preload);--this.toBeDownloaded,s.dispose(),d!=null&&typeof d==`function`&&d(g)}},_=(e,t,n,r,i,a,o,c,l,u)=>{let d=s(),f=g(e,t,n,r,i,a,o,c,l,u);return e=>{let t=[];if(e.traverse(e=>{e.isMesh&&e.geometry&&t.push(e),e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>e.dispose())}),d()){t.forEach(e=>e.geometry.dispose());return}if(t.length===0){--this.toBeDownloaded;return}this.toBeDownloaded+=t.length-1,t.forEach(e=>f(e.geometry))}},v=e=>{let[,t,n,r,i,a,o,s]=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);return{years:t,months:n,weeks:r,days:i,hours:a,mins:o,secs:s}};this.loadSettings=e=>{if(e){if(e.Duration){let t=v(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=v(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=v(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let y=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=oe(a,t))):n.Inline&&(a=n.Inline.URL,o=!0);let s={};if(n.LOD&&n.LOD.Levels){s.preload=!!n.LOD.Preload,s.levels={};for(let[e,r]of Object.entries(n.LOD.Levels))s.levels[e]={},s.levels[e].URL=oe(r.URL,t),s.levels[e].Index=r.Index}let c=n.GroupName;(c===void 0||c===``)&&(c=`_Unnamed`);let l={loaderOptions:{index:n.Index},isInline:o,fileFormat:n.FileFormat,anatomicalId:n.AnatomicalId,compression:n.compression,tubeLines:n.tubeLines,lod:s,renderOrder:r};switch(n.Type){case`Surfaces`:f(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=oe(n.GlyphGeometriesURL,t)),l.displayLabels=n.DisplayLabels,l.displayLabels===void 0&&(l.displayLabels=!0),l.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(e,a,r,c,i,l);break;case`Points`:this.loadPointsetURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Lines`:this.loadLinesURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Texture`:this.loadTextureURL(e,a,c,i,l)}}},b=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=oe(t.URL,e))):t.Inline&&(a=t.Inline.URL,o=!0),t.Type){case`View`:o?(n.setupMultipleViews(`default`,{default:a}),r=!0,i!=null&&typeof i==`function`&&i()):this.loadViewURL(a,i);break;case`Settings`:this.loadSettings(t)}}};this.loadGLTF=(e,t,r,i,a)=>{new Nn().load(n,e,t,r,i,a,s())};let x=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),y(e,t,n,i,r)}),n.Transformation&&e.setTransformation(n.Transformation),n.Children)for(let[i,a]of Object.entries(n.Children)){let n=e.findOrCreateChildFromPath(i);n&&x(n,t,a,r)}},S=(e,t)=>{let n=e,r=t?.enabled?.include,i=t?.enabled?.exclude,a=t?.tubeLines;return(r?.length||i?.length)&&(r&&(n=e.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<r.length;t++)if(we(e.RegionPath,e.GroupName,r[t]))return!0;return!1})),i&&(n=n.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<i.length;t++)if(we(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},C=(e,t)=>Array.isArray(e)?S(e,t):e,w=(e,t)=>{if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++)e[r].Type&&(t&&e[r].Type===`View`||e[r].Type===`Surfaces`||e[r].Type===`Glyph`||e[r].Type===`Points`||e[r].Type===`Lines`||e[r].Type===`Texture`)&&n++;return n}return 0},T=e=>{let t=e.Primitives?w(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=T(e)}),t},E=e=>{if(Array.isArray(e))return w(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return T(e.Regions)},D=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),y(a,t,n,r*2,i)},O=(e,t,n,r,i,a)=>{let o=C(t,a),s=E(o),c=new p(s,r,i);for(let e=0;e<o.length;e++)b(n,o[e],c);for(let t=0;t<o.length;t++)D(e,n,o[t],t,c)},k=(e,t,n,r,i)=>{let a=E(t),o=new p(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&c(n,t.Views,n),t.Regions&&x(e,n,t.Regions,o)};this.loadMetadataURL=(e,t,i,a,o)=>{let c=t,l=s();fetch(c).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(c).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{l()||(n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?O(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&k(e,t,s,i,a))}).catch(e=>{console.error(`Fetch failed for URL: ${c}`,e)})}},er=0,tr=function(){return`sc`+er++},nr=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},rr=6e3,ir=function(t,n){let r=t,i,a,o=!0,s=!1,c={},l={displayMarkers:void 0,displayMinimap:void 0,displayMiniAxes:void 0,playAnimation:void 0},u=new $n(this),d,f={},p=0,m={},h=0,g=new e.Scene,_=new e.Scene,v=new An(void 0,this);g.add(v.getGroup());let y=new e.Group;g.add(y),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let b=6e3,x;this.sceneName=void 0;let S=!1,C;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:`top-right`,updateRequired:!0};let w={x:0,y:0},T=nr(),E=new e.Vector2,D=[];this.forcePickableObjectsUpdate=!1,this.uuid=tr();let O=new nn(this);O.disable(),g.add(O.group);let k={main:[],mini:[]},A=new e.Vector3(0,0,0),j=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,M=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>u.getDownloadProgress(),this.onWindowResize=()=>{o=!0;let e=M();this.camera.aspect=j()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,x.onResize(),x.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{o=!0,this.onWindowResize(),x.resetView()},this.changeZoomByScrollRateUnit=e=>{o=!0,x.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,j()/M(),0,10),this.ambient=new e.AmbientLight(16777215,.2),g.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.7*Math.PI),g.add(this.directionalLight),x=new Wt(this.camera,n.domElement,n,this),x.setDirectionalLight(this.directionalLight),x.resetView(),d=new rn(this),this.loadView=e=>{o=!0;let t=new Ut;return t.setFromObject(e),x.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new Ut;t.setFromObject(n),x.addViewport(e,t)}x.setDefaultViewport(e)},this.getBoundingBox=()=>v.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(o=!0,e){let t=x.getViewportFromBoundingBox(e,1);x.setCurrentCameraSettings(t),x.calculateHeightPerPixelAtZeroDepth(M()),O.markerUpdateRequired=!0}},this.viewAll=()=>{o=!0;let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),O.markerUpdateRequired=!0},this.forEachGeometry=e=>{v.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{v.forEachGlyphset(e,!0)},this.forEachPointset=e=>{v.forEachPointset(e,!0)},this.forEachLine=e=>{v.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>v.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>v.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>v.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>v.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>v.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>v.findObjectsWithAnatomicalId(e,!0),this.getBoundingBoxOfZincObjects=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n].getBoundingBox();r&&(t?t.union(r):t=r)}return t},this.vectorToScreenXY=e=>{e.project(this.camera);let t=j(),n=M(),r=t/2,i=n/2;return e.x=e.x*r+r,e.y=-(e.y*i)+i,e},this.getObjectsScreenXY=t=>{if(t&&t.length>0){let n=this.getBoundingBoxOfZincObjects(t),r=new e.Vector3;return n.getCenter(r),this.vectorToScreenXY(r)}},this.getNamedObjectsScreenXY=e=>{let t=this.findObjectsWithGroupName(e);return this.getObjectsScreenXY(t)},this.addZincObject=e=>{o=!0,e&&(v.addZincObject(e),x&&x.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{u.loadGlyphsetURL(v,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{u.loadPointsetURL(v,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{u.loadLinesURL(v,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{u.loadSTL(v,e,t,n)},this.loadOBJ=(e,t,n)=>{u.loadOBJ(v,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{u.loadMetadataURL(v,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{u.loadModelsURL(v.urls,t,n,r,i,a)},this.loadViewURL=e=>{u.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{u.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{u.loadGLTF(v,e,t,n,r)},this.updateDirectionalLight=()=>{o=!0,x.updateDirectionalLight()},this.addObject=e=>{o=!0,g.add(e)},this.removeObject=e=>{o=!0,g.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(b);let e=v.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{o=!0,a?.setMorphTime(e,b),v.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:v.isTimeVarying(),this.renderGeometries=(e,t,n,r)=>{let i=o;o=!1,s=!1;let d=r?r.controls:x,f=c;if(f.camera=d,f.displayMarkers=this.displayMarkers,f.markerCluster=O,f.markersList=O.markers,f.ndcToBeUpdated=r?r.updated:!1,n&&(f.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*b;u.toBeDownloaded==0?(r||(x.setTime(e),f.ndcToBeUpdated=x.update(0),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.setMorphTime(e,!0),v.renderGeometries(0,0,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0)}(n||!a.isReadyToPlay())&&(i=!0)}else u.toBeDownloaded==0?(r||(f.ndcToBeUpdated=x.update(t),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.renderGeometries(e,t,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0);return(l.displayMarkers!==this.displayMarkers||l.displayMinimap!==this.displayMinimap||l.displayMiniAxes!==this.displayMiniAxes||l.playAnimation!==n)&&(l.displayMarkers=this.displayMarkers,l.displayMinimap=this.displayMinimap,l.displayMiniAxes=this.displayMiniAxes,l.playAnimation=n,i=!0),this.minimapScissor.updateRequired&&(this.displayMinimap||this.displayMiniAxes)&&(i=!0),!r&&f.ndcToBeUpdated&&(s=!0),(f.ndcToBeUpdated||n&&this.isTimeVarying()||u.toBeDownloaded>0||O.isEnabled()&&O.markerUpdateRequired)&&(i=!0),o&&=(i=!0,!1),i},this.invalidate=()=>{o=!0},this.isCameraUpdated=()=>s,this.getThreeJSScene=()=>g,this.setVideoHandler=e=>{o=!0,a||=e},this.setAdditionalScenesGroup=e=>{g.add(e)};let N=(e,t,n,r,i,a,o)=>{let s=0,c=0;return c=e.includes(`top`)?o-i-n:e.includes(`bottom`)?n:Math.floor((o-i)/2),s=e.includes(`left`)?t:e.includes(`right`)?a-t-r:Math.floor((a-r)/2),{x:s,y:c}},P=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(E),this.minimapScissor.updateRequired&&(w=N(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,E.x,E.y),this.minimapScissor.updateRequired=!1),e.setScissor(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),d.updateCamera(),this.displayMiniAxes?e.render(_,d.camera):(g.add(d.mask),e.render(g,d.camera),g.remove(d.mask)),e.setScissorTest(!1),e.setViewport(0,0,E.x,E.y))};this.render=e=>{this.autoClearFlag&&e.clear(),S&&C?C.render(g,this.camera):(e.render(g,this.camera),P(e))},this.setInteractiveControlEnable=e=>{e==1?x.enable():x.disable()},this.getZincCameraControls=()=>x,this.getThreeJSScene=()=>g,this.setDuration=e=>{o=!0,v.setDuration(e),b=e,x.setPathDuration(e),u.duration=e},this.getDuration=()=>b,this.setStereoEffectEnable=e=>{o=!0,e==1&&(C||=new Xt(n)),n.setSize(j(),M()),this.camera.updateProjectionMatrix(),S=e},this.objectIsInScene=e=>v.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(o=!0,t){t.getCenter(A);let r=this.getZincCameraControls().getCurrentViewport(),i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(i,a).normalize(),s.subVectors(i,A).normalize();let c=new e.Vector3;c.crossVectors(o,s);let l=o.angleTo(s);n>0?(this.getZincCameraControls().rotateCameraTransition(c,l,n),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(c,l),O.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(e,t,n)=>{if(e){let r=this.getZincCameraControls().getCurrentViewport(),i=this.getZincCameraControls().getViewportFromBoundingBox(e,t);n>0&&(this.getZincCameraControls().cameraTransition(r,i,n),this.getZincCameraControls().enableCameraTransition()),O.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(o=!0,this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(A);let i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(a,i),s.addVectors(A,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=A.x,r.targetPosition[1]=A.y,r.targetPosition[2]=A.z,this.getZincCameraControls().setCurrentCameraSettings(r),O.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>S,this.removeZincObject=e=>{o=!0,v.removeZincObject(e),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{D.length=0,O.isEnabled&&D.push(O.group),v.getPickableThreeJSObjects(D,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||v.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),D),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(w.x+this.minimapScissor.width>n.clientX&&n.clientX>w.x&&w.y+this.minimapScissor.height>i&&i>w.y)return{x:(n.clientX-w.x)/this.minimapScissor.width*2-1,y:(i-w.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(d)return d.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>n?.backend?.isWebGPUBackend===!0,this.getRenderer=()=>n,this.clearAll=()=>{o=!0,O.clear(),v.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),u.cancelPendingLoads(),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{T.TimeStamps[e]=te(t)},this.getMetadataTag=e=>T[e],this.getMetadata=()=>T,this.setMetadataTag=(e,t)=>{T[e]=t},this.removeMetadataTag=e=>{delete T[e]},this.resetMetadata=()=>{T=nr()},this.resetDuration=()=>{this.setDuration(rr)};let ee=e=>[...e.years?[`${e.years}years`]:[],...e.months?[`${e.months}months`]:[],...e.weeks?[`${e.weeks}weeks`]:[],...e.days?[`${e.days}days`]:[],...e.hours?[`${e.hours}hours`]:[],...e.mins?[`${e.mins}mins`]:[],...e.secs?[`${e.secs}secs`]:[]].join(` `),te=e=>e.years?e.years*31536e6:0+e.months?e.months*2592e6:0+e.weeks?e.weeks*6048e5:0+e.days?e.days*864e5:0+e.hours?e.hours*36e5:0+e.mins?e.mins*6e4:0+e.secs?e.secs*1e3:0;this.setDurationFromObject=e=>{let t=ee(e),n=te(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=ee(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new Mn(this).exportGLTF(e),this.getRootRegion=()=>v,this.createLines=(e,t,n,r)=>{let i=v.findChildFromPath(e);return i===void 0&&(i=v.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=v.findChildFromPath(e);return a===void 0&&(a=v.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(p+=1,f[p]=e,p),this.addZincObjectRemovedCallbacks=e=>(h+=1,m[h]=e,h),this.removeZincObjectAddedCallbacks=e=>{e in p&&delete f[e]},this.removeZincObjectRemovedCallbacks=e=>{e in h&&delete m[e]},this.clearZincObjectAddedCallbacks=()=>{f={},p=0},this.clearZincObjectRemovedCallbacks=()=>{m={},h=0},this.triggerObjectAddedCallback=e=>{for(let t in f)f.hasOwnProperty(t)&&f[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in m)m.hasOwnProperty(t)&&m[t](e)},this.addTemporaryPoints=(e,t)=>{o=!0;let n=jt(e.length),r=kt(Se());r.color.set(t),r.size=15,r.userData.uniforms.pointSize.value=15,r.alphaTest=.5;let i=new Dt(n,r,e.length),a=n.getAttribute(`instancePosition`);return i.pointPositions=a.array,e.forEach((e,t)=>{a.setXYZ(t,e[0],e[1],e[2])}),a.needsUpdate=!0,y.add(i),i},this.addTemporaryLines=(t,n)=>{o=!0;let r=new He(_e(t.length,t),new e.LineBasicMaterial({color:n}));return y.add(r),r},this.enableFrustumDisplay=()=>{o=!0,this.camera&&!i&&(i=new e.CameraHelper(this.camera),g.add(i))},this.disableFrustumDisplay=()=>{o=!0,i&&=(g.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{o=!0,y.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{o=!0;let e=0;return y.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),y.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,s=void 0)=>{o=!0;let c=v.findChildFromPath(t);c===void 0&&(c=v.createChildFromPath(t));let l=s||this.getBoundingBox();A.set(0,0,0);let u=A.subVectors(l.max,l.min),d=new e.BoxGeometry(u.x,u.y,u.z),f=c.createGeometryFromThreeJSGeometry(n,d,r,i,a,1e4);return u.addVectors(l.min,l.max).multiplyScalar(.5),f.setPosition(u.x,u.y,u.z),f},this.addSlicesPrimitive=(t,n,r,i,a,s=void 0)=>{if(o=!0,n&&n.length>=3&&r&&r.length>=3){let o=v.findChildFromPath(t);o===void 0&&(o=v.createChildFromPath(t));let c=s||this.getBoundingBox();A.set(0,0,0);let l=A.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let s;switch(t){case`x`:s=new e.PlaneGeometry(l.z,l.y),s.rotateY(Math.PI/2);break;case`y`:s=new e.PlaneGeometry(l.x,l.z),s.rotateX(Math.PI/2);break;case`z`:s=new e.PlaneGeometry(l.x,l.y)}let c=o.createGeometryFromThreeJSGeometry(n[f],s,r[f],i,a,10001);d.push(c),f++}),l.addVectors(c.min,c.max).multiplyScalar(.5),d.forEach(e=>{e.setPosition(l.x,l.y,l.z)}),d}},this.enableMarkerCluster=e=>{o=!0,e?(O.markerUpdateRequired=!0,O.enable()):(O.markerUpdateRequired=!1,O.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{o=!0,this.displayMiniAxes=!1,k.main&&(this.enableAxisDisplay(!1,!1),k.main.forEach(e=>{e.dispose&&e.dispose()})),k.mini&&(this.enableAxisDisplay(!1,!0),k.mini.forEach(e=>{e.dispose&&e.dispose()})),k={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{o=!0,this.destroyAxisDisplay();let n=[{name:`x`,dir:new e.Vector3(1,0,0),colour:`red`,hex:16733525},{name:`y`,dir:new e.Vector3(0,1,0),colour:`green`,hex:5635925},{name:`z`,dir:new e.Vector3(0,0,1),colour:`blue`,hex:5592575}],r=this.getBoundingBox(),i=r.min.distanceTo(r.max),a=new e.Vector3(0,0,0);t&&a.copy(r.min),n.forEach(t=>{let n=new e.ArrowHelper(t.dir,a,i,t.hex);k.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(A),i/2,t.hex);k.mini.push(o);let s=Ce(t.name,.036,t.colour,`Asap`,120,700),c=t.dir.clone().multiplyScalar(i).add(a);s.position.set(c.x,c.y,c.z),k.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{o=!0,t&&k?.mini?.length?(this.displayMiniAxes=e,k.mini.forEach(t=>{e?_.add(t):_.remove(t)})):!t&&k.main&&k.main.forEach(t=>{e?g.add(t):g.remove(t)})}},ar=function(t){let n=t,i,a,o=new e.Timer;this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,b,x,S=[],C=[],w=new e.Group,T,E,D=!1,O=!1,k=[0,0],A=!1,j=!0,M=()=>{j=!0},N={controls:void 0,updated:!1};this.getDrawingWidth=()=>n?n.clientWidth:T?T.clientWidth===void 0?Math.round(T.width):Math.round(T.clientWidth):0,this.getDrawingHeight=()=>n?n.clientHeight:T?T.clientHeight===void 0?Math.round(T.height):Math.round(T.clientHeight):0,this.onWindowResize=()=>{j=!0,a.onWindowResize();let t=this.getDrawingWidth()||1,r=this.getDrawingHeight()||1;if(i!=null){let o;n?(o=n.getBoundingClientRect(),i.setSize(t,r)):T&&(T.getBoundingClientRect===void 0?i.setSize(t,r,!1):(o=T.getBoundingClientRect(),T.width=t,T.height=r,i.setSize(t,r,!1))),o&&(o.left,o.top);let s=new e.Vector2;i.getSize(s),k[0]=s.x,k[1]=s.y;let c=a?.camera?.fov;c&&ae(k[1]*i.getPixelRatio()/(2*Math.tan(c*Math.PI/360)))}},this.initialiseVisualisation=async t=>{if(!O){if(t||={},t.antialias===void 0){let e=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0)}catch{e=!1}e?t.antialias=!1:t.antialias=!0}if(t.canvas&&(n=void 0,T=t.canvas),t.device===void 0&&t.requiredLimits===void 0&&typeof navigator<`u`&&navigator.gpu)try{let e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference});e&&(t.requiredLimits={maxTextureArrayLayers:e.limits.maxTextureArrayLayers,maxStorageBuffersPerShaderStage:e.limits.maxStorageBuffersPerShaderStage})}catch{}i=new e.WebGPURenderer(t),await i.init(),bt(i.backend?.isWebGPUBackend===!0),n!==void 0&&n.appendChild(i.domElement),i.setClearColor(16777215,1),T&&T.style&&(T.style.height=`100%`,T.style.width=`100%`);let r=i.domElement;r.addEventListener(`webglcontextlost`,P,!1),r.addEventListener(`webglcontextrestored`,ee,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),v(M),O=!0}};let P=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},ee=e=>{e.preventDefault();for(let e of Object.keys(c))m.hasOwnProperty(e)&&m[e].call()};this.getCurrentScene=()=>a,this.setCurrentScene=e=>{if(e){this.removeActiveScene(e);let t=a;a=e,t&&t.setInteractiveControlEnable(!1),a.setInteractiveControlEnable(!0),a.setAdditionalScenesGroup(w),j=!0,this.onWindowResize()}},this.getSceneByName=e=>S[e],this.createScene=e=>{if(S[e]==null){let t;return t=T?new ir(T,i):new ir(n,i),S[e]=t,t.sceneName=e,t}},this.resetView=()=>{a.resetView()},this.viewAll=()=>{if(a){let e=a.getBoundingBox();if(e){for(let t=0;t<C.length;t++){let n=C[t].getBoundingBox();n&&e.union(n)}a.viewAllWithBoundingBox(e)}}},this.loadModelsURL=(e,t,n,r,i,o)=>{a.loadModelsURL(e,t,n,r,i,o)},this.loadViewURL=e=>{a.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{a.loadFromViewURL(e,t)},this.updateDirectionalLight=()=>{a.updateDirectionalLight()};let te=()=>{D?(g=requestAnimationFrame(te),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{D&&=!1},this.animate=()=>{D||(o.reset(),D=!0,j=!0,te())},this.addContextLostCallbackFunction=e=>(p+=1,f[p]=e,p),this.removeContextLostCallbackFunction=e=>{e in f&&delete f[e]},this.addContextRestoredCallbackFunction=e=>(h+=1,m[h]=e,h),this.removeContextRestoredCallbackFunction=e=>{e in h&&delete h[e]},this.addPreRenderCallbackFunction=e=>(l+=1,c[l]=e,l),this.removePreRenderCallbackFunction=e=>{e in c&&delete c[e]},this.addPostRenderCallbackFunction=e=>(d+=1,u[d]=e,d),this.removePostRenderCallbackFunction=e=>{e in u&&delete u[e]},this.getPlayRate=()=>s,this.setPlayRate=e=>{s=e,j=!0},this.setRenderOnDemand=e=>{A=!!e,j=!0},this.isRenderOnDemand=()=>A,this.invalidate=()=>{j=!0},this.getCurrentTime=()=>a.getCurrentTime(),this.setMorphsTime=e=>{a.setMorphsTime(e)},this.getZincGeometryByID=e=>a.getZincGeometryByID(e),this.addToScene=e=>{a.addObject(e)},this.addToOrthoScene=t=>{if(b??=new e.Scene,_==null){let t=this.getDrawingWidth(),n=this.getDrawingHeight();_=new e.OrthographicCamera(-t/2,t/2,n/2,-n/2,1,10),_.position.z=10}b.add(t),j=!0};let ne=t=>n=>{n.needsUpdate=!0;let r=new e.SpriteMaterial({map:n}),i=r.map.image.width,a=r.map.image.height;t.material=r,t.scale.set(i,a,1);let o=this.getDrawingWidth(),s=this.getDrawingHeight();t.position.set((o-i)/2,(-s+a)/2,1),this.addToOrthoScene(t)};this.addLogo=()=>{x=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,ne(x))},this.render=()=>{E||(n?n.clientWidth>0&&n.clientHeight>0&&(E=new r.ResizeSensor(n,this.onWindowResize)):T&&T.width>0&&T.height>0&&(E=new r.ResizeSensor(T,this.onWindowResize))),o.update();let e=o.getDelta(),t=a.renderGeometries(s,e,this.playAnimation);C.length>0&&(N.controls=a.getZincCameraControls(),N.updated=a.isCameraUpdated());for(let n=0;n<C.length;n++)C[n].renderGeometries(s,e,this.playAnimation,N)&&(t=!0);for(let e in c)c.hasOwnProperty(e)&&c[e].call();if(!(A&&!t&&!j)){j=!1,a.render(i),_!=null&&b!=null&&(i.clearDepth(),i.render(b,_));for(let e in u)u.hasOwnProperty(e)&&u[e].call()}},this.forceContextLoss=()=>{},this.forceContextRestore=()=>{},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<C.length;t++)if(C[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(C.push(e),w.add(e.getThreeJSScene()),j=!0)},this.removeActiveScene=e=>{for(let t=0;t<C.length;t++)if(C[t]===e){C.splice(t,1),w.remove(e.getThreeJSScene()),j=!0;return}},this.clearAllActiveScene=()=>{for(let e=0;e<C.length;e++)w.remove(C[e].getThreeJSScene());C.splice(0,C.length),j=!0},this.dispose=()=>{D&&cancelAnimationFrame(g);for(let e in S)S.hasOwnProperty(e)&&S[e].clearAll();S=[],C=[],w=new e.Group,this.stopAnimate(),c={},l=0,u={},d=0,f={},p=0,m={},h=0,_=void 0,b=void 0,x=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),E=void 0,y(M),i?.dispose()},this.transitionScene=(e,t)=>{if(a){let n=a.getZincCameraControls(),r=e.getBoundingBox();if(r){let e=r.min.distanceTo(r.max)/2,i=(r.min.x+r.max.x)/2,a=(r.min.y+r.max.y)/2,o=(r.min.z+r.max.z)/2,s=n.getViewportFromCentreAndRadius(i,a,o,e,40,e*4),c=n.getCurrentViewport();n.cameraTransition(c,s,t),n.enableCameraTransition()}}},this.isWebGL2=()=>i?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>i?.backend?.isWebGPUBackend===!0},or=class{esize;ecode;edata;littleEndian;constructor(e,t,n,r){if(e%16!=0)throw Error(`This does not appear to be a NIFTI extension`);this.esize=e,this.ecode=t,this.edata=n,this.littleEndian=r}toArrayBuffer(){let e=new Uint8Array(this.esize),t=new Uint8Array(this.edata);e.set(t,8);let n=new DataView(e.buffer);return n.setInt32(0,this.esize,this.littleEndian),n.setInt32(4,this.ecode,this.littleEndian),e.buffer}},F=class e{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,t,n){var r=``,i,a;for(i=t;i<n;i+=1)a=e.getUint8(i),a!==0&&(r+=String.fromCharCode(a));return r}static getByteAt=function(e,t){return e.getUint8(t)};static getShortAt=function(e,t,n){return e.getInt16(t,n)};static getIntAt(e,t,n){return e.getInt32(t,n)}static getFloatAt(e,t,n){return e.getFloat32(t,n)}static getDoubleAt(e,t,n){return e.getFloat64(t,n)}static getInt64At(e,t,n){let r=e.getUint32(t,n),i=e.getInt32(t+4,n),a;return a=n?i*2**32+r:r*2**32+i,i<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,t,n){let r=e.getUint32(t+(n?0:4),n),i=e.getUint32(t+(n?4:0),n);return n?i*2**32+r:r*2**32+i}static getExtensionsAt(t,n,r,i){let a=[],o=n;for(;o<i;){let n=r,s=e.getIntAt(t,o,r);if(!s)break;if(s+o>i&&(n=!n,s=e.getIntAt(t,o,n),s+o>i))throw Error(`This does not appear to be a valid NIFTI extension`);if(s%16!=0)throw Error(`This does not appear to be a NIFTI extension`);let c=e.getIntAt(t,o+4,n),l=t.buffer.slice(o+8,o+s),u=new or(s,c,l,n);a.push(u),o+=s}return a}static toArrayBuffer(e){var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r;for(r=0;r<e.length;r+=1)n[r]=e[r];return t}static isString(e){return typeof e==`string`||e instanceof String}static formatNumber(t,n=void 0){let r;return r=e.isString(t)?Number(t):t,r=n?r.toPrecision(5):r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}static crc32(t){e.crcTable||=e.makeCRCTable();let n=e.crcTable,r=-1;for(var i=0;i<t.byteLength;i++)r=r>>>8^n[(r^t.getUint8(i))&255];return(r^-1)>>>0}},sr=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic=`0`;isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(t){var n=new DataView(t),r=F.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=F.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=F.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=F.getShortAt(n,s,this.littleEndian);for(this.intent_p1=F.getFloatAt(n,56,this.littleEndian),this.intent_p2=F.getFloatAt(n,60,this.littleEndian),this.intent_p3=F.getFloatAt(n,64,this.littleEndian),this.intent_code=F.getShortAt(n,68,this.littleEndian),this.datatypeCode=F.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=F.getShortAt(n,72,this.littleEndian),this.slice_start=F.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=F.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=F.getFloatAt(n,108,this.littleEndian),this.scl_slope=F.getFloatAt(n,112,this.littleEndian),this.scl_inter=F.getFloatAt(n,116,this.littleEndian),this.slice_end=F.getShortAt(n,120,this.littleEndian),this.slice_code=F.getByteAt(n,122),this.xyzt_units=F.getByteAt(n,123),this.cal_max=F.getFloatAt(n,124,this.littleEndian),this.cal_min=F.getFloatAt(n,128,this.littleEndian),this.slice_duration=F.getFloatAt(n,132,this.littleEndian),this.toffset=F.getFloatAt(n,136,this.littleEndian),this.description=F.getStringAt(n,148,228),this.aux_file=F.getStringAt(n,228,252),this.qform_code=F.getShortAt(n,252,this.littleEndian),this.sform_code=F.getShortAt(n,254,this.littleEndian),this.quatern_b=F.getFloatAt(n,256,this.littleEndian),this.quatern_c=F.getFloatAt(n,260,this.littleEndian),this.quatern_d=F.getFloatAt(n,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(this.quatern_b**2+this.quatern_c**2+this.quatern_d**2)),this.qoffset_x=F.getFloatAt(n,268,this.littleEndian),this.qoffset_y=F.getFloatAt(n,272,this.littleEndian),this.qoffset_z=F.getFloatAt(n,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){let e=this.quatern_a,t=this.quatern_b,n=this.quatern_c,r=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[e*e+t*t-n*n-r*r,2*t*n-2*e*r,2*t*r+2*e*n],[2*t*n+2*e*r,e*e+n*n-t*t-r*r,2*n*r-2*e*t],[2*t*r-2*e*n,2*n*r+2*e*t,e*e+r*r-n*n-t*t]],a=0;a<3;a+=1)for(o=0;o<3;o+=1)this.affine[a][o]=this.quatern_R[a][o]*this.pixDims[o+1],o===2&&(this.affine[a][o]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(a=0;a<3;a+=1)for(o=0;o<4;o+=1)s=280+(a*4+o)*4,this.affine[a][o]=F.getFloatAt(n,s,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=F.getStringAt(n,328,344),this.magic=F.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=F.getByteAt(n,348),this.extensionFlag[1]=F.getByteAt(n,349),this.extensionFlag[2]=F.getByteAt(n,350),this.extensionFlag[3]=F.getByteAt(n,351);let e=!0;!this.isHDR&&this.vox_offset<=352&&(e=!1),n.byteLength<=368&&(e=!1),e&&this.extensionFlag[0]&&(this.extensions=F.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=F.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
559
+ `),i=``,a=``,o=0,s=[],c=typeof``.trimLeft==`function`;for(let e=0,t=r.length;e<t;e++)if(i=r[e],i=c?i.trimLeft():i.trim(),o=i.length,o!==0&&(a=i.charAt(0),a!==`#`)){if(a===`v`){let e=i.split(/\s+/);switch(e[0]){case`v`:n.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?n.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):n.colors.push(void 0,void 0,void 0);break;case`vn`:n.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:n.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(a===`f`){let e=i.substr(1).trim().split(/\s+/),t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.length>0){let e=r.split(`/`);t.push(e)}}let r=t[0];for(let e=1,i=t.length-1;e<i;e++){let i=t[e],a=t[e+1];n.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a===`l`){let e=i.substring(1).trim().split(` `),t=[],r=[];if(i.indexOf(`/`)===-1)t=e;else for(let n=0,i=e.length;n<i;n++){let i=e[n].split(`/`);i[0]!==``&&t.push(i[0]),i[1]!==``&&r.push(i[1])}n.addLineGeometry(t,r)}else if(a===`p`){let e=i.substr(1).trim().split(` `);n.addPointGeometry(e)}else if((s=Pn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(In.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(Fn.test(i))n.materialLibraries.push(i.substring(7).trim());else if(Ln.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(s=i.split(` `),s.length>1){let e=s[1].trim().toLowerCase();n.object.smooth=e!==`0`&&e!==`off`}else n.object.smooth=!0;let e=n.object.currentMaterial();e&&(e.smooth=n.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}n.finalize();let l=new e.Group;if(l.materialLibraries=[].concat(n.materialLibraries),n.objects.length!==1||n.objects[0].geometry.vertices.length!==0)for(let t=0,r=n.objects.length;t<r;t++){let r=n.objects[t],i=r.geometry,a=r.materials,o=i.type===`Line`,s=i.type===`Points`,c=!1;if(i.vertices.length===0)continue;let u=new e.BufferGeometry;u.setAttribute(`position`,new e.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&u.setAttribute(`normal`,new e.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(c=!0,u.setAttribute(`color`,new e.Float32BufferAttribute(i.colors,3))),i.hasUVIndices===!0&&u.setAttribute(`uv`,new e.Float32BufferAttribute(i.uvs,2));let d=[];for(let t=0,r=a.length;t<r;t++){let r=a[t],i=r.name+`_`+r.smooth+`_`+c,l=n.materials[i];if(this.materials!==null){if(l=this.materials.create(r.name),o&&l&&!(l instanceof e.LineBasicMaterial)){let t=new e.LineBasicMaterial;e.Material.prototype.copy.call(t,l),t.color.copy(l.color),l=t}else if(s&&l&&!(l instanceof e.PointsMaterial)){let t=new e.PointsMaterial({size:10,sizeAttenuation:!1});e.Material.prototype.copy.call(t,l),t.color.copy(l.color),t.map=l.map,l=t}}l===void 0&&(l=o?new e.LineBasicMaterial:s?new e.PointsMaterial({size:1,sizeAttenuation:!1}):new e.MeshPhongMaterial,l.name=r.name,l.flatShading=!r.smooth,l.vertexColors=c,n.materials[i]=l),d.push(l)}let f;if(d.length>1){for(let e=0,t=a.length;e<t;e++){let t=a[e];u.addGroup(t.groupStart,t.groupCount,e)}f=o?new e.LineSegments(u,d):s?new e.Points(u,d):new e.Mesh(u,d)}else f=o?new e.LineSegments(u,d[0]):s?new e.Points(u,d[0]):new e.Mesh(u,d[0]);f.name=r.name,l.add(f)}else if(n.vertices.length>0){let t=new e.PointsMaterial({size:1,sizeAttenuation:!1}),r=new e.BufferGeometry;r.setAttribute(`position`,new e.Float32BufferAttribute(n.vertices,3)),n.colors.length>0&&n.colors[0]!==void 0&&(r.setAttribute(`color`,new e.Float32BufferAttribute(n.colors,3)),t.vertexColors=!0);let i=new e.Points(r,t);l.add(i)}return l}},Gn=e.FileLoader,Kn=e=>{let t=(e,t)=>{if(e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&t.labels){let n=t.labels;for(let t=0;t<n.length;t++)e.labels.push(n[t])}[`axis1`,`axis2`,`axis3`,`colors`,`positions`,`scale`].forEach(n=>{n in e&&Object.keys(e[n]).forEach(r=>{let i=t[n][r].length;for(let a=0;a<i;a++)e[n][r].push(t[n][r][a])})})};if(e&&e.length>0)for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}},qn=e=>{if(e&&e.length>0){if(e.length===1)return e[0];let t=ge(e);return e.forEach(e=>e.dispose()),t}},Jn=function(e,t,n,r){let i=new Gn,a=new dt;i.crossOrigin=t;let o=e,s=n,c=r,l,u=!1,d=!1,f,p=[],m=e=>{let t=l[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=a.parse(t);e.onLoad(n.geometry,n.materials)}}else h(e,{responseURL:o})},h=e=>{e.onError&&(f||={responseURL:o},e.onError(f))};this.downloadCompleted=e=>{try{l=JSON.parse(e[0]),u=!1,d=!0,Array.isArray(l)?p.forEach(e=>m(e)):p.forEach(e=>h(e))}catch{p.forEach(e=>h(e))}};let g=()=>e=>{f=e,d=!0,u=!1,p.forEach(e=>{h(e)}),c&&c(e)},_=()=>e=>{p.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,r)=>{let a={index:e,onLoad:t,onProgress:n,onError:r};d?l?m(a):h(a):u?p.push(a):(p.push(a),u=!0,i.load(o,s,_(),g()))}},Yn=function(e,t,n,r){let i=[],a=e,o=t,s=n,c=0,l,u=r?.isGlyphsets,d=()=>{u||i.forEach(e=>{e&&(e[0]?.dispose?.(),e[1]?.forEach(e=>e.dispose()))}),s&&s(...l)};this.itemFailed=(e,t)=>{l||=t,c++,c==a&&d()},this.itemDownloaded=(e,t)=>{if(i[e]=t,c++,c==a){if(l)d();else if(i.length>0){if(u){let e=i.map(e=>JSON.parse(e[0]));Kn(e),o(e[0])}else{let e=i[0][1],t=qn(i.map(e=>e[0]));for(let e=1;e<a;e++)i[e][1]?.forEach(e=>e.dispose());o(t,e)}}}}},Xn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new dt,n=new Gn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new Yn(a,t,r,i),c=0;e.forEach(e=>{let a=i?{...i}:{};a.msHandler=o,a.order=c,c++,s(e,t,n,r,a)})},o=(t,n,a,o,s)=>{let l=s?{...s}:{},u=i[t];if(!u){if(20>e){let n=new c(void 0,this,l),r=new c(void 0,this,{});++e,u=new Jn(t,this.crossOrigin,n,r),i[t]=u}else r.push({url:t,onLoad:n,onProgress:a,onError:o,options:s})}u&&(l.isHandler=u,u.load(s.index,n,a,o))},s=(i,a,s,l,u)=>{if(u&&u.index!==void 0)o(i,a,s,l,u);else if(20>e){++e;let r=new c(a,this,u),o=new c(l,this,u,!0);u?.isGlyphsets?n.load(i,r,s,o):(t.crossOrigin=this.crossOrigin,t.load(i,r,s,o))}else r.push({url:i,onLoad:a,onProgress:s,onError:l,options:u})};this.load=(e,t,n,r,i)=>{Array.isArray(e)?a(e,t,n,r,i):s(e,t,n,r,i)},this.loadFromWaitingList=()=>{for(;20>e;){let e=r.shift();if(e)this.load(e.url,e.onLoad,e.onProgress,e.onError,e.options);else return}},this.itemRemainingCheck=()=>{if(r.length===0&&e===0)for(let e in i)i.hasOwnProperty(e)&&delete i[e]};let c=function(t,n,r,i=!1){return(...a)=>{--e,r?.msHandler?i?r.msHandler.itemFailed(r.order,a):r.msHandler.itemDownloaded(r.order,a):r?.isHandler?r.isHandler.downloadCompleted(a):t&&t(...a),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>t.parse(e)},Zn=class extends e.Loader{constructor(e){super(e)}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}parse(t){function n(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let n=[115,111,108,105,100];for(let e=0;e<5;e++)if(r(n,t,e))return!1;return!0}function r(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r,!1))return!1;return!0}function i(t){let n=new DataView(t),r=n.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)n.getUint32(e,!1)==1129270351&&n.getUint8(e+4)==82&&n.getUint8(e+5)==61&&(s=!0,c=new Float32Array(r*3*3),l=n.getUint8(e+6)/255,u=n.getUint8(e+7)/255,d=n.getUint8(e+8)/255,f=n.getUint8(e+9)/255);let p=new e.BufferGeometry,m=new Float32Array(r*3*3),h=new Float32Array(r*3*3);for(let e=0;e<r;e++){let t=84+e*50,r=n.getFloat32(t,!0),f=n.getFloat32(t+4,!0),p=n.getFloat32(t+8,!0);if(s){let e=n.getUint16(t+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=t+l*12,d=e*3*3+(l-1)*3;m[d]=n.getFloat32(u,!0),m[d+1]=n.getFloat32(u+4,!0),m[d+2]=n.getFloat32(u+8,!0),h[d]=r,h[d+1]=f,h[d+2]=p,s&&(c[d]=i,c[d+1]=a,c[d+2]=o)}}return p.setAttribute(`position`,new e.BufferAttribute(m,3)),p.setAttribute(`normal`,new e.BufferAttribute(h,3)),s&&(p.setAttribute(`color`,new e.BufferAttribute(c,3)),p.hasColors=!0,p.alpha=f),p}function a(t){let n=new e.BufferGeometry,r=/solid([\s\S]*?)endsolid/g,i=/facet([\s\S]*?)endfacet/g,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=new e.Vector3,f,p=0,m=0,h=0;for(;(f=r.exec(t))!==null;){m=h;let e=f[0];for(;(f=i.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=c.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=s.exec(n))!==null;)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let t=m,r=h-m;n.addGroup(t,r,p),p++}return n.setAttribute(`position`,new e.Float32BufferAttribute(l,3)),n.setAttribute(`normal`,new e.Float32BufferAttribute(u,3)),n}function o(t){return typeof t==`string`?t:e.LoaderUtils.decodeText(new Uint8Array(t))}function s(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let c=s(t);return n(c)?i(c):a(o(t))}},Qn=function(){Xe.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,a,o)=>{if(n&&a){t={geometryIn:n,materialIn:a,options:o};let s=i(r(n)),c=new e.MeshStandardMaterial({color:a.color}),l=new e.Mesh(s,c);this.setMesh(l,o.localTimeEnabled,o.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){this.requestRender();let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{this.requestRender();let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,a)=>{if(this.requestRender(),e&&a){let{geometryIn:o}=t,s=this.getMorph();s.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:a}),s.geometry=i(r(o))}};let r=t=>{let n=t.getAttribute(`position`),r=[];for(let t=0;t<n.count;t++)r.push(new e.Vector3().fromBufferAttribute(n,t));return r},i=t=>{let{radius:r,radialSegments:i,smooth:a}=n,o;if(a){let n=new e.CatmullRomCurve3(t);o=new e.TubeGeometry(n,t.length,r,i,!1)}else{let n=[];for(let a=0;a+1<t.length;a+=2){let o=new e.LineCurve3(t[a],t[a+1]),s=new e.TubeGeometry(o,1,r,i,!1);n.push(s)}o=ge(n,!0),n.forEach(e=>e.dispose())}return o}};Qn.prototype=Object.create(Xe.prototype);var $n=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=0,o=new Xn;this.cancelPendingLoads=()=>{a++,this.toBeDownloaded=0,this.progressMap={},r=!1,i=!1};let s=()=>{let e=a;return()=>e!==a};this.getDownloadProgress=()=>{let e=0,t=0,n=!1;for(let r in this.progressMap){let i=this.progressMap[r];e+=i[1],t+=i[0],i[1]==0&&(n=!0)}return n&&(e=0),[e,t,i]},this.onProgress=e=>t=>{this.progressMap[e]=[t.loaded,t.total]},this.onError=e=>{let t=s();return n=>{t()||(--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${n?.responseURL?`: `+n?.responseURL:``}.`),e&&e({type:`Error`,xhr:n}))}};let c=(e,t)=>{let i=t.Default;if(t.Inline)n.setupMultipleViews(i,t.Entries);else{let a=[];for(let[n,r]of Object.entries(t.Entries))if(e){let t=oe(r,e);a.push(new Promise((e,r)=>{fetch(t).then(e=>e.json()).then(t=>e({key:n,data:t})).catch(e=>r(e))}))}Promise.all(a).then(e=>{let t={};e.forEach(e=>{t[e.key]=e.data}),n.setupMultipleViews(i,t);let a=n.getZincCameraControls();a&&a.setCurrentViewport(i),r=!0})}};this.loadViewURL=(e,t)=>{this.toBeDownloaded+=1;let i=e,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{a()||(n.setupMultipleViews(`default`,{default:e}),n.resetView(),r=!0,--this.toBeDownloaded,t!==void 0&&typeof t==`function`&&t())}).catch(e=>{console.error(`Fetch failed for URL: ${i}`,e),this.onError(t)({responseURL:i})})},this.loadModelsURL=(e,t,n,r,i,a,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=Ar.defaultMaterialColor,d=Ar.defaultOpacity;n!=null&&n[l]!=null&&(u=!!n[l]),r!=null&&r[l]!=null&&(d=r[l]);let f=0;i!=null&&i[l]!=null&&(f=!!i[l]);let p=!1;a!=null&&a[l]!=null&&(p=!!a[l]),o.load(c,g(e,u,d,f,p,void 0,void 0,void 0,void 0,s),this.onProgress(c),this.onError(s))}},this.loadFromViewURL=(e,t,r)=>{let i=t+`_view.json`,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{if(a())return;n.loadView(i);let o=[],s=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=s+(e+1)+`.json`;o.push(t)}this.loadModelsURL(e,o,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let l=(t,r,i,a,c,l,u,d,f)=>{let p=s();return(s,m)=>{if(p()){s.dispose();return}let h=d?new Qn:new It,g;m&&m[0]&&(g=new e.LineBasicMaterial({color:m[0].color.clone()}),1>m[0].opacity&&(g.transparent=!0),g.opacity=m[0].opacity,g.vertexColors=m[0].vertexColors);let _={};if(_.localTimeEnabled=r,_.localMorphColour=i,h&&(h.createLineSegment(s,g,_),h.setName(a),h.setAnatomicalId(c),h.setRenderOrder(l),t.addZincObject(h),h.setDuration(n.getDuration()),u&&u.levels))for(let[e,t]of Object.entries(u.levels))h.addLOD(o,e,t.URL,t.Index,u.preload);--this.toBeDownloaded,s.dispose(),f!=null&&typeof f==`function`&&f(h)}};this.loadLinesURL=(e,t,n,r,i,a,s)=>{let c=0;this.toBeDownloaded+=1;let u=s?.isInline?s.isInline:!1,d=s?.anatomicalId?s.anatomicalId:void 0,f=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(c=!!n);let p=0;r!=null&&(p=!!r);let m=s.tubeLines&&!c&&!p;if(u){let n=o.parse(t);l(e,c,p,i,d,f,s.lod,m,a)(n.geometry,n.materials)}else o.load(t,l(e,c,p,i,d,f,s.lod,m,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let u=(e,t,r,i,a)=>{let o=s();return s=>{if(o())return;let c=s;(typeof c==`string`||c instanceof String)&&(c=JSON.parse(s));let l=a&&a.isInline?a.isInline:void 0,u=a&&a.anatomicalId?a.anatomicalId:void 0,d=a?.displayLabels;d===void 0&&(d=!0);let f=a&&`renderOrder`in a?a.renderOrder:void 0,p=new Ct;p.setDuration(n.getDuration()),p.groupName=r,++this.toBeDownloaded,p.load(c,t,()=>{o()||(--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(p))},l,d),p.setAnatomicalId(u),p.setRenderOrder(f),e.addZincObject(p)}};this.loadGlyphsetURL=(e,t,n,r,i,a)=>{a&&a.isInline&&a.isInline?u(e,n,r,i,a)(t):o.load(t,u(e,n,r,i,a),this.onProgress(t),this.onError(i),a.loaderOptions)};let d=(t,r,i,a,o,c,l)=>{let u=s();return(s,d)=>{if(u()){s.dispose();return}let f=new Ft,p=new e.PointsMaterial({alphaTest:.05,size:10,sizeAttenuation:!1});d&&d[0]&&(1>d[0].opacity&&(p.transparent=!0),p.opacity=d[0].opacity,p.color=d[0].color,p.vertexColors=!1);let m={};m.localTimeEnabled=r,m.localMorphColour=i,f&&(f.createMesh(s,p,m),f.setName(a),f.setAnatomicalId(o),t.addZincObject(f),f.setDuration(n.getDuration()),f.setRenderOrder(c)),s.dispose(),--this.toBeDownloaded,l!=null&&typeof l==`function`&&l(f)}};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=Ar.defaultMaterialColor,a=Ar.defaultOpacity,o=new Zn;o.crossOrigin=`Anonymous`,o.load(t,g(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=Ar.defaultMaterialColor,a=Ar.defaultOpacity,o=new Wn;o.crossOrigin=`Anonymous`,o.load(t,_(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))};let f=(e,t,n,r,i,a,s)=>{this.toBeDownloaded+=1;let c=Ar.defaultMaterialColor,l=Ar.defaultOpacity,u=0,d=s&&s.isInline?s.isInline:!1,f=s&&s.fileFormat?s.fileFormat:void 0,p=s&&s.anatomicalId?s.anatomicalId:void 0,m=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let h=0;r!=null&&(h=!!r);let v=o;if(f==`STL`||f==`OBJ`){let n=f==`STL`?g:_;v=f==`STL`?new Zn:new Wn,v.crossOrigin=`Anonymous`,v.load(t,n(e,c,l,u,h,i,p,m,s||{},a),this.onProgress(t),this.onError(a));return}if(d){let n=o.parse(t);g(e,c,l,u,h,i,p,m,s,a)(n.geometry,n.materials)}else v.crossOrigin=`Anonymous`,o.load(t,g(e,c,l,u,h,i,p,m,s,a),this.onProgress(t),this.onError(a),s.loaderOptions)},p=function(e,t,i){let a=0;return o=>{if(a+=1,o&&t!=null&&typeof t==`function`&&t(o),a==e&&(r===!1&&n.viewAll(),i!=null&&typeof i==`function`)){i();let e=n.getZincCameraControls();e&&e.calculateMaxAllowedDistance(n)}}};this.loadPointsetURL=(e,t,n,r,i,a,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let l=0;r!=null&&(l=!!r);let u=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(u){let n=o.parse(t);d(e,c,l,i,f,p,a)(n.geometry,n.materials)}else o.load(t,d(e,c,l,i,f,p,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let m=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,c=a&&a.anatomicalId?a.anatomicalId:void 0,l=a&&`renderOrder`in a?a.renderOrder:void 0,u;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=oe(e[r],t);n.images.source[r]=i}}if(n.type===`slides`&&(u=new Ht),u){u.groupName=r;let t=s();++this.toBeDownloaded,u.load(n,()=>{if(t()){u.dispose();return}e.addZincObject(u),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(u)},o),u.setAnatomicalId(c),u.setRenderOrder(l)}}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)m(e,void 0,t,n,r,i);else{let a=t,o=s();fetch(a).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(a).href;return e.json().then(e=>({textureData:e,referenceURL:t}))}).then(({textureData:t,referenceURL:a})=>{o()||m(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let h=(e,t,r,i,a,o,s,c,l,u,d)=>{let f={};f.colour=r,f.opacity=i,f.localTimeEnabled=a,f.localMorphColour=o;let p=new $e;if(p.createMesh(t,c,f),p.getMorph())return p.setName(l),p.setRenderOrder(u),p.setAnatomicalId(d),e&&e.addZincObject(p),p.setDuration(n.getDuration()),s!=null&&typeof s==`function`&&s(p),p.videoHandler&&n.setVideoHandler(p.videoHandler),p},g=(e,t,n,r,i,a,c,l,u,d)=>{let f=s();return(s,p)=>{if(f()){s.dispose();return}let m;p&&p[0]&&(m=p[0]);let g=h(e,s,t,n,r,i,void 0,m,a,l,c);if(u?.lod?.levels)for(let[e,t]of Object.entries(u.lod.levels))g.addLOD(o,e,t.URL,t.Index,u.lod.preload);--this.toBeDownloaded,s.dispose(),d!=null&&typeof d==`function`&&d(g)}},_=(e,t,n,r,i,a,o,c,l,u)=>{let d=s(),f=g(e,t,n,r,i,a,o,c,l,u);return e=>{let t=[];if(e.traverse(e=>{e.isMesh&&e.geometry&&t.push(e),e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>e.dispose())}),d()){t.forEach(e=>e.geometry.dispose());return}if(t.length===0){--this.toBeDownloaded;return}this.toBeDownloaded+=t.length-1,t.forEach(e=>f(e.geometry))}},v=e=>{let[,t,n,r,i,a,o,s]=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);return{years:t,months:n,weeks:r,days:i,hours:a,mins:o,secs:s}};this.loadSettings=e=>{if(e){if(e.Duration){let t=v(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=v(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=v(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let y=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=oe(a,t))):n.Inline&&(a=n.Inline.URL,o=!0);let s={};if(n.LOD&&n.LOD.Levels){s.preload=!!n.LOD.Preload,s.levels={};for(let[e,r]of Object.entries(n.LOD.Levels))s.levels[e]={},s.levels[e].URL=oe(r.URL,t),s.levels[e].Index=r.Index}let c=n.GroupName;(c===void 0||c===``)&&(c=`_Unnamed`);let l={loaderOptions:{index:n.Index},isInline:o,fileFormat:n.FileFormat,anatomicalId:n.AnatomicalId,compression:n.compression,tubeLines:n.tubeLines,lod:s,renderOrder:r};switch(n.Type){case`Surfaces`:f(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=oe(n.GlyphGeometriesURL,t)),l.displayLabels=n.DisplayLabels,l.displayLabels===void 0&&(l.displayLabels=!0),l.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(e,a,r,c,i,l);break;case`Points`:this.loadPointsetURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Lines`:this.loadLinesURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Texture`:this.loadTextureURL(e,a,c,i,l)}}},b=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=oe(t.URL,e))):t.Inline&&(a=t.Inline.URL,o=!0),t.Type){case`View`:o?(n.setupMultipleViews(`default`,{default:a}),r=!0,i!=null&&typeof i==`function`&&i()):this.loadViewURL(a,i);break;case`Settings`:this.loadSettings(t)}}};this.loadGLTF=(e,t,r,i,a)=>{new Nn().load(n,e,t,r,i,a,s())};let x=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),y(e,t,n,i,r)}),n.Transformation&&e.setTransformation(n.Transformation),n.Children)for(let[i,a]of Object.entries(n.Children)){let n=e.findOrCreateChildFromPath(i);n&&x(n,t,a,r)}},S=(e,t)=>{let n=e,r=t?.enabled?.include,i=t?.enabled?.exclude,a=t?.tubeLines;return(r?.length||i?.length)&&(r&&(n=e.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<r.length;t++)if(we(e.RegionPath,e.GroupName,r[t]))return!0;return!1})),i&&(n=n.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<i.length;t++)if(we(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},C=(e,t)=>Array.isArray(e)?S(e,t):e,w=(e,t)=>{if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++)e[r].Type&&(t&&e[r].Type===`View`||e[r].Type===`Surfaces`||e[r].Type===`Glyph`||e[r].Type===`Points`||e[r].Type===`Lines`||e[r].Type===`Texture`)&&n++;return n}return 0},T=e=>{let t=e.Primitives?w(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=T(e)}),t},E=e=>{if(Array.isArray(e))return w(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return T(e.Regions)},D=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),y(a,t,n,r*2,i)},O=(e,t,n,r,i,a)=>{let o=C(t,a),s=E(o),c=new p(s,r,i);for(let e=0;e<o.length;e++)b(n,o[e],c);for(let t=0;t<o.length;t++)D(e,n,o[t],t,c)},k=(e,t,n,r,i)=>{let a=E(t),o=new p(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&c(n,t.Views,n),t.Regions&&x(e,n,t.Regions,o)};this.loadMetadataURL=(e,t,i,a,o)=>{let c=t,l=s();fetch(c).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(c).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{l()||(n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?O(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&k(e,t,s,i,a))}).catch(e=>{console.error(`Fetch failed for URL: ${c}`,e)})}},er=0,tr=function(){return`sc`+er++},nr=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},rr=6e3,ir=function(t,n){let r=t,i,a,o=!0,s=!1,c={},l={displayMarkers:void 0,displayMinimap:void 0,displayMiniAxes:void 0,playAnimation:void 0},u=new $n(this),d,f={},p=0,m={},h=0,g=new e.Scene,_=new e.Scene,v=new An(void 0,this);g.add(v.getGroup());let y=new e.Group;g.add(y),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let b=6e3,x;this.sceneName=void 0;let S=!1,C;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:`top-right`,updateRequired:!0};let w={x:0,y:0},T=nr(),E=new e.Vector2,D=[];this.forcePickableObjectsUpdate=!1,this.uuid=tr();let O=new nn(this);O.disable(),g.add(O.group);let k={main:[],mini:[]},A=new e.Vector3(0,0,0),j=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,M=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>u.getDownloadProgress(),this.onWindowResize=()=>{o=!0;let e=M();this.camera.aspect=j()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,x.onResize(),x.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{o=!0,this.onWindowResize(),x.resetView()},this.changeZoomByScrollRateUnit=e=>{o=!0,x.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,j()/M(),0,10),this.ambient=new e.AmbientLight(16777215,.2),g.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.7*Math.PI),g.add(this.directionalLight),x=new Wt(this.camera,n.domElement,n,this),x.setDirectionalLight(this.directionalLight),x.resetView(),d=new rn(this),this.loadView=e=>{o=!0;let t=new Ut;return t.setFromObject(e),x.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new Ut;t.setFromObject(n),x.addViewport(e,t)}x.setDefaultViewport(e)},this.getBoundingBox=()=>v.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(o=!0,e){let t=x.getViewportFromBoundingBox(e,1);x.setCurrentCameraSettings(t),x.calculateHeightPerPixelAtZeroDepth(M()),O.markerUpdateRequired=!0}},this.viewAll=()=>{o=!0;let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),O.markerUpdateRequired=!0},this.forEachGeometry=e=>{v.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{v.forEachGlyphset(e,!0)},this.forEachPointset=e=>{v.forEachPointset(e,!0)},this.forEachLine=e=>{v.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>v.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>v.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>v.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>v.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>v.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>v.findObjectsWithAnatomicalId(e,!0),this.getBoundingBoxOfZincObjects=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n].getBoundingBox();r&&(t?t.union(r):t=r)}return t},this.vectorToScreenXY=e=>{e.project(this.camera);let t=j(),n=M(),r=t/2,i=n/2;return e.x=e.x*r+r,e.y=-(e.y*i)+i,e},this.getObjectsScreenXY=t=>{if(t&&t.length>0){let n=this.getBoundingBoxOfZincObjects(t),r=new e.Vector3;return n.getCenter(r),this.vectorToScreenXY(r)}},this.getNamedObjectsScreenXY=e=>{let t=this.findObjectsWithGroupName(e);return this.getObjectsScreenXY(t)},this.addZincObject=e=>{o=!0,e&&(v.addZincObject(e),x&&x.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{u.loadGlyphsetURL(v,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{u.loadPointsetURL(v,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{u.loadLinesURL(v,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{u.loadSTL(v,e,t,n)},this.loadOBJ=(e,t,n)=>{u.loadOBJ(v,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{u.loadMetadataURL(v,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{u.loadModelsURL(v.urls,t,n,r,i,a)},this.loadViewURL=e=>{u.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{u.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{u.loadGLTF(v,e,t,n,r)},this.updateDirectionalLight=()=>{o=!0,x.updateDirectionalLight()},this.addObject=e=>{o=!0,g.add(e)},this.removeObject=e=>{o=!0,g.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(b);let e=v.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{o=!0,a?.setMorphTime(e,b),v.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:v.isTimeVarying(),this.renderGeometries=(e,t,n,r)=>{let i=o;o=!1,s=!1;let d=r?r.controls:x,f=c;if(f.camera=d,f.displayMarkers=this.displayMarkers,f.markerCluster=O,f.markersList=O.markers,f.ndcToBeUpdated=r?r.updated:!1,n&&(f.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*b;u.toBeDownloaded==0?(r||(x.setTime(e),f.ndcToBeUpdated=x.update(0),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.setMorphTime(e,!0),v.renderGeometries(0,0,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0)}(n||!a.isReadyToPlay())&&(i=!0)}else u.toBeDownloaded==0?(r||(f.ndcToBeUpdated=x.update(t),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.renderGeometries(e,t,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0);return(l.displayMarkers!==this.displayMarkers||l.displayMinimap!==this.displayMinimap||l.displayMiniAxes!==this.displayMiniAxes||l.playAnimation!==n)&&(l.displayMarkers=this.displayMarkers,l.displayMinimap=this.displayMinimap,l.displayMiniAxes=this.displayMiniAxes,l.playAnimation=n,i=!0),this.minimapScissor.updateRequired&&(this.displayMinimap||this.displayMiniAxes)&&(i=!0),!r&&f.ndcToBeUpdated&&(s=!0),(f.ndcToBeUpdated||n&&this.isTimeVarying()||u.toBeDownloaded>0||O.isEnabled()&&O.markerUpdateRequired)&&(i=!0),o&&=(i=!0,!1),i},this.invalidate=()=>{o=!0},this.isCameraUpdated=()=>s,this.getThreeJSScene=()=>g,this.setVideoHandler=e=>{o=!0,a||=e},this.setAdditionalScenesGroup=e=>{g.add(e)};let N=(e,t,n,r,i,a,o)=>{let s=0,c=0;return c=e.includes(`top`)?o-i-n:e.includes(`bottom`)?n:Math.floor((o-i)/2),s=e.includes(`left`)?t:e.includes(`right`)?a-t-r:Math.floor((a-r)/2),{x:s,y:c}},P=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(E),this.minimapScissor.updateRequired&&(w=N(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,E.x,E.y),this.minimapScissor.updateRequired=!1),e.setScissor(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),d.updateCamera(),this.displayMiniAxes?e.render(_,d.camera):(g.add(d.mask),e.render(g,d.camera),g.remove(d.mask)),e.setScissorTest(!1),e.setViewport(0,0,E.x,E.y))};this.render=e=>{this.autoClearFlag&&e.clear(),S&&C?C.render(g,this.camera):(e.render(g,this.camera),P(e))},this.setInteractiveControlEnable=e=>{e==1?x.enable():x.disable()},this.getZincCameraControls=()=>x,this.getThreeJSScene=()=>g,this.setDuration=e=>{o=!0,v.setDuration(e),b=e,x.setPathDuration(e),u.duration=e},this.getDuration=()=>b,this.setStereoEffectEnable=e=>{o=!0,e==1&&(C||=new Xt(n)),n.setSize(j(),M()),this.camera.updateProjectionMatrix(),S=e},this.objectIsInScene=e=>v.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(o=!0,t){t.getCenter(A);let r=this.getZincCameraControls().getCurrentViewport(),i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(i,a).normalize(),s.subVectors(i,A).normalize();let c=new e.Vector3;c.crossVectors(o,s);let l=o.angleTo(s);n>0?(this.getZincCameraControls().rotateCameraTransition(c,l,n),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(c,l),O.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(e,t,n)=>{if(e){let r=this.getZincCameraControls().getCurrentViewport(),i=this.getZincCameraControls().getViewportFromBoundingBox(e,t);n>0&&(this.getZincCameraControls().cameraTransition(r,i,n),this.getZincCameraControls().enableCameraTransition()),O.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(o=!0,this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(A);let i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(a,i),s.addVectors(A,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=A.x,r.targetPosition[1]=A.y,r.targetPosition[2]=A.z,this.getZincCameraControls().setCurrentCameraSettings(r),O.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>S,this.removeZincObject=e=>{o=!0,v.removeZincObject(e),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{D.length=0,O.isEnabled&&D.push(O.group),v.getPickableThreeJSObjects(D,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||v.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),D),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(w.x+this.minimapScissor.width>n.clientX&&n.clientX>w.x&&w.y+this.minimapScissor.height>i&&i>w.y)return{x:(n.clientX-w.x)/this.minimapScissor.width*2-1,y:(i-w.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(d)return d.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>n?.backend?.isWebGPUBackend===!0,this.getRenderer=()=>n,this.clearAll=()=>{o=!0,O.clear(),v.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),u.cancelPendingLoads(),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{T.TimeStamps[e]=te(t)},this.getMetadataTag=e=>T[e],this.getMetadata=()=>T,this.setMetadataTag=(e,t)=>{T[e]=t},this.removeMetadataTag=e=>{delete T[e]},this.resetMetadata=()=>{T=nr()},this.resetDuration=()=>{this.setDuration(rr)};let ee=e=>[...e.years?[`${e.years}years`]:[],...e.months?[`${e.months}months`]:[],...e.weeks?[`${e.weeks}weeks`]:[],...e.days?[`${e.days}days`]:[],...e.hours?[`${e.hours}hours`]:[],...e.mins?[`${e.mins}mins`]:[],...e.secs?[`${e.secs}secs`]:[]].join(` `),te=e=>e.years?e.years*31536e6:0+e.months?e.months*2592e6:0+e.weeks?e.weeks*6048e5:0+e.days?e.days*864e5:0+e.hours?e.hours*36e5:0+e.mins?e.mins*6e4:0+e.secs?e.secs*1e3:0;this.setDurationFromObject=e=>{let t=ee(e),n=te(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=ee(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new Mn(this).exportGLTF(e),this.getRootRegion=()=>v,this.createLines=(e,t,n,r)=>{let i=v.findChildFromPath(e);return i===void 0&&(i=v.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=v.findChildFromPath(e);return a===void 0&&(a=v.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(p+=1,f[p]=e,p),this.addZincObjectRemovedCallbacks=e=>(h+=1,m[h]=e,h),this.removeZincObjectAddedCallbacks=e=>{e in p&&delete f[e]},this.removeZincObjectRemovedCallbacks=e=>{e in h&&delete m[e]},this.clearZincObjectAddedCallbacks=()=>{f={},p=0},this.clearZincObjectRemovedCallbacks=()=>{m={},h=0},this.triggerObjectAddedCallback=e=>{for(let t in f)f.hasOwnProperty(t)&&f[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in m)m.hasOwnProperty(t)&&m[t](e)},this.addTemporaryPoints=(e,t)=>{o=!0;let n=jt(e.length),r=kt(Se());r.color.set(t),r.size=15,r.userData.uniforms.pointSize.value=15,r.alphaTest=.5;let i=new Dt(n,r,e.length),a=n.getAttribute(`instancePosition`);return i.pointPositions=a.array,e.forEach((e,t)=>{a.setXYZ(t,e[0],e[1],e[2])}),a.needsUpdate=!0,y.add(i),i},this.addTemporaryLines=(t,n)=>{o=!0;let r=new He(_e(t.length,t),new e.LineBasicMaterial({color:n}));return y.add(r),r},this.enableFrustumDisplay=()=>{o=!0,this.camera&&!i&&(i=new e.CameraHelper(this.camera),g.add(i))},this.disableFrustumDisplay=()=>{o=!0,i&&=(g.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{o=!0,y.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{o=!0;let e=0;return y.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),y.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,s=void 0)=>{o=!0;let c=v.findChildFromPath(t);c===void 0&&(c=v.createChildFromPath(t));let l=s||this.getBoundingBox();A.set(0,0,0);let u=A.subVectors(l.max,l.min),d=new e.BoxGeometry(u.x,u.y,u.z),f=c.createGeometryFromThreeJSGeometry(n,d,r,i,a,1e4);return u.addVectors(l.min,l.max).multiplyScalar(.5),f.setPosition(u.x,u.y,u.z),f},this.addSlicesPrimitive=(t,n,r,i,a,s=void 0)=>{if(o=!0,n&&n.length>=3&&r&&r.length>=3){let o=v.findChildFromPath(t);o===void 0&&(o=v.createChildFromPath(t));let c=s||this.getBoundingBox();A.set(0,0,0);let l=A.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let s;switch(t){case`x`:s=new e.PlaneGeometry(l.z,l.y),s.rotateY(Math.PI/2);break;case`y`:s=new e.PlaneGeometry(l.x,l.z),s.rotateX(Math.PI/2);break;case`z`:s=new e.PlaneGeometry(l.x,l.y)}let c=o.createGeometryFromThreeJSGeometry(n[f],s,r[f],i,a,10001);d.push(c),f++}),l.addVectors(c.min,c.max).multiplyScalar(.5),d.forEach(e=>{e.setPosition(l.x,l.y,l.z)}),d}},this.enableMarkerCluster=e=>{o=!0,e?(O.markerUpdateRequired=!0,O.enable()):(O.markerUpdateRequired=!1,O.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{o=!0,this.displayMiniAxes=!1,k.main&&(this.enableAxisDisplay(!1,!1),k.main.forEach(e=>{e.dispose&&e.dispose()})),k.mini&&(this.enableAxisDisplay(!1,!0),k.mini.forEach(e=>{e.dispose&&e.dispose()})),k={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{o=!0,this.destroyAxisDisplay();let n=[{name:`x`,dir:new e.Vector3(1,0,0),colour:`red`,hex:16733525},{name:`y`,dir:new e.Vector3(0,1,0),colour:`green`,hex:5635925},{name:`z`,dir:new e.Vector3(0,0,1),colour:`blue`,hex:5592575}],r=this.getBoundingBox(),i=r.min.distanceTo(r.max),a=new e.Vector3(0,0,0);t&&a.copy(r.min),n.forEach(t=>{let n=new e.ArrowHelper(t.dir,a,i,t.hex);k.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(A),i/2,t.hex);k.mini.push(o);let s=Ce(t.name,.036,t.colour,`Asap`,120,700),c=t.dir.clone().multiplyScalar(i).add(a);s.position.set(c.x,c.y,c.z),k.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{o=!0,t&&k?.mini?.length?(this.displayMiniAxes=e,k.mini.forEach(t=>{e?_.add(t):_.remove(t)})):!t&&k.main&&k.main.forEach(t=>{e?g.add(t):g.remove(t)})}},ar=function(t){let n=t,i,a,o=new e.Timer;this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,b,x,S=[],C=[],w=new e.Group,T,E,D=!1,O=!1,k=[0,0],A=!1,j=!0,M=()=>{j=!0},N={controls:void 0,updated:!1};this.getDrawingWidth=()=>n?n.clientWidth:T?T.clientWidth===void 0?Math.round(T.width):Math.round(T.clientWidth):0,this.getDrawingHeight=()=>n?n.clientHeight:T?T.clientHeight===void 0?Math.round(T.height):Math.round(T.clientHeight):0,this.onWindowResize=()=>{j=!0,a.onWindowResize();let t=this.getDrawingWidth()||1,r=this.getDrawingHeight()||1;if(i!=null){let o;n?(o=n.getBoundingClientRect(),i.setSize(t,r)):T&&(T.getBoundingClientRect===void 0?i.setSize(t,r,!1):(o=T.getBoundingClientRect(),T.width=t,T.height=r,i.setSize(t,r,!1))),o&&(o.left,o.top);let s=new e.Vector2;i.getSize(s),k[0]=s.x,k[1]=s.y;let c=a?.camera?.fov;c&&ae(k[1]*i.getPixelRatio()/(2*Math.tan(c*Math.PI/360)))}},this.initialiseVisualisation=async t=>{if(!O){if(t||={},t.antialias===void 0){let e=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0)}catch{e=!1}e?t.antialias=!1:t.antialias=!0}if(t.canvas&&(n=void 0,T=t.canvas),t.device===void 0&&t.requiredLimits===void 0&&typeof navigator<`u`&&navigator.gpu)try{let e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference});e&&(t.requiredLimits={maxTextureArrayLayers:e.limits.maxTextureArrayLayers,maxTextureDimension2D:e.limits.maxTextureDimension2D,maxStorageBuffersPerShaderStage:e.limits.maxStorageBuffersPerShaderStage})}catch{}i=new e.WebGPURenderer(t),await i.init(),bt(i.backend?.isWebGPUBackend===!0),n!==void 0&&n.appendChild(i.domElement),i.setClearColor(16777215,1),T&&T.style&&(T.style.height=`100%`,T.style.width=`100%`);let r=i.domElement;r.addEventListener(`webglcontextlost`,P,!1),r.addEventListener(`webglcontextrestored`,ee,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),v(M),O=!0}};let P=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},ee=e=>{e.preventDefault();for(let e of Object.keys(c))m.hasOwnProperty(e)&&m[e].call()};this.getCurrentScene=()=>a,this.setCurrentScene=e=>{if(e){this.removeActiveScene(e);let t=a;a=e,t&&t.setInteractiveControlEnable(!1),a.setInteractiveControlEnable(!0),a.setAdditionalScenesGroup(w),j=!0,this.onWindowResize()}},this.getSceneByName=e=>S[e],this.createScene=e=>{if(S[e]==null){let t;return t=T?new ir(T,i):new ir(n,i),S[e]=t,t.sceneName=e,t}},this.resetView=()=>{a.resetView()},this.viewAll=()=>{if(a){let e=a.getBoundingBox();if(e){for(let t=0;t<C.length;t++){let n=C[t].getBoundingBox();n&&e.union(n)}a.viewAllWithBoundingBox(e)}}},this.loadModelsURL=(e,t,n,r,i,o)=>{a.loadModelsURL(e,t,n,r,i,o)},this.loadViewURL=e=>{a.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{a.loadFromViewURL(e,t)},this.updateDirectionalLight=()=>{a.updateDirectionalLight()};let te=()=>{D?(g=requestAnimationFrame(te),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{D&&=!1},this.animate=()=>{D||(o.reset(),D=!0,j=!0,te())},this.addContextLostCallbackFunction=e=>(p+=1,f[p]=e,p),this.removeContextLostCallbackFunction=e=>{e in f&&delete f[e]},this.addContextRestoredCallbackFunction=e=>(h+=1,m[h]=e,h),this.removeContextRestoredCallbackFunction=e=>{e in h&&delete h[e]},this.addPreRenderCallbackFunction=e=>(l+=1,c[l]=e,l),this.removePreRenderCallbackFunction=e=>{e in c&&delete c[e]},this.addPostRenderCallbackFunction=e=>(d+=1,u[d]=e,d),this.removePostRenderCallbackFunction=e=>{e in u&&delete u[e]},this.getPlayRate=()=>s,this.setPlayRate=e=>{s=e,j=!0},this.setRenderOnDemand=e=>{A=!!e,j=!0},this.isRenderOnDemand=()=>A,this.invalidate=()=>{j=!0},this.getCurrentTime=()=>a.getCurrentTime(),this.setMorphsTime=e=>{a.setMorphsTime(e)},this.getZincGeometryByID=e=>a.getZincGeometryByID(e),this.addToScene=e=>{a.addObject(e)},this.addToOrthoScene=t=>{if(b??=new e.Scene,_==null){let t=this.getDrawingWidth(),n=this.getDrawingHeight();_=new e.OrthographicCamera(-t/2,t/2,n/2,-n/2,1,10),_.position.z=10}b.add(t),j=!0};let ne=t=>n=>{n.needsUpdate=!0;let r=new e.SpriteMaterial({map:n}),i=r.map.image.width,a=r.map.image.height;t.material=r,t.scale.set(i,a,1);let o=this.getDrawingWidth(),s=this.getDrawingHeight();t.position.set((o-i)/2,(-s+a)/2,1),this.addToOrthoScene(t)};this.addLogo=()=>{x=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,ne(x))},this.render=()=>{E||(n?n.clientWidth>0&&n.clientHeight>0&&(E=new r.ResizeSensor(n,this.onWindowResize)):T&&T.width>0&&T.height>0&&(E=new r.ResizeSensor(T,this.onWindowResize))),o.update();let e=o.getDelta(),t=a.renderGeometries(s,e,this.playAnimation);C.length>0&&(N.controls=a.getZincCameraControls(),N.updated=a.isCameraUpdated());for(let n=0;n<C.length;n++)C[n].renderGeometries(s,e,this.playAnimation,N)&&(t=!0);for(let e in c)c.hasOwnProperty(e)&&c[e].call();if(!(A&&!t&&!j)){j=!1,a.render(i),_!=null&&b!=null&&(i.clearDepth(),i.render(b,_));for(let e in u)u.hasOwnProperty(e)&&u[e].call()}},this.forceContextLoss=()=>{},this.forceContextRestore=()=>{},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<C.length;t++)if(C[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(C.push(e),w.add(e.getThreeJSScene()),j=!0)},this.removeActiveScene=e=>{for(let t=0;t<C.length;t++)if(C[t]===e){C.splice(t,1),w.remove(e.getThreeJSScene()),j=!0;return}},this.clearAllActiveScene=()=>{for(let e=0;e<C.length;e++)w.remove(C[e].getThreeJSScene());C.splice(0,C.length),j=!0},this.dispose=()=>{D&&cancelAnimationFrame(g);for(let e in S)S.hasOwnProperty(e)&&S[e].clearAll();S=[],C=[],w=new e.Group,this.stopAnimate(),c={},l=0,u={},d=0,f={},p=0,m={},h=0,_=void 0,b=void 0,x=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),E=void 0,y(M),i?.dispose()},this.transitionScene=(e,t)=>{if(a){let n=a.getZincCameraControls(),r=e.getBoundingBox();if(r){let e=r.min.distanceTo(r.max)/2,i=(r.min.x+r.max.x)/2,a=(r.min.y+r.max.y)/2,o=(r.min.z+r.max.z)/2,s=n.getViewportFromCentreAndRadius(i,a,o,e,40,e*4),c=n.getCurrentViewport();n.cameraTransition(c,s,t),n.enableCameraTransition()}}},this.isWebGL2=()=>i?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>i?.backend?.isWebGPUBackend===!0},or=class{esize;ecode;edata;littleEndian;constructor(e,t,n,r){if(e%16!=0)throw Error(`This does not appear to be a NIFTI extension`);this.esize=e,this.ecode=t,this.edata=n,this.littleEndian=r}toArrayBuffer(){let e=new Uint8Array(this.esize),t=new Uint8Array(this.edata);e.set(t,8);let n=new DataView(e.buffer);return n.setInt32(0,this.esize,this.littleEndian),n.setInt32(4,this.ecode,this.littleEndian),e.buffer}},F=class e{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,t,n){var r=``,i,a;for(i=t;i<n;i+=1)a=e.getUint8(i),a!==0&&(r+=String.fromCharCode(a));return r}static getByteAt=function(e,t){return e.getUint8(t)};static getShortAt=function(e,t,n){return e.getInt16(t,n)};static getIntAt(e,t,n){return e.getInt32(t,n)}static getFloatAt(e,t,n){return e.getFloat32(t,n)}static getDoubleAt(e,t,n){return e.getFloat64(t,n)}static getInt64At(e,t,n){let r=e.getUint32(t,n),i=e.getInt32(t+4,n),a;return a=n?i*2**32+r:r*2**32+i,i<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,t,n){let r=e.getUint32(t+(n?0:4),n),i=e.getUint32(t+(n?4:0),n);return n?i*2**32+r:r*2**32+i}static getExtensionsAt(t,n,r,i){let a=[],o=n;for(;o<i;){let n=r,s=e.getIntAt(t,o,r);if(!s)break;if(s+o>i&&(n=!n,s=e.getIntAt(t,o,n),s+o>i))throw Error(`This does not appear to be a valid NIFTI extension`);if(s%16!=0)throw Error(`This does not appear to be a NIFTI extension`);let c=e.getIntAt(t,o+4,n),l=t.buffer.slice(o+8,o+s),u=new or(s,c,l,n);a.push(u),o+=s}return a}static toArrayBuffer(e){var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r;for(r=0;r<e.length;r+=1)n[r]=e[r];return t}static isString(e){return typeof e==`string`||e instanceof String}static formatNumber(t,n=void 0){let r;return r=e.isString(t)?Number(t):t,r=n?r.toPrecision(5):r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}static crc32(t){e.crcTable||=e.makeCRCTable();let n=e.crcTable,r=-1;for(var i=0;i<t.byteLength;i++)r=r>>>8^n[(r^t.getUint8(i))&255];return(r^-1)>>>0}},sr=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic=`0`;isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(t){var n=new DataView(t),r=F.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=F.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=F.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=F.getShortAt(n,s,this.littleEndian);for(this.intent_p1=F.getFloatAt(n,56,this.littleEndian),this.intent_p2=F.getFloatAt(n,60,this.littleEndian),this.intent_p3=F.getFloatAt(n,64,this.littleEndian),this.intent_code=F.getShortAt(n,68,this.littleEndian),this.datatypeCode=F.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=F.getShortAt(n,72,this.littleEndian),this.slice_start=F.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=F.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=F.getFloatAt(n,108,this.littleEndian),this.scl_slope=F.getFloatAt(n,112,this.littleEndian),this.scl_inter=F.getFloatAt(n,116,this.littleEndian),this.slice_end=F.getShortAt(n,120,this.littleEndian),this.slice_code=F.getByteAt(n,122),this.xyzt_units=F.getByteAt(n,123),this.cal_max=F.getFloatAt(n,124,this.littleEndian),this.cal_min=F.getFloatAt(n,128,this.littleEndian),this.slice_duration=F.getFloatAt(n,132,this.littleEndian),this.toffset=F.getFloatAt(n,136,this.littleEndian),this.description=F.getStringAt(n,148,228),this.aux_file=F.getStringAt(n,228,252),this.qform_code=F.getShortAt(n,252,this.littleEndian),this.sform_code=F.getShortAt(n,254,this.littleEndian),this.quatern_b=F.getFloatAt(n,256,this.littleEndian),this.quatern_c=F.getFloatAt(n,260,this.littleEndian),this.quatern_d=F.getFloatAt(n,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(this.quatern_b**2+this.quatern_c**2+this.quatern_d**2)),this.qoffset_x=F.getFloatAt(n,268,this.littleEndian),this.qoffset_y=F.getFloatAt(n,272,this.littleEndian),this.qoffset_z=F.getFloatAt(n,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){let e=this.quatern_a,t=this.quatern_b,n=this.quatern_c,r=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[e*e+t*t-n*n-r*r,2*t*n-2*e*r,2*t*r+2*e*n],[2*t*n+2*e*r,e*e+n*n-t*t-r*r,2*n*r-2*e*t],[2*t*r-2*e*n,2*n*r+2*e*t,e*e+r*r-n*n-t*t]],a=0;a<3;a+=1)for(o=0;o<3;o+=1)this.affine[a][o]=this.quatern_R[a][o]*this.pixDims[o+1],o===2&&(this.affine[a][o]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(a=0;a<3;a+=1)for(o=0;o<4;o+=1)s=280+(a*4+o)*4,this.affine[a][o]=F.getFloatAt(n,s,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=F.getStringAt(n,328,344),this.magic=F.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=F.getByteAt(n,348),this.extensionFlag[1]=F.getByteAt(n,349),this.extensionFlag[2]=F.getByteAt(n,350),this.extensionFlag[3]=F.getByteAt(n,351);let e=!0;!this.isHDR&&this.vox_offset<=352&&(e=!1),n.byteLength<=368&&(e=!1),e&&this.extensionFlag[0]&&(this.extensions=F.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=F.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
560
560
  `,n+=`Image Dimensions (1-8): `+this.dims[0]+`, `+this.dims[1]+`, `+this.dims[2]+`, `+this.dims[3]+`, `+this.dims[4]+`, `+this.dims[5]+`, `+this.dims[6]+`, `+this.dims[7]+`
561
561
  `,n+=`Intent Parameters (1-3): `+this.intent_p1+`, `+this.intent_p2+`, `+this.intent_p3+`
562
562
  `,n+=`Intent Code = `+this.intent_code+`