iflow-engine-base 1.1.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(xt,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],S):(xt=typeof globalThis<"u"?globalThis:xt||self,S(xt.BimEngineSDK={},xt.THREE))})(this,(function(xt,S){"use strict";function Lo(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const T=Lo(S);class Oo{engine;scene;constructor(e){this.engine=e,this.scene=new T.Scene;let t=new T.Group;t.name="groupEdge",this.scene.add(t)}}class zo{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new T.PerspectiveCamera(60,this.engine.container.clientWidth/this.engine.container.clientHeight,.1,1e3),this.perspectiveCamera.position.set(2,2,2),this.perspectiveCamera.lookAt(0,0,0);const t=50,n=this.engine.container.clientWidth/this.engine.container.clientHeight;this.orthographicCamera=new T.OrthographicCamera(t*n/-2,t*n/2,t/2,t/-2,.1,1e3)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}updateComposerCamera(){if(!this.engine.composerModule?.composer)return;const e=this.engine.camera,t=this.engine.composerModule.composer;if(t.passes)for(const n of t.passes)n.camera!==void 0&&(n.camera=e)}switchToPerspectiveCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.perspectiveCamera,this.engine.scene.camera=this.perspectiveCamera,this.perspectiveCamera.position.copy(e),this.perspectiveCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.perspectiveCamera,this.engine.controlModule.firstPersonControls.camera=this.perspectiveCamera,this.updateComposerCamera(),this.perspectiveCamera.updateProjectionMatrix(),this.perspectiveCamera.updateMatrixWorld()}switchToOrthographicCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.orthographicCamera,this.engine.scene.camera=this.orthographicCamera,this.orthographicCamera.position.copy(e),this.orthographicCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.orthographicCamera,this.engine.controlModule.firstPersonControls.camera=this.orthographicCamera,this.updateComposerCamera(),this.orthographicCamera.updateProjectionMatrix(),this.orthographicCamera.updateMatrixWorld()}getCameraType(){return this.engine.camera===this.perspectiveCamera?"perspective":this.engine.camera===this.orthographicCamera?"orthographic":"perspective"}getCameraPose(){const e=this.engine.camera,t=this.getCameraType(),n={type:t,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w}};return this.engine.controls&&this.engine.controls.target&&(n.target={x:this.engine.controls.target.x,y:this.engine.controls.target.y,z:this.engine.controls.target.z}),t==="orthographic"&&(n.zoom=e.zoom),n}restoreCameraPose(e){this.getCameraType()!==e.type&&(e.type==="perspective"?this.switchToPerspectiveCamera():this.switchToOrthographicCamera());const n=this.engine.camera;n.position.set(e.position.x,e.position.y,e.position.z),e.quaternion?n.quaternion.set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w):e.rotation&&n.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.target&&this.engine.controls&&this.engine.controls.target&&this.engine.controls.target.set(e.target.x,e.target.y,e.target.z),e.type==="orthographic"&&e.zoom!==void 0&&(n.zoom=e.zoom,n.updateProjectionMatrix()),n.updateMatrix(),n.updateMatrixWorld(!0),this.engine.controls&&this.engine.controls.update&&this.engine.controls.update()}}class No{engine;deviceType;constructor(e){this.engine=e,this.deviceType="PC"}getDeviceType(){return this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class Ro{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new T.WebGLRenderer({alpha:!0,premultipliedAlpha:!1,stencil:!0}),this.renderer.setClearColor(0,0),this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=T.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=T.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Ps={type:"change"},yi={type:"start"},Ds={type:"end"},xn=new S.Ray,ks=new S.Plane,Fo=Math.cos(70*S.MathUtils.DEG2RAD),xe=new S.Vector3,Oe=2*Math.PI,ue={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},wi=1e-6;class Uo extends S.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=ue.NONE,this.target=new S.Vector3,this.cursor=new S.Vector3,this.origin=new S.Vector3(0,0,0),this.showOriginIcon=!0,this.originPosition={x:0,y:0},this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:S.MOUSE.ROTATE,MIDDLE:S.MOUSE.DOLLY,RIGHT:S.MOUSE.PAN},this.touches={ONE:S.TOUCH.ROTATE,TWO:S.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new S.Vector3,this._lastQuaternion=new S.Quaternion,this._lastTargetPosition=new S.Vector3,this._quat=new S.Quaternion().setFromUnitVectors(t.up,new S.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new S.Spherical,this._sphericalDelta=new S.Spherical,this._scale=1,this._panOffset=new S.Vector3,this._rotateStart=new S.Vector2,this._rotateEnd=new S.Vector2,this._rotateDelta=new S.Vector2,this._panStart=new S.Vector2,this._panEnd=new S.Vector2,this._panDelta=new S.Vector2,this._dollyStart=new S.Vector2,this._dollyEnd=new S.Vector2,this._dollyDelta=new S.Vector2,this._dollyDirection=new S.Vector3,this._mouse=new S.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=jo.bind(this),this._onPointerDown=Vo.bind(this),this._onPointerUp=Go.bind(this),this._onContextMenu=$o.bind(this),this._onMouseWheel=qo.bind(this),this._onKeyDown=Ko.bind(this),this._onTouchStart=Zo.bind(this),this._onTouchMove=Yo.bind(this),this._onMouseDown=Wo.bind(this),this._onMouseMove=Xo.bind(this),this._interceptControlDown=Jo.bind(this),this._interceptControlUp=Ho.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ps),this.update(),this.state=ue.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;xe.copy(t).sub(this.target),xe.applyQuaternion(this._quat),this._spherical.setFromVector3(xe),this.autoRotate&&this.state===ue.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Oe:n>Math.PI&&(n-=Oe),i<-Math.PI?i+=Oe:i>Math.PI&&(i-=Oe),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(xe.setFromSpherical(this._spherical),xe.applyQuaternion(this._quatInverse),this.engine&&this.engine.DeviceType==="PC"){const o=new S.Vector3;if(o.copy(this.origin).sub(this.target),o.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,h=new S.Vector3(0,1,0),c=new S.Vector3;this.object.getWorldDirection(c);const u=c.clone().cross(h).normalize(),p=new S.Vector3().copy(this.object.position).sub(this.origin);p.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(u,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(p);const f=new S.Vector3().copy(this.target).sub(this.origin);f.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),f.applyAxisAngle(u,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(f)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const l=new S.Vector3;this.object.getWorldDirection(l);const h=this._spherical.radius*.05*(this._scale-1);t.add(l.multiplyScalar(h))}}else t.copy(this.target).add(xe);this.object.lookAt(this.target)}else t.copy(this.target).add(xe),this.object.lookAt(this.target);if(this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=xe.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new S.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const h=new S.Vector3(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(a),this.object.updateMatrixWorld(),o=xe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(xn.origin.copy(this.object.position),xn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(xn.direction))<Fo?this.object.lookAt(this.target):(ks.setFromNormalAndCoplanarPoint(this.object.up,this.target),xn.intersectPlane(ks,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>wi||8*(1-this._lastQuaternion.dot(this.object.quaternion))>wi||this._lastTargetPosition.distanceToSquared(this.target)>wi?(this.dispatchEvent(Ps),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Oe/60*this.autoRotateSpeed*e:Oe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){xe.setFromMatrixColumn(t,0),xe.multiplyScalar(-e),this._panOffset.add(xe)}_panUp(e,t){this.screenSpacePanning===!0?xe.setFromMatrixColumn(t,1):(xe.setFromMatrixColumn(t,0),xe.crossVectors(this.object.up,xe)),xe.multiplyScalar(e),this._panOffset.add(xe)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;xe.copy(i).sub(this.target);let s=xe.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Oe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY);let t;if(this.object.isOrthographicCamera)e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY!==0&&this._dollyOut(this._getZoomScale(e.deltaY));else{const n=Math.abs(e.deltaY*.01);t=Math.pow(1.15,this.zoomSpeed*n),e.deltaY>0?this._scale/=t:e.deltaY!==0&&(this._scale*=t)}this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Oe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new S.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Vo(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function jo(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function Go(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Ds),this.state=ue.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Wo(r){if(this.showOriginIcon&&this.engine&&this.engine.ToolUntils){const t=this.engine.scene?.camera||this.object;this.originPosition=this.engine.ToolUntils.WorldPointToScreenPoint(this.origin.clone(),t),console.log("Origin position:",this.originPosition,"Origin:",this.origin)}let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case S.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=ue.DOLLY;break;case S.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=ue.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=ue.ROTATE}break;case S.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=ue.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=ue.PAN}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(yi)}function Xo(r){switch(this.state){case ue.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case ue.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case ue.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function qo(r){this.enabled===!1||this.enableZoom===!1||this.state!==ue.NONE||(r.preventDefault(),this.dispatchEvent(yi),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(Ds))}function Ko(r){this.enabled!==!1&&this._handleKeyDown(r)}function Zo(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case S.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=ue.TOUCH_ROTATE;break;case S.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=ue.TOUCH_PAN;break;default:this.state=ue.NONE}break;case 2:switch(this.touches.TWO){case S.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=ue.TOUCH_DOLLY_PAN;break;case S.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=ue.TOUCH_DOLLY_ROTATE;break;default:this.state=ue.NONE}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(yi)}function Yo(r){switch(this._trackPointer(r),this.state){case ue.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case ue.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case ue.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case ue.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=ue.NONE}}function $o(r){this.enabled!==!1&&r.preventDefault()}function Jo(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Ho(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Is{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new T.Vector3(0,-1,0),this._camerLocalDirection=new T.Vector3,this._tmpVector=new T.Vector3,this._rayCaster=new T.Raycaster,this._fallingTime=0,this._euler=new T.Euler(0,0,0,"YZX"),this._prevMouseX=0,this._prevMouseY=0,this.applyGravity=!1,this.gravityMinHeight=!0,this.applyCollision=!0,this.positionEasing=!0,this.lookflag=1,this.lookSpeed=.008,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=.8,this.g=9.8,this.bindmousedown=this._Engine&&this._Engine.DeviceType!=="PC"?this.onTouchStart.bind(this):this.onMouseDown.bind(this),this.bindmouseup=this._Engine&&this._Engine.DeviceType!=="PC"?this.onTouchEnd.bind(this):this.onMouseUp.bind(this),this.bindmousemove=this._Engine&&this._Engine.DeviceType!=="PC"?this.onTouchMove.bind(this):this.onMouseMove.bind(this),this.bindonKeyDown=this.onKeyDown.bind(this),this.bindonKeyUp=this.onKeyUp.bind(this),this.bindMousewheel=this.onMousewheel.bind(this),this.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),window.addEventListener("keydown",this.bindonKeyDown,!1),window.addEventListener("keyup",this.bindonKeyUp,!1),this.needMousewheel&&(document.addEventListener&&document.addEventListener("DOMMouseScroll",this.bindMousewheel,!1),window.addEventListener("mousewheel",this.bindMousewheel,!1))}removeEvents(){this._Engine&&this._Engine.DeviceType!=="PC"?(this.domElement.removeEventListener("touchstart",this.bindmousedown),this.domElement.removeEventListener("touchend",this.bindmouseup),this.domElement.removeEventListener("touchmove",this.bindmousemove)):(this.domElement.removeEventListener("mousedown",this.bindmousedown),this.domElement.removeEventListener("mouseup",this.bindmouseup),this.domElement.removeEventListener("mousemove",this.bindmousemove)),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMousewheel(e){debugger;let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,n=this._prevMouseY?e.screenY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let s=this.GetEngine();s.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,n=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let s=this.GetEngine();s.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){var t=new CustomEvent("bimengine:camerachange",{detail:""});let n=this.GetEngine();switch(n.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break}}onKeyUp(e){let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t){const n=t.point.add(new T.Vector3(0,this.playerHeight,0));if(this.positionEasing){if(n.y>=this.camera.position.y||n.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(n.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(n.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new T.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var n=this.GetEngine().scene.ground;return n&&n.material.type,null}}function bi(r){const e={self:null,options:null,mouseDownTime:0,lastClickTime:0};e.init=function(u,p){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,p==null&&(p={showCatch:!1}),e.options=p},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.container.addEventListener("mousedown",a),r.container.addEventListener("mouseup",h),r.container.addEventListener("mousemove",l),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){r.container.removeEventListener("mousedown",a),r.container.removeEventListener("mouseup",h),r.container.removeEventListener("mousemove",l),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(u){(u.keyCode===8||u.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),u.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),u.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),u.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(u){u.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),u.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),u.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),u.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(u){const p=new T.Vector2,f=r.renderer.domElement.clientWidth,d=r.renderer.domElement.clientHeight;return p.x=u.offsetX/f*2-1,p.y=-(u.offsetY/d)*2+1,p}function s(u){const p=new T.Raycaster,f=i(u);return p.setFromCamera(f,r.camera),p}function o(u,p=!1){const f=s(u);if(u.raycaster=f,p){const d=c(f,u);u.catch=d}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.self&&e.self.handleMouseDown!=null&&(o(u,!0),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&(o(u,!0),e.self.handleMouseMove(u))}function h(u){if(u.button!==0)return;const p=Date.now(),f=p-e.mouseDownTime;if(e.self&&e.self.handleMouseUp!=null&&(o(u,!1),e.self.handleMouseUp(u)),f<100&&e.self&&e.self.handleMouseClick!=null){o(u,!0);const d=p-e.lastClickTime;console.log(d),d<200?e.self.handleMouseDoubleClick(u):e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function c(u,p){r.catchSvg.innerHTML="";const f=r.octreeBox.rayInterationModel(u);if(f.length===0)return;let d=f[0].object.url,m=f[0].object.name,g=r.modelEdge.getModelEdge(d,m);g||(g=[0,0,[]]);let y="face",w=[],b=[],x=5;if(g[2].map(k=>k[0]).forEach(k=>{let C=new T.Vector3(k.X,k.Z,-k.Y),I=r.worldToScreen.worldToScreen(C),O=Math.sqrt(Math.pow(I.x-p.offsetX,2)+Math.pow(I.y-p.offsetY,2));O<x&&(x=O,w.push({point:C,distance:O,pointxy:I}))}),w.length>0?(w.sort((k,C)=>k.distance-C.distance),y="point"):(g[2].forEach(k=>{let C=new T.Vector3(k[0].X,k[0].Z,-k[0].Y),I=new T.Vector3(k[1].X,k[1].Z,-k[1].Y),O=r.worldToScreen.worldToScreen(C),A=r.worldToScreen.worldToScreen(I),E=_(new T.Vector2(p.offsetX,p.offsetY),O,A);if(E<x){let v=D(new T.Vector2(p.offsetX,p.offsetY),O,A),z=P(v,C,I);b.push({distance:E,point:z,pointxy:r.worldToScreen.worldToScreen(z),start:O,end:A})}}),b.length>0&&(b.sort((k,C)=>k.distance-C.distance),y="line")),y=="point"&&e.options.showCatch){const k=r.worldToScreen.worldToScreen(w[0].point);console.log("捕捉点屏幕坐标:",k.x,k.y),console.log("Canvas尺寸:",r.renderer.domElement.width,r.renderer.domElement.height),console.log("SVG尺寸:",r.catchSvg.clientWidth,r.catchSvg.clientHeight),r.catchSvg.innerHTML="";const C=document.createElementNS("http://www.w3.org/2000/svg","circle");C.setAttribute("class","catchPoint"),C.setAttribute("cx",(k.x+r.reactBoundingClientRect.left).toString()),C.setAttribute("cy",(k.y+r.reactBoundingClientRect.top).toString()),C.setAttribute("r","5"),C.setAttribute("fill","rgb(0, 255, 247)"),r.catchSvg.appendChild(C)}else if(y=="line"&&e.options.showCatch){const k=r.worldToScreen.worldToScreen(b[0].point),C=b[0].start,I=b[0].end;console.log("捕捉点屏幕坐标:",k.x,k.y),console.log("Canvas尺寸:",r.renderer.domElement.width,r.renderer.domElement.height),console.log("SVG尺寸:",r.catchSvg.clientWidth,r.catchSvg.clientHeight),r.catchSvg.innerHTML="";const O=document.createElementNS("http://www.w3.org/2000/svg","line");O.setAttribute("class","catchLine"),O.setAttribute("x1",(C.x+r.reactBoundingClientRect.left).toString()),O.setAttribute("y1",(C.y+r.reactBoundingClientRect.top).toString()),O.setAttribute("x2",(I.x+r.reactBoundingClientRect.left).toString()),O.setAttribute("y2",(I.y+r.reactBoundingClientRect.top).toString()),O.setAttribute("stroke","rgb(0, 255, 247)"),O.setAttribute("stroke-width","2"),r.catchSvg.appendChild(O)}else if(y=="face"&&e.options.showCatch){let k=f[0].point.clone(),C=f[0].normal||(f[0].face?f[0].face.normal:null);const I=(C?C.clone():new T.Vector3(0,0,1)).normalize(),O=Math.abs(I.y)<.9?new T.Vector3(0,1,0):new T.Vector3(1,0,0),A=new T.Vector3().crossVectors(I,O).normalize(),E=new T.Vector3().crossVectors(I,A).normalize(),v=.05,W=[new T.Vector3().copy(A).add(E).multiplyScalar(v),new T.Vector3().copy(A).sub(E).multiplyScalar(v),new T.Vector3().copy(A).multiplyScalar(-1).sub(E).multiplyScalar(v),new T.Vector3().copy(A).multiplyScalar(-1).add(E).multiplyScalar(v)].map(G=>new T.Vector3().copy(k).add(G)).map(G=>r.worldToScreen.worldToScreen(G));r.catchSvg.innerHTML="";const Q=document.createElementNS("http://www.w3.org/2000/svg","polygon");Q.setAttribute("class","catchFace"),Q.setAttribute("points",W.map(G=>`${G.x+r.reactBoundingClientRect.left},${G.y+r.reactBoundingClientRect.top}`).join(" ")),Q.setAttribute("fill","rgba(1, 238, 255, 0.2)"),Q.setAttribute("stroke","rgb(0, 255, 247)"),Q.setAttribute("stroke-width","1"),r.catchSvg.appendChild(Q)}return f[0];function _(k,C,I){const O=new T.Vector2().subVectors(I,C),A=O.lengthSq();if(A<1e-10)return k.distanceTo(C);const E=new T.Vector2().subVectors(k,C),v=T.MathUtils.clamp(E.dot(O)/A,0,1),z=new T.Vector2().copy(O).multiplyScalar(v).add(C);return k.distanceTo(z)}function D(k,C,I){const O=new T.Vector2().subVectors(I,C),A=O.lengthSq();if(A<1e-10)return 0;const E=new T.Vector2().subVectors(k,C);return T.MathUtils.clamp(E.dot(O)/A,0,1)}function P(k,C,I){const O=T.MathUtils.clamp(k,0,1);return new T.Vector3().lerpVectors(C,I,O)}}return e}class Qo{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=bi(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Uo(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Is(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e}getMoveSpeed(){return this.firstPersonControls.moveSpeed}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new Is(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1,this.engine.cameraModule.switchToOrthographicCamera()),this.orbitControls.enabled=!0}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,n=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=n.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=n.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const _n={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
1
+ (function(_t,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],S):(_t=typeof globalThis<"u"?globalThis:_t||self,S(_t.BimEngineSDK={},_t.THREE))})(this,(function(_t,S){"use strict";function Oo(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const T=Oo(S);class zo{engine;scene;constructor(e){this.engine=e,this.scene=new T.Scene;let t=new T.Group;t.name="groupEdge",this.scene.add(t)}}class No{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new T.PerspectiveCamera(60,this.engine.container.clientWidth/this.engine.container.clientHeight,.1,1e3),this.perspectiveCamera.position.set(2,2,2),this.perspectiveCamera.lookAt(0,0,0);const t=50,n=this.engine.container.clientWidth/this.engine.container.clientHeight;this.orthographicCamera=new T.OrthographicCamera(t*n/-2,t*n/2,t/2,t/-2,.1,1e3)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}updateComposerCamera(){if(!this.engine.composerModule?.composer)return;const e=this.engine.camera,t=this.engine.composerModule.composer;if(t.passes)for(const n of t.passes)n.camera!==void 0&&(n.camera=e)}switchToPerspectiveCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.perspectiveCamera,this.engine.scene.camera=this.perspectiveCamera,this.perspectiveCamera.position.copy(e),this.perspectiveCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.perspectiveCamera,this.engine.controlModule.firstPersonControls.camera=this.perspectiveCamera,this.updateComposerCamera(),this.perspectiveCamera.updateProjectionMatrix(),this.perspectiveCamera.updateMatrixWorld()}switchToOrthographicCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.orthographicCamera,this.engine.scene.camera=this.orthographicCamera,this.orthographicCamera.position.copy(e),this.orthographicCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.orthographicCamera,this.engine.controlModule.firstPersonControls.camera=this.orthographicCamera,this.updateComposerCamera(),this.orthographicCamera.updateProjectionMatrix(),this.orthographicCamera.updateMatrixWorld()}getCameraType(){return this.engine.camera===this.perspectiveCamera?"perspective":this.engine.camera===this.orthographicCamera?"orthographic":"perspective"}getCameraPose(){const e=this.engine.camera,t=this.getCameraType(),n={type:t,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w}};return this.engine.controls&&this.engine.controls.target&&(n.target={x:this.engine.controls.target.x,y:this.engine.controls.target.y,z:this.engine.controls.target.z}),t==="orthographic"&&(n.zoom=e.zoom),n}restoreCameraPose(e){this.getCameraType()!==e.type&&(e.type==="perspective"?this.switchToPerspectiveCamera():this.switchToOrthographicCamera());const n=this.engine.camera;n.position.set(e.position.x,e.position.y,e.position.z),e.quaternion?n.quaternion.set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w):e.rotation&&n.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.target&&this.engine.controls&&this.engine.controls.target&&this.engine.controls.target.set(e.target.x,e.target.y,e.target.z),e.type==="orthographic"&&e.zoom!==void 0&&(n.zoom=e.zoom,n.updateProjectionMatrix()),n.updateMatrix(),n.updateMatrixWorld(!0),this.engine.controls&&this.engine.controls.update&&this.engine.controls.update()}}class Ro{engine;deviceType;constructor(e){this.engine=e,this.deviceType="PC"}getDeviceType(){return this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class Fo{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new T.WebGLRenderer({alpha:!0,premultipliedAlpha:!1,stencil:!0}),this.renderer.setClearColor(0,0),this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=T.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=T.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Ds={type:"change"},wi={type:"start"},ks={type:"end"},xn=new S.Ray,Is=new S.Plane,Uo=Math.cos(70*S.MathUtils.DEG2RAD),_e=new S.Vector3,Oe=2*Math.PI,ue={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},bi=1e-6;class Vo extends S.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=ue.NONE,this.target=new S.Vector3,this.origin=new S.Vector3(0,0,0),this.cursor=new S.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:S.MOUSE.ROTATE,MIDDLE:S.MOUSE.DOLLY,RIGHT:S.MOUSE.PAN},this.touches={ONE:S.TOUCH.ROTATE,TWO:S.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new S.Vector3,this._lastQuaternion=new S.Quaternion,this._lastTargetPosition=new S.Vector3,this._quat=new S.Quaternion().setFromUnitVectors(t.up,new S.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new S.Spherical,this._sphericalDelta=new S.Spherical,this._scale=1,this._panOffset=new S.Vector3,this._rotateStart=new S.Vector2,this._rotateEnd=new S.Vector2,this._rotateDelta=new S.Vector2,this._panStart=new S.Vector2,this._panEnd=new S.Vector2,this._panDelta=new S.Vector2,this._dollyStart=new S.Vector2,this._dollyEnd=new S.Vector2,this._dollyDelta=new S.Vector2,this._dollyDirection=new S.Vector3,this._mouse=new S.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Go.bind(this),this._onPointerDown=jo.bind(this),this._onPointerUp=Wo.bind(this),this._onContextMenu=Jo.bind(this),this._onMouseWheel=Ko.bind(this),this._onKeyDown=Zo.bind(this),this._onTouchStart=Yo.bind(this),this._onTouchMove=$o.bind(this),this._onMouseDown=Xo.bind(this),this._onMouseMove=qo.bind(this),this._interceptControlDown=Ho.bind(this),this._interceptControlUp=Qo.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ds),this.update(),this.state=ue.NONE}update(e=null){const t=this.object.position;_e.copy(t).sub(this.target),_e.applyQuaternion(this._quat),this._spherical.setFromVector3(_e),this.autoRotate&&this.state===ue.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Oe:n>Math.PI&&(n-=Oe),i<-Math.PI?i+=Oe:i>Math.PI&&(i-=Oe),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(_e.setFromSpherical(this._spherical),_e.applyQuaternion(this._quatInverse),t.copy(this.target).add(_e),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=_e.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new S.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const h=new S.Vector3(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(a),this.object.updateMatrixWorld(),o=_e.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(xn.origin.copy(this.object.position),xn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(xn.direction))<Uo?this.object.lookAt(this.target):(Is.setFromNormalAndCoplanarPoint(this.object.up,this.target),xn.intersectPlane(Is,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>bi||8*(1-this._lastQuaternion.dot(this.object.quaternion))>bi||this._lastTargetPosition.distanceToSquared(this.target)>bi?(this.dispatchEvent(Ds),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Oe/60*this.autoRotateSpeed*e:Oe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){_e.setFromMatrixColumn(t,0),_e.multiplyScalar(-e),this._panOffset.add(_e)}_panUp(e,t){this.screenSpacePanning===!0?_e.setFromMatrixColumn(t,1):(_e.setFromMatrixColumn(t,0),_e.crossVectors(this.object.up,_e)),_e.multiplyScalar(e),this._panOffset.add(_e)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;_e.copy(i).sub(this.target);let s=_e.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Oe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Oe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new S.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function jo(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function Go(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function Wo(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ks),this.state=ue.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Xo(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case S.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=ue.DOLLY;break;case S.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=ue.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=ue.ROTATE}break;case S.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=ue.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=ue.PAN}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(wi)}function qo(r){switch(this.state){case ue.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case ue.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case ue.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function Ko(r){this.enabled===!1||this.enableZoom===!1||this.state!==ue.NONE||(r.preventDefault(),this.dispatchEvent(wi),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(ks))}function Zo(r){this.enabled!==!1&&this._handleKeyDown(r)}function Yo(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case S.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=ue.TOUCH_ROTATE;break;case S.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=ue.TOUCH_PAN;break;default:this.state=ue.NONE}break;case 2:switch(this.touches.TWO){case S.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=ue.TOUCH_DOLLY_PAN;break;case S.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=ue.TOUCH_DOLLY_ROTATE;break;default:this.state=ue.NONE}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(wi)}function $o(r){switch(this._trackPointer(r),this.state){case ue.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case ue.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case ue.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case ue.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=ue.NONE}}function Jo(r){this.enabled!==!1&&r.preventDefault()}function Ho(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Qo(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Es{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new T.Vector3(0,-1,0),this._camerLocalDirection=new T.Vector3,this._tmpVector=new T.Vector3,this._rayCaster=new T.Raycaster,this._fallingTime=0,this._euler=new T.Euler(0,0,0,"YZX"),this._prevMouseX=0,this._prevMouseY=0,this.applyGravity=!1,this.gravityMinHeight=!0,this.applyCollision=!0,this.positionEasing=!0,this.lookflag=1,this.lookSpeed=.008,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=.8,this.g=9.8,this.bindmousedown=this._Engine&&this._Engine.DeviceType!=="PC"?this.onTouchStart.bind(this):this.onMouseDown.bind(this),this.bindmouseup=this._Engine&&this._Engine.DeviceType!=="PC"?this.onTouchEnd.bind(this):this.onMouseUp.bind(this),this.bindmousemove=this._Engine&&this._Engine.DeviceType!=="PC"?this.onTouchMove.bind(this):this.onMouseMove.bind(this),this.bindonKeyDown=this.onKeyDown.bind(this),this.bindonKeyUp=this.onKeyUp.bind(this),this.bindMousewheel=this.onMousewheel.bind(this),this.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),window.addEventListener("keydown",this.bindonKeyDown,!1),window.addEventListener("keyup",this.bindonKeyUp,!1),this.needMousewheel&&(document.addEventListener&&document.addEventListener("DOMMouseScroll",this.bindMousewheel,!1),window.addEventListener("mousewheel",this.bindMousewheel,!1))}removeEvents(){this._Engine&&this._Engine.DeviceType!=="PC"?(this.domElement.removeEventListener("touchstart",this.bindmousedown),this.domElement.removeEventListener("touchend",this.bindmouseup),this.domElement.removeEventListener("touchmove",this.bindmousemove)):(this.domElement.removeEventListener("mousedown",this.bindmousedown),this.domElement.removeEventListener("mouseup",this.bindmouseup),this.domElement.removeEventListener("mousemove",this.bindmousemove)),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMousewheel(e){debugger;let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,n=this._prevMouseY?e.screenY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let s=this.GetEngine();s.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,n=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let s=this.GetEngine();s.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){var t=new CustomEvent("bimengine:camerachange",{detail:""});let n=this.GetEngine();switch(n.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break}}onKeyUp(e){let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t){const n=t.point.add(new T.Vector3(0,this.playerHeight,0));if(this.positionEasing){if(n.y>=this.camera.position.y||n.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(n.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(n.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new T.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var n=this.GetEngine().scene.ground;return n&&n.material.type,null}}function xi(r){const e={self:null,options:null,mouseDownTime:0,lastClickTime:0};e.init=function(u,f){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,f==null&&(f={showCatch:!1}),e.options=f},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.container.addEventListener("mousedown",a),r.container.addEventListener("mouseup",h),r.container.addEventListener("mousemove",l),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){r.container.removeEventListener("mousedown",a),r.container.removeEventListener("mouseup",h),r.container.removeEventListener("mousemove",l),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(u){(u.keyCode===8||u.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),u.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),u.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),u.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(u){u.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),u.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),u.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),u.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(u){const f=new T.Vector2,p=r.renderer.domElement.clientWidth,d=r.renderer.domElement.clientHeight;return f.x=u.offsetX/p*2-1,f.y=-(u.offsetY/d)*2+1,f}function s(u){const f=new T.Raycaster,p=i(u);return f.setFromCamera(p,r.camera),f}function o(u,f=!1){const p=s(u);if(u.raycaster=p,f){const d=c(p,u);u.catch=d}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.self&&e.self.handleMouseDown!=null&&(o(u,!0),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&(o(u,!0),e.self.handleMouseMove(u))}function h(u){if(u.button!==0)return;const f=Date.now(),p=f-e.mouseDownTime;if(e.self&&e.self.handleMouseUp!=null&&(o(u,!1),e.self.handleMouseUp(u)),p<100&&e.self&&e.self.handleMouseClick!=null){o(u,!0);const d=f-e.lastClickTime;console.log(d),d<200?e.self.handleMouseDoubleClick(u):e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function c(u,f){if(!r.engineStatus.isFree){r.hoverHighLight.clearHighlight();return}r.catchSvg.innerHTML="";const p=r.octreeBox.rayInterationModel(u);if(p.length===0)return;let d=p[0].object.url,m=p[0].object.name,g=r.modelEdge.getModelEdge(d,m);g||(g=[0,0,[]]);let y="face",w=[],b=[],x=5;if(g[2].map(k=>k[0]).forEach(k=>{let C=new T.Vector3(k.X,k.Z,-k.Y),I=r.worldToScreen.worldToScreen(C),O=Math.sqrt(Math.pow(I.x-f.offsetX,2)+Math.pow(I.y-f.offsetY,2));O<x&&(x=O,w.push({point:C,distance:O,pointxy:I}))}),w.length>0?(w.sort((k,C)=>k.distance-C.distance),y="point"):(g[2].forEach(k=>{let C=new T.Vector3(k[0].X,k[0].Z,-k[0].Y),I=new T.Vector3(k[1].X,k[1].Z,-k[1].Y),O=r.worldToScreen.worldToScreen(C),A=r.worldToScreen.worldToScreen(I),B=_(new T.Vector2(f.offsetX,f.offsetY),O,A);if(B<x){let v=D(new T.Vector2(f.offsetX,f.offsetY),O,A),z=P(v,C,I);b.push({distance:B,point:z,pointxy:r.worldToScreen.worldToScreen(z),start:O,end:A})}}),b.length>0&&(b.sort((k,C)=>k.distance-C.distance),y="line")),y=="point"&&e.options.showCatch){const k=r.worldToScreen.worldToScreen(w[0].point);console.log("捕捉点屏幕坐标:",k.x,k.y),console.log("Canvas尺寸:",r.renderer.domElement.width,r.renderer.domElement.height),console.log("SVG尺寸:",r.catchSvg.clientWidth,r.catchSvg.clientHeight),r.catchSvg.innerHTML="";const C=document.createElementNS("http://www.w3.org/2000/svg","circle");C.setAttribute("class","catchPoint"),C.setAttribute("cx",(k.x+r.reactBoundingClientRect.left).toString()),C.setAttribute("cy",(k.y+r.reactBoundingClientRect.top).toString()),C.setAttribute("r","5"),C.setAttribute("fill","rgb(0, 255, 247)"),r.catchSvg.appendChild(C)}else if(y=="line"&&e.options.showCatch){const k=r.worldToScreen.worldToScreen(b[0].point),C=b[0].start,I=b[0].end;console.log("捕捉点屏幕坐标:",k.x,k.y),console.log("Canvas尺寸:",r.renderer.domElement.width,r.renderer.domElement.height),console.log("SVG尺寸:",r.catchSvg.clientWidth,r.catchSvg.clientHeight),r.catchSvg.innerHTML="";const O=document.createElementNS("http://www.w3.org/2000/svg","line");O.setAttribute("class","catchLine"),O.setAttribute("x1",(C.x+r.reactBoundingClientRect.left).toString()),O.setAttribute("y1",(C.y+r.reactBoundingClientRect.top).toString()),O.setAttribute("x2",(I.x+r.reactBoundingClientRect.left).toString()),O.setAttribute("y2",(I.y+r.reactBoundingClientRect.top).toString()),O.setAttribute("stroke","rgb(0, 255, 247)"),O.setAttribute("stroke-width","2"),r.catchSvg.appendChild(O)}else if(y=="face"&&e.options.showCatch){let k=p[0].point.clone(),C=p[0].normal||(p[0].face?p[0].face.normal:null);const I=(C?C.clone():new T.Vector3(0,0,1)).normalize(),O=Math.abs(I.y)<.9?new T.Vector3(0,1,0):new T.Vector3(1,0,0),A=new T.Vector3().crossVectors(I,O).normalize(),B=new T.Vector3().crossVectors(I,A).normalize(),v=.05,W=[new T.Vector3().copy(A).add(B).multiplyScalar(v),new T.Vector3().copy(A).sub(B).multiplyScalar(v),new T.Vector3().copy(A).multiplyScalar(-1).sub(B).multiplyScalar(v),new T.Vector3().copy(A).multiplyScalar(-1).add(B).multiplyScalar(v)].map(G=>new T.Vector3().copy(k).add(G)).map(G=>r.worldToScreen.worldToScreen(G));r.catchSvg.innerHTML="";const Q=document.createElementNS("http://www.w3.org/2000/svg","polygon");Q.setAttribute("class","catchFace"),Q.setAttribute("points",W.map(G=>`${G.x+r.reactBoundingClientRect.left},${G.y+r.reactBoundingClientRect.top}`).join(" ")),Q.setAttribute("fill","rgba(1, 238, 255, 0.2)"),Q.setAttribute("stroke","rgb(0, 255, 247)"),Q.setAttribute("stroke-width","1"),r.catchSvg.appendChild(Q)}return p[0];function _(k,C,I){const O=new T.Vector2().subVectors(I,C),A=O.lengthSq();if(A<1e-10)return k.distanceTo(C);const B=new T.Vector2().subVectors(k,C),v=T.MathUtils.clamp(B.dot(O)/A,0,1),z=new T.Vector2().copy(O).multiplyScalar(v).add(C);return k.distanceTo(z)}function D(k,C,I){const O=new T.Vector2().subVectors(I,C),A=O.lengthSq();if(A<1e-10)return 0;const B=new T.Vector2().subVectors(k,C);return T.MathUtils.clamp(B.dot(O)/A,0,1)}function P(k,C,I){const O=T.MathUtils.clamp(k,0,1);return new T.Vector3().lerpVectors(C,I,O)}}return e}class ea{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=xi(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Vo(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Es(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e}getMoveSpeed(){return this.firstPersonControls.moveSpeed}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new Es(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1,this.engine.cameraModule.switchToOrthographicCamera()),this.orbitControls.enabled=!0}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,n=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=n.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=n.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const _n={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
2
2
 
3
3
  varying vec2 vUv;
4
4
 
@@ -21,7 +21,7 @@
21
21
  gl_FragColor = opacity * texel;
22
22
 
23
23
 
24
- }`};class Rt{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const ea=new S.OrthographicCamera(-1,1,1,-1,0,1);class ta extends S.BufferGeometry{constructor(){super(),this.setAttribute("position",new S.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new S.Float32BufferAttribute([0,2,0,0,2,0],2))}}const na=new ta;class xi{constructor(e){this._mesh=new S.Mesh(na,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ea)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class vn extends Rt{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof S.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=S.UniformsUtils.clone(e.uniforms),this.material=new S.ShaderMaterial({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new xi(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Bs extends Rt{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class ia extends Rt{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class sa{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new S.Vector2);this._width=n.width,this._height=n.height,t=new S.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:S.HalfFloatType}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new vn(_n),this.copyPass.material.blending=S.NoBlending,this.clock=new S.Clock}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,s=this.passes.length;i<s;i++){const o=this.passes[i];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){const a=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Bs!==void 0&&(o instanceof Bs?n=!0:o instanceof ia&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new S.Vector2);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class ra extends Rt{constructor(e,t,n=null,i=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new S.Color}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=i}}const Mn={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new S.Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new S.Matrix4},cameraProjectionMatrixInverse:{value:new S.Matrix4},cameraWorldMatrix:{value:new S.Matrix4},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new S.Vector3(-1,-1,-1)},sceneBoxMax:{value:new S.Vector3(1,1,1)}},vertexShader:`
24
+ }`};class Ft{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const ta=new S.OrthographicCamera(-1,1,1,-1,0,1);class na extends S.BufferGeometry{constructor(){super(),this.setAttribute("position",new S.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new S.Float32BufferAttribute([0,2,0,0,2,0],2))}}const ia=new na;class _i{constructor(e){this._mesh=new S.Mesh(ia,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ta)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class vn extends Ft{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof S.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=S.UniformsUtils.clone(e.uniforms),this.material=new S.ShaderMaterial({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new _i(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class Bs extends Ft{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class sa extends Ft{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ra{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new S.Vector2);this._width=n.width,this._height=n.height,t=new S.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:S.HalfFloatType}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new vn(_n),this.copyPass.material.blending=S.NoBlending,this.clock=new S.Clock}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,s=this.passes.length;i<s;i++){const o=this.passes[i];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){const a=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Bs!==void 0&&(o instanceof Bs?n=!0:o instanceof sa&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new S.Vector2);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class oa extends Ft{constructor(e,t,n=null,i=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new S.Color}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=i}}const Mn={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new S.Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new S.Matrix4},cameraProjectionMatrixInverse:{value:new S.Matrix4},cameraWorldMatrix:{value:new S.Matrix4},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new S.Vector3(-1,-1,-1)},sceneBoxMax:{value:new S.Vector3(1,1,1)}},vertexShader:`
25
25
 
26
26
  varying vec2 vUv;
27
27
 
@@ -232,7 +232,7 @@
232
232
  float depth = getLinearDepth( vUv );
233
233
  gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
234
234
 
235
- }`},_i={uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
235
+ }`},vi={uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
236
236
  varying vec2 vUv;
237
237
 
238
238
  void main() {
@@ -246,7 +246,7 @@
246
246
  void main() {
247
247
  vec4 texel = texture2D( tDiffuse, vUv );
248
248
  gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
249
- }`};function oa(r=5){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=aa(e),n=t.length,i=new Uint8Array(n*4);for(let o=0;o<n;++o){const a=t[o],l=2*Math.PI*a/n,h=new S.Vector3(Math.cos(l),Math.sin(l),0).normalize();i[o*4]=(h.x*.5+.5)*255,i[o*4+1]=(h.y*.5+.5)*255,i[o*4+2]=127,i[o*4+3]=255}const s=new S.DataTexture(i,e,e);return s.wrapS=S.RepeatWrapping,s.wrapT=S.RepeatWrapping,s.needsUpdate=!0,s}function aa(r){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),s=e-1;for(let o=1;o<=t;){if(i===-1&&s===e?(s=e-2,i=0):(s===e&&(s=0),i<0&&(i=e-1)),n[i*e+s]!==0){s-=2,i++;continue}else n[i*e+s]=o++;s++,i--}return n}const An={defines:{SAMPLES:16,SAMPLE_VECTORS:Es(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new S.Vector2},cameraProjectionMatrixInverse:{value:new S.Matrix4},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
249
+ }`};function aa(r=5){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=la(e),n=t.length,i=new Uint8Array(n*4);for(let o=0;o<n;++o){const a=t[o],l=2*Math.PI*a/n,h=new S.Vector3(Math.cos(l),Math.sin(l),0).normalize();i[o*4]=(h.x*.5+.5)*255,i[o*4+1]=(h.y*.5+.5)*255,i[o*4+2]=127,i[o*4+3]=255}const s=new S.DataTexture(i,e,e);return s.wrapS=S.RepeatWrapping,s.wrapT=S.RepeatWrapping,s.needsUpdate=!0,s}function la(r){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),s=e-1;for(let o=1;o<=t;){if(i===-1&&s===e?(s=e-2,i=0):(s===e&&(s=0),i<0&&(i=e-1)),n[i*e+s]!==0){s-=2,i++;continue}else n[i*e+s]=o++;s++,i--}return n}const An={defines:{SAMPLES:16,SAMPLE_VECTORS:Ls(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new S.Vector2},cameraProjectionMatrixInverse:{value:new S.Matrix4},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
250
250
 
251
251
  varying vec2 vUv;
252
252
 
@@ -391,7 +391,7 @@
391
391
  denoised /= totalWeight;
392
392
  }
393
393
  gl_FragColor = FRAGMENT_OUTPUT;
394
- }`};function Es(r,e,t){const n=la(r,e,t);let i="vec3[SAMPLES](";for(let s=0;s<r;s++){const o=n[s];i+=`vec3(${o.x}, ${o.y}, ${o.z})${s<r-1?",":")"}`}return i}function la(r,e,t){const n=[];for(let i=0;i<r;i++){const s=2*Math.PI*e*i/r,o=Math.pow(i/(r-1),t);n.push(new S.Vector3(Math.cos(s),Math.sin(s),o))}return n}class ca{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,i,s;const o=.5*(Math.sqrt(3)-1),a=(e+t)*o,l=Math.floor(e+a),h=Math.floor(t+a),c=(3-Math.sqrt(3))/6,u=(l+h)*c,p=l-u,f=h-u,d=e-p,m=t-f;let g,y;d>m?(g=1,y=0):(g=0,y=1);const w=d-g+c,b=m-y+c,x=d-1+2*c,_=m-1+2*c,D=l&255,P=h&255,k=this.perm[D+this.perm[P]]%12,C=this.perm[D+g+this.perm[P+y]]%12,I=this.perm[D+1+this.perm[P+1]]%12;let O=.5-d*d-m*m;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],d,m));let A=.5-w*w-b*b;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[C],w,b));let E=.5-x*x-_*_;return E<0?s=0:(E*=E,s=E*E*this._dot(this.grad3[I],x,_)),70*(n+i+s)}noise3d(e,t,n){let i,s,o,a;const h=(e+t+n)*.3333333333333333,c=Math.floor(e+h),u=Math.floor(t+h),p=Math.floor(n+h),f=1/6,d=(c+u+p)*f,m=c-d,g=u-d,y=p-d,w=e-m,b=t-g,x=n-y;let _,D,P,k,C,I;w>=b?b>=x?(_=1,D=0,P=0,k=1,C=1,I=0):w>=x?(_=1,D=0,P=0,k=1,C=0,I=1):(_=0,D=0,P=1,k=1,C=0,I=1):b<x?(_=0,D=0,P=1,k=0,C=1,I=1):w<x?(_=0,D=1,P=0,k=0,C=1,I=1):(_=0,D=1,P=0,k=1,C=1,I=0);const O=w-_+f,A=b-D+f,E=x-P+f,v=w-k+2*f,z=b-C+2*f,Z=x-I+2*f,W=w-1+3*f,Q=b-1+3*f,G=x-1+3*f,te=c&255,F=u&255,R=p&255,ne=this.perm[te+this.perm[F+this.perm[R]]]%12,H=this.perm[te+_+this.perm[F+D+this.perm[R+P]]]%12,Y=this.perm[te+k+this.perm[F+C+this.perm[R+I]]]%12,de=this.perm[te+1+this.perm[F+1+this.perm[R+1]]]%12;let fe=.6-w*w-b*b-x*x;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[ne],w,b,x));let se=.6-O*O-A*A-E*E;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[H],O,A,E));let oe=.6-v*v-z*z-Z*Z;oe<0?o=0:(oe*=oe,o=oe*oe*this._dot3(this.grad3[Y],v,z,Z));let he=.6-W*W-Q*Q-G*G;return he<0?a=0:(he*=he,a=he*he*this._dot3(this.grad3[de],W,Q,G)),32*(i+s+o+a)}noise4d(e,t,n,i){const s=this.grad4,o=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,h=(5-Math.sqrt(5))/20;let c,u,p,f,d;const m=(e+t+n+i)*l,g=Math.floor(e+m),y=Math.floor(t+m),w=Math.floor(n+m),b=Math.floor(i+m),x=(g+y+w+b)*h,_=g-x,D=y-x,P=w-x,k=b-x,C=e-_,I=t-D,O=n-P,A=i-k,E=C>I?32:0,v=C>O?16:0,z=I>O?8:0,Z=C>A?4:0,W=I>A?2:0,Q=O>A?1:0,G=E+v+z+Z+W+Q,te=o[G][0]>=3?1:0,F=o[G][1]>=3?1:0,R=o[G][2]>=3?1:0,ne=o[G][3]>=3?1:0,H=o[G][0]>=2?1:0,Y=o[G][1]>=2?1:0,de=o[G][2]>=2?1:0,fe=o[G][3]>=2?1:0,se=o[G][0]>=1?1:0,oe=o[G][1]>=1?1:0,he=o[G][2]>=1?1:0,pe=o[G][3]>=1?1:0,Ae=C-te+h,Le=I-F+h,M=O-R+h,X=A-ne+h,j=C-H+2*h,L=I-Y+2*h,B=O-de+2*h,N=A-fe+2*h,q=C-se+3*h,K=I-oe+3*h,U=O-he+3*h,$=A-pe+3*h,ee=C-1+4*h,J=I-1+4*h,ie=O-1+4*h,ce=A-1+4*h,ae=g&255,Te=y&255,$e=w&255,ke=b&255,Lt=a[ae+a[Te+a[$e+a[ke]]]]%32,ge=a[ae+te+a[Te+F+a[$e+R+a[ke+ne]]]]%32,Qt=a[ae+H+a[Te+Y+a[$e+de+a[ke+fe]]]]%32,wn=a[ae+se+a[Te+oe+a[$e+he+a[ke+pe]]]]%32,Je=a[ae+1+a[Te+1+a[$e+1+a[ke+1]]]]%32;let wt=.6-C*C-I*I-O*O-A*A;wt<0?c=0:(wt*=wt,c=wt*wt*this._dot4(s[Lt],C,I,O,A));let Ot=.6-Ae*Ae-Le*Le-M*M-X*X;Ot<0?u=0:(Ot*=Ot,u=Ot*Ot*this._dot4(s[ge],Ae,Le,M,X));let zt=.6-j*j-L*L-B*B-N*N;zt<0?p=0:(zt*=zt,p=zt*zt*this._dot4(s[Qt],j,L,B,N));let Nt=.6-q*q-K*K-U*U-$*$;Nt<0?f=0:(Nt*=Nt,f=Nt*Nt*this._dot4(s[wn],q,K,U,$));let bt=.6-ee*ee-J*J-ie*ie-ce*ce;return bt<0?d=0:(bt*=bt,d=bt*bt*this._dot4(s[Je],ee,J,ie,ce)),27*(c+u+p+f+d)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,s){return e[0]*t+e[1]*n+e[2]*i+e[3]*s}}class ze extends Rt{constructor(e,t,n=512,i=512,s,o,a){super(),this.width=n,this.height=i,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=oa(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{type:S.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new S.ShaderMaterial({defines:Object.assign({},Mn.defines),uniforms:S.UniformsUtils.clone(Mn.uniforms),vertexShader:Mn.vertexShader,fragmentShader:Mn.fragmentShader,blending:S.NoBlending,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new S.MeshNormalMaterial,this.normalMaterial.blending=S.NoBlending,this.pdMaterial=new S.ShaderMaterial({defines:Object.assign({},An.defines),uniforms:S.UniformsUtils.clone(An.uniforms),vertexShader:An.vertexShader,fragmentShader:An.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new S.ShaderMaterial({defines:Object.assign({},Sn.defines),uniforms:S.UniformsUtils.clone(Sn.uniforms),vertexShader:Sn.vertexShader,fragmentShader:Sn.fragmentShader,blending:S.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(_n.uniforms),vertexShader:_n.vertexShader,fragmentShader:_n.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this.blendMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(_i.uniforms),vertexShader:_i.vertexShader,fragmentShader:_i.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:S.CustomBlending,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this._fsQuad=new xi(null),this._originalClearColor=new S.Color,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),o!==void 0&&this.updateGtaoMaterial(o),a!==void 0&&this.updatePdMaterial(a)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new S.DepthTexture,this.depthTexture.format=S.DepthStencilFormat,this.depthTexture.type=S.UnsignedInt248Type,this.normalRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{minFilter:S.NearestFilter,magFilter:S.NearestFilter,type:S.HalfFloatType,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,i=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=i,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=i,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Es(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ze.OUTPUT.Off:break;case ze.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,s=t.clearAlpha||s,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(n){(n.isPoints||n.isLine||n.isLine2)&&n.visible&&(n.visible=!1,t.push(n))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){const t=new ca,n=e*e*4,i=new Uint8Array(n);for(let o=0;o<e;o++)for(let a=0;a<e;a++){const l=o,h=a;i[(o*e+a)*4]=(t.noise(l,h)*.5+.5)*255,i[(o*e+a)*4+1]=(t.noise(l+e,h)*.5+.5)*255,i[(o*e+a)*4+2]=(t.noise(l,h+e)*.5+.5)*255,i[(o*e+a)*4+3]=(t.noise(l+e,h+e)*.5+.5)*255}const s=new S.DataTexture(i,e,e,S.RGBAFormat,S.UnsignedByteType);return s.wrapS=S.RepeatWrapping,s.wrapT=S.RepeatWrapping,s.needsUpdate=!0,s}}ze.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Tn={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
394
+ }`};function Ls(r,e,t){const n=ca(r,e,t);let i="vec3[SAMPLES](";for(let s=0;s<r;s++){const o=n[s];i+=`vec3(${o.x}, ${o.y}, ${o.z})${s<r-1?",":")"}`}return i}function ca(r,e,t){const n=[];for(let i=0;i<r;i++){const s=2*Math.PI*e*i/r,o=Math.pow(i/(r-1),t);n.push(new S.Vector3(Math.cos(s),Math.sin(s),o))}return n}class ha{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,i,s;const o=.5*(Math.sqrt(3)-1),a=(e+t)*o,l=Math.floor(e+a),h=Math.floor(t+a),c=(3-Math.sqrt(3))/6,u=(l+h)*c,f=l-u,p=h-u,d=e-f,m=t-p;let g,y;d>m?(g=1,y=0):(g=0,y=1);const w=d-g+c,b=m-y+c,x=d-1+2*c,_=m-1+2*c,D=l&255,P=h&255,k=this.perm[D+this.perm[P]]%12,C=this.perm[D+g+this.perm[P+y]]%12,I=this.perm[D+1+this.perm[P+1]]%12;let O=.5-d*d-m*m;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],d,m));let A=.5-w*w-b*b;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[C],w,b));let B=.5-x*x-_*_;return B<0?s=0:(B*=B,s=B*B*this._dot(this.grad3[I],x,_)),70*(n+i+s)}noise3d(e,t,n){let i,s,o,a;const h=(e+t+n)*.3333333333333333,c=Math.floor(e+h),u=Math.floor(t+h),f=Math.floor(n+h),p=1/6,d=(c+u+f)*p,m=c-d,g=u-d,y=f-d,w=e-m,b=t-g,x=n-y;let _,D,P,k,C,I;w>=b?b>=x?(_=1,D=0,P=0,k=1,C=1,I=0):w>=x?(_=1,D=0,P=0,k=1,C=0,I=1):(_=0,D=0,P=1,k=1,C=0,I=1):b<x?(_=0,D=0,P=1,k=0,C=1,I=1):w<x?(_=0,D=1,P=0,k=0,C=1,I=1):(_=0,D=1,P=0,k=1,C=1,I=0);const O=w-_+p,A=b-D+p,B=x-P+p,v=w-k+2*p,z=b-C+2*p,Z=x-I+2*p,W=w-1+3*p,Q=b-1+3*p,G=x-1+3*p,te=c&255,F=u&255,R=f&255,ne=this.perm[te+this.perm[F+this.perm[R]]]%12,H=this.perm[te+_+this.perm[F+D+this.perm[R+P]]]%12,Y=this.perm[te+k+this.perm[F+C+this.perm[R+I]]]%12,de=this.perm[te+1+this.perm[F+1+this.perm[R+1]]]%12;let fe=.6-w*w-b*b-x*x;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[ne],w,b,x));let se=.6-O*O-A*A-B*B;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[H],O,A,B));let oe=.6-v*v-z*z-Z*Z;oe<0?o=0:(oe*=oe,o=oe*oe*this._dot3(this.grad3[Y],v,z,Z));let he=.6-W*W-Q*Q-G*G;return he<0?a=0:(he*=he,a=he*he*this._dot3(this.grad3[de],W,Q,G)),32*(i+s+o+a)}noise4d(e,t,n,i){const s=this.grad4,o=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,h=(5-Math.sqrt(5))/20;let c,u,f,p,d;const m=(e+t+n+i)*l,g=Math.floor(e+m),y=Math.floor(t+m),w=Math.floor(n+m),b=Math.floor(i+m),x=(g+y+w+b)*h,_=g-x,D=y-x,P=w-x,k=b-x,C=e-_,I=t-D,O=n-P,A=i-k,B=C>I?32:0,v=C>O?16:0,z=I>O?8:0,Z=C>A?4:0,W=I>A?2:0,Q=O>A?1:0,G=B+v+z+Z+W+Q,te=o[G][0]>=3?1:0,F=o[G][1]>=3?1:0,R=o[G][2]>=3?1:0,ne=o[G][3]>=3?1:0,H=o[G][0]>=2?1:0,Y=o[G][1]>=2?1:0,de=o[G][2]>=2?1:0,fe=o[G][3]>=2?1:0,se=o[G][0]>=1?1:0,oe=o[G][1]>=1?1:0,he=o[G][2]>=1?1:0,pe=o[G][3]>=1?1:0,Ae=C-te+h,Le=I-F+h,M=O-R+h,X=A-ne+h,j=C-H+2*h,L=I-Y+2*h,E=O-de+2*h,N=A-fe+2*h,q=C-se+3*h,K=I-oe+3*h,U=O-he+3*h,$=A-pe+3*h,ee=C-1+4*h,J=I-1+4*h,ie=O-1+4*h,ce=A-1+4*h,ae=g&255,Te=y&255,$e=w&255,ke=b&255,Ot=a[ae+a[Te+a[$e+a[ke]]]]%32,ge=a[ae+te+a[Te+F+a[$e+R+a[ke+ne]]]]%32,Qt=a[ae+H+a[Te+Y+a[$e+de+a[ke+fe]]]]%32,wn=a[ae+se+a[Te+oe+a[$e+he+a[ke+pe]]]]%32,Je=a[ae+1+a[Te+1+a[$e+1+a[ke+1]]]]%32;let bt=.6-C*C-I*I-O*O-A*A;bt<0?c=0:(bt*=bt,c=bt*bt*this._dot4(s[Ot],C,I,O,A));let zt=.6-Ae*Ae-Le*Le-M*M-X*X;zt<0?u=0:(zt*=zt,u=zt*zt*this._dot4(s[ge],Ae,Le,M,X));let Nt=.6-j*j-L*L-E*E-N*N;Nt<0?f=0:(Nt*=Nt,f=Nt*Nt*this._dot4(s[Qt],j,L,E,N));let Rt=.6-q*q-K*K-U*U-$*$;Rt<0?p=0:(Rt*=Rt,p=Rt*Rt*this._dot4(s[wn],q,K,U,$));let xt=.6-ee*ee-J*J-ie*ie-ce*ce;return xt<0?d=0:(xt*=xt,d=xt*xt*this._dot4(s[Je],ee,J,ie,ce)),27*(c+u+f+p+d)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,s){return e[0]*t+e[1]*n+e[2]*i+e[3]*s}}class ze extends Ft{constructor(e,t,n=512,i=512,s,o,a){super(),this.width=n,this.height=i,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=aa(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{type:S.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new S.ShaderMaterial({defines:Object.assign({},Mn.defines),uniforms:S.UniformsUtils.clone(Mn.uniforms),vertexShader:Mn.vertexShader,fragmentShader:Mn.fragmentShader,blending:S.NoBlending,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new S.MeshNormalMaterial,this.normalMaterial.blending=S.NoBlending,this.pdMaterial=new S.ShaderMaterial({defines:Object.assign({},An.defines),uniforms:S.UniformsUtils.clone(An.uniforms),vertexShader:An.vertexShader,fragmentShader:An.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new S.ShaderMaterial({defines:Object.assign({},Sn.defines),uniforms:S.UniformsUtils.clone(Sn.uniforms),vertexShader:Sn.vertexShader,fragmentShader:Sn.fragmentShader,blending:S.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(_n.uniforms),vertexShader:_n.vertexShader,fragmentShader:_n.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this.blendMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(vi.uniforms),vertexShader:vi.vertexShader,fragmentShader:vi.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:S.CustomBlending,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this._fsQuad=new _i(null),this._originalClearColor=new S.Color,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),o!==void 0&&this.updateGtaoMaterial(o),a!==void 0&&this.updatePdMaterial(a)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new S.DepthTexture,this.depthTexture.format=S.DepthStencilFormat,this.depthTexture.type=S.UnsignedInt248Type,this.normalRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{minFilter:S.NearestFilter,magFilter:S.NearestFilter,type:S.HalfFloatType,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,i=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=i,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=i,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Ls(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ze.OUTPUT.Off:break;case ze.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,s=t.clearAlpha||s,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(n){(n.isPoints||n.isLine||n.isLine2)&&n.visible&&(n.visible=!1,t.push(n))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){const t=new ha,n=e*e*4,i=new Uint8Array(n);for(let o=0;o<e;o++)for(let a=0;a<e;a++){const l=o,h=a;i[(o*e+a)*4]=(t.noise(l,h)*.5+.5)*255,i[(o*e+a)*4+1]=(t.noise(l+e,h)*.5+.5)*255,i[(o*e+a)*4+2]=(t.noise(l,h+e)*.5+.5)*255,i[(o*e+a)*4+3]=(t.noise(l+e,h+e)*.5+.5)*255}const s=new S.DataTexture(i,e,e,S.RGBAFormat,S.UnsignedByteType);return s.wrapS=S.RepeatWrapping,s.wrapT=S.RepeatWrapping,s.needsUpdate=!0,s}}ze.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Tn={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
395
395
  precision highp float;
396
396
 
397
397
  uniform mat4 modelViewMatrix;
@@ -462,7 +462,7 @@
462
462
 
463
463
  #endif
464
464
 
465
- }`};class ha extends Rt{constructor(){super(),this.uniforms=S.UniformsUtils.clone(Tn.uniforms),this.material=new S.RawShaderMaterial({name:Tn.name,uniforms:this.uniforms,vertexShader:Tn.vertexShader,fragmentShader:Tn.fragmentShader}),this._fsQuad=new xi(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},S.ColorManagement.getTransfer(this._outputColorSpace)===S.SRGBTransfer&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===S.LinearToneMapping?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===S.ReinhardToneMapping?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===S.CineonToneMapping?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===S.ACESFilmicToneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===S.AgXToneMapping?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===S.NeutralToneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===S.CustomToneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}const ua={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new S.Vector2(1/1024,1/512)}},vertexShader:`
465
+ }`};class ua extends Ft{constructor(){super(),this.uniforms=S.UniformsUtils.clone(Tn.uniforms),this.material=new S.RawShaderMaterial({name:Tn.name,uniforms:this.uniforms,vertexShader:Tn.vertexShader,fragmentShader:Tn.fragmentShader}),this._fsQuad=new _i(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},S.ColorManagement.getTransfer(this._outputColorSpace)===S.SRGBTransfer&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===S.LinearToneMapping?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===S.ReinhardToneMapping?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===S.CineonToneMapping?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===S.ACESFilmicToneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===S.AgXToneMapping?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===S.NeutralToneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===S.CustomToneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}const da={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new S.Vector2(1/1024,1/512)}},vertexShader:`
466
466
 
467
467
  varying vec2 vUv;
468
468
 
@@ -723,7 +723,7 @@
723
723
 
724
724
  gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
725
725
 
726
- }`},da={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
726
+ }`},fa={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
727
727
  varying vec2 vUv;
728
728
  void main() {
729
729
  vUv = uv;
@@ -749,18 +749,18 @@
749
749
 
750
750
  gl_FragColor = color;
751
751
  }
752
- `};class fa{engine;composer;saturationPass;constructor(e){this.engine=e}resize(e,t){if(e===void 0||t===void 0){const s=this.engine.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t||!this.composer)return;const n=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(s=>s instanceof vn&&s.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(e*n),i.material.uniforms.resolution.value.y=1/(t*n))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=this.engine.scene,i=this.engine.camera,s=this.engine.renderer,o=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new T.WebGLRenderTarget(e,t,{minFilter:T.LinearFilter,magFilter:T.LinearFilter,format:T.RGBAFormat,samples:4});this.composer=new sa(s,a),this.composer.setPixelRatio(o),this.composer.setSize(e,t);const l=new ra(n,i);this.composer.addPass(l);const h=new ze(n,i,e,t);h.output=ze.OUTPUT.Default,h.blendIntensity=.5,h.updateGtaoMaterial&&h.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.saturationPass=new vn(da),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,new ha;const c=new vn(ua);c.material.uniforms.resolution.value.x=1/(e*o),c.material.uniforms.resolution.value.y=1/(t*o)}}var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ls(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Pn(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var vi={exports:{}};var Os;function pa(){return Os||(Os=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function t(n,i,s){function o(h,c){if(!i[h]){if(!n[h]){var u=typeof Pn=="function"&&Pn;if(!c&&u)return u(h,!0);if(a)return a(h,!0);var p=new Error("Cannot find module '"+h+"'");throw p.code="MODULE_NOT_FOUND",p}var f=i[h]={exports:{}};n[h][0].call(f.exports,function(d){var m=n[h][1][d];return o(m||d)},f,f.exports,t,n,i,s)}return i[h].exports}for(var a=typeof Pn=="function"&&Pn,l=0;l<s.length;l++)o(s[l]);return o})({1:[function(t,n,i){var s=t("./utils"),o=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var h,c,u,p,f,d,m,g=[],y=0,w=l.length,b=w,x=s.getTypeOf(l)!=="string";y<l.length;)b=w-y,u=x?(h=l[y++],c=y<w?l[y++]:0,y<w?l[y++]:0):(h=l.charCodeAt(y++),c=y<w?l.charCodeAt(y++):0,y<w?l.charCodeAt(y++):0),p=h>>2,f=(3&h)<<4|c>>4,d=1<b?(15&c)<<2|u>>6:64,m=2<b?63&u:64,g.push(a.charAt(p)+a.charAt(f)+a.charAt(d)+a.charAt(m));return g.join("")},i.decode=function(l){var h,c,u,p,f,d,m=0,g=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var w,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&b--,l.charAt(l.length-2)===a.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=o.uint8array?new Uint8Array(0|b):new Array(0|b);m<l.length;)h=a.indexOf(l.charAt(m++))<<2|(p=a.indexOf(l.charAt(m++)))>>4,c=(15&p)<<4|(f=a.indexOf(l.charAt(m++)))>>2,u=(3&f)<<6|(d=a.indexOf(l.charAt(m++))),w[g++]=h,f!==64&&(w[g++]=c),d!==64&&(w[g++]=u);return w}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),o=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function h(c,u,p,f,d){this.compressedSize=c,this.uncompressedSize=u,this.crc32=p,this.compression=f,this.compressedContent=d}h.prototype={getContentWorker:function(){var c=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return c.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},h.createWorkerFrom=function(c,u,p){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},n.exports=h},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var s=t("./utils"),o=(function(){for(var a,l=[],h=0;h<256;h++){a=h;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[h]=a}return l})();n.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(h,c,u,p){var f=o,d=p+u;h^=-1;for(var m=p;m<d;m++)h=h>>>8^f[255&(h^c[m])];return-1^h})(0|l,a,a.length,0):(function(h,c,u,p){var f=o,d=p+u;h^=-1;for(var m=p;m<d;m++)h=h>>>8^f[255&(h^c.charCodeAt(m))];return-1^h})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var s=null;s=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:s}},{lie:37}],7:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),h=s?"uint8array":"array";function c(u,p){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=p,this.meta={}}i.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(h,u.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(p){u.push({data:p,meta:u.meta})}},i.compressWorker=function(u){return new c("Deflate",u)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(f,d){var m,g="";for(m=0;m<d;m++)g+=String.fromCharCode(255&f),f>>>=8;return g}function o(f,d,m,g,y,w){var b,x,_=f.file,D=f.compression,P=w!==h.utf8encode,k=a.transformTo("string",w(_.name)),C=a.transformTo("string",h.utf8encode(_.name)),I=_.comment,O=a.transformTo("string",w(I)),A=a.transformTo("string",h.utf8encode(I)),E=C.length!==_.name.length,v=A.length!==I.length,z="",Z="",W="",Q=_.dir,G=_.date,te={crc32:0,compressedSize:0,uncompressedSize:0};d&&!m||(te.crc32=f.crc32,te.compressedSize=f.compressedSize,te.uncompressedSize=f.uncompressedSize);var F=0;d&&(F|=8),P||!E&&!v||(F|=2048);var R=0,ne=0;Q&&(R|=16),y==="UNIX"?(ne=798,R|=(function(Y,de){var fe=Y;return Y||(fe=de?16893:33204),(65535&fe)<<16})(_.unixPermissions,Q)):(ne=20,R|=(function(Y){return 63&(Y||0)})(_.dosPermissions)),b=G.getUTCHours(),b<<=6,b|=G.getUTCMinutes(),b<<=5,b|=G.getUTCSeconds()/2,x=G.getUTCFullYear()-1980,x<<=4,x|=G.getUTCMonth()+1,x<<=5,x|=G.getUTCDate(),E&&(Z=s(1,1)+s(c(k),4)+C,z+="up"+s(Z.length,2)+Z),v&&(W=s(1,1)+s(c(O),4)+A,z+="uc"+s(W.length,2)+W);var H="";return H+=`
753
- \0`,H+=s(F,2),H+=D.magic,H+=s(b,2),H+=s(x,2),H+=s(te.crc32,4),H+=s(te.compressedSize,4),H+=s(te.uncompressedSize,4),H+=s(k.length,2),H+=s(z.length,2),{fileRecord:u.LOCAL_FILE_HEADER+H+k+z,dirRecord:u.CENTRAL_FILE_HEADER+s(ne,2)+H+s(O.length,2)+"\0\0\0\0"+s(R,4)+s(g,4)+k+z+O}}var a=t("../utils"),l=t("../stream/GenericWorker"),h=t("../utf8"),c=t("../crc32"),u=t("../signature");function p(f,d,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=d,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(f){var d=f.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,l.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:m?(d+100*(m-g-1))/m:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var d=this.streamFiles&&!f.file.dir;if(d){var m=o(f,d,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var d=this.streamFiles&&!f.file.dir,m=o(f,d,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),d)this.push({data:(function(g){return u.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(f),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,d=0;d<this.dirRecords.length;d++)this.push({data:this.dirRecords[d],meta:{percent:100}});var m=this.bytesWritten-f,g=(function(y,w,b,x,_){var D=a.transformTo("string",_(x));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(w,4)+s(b,4)+s(D.length,2)+D})(this.dirRecords.length,m,f,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(f){this._sources.push(f);var d=this;return f.on("data",function(m){d.processChunk(m)}),f.on("end",function(){d.closedSource(d.previous.streamInfo),d._sources.length?d.prepareNextSource():d.end()}),f.on("error",function(m){d.error(m)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(f){var d=this._sources;if(!l.prototype.error.call(this,f))return!1;for(var m=0;m<d.length;m++)try{d[m].error(f)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var f=this._sources,d=0;d<f.length;d++)f[d].lock()},n.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),o=t("./ZipFileWorker");i.generateWorker=function(a,l,h){var c=new o(l.streamFiles,h,l.platform,l.encodeFileName),u=0;try{a.forEach(function(p,f){u++;var d=(function(w,b){var x=w||b,_=s[x];if(!_)throw new Error(x+" is not a valid compression method !");return _})(f.options.compression,l.compression),m=f.options.compressionOptions||l.compressionOptions||{},g=f.dir,y=f.date;f._compressWorker(d,m).withStreamInfo("file",{name:p,dir:g,date:y,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(c)}),c.entriesCount=u}catch(p){c.error(p)}return c}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new s;for(var a in this)typeof this[a]!="function"&&(o[a]=this[a]);return o}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(o,a){return new s().loadAsync(o,a)},s.external=t("./external"),n.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var s=t("./utils"),o=t("./external"),a=t("./utf8"),l=t("./zipEntries"),h=t("./stream/Crc32Probe"),c=t("./nodejsUtils");function u(p){return new o.Promise(function(f,d){var m=p.decompressed.getContentWorker().pipe(new h);m.on("error",function(g){d(g)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?d(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}n.exports=function(p,f){var d=this;return f=s.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,f.optimizedBinaryString,f.base64).then(function(m){var g=new l(f);return g.load(m),g}).then(function(m){var g=[o.Promise.resolve(m)],y=m.files;if(f.checkCRC32)for(var w=0;w<y.length;w++)g.push(u(y[w]));return o.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,w=0;w<y.length;w++){var b=y[w],x=b.fileNameStr,_=s.resolve(b.fileNameStr);d.file(_,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:f.createFolders}),b.dir||(d.file(_).unsafeOriginalName=x)}return g.zipComment.length&&(d.comment=g.zipComment),d})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),o=t("../stream/GenericWorker");function a(l,h){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(h)}s.inherits(a,o),a.prototype._bindStream=function(l){var h=this;(this._stream=l).pause(),l.on("data",function(c){h.push({data:c,meta:{percent:0}})}).on("error",function(c){h.isPaused?this.generatedError=c:h.error(c)}).on("end",function(){h.isPaused?h._upstreamEnded=!0:h.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,n,i){var s=t("readable-stream").Readable;function o(a,l,h){s.call(this,l),this._helper=a;var c=this;a.on("data",function(u,p){c.push(u)||c._helper.pause(),h&&h(p)}).on("error",function(u){c.emit("error",u)}).on("end",function(){c.push(null)})}t("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},n.exports=o},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,n,i){function s(_,D,P){var k,C=a.getTypeOf(D),I=a.extend(P||{},c);I.date=I.date||new Date,I.compression!==null&&(I.compression=I.compression.toUpperCase()),typeof I.unixPermissions=="string"&&(I.unixPermissions=parseInt(I.unixPermissions,8)),I.unixPermissions&&16384&I.unixPermissions&&(I.dir=!0),I.dosPermissions&&16&I.dosPermissions&&(I.dir=!0),I.dir&&(_=y(_)),I.createFolders&&(k=g(_))&&w.call(this,k,!0);var O=C==="string"&&I.binary===!1&&I.base64===!1;P&&P.binary!==void 0||(I.binary=!O),(D instanceof u&&D.uncompressedSize===0||I.dir||!D||D.length===0)&&(I.base64=!1,I.binary=!0,D="",I.compression="STORE",C="string");var A=null;A=D instanceof u||D instanceof l?D:d.isNode&&d.isStream(D)?new m(_,D):a.prepareContent(_,D,I.binary,I.optimizedBinaryString,I.base64);var E=new p(_,A,I);this.files[_]=E}var o=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),h=t("./stream/StreamHelper"),c=t("./defaults"),u=t("./compressedObject"),p=t("./zipObject"),f=t("./generate"),d=t("./nodejsUtils"),m=t("./nodejs/NodejsStreamInputAdapter"),g=function(_){_.slice(-1)==="/"&&(_=_.substring(0,_.length-1));var D=_.lastIndexOf("/");return 0<D?_.substring(0,D):""},y=function(_){return _.slice(-1)!=="/"&&(_+="/"),_},w=function(_,D){return D=D!==void 0?D:c.createFolders,_=y(_),this.files[_]||s.call(this,_,null,{dir:!0,createFolders:D}),this.files[_]};function b(_){return Object.prototype.toString.call(_)==="[object RegExp]"}var x={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(_){var D,P,k;for(D in this.files)k=this.files[D],(P=D.slice(this.root.length,D.length))&&D.slice(0,this.root.length)===this.root&&_(P,k)},filter:function(_){var D=[];return this.forEach(function(P,k){_(P,k)&&D.push(k)}),D},file:function(_,D,P){if(arguments.length!==1)return _=this.root+_,s.call(this,_,D,P),this;if(b(_)){var k=_;return this.filter(function(I,O){return!O.dir&&k.test(I)})}var C=this.files[this.root+_];return C&&!C.dir?C:null},folder:function(_){if(!_)return this;if(b(_))return this.filter(function(C,I){return I.dir&&_.test(C)});var D=this.root+_,P=w.call(this,D),k=this.clone();return k.root=P.name,k},remove:function(_){_=this.root+_;var D=this.files[_];if(D||(_.slice(-1)!=="/"&&(_+="/"),D=this.files[_]),D&&!D.dir)delete this.files[_];else for(var P=this.filter(function(C,I){return I.name.slice(0,_.length)===_}),k=0;k<P.length;k++)delete this.files[P[k].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(_){var D,P={};try{if((P=a.extend(_||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");a.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var k=P.comment||this.comment||"";D=f.generateWorker(this,P,k)}catch(C){(D=new l("error")).error(C)}return new h(D,P.type||"string",P.mimeType)},generateAsync:function(_,D){return this.generateInternalStream(_).accumulate(D)},generateNodeStream:function(_,D){return(_=_||{}).type||(_.type="nodebuffer"),this.generateInternalStream(_).toNodejsStream(D)}};n.exports=x},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,n,i){n.exports=t("stream")},{stream:void 0}],17:[function(t,n,i){var s=t("./DataReader");function o(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),u=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===h&&this.data[p+2]===c&&this.data[p+3]===u)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),u=a.charCodeAt(3),p=this.readData(4);return l===p[0]&&h===p[1]&&c===p[2]&&u===p[3]},o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var s=t("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,h=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)h=(h<<8)+this.byteAt(l);return this.index+=a,h},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=o},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),o=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),h=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");n.exports=function(u){var p=s.getTypeOf(u);return s.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new h(u):o.uint8array?new c(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),o=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),o=t("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var h=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=h+l.data.length}o.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataWorker");var h=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){h.dataIsReady=!0,h.data=c,h.max=c&&c.length||0,h.type=s.getTypeOf(c),h.isPaused||h._tickAndRepeat()},function(c){h.error(c)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,h=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,h);break;case"uint8array":l=this.data.subarray(this.index,h);break;case"array":case"nodebuffer":l=this.data.slice(this.index,h)}return this.index=h,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),o=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),h=t("../support"),c=t("../external"),u=null;if(h.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(d,m){return new c.Promise(function(g,y){var w=[],b=d._internalType,x=d._outputType,_=d._mimeType;d.on("data",function(D,P){w.push(D),m&&m(P)}).on("error",function(D){w=[],y(D)}).on("end",function(){try{var D=(function(P,k,C){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",k),C);case"base64":return l.encode(k);default:return s.transformTo(P,k)}})(x,(function(P,k){var C,I=0,O=null,A=0;for(C=0;C<k.length;C++)A+=k[C].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(A),C=0;C<k.length;C++)O.set(k[C],I),I+=k[C].length;return O;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+P+"'")}})(b,w),_);g(D)}catch(P){y(P)}w=[]}).resume()})}function f(d,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,s.checkSupport(y),this._worker=d.pipe(new o(y)),d.lock()}catch(w){this._worker=new a("error"),this._worker.error(w)}}f.prototype={accumulate:function(d){return p(this,d)},on:function(d,m){var g=this;return d==="data"?this._worker.on(d,function(y){m.call(g,y.data,y.meta)}):this._worker.on(d,function(){s.delay(m,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(d){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},d)}},n.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var s=t("./utils"),o=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),h=new Array(256),c=0;c<256;c++)h[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;h[254]=h[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}i.utf8encode=function(f){return o.nodebuffer?a.newBufferFrom(f,"utf-8"):(function(d){var m,g,y,w,b,x=d.length,_=0;for(w=0;w<x;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<x&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),_+=g<128?1:g<2048?2:g<65536?3:4;for(m=o.uint8array?new Uint8Array(_):new Array(_),w=b=0;b<_;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<x&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(f)},i.utf8decode=function(f){return o.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):(function(d){var m,g,y,w,b=d.length,x=new Array(2*b);for(m=g=0;m<b;)if((y=d[m++])<128)x[g++]=y;else if(4<(w=h[y]))x[g++]=65533,m+=w-1;else{for(y&=w===2?31:w===3?15:7;1<w&&m<b;)y=y<<6|63&d[m++],w--;1<w?x[g++]=65533:y<65536?x[g++]=y:(y-=65536,x[g++]=55296|y>>10&1023,x[g++]=56320|1023&y)}return x.length!==g&&(x.subarray?x=x.subarray(0,g):x.length=g),s.applyFromCharCode(x)})(f=s.transformTo(o.uint8array?"uint8array":"array",f))},s.inherits(u,l),u.prototype.processChunk=function(f){var d=s.transformTo(o.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var m=d;(d=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),d.set(m,this.leftOver.length)}else d=this.leftOver.concat(d);this.leftOver=null}var g=(function(w,b){var x;for((b=b||w.length)>w.length&&(b=w.length),x=b-1;0<=x&&(192&w[x])==128;)x--;return x<0||x===0?b:x+h[w[x]]>b?x:b})(d),y=d;g!==d.length&&(o.uint8array?(y=d.subarray(0,g),this.leftOver=d.subarray(g,d.length)):(y=d.slice(0,g),this.leftOver=d.slice(g,d.length))),this.push({data:i.utf8decode(y),meta:f.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=u,s.inherits(p,l),p.prototype.processChunk=function(f){this.push({data:i.utf8encode(f.data),meta:f.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),o=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function h(m){return m}function c(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,g,y){var w=[],b=0,x=m.length;if(x<=y)return String.fromCharCode.apply(null,m);for(;b<x;)g==="array"||g==="nodebuffer"?w.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,x)))):w.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,x)))),b+=y;return w.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var g=65536,y=i.getTypeOf(m),w=!0;if(y==="uint8array"?w=u.applyCanBeUsed.uint8array:y==="nodebuffer"&&(w=u.applyCanBeUsed.nodebuffer),w)for(;1<g;)try{return u.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return u.stringifyByChar(m)}function f(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=p;var d={};d.string={string:h,array:function(m){return c(m,new Array(m.length))},arraybuffer:function(m){return d.string.uint8array(m).buffer},uint8array:function(m){return c(m,new Uint8Array(m.length))},nodebuffer:function(m){return c(m,a.allocBuffer(m.length))}},d.array={string:p,array:h,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},d.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return f(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:h,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},d.uint8array={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:h,nodebuffer:function(m){return a.newBufferFrom(m)}},d.nodebuffer={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return d.nodebuffer.uint8array(m).buffer},uint8array:function(m){return f(m,new Uint8Array(m.length))},nodebuffer:h},i.transformTo=function(m,g){if(g=g||"",!m)return g;i.checkSupport(m);var y=i.getTypeOf(g);return d[y][m](g)},i.resolve=function(m){for(var g=m.split("/"),y=[],w=0;w<g.length;w++){var b=g[w];b==="."||b===""&&w!==0&&w!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,w="";for(y=0;y<(m||"").length;y++)w+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return w},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,w,b){return l.Promise.resolve(g).then(function(x){return s.blob&&(x instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(x))!==-1)&&typeof FileReader<"u"?new l.Promise(function(_,D){var P=new FileReader;P.onload=function(k){_(k.target.result)},P.onerror=function(k){D(k.target.error)},P.readAsArrayBuffer(x)}):x}).then(function(x){var _=i.getTypeOf(x);return _?(_==="arraybuffer"?x=i.transformTo("uint8array",x):_==="string"&&(b?x=o.decode(x):y&&w!==!0&&(x=(function(D){return c(D,s.uint8array?new Uint8Array(D.length):new Array(D.length))})(x))),x):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var s=t("./reader/readerFor"),o=t("./utils"),a=t("./signature"),l=t("./zipEntry"),h=t("./support");function c(u){this.files=[],this.loadOptions=u}c.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(u)+")")}},isSignature:function(u,p){var f=this.reader.index;this.reader.setIndex(u);var d=this.reader.readString(4)===p;return this.reader.setIndex(f),d},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),p=h.uint8array?"uint8array":"array",f=o.transformTo(p,u);this.zipComment=this.loadOptions.decodeFileName(f)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,p,f,d=this.zip64EndOfCentralSize-44;0<d;)u=this.reader.readInt(2),p=this.reader.readInt(4),f=this.reader.readData(p),this.zip64ExtensibleData[u]={id:u,length:p,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,p;for(u=0;u<this.files.length;u++)p=this.files[u],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var p=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var d=p-f;if(0<d)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=d);else if(d<0)throw new Error("Corrupted zip: missing "+Math.abs(d)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),o=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),h=t("./utf8"),c=t("./compressions"),u=t("./support");function p(f,d){this.options=f,this.loadOptions=d}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var d,m;if(f.skip(22),this.fileNameLength=f.readInt(2),m=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((d=(function(g){for(var y in c)if(Object.prototype.hasOwnProperty.call(c,y)&&c[y].magic===g)return c[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,d,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var d=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(d),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var d,m,g,y=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<y;)d=f.readInt(2),m=f.readInt(2),g=f.readData(m),this.extraFields[d]={id:d,length:m,value:g};f.setIndex(y)},handleUTF8:function(){var f=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=h.utf8decode(this.fileName),this.fileCommentStr=h.utf8decode(this.fileComment);else{var d=this.findExtraFieldUnicodePath();if(d!==null)this.fileNameStr=d;else{var m=o.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=o.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var d=s(f.value);return d.readInt(1)!==1||l(this.fileName)!==d.readInt(4)?null:h.utf8decode(d.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var d=s(f.value);return d.readInt(1)!==1||l(this.fileComment)!==d.readInt(4)?null:h.utf8decode(d.readData(f.length-5))}return null}},n.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(d,m,g){this.name=d,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var o=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),h=t("./compressedObject"),c=t("./stream/GenericWorker");s.prototype={internalStream:function(d){var m=null,g="string";try{if(!d)throw new Error("No output type specified.");var y=(g=d.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var w=!this._dataBinary;w&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!w&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new c("error")).error(b)}return new o(m,g,"")},async:function(d,m){return this.internalStream(d).accumulate(m)},nodeStream:function(d,m){return this.internalStream(d||"nodebuffer").toNodejsStream(m)},_compressWorker:function(d,m){if(this._data instanceof h&&this._data.compression.magic===d.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),h.createWorkerFrom(g,d,m)},_decompressWorker:function(){return this._data instanceof h?this._data.getContentWorker():this._data instanceof c?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)s.prototype[u[f]]=p;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var o,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var h=0,c=new l(d),u=s.document.createTextNode("");c.observe(u,{characterData:!0}),o=function(){u.data=h=++h%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){d(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(d,0)};else{var p=new s.MessageChannel;p.port1.onmessage=d,o=function(){p.port2.postMessage(0)}}var f=[];function d(){var m,g;a=!0;for(var y=f.length;y;){for(g=f,f=[],m=-1;++m<y;)g[m]();y=f.length}a=!1}n.exports=function(m){f.push(m)!==1||a||o()}}).call(this,typeof Cn<"u"?Cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var s=t("immediate");function o(){}var a={},l=["REJECTED"],h=["FULFILLED"],c=["PENDING"];function u(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,y!==o&&m(this,y)}function p(y,w,b){this.promise=y,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function f(y,w,b){s(function(){var x;try{x=w(b)}catch(_){return a.reject(y,_)}x===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,x)})}function d(y){var w=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof w=="function")return function(){w.apply(y,arguments)}}function m(y,w){var b=!1;function x(P){b||(b=!0,a.reject(y,P))}function _(P){b||(b=!0,a.resolve(y,P))}var D=g(function(){w(_,x)});D.status==="error"&&x(D.value)}function g(y,w){var b={};try{b.value=y(w),b.status="success"}catch(x){b.status="error",b.value=x}return b}(n.exports=u).prototype.finally=function(y){if(typeof y!="function")return this;var w=this.constructor;return this.then(function(b){return w.resolve(y()).then(function(){return b})},function(b){return w.resolve(y()).then(function(){throw b})})},u.prototype.catch=function(y){return this.then(null,y)},u.prototype.then=function(y,w){if(typeof y!="function"&&this.state===h||typeof w!="function"&&this.state===l)return this;var b=new this.constructor(o);return this.state!==c?f(b,this.state===h?y:w,this.outcome):this.queue.push(new p(b,y,w)),b},p.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){f(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){a.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){f(this.promise,this.onRejected,y)},a.resolve=function(y,w){var b=g(d,w);if(b.status==="error")return a.reject(y,b.value);var x=b.value;if(x)m(y,x);else{y.state=h,y.outcome=w;for(var _=-1,D=y.queue.length;++_<D;)y.queue[_].callFulfilled(w)}return y},a.reject=function(y,w){y.state=l,y.outcome=w;for(var b=-1,x=y.queue.length;++b<x;)y.queue[b].callRejected(w);return y},u.resolve=function(y){return y instanceof this?y:a.resolve(new this(o),y)},u.reject=function(y){var w=new this(o);return a.reject(w,y)},u.all=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,x=!1;if(!b)return this.resolve([]);for(var _=new Array(b),D=0,P=-1,k=new this(o);++P<b;)C(y[P],P);return k;function C(I,O){w.resolve(I).then(function(A){_[O]=A,++D!==b||x||(x=!0,a.resolve(k,_))},function(A){x||(x=!0,a.reject(k,A))})}},u.race=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,x=!1;if(!b)return this.resolve([]);for(var _=-1,D=new this(o);++_<b;)P=y[_],w.resolve(P).then(function(k){x||(x=!0,a.resolve(D,k))},function(k){x||(x=!0,a.reject(D,k))});var P;return D}},{immediate:36}],38:[function(t,n,i){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),n.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,n,i){var s=t("./zlib/deflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),h=t("./zlib/zstream"),c=Object.prototype.toString,u=0,p=-1,f=0,d=8;function m(y){if(!(this instanceof m))return new m(y);this.options=o.assign({level:p,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},y||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var b=s.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(b!==u)throw new Error(l[b]);if(w.header&&s.deflateSetHeader(this.strm,w.header),w.dictionary){var x;if(x=typeof w.dictionary=="string"?a.string2buf(w.dictionary):c.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(b=s.deflateSetDictionary(this.strm,x))!==u)throw new Error(l[b]);this._dict_set=!0}}function g(y,w){var b=new m(w);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,w){var b,x,_=this.strm,D=this.options.chunkSize;if(this.ended)return!1;x=w===~~w?w:w===!0?4:0,typeof y=="string"?_.input=a.string2buf(y):c.call(y)==="[object ArrayBuffer]"?_.input=new Uint8Array(y):_.input=y,_.next_in=0,_.avail_in=_.input.length;do{if(_.avail_out===0&&(_.output=new o.Buf8(D),_.next_out=0,_.avail_out=D),(b=s.deflate(_,x))!==1&&b!==u)return this.onEnd(b),!(this.ended=!0);_.avail_out!==0&&(_.avail_in!==0||x!==4&&x!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(o.shrinkBuf(_.output,_.next_out))):this.onData(o.shrinkBuf(_.output,_.next_out)))}while((0<_.avail_in||_.avail_out===0)&&b!==1);return x===4?(b=s.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===u):x!==2||(this.onEnd(u),!(_.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,w){return(w=w||{}).raw=!0,g(y,w)},i.gzip=function(y,w){return(w=w||{}).gzip=!0,g(y,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var s=t("./zlib/inflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),c=t("./zlib/zstream"),u=t("./zlib/gzheader"),p=Object.prototype.toString;function f(m){if(!(this instanceof f))return new f(m);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(h[y]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function d(m,g){var y=new f(g);if(y.push(m,!0),y.err)throw y.msg||h[y.err];return y.result}f.prototype.push=function(m,g){var y,w,b,x,_,D,P=this.strm,k=this.options.chunkSize,C=this.options.dictionary,I=!1;if(this.ended)return!1;w=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?P.input=a.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?P.input=new Uint8Array(m):P.input=m,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new o.Buf8(k),P.next_out=0,P.avail_out=k),(y=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(D=typeof C=="string"?a.string2buf(C):p.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,y=s.inflateSetDictionary(this.strm,D)),y===l.Z_BUF_ERROR&&I===!0&&(y=l.Z_OK,I=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(P.output,P.next_out),x=P.next_out-b,_=a.buf2string(P.output,b),P.next_out=x,P.avail_out=k-x,x&&o.arraySet(P.output,P.output,b,x,0),this.onData(_)):this.onData(o.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(I=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(w=l.Z_FINISH),w===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=f,i.inflate=d,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,d(m,g)},i.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var h=Array.prototype.slice.call(arguments,1);h.length;){var c=h.shift();if(c){if(typeof c!="object")throw new TypeError(c+"must be non-object");for(var u in c)c.hasOwnProperty(u)&&(l[u]=c[u])}}return l},i.shrinkBuf=function(l,h){return l.length===h?l:l.subarray?l.subarray(0,h):(l.length=h,l)};var o={arraySet:function(l,h,c,u,p){if(h.subarray&&l.subarray)l.set(h.subarray(c,c+u),p);else for(var f=0;f<u;f++)l[p+f]=h[c+f]},flattenChunks:function(l){var h,c,u,p,f,d;for(h=u=0,c=l.length;h<c;h++)u+=l[h].length;for(d=new Uint8Array(u),h=p=0,c=l.length;h<c;h++)f=l[h],d.set(f,p),p+=f.length;return d}},a={arraySet:function(l,h,c,u,p){for(var f=0;f<u;f++)l[p+f]=h[c+f]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(s)},{}],42:[function(t,n,i){var s=t("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new s.Buf8(256),h=0;h<256;h++)l[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;function c(u,p){if(p<65537&&(u.subarray&&a||!u.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(u,p));for(var f="",d=0;d<p;d++)f+=String.fromCharCode(u[d]);return f}l[254]=l[254]=1,i.string2buf=function(u){var p,f,d,m,g,y=u.length,w=0;for(m=0;m<y;m++)(64512&(f=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(d-56320),m++),w+=f<128?1:f<2048?2:f<65536?3:4;for(p=new s.Buf8(w),m=g=0;g<w;m++)(64512&(f=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(d-56320),m++),f<128?p[g++]=f:(f<2048?p[g++]=192|f>>>6:(f<65536?p[g++]=224|f>>>12:(p[g++]=240|f>>>18,p[g++]=128|f>>>12&63),p[g++]=128|f>>>6&63),p[g++]=128|63&f);return p},i.buf2binstring=function(u){return c(u,u.length)},i.binstring2buf=function(u){for(var p=new s.Buf8(u.length),f=0,d=p.length;f<d;f++)p[f]=u.charCodeAt(f);return p},i.buf2string=function(u,p){var f,d,m,g,y=p||u.length,w=new Array(2*y);for(f=d=0;f<y;)if((m=u[f++])<128)w[d++]=m;else if(4<(g=l[m]))w[d++]=65533,f+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&f<y;)m=m<<6|63&u[f++],g--;1<g?w[d++]=65533:m<65536?w[d++]=m:(m-=65536,w[d++]=55296|m>>10&1023,w[d++]=56320|1023&m)}return c(w,d)},i.utf8border=function(u,p){var f;for((p=p||u.length)>u.length&&(p=u.length),f=p-1;0<=f&&(192&u[f])==128;)f--;return f<0||f===0?p:f+l[u[f]]>p?f:p}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,o,a,l){for(var h=65535&s|0,c=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;c=c+(h=h+o[l++]|0)|0,--u;);h%=65521,c%=65521}return h|c<<16|0}},{}],44:[function(t,n,i){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,n,i){var s=(function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var h=0;h<8;h++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a})();n.exports=function(o,a,l,h){var c=s,u=h+l;o^=-1;for(var p=h;p<u;p++)o=o>>>8^c[255&(o^a[p])];return-1^o}},{}],46:[function(t,n,i){var s,o=t("../utils/common"),a=t("./trees"),l=t("./adler32"),h=t("./crc32"),c=t("./messages"),u=0,p=4,f=0,d=-2,m=-1,g=4,y=2,w=8,b=9,x=286,_=30,D=19,P=2*x+1,k=15,C=3,I=258,O=I+C+1,A=42,E=113,v=1,z=2,Z=3,W=4;function Q(M,X){return M.msg=c[X],X}function G(M){return(M<<1)-(4<M?9:0)}function te(M){for(var X=M.length;0<=--X;)M[X]=0}function F(M){var X=M.state,j=X.pending;j>M.avail_out&&(j=M.avail_out),j!==0&&(o.arraySet(M.output,X.pending_buf,X.pending_out,j,M.next_out),M.next_out+=j,X.pending_out+=j,M.total_out+=j,M.avail_out-=j,X.pending-=j,X.pending===0&&(X.pending_out=0))}function R(M,X){a._tr_flush_block(M,0<=M.block_start?M.block_start:-1,M.strstart-M.block_start,X),M.block_start=M.strstart,F(M.strm)}function ne(M,X){M.pending_buf[M.pending++]=X}function H(M,X){M.pending_buf[M.pending++]=X>>>8&255,M.pending_buf[M.pending++]=255&X}function Y(M,X){var j,L,B=M.max_chain_length,N=M.strstart,q=M.prev_length,K=M.nice_match,U=M.strstart>M.w_size-O?M.strstart-(M.w_size-O):0,$=M.window,ee=M.w_mask,J=M.prev,ie=M.strstart+I,ce=$[N+q-1],ae=$[N+q];M.prev_length>=M.good_match&&(B>>=2),K>M.lookahead&&(K=M.lookahead);do if($[(j=X)+q]===ae&&$[j+q-1]===ce&&$[j]===$[N]&&$[++j]===$[N+1]){N+=2,j++;do;while($[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&N<ie);if(L=I-(ie-N),N=ie-I,q<L){if(M.match_start=X,K<=(q=L))break;ce=$[N+q-1],ae=$[N+q]}}while((X=J[X&ee])>U&&--B!=0);return q<=M.lookahead?q:M.lookahead}function de(M){var X,j,L,B,N,q,K,U,$,ee,J=M.w_size;do{if(B=M.window_size-M.lookahead-M.strstart,M.strstart>=J+(J-O)){for(o.arraySet(M.window,M.window,J,J,0),M.match_start-=J,M.strstart-=J,M.block_start-=J,X=j=M.hash_size;L=M.head[--X],M.head[X]=J<=L?L-J:0,--j;);for(X=j=J;L=M.prev[--X],M.prev[X]=J<=L?L-J:0,--j;);B+=J}if(M.strm.avail_in===0)break;if(q=M.strm,K=M.window,U=M.strstart+M.lookahead,$=B,ee=void 0,ee=q.avail_in,$<ee&&(ee=$),j=ee===0?0:(q.avail_in-=ee,o.arraySet(K,q.input,q.next_in,ee,U),q.state.wrap===1?q.adler=l(q.adler,K,ee,U):q.state.wrap===2&&(q.adler=h(q.adler,K,ee,U)),q.next_in+=ee,q.total_in+=ee,ee),M.lookahead+=j,M.lookahead+M.insert>=C)for(N=M.strstart-M.insert,M.ins_h=M.window[N],M.ins_h=(M.ins_h<<M.hash_shift^M.window[N+1])&M.hash_mask;M.insert&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[N+C-1])&M.hash_mask,M.prev[N&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=N,N++,M.insert--,!(M.lookahead+M.insert<C)););}while(M.lookahead<O&&M.strm.avail_in!==0)}function fe(M,X){for(var j,L;;){if(M.lookahead<O){if(de(M),M.lookahead<O&&X===u)return v;if(M.lookahead===0)break}if(j=0,M.lookahead>=C&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),j!==0&&M.strstart-j<=M.w_size-O&&(M.match_length=Y(M,j)),M.match_length>=C)if(L=a._tr_tally(M,M.strstart-M.match_start,M.match_length-C),M.lookahead-=M.match_length,M.match_length<=M.max_lazy_match&&M.lookahead>=C){for(M.match_length--;M.strstart++,M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart,--M.match_length!=0;);M.strstart++}else M.strstart+=M.match_length,M.match_length=0,M.ins_h=M.window[M.strstart],M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+1])&M.hash_mask;else L=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++;if(L&&(R(M,!1),M.strm.avail_out===0))return v}return M.insert=M.strstart<C-1?M.strstart:C-1,X===p?(R(M,!0),M.strm.avail_out===0?Z:W):M.last_lit&&(R(M,!1),M.strm.avail_out===0)?v:z}function se(M,X){for(var j,L,B;;){if(M.lookahead<O){if(de(M),M.lookahead<O&&X===u)return v;if(M.lookahead===0)break}if(j=0,M.lookahead>=C&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),M.prev_length=M.match_length,M.prev_match=M.match_start,M.match_length=C-1,j!==0&&M.prev_length<M.max_lazy_match&&M.strstart-j<=M.w_size-O&&(M.match_length=Y(M,j),M.match_length<=5&&(M.strategy===1||M.match_length===C&&4096<M.strstart-M.match_start)&&(M.match_length=C-1)),M.prev_length>=C&&M.match_length<=M.prev_length){for(B=M.strstart+M.lookahead-C,L=a._tr_tally(M,M.strstart-1-M.prev_match,M.prev_length-C),M.lookahead-=M.prev_length-1,M.prev_length-=2;++M.strstart<=B&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),--M.prev_length!=0;);if(M.match_available=0,M.match_length=C-1,M.strstart++,L&&(R(M,!1),M.strm.avail_out===0))return v}else if(M.match_available){if((L=a._tr_tally(M,0,M.window[M.strstart-1]))&&R(M,!1),M.strstart++,M.lookahead--,M.strm.avail_out===0)return v}else M.match_available=1,M.strstart++,M.lookahead--}return M.match_available&&(L=a._tr_tally(M,0,M.window[M.strstart-1]),M.match_available=0),M.insert=M.strstart<C-1?M.strstart:C-1,X===p?(R(M,!0),M.strm.avail_out===0?Z:W):M.last_lit&&(R(M,!1),M.strm.avail_out===0)?v:z}function oe(M,X,j,L,B){this.good_length=M,this.max_lazy=X,this.nice_length=j,this.max_chain=L,this.func=B}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*P),this.dyn_dtree=new o.Buf16(2*(2*_+1)),this.bl_tree=new o.Buf16(2*(2*D+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(k+1),this.heap=new o.Buf16(2*x+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*x+1),te(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pe(M){var X;return M&&M.state?(M.total_in=M.total_out=0,M.data_type=y,(X=M.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?A:E,M.adler=X.wrap===2?0:1,X.last_flush=u,a._tr_init(X),f):Q(M,d)}function Ae(M){var X=pe(M);return X===f&&(function(j){j.window_size=2*j.w_size,te(j.head),j.max_lazy_match=s[j.level].max_lazy,j.good_match=s[j.level].good_length,j.nice_match=s[j.level].nice_length,j.max_chain_length=s[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=C-1,j.match_available=0,j.ins_h=0})(M.state),X}function Le(M,X,j,L,B,N){if(!M)return d;var q=1;if(X===m&&(X=6),L<0?(q=0,L=-L):15<L&&(q=2,L-=16),B<1||b<B||j!==w||L<8||15<L||X<0||9<X||N<0||g<N)return Q(M,d);L===8&&(L=9);var K=new he;return(M.state=K).strm=M,K.wrap=q,K.gzhead=null,K.w_bits=L,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=B+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+C-1)/C),K.window=new o.Buf8(2*K.w_size),K.head=new o.Buf16(K.hash_size),K.prev=new o.Buf16(K.w_size),K.lit_bufsize=1<<B+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new o.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=X,K.strategy=N,K.method=j,Ae(M)}s=[new oe(0,0,0,0,function(M,X){var j=65535;for(j>M.pending_buf_size-5&&(j=M.pending_buf_size-5);;){if(M.lookahead<=1){if(de(M),M.lookahead===0&&X===u)return v;if(M.lookahead===0)break}M.strstart+=M.lookahead,M.lookahead=0;var L=M.block_start+j;if((M.strstart===0||M.strstart>=L)&&(M.lookahead=M.strstart-L,M.strstart=L,R(M,!1),M.strm.avail_out===0)||M.strstart-M.block_start>=M.w_size-O&&(R(M,!1),M.strm.avail_out===0))return v}return M.insert=0,X===p?(R(M,!0),M.strm.avail_out===0?Z:W):(M.strstart>M.block_start&&(R(M,!1),M.strm.avail_out),v)}),new oe(4,4,8,4,fe),new oe(4,5,16,8,fe),new oe(4,6,32,32,fe),new oe(4,4,16,16,se),new oe(8,16,32,32,se),new oe(8,16,128,128,se),new oe(8,32,128,256,se),new oe(32,128,258,1024,se),new oe(32,258,258,4096,se)],i.deflateInit=function(M,X){return Le(M,X,w,15,8,0)},i.deflateInit2=Le,i.deflateReset=Ae,i.deflateResetKeep=pe,i.deflateSetHeader=function(M,X){return M&&M.state?M.state.wrap!==2?d:(M.state.gzhead=X,f):d},i.deflate=function(M,X){var j,L,B,N;if(!M||!M.state||5<X||X<0)return M?Q(M,d):d;if(L=M.state,!M.output||!M.input&&M.avail_in!==0||L.status===666&&X!==p)return Q(M,M.avail_out===0?-5:d);if(L.strm=M,j=L.last_flush,L.last_flush=X,L.status===A)if(L.wrap===2)M.adler=0,ne(L,31),ne(L,139),ne(L,8),L.gzhead?(ne(L,(L.gzhead.text?1:0)+(L.gzhead.hcrc?2:0)+(L.gzhead.extra?4:0)+(L.gzhead.name?8:0)+(L.gzhead.comment?16:0)),ne(L,255&L.gzhead.time),ne(L,L.gzhead.time>>8&255),ne(L,L.gzhead.time>>16&255),ne(L,L.gzhead.time>>24&255),ne(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),ne(L,255&L.gzhead.os),L.gzhead.extra&&L.gzhead.extra.length&&(ne(L,255&L.gzhead.extra.length),ne(L,L.gzhead.extra.length>>8&255)),L.gzhead.hcrc&&(M.adler=h(M.adler,L.pending_buf,L.pending,0)),L.gzindex=0,L.status=69):(ne(L,0),ne(L,0),ne(L,0),ne(L,0),ne(L,0),ne(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),ne(L,3),L.status=E);else{var q=w+(L.w_bits-8<<4)<<8;q|=(2<=L.strategy||L.level<2?0:L.level<6?1:L.level===6?2:3)<<6,L.strstart!==0&&(q|=32),q+=31-q%31,L.status=E,H(L,q),L.strstart!==0&&(H(L,M.adler>>>16),H(L,65535&M.adler)),M.adler=1}if(L.status===69)if(L.gzhead.extra){for(B=L.pending;L.gzindex<(65535&L.gzhead.extra.length)&&(L.pending!==L.pending_buf_size||(L.gzhead.hcrc&&L.pending>B&&(M.adler=h(M.adler,L.pending_buf,L.pending-B,B)),F(M),B=L.pending,L.pending!==L.pending_buf_size));)ne(L,255&L.gzhead.extra[L.gzindex]),L.gzindex++;L.gzhead.hcrc&&L.pending>B&&(M.adler=h(M.adler,L.pending_buf,L.pending-B,B)),L.gzindex===L.gzhead.extra.length&&(L.gzindex=0,L.status=73)}else L.status=73;if(L.status===73)if(L.gzhead.name){B=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>B&&(M.adler=h(M.adler,L.pending_buf,L.pending-B,B)),F(M),B=L.pending,L.pending===L.pending_buf_size)){N=1;break}N=L.gzindex<L.gzhead.name.length?255&L.gzhead.name.charCodeAt(L.gzindex++):0,ne(L,N)}while(N!==0);L.gzhead.hcrc&&L.pending>B&&(M.adler=h(M.adler,L.pending_buf,L.pending-B,B)),N===0&&(L.gzindex=0,L.status=91)}else L.status=91;if(L.status===91)if(L.gzhead.comment){B=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>B&&(M.adler=h(M.adler,L.pending_buf,L.pending-B,B)),F(M),B=L.pending,L.pending===L.pending_buf_size)){N=1;break}N=L.gzindex<L.gzhead.comment.length?255&L.gzhead.comment.charCodeAt(L.gzindex++):0,ne(L,N)}while(N!==0);L.gzhead.hcrc&&L.pending>B&&(M.adler=h(M.adler,L.pending_buf,L.pending-B,B)),N===0&&(L.status=103)}else L.status=103;if(L.status===103&&(L.gzhead.hcrc?(L.pending+2>L.pending_buf_size&&F(M),L.pending+2<=L.pending_buf_size&&(ne(L,255&M.adler),ne(L,M.adler>>8&255),M.adler=0,L.status=E)):L.status=E),L.pending!==0){if(F(M),M.avail_out===0)return L.last_flush=-1,f}else if(M.avail_in===0&&G(X)<=G(j)&&X!==p)return Q(M,-5);if(L.status===666&&M.avail_in!==0)return Q(M,-5);if(M.avail_in!==0||L.lookahead!==0||X!==u&&L.status!==666){var K=L.strategy===2?(function(U,$){for(var ee;;){if(U.lookahead===0&&(de(U),U.lookahead===0)){if($===u)return v;break}if(U.match_length=0,ee=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,ee&&(R(U,!1),U.strm.avail_out===0))return v}return U.insert=0,$===p?(R(U,!0),U.strm.avail_out===0?Z:W):U.last_lit&&(R(U,!1),U.strm.avail_out===0)?v:z})(L,X):L.strategy===3?(function(U,$){for(var ee,J,ie,ce,ae=U.window;;){if(U.lookahead<=I){if(de(U),U.lookahead<=I&&$===u)return v;if(U.lookahead===0)break}if(U.match_length=0,U.lookahead>=C&&0<U.strstart&&(J=ae[ie=U.strstart-1])===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]){ce=U.strstart+I;do;while(J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&ie<ce);U.match_length=I-(ce-ie),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=C?(ee=a._tr_tally(U,1,U.match_length-C),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(ee=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),ee&&(R(U,!1),U.strm.avail_out===0))return v}return U.insert=0,$===p?(R(U,!0),U.strm.avail_out===0?Z:W):U.last_lit&&(R(U,!1),U.strm.avail_out===0)?v:z})(L,X):s[L.level].func(L,X);if(K!==Z&&K!==W||(L.status=666),K===v||K===Z)return M.avail_out===0&&(L.last_flush=-1),f;if(K===z&&(X===1?a._tr_align(L):X!==5&&(a._tr_stored_block(L,0,0,!1),X===3&&(te(L.head),L.lookahead===0&&(L.strstart=0,L.block_start=0,L.insert=0))),F(M),M.avail_out===0))return L.last_flush=-1,f}return X!==p?f:L.wrap<=0?1:(L.wrap===2?(ne(L,255&M.adler),ne(L,M.adler>>8&255),ne(L,M.adler>>16&255),ne(L,M.adler>>24&255),ne(L,255&M.total_in),ne(L,M.total_in>>8&255),ne(L,M.total_in>>16&255),ne(L,M.total_in>>24&255)):(H(L,M.adler>>>16),H(L,65535&M.adler)),F(M),0<L.wrap&&(L.wrap=-L.wrap),L.pending!==0?f:1)},i.deflateEnd=function(M){var X;return M&&M.state?(X=M.state.status)!==A&&X!==69&&X!==73&&X!==91&&X!==103&&X!==E&&X!==666?Q(M,d):(M.state=null,X===E?Q(M,-3):f):d},i.deflateSetDictionary=function(M,X){var j,L,B,N,q,K,U,$,ee=X.length;if(!M||!M.state||(N=(j=M.state).wrap)===2||N===1&&j.status!==A||j.lookahead)return d;for(N===1&&(M.adler=l(M.adler,X,ee,0)),j.wrap=0,ee>=j.w_size&&(N===0&&(te(j.head),j.strstart=0,j.block_start=0,j.insert=0),$=new o.Buf8(j.w_size),o.arraySet($,X,ee-j.w_size,j.w_size,0),X=$,ee=j.w_size),q=M.avail_in,K=M.next_in,U=M.input,M.avail_in=ee,M.next_in=0,M.input=X,de(j);j.lookahead>=C;){for(L=j.strstart,B=j.lookahead-(C-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[L+C-1])&j.hash_mask,j.prev[L&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=L,L++,--B;);j.strstart=L,j.lookahead=C-1,de(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=C-1,j.match_available=0,M.next_in=K,M.input=U,M.avail_in=q,j.wrap=N,f},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,n,i){n.exports=function(s,o){var a,l,h,c,u,p,f,d,m,g,y,w,b,x,_,D,P,k,C,I,O,A,E,v,z;a=s.state,l=s.next_in,v=s.input,h=l+(s.avail_in-5),c=s.next_out,z=s.output,u=c-(o-s.avail_out),p=c+(s.avail_out-257),f=a.dmax,d=a.wsize,m=a.whave,g=a.wnext,y=a.window,w=a.hold,b=a.bits,x=a.lencode,_=a.distcode,D=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{b<15&&(w+=v[l++]<<b,b+=8,w+=v[l++]<<b,b+=8),k=x[w&D];t:for(;;){if(w>>>=C=k>>>24,b-=C,(C=k>>>16&255)===0)z[c++]=65535&k;else{if(!(16&C)){if((64&C)==0){k=x[(65535&k)+(w&(1<<C)-1)];continue t}if(32&C){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}I=65535&k,(C&=15)&&(b<C&&(w+=v[l++]<<b,b+=8),I+=w&(1<<C)-1,w>>>=C,b-=C),b<15&&(w+=v[l++]<<b,b+=8,w+=v[l++]<<b,b+=8),k=_[w&P];n:for(;;){if(w>>>=C=k>>>24,b-=C,!(16&(C=k>>>16&255))){if((64&C)==0){k=_[(65535&k)+(w&(1<<C)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,b<(C&=15)&&(w+=v[l++]<<b,(b+=8)<C&&(w+=v[l++]<<b,b+=8)),f<(O+=w&(1<<C)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(w>>>=C,b-=C,(C=c-u)<O){if(m<(C=O-C)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(E=y,(A=0)===g){if(A+=d-C,C<I){for(I-=C;z[c++]=y[A++],--C;);A=c-O,E=z}}else if(g<C){if(A+=d+g-C,(C-=g)<I){for(I-=C;z[c++]=y[A++],--C;);if(A=0,g<I){for(I-=C=g;z[c++]=y[A++],--C;);A=c-O,E=z}}}else if(A+=g-C,C<I){for(I-=C;z[c++]=y[A++],--C;);A=c-O,E=z}for(;2<I;)z[c++]=E[A++],z[c++]=E[A++],z[c++]=E[A++],I-=3;I&&(z[c++]=E[A++],1<I&&(z[c++]=E[A++]))}else{for(A=c-O;z[c++]=z[A++],z[c++]=z[A++],z[c++]=z[A++],2<(I-=3););I&&(z[c++]=z[A++],1<I&&(z[c++]=z[A++]))}break}}break}}while(l<h&&c<p);l-=I=b>>3,w&=(1<<(b-=I<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l<h?h-l+5:5-(l-h),s.avail_out=c<p?p-c+257:257-(c-p),a.hold=w,a.bits=b}},{}],49:[function(t,n,i){var s=t("../utils/common"),o=t("./adler32"),a=t("./crc32"),l=t("./inffast"),h=t("./inftrees"),c=1,u=2,p=0,f=-2,d=1,m=852,g=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(A){var E;return A&&A.state?(E=A.state,A.total_in=A.total_out=E.total=0,A.msg="",E.wrap&&(A.adler=1&E.wrap),E.mode=d,E.last=0,E.havedict=0,E.dmax=32768,E.head=null,E.hold=0,E.bits=0,E.lencode=E.lendyn=new s.Buf32(m),E.distcode=E.distdyn=new s.Buf32(g),E.sane=1,E.back=-1,p):f}function x(A){var E;return A&&A.state?((E=A.state).wsize=0,E.whave=0,E.wnext=0,b(A)):f}function _(A,E){var v,z;return A&&A.state?(z=A.state,E<0?(v=0,E=-E):(v=1+(E>>4),E<48&&(E&=15)),E&&(E<8||15<E)?f:(z.window!==null&&z.wbits!==E&&(z.window=null),z.wrap=v,z.wbits=E,x(A))):f}function D(A,E){var v,z;return A?(z=new w,(A.state=z).window=null,(v=_(A,E))!==p&&(A.state=null),v):f}var P,k,C=!0;function I(A){if(C){var E;for(P=new s.Buf32(512),k=new s.Buf32(32),E=0;E<144;)A.lens[E++]=8;for(;E<256;)A.lens[E++]=9;for(;E<280;)A.lens[E++]=7;for(;E<288;)A.lens[E++]=8;for(h(c,A.lens,0,288,P,0,A.work,{bits:9}),E=0;E<32;)A.lens[E++]=5;h(u,A.lens,0,32,k,0,A.work,{bits:5}),C=!1}A.lencode=P,A.lenbits=9,A.distcode=k,A.distbits=5}function O(A,E,v,z){var Z,W=A.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new s.Buf8(W.wsize)),z>=W.wsize?(s.arraySet(W.window,E,v-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(z<(Z=W.wsize-W.wnext)&&(Z=z),s.arraySet(W.window,E,v-z,Z,W.wnext),(z-=Z)?(s.arraySet(W.window,E,v-z,z,0),W.wnext=z,W.whave=W.wsize):(W.wnext+=Z,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=Z))),0}i.inflateReset=x,i.inflateReset2=_,i.inflateResetKeep=b,i.inflateInit=function(A){return D(A,15)},i.inflateInit2=D,i.inflate=function(A,E){var v,z,Z,W,Q,G,te,F,R,ne,H,Y,de,fe,se,oe,he,pe,Ae,Le,M,X,j,L,B=0,N=new s.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return f;(v=A.state).mode===12&&(v.mode=13),Q=A.next_out,Z=A.output,te=A.avail_out,W=A.next_in,z=A.input,G=A.avail_in,F=v.hold,R=v.bits,ne=G,H=te,X=p;e:for(;;)switch(v.mode){case d:if(v.wrap===0){v.mode=13;break}for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(2&v.wrap&&F===35615){N[v.check=0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0),R=F=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&F)<<8)+(F>>8))%31){A.msg="incorrect header check",v.mode=30;break}if((15&F)!=8){A.msg="unknown compression method",v.mode=30;break}if(R-=4,M=8+(15&(F>>>=4)),v.wbits===0)v.wbits=M;else if(M>v.wbits){A.msg="invalid window size",v.mode=30;break}v.dmax=1<<M,A.adler=v.check=1,v.mode=512&F?10:12,R=F=0;break;case 2:for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(v.flags=F,(255&v.flags)!=8){A.msg="unknown compression method",v.mode=30;break}if(57344&v.flags){A.msg="unknown header flags set",v.mode=30;break}v.head&&(v.head.text=F>>8&1),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0)),R=F=0,v.mode=3;case 3:for(;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.head&&(v.head.time=F),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,N[2]=F>>>16&255,N[3]=F>>>24&255,v.check=a(v.check,N,4,0)),R=F=0,v.mode=4;case 4:for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.head&&(v.head.xflags=255&F,v.head.os=F>>8),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0)),R=F=0,v.mode=5;case 5:if(1024&v.flags){for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.length=F,v.head&&(v.head.extra_len=F),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0)),R=F=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(G<(Y=v.length)&&(Y=G),Y&&(v.head&&(M=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,z,W,Y,M)),512&v.flags&&(v.check=a(v.check,z,Y,W)),G-=Y,W+=Y,v.length-=Y),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(G===0)break e;for(Y=0;M=z[W+Y++],v.head&&M&&v.length<65536&&(v.head.name+=String.fromCharCode(M)),M&&Y<G;);if(512&v.flags&&(v.check=a(v.check,z,Y,W)),G-=Y,W+=Y,M)break e}else v.head&&(v.head.name=null);v.length=0,v.mode=8;case 8:if(4096&v.flags){if(G===0)break e;for(Y=0;M=z[W+Y++],v.head&&M&&v.length<65536&&(v.head.comment+=String.fromCharCode(M)),M&&Y<G;);if(512&v.flags&&(v.check=a(v.check,z,Y,W)),G-=Y,W+=Y,M)break e}else v.head&&(v.head.comment=null);v.mode=9;case 9:if(512&v.flags){for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(F!==(65535&v.check)){A.msg="header crc mismatch",v.mode=30;break}R=F=0}v.head&&(v.head.hcrc=v.flags>>9&1,v.head.done=!0),A.adler=v.check=0,v.mode=12;break;case 10:for(;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}A.adler=v.check=y(F),R=F=0,v.mode=11;case 11:if(v.havedict===0)return A.next_out=Q,A.avail_out=te,A.next_in=W,A.avail_in=G,v.hold=F,v.bits=R,2;A.adler=v.check=1,v.mode=12;case 12:if(E===5||E===6)break e;case 13:if(v.last){F>>>=7&R,R-=7&R,v.mode=27;break}for(;R<3;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}switch(v.last=1&F,R-=1,3&(F>>>=1)){case 0:v.mode=14;break;case 1:if(I(v),v.mode=20,E!==6)break;F>>>=2,R-=2;break e;case 2:v.mode=17;break;case 3:A.msg="invalid block type",v.mode=30}F>>>=2,R-=2;break;case 14:for(F>>>=7&R,R-=7&R;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if((65535&F)!=(F>>>16^65535)){A.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&F,R=F=0,v.mode=15,E===6)break e;case 15:v.mode=16;case 16:if(Y=v.length){if(G<Y&&(Y=G),te<Y&&(Y=te),Y===0)break e;s.arraySet(Z,z,W,Y,Q),G-=Y,W+=Y,te-=Y,Q+=Y,v.length-=Y;break}v.mode=12;break;case 17:for(;R<14;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(v.nlen=257+(31&F),F>>>=5,R-=5,v.ndist=1+(31&F),F>>>=5,R-=5,v.ncode=4+(15&F),F>>>=4,R-=4,286<v.nlen||30<v.ndist){A.msg="too many length or distance symbols",v.mode=30;break}v.have=0,v.mode=18;case 18:for(;v.have<v.ncode;){for(;R<3;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.lens[q[v.have++]]=7&F,F>>>=3,R-=3}for(;v.have<19;)v.lens[q[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,j={bits:v.lenbits},X=h(0,v.lens,0,19,v.lencode,0,v.work,j),v.lenbits=j.bits,X){A.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have<v.nlen+v.ndist;){for(;oe=(B=v.lencode[F&(1<<v.lenbits)-1])>>>16&255,he=65535&B,!((se=B>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(he<16)F>>>=se,R-=se,v.lens[v.have++]=he;else{if(he===16){for(L=se+2;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(F>>>=se,R-=se,v.have===0){A.msg="invalid bit length repeat",v.mode=30;break}M=v.lens[v.have-1],Y=3+(3&F),F>>>=2,R-=2}else if(he===17){for(L=se+3;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}R-=se,M=0,Y=3+(7&(F>>>=se)),F>>>=3,R-=3}else{for(L=se+7;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}R-=se,M=0,Y=11+(127&(F>>>=se)),F>>>=7,R-=7}if(v.have+Y>v.nlen+v.ndist){A.msg="invalid bit length repeat",v.mode=30;break}for(;Y--;)v.lens[v.have++]=M}}if(v.mode===30)break;if(v.lens[256]===0){A.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,j={bits:v.lenbits},X=h(c,v.lens,0,v.nlen,v.lencode,0,v.work,j),v.lenbits=j.bits,X){A.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,j={bits:v.distbits},X=h(u,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,j),v.distbits=j.bits,X){A.msg="invalid distances set",v.mode=30;break}if(v.mode=20,E===6)break e;case 20:v.mode=21;case 21:if(6<=G&&258<=te){A.next_out=Q,A.avail_out=te,A.next_in=W,A.avail_in=G,v.hold=F,v.bits=R,l(A,H),Q=A.next_out,Z=A.output,te=A.avail_out,W=A.next_in,z=A.input,G=A.avail_in,F=v.hold,R=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;oe=(B=v.lencode[F&(1<<v.lenbits)-1])>>>16&255,he=65535&B,!((se=B>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(oe&&(240&oe)==0){for(pe=se,Ae=oe,Le=he;oe=(B=v.lencode[Le+((F&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&B,!(pe+(se=B>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}F>>>=pe,R-=pe,v.back+=pe}if(F>>>=se,R-=se,v.back+=se,v.length=he,oe===0){v.mode=26;break}if(32&oe){v.back=-1,v.mode=12;break}if(64&oe){A.msg="invalid literal/length code",v.mode=30;break}v.extra=15&oe,v.mode=22;case 22:if(v.extra){for(L=v.extra;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.length+=F&(1<<v.extra)-1,F>>>=v.extra,R-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;oe=(B=v.distcode[F&(1<<v.distbits)-1])>>>16&255,he=65535&B,!((se=B>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if((240&oe)==0){for(pe=se,Ae=oe,Le=he;oe=(B=v.distcode[Le+((F&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&B,!(pe+(se=B>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}F>>>=pe,R-=pe,v.back+=pe}if(F>>>=se,R-=se,v.back+=se,64&oe){A.msg="invalid distance code",v.mode=30;break}v.offset=he,v.extra=15&oe,v.mode=24;case 24:if(v.extra){for(L=v.extra;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.offset+=F&(1<<v.extra)-1,F>>>=v.extra,R-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){A.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(te===0)break e;if(Y=H-te,v.offset>Y){if((Y=v.offset-Y)>v.whave&&v.sane){A.msg="invalid distance too far back",v.mode=30;break}de=Y>v.wnext?(Y-=v.wnext,v.wsize-Y):v.wnext-Y,Y>v.length&&(Y=v.length),fe=v.window}else fe=Z,de=Q-v.offset,Y=v.length;for(te<Y&&(Y=te),te-=Y,v.length-=Y;Z[Q++]=fe[de++],--Y;);v.length===0&&(v.mode=21);break;case 26:if(te===0)break e;Z[Q++]=v.length,te--,v.mode=21;break;case 27:if(v.wrap){for(;R<32;){if(G===0)break e;G--,F|=z[W++]<<R,R+=8}if(H-=te,A.total_out+=H,v.total+=H,H&&(A.adler=v.check=v.flags?a(v.check,Z,H,Q-H):o(v.check,Z,H,Q-H)),H=te,(v.flags?F:y(F))!==v.check){A.msg="incorrect data check",v.mode=30;break}R=F=0}v.mode=28;case 28:if(v.wrap&&v.flags){for(;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(F!==(4294967295&v.total)){A.msg="incorrect length check",v.mode=30;break}R=F=0}v.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;case 32:default:return f}return A.next_out=Q,A.avail_out=te,A.next_in=W,A.avail_in=G,v.hold=F,v.bits=R,(v.wsize||H!==A.avail_out&&v.mode<30&&(v.mode<27||E!==4))&&O(A,A.output,A.next_out,H-A.avail_out)?(v.mode=31,-4):(ne-=A.avail_in,H-=A.avail_out,A.total_in+=ne,A.total_out+=H,v.total+=H,v.wrap&&H&&(A.adler=v.check=v.flags?a(v.check,Z,H,A.next_out-H):o(v.check,Z,H,A.next_out-H)),A.data_type=v.bits+(v.last?64:0)+(v.mode===12?128:0)+(v.mode===20||v.mode===15?256:0),(ne==0&&H===0||E===4)&&X===p&&(X=-5),X)},i.inflateEnd=function(A){if(!A||!A.state)return f;var E=A.state;return E.window&&(E.window=null),A.state=null,p},i.inflateGetHeader=function(A,E){var v;return A&&A.state?(2&(v=A.state).wrap)==0?f:((v.head=E).done=!1,p):f},i.inflateSetDictionary=function(A,E){var v,z=E.length;return A&&A.state?(v=A.state).wrap!==0&&v.mode!==11?f:v.mode===11&&o(1,E,z,0)!==v.check?-3:O(A,E,z,z)?(v.mode=31,-4):(v.havedict=1,p):f},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var s=t("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],h=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(c,u,p,f,d,m,g,y){var w,b,x,_,D,P,k,C,I,O=y.bits,A=0,E=0,v=0,z=0,Z=0,W=0,Q=0,G=0,te=0,F=0,R=null,ne=0,H=new s.Buf16(16),Y=new s.Buf16(16),de=null,fe=0;for(A=0;A<=15;A++)H[A]=0;for(E=0;E<f;E++)H[u[p+E]]++;for(Z=O,z=15;1<=z&&H[z]===0;z--);if(z<Z&&(Z=z),z===0)return d[m++]=20971520,d[m++]=20971520,y.bits=1,0;for(v=1;v<z&&H[v]===0;v++);for(Z<v&&(Z=v),A=G=1;A<=15;A++)if(G<<=1,(G-=H[A])<0)return-1;if(0<G&&(c===0||z!==1))return-1;for(Y[1]=0,A=1;A<15;A++)Y[A+1]=Y[A]+H[A];for(E=0;E<f;E++)u[p+E]!==0&&(g[Y[u[p+E]]++]=E);if(P=c===0?(R=de=g,19):c===1?(R=o,ne-=257,de=a,fe-=257,256):(R=l,de=h,-1),A=v,D=m,Q=E=F=0,x=-1,_=(te=1<<(W=Z))-1,c===1&&852<te||c===2&&592<te)return 1;for(;;){for(k=A-Q,I=g[E]<P?(C=0,g[E]):g[E]>P?(C=de[fe+g[E]],R[ne+g[E]]):(C=96,0),w=1<<A-Q,v=b=1<<W;d[D+(F>>Q)+(b-=w)]=k<<24|C<<16|I|0,b!==0;);for(w=1<<A-1;F&w;)w>>=1;if(w!==0?(F&=w-1,F+=w):F=0,E++,--H[A]==0){if(A===z)break;A=u[p+g[E]]}if(Z<A&&(F&_)!==x){for(Q===0&&(Q=Z),D+=v,G=1<<(W=A-Q);W+Q<z&&!((G-=H[W+Q])<=0);)W++,G<<=1;if(te+=1<<W,c===1&&852<te||c===2&&592<te)return 1;d[x=F&_]=Z<<24|W<<16|D-m|0}}return F!==0&&(d[D+F]=A-Q<<24|64<<16|0),y.bits=Z,0}},{"../utils/common":41}],51:[function(t,n,i){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,n,i){var s=t("../utils/common"),o=0,a=1;function l(B){for(var N=B.length;0<=--N;)B[N]=0}var h=0,c=29,u=256,p=u+1+c,f=30,d=19,m=2*p+1,g=15,y=16,w=7,b=256,x=16,_=17,D=18,P=[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],k=[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],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(p+2));l(O);var A=new Array(2*f);l(A);var E=new Array(512);l(E);var v=new Array(256);l(v);var z=new Array(c);l(z);var Z,W,Q,G=new Array(f);function te(B,N,q,K,U){this.static_tree=B,this.extra_bits=N,this.extra_base=q,this.elems=K,this.max_length=U,this.has_stree=B&&B.length}function F(B,N){this.dyn_tree=B,this.max_code=0,this.stat_desc=N}function R(B){return B<256?E[B]:E[256+(B>>>7)]}function ne(B,N){B.pending_buf[B.pending++]=255&N,B.pending_buf[B.pending++]=N>>>8&255}function H(B,N,q){B.bi_valid>y-q?(B.bi_buf|=N<<B.bi_valid&65535,ne(B,B.bi_buf),B.bi_buf=N>>y-B.bi_valid,B.bi_valid+=q-y):(B.bi_buf|=N<<B.bi_valid&65535,B.bi_valid+=q)}function Y(B,N,q){H(B,q[2*N],q[2*N+1])}function de(B,N){for(var q=0;q|=1&B,B>>>=1,q<<=1,0<--N;);return q>>>1}function fe(B,N,q){var K,U,$=new Array(g+1),ee=0;for(K=1;K<=g;K++)$[K]=ee=ee+q[K-1]<<1;for(U=0;U<=N;U++){var J=B[2*U+1];J!==0&&(B[2*U]=de($[J]++,J))}}function se(B){var N;for(N=0;N<p;N++)B.dyn_ltree[2*N]=0;for(N=0;N<f;N++)B.dyn_dtree[2*N]=0;for(N=0;N<d;N++)B.bl_tree[2*N]=0;B.dyn_ltree[2*b]=1,B.opt_len=B.static_len=0,B.last_lit=B.matches=0}function oe(B){8<B.bi_valid?ne(B,B.bi_buf):0<B.bi_valid&&(B.pending_buf[B.pending++]=B.bi_buf),B.bi_buf=0,B.bi_valid=0}function he(B,N,q,K){var U=2*N,$=2*q;return B[U]<B[$]||B[U]===B[$]&&K[N]<=K[q]}function pe(B,N,q){for(var K=B.heap[q],U=q<<1;U<=B.heap_len&&(U<B.heap_len&&he(N,B.heap[U+1],B.heap[U],B.depth)&&U++,!he(N,K,B.heap[U],B.depth));)B.heap[q]=B.heap[U],q=U,U<<=1;B.heap[q]=K}function Ae(B,N,q){var K,U,$,ee,J=0;if(B.last_lit!==0)for(;K=B.pending_buf[B.d_buf+2*J]<<8|B.pending_buf[B.d_buf+2*J+1],U=B.pending_buf[B.l_buf+J],J++,K===0?Y(B,U,N):(Y(B,($=v[U])+u+1,N),(ee=P[$])!==0&&H(B,U-=z[$],ee),Y(B,$=R(--K),q),(ee=k[$])!==0&&H(B,K-=G[$],ee)),J<B.last_lit;);Y(B,b,N)}function Le(B,N){var q,K,U,$=N.dyn_tree,ee=N.stat_desc.static_tree,J=N.stat_desc.has_stree,ie=N.stat_desc.elems,ce=-1;for(B.heap_len=0,B.heap_max=m,q=0;q<ie;q++)$[2*q]!==0?(B.heap[++B.heap_len]=ce=q,B.depth[q]=0):$[2*q+1]=0;for(;B.heap_len<2;)$[2*(U=B.heap[++B.heap_len]=ce<2?++ce:0)]=1,B.depth[U]=0,B.opt_len--,J&&(B.static_len-=ee[2*U+1]);for(N.max_code=ce,q=B.heap_len>>1;1<=q;q--)pe(B,$,q);for(U=ie;q=B.heap[1],B.heap[1]=B.heap[B.heap_len--],pe(B,$,1),K=B.heap[1],B.heap[--B.heap_max]=q,B.heap[--B.heap_max]=K,$[2*U]=$[2*q]+$[2*K],B.depth[U]=(B.depth[q]>=B.depth[K]?B.depth[q]:B.depth[K])+1,$[2*q+1]=$[2*K+1]=U,B.heap[1]=U++,pe(B,$,1),2<=B.heap_len;);B.heap[--B.heap_max]=B.heap[1],(function(ae,Te){var $e,ke,Lt,ge,Qt,wn,Je=Te.dyn_tree,wt=Te.max_code,Ot=Te.stat_desc.static_tree,zt=Te.stat_desc.has_stree,Nt=Te.stat_desc.extra_bits,bt=Te.stat_desc.extra_base,bn=Te.stat_desc.max_length,gi=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(Je[2*ae.heap[ae.heap_max]+1]=0,$e=ae.heap_max+1;$e<m;$e++)bn<(ge=Je[2*Je[2*(ke=ae.heap[$e])+1]+1]+1)&&(ge=bn,gi++),Je[2*ke+1]=ge,wt<ke||(ae.bl_count[ge]++,Qt=0,bt<=ke&&(Qt=Nt[ke-bt]),wn=Je[2*ke],ae.opt_len+=wn*(ge+Qt),zt&&(ae.static_len+=wn*(Ot[2*ke+1]+Qt)));if(gi!==0){do{for(ge=bn-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[bn]--,gi-=2}while(0<gi);for(ge=bn;ge!==0;ge--)for(ke=ae.bl_count[ge];ke!==0;)wt<(Lt=ae.heap[--$e])||(Je[2*Lt+1]!==ge&&(ae.opt_len+=(ge-Je[2*Lt+1])*Je[2*Lt],Je[2*Lt+1]=ge),ke--)}})(B,N),fe($,ce,B.bl_count)}function M(B,N,q){var K,U,$=-1,ee=N[1],J=0,ie=7,ce=4;for(ee===0&&(ie=138,ce=3),N[2*(q+1)+1]=65535,K=0;K<=q;K++)U=ee,ee=N[2*(K+1)+1],++J<ie&&U===ee||(J<ce?B.bl_tree[2*U]+=J:U!==0?(U!==$&&B.bl_tree[2*U]++,B.bl_tree[2*x]++):J<=10?B.bl_tree[2*_]++:B.bl_tree[2*D]++,$=U,ce=(J=0)===ee?(ie=138,3):U===ee?(ie=6,3):(ie=7,4))}function X(B,N,q){var K,U,$=-1,ee=N[1],J=0,ie=7,ce=4;for(ee===0&&(ie=138,ce=3),K=0;K<=q;K++)if(U=ee,ee=N[2*(K+1)+1],!(++J<ie&&U===ee)){if(J<ce)for(;Y(B,U,B.bl_tree),--J!=0;);else U!==0?(U!==$&&(Y(B,U,B.bl_tree),J--),Y(B,x,B.bl_tree),H(B,J-3,2)):J<=10?(Y(B,_,B.bl_tree),H(B,J-3,3)):(Y(B,D,B.bl_tree),H(B,J-11,7));$=U,ce=(J=0)===ee?(ie=138,3):U===ee?(ie=6,3):(ie=7,4)}}l(G);var j=!1;function L(B,N,q,K){H(B,(h<<1)+(K?1:0),3),(function(U,$,ee,J){oe(U),ne(U,ee),ne(U,~ee),s.arraySet(U.pending_buf,U.window,$,ee,U.pending),U.pending+=ee})(B,N,q)}i._tr_init=function(B){j||((function(){var N,q,K,U,$,ee=new Array(g+1);for(U=K=0;U<c-1;U++)for(z[U]=K,N=0;N<1<<P[U];N++)v[K++]=U;for(v[K-1]=U,U=$=0;U<16;U++)for(G[U]=$,N=0;N<1<<k[U];N++)E[$++]=U;for($>>=7;U<f;U++)for(G[U]=$<<7,N=0;N<1<<k[U]-7;N++)E[256+$++]=U;for(q=0;q<=g;q++)ee[q]=0;for(N=0;N<=143;)O[2*N+1]=8,N++,ee[8]++;for(;N<=255;)O[2*N+1]=9,N++,ee[9]++;for(;N<=279;)O[2*N+1]=7,N++,ee[7]++;for(;N<=287;)O[2*N+1]=8,N++,ee[8]++;for(fe(O,p+1,ee),N=0;N<f;N++)A[2*N+1]=5,A[2*N]=de(N,5);Z=new te(O,P,u+1,p,g),W=new te(A,k,0,f,g),Q=new te(new Array(0),C,0,d,w)})(),j=!0),B.l_desc=new F(B.dyn_ltree,Z),B.d_desc=new F(B.dyn_dtree,W),B.bl_desc=new F(B.bl_tree,Q),B.bi_buf=0,B.bi_valid=0,se(B)},i._tr_stored_block=L,i._tr_flush_block=function(B,N,q,K){var U,$,ee=0;0<B.level?(B.strm.data_type===2&&(B.strm.data_type=(function(J){var ie,ce=4093624447;for(ie=0;ie<=31;ie++,ce>>>=1)if(1&ce&&J.dyn_ltree[2*ie]!==0)return o;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return a;for(ie=32;ie<u;ie++)if(J.dyn_ltree[2*ie]!==0)return a;return o})(B)),Le(B,B.l_desc),Le(B,B.d_desc),ee=(function(J){var ie;for(M(J,J.dyn_ltree,J.l_desc.max_code),M(J,J.dyn_dtree,J.d_desc.max_code),Le(J,J.bl_desc),ie=d-1;3<=ie&&J.bl_tree[2*I[ie]+1]===0;ie--);return J.opt_len+=3*(ie+1)+5+5+4,ie})(B),U=B.opt_len+3+7>>>3,($=B.static_len+3+7>>>3)<=U&&(U=$)):U=$=q+5,q+4<=U&&N!==-1?L(B,N,q,K):B.strategy===4||$===U?(H(B,2+(K?1:0),3),Ae(B,O,A)):(H(B,4+(K?1:0),3),(function(J,ie,ce,ae){var Te;for(H(J,ie-257,5),H(J,ce-1,5),H(J,ae-4,4),Te=0;Te<ae;Te++)H(J,J.bl_tree[2*I[Te]+1],3);X(J,J.dyn_ltree,ie-1),X(J,J.dyn_dtree,ce-1)})(B,B.l_desc.max_code+1,B.d_desc.max_code+1,ee+1),Ae(B,B.dyn_ltree,B.dyn_dtree)),se(B),K&&oe(B)},i._tr_tally=function(B,N,q){return B.pending_buf[B.d_buf+2*B.last_lit]=N>>>8&255,B.pending_buf[B.d_buf+2*B.last_lit+1]=255&N,B.pending_buf[B.l_buf+B.last_lit]=255&q,B.last_lit++,N===0?B.dyn_ltree[2*q]++:(B.matches++,N--,B.dyn_ltree[2*(v[q]+u+1)]++,B.dyn_dtree[2*R(N)]++),B.last_lit===B.lit_bufsize-1},i._tr_align=function(B){H(B,2,3),Y(B,b,O),(function(N){N.bi_valid===16?(ne(N,N.bi_buf),N.bi_buf=0,N.bi_valid=0):8<=N.bi_valid&&(N.pending_buf[N.pending++]=255&N.bi_buf,N.bi_buf>>=8,N.bi_valid-=8)})(B)}},{"../utils/common":41}],53:[function(t,n,i){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,n,i){(function(s){(function(o,a){if(!o.setImmediate){var l,h,c,u,p=1,f={},d=!1,m=o.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(o);g=g&&g.setTimeout?g:o,l={}.toString.call(o.process)==="[object process]"?function(x){process.nextTick(function(){w(x)})}:(function(){if(o.postMessage&&!o.importScripts){var x=!0,_=o.onmessage;return o.onmessage=function(){x=!1},o.postMessage("","*"),o.onmessage=_,x}})()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",b,!1):o.attachEvent("onmessage",b),function(x){o.postMessage(u+x,"*")}):o.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){w(x.data)},function(x){c.port2.postMessage(x)}):m&&"onreadystatechange"in m.createElement("script")?(h=m.documentElement,function(x){var _=m.createElement("script");_.onreadystatechange=function(){w(x),_.onreadystatechange=null,h.removeChild(_),_=null},h.appendChild(_)}):function(x){setTimeout(w,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var _=new Array(arguments.length-1),D=0;D<_.length;D++)_[D]=arguments[D+1];var P={callback:x,args:_};return f[p]=P,l(p),p++},g.clearImmediate=y}function y(x){delete f[x]}function w(x){if(d)setTimeout(w,0,x);else{var _=f[x];if(_){d=!0;try{(function(D){var P=D.callback,k=D.args;switch(k.length){case 0:P();break;case 1:P(k[0]);break;case 2:P(k[0],k[1]);break;case 3:P(k[0],k[1],k[2]);break;default:P.apply(a,k)}})(_)}finally{y(x),d=!1}}}}function b(x){x.source===o&&typeof x.data=="string"&&x.data.indexOf(u)===0&&w(+x.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Cn<"u"?Cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(vi)),vi.exports}var ma=pa();const zs=Ls(ma);function Ns(r,e){return function(){return r.apply(e,arguments)}}const{toString:ga}=Object.prototype,{getPrototypeOf:Mi}=Object,{iterator:Dn,toStringTag:Rs}=Symbol,kn=(r=>e=>{const t=ga.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ke=r=>(r=r.toLowerCase(),e=>kn(e)===r),In=r=>e=>typeof e===r,{isArray:Ft}=Array,Ut=In("undefined");function en(r){return r!==null&&!Ut(r)&&r.constructor!==null&&!Ut(r.constructor)&&Ne(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Fs=Ke("ArrayBuffer");function ya(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Fs(r.buffer),e}const wa=In("string"),Ne=In("function"),Us=In("number"),tn=r=>r!==null&&typeof r=="object",ba=r=>r===!0||r===!1,Bn=r=>{if(kn(r)!=="object")return!1;const e=Mi(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Rs in r)&&!(Dn in r)},xa=r=>{if(!tn(r)||en(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},_a=Ke("Date"),va=Ke("File"),Ma=Ke("Blob"),Sa=Ke("FileList"),Aa=r=>tn(r)&&Ne(r.pipe),Ta=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Ne(r.append)&&((e=kn(r))==="formdata"||e==="object"&&Ne(r.toString)&&r.toString()==="[object FormData]"))},Ca=Ke("URLSearchParams"),[Pa,Da,ka,Ia]=["ReadableStream","Request","Response","Headers"].map(Ke),Ba=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nn(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,i;if(typeof r!="object"&&(r=[r]),Ft(r))for(n=0,i=r.length;n<i;n++)e.call(null,r[n],n,r);else{if(en(r))return;const s=t?Object.getOwnPropertyNames(r):Object.keys(r),o=s.length;let a;for(n=0;n<o;n++)a=s[n],e.call(null,r[a],a,r)}}function Vs(r,e){if(en(r))return null;e=e.toLowerCase();const t=Object.keys(r);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const _t=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,js=r=>!Ut(r)&&r!==_t;function Si(){const{caseless:r,skipUndefined:e}=js(this)&&this||{},t={},n=(i,s)=>{const o=r&&Vs(t,s)||s;Bn(t[o])&&Bn(i)?t[o]=Si(t[o],i):Bn(i)?t[o]=Si({},i):Ft(i)?t[o]=i.slice():(!e||!Ut(i))&&(t[o]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&nn(arguments[i],n);return t}const Ea=(r,e,t,{allOwnKeys:n}={})=>(nn(e,(i,s)=>{t&&Ne(i)?r[s]=Ns(i,t):r[s]=i},{allOwnKeys:n}),r),La=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),Oa=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},za=(r,e,t,n)=>{let i,s,o;const a={};if(e=e||{},r==null)return e;do{for(i=Object.getOwnPropertyNames(r),s=i.length;s-- >0;)o=i[s],(!n||n(o,r,e))&&!a[o]&&(e[o]=r[o],a[o]=!0);r=t!==!1&&Mi(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Na=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const n=r.indexOf(e,t);return n!==-1&&n===t},Ra=r=>{if(!r)return null;if(Ft(r))return r;let e=r.length;if(!Us(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},Fa=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&Mi(Uint8Array)),Ua=(r,e)=>{const n=(r&&r[Dn]).call(r);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(r,s[0],s[1])}},Va=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},ja=Ke("HTMLFormElement"),Ga=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Gs=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Wa=Ke("RegExp"),Ws=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};nn(t,(i,s)=>{let o;(o=e(i,s,r))!==!1&&(n[s]=o||i)}),Object.defineProperties(r,n)},Xa=r=>{Ws(r,(e,t)=>{if(Ne(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(Ne(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},qa=(r,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return Ft(r)?n(r):n(String(r).split(e)),t},Ka=()=>{},Za=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function Ya(r){return!!(r&&Ne(r.append)&&r[Rs]==="FormData"&&r[Dn])}const $a=r=>{const e=new Array(10),t=(n,i)=>{if(tn(n)){if(e.indexOf(n)>=0)return;if(en(n))return n;if(!("toJSON"in n)){e[i]=n;const s=Ft(n)?[]:{};return nn(n,(o,a)=>{const l=t(o,i+1);!Ut(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(r,0)},Ja=Ke("AsyncFunction"),Ha=r=>r&&(tn(r)||Ne(r))&&Ne(r.then)&&Ne(r.catch),Xs=((r,e)=>r?setImmediate:e?((t,n)=>(_t.addEventListener("message",({source:i,data:s})=>{i===_t&&s===t&&n.length&&n.shift()()},!1),i=>{n.push(i),_t.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ne(_t.postMessage)),Qa=typeof queueMicrotask<"u"?queueMicrotask.bind(_t):typeof process<"u"&&process.nextTick||Xs,V={isArray:Ft,isArrayBuffer:Fs,isBuffer:en,isFormData:Ta,isArrayBufferView:ya,isString:wa,isNumber:Us,isBoolean:ba,isObject:tn,isPlainObject:Bn,isEmptyObject:xa,isReadableStream:Pa,isRequest:Da,isResponse:ka,isHeaders:Ia,isUndefined:Ut,isDate:_a,isFile:va,isBlob:Ma,isRegExp:Wa,isFunction:Ne,isStream:Aa,isURLSearchParams:Ca,isTypedArray:Fa,isFileList:Sa,forEach:nn,merge:Si,extend:Ea,trim:Ba,stripBOM:La,inherits:Oa,toFlatObject:za,kindOf:kn,kindOfTest:Ke,endsWith:Na,toArray:Ra,forEachEntry:Ua,matchAll:Va,isHTMLForm:ja,hasOwnProperty:Gs,hasOwnProp:Gs,reduceDescriptors:Ws,freezeMethods:Xa,toObjectSet:qa,toCamelCase:Ga,noop:Ka,toFiniteNumber:Za,findKey:Vs,global:_t,isContextDefined:js,isSpecCompliantForm:Ya,toJSONObject:$a,isAsyncFn:Ja,isThenable:Ha,setImmediate:Xs,asap:Qa,isIterable:r=>r!=null&&Ne(r[Dn])};function re(r,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}V.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const qs=re.prototype,Ks={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Ks[r]={value:r}}),Object.defineProperties(re,Ks),Object.defineProperty(qs,"isAxiosError",{value:!0}),re.from=(r,e,t,n,i,s)=>{const o=Object.create(qs);V.toFlatObject(r,o,function(c){return c!==Error.prototype},h=>h!=="isAxiosError");const a=r&&r.message?r.message:"Error",l=e==null&&r?r.code:e;return re.call(o,a,l,t,n,i),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",s&&Object.assign(o,s),o};const el=null;function Ai(r){return V.isPlainObject(r)||V.isArray(r)}function Zs(r){return V.endsWith(r,"[]")?r.slice(0,-2):r}function Ys(r,e,t){return r?r.concat(e).map(function(i,s){return i=Zs(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function tl(r){return V.isArray(r)&&!r.some(Ai)}const nl=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)});function En(r,e,t){if(!V.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=V.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!V.isUndefined(g[m])});const n=t.metaTokens,i=t.visitor||c,s=t.dots,o=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(e);if(!V.isFunction(i))throw new TypeError("visitor must be a function");function h(d){if(d===null)return"";if(V.isDate(d))return d.toISOString();if(V.isBoolean(d))return d.toString();if(!l&&V.isBlob(d))throw new re("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(d)||V.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,m,g){let y=d;if(d&&!g&&typeof d=="object"){if(V.endsWith(m,"{}"))m=n?m:m.slice(0,-2),d=JSON.stringify(d);else if(V.isArray(d)&&tl(d)||(V.isFileList(d)||V.endsWith(m,"[]"))&&(y=V.toArray(d)))return m=Zs(m),y.forEach(function(b,x){!(V.isUndefined(b)||b===null)&&e.append(o===!0?Ys([m],x,s):o===null?m:m+"[]",h(b))}),!1}return Ai(d)?!0:(e.append(Ys(g,m,s),h(d)),!1)}const u=[],p=Object.assign(nl,{defaultVisitor:c,convertValue:h,isVisitable:Ai});function f(d,m){if(!V.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+m.join("."));u.push(d),V.forEach(d,function(y,w){(!(V.isUndefined(y)||y===null)&&i.call(e,y,V.isString(w)?w.trim():w,m,p))===!0&&f(y,m?m.concat(w):[w])}),u.pop()}}if(!V.isObject(r))throw new TypeError("data must be an object");return f(r),e}function $s(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Ti(r,e){this._pairs=[],r&&En(r,this,e)}const Js=Ti.prototype;Js.append=function(e,t){this._pairs.push([e,t])},Js.toString=function(e){const t=e?function(n){return e.call(this,n,$s)}:$s;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function il(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Hs(r,e,t){if(!e)return r;const n=t&&t.encode||il;V.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=V.isURLSearchParams(e)?e.toString():new Ti(e,t).toString(n),s){const o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Qs{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(n){n!==null&&e(n)})}}const er={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},sl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ti,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ci=typeof window<"u"&&typeof document<"u",Pi=typeof navigator=="object"&&navigator||void 0,rl=Ci&&(!Pi||["ReactNative","NativeScript","NS"].indexOf(Pi.product)<0),ol=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",al=Ci&&window.location.href||"http://localhost",De={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ci,hasStandardBrowserEnv:rl,hasStandardBrowserWebWorkerEnv:ol,navigator:Pi,origin:al},Symbol.toStringTag,{value:"Module"})),...sl};function ll(r,e){return En(r,new De.classes.URLSearchParams,{visitor:function(t,n,i,s){return De.isNode&&V.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function cl(r){return V.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function hl(r){const e={},t=Object.keys(r);let n;const i=t.length;let s;for(n=0;n<i;n++)s=t[n],e[s]=r[s];return e}function tr(r){function e(t,n,i,s){let o=t[s++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),l=s>=t.length;return o=!o&&V.isArray(i)?i.length:o,l?(V.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!V.isObject(i[o]))&&(i[o]=[]),e(t,n,i[o],s)&&V.isArray(i[o])&&(i[o]=hl(i[o])),!a)}if(V.isFormData(r)&&V.isFunction(r.entries)){const t={};return V.forEachEntry(r,(n,i)=>{e(cl(n),i,t,0)}),t}return null}function ul(r,e,t){if(V.isString(r))try{return(e||JSON.parse)(r),V.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}const sn={transitional:er,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=V.isObject(e);if(s&&V.isHTMLForm(e)&&(e=new FormData(e)),V.isFormData(e))return i?JSON.stringify(tr(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return ll(e,this.formSerializer).toString();if((a=V.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return En(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),ul(e)):e}],transformResponse:[function(e){const t=this.transitional||sn.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(n&&!this.responseType||i)){const o=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?re.from(a,re.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:De.classes.FormData,Blob:De.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],r=>{sn.headers[r]={}});const dl=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),fl=r=>{const e={};let t,n,i;return r&&r.split(`
754
- `).forEach(function(o){i=o.indexOf(":"),t=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!t||e[t]&&dl[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},nr=Symbol("internals");function rn(r){return r&&String(r).trim().toLowerCase()}function Ln(r){return r===!1||r==null?r:V.isArray(r)?r.map(Ln):String(r)}function pl(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}const ml=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function Di(r,e,t,n,i){if(V.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!V.isString(e)){if(V.isString(n))return e.indexOf(n)!==-1;if(V.isRegExp(n))return n.test(e)}}function gl(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function yl(r,e){const t=V.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(i,s,o){return this[n].call(this,e,i,s,o)},configurable:!0})})}let Re=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(a,l,h){const c=rn(l);if(!c)throw new Error("header name must be a non-empty string");const u=V.findKey(i,c);(!u||i[u]===void 0||h===!0||h===void 0&&i[u]!==!1)&&(i[u||l]=Ln(a))}const o=(a,l)=>V.forEach(a,(h,c)=>s(h,c,l));if(V.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(V.isString(e)&&(e=e.trim())&&!ml(e))o(fl(e),t);else if(V.isObject(e)&&V.isIterable(e)){let a={},l,h;for(const c of e){if(!V.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[h=c[0]]=(l=a[h])?V.isArray(l)?[...l,c[1]]:[l,c[1]]:c[1]}o(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=rn(e),e){const n=V.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return pl(i);if(V.isFunction(t))return t.call(this,i,n);if(V.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=rn(e),e){const n=V.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Di(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function s(o){if(o=rn(o),o){const a=V.findKey(n,o);a&&(!t||Di(n,n[a],a,t))&&(delete n[a],i=!0)}}return V.isArray(e)?e.forEach(s):s(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const s=t[n];(!e||Di(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return V.forEach(this,(i,s)=>{const o=V.findKey(n,s);if(o){t[o]=Ln(i),delete t[s];return}const a=e?gl(s):String(s).trim();a!==s&&delete t[s],t[a]=Ln(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return V.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&V.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
755
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[nr]=this[nr]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=rn(o);n[a]||(yl(i,o),n[a]=!0)}return V.isArray(e)?e.forEach(s):s(e),this}};Re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Re.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),V.freezeMethods(Re);function ki(r,e){const t=this||sn,n=e||t,i=Re.from(n.headers);let s=n.data;return V.forEach(r,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function ir(r){return!!(r&&r.__CANCEL__)}function Vt(r,e,t){re.call(this,r??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}V.inherits(Vt,re,{__CANCEL__:!0});function sr(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new re("Request failed with status code "+t.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function wl(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function bl(r,e){r=r||10;const t=new Array(r),n=new Array(r);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(l){const h=Date.now(),c=n[s];o||(o=h),t[i]=l,n[i]=h;let u=s,p=0;for(;u!==i;)p+=t[u++],u=u%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),h-o<e)return;const f=c&&h-c;return f?Math.round(p*1e3/f):void 0}}function xl(r,e){let t=0,n=1e3/e,i,s;const o=(h,c=Date.now())=>{t=c,i=null,s&&(clearTimeout(s),s=null),r(...h)};return[(...h)=>{const c=Date.now(),u=c-t;u>=n?o(h,c):(i=h,s||(s=setTimeout(()=>{s=null,o(i)},n-u)))},()=>i&&o(i)]}const On=(r,e,t=3)=>{let n=0;const i=bl(50,250);return xl(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,l=o-n,h=i(l),c=o<=a;n=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:h||void 0,estimated:h&&a&&c?(a-o)/h:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};r(u)},t)},rr=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},or=r=>(...e)=>V.asap(()=>r(...e)),_l=De.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,De.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(De.origin),De.navigator&&/(msie|trident)/i.test(De.navigator.userAgent)):()=>!0,vl=De.hasStandardBrowserEnv?{write(r,e,t,n,i,s,o){if(typeof document>"u")return;const a=[`${r}=${encodeURIComponent(e)}`];V.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),V.isString(n)&&a.push(`path=${n}`),V.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),V.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(r){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+r+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(r){this.write(r,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Ml(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Sl(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function ar(r,e,t){let n=!Ml(e);return r&&(n||t==!1)?Sl(r,e):e}const lr=r=>r instanceof Re?{...r}:r;function vt(r,e){e=e||{};const t={};function n(h,c,u,p){return V.isPlainObject(h)&&V.isPlainObject(c)?V.merge.call({caseless:p},h,c):V.isPlainObject(c)?V.merge({},c):V.isArray(c)?c.slice():c}function i(h,c,u,p){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h,u,p)}else return n(h,c,u,p)}function s(h,c){if(!V.isUndefined(c))return n(void 0,c)}function o(h,c){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h)}else return n(void 0,c)}function a(h,c,u){if(u in e)return n(h,c);if(u in r)return n(void 0,h)}const l={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(h,c,u)=>i(lr(h),lr(c),u,!0)};return V.forEach(Object.keys({...r,...e}),function(c){const u=l[c]||i,p=u(r[c],e[c],c);V.isUndefined(p)&&u!==a||(t[c]=p)}),t}const cr=r=>{const e=vt({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;if(e.headers=o=Re.from(o),e.url=Hs(ar(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(t)){if(De.hasStandardBrowserEnv||De.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(V.isFunction(t.getHeaders)){const l=t.getHeaders(),h=["content-type","content-length"];Object.entries(l).forEach(([c,u])=>{h.includes(c.toLowerCase())&&o.set(c,u)})}}if(De.hasStandardBrowserEnv&&(n&&V.isFunction(n)&&(n=n(e)),n||n!==!1&&_l(e.url))){const l=i&&s&&vl.read(s);l&&o.set(i,l)}return e},Al=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const i=cr(r);let s=i.data;const o=Re.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:h}=i,c,u,p,f,d;function m(){f&&f(),d&&d(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const b=Re.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),_={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:b,config:r,request:g};sr(function(P){t(P),m()},function(P){n(P),m()},_),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(n(new re("Request aborted",re.ECONNABORTED,r,g)),g=null)},g.onerror=function(x){const _=x&&x.message?x.message:"Network Error",D=new re(_,re.ERR_NETWORK,r,g);D.event=x||null,n(D),g=null},g.ontimeout=function(){let x=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const _=i.transitional||er;i.timeoutErrorMessage&&(x=i.timeoutErrorMessage),n(new re(x,_.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,r,g)),g=null},s===void 0&&o.setContentType(null),"setRequestHeader"in g&&V.forEach(o.toJSON(),function(x,_){g.setRequestHeader(_,x)}),V.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),h&&([p,d]=On(h,!0),g.addEventListener("progress",p)),l&&g.upload&&([u,f]=On(l),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",f)),(i.cancelToken||i.signal)&&(c=b=>{g&&(n(!b||b.type?new Vt(null,r,g):b),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const w=wl(i.url);if(w&&De.protocols.indexOf(w)===-1){n(new re("Unsupported protocol "+w+":",re.ERR_BAD_REQUEST,r));return}g.send(s||null)})},Tl=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,i;const s=function(h){if(!i){i=!0,a();const c=h instanceof Error?h:this.reason;n.abort(c instanceof re?c:new Vt(c instanceof Error?c.message:c))}};let o=e&&setTimeout(()=>{o=null,s(new re(`timeout ${e} of ms exceeded`,re.ETIMEDOUT))},e);const a=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),r=null)};r.forEach(h=>h.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>V.asap(a),l}},Cl=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let n=0,i;for(;n<t;)i=n+e,yield r.slice(n,i),n=i},Pl=async function*(r,e){for await(const t of Dl(r))yield*Cl(t,e)},Dl=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},hr=(r,e,t,n)=>{const i=Pl(r,e);let s=0,o,a=l=>{o||(o=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:h,value:c}=await i.next();if(h){a(),l.close();return}let u=c.byteLength;if(t){let p=s+=u;t(p)}l.enqueue(new Uint8Array(c))}catch(h){throw a(h),h}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},ur=64*1024,{isFunction:zn}=V,kl=(({Request:r,Response:e})=>({Request:r,Response:e}))(V.global),{ReadableStream:dr,TextEncoder:fr}=V.global,pr=(r,...e)=>{try{return!!r(...e)}catch{return!1}},Il=r=>{r=V.merge.call({skipUndefined:!0},kl,r);const{fetch:e,Request:t,Response:n}=r,i=e?zn(e):typeof fetch=="function",s=zn(t),o=zn(n);if(!i)return!1;const a=i&&zn(dr),l=i&&(typeof fr=="function"?(d=>m=>d.encode(m))(new fr):async d=>new Uint8Array(await new t(d).arrayBuffer())),h=s&&a&&pr(()=>{let d=!1;const m=new t(De.origin,{body:new dr,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!m}),c=o&&a&&pr(()=>V.isReadableStream(new n("").body)),u={stream:c&&(d=>d.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(m,g)=>{let y=m&&m[d];if(y)return y.call(m);throw new re(`Response type '${d}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const p=async d=>{if(d==null)return 0;if(V.isBlob(d))return d.size;if(V.isSpecCompliantForm(d))return(await new t(De.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(V.isArrayBufferView(d)||V.isArrayBuffer(d))return d.byteLength;if(V.isURLSearchParams(d)&&(d=d+""),V.isString(d))return(await l(d)).byteLength},f=async(d,m)=>{const g=V.toFiniteNumber(d.getContentLength());return g??p(m)};return async d=>{let{url:m,method:g,data:y,signal:w,cancelToken:b,timeout:x,onDownloadProgress:_,onUploadProgress:D,responseType:P,headers:k,withCredentials:C="same-origin",fetchOptions:I}=cr(d),O=e||fetch;P=P?(P+"").toLowerCase():"text";let A=Tl([w,b&&b.toAbortSignal()],x),E=null;const v=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let z;try{if(D&&h&&g!=="get"&&g!=="head"&&(z=await f(k,y))!==0){let F=new t(m,{method:"POST",body:y,duplex:"half"}),R;if(V.isFormData(y)&&(R=F.headers.get("content-type"))&&k.setContentType(R),F.body){const[ne,H]=rr(z,On(or(D)));y=hr(F.body,ur,ne,H)}}V.isString(C)||(C=C?"include":"omit");const Z=s&&"credentials"in t.prototype,W={...I,signal:A,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:Z?C:void 0};E=s&&new t(m,W);let Q=await(s?O(E,I):O(m,W));const G=c&&(P==="stream"||P==="response");if(c&&(_||G&&v)){const F={};["status","statusText","headers"].forEach(Y=>{F[Y]=Q[Y]});const R=V.toFiniteNumber(Q.headers.get("content-length")),[ne,H]=_&&rr(R,On(or(_),!0))||[];Q=new n(hr(Q.body,ur,ne,()=>{H&&H(),v&&v()}),F)}P=P||"text";let te=await u[V.findKey(u,P)||"text"](Q,d);return!G&&v&&v(),await new Promise((F,R)=>{sr(F,R,{data:te,headers:Re.from(Q.headers),status:Q.status,statusText:Q.statusText,config:d,request:E})})}catch(Z){throw v&&v(),Z&&Z.name==="TypeError"&&/Load failed|fetch/i.test(Z.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,d,E),{cause:Z.cause||Z}):re.from(Z,Z&&Z.code,d,E)}}},Bl=new Map,mr=r=>{let e=r&&r.env||{};const{fetch:t,Request:n,Response:i}=e,s=[n,i,t];let o=s.length,a=o,l,h,c=Bl;for(;a--;)l=s[a],h=c.get(l),h===void 0&&c.set(l,h=a?new Map:Il(e)),c=h;return h};mr();const Ii={http:el,xhr:Al,fetch:{get:mr}};V.forEach(Ii,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const gr=r=>`- ${r}`,El=r=>V.isFunction(r)||r===null||r===!1;function Ll(r,e){r=V.isArray(r)?r:[r];const{length:t}=r;let n,i;const s={};for(let o=0;o<t;o++){n=r[o];let a;if(i=n,!El(n)&&(i=Ii[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(V.isFunction(i)||(i=i.get(e))))break;s[a||"#"+o]=i}if(!i){const o=Object.entries(s).map(([l,h])=>`adapter ${l} `+(h===!1?"is not supported by the environment":"is not available in the build"));let a=t?o.length>1?`since :
756
- `+o.map(gr).join(`
757
- `):" "+gr(o[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const yr={getAdapter:Ll,adapters:Ii};function Bi(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Vt(null,r)}function wr(r){return Bi(r),r.headers=Re.from(r.headers),r.data=ki.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),yr.getAdapter(r.adapter||sn.adapter,r)(r).then(function(n){return Bi(r),n.data=ki.call(r,r.transformResponse,n),n.headers=Re.from(n.headers),n},function(n){return ir(n)||(Bi(r),n&&n.response&&(n.response.data=ki.call(r,r.transformResponse,n.response),n.response.headers=Re.from(n.response.headers))),Promise.reject(n)})}const br="1.13.2",Nn={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{Nn[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const xr={};Nn.transitional=function(e,t,n){function i(s,o){return"[Axios v"+br+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new re(i(o," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!xr[o]&&(xr[o]=!0,console.warn(i(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,o,a):!0}},Nn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Ol(r,e,t){if(typeof r!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=r[s],l=a===void 0||o(a,s,r);if(l!==!0)throw new re("option "+s+" must be "+l,re.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new re("Unknown option "+s,re.ERR_BAD_OPTION)}}const Rn={assertOptions:Ol,validators:Nn},He=Rn.validators;let Mt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Qs,response:new Qs}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
758
- `+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=vt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Rn.assertOptions(n,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),i!=null&&(V.isFunction(i)?t.paramsSerializer={serialize:i}:Rn.assertOptions(i,{encode:He.function,serialize:He.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Rn.assertOptions(t,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=s&&V.merge(s.common,s[t.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],d=>{delete s[d]}),t.headers=Re.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let c,u=0,p;if(!l){const d=[wr.bind(this),void 0];for(d.unshift(...a),d.push(...h),p=d.length,c=Promise.resolve(t);u<p;)c=c.then(d[u++],d[u++]);return c}p=a.length;let f=t;for(;u<p;){const d=a[u++],m=a[u++];try{f=d(f)}catch(g){m.call(this,g);break}}try{c=wr.call(this,f)}catch(d){return Promise.reject(d)}for(u=0,p=h.length;u<p;)c=c.then(h[u++],h[u++]);return c}getUri(e){e=vt(this.defaults,e);const t=ar(e.baseURL,e.url,e.allowAbsoluteUrls);return Hs(t,e.params,e.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(e){Mt.prototype[e]=function(t,n){return this.request(vt(n||{},{method:e,url:t,data:(n||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(n){return function(s,o,a){return this.request(vt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Mt.prototype[e]=t(),Mt.prototype[e+"Form"]=t(!0)});let zl=class Eo{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Vt(s,o,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Eo(function(i){e=i}),cancel:e}}};function Nl(r){return function(t){return r.apply(null,t)}}function Rl(r){return V.isObject(r)&&r.isAxiosError===!0}const Ei={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ei).forEach(([r,e])=>{Ei[e]=r});function _r(r){const e=new Mt(r),t=Ns(Mt.prototype.request,e);return V.extend(t,Mt.prototype,e,{allOwnKeys:!0}),V.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return _r(vt(r,i))},t}const ye=_r(sn);ye.Axios=Mt,ye.CanceledError=Vt,ye.CancelToken=zl,ye.isCancel=ir,ye.VERSION=br,ye.toFormData=En,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=Nl,ye.isAxiosError=Rl,ye.mergeConfig=vt,ye.AxiosHeaders=Re,ye.formToJSON=r=>tr(V.isHTMLForm(r)?new FormData(r):r),ye.getAdapter=yr.getAdapter,ye.HttpStatusCode=Ei,ye.default=ye;const{Axios:xd,AxiosError:_d,CanceledError:vd,isCancel:Md,CancelToken:Sd,VERSION:Ad,all:Td,Cancel:Cd,isAxiosError:Pd,spread:Dd,toFormData:kd,AxiosHeaders:Id,HttpStatusCode:Bd,formToJSON:Ed,getAdapter:Ld,mergeConfig:Od}=ye;function vr(r,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=r;t.open("GET",n,!0),t.send(null),t.onreadystatechange=function(){t.readyState==4&&t.status==200&&(t.responseText.includes("</html>",0)&&t.responseText.includes("</body>",0)&&t.responseText.includes("</head>",0)?e(null):e(t.responseText))},t.onloadend=function(){t.readyState==4&&t.status==404&&t.status==502&&e(null)}}}function Fl(r,e){ye({method:"get",responseType:"blob",url:r}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});zs.loadAsync(n).then(i=>{const s=new Map,o=[];for(let a in i.files){if(i.files[a].dir)continue;const l=i.file(i.files[a].name);if(l){const h=l.async("blob").then(c=>{const u=URL.createObjectURL(c);s.set("/"+i.files[a].name.replace("\\","/"),u)});o.push(h)}}Promise.all(o).then(()=>{e(s)}).catch(a=>{console.error("解压zip文件失败:",a),e(new Map)})}).catch(i=>{console.error("加载zip文件失败:",i),e(new Map)})}).catch(t=>{console.error("下载zip文件失败:",t),e(new Map)})}function Mr(r,e){ye({method:"get",responseType:"blob",url:r}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});zs.loadAsync(i).then(s=>{for(let o in s.files)s.file(s.files[o].name).async("blob").then(l=>{t(l,"utf-8",function(h,c){e(c)})})})});function t(n,i,s){var o=new FileReader,a=new Blob([n]);o.onload=function(l){s(null,l.target.result)},o.onerror=function(l){s(l.error,null)},o.readAsText(a,i)}}const Li=new WeakMap;class Ul extends S.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new S.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,S.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=S.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Li.has(e)){const l=Li.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((h,c)=>{i._callbacks[s]={resolve:h,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Li.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new S.BufferGeometry;e.index&&t.setIndex(new S.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:o,stride:a,vertexColorSpace:l}=e.attributes[n];let h;if(o===a)h=new S.BufferAttribute(s,o);else{const c=new S.InterleavedBuffer(s,a);h=new S.InterleavedBufferAttribute(c,o,0)}i==="color"&&(this._assignVertexColorSpace(h,l),h.normalized=!(s instanceof Float32Array)),t.setAttribute(i,h)}return t}_assignVertexColorSpace(e,t){if(t!==S.SRGBColorSpace)return;const n=new S.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),S.ColorManagement.colorSpaceToWorking(n,S.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new S.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=Vl.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
759
- `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Vl(){let r,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(c){r.onModuleLoaded=function(u){c({draco:u})},DracoDecoderModule(r)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const u=c.draco,p=new u.Decoder;try{const f=t(u,p,new Int8Array(l),h),d=f.attributes.map(m=>m.array.buffer);f.index&&d.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},d)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{u.destroy(p)}});break}};function t(o,a,l,h){const c=h.attributeIDs,u=h.attributeTypes;let p,f;const d=a.GetEncodedGeometryType(l);if(d===o.TRIANGULAR_MESH)p=new o.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,p);else if(d===o.POINT_CLOUD)p=new o.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const m={index:null,attributes:[]};for(const g in c){const y=self[u[g]];let w,b;if(h.useUniqueIDs)b=c[g],w=a.GetAttributeByUniqueId(p,b);else{if(b=a.GetAttributeId(p,o[c[g]]),b===-1)continue;w=a.GetAttribute(p,b)}const x=i(o,a,p,g,y,w);g==="color"&&(x.vertexColorSpace=h.vertexColorSpace),m.attributes.push(x)}return d===o.TRIANGULAR_MESH&&(m.index=n(o,a,p)),o.destroy(p),m}function n(o,a,l){const c=l.num_faces()*3,u=c*4,p=o._malloc(u);a.GetTrianglesUInt32Array(l,u,p);const f=new Uint32Array(o.HEAPF32.buffer,p,c).slice();return o._free(p),{array:f,itemSize:1}}function i(o,a,l,h,c,u){const p=l.num_points(),f=u.num_components(),d=s(o,c),m=f*c.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,y=g/c.BYTES_PER_ELEMENT,w=p*m,b=p*g,x=o._malloc(w);a.GetAttributeDataArrayForAllPoints(l,u,d,w,x);const _=new c(o.HEAPF32.buffer,x,w/c.BYTES_PER_ELEMENT);let D;if(m===g)D=_.slice();else{D=new c(b/c.BYTES_PER_ELEMENT);let P=0;for(let k=0,C=_.length;k<C;k++){for(let I=0;I<f;I++)D[P+I]=_[k*f+I];P+=y}}return o._free(x),{name:h,count:p,itemSize:f,array:D,stride:y}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var jt=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.ViewportResize="viewport-resize",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.SectionMove="section-move",r))(jt||{});function jl(r,e,t,n){let i=0,s=0,o=0,a=r.models.find(f=>f.url==t),l=e.circularMeps,h=e.rectMeps.filter(f=>f.type==="风管"),c=e.rectMeps.filter(f=>f.type==="桥架"),u=e.ellipseMeps,p=r.scene;if(new T.MeshBasicMaterial,new T.BufferGeometry,l&&l.length){let f=[],d=0;for(let m of l)m.color=new T.Color(`rgb(${m.color})`),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Fn("Circle",p,f,t)}if(h&&h.length){let f=[],d=0;for(let m of h)m.color=new T.Color(`rgb(${m.color})`),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Fn("Rect",p,f,t)}if(u&&u.length){let f=[],d=0;for(let m of u)m.color=new T.Color(`rgb(${m.color})`),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Fn("Ellipse",p,f,t)}if(c&&c.length){let f=[],d=0;for(let m of c)m.color=new T.Color(`rgb(${m.color})`),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Fn("Bridge",p,f,t)}}function Fn(r,e,t,n,i){let s,o,a={width:1,height:1,length:1,diameter:1,color:new T.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":o=Un("Rect",a);break;case"Bridge":o=Un("Bridge",a);break;case"Circle":o=Un("Circle",a);break;case"Ellipse":o=Un("Ellipse",a);break}o&&(s=new T.InstancedMesh(o.geometry,o.material,t.length),s.url=n,e.add(s));let l=[];for(var h=0;h<t.length;h++){let p=t[h],f=new T.Vector3(p.startPoint.X,0,-p.startPoint.Y),d=new T.Vector3(p.endPoint.X,0,-p.endPoint.Y),m=new T.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),g=new T.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),y=0,w=0,b=0;if(Math.abs(d.clone().sub(f.clone()).z)<.01&&Math.abs(d.clone().sub(f.clone()).x)<.01){if(y=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var c=new T.Vector3(p.base_x.X,0,-p.base_x.Y);w=(c.clone().cross(new T.Vector3(0,0,1)).y<=0?1:-1)*c.angleTo(new T.Vector3(0,0,1))+Math.PI*.5}}else w=(d.clone().sub(f.clone()).cross(new T.Vector3(0,0,1)).y>0?-1:1)*d.clone().sub(f.clone()).angleTo(new T.Vector3(0,0,1)),y=(p.startPoint.Z>p.endPoint.Z?1:-1)*d.clone().sub(f.clone()).angleTo(g.clone().sub(m.clone()));let x=new T.Matrix4;const _=new T.Euler(y,w,b,"YXZ");let D=x.clone().makeRotationFromEuler(_),P,k;r==="Circle"?(P=p.diameter,k=p.diameter):(P=p.width,k=p.height);let C=x.clone().makeScale(P,k,p.length);x.multiplyMatrices(D,C),x.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(h,x.clone()),s.setColorAt(h,p.color),s.geometry.computeBoundingBox();let I=s.geometry.boundingBox.min.clone().applyMatrix4(x.clone()),O=s.geometry.boundingBox.max.clone().applyMatrix4(x.clone()),A=new T.Vector3(Math.min(I.x,O.x),Math.min(I.y,O.y),Math.min(I.z,O.z)),E=new T.Vector3(Math.max(I.x,O.x),Math.max(I.y,O.y),Math.max(I.z,O.z)),v=A.clone().add(E.clone()).multiplyScalar(.5),z={name:p.name,min:A,max:E,center:v,dbid:h,materialName:o.material.name},Z=null,W=null;r==="Circle"&&(Z={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},W={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},z.minC=Z,z.maxC=W),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(x.clone()),s.ids.push(Number(p.id)),l.push(z)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=r,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone();let u=[];u={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=u,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Un(r,e,t){let n=new T.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,r){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return s(n,i,e.color,e.position,e.rotation);function s(o,a,l,h,c){let u=new T.ExtrudeGeometry(o,a),p=new T.MeshPhongMaterial({color:l,side:T.DoubleSide}),f=new T.Mesh(u,p);return f.position.set(h.x,h.y,h.z),f.rotation._order="YXZ",f.rotation.set(c.x,c.y,c.z),f}}function Sr(r,e=!1){const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new S.BufferGeometry;let h=0;for(let c=0;c<r.length;++c){const u=r[c];let p=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(u.attributes[f]),p++}if(p!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(u.morphAttributes[f])}if(e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,f,c),h+=f}}if(t){let c=0;const u=[];for(let p=0;p<r.length;++p){const f=r[p].index;for(let d=0;d<f.count;++d)u.push(f.getX(d)+c);c+=r[p].attributes.position.count}l.setIndex(u)}for(const c in s){const u=Ar(s[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(const c in o){const u=o[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let p=0;p<u;++p){const f=[];for(let m=0;m<o[c].length;++m)f.push(o[c][m][p]);const d=Ar(f);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(d)}}return l}function Ar(r){let e,t,n,i=-1,s=0;for(let h=0;h<r.length;++h){const c=r[h];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=c.gpuType),i!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*t}const o=new e(s),a=new S.BufferAttribute(o,t,n);let l=0;for(let h=0;h<r.length;++h){const c=r[h];if(c.isInterleavedBufferAttribute){const u=l/t;for(let p=0,f=c.count;p<f;p++)for(let d=0;d<t;d++){const m=c.getComponent(p,d);a.setComponent(p+u,d,m)}}else o.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Tr(r,e){if(e===S.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===S.TriangleFanDrawMode||e===S.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===S.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class Gl extends S.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Zl(t)}),this.register(function(t){return new Yl(t)}),this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new Jl(t)}),this.register(function(t){return new Hl(t)}),this.register(function(t){return new Ql(t)}),this.register(function(t){return new ec(t)}),this.register(function(t){return new Kl(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new $l(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new nc(t)}),this.register(function(t){return new Xl(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new lc(t)})}load(e,t,n,i){const s=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const h=S.LoaderUtils.extractUrlBase(e);o=S.LoaderUtils.resolveURL(h,this.path)}else o=S.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){i?i(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},l=new S.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{s.parse(h,o,function(c){t(c),s.manager.itemEnd(e)},a)}catch(c){a(c)}},n,a)}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,i){let s;const o={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Cr){try{o[le.KHR_BINARY_GLTF]=new cc(e)}catch(u){i&&i(u);return}s=JSON.parse(o[le.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new vc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const u=this.pluginCallbacks[c](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const u=s.extensionsUsed[c],p=s.extensionsRequired||[];switch(u){case le.KHR_MATERIALS_UNLIT:o[u]=new ql;break;case le.KHR_DRACO_MESH_COMPRESSION:o[u]=new hc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:o[u]=new uc;break;case le.KHR_MESH_QUANTIZATION:o[u]=new dc;break;default:p.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}h.setExtensions(o),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function Wl(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const le={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Xl{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const c=new S.Color(16777215);l.color!==void 0&&c.setRGB(l.color[0],l.color[1],l.color[2],S.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new S.DirectionalLight(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new S.PointLight(c),h.distance=u;break;case"spot":h=new S.SpotLight(c),h.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Qe(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class ql{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return S.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new S.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],S.LinearSRGBColorSpace),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,S.SRGBColorSpace))}return Promise.all(i)}}class Kl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Zl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new S.Vector2(a,a)}return Promise.all(s)}}class Yl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class $l{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}}class Jl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new S.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,S.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class Hl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class Ql{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),Promise.all(s)}}class ec{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class tc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,S.SRGBColorSpace)),Promise.all(s)}}class nc{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}}class ic{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}}class sc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class rc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,o.source,l)}}class oc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,o.source,l)}}class ac{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,h=i.byteLength||0,c=i.count,u=i.byteStride,p=new Uint8Array(a,l,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(c,u,p,i.mode,i.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(c*u);return o.decodeGltfBuffer(new Uint8Array(f),c,u,p,i.mode,i.filter),f})})}else return null}}class lc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Ue.TRIANGLES&&h.mode!==Ue.TRIANGLE_STRIP&&h.mode!==Ue.TRIANGLE_FAN&&h.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const h in o)a.push(this.parser.getDependency("accessor",o[h]).then(c=>(l[h]=c,l[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const c=h.pop(),u=c.isGroup?c.children:[c],p=h[0].count,f=[];for(const d of u){const m=new S.Matrix4,g=new S.Vector3,y=new S.Quaternion,w=new S.Vector3(1,1,1),b=new S.InstancedMesh(d.geometry,d.material,p);for(let x=0;x<p;x++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,x),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,x),l.SCALE&&w.fromBufferAttribute(l.SCALE,x),b.setMatrixAt(x,m.compose(g,y,w));for(const x in l)if(x==="_COLOR_0"){const _=l[x];b.instanceColor=new S.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&d.geometry.setAttribute(x,l[x]);S.Object3D.prototype.copy.call(b,d),this.parser.assignFinalMaterial(b),f.push(b)}return c.isGroup?(c.clear(),c.add(...f),c):f[0]}))}}const Cr="glTF",on=12,Pr={JSON:1313821514,BIN:5130562};class cc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,on),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!==Cr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-on,s=new DataView(e,on);let o=0;for(;o<i;){const a=s.getUint32(o,!0);o+=4;const l=s.getUint32(o,!0);if(o+=4,l===Pr.JSON){const h=new Uint8Array(e,on+o,a);this.content=n.decode(h)}else if(l===Pr.BIN){const h=on+o;this.body=e.slice(h,h+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class hc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},h={};for(const c in o){const u=zi[c]||c.toLowerCase();a[u]=o[c]}for(const c in e.attributes){const u=zi[c]||c.toLowerCase();if(o[c]!==void 0){const p=n.accessors[e.attributes[c]],f=Gt[p.componentType];h[u]=f.name,l[u]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(u,p){i.decodeDracoFile(c,function(f){for(const d in f.attributes){const m=f.attributes[d],g=l[d];g!==void 0&&(m.normalized=g)}u(f)},a,h,S.LinearSRGBColorSpace,p)})})}}class uc{constructor(){this.name=le.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.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}}class dc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Dr extends S.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,h=a*3,c=i-t,u=(n-t)/c,p=u*u,f=p*u,d=e*h,m=d-h,g=-2*f+3*p,y=f-p,w=1-g,b=y-p+u;for(let x=0;x!==a;x++){const _=o[m+x+a],D=o[m+x+l]*c,P=o[d+x+a],k=o[d+x]*c;s[x]=w*_+b*D+g*P+y*k}return s}}const fc=new S.Quaternion;class pc extends Dr{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return fc.fromArray(s).normalize().toArray(s),s}}const Ue={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Gt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kr={9728:S.NearestFilter,9729:S.LinearFilter,9984:S.NearestMipmapNearestFilter,9985:S.LinearMipmapNearestFilter,9986:S.NearestMipmapLinearFilter,9987:S.LinearMipmapLinearFilter},Ir={33071:S.ClampToEdgeWrapping,33648:S.MirroredRepeatWrapping,10497:S.RepeatWrapping},Oi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zi={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"},ht={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},mc={CUBICSPLINE:void 0,LINEAR:S.InterpolateLinear,STEP:S.InterpolateDiscrete},Ni={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function gc(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new S.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:S.FrontSide})),r.DefaultMaterial}function St(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function yc(r,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const u=e[h];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const o=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const u=e[h];if(n){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;o.push(p)}if(i){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;a.push(p)}if(s){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;l.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],u=h[1],p=h[2];return n&&(r.morphAttributes.position=c),i&&(r.morphAttributes.normal=u),s&&(r.morphAttributes.color=p),r.morphTargetsRelative=!0,r})}function wc(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function bc(r){let e;const t=r.extensions&&r.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ri(t.attributes):e=r.indices+":"+Ri(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Ri(r.targets[n]);return e}function Ri(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Fi(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function xc(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const _c=new S.Matrix4;class vc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Wl,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,i=-1,s=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&o<98?this.textureLoader=new S.TextureLoader(this.options.manager):this.textureLoader=new S.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new S.FileLoader(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){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return St(s,a,i),Qe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.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;const i=n.clone(),s=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[h,c]of o.children.entries())s(c,a.children[h])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[le.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){n.load(S.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Oi[i.type],a=Gt[i.componentType],l=i.normalized===!0,h=new a(i.count*o);return Promise.resolve(new S.BufferAttribute(h,o,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],l=Oi[i.type],h=Gt[i.componentType],c=h.BYTES_PER_ELEMENT,u=c*l,p=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0;let m,g;if(f&&f!==u){const y=Math.floor(p/f),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let b=t.cache.get(w);b||(m=new h(a,y*f,i.count*f/c),b=new S.InterleavedBuffer(m,f/c),t.cache.add(w,b)),g=new S.InterleavedBufferAttribute(b,l,p%f/c,d)}else a===null?m=new h(i.count*l):m=new h(a,p,i.count*l),g=new S.BufferAttribute(m,l,d);if(i.sparse!==void 0){const y=Oi.SCALAR,w=Gt[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,_=new w(o[1],b,i.sparse.count*y),D=new h(o[2],x,i.sparse.count*l);a!==null&&(g=new S.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=_.length;P<k;P++){const C=_[P];if(g.setX(C,D[P*l]),l>=2&&g.setY(C,D[P*l+1]),l>=3&&g.setZ(C,D[P*l+2]),l>=4&&g.setW(C,D[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=d}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,n).then(function(c){c.flipY=!1,c.name=o.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const p=(s.samplers||{})[o.sampler]||{};return c.magFilter=kr[p.magFilter]||S.LinearFilter,c.minFilter=kr[p.minFilter]||S.LinearMipmapLinearFilter,c.wrapS=Ir[p.wrapS]||S.RepeatWrapping,c.wrapT=Ir[p.wrapT]||S.RepeatWrapping,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==S.NearestFilter&&c.minFilter!==S.LinearFilter,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",h=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){h=!0;const p=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(p),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(l).then(function(u){return new Promise(function(p,f){let d=p;t.isImageBitmapLoader===!0&&(d=function(m){const g=new S.Texture(m);g.needsUpdate=!0,p(g)}),t.load(S.LoaderUtils.resolveURL(u,s.path),d,void 0,f)})}).then(function(u){return h===!0&&a.revokeObjectURL(l),Qe(u,o),u.userData.mimeType=o.mimeType||xc(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.PointsMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.LineBasicMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return S.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},h=[];if(l[le.KHR_MATERIALS_UNLIT]){const u=i[le.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),h.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new S.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],S.LinearSRGBColorSpace),a.opacity=p[3]}u.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",u.baseColorTexture,S.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=S.DoubleSide);const c=s.alphaMode||Ni.OPAQUE;if(c===Ni.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Ni.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new S.Vector2(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==S.MeshBasicMaterial){const u=s.emissiveFactor;a.emissive=new S.Color().setRGB(u[0],u[1],u[2],S.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&o!==S.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,S.SRGBColorSpace)),Promise.all(h).then(function(){const u=new o(a);return s.name&&(u.name=s.name),Qe(u,s),t.associations.set(u,{materials:e}),s.extensions&&St(i,u,s),u})}createUniqueName(e){const t=S.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Br(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=bc(h),u=i[c];if(u)o.push(u.promise);else{let p;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?p=s(h):p=Br(new S.BufferGeometry,h,t),i[c]={primitive:h,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let l=0,h=o.length;l<h;l++){const c=o[l].material===void 0?gc(this.cache):this.getDependency("material",o[l].material);a.push(c)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const h=l.slice(0,l.length-1),c=l[l.length-1],u=[];for(let f=0,d=c.length;f<d;f++){const m=c[f],g=o[f];let y;const w=h[f];if(g.mode===Ue.TRIANGLES||g.mode===Ue.TRIANGLE_STRIP||g.mode===Ue.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new S.SkinnedMesh(m,w):new S.Mesh(m,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ue.TRIANGLE_STRIP?y.geometry=Tr(y.geometry,S.TriangleStripDrawMode):g.mode===Ue.TRIANGLE_FAN&&(y.geometry=Tr(y.geometry,S.TriangleFanDrawMode));else if(g.mode===Ue.LINES)y=new S.LineSegments(m,w);else if(g.mode===Ue.LINE_STRIP)y=new S.Line(m,w);else if(g.mode===Ue.LINE_LOOP)y=new S.LineLoop(m,w);else if(g.mode===Ue.POINTS)y=new S.Points(m,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&wc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&St(i,y,g),t.assignFinalMaterial(y),u.push(y)}for(let f=0,d=u.length;f<d;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return s.extensions&&St(i,u[0],s),u[0];const p=new S.Group;s.extensions&&St(i,p,s),t.associations.set(p,{meshes:e});for(let f=0,d=u.length;f<d;f++)p.add(u[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new S.PerspectiveCamera(S.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new S.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Qe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),o=i,a=[],l=[];for(let h=0,c=o.length;h<c;h++){const u=o[h];if(u){a.push(u);const p=new S.Matrix4;s!==null&&p.fromArray(s.array,h*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new S.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,o=[],a=[],l=[],h=[],c=[];for(let u=0,p=i.channels.length;u<p;u++){const f=i.channels[u],d=i.samplers[f.sampler],m=f.target,g=m.node,y=i.parameters!==void 0?i.parameters[d.input]:d.input,w=i.parameters!==void 0?i.parameters[d.output]:d.output;m.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(d),c.push(m))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(u){const p=u[0],f=u[1],d=u[2],m=u[3],g=u[4],y=[];for(let b=0,x=p.length;b<x;b++){const _=p[b],D=f[b],P=d[b],k=m[b],C=g[b];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const I=n._createAnimationTracks(_,D,P,k,C);if(I)for(let O=0;O<I.length;O++)y.push(I[O])}const w=new S.AnimationClip(s,void 0,y);return Qe(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const o=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,h=i.weights.length;l<h;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=i.children||[];for(let h=0,c=a.length;h<c;h++)o.push(n.getDependency("node",a[h]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(o),l]).then(function(h){const c=h[0],u=h[1],p=h[2];p!==null&&c.traverse(function(f){f.isSkinnedMesh&&f.bind(p,_c)});for(let f=0,d=u.length;f<d;f++)c.add(u[f]);return c})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],o=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(h){return i._getNodeRef(i.cameraCache,s.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let c;if(s.isBone===!0?c=new S.Bone:h.length>1?c=new S.Group:h.length===1?c=h[0]:c=new S.Object3D,c!==h[0])for(let u=0,p=h.length;u<p;u++)c.add(h[u]);if(s.name&&(c.userData.name=s.name,c.name=o),Qe(c,s),s.extensions&&St(n,c,s),s.matrix!==void 0){const u=new S.Matrix4;u.fromArray(s.matrix),c.applyMatrix4(u)}else s.translation!==void 0&&c.position.fromArray(s.translation),s.rotation!==void 0&&c.quaternion.fromArray(s.rotation),s.scale!==void 0&&c.scale.fromArray(s.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(c);i.associations.set(c,{...u})}return i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new S.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&St(t,s,n);const o=n.nodes||[],a=[];for(let l=0,h=o.length;l<h;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let c=0,u=l.length;c<u;c++)s.add(l[c]);const h=c=>{const u=new Map;for(const[p,f]of i.associations)(p instanceof S.Material||p instanceof S.Texture)&&u.set(p,f);return c.traverse(p=>{const f=i.associations.get(p);f!=null&&u.set(p,f)}),u};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];ht[s.path]===ht.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let h;switch(ht[s.path]){case ht.weights:h=S.NumberKeyframeTrack;break;case ht.rotation:h=S.QuaternionKeyframeTrack;break;case ht.translation:case ht.scale:h=S.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=S.NumberKeyframeTrack;break;case 2:case 3:default:h=S.VectorKeyframeTrack;break}break}const c=i.interpolation!==void 0?mc[i.interpolation]:S.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let p=0,f=l.length;p<f;p++){const d=new h(l[p]+"."+ht[s.path],t.array,u,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(d),o.push(d)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Fi(t.constructor),i=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof S.QuaternionKeyframeTrack?pc:Dr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Mc(r,e,t){const n=e.attributes,i=new S.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(i.set(new S.Vector3(l[0],l[1],l[2]),new S.Vector3(h[0],h[1],h[2])),a.normalized){const c=Fi(Gt[a.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new S.Vector3,l=new S.Vector3;for(let h=0,c=s.length;h<c;h++){const u=s[h];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,d=p.max;if(f!==void 0&&d!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(d[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(d[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(d[2]))),p.normalized){const m=Fi(Gt[p.componentType]);l.multiplyScalar(m)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}r.boundingBox=i;const o=new S.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=o}function Br(r,e,t){const n=e.attributes,i=[];function s(o,a){return t.getDependency("accessor",o).then(function(l){r.setAttribute(a,l)})}for(const o in n){const a=zi[o]||o.toLowerCase();a in r.attributes||i.push(s(n[o],a))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(o)}return S.ColorManagement.workingColorSpace!==S.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${S.ColorManagement.workingColorSpace}" not supported.`),Qe(r,e),Mc(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?yc(r,e.targets,t):r})}function Sc(r,e,t){let n=new T.Group;n.name=e,r.scene.add(n),Mr(e+"/info",i=>{let s=JSON.parse(i);r.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),r.models==null&&(r.models=[]),r.models.push({url:e,nodesMap:new Map,boundingBox:{min:new T.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new T.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),r.events.trigger(jt.EngineFree,null)})}function Ac(r){r.engineStatus.models.forEach(e=>{e.loadStatus==null&&(e.loadStatus={mep:!1,instance:!1,normal:!1}),e.status==="loading"&&e.type==="light"&&(e.loadStatus.modelMep!=!0&&(e.loadStatus.modelMep=!0,jl(r,e.info.modelMep,e.url)),e.loadStatus.normal!=!0&&Tc(r,e))})}function Tc(r,e){if(r.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(i=>{if(i.status!=!0)if(i.glbs==null)console.log("加载GLB............."),i.glbs={},Fl(e.url+i.path,s=>{vr(s.get("/nodes.json"),o=>{let a=JSON.parse(o);r.models.find(c=>c.url==e.url).nodesMap==null&&(r.models.find(c=>c.url==e.url).nodesMap=new Map);let l=r.models.find(c=>c.url==e.url).nodesMap,h=0;for(let c in a){a[c].forEach(f=>{f.glb=c,l.has(f.id)==!1?l.set(f.id,{infos:[f]}):l.get(f.id).infos.push(f)});let u=new Gl;const p=new Ul;p.setDecoderPath("/draco/"),p.preload(),u.setDRACOLoader(p),u.load(s.get(c+".glb"),f=>{i.glbs[c]=f.scene.children,h++,h==Object.keys(a).length&&r.engineStatus.isFree&&(r.events.trigger(jt.EngineFree,null),r.viewCube.CameraGoHome())})}vr(s.get("/instances.json"),c=>{let u=JSON.parse(c);r.models.find(p=>p.url==e.url).instanceNodes=u})})});else{console.log("加载模型.............");let s=n(e,i,i.octreeBox),o=[],a=r.models.find(h=>h.url==e.url);s.forEach(h=>{a.nodesMap.has(h)&&a.nodesMap.get(h).infos.forEach(c=>{let u=i.glbs[c.glb][c.mesh];if(u!=null&&u.geometry!=null&&u.material!=null){let p=new T.Matrix4;p.elements=c.matrix;let f=new T.Mesh(u.geometry.clone().applyMatrix4(p),u.material),d=new T.Box3().setFromObject(f);c.box=d,c.mesh=f,f.name=h,f.glb=c.glb,f.url=e.url,o.push(f)}})}),console.log("加载模型数量",o.length),Cc(e.url,r,o);let l=a.instanceNodes;for(let h in l)(l[h].isLoaded==null||l[h].isLoaded==!1)&&(l[h].isLoaded=!0,l[h].forEach(c=>{let u=i.glbs[h][c.mesh];Pc(e.url,c.mesh,r,u,c.children)}))}});function n(i,s,o){let a=[];if(o.status!=!0){if(!r.engineStatus.isFree)return a;let l=new T.Vector3(o.min.X,o.min.Z,-o.min.Y),h=new T.Vector3(o.max.X,o.max.Z,-o.max.Y);h.distanceTo(l);let c=r.camera.position,u=new T.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(u),o.elements.forEach(p=>{a.push(p)}),o.children.forEach(p=>{a.push(...n(i,s,p))}),o.children.findIndex(p=>p.status!=!0)==-1&&(o.status=!0),o.children.length==0&&(o.status=!0)}return a}}function Cc(r,e,t){let n=[];t.forEach(i=>{n.findIndex(o=>o.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(o=>o.glb==i.glb).meshes.push(i),n.find(o=>o.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(o=>o.glb==i.glb);s.indexes.set(Number(i.name),[s.currentIndex-i.geometry.index.count,s.currentIndex])}),n.forEach(i=>{let s=e.scene.children.find(o=>o instanceof T.Mesh&&o.url==r&&o.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let o=new T.BufferGeometry,a=Dc(i.meshes[0].material);o=Sr(i.meshes.map(c=>c.geometry),!1);let l=new T.Mesh(o,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=r,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(c=>c.geometry);let h=e.models.find(c=>c.url==r);if(h!=null){let c=0;i.indexes.forEach(u=>{h.nodesMap.get(Number(i.meshes[c].name)).indexes==null&&(h.nodesMap.get(Number(i.meshes[c].name)).indexes=[]),h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index,c++,u[0],u[1]])})}}})}function Pc(r,e,t,n,i){let s=new T.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const o=new Float32Array(i.length*3);for(let a=0;a<i.length;a++)o[a*3]=1,o[a*3+1]=1,o[a*3+2]=1;s.instanceColor=new T.InstancedBufferAttribute(o,3);for(let a=0;a<i.length;a++){let l=i[a],h=new T.Matrix4;h.elements=l.matrix,s.setMatrixAt(a,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),t.models.find(c=>c.url==r).nodesMap.has(l.id)?t.models.find(c=>c.url==r).nodesMap.get(l.id).indexes.push([t.scene.children.length-1,a,0,0]):t.models.find(c=>c.url==r).nodesMap.set(l.id,{instance:!0,info:l,indexes:[[t.scene.children.length-1,a,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=r,s.glb=n.glb,s.ids=i.map(a=>a.id)}function Dc(r){return r.map!=null&&(r.map.colorSpace=T.SRGBColorSpace,r.map.needsUpdate=!0),r.shadowSide=T.FrontSide,r.side=r.side,r}class kc{engine;constructor(e){this.engine=e}async loadModels(e,t){for(const i of e)n(i)==="light"&&Sc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class Ic{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(jt.EngineFree,()=>{this.updateFree(!0),console.log("引擎空闲"),Ac(this.engine)}),this.engine.events.on(jt.EngineBusy,()=>{this.updateFree(!1),console.log("引擎繁忙")})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Bc{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,o)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}}class Ec{engine;constructor(e){this.engine=e}init(){const e=new T.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new T.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new T.AmbientLight(16777215,1);this.engine.scene.add(i)}}var ve=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r))(ve||{});class Lc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new T.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}handleMouseClick(e){let t=this.handleMouseClickInstance(e.raycaster);if(t.length>0&&(e.catch==null||t[0].distance<e.catch.distance)){this.engine.controlModule.orbitControls.origin.set(t[0].point.x,t[0].point.y,t[0].point.z),this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels();let n=t[0].object;this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.ids[t[0].instanceId]]}])}else if(e.catch!=null&&(t.length==0||t[0].distance>e.catch.distance)){const n=e.catch;n.object,this.engine.events.trigger(ve.Click,n);let i=n.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:i.url,ids:[i.name]}]),this.engine.controlModule.orbitControls.origin.set(n.point.x,n.point.y,n.point.z),this.engine.modelToolModule.highlightModel([{url:i.url,ids:[i.name]}])}e.catch==null&&t.length==0&&this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object,this.engine.events.trigger(ve.Click,n);let i=n.object,a=this.engine.models.find(h=>h.url===i.url).nodesMap.get(i.name).infos.map(h=>h.box),l=t(a);this.engine.viewCube.zoomToModel(l)}function t(n){let i=new T.Vector3(1e8,1e9,1e10),s=new T.Vector3(-1e8,-1e9,-1e10);return n.forEach(o=>{o.min.x<i.x&&(i.x=o.min.x),o.min.y<i.y&&(i.y=o.min.y),o.min.z<i.z&&(i.z=o.min.z),o.max.x>s.x&&(s.x=o.max.x),o.max.y>s.y&&(s.y=o.max.y),o.max.z>s.z&&(s.z=o.max.z)}),new T.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof T.InstancedMesh),!0)}}class Oc{engine;highlightMaterial;hideMaterial;translucentMaterial;cloneModels=new Map;clonetranslucentModels=new Map;constructor(e){this.engine=e,this.highlightMaterial=new T.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:T.DoubleSide}),this.hideMaterial=new T.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:T.DoubleSide}),this.translucentMaterial=new T.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:T.DoubleSide})}split_merge_model(e){if(e.isSplit||e instanceof T.InstancedMesh)return;let t=e.materialClone.clone(),n=Sr(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s?.indexes.forEach(o=>{this.engine.scene.children[o[0]]instanceof T.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(console.log(this.engine.scene.children[o[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[o[0]]),this.engine.scene.children[o[0]].geometry.groups[o[1]].materialIndex=1)})}),zc(n,this.engine,this.cloneModels),this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s?.indexes.forEach(o=>{this.engine.scene.children[o[0]]instanceof T.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.engine.scene.children[o[0]].geometry.groups[o[1]].materialIndex=0})}),Er(n,this.engine,this.cloneModels)})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),o.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof T.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Rc(n,this.engine,this.cloneModels);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),o.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof T.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Lr(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const o=i.ids.indexOf(s);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(o=>o.url==n.url);for(let o of n.nodesMap)s==null?i.ids.push(o[0]):s.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(o=>o.url==n.url);for(let o of n.nodesMap)s==null?i.ids.push(o[0]):s.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.unhighlightAllModels(),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightModel(e),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);o&&o.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof T.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=2)})}),Nc(n,this.engine,this.clonetranslucentModels);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s&&s.indexes.forEach(o=>{const a=this.engine.scene.children[o[0]];a instanceof T.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.engine.scene.children[o[0]]),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&Lr(n,this.engine),Er(n,this.engine,this.clonetranslucentModels)}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function zc(r,e,t){r.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof T.InstancedMesh))return;const o=s.geometry,a=new T.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:T.DoubleSide}),l=new T.InstancedMesh(o,a,n.length);l.name="highlightModel";const h=new Map,c=new T.Matrix4,u=new T.Matrix4;u.makeScale(0,0,0),n.forEach((p,f)=>{s.getMatrixAt(p,c),h.set(p,c.clone()),s.setMatrixAt(p,u),l.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Er(r,e,t){r.forEach((n,i)=>{const s=t.get(i);if(!s)return;const o=e.scene.children[i];o instanceof T.InstancedMesh&&(n.forEach(a=>{const l=s.originalMatrices.get(a);l&&o.setMatrixAt(a,l)}),o.instanceMatrix.needsUpdate=!0,s.cloneModel.parent&&s.cloneModel.parent.remove(s.cloneModel),s.cloneModel.geometry,s.cloneModel.material&&(Array.isArray(s.cloneModel.material)?s.cloneModel.material.forEach(a=>a.dispose()):s.cloneModel.material.dispose()),t.delete(i))})}function Nc(r,e,t){r.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof T.InstancedMesh))return;const o=s.geometry,a=new T.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:T.DoubleSide}),l=new T.InstancedMesh(o,a,n.length);l.name="translucentModel";const h=new Map,c=new T.Matrix4,u=new T.Matrix4;u.makeScale(0,0,0),n.forEach((p,f)=>{s.getMatrixAt(p,c),h.set(p,c.clone()),s.setMatrixAt(p,u),l.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Rc(r,e,t){e.scene.children.forEach(n=>{n.name=="highlightModel"&&n.parent.remove(n)}),r.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof T.InstancedMesh))return;const o=new Map,a=new T.Matrix4,l=new T.Matrix4;l.makeScale(0,0,0),n.forEach((h,c)=>{s.getMatrixAt(h,a),o.set(h,a.clone()),s.setMatrixAt(h,l)}),s.instanceMatrix.needsUpdate=!0,t.set(i,{cloneModel:null,originalMatrices:o})})}function Lr(r,e){r.forEach((t,n)=>{const i=e.scene.children[n];i instanceof T.InstancedMesh&&(t.forEach(s=>{const o=i.matrixs[s];o&&i.setMatrixAt(s,o)}),i.instanceMatrix.needsUpdate=!0)})}class Ve{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new T.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new T.Vector2(t.x,t.y)}worldToScreen(e){const t=this.worldToScreenNormalized(e),n=this.renderer.domElement.width,i=this.renderer.domElement.height,s=(t.x+1)*n/2,o=(1-t.y)*i/2;return new T.Vector2(s,o)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,s=e/n*2-1,o=-(t/i*2-1);return new T.Vector2(s,o)}screenToWorld(e,t,n){if(!this.scene&&!n)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=n||this.scene.children,o=this.raycaster.intersectObjects(s,!0);return o.length>0?o[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=new T.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}var Vn={exports:{}},Fc=Vn.exports,Or;function Uc(){return Or||(Or=1,(function(r,e){(function(t,n){r.exports=n()})(Fc,function(){var t=function(){function n(f){return o.appendChild(f.dom),f}function i(f){for(var d=0;d<o.children.length;d++)o.children[d].style.display=d===f?"block":"none";s=f}var s=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(f){f.preventDefault(),i(++s%o.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var f=(performance||Date).now();if(u.update(f-a,200),f>l+1e3&&(c.update(1e3*h/(f-l),100),l=f,h=0,p)){var d=performance.memory;p.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return f},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,h=l(window.devicePixelRatio||1),c=80*h,u=48*h,p=3*h,f=2*h,d=3*h,m=15*h,g=74*h,y=30*h,w=document.createElement("canvas");w.width=c,w.height=u,w.style.cssText="width:80px;height:48px";var b=w.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=s,b.fillRect(0,0,c,u),b.fillStyle=i,b.fillText(n,p,f),b.fillRect(d,m,g,y),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(d,m,g,y),{dom:w,update:function(x,_){o=Math.min(o,x),a=Math.max(a,x),b.fillStyle=s,b.globalAlpha=1,b.fillRect(0,0,c,m),b.fillStyle=i,b.fillText(l(x)+" "+n+" ("+l(o)+"-"+l(a)+")",p,f),b.drawImage(w,d+h,m,g-h,y,d,m,g-h,y),b.fillRect(d+g-h,m,h,y),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(d+g-h,m,h,l((1-x/_)*y))}}},t})})(Vn)),Vn.exports}var Vc=Uc();const jc=Ls(Vc);var Wt=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-Wt.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?Wt.Bounce.In(r*2)*.5:Wt.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),an=function(){return performance.now()},Gc=(function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=an()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],o=!t;s&&s.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),Ui={Linear:function(r,e){var t=r.length-1,n=t*e,i=Math.floor(n),s=Ui.Utils.Linear;return e<0?s(r[0],r[1],n):e>1?s(r[t],r[t-1],t-n):s(r[i],r[i+1>t?t:i+1],n-i)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},zr=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),Vi=new Gc,Wc=(function(){function r(e,t){t===void 0&&(t=Vi),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Wt.Linear.None,this._interpolationFunction=Ui.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=zr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=an()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,n,i,s){for(var o in n){var a=e[o],l=Array.isArray(a),h=l?"array":typeof a,c=!l&&Array.isArray(n[o]);if(!(h==="undefined"||h==="function")){if(c){var u=n[o];if(u.length===0)continue;for(var p=[a],f=0,d=u.length;f<d;f+=1){var m=this._handleRelativeValue(a,u[f]);if(isNaN(m)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(m)}c&&(n[o]=p)}if((h==="object"||l)&&a&&!c){t[o]=l?[]:{};var g=a;for(var y in g)t[o][y]=g[y];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var w={};for(var y in u)w[y]=u[y];n[o]=u=w}this._setupProperties(g,t[o],u,i[o],s)}else(typeof t[o]>"u"||s)&&(t[o]=a),l||(t[o]*=1),c?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},r.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=an()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=an()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=Vi),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=Wt.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=Ui.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=an()),t===void 0&&(t=!0),this._isPaused)return!0;var s,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),h=this._duration+this._repeat*l,c=function(){if(n._duration===0||a>h)return 1;var g=Math.trunc(a/l),y=a-g*l,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},u=c(),p=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,m=this._chainedTweens.length;d<m;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var o=t[s]||0,a=n[s],l=Array.isArray(e[s]),h=Array.isArray(a),c=!l&&h;c?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[s]=o+(a-o)*i))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},r})();zr.nextId;var et=Vi;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var ji={Easing:Wt,Tween:Wc};function Xc(){return new T.Scene}function qc(r,e){r.appendChild(e.domElement)}function Kc(r,e,t){var n=new Object;n.visible=!0;let i=null,s,o,a=[];n.init=function(){s||(h(),c(),u())},n.Hide=function(){s.style.display="none",n.visible=!1},n.Show=function(){s.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);let m=new T.Vector3(0,0,-1).clone().applyMatrix4(e.camera.matrixWorld.clone()),g=e.camera.position.clone().sub(m.clone()).setLength(100);n.camera.position.copy(g),n.camera.lookAt(new T.Vector3),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(d){console.log(d);var m=new T.Vector3(0,0,0);d=="top"?m=new T.Vector3(0,1,0):d=="down"?m=new T.Vector3(0,-1,0):d=="front"?m=new T.Vector3(0,0,1):d=="left"?m=new T.Vector3(-1,0,0):d=="back"?m=new T.Vector3(0,0,-1):d=="right"?m=new T.Vector3(1,0,0):d=="top_front"?m=new T.Vector3(1,1,0):d=="top_left"?m=new T.Vector3(0,1,-1):d=="top_back"?m=new T.Vector3(-1,1,0):d=="top_right"?m=new T.Vector3(0,1,1):d=="down_front"?m=new T.Vector3(1,-1,0):d=="down_left"?m=new T.Vector3(0,-1,-1):d=="down_back"?m=new T.Vector3(-1,-1,0):d=="down_right"?m=new T.Vector3(0,-1,1):d=="front_right"?m=new T.Vector3(1,0,1):d=="right_back"?m=new T.Vector3(-1,0,1):d=="back_left"?m=new T.Vector3(-1,0,-1):d=="left_front"?m=new T.Vector3(1,0,-1):d=="top_left_front"?m=new T.Vector3(1,1,-1):d=="top_front_right"?m=new T.Vector3(1,1,1):d=="top_right_back"?m=new T.Vector3(-1,1,1):d=="top_back_left"?m=new T.Vector3(-1,1,-1):d=="button_left_front"?m=new T.Vector3(1,-1,-1):d=="button_front_right"?m=new T.Vector3(1,-1,1):d=="button_right_back"?m=new T.Vector3(-1,1,1):d=="button_back_left"&&(m=new T.Vector3(-1,-1,-1));var g=r.octreeBox.getBoundingBox(),y=g.min,w=g.max,b=y.clone().add(w.clone()).multiplyScalar(.5),x=b.clone().add(m.multiplyScalar(1*w.distanceTo(y)));l(e.camera.position,x,r.controls.target.clone(),b)},n.GetCameraPose=function(){var d=e.camera.quaternion,m=e.camera.position,g=r.controls.target,y={quaternion:d,position:m,target:g};return y},n.ReductionCameraPose=function(d,m=1e3,g){var y=new T.Quaternion(d.quaternion._x,d.quaternion._y,d.quaternion._z,d.quaternion._w),w=new T.Vector3(d.position.x,d.position.y,d.position.z),b=new T.Vector3(d.target.x,d.target.y,d.target.z);let x=!1;l(e.camera.position,w,r.controls.target.clone(),b,e.camera.quaternion,y,m,_=>{g&&(x||(g(_),x=!0))}),g&&setTimeout(()=>{x||(g(!0),x=!0)},m+10)},n.CameraGoHome=function(){var d=r.octreeBox.getBoundingBox(),m=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let g=new T.Vector3(1,1,1);var y=d.max.distanceTo(d.min),w=m.clone().add(g.multiplyScalar(y));if(e.camera.isOrthographicCamera){var b=r.container.clientWidth/r.container.clientHeight,x=y*.6;e.camera.left=-x*b,e.camera.right=x*b,e.camera.top=x,e.camera.bottom=-x,e.camera.zoom=1,e.camera.updateProjectionMatrix()}l(e.camera.position,w,r.controls.target.clone(),m)},n.zoomToBox=function(d){var m=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let y=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var w=m.clone().add(y.multiplyScalar(1*d.max.distanceTo(d.min)));l(e.camera.position,w,r.controls.target.clone(),m)};function l(d,m,g,y,w,b,x=1e3,_){var D;w&&b?(D=new ji.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w}),D.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z,_x:b._x,_y:b._y,_z:b._z,_w:b._w},x)):(D=new ji.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z}),D.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z},x)),D.onUpdate(function(k){r.controls&&(w&&b?(e.camera.quaternion._x=k._x,e.camera.quaternion._y=k._y,e.camera.quaternion._z=k._z,e.camera.quaternion._w=k._w):r.controls.auto=!0,e.camera.position.x=k.x1,e.camera.position.y=k.y1,e.camera.position.z=k.z1,r.controls.target.x=k.x2,r.controls.target.y=k.y2,r.controls.target.z=k.z2,r.controls.update(),n.RenderScene())}),D.onComplete(function(k){r.controls&&(r.controls.auto=!1,n.RenderScene(),_&&_(!0),cancelAnimationFrame(i),i=null)}),D.easing(ji.Easing.Cubic.InOut);function P(k){i=requestAnimationFrame(P),D.update()}D.start(),P()}function h(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...",s.appendChild(o);var d=document.createElement("div");d.className="homeViewWrapper",d.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(d);const m=document.createElement("div");m.className="cameraToggleWrapper",m.title="切换正交/透视视图",m.innerHTML="⊞",m.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),w()}),s.appendChild(m);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("截图"),n.TakeScreenshot(),w()}),s.appendChild(g);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),w()}),s.appendChild(y),o.addEventListener("mousedown",function(x){x.stopPropagation(),m.classList.contains("show")?(w(),console.log("隐藏功能按钮")):(b(),console.log("显示功能按钮"))});function w(){m.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function b(){m.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function c(){n.sceneOrtho=Xc();var g=t.clientWidth,y=t.clientWidth,d=g>y?g/y:y/g,m=300;n.camera=new T.OrthographicCamera(m*d/-2,m*d/2,m/2,m/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,w=new T.WebGLRenderer({alpha:!0});w.setSize(g,y),w.setClearAlpha(0),n.sceneOrtho.renderer=w;let b=new T.AmbientLight(16777215,.8);n.sceneOrtho.add(b),qc(s,w)}function u(){const d="/assets/viewcube/";let m=[{label:"右",icon:d+"cn_right.png"},{label:"左",icon:d+"cn_left.png"},{label:"顶",icon:d+"cn_top.png"},{label:"底",icon:d+"cn_bottom.png"},{label:"前",icon:d+"cn_front.png"},{label:"后",icon:d+"cn_back.png"}];var g=[];for(const w of m)g.push(new T.MeshBasicMaterial({color:16777215,map:new T.TextureLoader().load(w.icon)}));new T.MeshLambertMaterial({color:255});var y=new T.Mesh(new T.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),p(122),s.addEventListener("mousedown",w=>{var b={};b.x=w.offsetX/s.clientWidth*2-1,b.y=-(w.offsetY/s.clientHeight)*2+1;var x=new T.Raycaster;x.setFromCamera(b,n.camera);const _=x.intersectObjects(a,!1);_.length>0&&n.ToggleDirectionView(_[0].object.name)}),s.addEventListener("mousemove",w=>{var b={};b.x=w.offsetX/s.clientWidth*2-1,b.y=-(w.offsetY/s.clientHeight)*2+1;var x=new T.Raycaster;x.setFromCamera(b,n.camera);const _=x.intersectObjects(a,!1);for(var D of a)D.material.opacity=.01;_.length>0&&(_[0].object.material.opacity=.2)})}function p(d){for(var m=d*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new T.Vector3(m,0,0)},{name:"back",a:75,b:75,c:30,point:new T.Vector3(0,0,-m)},{name:"left",a:30,b:75,c:75,point:new T.Vector3(-m,0,0)},{name:"front",a:75,b:75,c:30,point:new T.Vector3(0,0,m)},{name:"top",a:75,b:30,c:75,point:new T.Vector3(0,m,0)},{name:"button",a:75,b:30,c:75,point:new T.Vector3(0,-m,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new T.Vector3(-m,m,m)},{name:"button_front_right",a:30,b:30,c:30,point:new T.Vector3(-m,-m,m)},{name:"top_front_right",a:30,b:30,c:30,point:new T.Vector3(m,m,m)},{name:"button_right_back",a:30,b:30,c:30,point:new T.Vector3(m,-m,m)},{name:"top_back_left",a:30,b:30,c:30,point:new T.Vector3(-m,m,-m)},{name:"button_back_left",a:30,b:30,c:30,point:new T.Vector3(-m,-m,-m)},{name:"top_left_front",a:30,b:30,c:30,point:new T.Vector3(m,m,-m)},{name:"button_left_front",a:30,b:30,c:30,point:new T.Vector3(m,-m,-m)}],w=[{name:"top_front",a:30,b:30,c:75,point:new T.Vector3(m,m,0)},{name:"top_right",a:75,b:30,c:30,point:new T.Vector3(0,m,m)},{name:"top_back",a:30,b:30,c:75,point:new T.Vector3(-m,m,0)},{name:"top_left",a:75,b:30,c:30,point:new T.Vector3(0,m,-m)},{name:"button_front",a:30,b:30,c:75,point:new T.Vector3(m,-m,0)},{name:"button_right",a:75,b:30,c:30,point:new T.Vector3(0,-m,m)},{name:"button_back",a:30,b:30,c:75,point:new T.Vector3(-m,-m,0)},{name:"button_left",a:75,b:30,c:30,point:new T.Vector3(0,-m,-m)},{name:"front_right",a:30,b:75,c:30,point:new T.Vector3(m,0,m)},{name:"right_back",a:30,b:75,c:30,point:new T.Vector3(-m,0,m)},{name:"back_left",a:30,b:75,c:30,point:new T.Vector3(-m,0,-m)},{name:"left_front",a:30,b:75,c:30,point:new T.Vector3(m,0,-m)}],b=0;b<g.length;b++)a.push(f(g[b]));for(var b=0;b<y.length;b++)a.push(f(y[b]));for(var b=0;b<w.length;b++)a.push(f(w[b]))}function f(d){const m=new T.BoxGeometry(d.a,d.b,d.c),g=new T.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new T.Matrix4().makeTranslation(d.point.x,d.point.y,d.point.z);let w=m.applyMatrix4(y),b=new T.Mesh(w,g);return b.name=d.name,n.sceneOrtho.add(b),b}return n.ToggleCameraType=function(){r.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!r.renderer){console.error("渲染器未初始化");return}r.renderer.render(e,e.camera);const m=r.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=m,g.click(),console.log("截图已保存")}catch(d){console.error("截图失败:",d)}},n.ToggleFullscreen=function(){const d=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(d.requestFullscreen?d.requestFullscreen():d.webkitRequestFullscreen?d.webkitRequestFullscreen():d.mozRequestFullScreen?d.mozRequestFullScreen():d.msRequestFullscreen&&d.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class Zc{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Kc(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function Yc(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,n=new T.Vector3(1e8,1e9,1e10),i=new T.Vector3(-1e8,-1e9,-1e10);t.forEach(u=>{let p=u.boundingBox.min,f=u.boundingBox.max;p.x<n.x&&(n.x=p.x),p.y<n.y&&(n.y=p.y),p.z<n.z&&(n.z=p.z),f.x>i.x&&(i.x=f.x),f.y>i.y&&(i.y=f.y),f.z>i.z&&(i.z=f.z)});let s=Math.min(n.x,i.x),o=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),h=Math.max(n.y,i.y),c=Math.max(n.z,i.z);return{min:new T.Vector3(s,o,a),max:new T.Vector3(l,h,c)}},e.rayInterationModel=function(t){let n=[];return r.engineStatus.models.forEach(o=>{o.info.lods.forEach(a=>{let l=a.octreeBox;s(t,l,o)})}),t.intersectObjects(n,!1);function s(o,a,l){if(a==null)return;let h=new T.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),c=new T.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),u=new T.Vector3(Math.min(h.x,c.X),Math.min(h.y,c.y),Math.min(h.z,c.z)),p=new T.Vector3(Math.max(c.x,h.x),Math.max(c.y,h.y),Math.max(c.z,h.z)),f=new T.Box3(u,p),d=o.ray.intersectsBox(f);if(!(d==null||d==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var m of a.elements){let g=r.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let y=r.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let b=r.models.find(x=>x.url==l.url).nodesMap.get(m);b!=null&&!b.instance&&b.infos.map(_=>_.mesh).forEach(_=>{n.push(_)})}}else{if(a.elements!=null)for(var m of a.elements){let y=r.engineStatus.hideModels.find(_=>_.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let w=r.engineStatus.translucentModels.find(_=>_.url==l.url)?.ids;if(w!=null&&w.includes(m))continue;let x=r.models.find(_=>_.url==l.url).nodesMap.get(m);x!=null&&!x.instance&&x.infos.map(D=>D.mesh).forEach(D=>{n.push(D)})}for(let g of a.children)s(o,g,l)}}},e}class $c{engine;isDrawing=!1;startPoint=new T.Vector2;endPoint=new T.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new Ve(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),n=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),s=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${n}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${s}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:s},{x:i,y:s},{x:i,y:o},{x:n,y:o}];for(const c of l){const u=this.worldToScreen.screenToWorld(c.x,c.y);u&&a.push(u)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const h=new T.Box3;for(const c of a)h.expandByPoint(c);if(h.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(h)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new T.Vector3;e.getCenter(i);const s=new T.Vector3;e.getSize(s);const o=Math.max(s.x,s.y,s.z);if(t instanceof T.PerspectiveCamera){const a=t.fov*(Math.PI/180),h=o/(2*Math.tan(a/2))*1.2,c=new T.Vector3;t.getWorldDirection(c);const u=i.clone().sub(t.position);c.dot(u.normalize())<0&&c.negate();const f=i.clone().sub(c.multiplyScalar(h));t.position.copy(f),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof T.OrthographicCamera){const l=o*1.2,h=this.engine.renderer?.domElement,c=h?h.width/h.height:1;t.left=-l*c/2,t.right=l*c/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const u=new T.Vector3;t.getWorldDirection(u);const p=o*1.5,f=i.clone().sub(u.multiplyScalar(p));t.position.copy(f),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class Jc{engine;ground=null;constructor(e){this.engine=e}init(){}setStatsVisible(e){this.engine.stats?.dom&&(this.engine.stats.dom.style.display=e?"block":"none")}setAmbientLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof T.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof T.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);if(t?.shadow){const i={low:1024,medium:2048,high:4096,ultra:8192}[e];t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null}}setDirectionalLightShadow(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);t&&(t.castShadow=e),this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e)}setGTAOEnabled(e){if(!this.engine.composerModule?.composer){console.warn("Composer not initialized");return}const t=this.engine.composerModule.composer,n=t.passes.find(i=>i instanceof ze);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),o=new ze(this.engine.scene,this.engine.camera,i,s);o.output=ze.OUTPUT.Default,o.blendIntensity=.5,o.updateGtaoMaterial&&o.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0});const a=t.passes.findIndex(l=>l.constructor.name==="RenderPass");t.passes.splice(a+1,0,o)}else n&&(n.enabled=!1)}setSceneSaturation(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.saturation.value=e}setSceneContrast(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.contrast.value=e}setGroundEnabled(e,t){if(e)if(this.ground)this.ground.visible=!0;else{const n=t?.size??100,i=t?.color??8421504,s=t?.opacity??.3,o=new T.PlaneGeometry(n,n),a=new T.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:T.DoubleSide});this.ground=new T.Mesh(o,a),this.ground.rotation.x=-Math.PI/2,this.ground.position.y=0,this.ground.receiveShadow=!0,this.ground.name="ground",this.engine.scene.add(this.ground)}else this.ground&&(this.ground.visible=!1)}setHDRBackground(e){e?(this.engine.scene.background=e,this.engine.scene.environment=e):(this.engine.scene.background=null,this.engine.scene.environment=null)}}function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var e=Math.random()*16|0,t=r=="x"?e:e&3|8;return t.toString(16)})}class it{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=bi(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(d=>{f(d)}),this.engine.measure.annotationData.elevationAnnotation.forEach(d=>{p(d)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(d=>{u(d)}),this.engine.measure.annotationData.angleAnnotation.forEach(d=>{l(d)}),this.engine.measure.annotationData.areaAnnotation.forEach(d=>{h(d)}),this.engine.measure.annotationData.slopeAnnotation.forEach(d=>{c(d)});function l(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="angle-annotation",d.container.id=d.id,d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point3),w=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;m.x+=w,m.y+=b,g.x+=w,g.y+=b,y.x+=w,y.y+=b;let x=d.container;x.getElementsByTagName("circle")[0].setAttribute("cx",m.x),x.getElementsByTagName("circle")[0].setAttribute("cy",m.y),x.getElementsByTagName("circle")[1].setAttribute("cx",g.x),x.getElementsByTagName("circle")[1].setAttribute("cy",g.y),x.getElementsByTagName("circle")[2].setAttribute("cx",y.x),x.getElementsByTagName("circle")[2].setAttribute("cy",y.y),x.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y),x.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let _=g.x,D=g.y-30;x.getElementsByTagName("rect")[0].setAttribute("x",_-40),x.getElementsByTagName("rect")[0].setAttribute("y",D-12.5),x.getElementsByTagName("text")[0].setAttribute("x",_),x.getElementsByTagName("text")[0].setAttribute("y",D+4),x.getElementsByTagName("text")[0].innerHTML=d.text,x.style.top="0px",x.style.left="0px"}function h(d){if(d.container==null){let k=['<svg class="measureSvg">','<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,2)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="area-annotation",d.container.id=d.id,d.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}if(!d.points||d.points.length<3)return;let m=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],w=0,b=0;for(let k=0;k<d.points.length;k++){let C=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.points[k]);C.x+=m,C.y+=g,y.push(C),w+=C.x,b+=C.y}w=w/y.length,b=b/y.length;let x=y.map(k=>k.x+","+k.y).join(" "),_=d.container;_.getElementsByTagName("polygon")[0].setAttribute("points",x),_.getElementsByTagName("polyline")[0].setAttribute("points",x);let D=w,P=b;_.getElementsByTagName("rect")[0].setAttribute("x",D-40),_.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),_.getElementsByTagName("text")[0].setAttribute("x",D),_.getElementsByTagName("text")[0].setAttribute("y",P+4),_.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,2),_.style.top="0px",_.style.left="0px"}function c(d){if(d.container==null){let D=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+d.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+d.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="slope-annotation",d.container.id=d.id,d.container.innerHTML=D,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.x+=y,m.y+=w,g.x+=y,g.y+=w;let b=d.container;b.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y);let x=(m.x+g.x)/2,_=(m.y+g.y)/2-30;b.getElementsByTagName("rect")[0].setAttribute("x",x-50),b.getElementsByTagName("rect")[0].setAttribute("y",_-12.5),b.getElementsByTagName("text")[0].setAttribute("x",x),b.getElementsByTagName("text")[0].setAttribute("y",_+4),b.getElementsByTagName("text")[0].innerHTML=d.text,b.style.top="0px",b.style.left="0px"}function u(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(d.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-d.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(d.textY,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="coordinate-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container,g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=w,m.style.top="0px",m.style.left="0px";let b=m.getElementsByTagName("circle")[0];b&&(b.setAttribute("cx",g.x),b.setAttribute("cy",g.y));let x=m.getElementsByTagName("rect"),_=m.getElementsByTagName("text"),D=-55;x[0]&&(x[0].setAttribute("x",g.x+10),x[0].setAttribute("y",g.y+10+D)),_[0]&&(_[0].setAttribute("x",g.x+10+40),_[0].setAttribute("y",g.y+10+16+D)),x[1]&&(x[1].setAttribute("x",g.x+10),x[1].setAttribute("y",g.y+10+30+D)),_[1]&&(_[1].setAttribute("x",g.x+10+40),_[1].setAttribute("y",g.y+10+46+D)),x[2]&&(x[2].setAttribute("x",g.x+10),x[2].setAttribute("y",g.y+10+60+D)),_[2]&&(_[2].setAttribute("x",g.x+10+40),_[2].setAttribute("y",g.y+10+76+D)),_[0]&&(_[0].innerHTML="X: "+e.getMeasureText(d.textX,1)),_[1]&&(_[1].innerHTML="Y: "+e.getMeasureText(-d.textZ,1)),_[2]&&(_[2].innerHTML="Z: "+e.getMeasureText(d.textY,1))}function p(d){if(d.container==null){let b=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");d.container=document.createElement("div"),d.container.className="elevation-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container,g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.style.top=g.y+w-48+"px",m.style.left=g.x+y-16+"px",m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1)}function f(d){if(d.container==null){let x=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="normal-annotation",d.container.id=d.id,d.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container;if(d.point1==null||d.point2==null){m.style.display="none";return}else m.style.display="block";let g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),y=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),w=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;g.x+=w,g.y+=b,y.x+=w,y.y+=b,m.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),m.getElementsByTagName("circle")[0].setAttribute("cx",g.x),m.getElementsByTagName("circle")[0].setAttribute("cy",g.y),m.getElementsByTagName("circle")[1].setAttribute("cx",y.x),m.getElementsByTagName("circle")[1].setAttribute("cy",y.y),m.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),m.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),m.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1),m.style.top="0px",m.style.left="0px"}}}class Hc{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:nt(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new T.Raycaster(e.catch.point.clone().add(new T.Vector3(0,.01,0)),new T.Vector3(0,1,0));const i=this.engine.octreeBox.rayInterationModel(n);if(i.length===0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(ve.MeasureChanged,t)}}class Qc{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active()}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:nt(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class eh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:nt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new T.Raycaster(e.catch.point.clone().add(e.catch.normal.clone().setLength(.01)),e.catch.normal);const i=this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(ve.MeasureChanged,t)}}class th{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(ve.MeasureChanged,t))}}class nh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,this.engine.events.trigger(ve.MeasureChanged,t))}}class ih{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new T.Vector3().subVectors(e,t),s=new T.Vector3().subVectors(n,t),o=i.length(),a=s.length();if(o===0||a===0)return 0;const h=i.dot(s)/(o*a),c=Math.max(-1,Math.min(1,h));return Math.acos(c)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class sh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const s=(i+1)%n;t+=e[i].x*e[s].z,t-=e[s].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:nt(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:nt(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,e))}}class rh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,s=t.z-e.z,o=Math.sqrt(i*i+s*s);if(o===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/o*100,h=Math.atan(n/o)*(180/Math.PI);return{percentage:a,angle:h,heightDiff:n,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);n==null&&(n={id:nt(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class oh{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new Hc(e),this.distanceMeasure=new Qc(e),this.clearDistanceMeasure=new eh(e),this.elevationMeasure=new th(e),this.pointMeasure=new nh(e),this.angleMeasure=new ih(e),this.areaMeasure=new sh(e),this.slopeMeasure=new rh(e),this.tools=new it(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let n=0;n<t.length;n++)t[n].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}const Nr=0,ah=1,lh=2,Rr=2,Gi=1.25,Fr=1,Ie=32,Me=Ie/4,Ur=65535,ch=Math.pow(2,-24),Wi=Symbol("SKIP_GENERATION");function hh(r){return r.index?r.index.count:r.attributes.position.count}function At(r){return hh(r)/3}function uh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function dh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=uh(t,n);r.setIndex(new S.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Vr(r,e){const t=At(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,o=Math.max(0,i),a=Math.min(t,s)-o;return[{offset:Math.floor(o),count:Math.floor(a)}]}function jr(r,e){if(!r.groups||!r.groups.length)return Vr(r,e);const t=[],n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,o=At(r),a=[];for(const c of r.groups){const{start:u,count:p}=c,f=u/3,d=isFinite(p)?p:o*3-u,m=(u+d)/3;f<s&&m>i&&(a.push({pos:Math.max(i,f),isStart:!0}),a.push({pos:Math.min(s,m),isStart:!1}))}a.sort((c,u)=>c.pos!==u.pos?c.pos-u.pos:c.type==="end"?-1:1);let l=0,h=null;for(const c of a){const u=c.pos;l!==0&&u!==h&&t.push({offset:h,count:u-h}),l+=c.isStart?1:-1,h=u}return t}function Xi(r,e,t,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,p=1/0,f=1/0,d=-1/0,m=-1/0,g=-1/0;const y=r.offset||0;for(let w=(e-y)*6,b=(e+t-y)*6;w<b;w+=6){const x=r[w+0],_=r[w+1],D=x-_,P=x+_;D<s&&(s=D),P>l&&(l=P),x<u&&(u=x),x>d&&(d=x);const k=r[w+2],C=r[w+3],I=k-C,O=k+C;I<o&&(o=I),O>h&&(h=O),k<p&&(p=k),k>m&&(m=k);const A=r[w+4],E=r[w+5],v=A-E,z=A+E;v<a&&(a=v),z>c&&(c=z),A<f&&(f=A),A>g&&(g=A)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=h,n[5]=c,i[0]=u,i[1]=p,i[2]=f,i[3]=d,i[4]=m,i[5]=g}function Gr(r,e,t=null,n=null,i=null){const s=r.attributes.position,o=r.index?r.index.array:null,a=s.normalized;if(i===null)i=new Float32Array(t*6),i.offset=e;else if(e<0||t+e>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=s.array,h=s.offset||0;let c=3;s.isInterleavedBufferAttribute&&(c=s.data.stride);const u=["getX","getY","getZ"],p=i.offset;for(let f=e,d=e+t;f<d;f++){const g=(n?n[f]:f)*3,y=(f-p)*6;let w=g+0,b=g+1,x=g+2;o&&(w=o[w],b=o[b],x=o[x]),a||(w=w*c+h,b=b*c+h,x=x*c+h);for(let _=0;_<3;_++){let D,P,k;a?(D=s[u[_]](w),P=s[u[_]](b),k=s[u[_]](x)):(D=l[w+_],P=l[b+_],k=l[x+_]);let C=D;P<C&&(C=P),k<C&&(C=k);let I=D;P>I&&(I=P),k>I&&(I=k);const O=(I-C)/2,A=_*2;i[y+A+0]=C+O,i[y+A+1]=O+(Math.abs(C)+O)*ch}}return i}function we(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Wr(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Xr(r,e){e.set(r)}function qr(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function jn(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function ln(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const st=32,fh=(r,e)=>r.candidate-e.candidate,ut=new Array(st).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Gn=new Float32Array(6);function ph(r,e,t,n,i,s){let o=-1,a=0;if(s===Nr)o=Wr(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===ah)o=Wr(r),o!==-1&&(a=mh(t,n,i,o));else if(s===lh){const l=ln(r);let h=Gi*i;const c=t.offset||0,u=(n-c)*6,p=(n+i-c)*6;for(let f=0;f<3;f++){const d=e[f],y=(e[f+3]-d)/st;if(i<st/4){const w=[...ut];w.length=i;let b=0;for(let _=u;_<p;_+=6,b++){const D=w[b];D.candidate=t[_+2*f],D.count=0;const{bounds:P,leftCacheBounds:k,rightCacheBounds:C}=D;for(let I=0;I<3;I++)C[I]=1/0,C[I+3]=-1/0,k[I]=1/0,k[I+3]=-1/0,P[I]=1/0,P[I+3]=-1/0;jn(_,t,P)}w.sort(fh);let x=i;for(let _=0;_<x;_++){const D=w[_];for(;_+1<x&&w[_+1].candidate===D.candidate;)w.splice(_+1,1),x--}for(let _=u;_<p;_+=6){const D=t[_+2*f];for(let P=0;P<x;P++){const k=w[P];D>=k.candidate?jn(_,t,k.rightCacheBounds):(jn(_,t,k.leftCacheBounds),k.count++)}}for(let _=0;_<x;_++){const D=w[_],P=D.count,k=i-D.count,C=D.leftCacheBounds,I=D.rightCacheBounds;let O=0;P!==0&&(O=ln(C)/l);let A=0;k!==0&&(A=ln(I)/l);const E=Fr+Gi*(O*P+A*k);E<h&&(o=f,h=E,a=D.candidate)}}else{for(let x=0;x<st;x++){const _=ut[x];_.count=0,_.candidate=d+y+x*y;const D=_.bounds;for(let P=0;P<3;P++)D[P]=1/0,D[P+3]=-1/0}for(let x=u;x<p;x+=6){let P=~~((t[x+2*f]-d)/y);P>=st&&(P=st-1);const k=ut[P];k.count++,jn(x,t,k.bounds)}const w=ut[st-1];Xr(w.bounds,w.rightCacheBounds);for(let x=st-2;x>=0;x--){const _=ut[x],D=ut[x+1];qr(_.bounds,D.rightCacheBounds,_.rightCacheBounds)}let b=0;for(let x=0;x<st-1;x++){const _=ut[x],D=_.count,P=_.bounds,C=ut[x+1].rightCacheBounds;D!==0&&(b===0?Xr(P,Gn):qr(P,Gn,Gn)),b+=D;let I=0,O=0;b!==0&&(I=ln(Gn)/l);const A=i-b;A!==0&&(O=ln(C)/l);const E=Fr+Gi*(I*b+O*A);E<h&&(o=f,h=E,a=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function mh(r,e,t,n){let i=0;const s=r.offset;for(let o=e,a=e+t;o<a;o++)i+=r[(o-s)*6+n*2];return i/t}class qi{constructor(){this.boundingData=new Float32Array(6)}}function gh(r,e,t,n,i,s){let o=n,a=n+i-1;const l=s.pos,h=s.axis*2,c=t.offset||0;for(;;){for(;o<=a&&t[(o-c)*6+h]<l;)o++;for(;o<=a&&t[(a-c)*6+h]>=l;)a--;if(o<a){for(let u=0;u<3;u++){let p=e[o*3+u];e[o*3+u]=e[a*3+u],e[a*3+u]=p}for(let u=0;u<6;u++){const p=o-c,f=a-c,d=t[p*6+u];t[p*6+u]=t[f*6+u],t[f*6+u]=d}o++,a--}else return o}}function yh(r,e,t,n,i,s){let o=n,a=n+i-1;const l=s.pos,h=s.axis*2,c=t.offset||0;for(;;){for(;o<=a&&t[(o-c)*6+h]<l;)o++;for(;o<=a&&t[(a-c)*6+h]>=l;)a--;if(o<a){let u=r[o];r[o]=r[a],r[a]=u;for(let p=0;p<6;p++){const f=o-c,d=a-c,m=t[f*6+p];t[f*6+p]=t[d*6+p],t[d*6+p]=m}o++,a--}else return o}}let Kr,Wn,Ki,Zr;const wh=Math.pow(2,32);function Zi(r){return"count"in r?1:1+Zi(r.left)+Zi(r.right)}function bh(r,e,t){return Kr=new Float32Array(t),Wn=new Uint32Array(t),Ki=new Uint16Array(t),Zr=new Uint8Array(t),Yi(r,e)}function Yi(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let o=0;o<6;o++)Kr[t+o]=s[o];if(i)return e.buffer?(Zr.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Wn[t+6]=e.offset,Ki[n+14]=e.count,Ki[n+15]=Ur,r+Ie);{const{left:o,right:a,splitAxis:l}=e,h=r+Ie;let c=Yi(h,o);const u=r/Ie,f=c/Ie-u;if(f>wh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Wn[t+6]=f,Wn[t+7]=l,Yi(c,a)}}function xh(r,e,t){const i=(r.index?r.index.count:r.attributes.position.count)/3>2**16,s=t.reduce((c,u)=>c+u.count,0),o=i?4:2,a=e?new SharedArrayBuffer(s*o):new ArrayBuffer(s*o),l=i?new Uint32Array(a):new Uint16Array(a);let h=0;for(let c=0;c<t.length;c++){const{offset:u,count:p}=t[c];for(let f=0;f<p;f++)l[h+f]=u+f;h+=p}return l}function _h(r,e,t,n,i){const{maxDepth:s,verbose:o,maxLeafTris:a,strategy:l,onProgress:h,indirect:c}=i,u=r._indirectBuffer,p=r.geometry,f=p.index?p.index.array:null,d=c?yh:gh,m=At(p),g=new Float32Array(6);let y=!1;const w=new qi;return Xi(e,t,n,w.boundingData,g),x(w,t,n,g),w;function b(_){h&&h(_/m)}function x(_,D,P,k=null,C=0){if(!y&&C>=s&&(y=!0,o&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(p))),P<=a||C>=s)return b(D+P),_.offset=D,_.count=P,_;const I=ph(_.boundingData,k,e,D,P,l);if(I.axis===-1)return b(D+P),_.offset=D,_.count=P,_;const O=d(u,f,e,D,P,I);if(O===D||O===D+P)b(D+P),_.offset=D,_.count=P;else{_.splitAxis=I.axis;const A=new qi,E=D,v=O-D;_.left=A,Xi(e,E,v,A.boundingData,g),x(A,E,v,g,C+1);const z=new qi,Z=O,W=P-v;_.right=z,Xi(e,Z,W,z.boundingData,g),x(z,Z,W,g,C+1)}return _}}function vh(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.geometry;let i,s;if(e.indirect){const o=jr(n,e.range),a=xh(n,e.useSharedArrayBuffer,o);r._indirectBuffer=a,i=Gr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{dh(n,e);const o=Vr(n,e.range)[0];i=Gr(n,o.offset,o.count),s=jr(n,e.range)}r._roots=s.map(o=>{const a=_h(r,i,o.offset,o.count,e),l=Zi(a),h=new t(Ie*l);return bh(0,a,h),h})}class rt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){const l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){const a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}rt.prototype.setFromBox=(function(){const r=new S.Vector3;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*h+s.y*(1-h),r.z=i.z*c+s.z*(1-c);const u=t.dot(r);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}})();const Mh=(function(){const r=new S.Vector3,e=new S.Vector3,t=new S.Vector3;return function(i,s,o){const a=i.start,l=r,h=s.start,c=e;t.subVectors(a,h),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const u=t.dot(c),p=c.dot(l),f=c.dot(c),d=t.dot(l),g=l.dot(l)*f-p*p;let y,w;g!==0?y=(u*p-d*f)/g:y=0,w=(u+y*p)/f,o.x=y,o.y=w}})(),$i=(function(){const r=new S.Vector2,e=new S.Vector3,t=new S.Vector3;return function(i,s,o,a){Mh(i,s,r);let l=r.x,h=r.y;if(l>=0&&l<=1&&h>=0&&h<=1){i.at(l,o),s.at(h,a);return}else if(l>=0&&l<=1){h<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(h>=0&&h<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let u;h<0?u=s.start:u=s.end;const p=e,f=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(c,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(c)){o.copy(p),a.copy(u);return}else{o.copy(c),a.copy(f);return}}}})(),Sh=(function(){const r=new S.Vector3,e=new S.Vector3,t=new S.Plane,n=new S.Line3;return function(s,o){const{radius:a,center:l}=s,{a:h,b:c,c:u}=o;if(n.start=h,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=h,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const m=o.getPlane(t);if(Math.abs(m.distanceToPoint(l))<=a){const y=m.projectPoint(l,e);if(o.containsPoint(y))return!0}return!1}})(),Ah=["x","y","z"],ot=1e-15,Yr=ot*ot;function je(r){return Math.abs(r)<ot}class Ge extends S.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new S.Vector3),this.satBounds=new Array(4).fill().map(()=>new rt),this.points=[this.a,this.b,this.c],this.plane=new S.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new S.Line3,this.needsUpdate=!0}intersectsSphere(e){return Sh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const h=s[1],c=o[1];h.subVectors(e,t),c.setFromPoints(h,i);const u=s[2],p=o[2];u.subVectors(t,n),p.setFromPoints(u,i);const f=s[3],d=o[3];f.subVectors(n,e),d.setFromPoints(f,i);const m=h.length(),g=u.length(),y=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<ot?g<ot||y<ot?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ot?y<ot?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ot&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Ge.prototype.closestPointToSegment=(function(){const r=new S.Vector3,e=new S.Vector3,t=new S.Line3;return function(i,s=null,o=null){const{start:a,end:l}=i,h=this.points;let c,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(h[p]),t.end.copy(h[f]),$i(t,i,r,e),c=r.distanceToSquared(e),c<u&&(u=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<u&&(u=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<u&&(u=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(u)}})(),Ge.prototype.intersectsTriangle=(function(){const r=new Ge,e=new rt,t=new rt,n=new S.Vector3,i=new S.Vector3,s=new S.Vector3,o=new S.Vector3,a=new S.Line3,l=new S.Line3,h=new S.Vector3,c=new S.Vector2,u=new S.Vector2;function p(b,x,_,D){const P=n;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?P.copy(b.plane.normal):P.copy(x.plane.normal);const k=b.satBounds,C=b.satAxes;for(let A=1;A<4;A++){const E=k[A],v=C[A];if(e.setFromPoints(v,x.points),E.isSeparated(e)||(o.copy(P).cross(v),e.setFromPoints(o,b.points),t.setFromPoints(o,x.points),e.isSeparated(t)))return!1}const I=x.satBounds,O=x.satAxes;for(let A=1;A<4;A++){const E=I[A],v=O[A];if(e.setFromPoints(v,b.points),E.isSeparated(e)||(o.crossVectors(P,v),e.setFromPoints(o,b.points),t.setFromPoints(o,x.points),e.isSeparated(t)))return!1}return _&&(D||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}function f(b,x,_,D,P,k,C,I,O,A,E){let v=C/(C-I);A.x=D+(P-D)*v,E.start.subVectors(x,b).multiplyScalar(v).add(b),v=C/(C-O),A.y=D+(k-D)*v,E.end.subVectors(_,b).multiplyScalar(v).add(b)}function d(b,x,_,D,P,k,C,I,O,A,E){if(P>0)f(b.c,b.a,b.b,D,x,_,O,C,I,A,E);else if(k>0)f(b.b,b.a,b.c,_,x,D,I,C,O,A,E);else if(I*O>0||C!=0)f(b.a,b.b,b.c,x,_,D,C,I,O,A,E);else if(I!=0)f(b.b,b.a,b.c,_,x,D,I,C,O,A,E);else if(O!=0)f(b.c,b.a,b.b,D,x,_,O,C,I,A,E);else return!0;return!1}function m(b,x,_,D){const P=x.degenerateSegment,k=b.plane.distanceToPoint(P.start),C=b.plane.distanceToPoint(P.end);return je(k)?je(C)?p(b,x,_,D):(_&&(_.start.copy(P.start),_.end.copy(P.start)),b.containsPoint(P.start)):je(C)?(_&&(_.start.copy(P.end),_.end.copy(P.end)),b.containsPoint(P.end)):b.plane.intersectLine(P,n)!=null?(_&&(_.start.copy(n),_.end.copy(n)),b.containsPoint(n)):!1}function g(b,x,_){const D=x.a;return je(b.plane.distanceToPoint(D))&&b.containsPoint(D)?(_&&(_.start.copy(D),_.end.copy(D)),!0):!1}function y(b,x,_){const D=b.degenerateSegment,P=x.a;return D.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<Yr?(_&&(_.start.copy(P),_.end.copy(P)),!0):!1}function w(b,x,_,D){if(b.isDegenerateIntoSegment)if(x.isDegenerateIntoSegment){const P=b.degenerateSegment,k=x.degenerateSegment,C=i,I=s;P.delta(C),k.delta(I);const O=n.subVectors(k.start,P.start),A=C.x*I.y-C.y*I.x;if(je(A))return!1;const E=(O.x*I.y-O.y*I.x)/A,v=-(C.x*O.y-C.y*O.x)/A;if(E<0||E>1||v<0||v>1)return!1;const z=P.start.z+C.z*E,Z=k.start.z+I.z*v;return je(z-Z)?(_&&(_.start.copy(P.start).addScaledVector(C,E),_.end.copy(P.start).addScaledVector(C,E)),!0):!1}else return x.isDegenerateIntoPoint?y(b,x,_):m(x,b,_,D);else{if(b.isDegenerateIntoPoint)return x.isDegenerateIntoPoint?x.a.distanceToSquared(b.a)<Yr?(_&&(_.start.copy(b.a),_.end.copy(b.a)),!0):!1:x.isDegenerateIntoSegment?y(x,b,_):g(x,b,_);if(x.isDegenerateIntoPoint)return g(b,x,_);if(x.isDegenerateIntoSegment)return m(b,x,_,D)}}return function(x,_=null,D=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(r.copy(x),r.update(),x=r);const P=w(this,x,_,D);if(P!==void 0)return P;const k=this.plane,C=x.plane;let I=C.distanceToPoint(this.a),O=C.distanceToPoint(this.b),A=C.distanceToPoint(this.c);je(I)&&(I=0),je(O)&&(O=0),je(A)&&(A=0);const E=I*O,v=I*A;if(E>0&&v>0)return!1;let z=k.distanceToPoint(x.a),Z=k.distanceToPoint(x.b),W=k.distanceToPoint(x.c);je(z)&&(z=0),je(Z)&&(Z=0),je(W)&&(W=0);const Q=z*Z,G=z*W;if(Q>0&&G>0)return!1;i.copy(k.normal),s.copy(C.normal);const te=i.cross(s);let F=0,R=Math.abs(te.x);const ne=Math.abs(te.y);ne>R&&(R=ne,F=1),Math.abs(te.z)>R&&(F=2);const Y=Ah[F],de=this.a[Y],fe=this.b[Y],se=this.c[Y],oe=x.a[Y],he=x.b[Y],pe=x.c[Y];if(d(this,de,fe,se,E,v,I,O,A,c,a))return p(this,x,_,D);if(d(x,oe,he,pe,Q,G,z,Z,W,u,l))return p(this,x,_,D);if(c.y<c.x){const Ae=c.y;c.y=c.x,c.x=Ae,h.copy(a.start),a.start.copy(a.end),a.end.copy(h)}if(u.y<u.x){const Ae=u.y;u.y=u.x,u.x=Ae,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return c.y<u.x||u.y<c.x?!1:(_&&(u.x>c.x?_.start.copy(l.start):_.start.copy(a.start),u.y<c.y?_.end.copy(l.end):_.end.copy(a.end)),!0)}})(),Ge.prototype.distanceToPoint=(function(){const r=new S.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})(),Ge.prototype.distanceToTriangle=(function(){const r=new S.Vector3,e=new S.Vector3,t=["a","b","c"],n=new S.Line3,i=new S.Line3;return function(o,a=null,l=null){const h=a||l?n:null;if(this.intersectsTriangle(o,h))return(a||l)&&(a&&h.getCenter(a),l&&h.getCenter(l)),0;let c=1/0;for(let u=0;u<3;u++){let p;const f=t[u],d=o[f];this.closestPointToPoint(d,r),p=d.distanceToSquared(r),p<c&&(c=p,a&&a.copy(r),l&&l.copy(d));const m=this[f];o.closestPointToPoint(m,r),p=m.distanceToSquared(r),p<c&&(c=p,a&&a.copy(m),l&&l.copy(r))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let d=0;d<3;d++){const m=t[d],g=t[(d+1)%3];i.set(o[m],o[g]),$i(n,i,r,e);const y=r.distanceToSquared(e);y<c&&(c=y,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}})();class Be{constructor(e,t,n){this.isOrientedBox=!0,this.min=new S.Vector3,this.max=new S.Vector3,this.matrix=new S.Matrix4,this.invMatrix=new S.Matrix4,this.points=new Array(8).fill().map(()=>new S.Vector3),this.satAxes=new Array(3).fill().map(()=>new S.Vector3),this.satBounds=new Array(3).fill().map(()=>new rt),this.alignedSatBounds=new Array(3).fill().map(()=>new rt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Be.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let h=0;h<=1;h++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){const p=1*h|2*c|4*u,f=i[p];f.x=h?n.x:t.x,f.y=c?n.y:t.y,f.z=u?n.z:t.z,f.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let h=0;h<3;h++){const c=o[h],u=s[h],p=1<<h,f=i[p];c.subVectors(a,f),u.setFromPoints(c,i)}const l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Be.prototype.intersectsBox=(function(){const r=new rt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){const h=o[l],c=s[l];if(r.setFromBox(h,t),c.isSeparated(r))return!1}return!0}})(),Be.prototype.intersectsTriangle=(function(){const r=new Ge,e=new Array(3),t=new rt,n=new rt,i=new S.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let p=0;p<3;p++){const f=a[p],d=l[p];if(t.setFromPoints(d,e),f.isSeparated(t))return!1}const h=o.satBounds,c=o.satAxes,u=this.points;for(let p=0;p<3;p++){const f=h[p],d=c[p];if(t.setFromPoints(d,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=l[p];for(let d=0;d<4;d++){const m=c[d];if(i.crossVectors(f,m),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}})(),Be.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),Be.prototype.distanceToPoint=(function(){const r=new S.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})(),Be.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new S.Line3),t=new Array(12).fill().map(()=>new S.Line3),n=new S.Vector3,i=new S.Vector3;return function(o,a=0,l=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||h)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),h&&h.copy(i)),0;const c=a*a,u=o.min,p=o.max,f=this.points;let d=1/0;for(let g=0;g<8;g++){const y=f[g];i.copy(y).clamp(u,p);const w=y.distanceToSquared(i);if(w<d&&(d=w,l&&l.copy(y),h&&h.copy(i),w<c))return Math.sqrt(w)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){const b=(g+1)%3,x=(g+2)%3,_=y<<b|w<<x,D=1<<g|y<<b|w<<x,P=f[_],k=f[D];e[m].set(P,k);const I=r[g],O=r[b],A=r[x],E=t[m],v=E.start,z=E.end;v[I]=u[I],v[O]=y?u[O]:p[O],v[A]=w?u[A]:p[O],z[I]=p[I],z[O]=y?u[O]:p[O],z[A]=w?u[A]:p[O],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){i.x=g?p.x:u.x,i.y=y?p.y:u.y,i.z=w?p.z:u.z,this.closestPointToPoint(i,n);const b=i.distanceToSquared(n);if(b<d&&(d=b,l&&l.copy(n),h&&h.copy(i),b<c))return Math.sqrt(b)}for(let g=0;g<12;g++){const y=e[g];for(let w=0;w<12;w++){const b=t[w];$i(y,b,n,i);const x=n.distanceToSquared(i);if(x<d&&(d=x,l&&l.copy(n),h&&h.copy(i),x<c))return Math.sqrt(x)}}return Math.sqrt(d)}})();class Ji{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Th extends Ji{constructor(){super(()=>new Ge)}}const We=new Th;function Se(r,e){return e[r+15]===Ur}function Fe(r,e){return e[r+6]}function Xe(r,e){return e[r+14]}function Ce(r){return r+Me}function Pe(r,e){const t=e[r+6];return r+t*Me}function Hi(r,e){return e[r+7]}function zd(r){return r}class Ch{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const me=new Ch;let dt,Xt;const qt=[],Xn=new Ji(()=>new S.Box3);function Ph(r,e,t,n,i,s){dt=Xn.getPrimitive(),Xt=Xn.getPrimitive(),qt.push(dt,Xt),me.setBuffer(r._roots[e]);const o=Qi(0,r.geometry,t,n,i,s);me.clearBuffer(),Xn.releasePrimitive(dt),Xn.releasePrimitive(Xt),qt.pop(),qt.pop();const a=qt.length;return a>0&&(Xt=qt[a-1],dt=qt[a-2]),o}function Qi(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:h}=me;let c=r*2;if(Se(c,l)){const p=Fe(r,h),f=Xe(c,l);return we(r,a,dt),n(p,f,!1,o,s+r/Me,dt)}else{let I=function(A){const{uint16Array:E,uint32Array:v}=me;let z=A*2;for(;!Se(z,E);)A=Ce(A),z=A*2;return Fe(A,v)},O=function(A){const{uint16Array:E,uint32Array:v}=me;let z=A*2;for(;!Se(z,E);)A=Pe(A,v),z=A*2;return Fe(A,v)+Xe(z,E)};const p=Ce(r),f=Pe(r,h);let d=p,m=f,g,y,w,b;if(i&&(w=dt,b=Xt,we(d,a,w),we(m,a,b),g=i(w),y=i(b),y<g)){d=f,m=p;const A=g;g=y,y=A,w=b}w||(w=dt,we(d,a,w));const x=Se(d*2,l),_=t(w,x,g,o+1,s+d/Me);let D;if(_===Rr){const A=I(d),v=O(d)-A;D=n(A,v,!0,o+1,s+d/Me,w)}else D=_&&Qi(d,e,t,n,i,s,o+1);if(D)return!0;b=Xt,we(m,a,b);const P=Se(m*2,l),k=t(b,P,y,o+1,s+m/Me);let C;if(k===Rr){const A=I(m),v=O(m)-A;C=n(A,v,!0,o+1,s+m/Me,b)}else C=k&&Qi(m,e,t,n,i,s,o+1);return!!C}}const cn=new S.Vector3,es=new S.Vector3;function Dh(r,e,t={},n=0,i=1/0){const s=n*n,o=i*i;let a=1/0,l=null;if(r.shapecast({boundsTraverseOrder:c=>(cn.copy(e).clamp(c.min,c.max),cn.distanceToSquared(e)),intersectsBounds:(c,u,p)=>p<a&&p<o,intersectsTriangle:(c,u)=>{c.closestPointToPoint(e,cn);const p=e.distanceToSquared(cn);return p<a&&(es.copy(cn),a=p,l=u),p<s}}),a===1/0)return null;const h=Math.sqrt(a);return t.point?t.point.copy(es):t.point=es.clone(),t.distance=h,t.faceIndex=l,t}const qn=parseInt(S.REVISION)>=169,kh=parseInt(S.REVISION)<=161,Tt=new S.Vector3,Ct=new S.Vector3,Pt=new S.Vector3,Kn=new S.Vector2,Zn=new S.Vector2,Yn=new S.Vector2,$r=new S.Vector3,Jr=new S.Vector3,Hr=new S.Vector3,hn=new S.Vector3;function Ih(r,e,t,n,i,s,o,a){let l;if(s===S.BackSide?l=r.intersectTriangle(n,t,e,!0,i):l=r.intersectTriangle(e,t,n,s!==S.DoubleSide,i),l===null)return null;const h=r.origin.distanceTo(i);return h<o||h>a?null:{distance:h,point:i.clone()}}function Qr(r,e,t,n,i,s,o,a,l,h,c){Tt.fromBufferAttribute(e,s),Ct.fromBufferAttribute(e,o),Pt.fromBufferAttribute(e,a);const u=Ih(r,Tt,Ct,Pt,hn,l,h,c);if(u){if(n){Kn.fromBufferAttribute(n,s),Zn.fromBufferAttribute(n,o),Yn.fromBufferAttribute(n,a),u.uv=new S.Vector2;const f=S.Triangle.getInterpolation(hn,Tt,Ct,Pt,Kn,Zn,Yn,u.uv);qn||(u.uv=f)}if(i){Kn.fromBufferAttribute(i,s),Zn.fromBufferAttribute(i,o),Yn.fromBufferAttribute(i,a),u.uv1=new S.Vector2;const f=S.Triangle.getInterpolation(hn,Tt,Ct,Pt,Kn,Zn,Yn,u.uv1);qn||(u.uv1=f),kh&&(u.uv2=u.uv1)}if(t){$r.fromBufferAttribute(t,s),Jr.fromBufferAttribute(t,o),Hr.fromBufferAttribute(t,a),u.normal=new S.Vector3;const f=S.Triangle.getInterpolation(hn,Tt,Ct,Pt,$r,Jr,Hr,u.normal);u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1),qn||(u.normal=f)}const p={a:s,b:o,c:a,normal:new S.Vector3,materialIndex:0};if(S.Triangle.getNormal(Tt,Ct,Pt,p.normal),u.face=p,u.faceIndex=s,qn){const f=new S.Vector3;S.Triangle.getBarycoord(hn,Tt,Ct,Pt,f),u.barycoord=f}}return u}function eo(r){return r&&r.isMaterial?r.side:r}function $n(r,e,t,n,i,s,o){const a=n*3;let l=a+0,h=a+1,c=a+2;const{index:u,groups:p}=r;r.index&&(l=u.getX(l),h=u.getX(h),c=u.getX(c));const{position:f,normal:d,uv:m,uv1:g}=r.attributes;if(Array.isArray(e)){const y=n*3;for(let w=0,b=p.length;w<b;w++){const{start:x,count:_,materialIndex:D}=p[w];if(y>=x&&y<x+_){const P=eo(e[D]),k=Qr(t,f,d,m,g,l,h,c,P,s,o);if(k)if(k.faceIndex=n,k.face.materialIndex=D,i)i.push(k);else return k}}}else{const y=eo(e),w=Qr(t,f,d,m,g,l,h,c,y,s,o);if(w)if(w.faceIndex=n,w.face.materialIndex=0,i)i.push(w);else return w}return null}function _e(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,h=e+2;t&&(a=t.getX(a),l=t.getX(l),h=t.getX(h)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(h),o.y=n.getY(h),o.z=n.getZ(h)}function Bh(r,e,t,n,i,s,o,a){const{geometry:l,_indirectBuffer:h}=r;for(let c=n,u=n+i;c<u;c++)$n(l,e,t,c,s,o,a)}function Eh(r,e,t,n,i,s,o){const{geometry:a,_indirectBuffer:l}=r;let h=1/0,c=null;for(let u=n,p=n+i;u<p;u++){let f;f=$n(a,e,t,u,null,s,o),f&&f.distance<h&&(c=f,h=f.distance)}return c}function Lh(r,e,t,n,i,s,o){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=r,u=e+r;c<u;c++){let p;if(p=c,_e(o,p*3,l,h),o.needsUpdate=!0,n(o,p,i,s))return!0}return!1}function Oh(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,o,a,l,h=0;const c=r._roots;for(let p=0,f=c.length;p<f;p++)s=c[p],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(p,f,d=!1){const m=p*2;if(Se(m,a)){const g=o[p+6],y=a[m+14];let w=1/0,b=1/0,x=1/0,_=-1/0,D=-1/0,P=-1/0;for(let k=3*g,C=3*(g+y);k<C;k++){let I=n[k];const O=i.getX(I),A=i.getY(I),E=i.getZ(I);O<w&&(w=O),O>_&&(_=O),A<b&&(b=A),A>D&&(D=A),E<x&&(x=E),E>P&&(P=E)}return l[p+0]!==w||l[p+1]!==b||l[p+2]!==x||l[p+3]!==_||l[p+4]!==D||l[p+5]!==P?(l[p+0]=w,l[p+1]=b,l[p+2]=x,l[p+3]=_,l[p+4]=D,l[p+5]=P,!0):!1}else{const g=Ce(p),y=Pe(p,o);let w=d,b=!1,x=!1;if(e){if(!w){const I=g/Me+f/Ie,O=y/Me+f/Ie;b=e.has(I),x=e.has(O),w=!b&&!x}}else b=!0,x=!0;const _=w||b,D=w||x;let P=!1;_&&(P=u(g,f,w));let k=!1;D&&(k=u(y,f,w));const C=P||k;if(C)for(let I=0;I<3;I++){const O=g+I,A=y+I,E=l[O],v=l[O+3],z=l[A],Z=l[A+3];l[p+I]=E<z?E:z,l[p+I+3]=v>Z?v:Z}return C}}}function ft(r,e,t,n,i){let s,o,a,l,h,c;const u=1/t.direction.x,p=1/t.direction.y,f=1/t.direction.z,d=t.origin.x,m=t.origin.y,g=t.origin.z;let y=e[r],w=e[r+3],b=e[r+1],x=e[r+3+1],_=e[r+2],D=e[r+3+2];return u>=0?(s=(y-d)*u,o=(w-d)*u):(s=(w-d)*u,o=(y-d)*u),p>=0?(a=(b-m)*p,l=(x-m)*p):(a=(x-m)*p,l=(b-m)*p),s>l||a>o||((a>s||isNaN(s))&&(s=a),(l<o||isNaN(o))&&(o=l),f>=0?(h=(_-g)*f,c=(D-g)*f):(h=(D-g)*f,c=(_-g)*f),s>c||h>o)?!1:((h>s||s!==s)&&(s=h),(c<o||o!==o)&&(o=c),s<=i&&o>=n)}function zh(r,e,t,n,i,s,o,a){const{geometry:l,_indirectBuffer:h}=r;for(let c=n,u=n+i;c<u;c++){let p=h?h[c]:c;$n(l,e,t,p,s,o,a)}}function Nh(r,e,t,n,i,s,o){const{geometry:a,_indirectBuffer:l}=r;let h=1/0,c=null;for(let u=n,p=n+i;u<p;u++){let f;f=$n(a,e,t,l?l[u]:u,null,s,o),f&&f.distance<h&&(c=f,h=f.distance)}return c}function Rh(r,e,t,n,i,s,o){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=r,u=e+r;c<u;c++){let p;if(p=t.resolveTriangleIndex(c),_e(o,p*3,l,h),o.needsUpdate=!0,n(o,p,i,s))return!0}return!1}function Fh(r,e,t,n,i,s,o){me.setBuffer(r._roots[e]),ts(0,r,t,n,i,s,o),me.clearBuffer()}function ts(r,e,t,n,i,s,o){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=r*2;if(Se(c,l)){const p=Fe(r,h),f=Xe(c,l);Bh(e,t,n,p,f,i,s,o)}else{const p=Ce(r);ft(p,a,n,s,o)&&ts(p,e,t,n,i,s,o);const f=Pe(r,h);ft(f,a,n,s,o)&&ts(f,e,t,n,i,s,o)}}const Uh=["x","y","z"];function Vh(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const o=ns(0,r,t,n,i,s);return me.clearBuffer(),o}function ns(r,e,t,n,i,s){const{float32Array:o,uint16Array:a,uint32Array:l}=me;let h=r*2;if(Se(h,a)){const u=Fe(r,l),p=Xe(h,a);return Eh(e,t,n,u,p,i,s)}else{const u=Hi(r,l),p=Uh[u],d=n.direction[p]>=0;let m,g;d?(m=Ce(r),g=Pe(r,l)):(m=Pe(r,l),g=Ce(r));const w=ft(m,o,n,i,s)?ns(m,e,t,n,i,s):null;if(w){const _=w.point[p];if(d?_<=o[g+u]:_>=o[g+u+3])return w}const x=ft(g,o,n,i,s)?ns(g,e,t,n,i,s):null;return w&&x?w.distance<=x.distance?w:x:w||x||null}}const Jn=new S.Box3,Kt=new Ge,Zt=new Ge,un=new S.Matrix4,to=new Be,Hn=new Be;function jh(r,e,t,n){me.setBuffer(r._roots[e]);const i=is(0,r,t,n);return me.clearBuffer(),i}function is(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=me;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),to.set(t.boundingBox.min,t.boundingBox.max,n),i=to),Se(l,o)){const c=e.geometry,u=c.index,p=c.attributes.position,f=t.index,d=t.attributes.position,m=Fe(r,a),g=Xe(l,o);if(un.copy(n).invert(),t.boundsTree)return we(r,s,Hn),Hn.matrix.copy(un),Hn.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>Hn.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let b=m*3,x=(g+m)*3;b<x;b+=3)if(_e(Zt,b,u,p),Zt.needsUpdate=!0,w.intersectsTriangle(Zt))return!0;return!1}});{const y=At(t);for(let w=m*3,b=(g+m)*3;w<b;w+=3){_e(Kt,w,u,p),Kt.a.applyMatrix4(un),Kt.b.applyMatrix4(un),Kt.c.applyMatrix4(un),Kt.needsUpdate=!0;for(let x=0,_=y*3;x<_;x+=3)if(_e(Zt,x,f,d),Zt.needsUpdate=!0,Kt.intersectsTriangle(Zt))return!0}}}else{const c=Ce(r),u=Pe(r,a);return we(c,s,Jn),!!(i.intersectsBox(Jn)&&is(c,e,t,n,i)||(we(u,s,Jn),i.intersectsBox(Jn)&&is(u,e,t,n,i)))}}const Qn=new S.Matrix4,ss=new Be,dn=new Be,Gh=new S.Vector3,Wh=new S.Vector3,Xh=new S.Vector3,qh=new S.Vector3;function Kh(r,e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),ss.set(e.boundingBox.min,e.boundingBox.max,t),ss.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,p=We.getPrimitive(),f=We.getPrimitive();let d=Gh,m=Wh,g=null,y=null;i&&(g=Xh,y=qh);let w=1/0,b=null,x=null;return Qn.copy(t).invert(),dn.matrix.copy(Qn),r.shapecast({boundsTraverseOrder:_=>ss.distanceToBox(_),intersectsBounds:(_,D,P)=>P<w&&P<o?(D&&(dn.min.copy(_.min),dn.max.copy(_.max),dn.needsUpdate=!0),!0):!1,intersectsRange:(_,D)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>dn.distanceToBox(k),intersectsBounds:(k,C,I)=>I<w&&I<o,intersectsRange:(k,C)=>{for(let I=k,O=k+C;I<O;I++){_e(f,3*I,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let A=_,E=_+D;A<E;A++){_e(p,3*A,h,l),p.needsUpdate=!0;const v=p.distanceToTriangle(f,d,g);if(v<w&&(m.copy(d),y&&y.copy(g),w=v,b=A,x=I),v<s)return!0}}}});{const P=At(e);for(let k=0,C=P;k<C;k++){_e(f,3*k,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=_,O=_+D;I<O;I++){_e(p,3*I,h,l),p.needsUpdate=!0;const A=p.distanceToTriangle(f,d,g);if(A<w&&(m.copy(d),y&&y.copy(g),w=A,b=I,x=k),A<s)return!0}}}}}),We.releasePrimitive(p),We.releasePrimitive(f),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=b,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(Qn),m.applyMatrix4(Qn),i.distance=m.sub(i.point).length(),i.faceIndex=x),n)}function Zh(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,o,a,l,h=0;const c=r._roots;for(let p=0,f=c.length;p<f;p++)s=c[p],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(p,f,d=!1){const m=p*2;if(Se(m,a)){const g=o[p+6],y=a[m+14];let w=1/0,b=1/0,x=1/0,_=-1/0,D=-1/0,P=-1/0;for(let k=g,C=g+y;k<C;k++){const I=3*r.resolveTriangleIndex(k);for(let O=0;O<3;O++){let A=I+O;A=n?n[A]:A;const E=i.getX(A),v=i.getY(A),z=i.getZ(A);E<w&&(w=E),E>_&&(_=E),v<b&&(b=v),v>D&&(D=v),z<x&&(x=z),z>P&&(P=z)}}return l[p+0]!==w||l[p+1]!==b||l[p+2]!==x||l[p+3]!==_||l[p+4]!==D||l[p+5]!==P?(l[p+0]=w,l[p+1]=b,l[p+2]=x,l[p+3]=_,l[p+4]=D,l[p+5]=P,!0):!1}else{const g=Ce(p),y=Pe(p,o);let w=d,b=!1,x=!1;if(e){if(!w){const I=g/Me+f/Ie,O=y/Me+f/Ie;b=e.has(I),x=e.has(O),w=!b&&!x}}else b=!0,x=!0;const _=w||b,D=w||x;let P=!1;_&&(P=u(g,f,w));let k=!1;D&&(k=u(y,f,w));const C=P||k;if(C)for(let I=0;I<3;I++){const O=g+I,A=y+I,E=l[O],v=l[O+3],z=l[A],Z=l[A+3];l[p+I]=E<z?E:z,l[p+I+3]=v>Z?v:Z}return C}}}function Yh(r,e,t,n,i,s,o){me.setBuffer(r._roots[e]),rs(0,r,t,n,i,s,o),me.clearBuffer()}function rs(r,e,t,n,i,s,o){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=r*2;if(Se(c,l)){const p=Fe(r,h),f=Xe(c,l);zh(e,t,n,p,f,i,s,o)}else{const p=Ce(r);ft(p,a,n,s,o)&&rs(p,e,t,n,i,s,o);const f=Pe(r,h);ft(f,a,n,s,o)&&rs(f,e,t,n,i,s,o)}}const $h=["x","y","z"];function Jh(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const o=os(0,r,t,n,i,s);return me.clearBuffer(),o}function os(r,e,t,n,i,s){const{float32Array:o,uint16Array:a,uint32Array:l}=me;let h=r*2;if(Se(h,a)){const u=Fe(r,l),p=Xe(h,a);return Nh(e,t,n,u,p,i,s)}else{const u=Hi(r,l),p=$h[u],d=n.direction[p]>=0;let m,g;d?(m=Ce(r),g=Pe(r,l)):(m=Pe(r,l),g=Ce(r));const w=ft(m,o,n,i,s)?os(m,e,t,n,i,s):null;if(w){const _=w.point[p];if(d?_<=o[g+u]:_>=o[g+u+3])return w}const x=ft(g,o,n,i,s)?os(g,e,t,n,i,s):null;return w&&x?w.distance<=x.distance?w:x:w||x||null}}const ei=new S.Box3,Yt=new Ge,$t=new Ge,fn=new S.Matrix4,no=new Be,ti=new Be;function Hh(r,e,t,n){me.setBuffer(r._roots[e]);const i=as(0,r,t,n);return me.clearBuffer(),i}function as(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=me;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),no.set(t.boundingBox.min,t.boundingBox.max,n),i=no),Se(l,o)){const c=e.geometry,u=c.index,p=c.attributes.position,f=t.index,d=t.attributes.position,m=Fe(r,a),g=Xe(l,o);if(fn.copy(n).invert(),t.boundsTree)return we(r,s,ti),ti.matrix.copy(fn),ti.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>ti.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let b=m,x=g+m;b<x;b++)if(_e($t,3*e.resolveTriangleIndex(b),u,p),$t.needsUpdate=!0,w.intersectsTriangle($t))return!0;return!1}});{const y=At(t);for(let w=m,b=g+m;w<b;w++){const x=e.resolveTriangleIndex(w);_e(Yt,3*x,u,p),Yt.a.applyMatrix4(fn),Yt.b.applyMatrix4(fn),Yt.c.applyMatrix4(fn),Yt.needsUpdate=!0;for(let _=0,D=y*3;_<D;_+=3)if(_e($t,_,f,d),$t.needsUpdate=!0,Yt.intersectsTriangle($t))return!0}}}else{const c=Ce(r),u=Pe(r,a);return we(c,s,ei),!!(i.intersectsBox(ei)&&as(c,e,t,n,i)||(we(u,s,ei),i.intersectsBox(ei)&&as(u,e,t,n,i)))}}const ni=new S.Matrix4,ls=new Be,pn=new Be,Qh=new S.Vector3,eu=new S.Vector3,tu=new S.Vector3,nu=new S.Vector3;function iu(r,e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),ls.set(e.boundingBox.min,e.boundingBox.max,t),ls.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,p=We.getPrimitive(),f=We.getPrimitive();let d=Qh,m=eu,g=null,y=null;i&&(g=tu,y=nu);let w=1/0,b=null,x=null;return ni.copy(t).invert(),pn.matrix.copy(ni),r.shapecast({boundsTraverseOrder:_=>ls.distanceToBox(_),intersectsBounds:(_,D,P)=>P<w&&P<o?(D&&(pn.min.copy(_.min),pn.max.copy(_.max),pn.needsUpdate=!0),!0):!1,intersectsRange:(_,D)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>pn.distanceToBox(k),intersectsBounds:(k,C,I)=>I<w&&I<o,intersectsRange:(k,C)=>{for(let I=k,O=k+C;I<O;I++){const A=P.resolveTriangleIndex(I);_e(f,3*A,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let E=_,v=_+D;E<v;E++){const z=r.resolveTriangleIndex(E);_e(p,3*z,h,l),p.needsUpdate=!0;const Z=p.distanceToTriangle(f,d,g);if(Z<w&&(m.copy(d),y&&y.copy(g),w=Z,b=E,x=I),Z<s)return!0}}}})}else{const P=At(e);for(let k=0,C=P;k<C;k++){_e(f,3*k,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=_,O=_+D;I<O;I++){const A=r.resolveTriangleIndex(I);_e(p,3*A,h,l),p.needsUpdate=!0;const E=p.distanceToTriangle(f,d,g);if(E<w&&(m.copy(d),y&&y.copy(g),w=E,b=I,x=k),E<s)return!0}}}}}),We.releasePrimitive(p),We.releasePrimitive(f),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=b,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ni),m.applyMatrix4(ni),i.distance=m.sub(i.point).length(),i.faceIndex=x),n)}function su(){return typeof SharedArrayBuffer<"u"}const mn=new me.constructor,ii=new me.constructor,pt=new Ji(()=>new S.Box3),Jt=new S.Box3,Ht=new S.Box3,cs=new S.Box3,hs=new S.Box3;let us=!1;function ru(r,e,t,n){if(us)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");us=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const h=new S.Matrix4().copy(t).invert();for(let c=0,u=i.length;c<u;c++){mn.setBuffer(i[c]),l=0;const p=pt.getPrimitive();we(0,mn.float32Array,p),p.applyMatrix4(h);for(let f=0,d=s.length;f<d&&(ii.setBuffer(s[f]),o=Ze(0,0,t,h,n,a,l,0,0,p),ii.clearBuffer(),l+=s[f].byteLength/Ie,!o);f++);if(pt.releasePrimitive(p),mn.clearBuffer(),a+=i[c].byteLength/Ie,o)break}return us=!1,o}function Ze(r,e,t,n,i,s=0,o=0,a=0,l=0,h=null,c=!1){let u,p;c?(u=ii,p=mn):(u=mn,p=ii);const f=u.float32Array,d=u.uint32Array,m=u.uint16Array,g=p.float32Array,y=p.uint32Array,w=p.uint16Array,b=r*2,x=e*2,_=Se(b,m),D=Se(x,w);let P=!1;if(D&&_)c?P=i(Fe(e,y),Xe(e*2,w),Fe(r,d),Xe(r*2,m),l,o+e/Me,a,s+r/Me):P=i(Fe(r,d),Xe(r*2,m),Fe(e,y),Xe(e*2,w),a,s+r/Me,l,o+e/Me);else if(D){const k=pt.getPrimitive();we(e,g,k),k.applyMatrix4(t);const C=Ce(r),I=Pe(r,d);we(C,f,Jt),we(I,f,Ht);const O=k.intersectsBox(Jt),A=k.intersectsBox(Ht);P=O&&Ze(e,C,n,t,i,o,s,l,a+1,k,!c)||A&&Ze(e,I,n,t,i,o,s,l,a+1,k,!c),pt.releasePrimitive(k)}else{const k=Ce(e),C=Pe(e,y);we(k,g,cs),we(C,g,hs);const I=h.intersectsBox(cs),O=h.intersectsBox(hs);if(I&&O)P=Ze(r,k,t,n,i,s,o,a,l+1,h,c)||Ze(r,C,t,n,i,s,o,a,l+1,h,c);else if(I)if(_)P=Ze(r,k,t,n,i,s,o,a,l+1,h,c);else{const A=pt.getPrimitive();A.copy(cs).applyMatrix4(t);const E=Ce(r),v=Pe(r,d);we(E,f,Jt),we(v,f,Ht);const z=A.intersectsBox(Jt),Z=A.intersectsBox(Ht);P=z&&Ze(k,E,n,t,i,o,s,l,a+1,A,!c)||Z&&Ze(k,v,n,t,i,o,s,l,a+1,A,!c),pt.releasePrimitive(A)}else if(O)if(_)P=Ze(r,C,t,n,i,s,o,a,l+1,h,c);else{const A=pt.getPrimitive();A.copy(hs).applyMatrix4(t);const E=Ce(r),v=Pe(r,d);we(E,f,Jt),we(v,f,Ht);const z=A.intersectsBox(Jt),Z=A.intersectsBox(Ht);P=z&&Ze(C,E,n,t,i,o,s,l,a+1,A,!c)||Z&&Ze(C,v,n,t,i,o,s,l,a+1,A,!c),pt.releasePrimitive(A)}}return P}const si=new Be,io=new S.Box3,ou={strategy:Nr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class ds{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,o=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=s?s.slice():null):(a.roots=i,a.index=o?o.array:null,a.indirectBuffer=s),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(s));const a=new ds(t,{...n,[Wi]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const h=t.getIndex();if(h===null){const c=new S.BufferAttribute(e.index,1,!1);t.setIndex(c)}else h.array!==i&&(h.array.set(i),h.needsUpdate=!0)}return a;function l(h){for(let c=0;c<h.length;c++){const u=h[c],p=new Uint32Array(u),f=new Uint16Array(u);for(let d=0,m=u.byteLength/Ie;d<m;d++){const g=Me*d,y=2*g;Se(y,f)||(p[g+6]=p[g+6]/Me-d)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...ou,[Wi]:!1},t),t.useSharedArrayBuffer&&!su())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Wi]||(vh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new S.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],o=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Ie;for(let h=0;h<l;h++){const c=Me*h,u=2*c;Se(u,a)&&(o[c+6]+=e)}}}}refit(e=null){return(this.indirect?Zh:Oh)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const h=a*2,c=Se(h,s);if(c){const u=i[a+6],p=s[h+14];e(l,c,new Float32Array(n,a*4,6),u,p)}else{const u=Ce(a),p=Pe(a,i),f=Hi(a,i);e(l,c,new Float32Array(n,a*4,6),f)||(o(u,l+1),o(p,l+1))}}}raycast(e,t=S.FrontSide,n=0,i=1/0){const s=this._roots,o=[],a=this.indirect?Yh:Fh;for(let l=0,h=s.length;l<h;l++)a(this,l,t,e,o,n,i);return o}raycastFirst(e,t=S.FrontSide,n=0,i=1/0){const s=this._roots;let o=null;const a=this.indirect?Jh:Vh;for(let l=0,h=s.length;l<h;l++){const c=a(this,l,t,e,n,i);c!=null&&(o==null||c.distance<o.distance)&&(o=c)}return o}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?Hh:jh;for(let o=0,a=i.length;o<a&&(n=s(this,o,e,t),!n);o++);return n}shapecast(e){const t=We.getPrimitive(),n=this.indirect?Rh:Lh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:o,intersectsTriangle:a}=e;if(o&&a){const u=o;o=(p,f,d,m,g)=>u(p,f,d,m,g)?!0:n(p,f,this,a,d,m,t)}else o||(a?o=(u,p,f,d)=>n(u,p,this,a,f,d,t):o=(u,p,f)=>f);let l=!1,h=0;const c=this._roots;for(let u=0,p=c.length;u<p;u++){const f=c[u];if(l=Ph(this,u,s,o,i,h),l)break;h+=f.byteLength/Ie}return We.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const o=We.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,h=this.indirect?d=>{const m=this.resolveTriangleIndex(d);_e(o,m*3,a,l)}:d=>{_e(o,d*3,a,l)},c=We.getPrimitive(),u=e.geometry.index,p=e.geometry.attributes.position,f=e.indirect?d=>{const m=e.resolveTriangleIndex(d);_e(c,m*3,u,p)}:d=>{_e(c,d*3,u,p)};if(s){const d=(m,g,y,w,b,x,_,D)=>{for(let P=y,k=y+w;P<k;P++){f(P),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let C=m,I=m+g;C<I;C++)if(h(C),o.needsUpdate=!0,s(o,c,C,P,b,x,_,D))return!0}return!1};if(i){const m=i;i=function(g,y,w,b,x,_,D,P){return m(g,y,w,b,x,_,D,P)?!0:d(g,y,w,b,x,_,D,P)}}else i=d}return ru(this,e,t,i)}intersectsBox(e,t){return si.set(e.min,e.max,t),si.needsUpdate=!0,this.shapecast({intersectsBounds:n=>si.intersectsBox(n),intersectsTriangle:n=>si.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?iu:Kh)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return Dh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{we(0,new Float32Array(n),io),e.union(io)}),e}}const so=1e-6,au=so*.5,ro=Math.pow(10,-Math.log10(so)),lu=au*ro;function tt(r){return~~(r*ro+lu)}function cu(r){return`${tt(r.x)},${tt(r.y)}`}function oo(r){return`${tt(r.x)},${tt(r.y)},${tt(r.z)}`}function hu(r){return`${tt(r.x)},${tt(r.y)},${tt(r.z)},${tt(r.w)}`}function uu(r,e,t){t.direction.subVectors(e,r).normalize();const n=r.dot(t.direction);return t.origin.copy(r).addScaledVector(t.direction,-n),t}function ao(){return typeof SharedArrayBuffer<"u"}function du(r){if(r.buffer instanceof SharedArrayBuffer)return r;const e=r.constructor,t=r.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function fu(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function pu(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=fu(t,n);r.setIndex(new S.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function mu(r){return r.index?r.index.count:r.attributes.position.count}function fs(r){return mu(r)/3}const gu=1e-8,yu=new S.Vector3;function wu(r){return~~(r/3)}function bu(r){return r%3}function lo(r,e){return r.start-e.start}function co(r,e){return yu.subVectors(e,r.origin).dot(r.direction)}function xu(r,e,t,n=gu){r.sort(lo),e.sort(lo);for(let a=0;a<r.length;a++){const l=r[a];for(let h=0;h<e.length;h++){const c=e[h];if(!(c.start>l.end)){if(l.end<c.start||c.end<l.start)continue;if(l.start<=c.start&&l.end>=c.end)s(c.end,l.end)||r.splice(a+1,0,{start:c.end,end:l.end,index:l.index}),l.end=c.start,c.start=0,c.end=0;else if(l.start>=c.start&&l.end<=c.end)s(l.end,c.end)||e.splice(h+1,0,{start:l.end,end:c.end,index:c.index}),c.end=l.start,l.start=0,l.end=0;else if(l.start<=c.start&&l.end<=c.end){const u=l.end;l.end=c.start,c.start=u}else if(l.start>=c.start&&l.end>=c.end){const u=c.end;c.end=l.start,l.start=u}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(c.index)||t.set(c.index,[]),t.get(l.index).push(c.index),t.get(c.index).push(l.index),o(c)&&(e.splice(h,1),h--),o(l)){r.splice(a,1),a--;break}}}i(r),i(e);function i(a){for(let l=0;l<a.length;l++)o(a[l])&&(a.splice(l,1),l--)}function s(a,l){return Math.abs(l-a)<n}function o(a){return Math.abs(a.end-a.start)<n}}const ho=1e-5,uo=1e-4;class _u{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,s=null;for(let l=0,h=t.length;l<h;l++){const c=t[l];if(o(c,e)&&o(c,n))continue;const u=a(c,e),p=a(c,n),f=Math.min(u,p);f<i&&(i=f,s=c)}return s;function o(l,h){const c=l.origin.distanceTo(h.origin)>ho;return l.direction.angleTo(h.direction)>uo||c}function a(l,h){const c=l.origin.distanceTo(h.origin),u=l.direction.angleTo(h.direction);return c/ho+u/uo}}}const ps=new S.Vector3,ms=new S.Vector3,ri=new S.Ray;function vu(r,e,t){const n=r.attributes,i=r.index,s=n.position,o=new Map,a=new Map,l=Array.from(e),h=new _u;for(let c=0,u=l.length;c<u;c++){const p=l[c],f=wu(p),d=bu(p);let m=3*f+d,g=3*f+(d+1)%3;i&&(m=i.getX(m),g=i.getX(g)),ps.fromBufferAttribute(s,m),ms.fromBufferAttribute(s,g),uu(ps,ms,ri);let y,w=h.findClosestRay(ri);w===null&&(w=ri.clone(),h.addRay(w)),a.has(w)||a.set(w,{forward:[],reverse:[],ray:w}),y=a.get(w);let b=co(w,ps),x=co(w,ms);b>x&&([b,x]=[x,b]),ri.direction.dot(w.direction)<0?y.reverse.push({start:b,end:x,index:p}):y.forward.push({start:b,end:x,index:p})}return a.forEach(({forward:c,reverse:u},p)=>{xu(c,u,o,t),c.length===0&&u.length===0&&a.delete(p)}),{disjointConnectivityMap:o,fragmentMap:a}}const Mu=new S.Vector2,gs=new S.Vector3,Su=new S.Vector4,ys=["","",""];class Au{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>~~(s/3)):[]}getDisjointSiblingEdgeIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>s%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:s}=this,o=t?b:w,a=new Map,{attributes:l}=e,h=t?Object.keys(l):null,c=e.index,u=l.position;let p=fs(e);const f=p;let d=0;n&&(d=e.drawRange.start,e.drawRange.count!==1/0&&(p=~~(e.drawRange.count/3)));let m=this.data;(!m||m.length<3*f)&&(m=new Int32Array(3*f)),m.fill(-1);let g=0,y=new Set;for(let x=d,_=p*3+d;x<_;x+=3){const D=x;for(let P=0;P<3;P++){let k=D+P;c&&(k=c.getX(k)),ys[P]=o(k)}for(let P=0;P<3;P++){const k=(P+1)%3,C=ys[P],I=ys[k],O=`${I}_${C}`;if(a.has(O)){const A=D+P,E=a.get(O);m[A]=E,m[E]=A,a.delete(O),g+=2,y.delete(E)}else{const A=`${C}_${I}`,E=D+P;a.set(A,E),y.add(E)}}}if(i){const{fragmentMap:x,disjointConnectivityMap:_}=vu(e,y,s);y.clear(),x.forEach(({forward:D,reverse:P})=>{D.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=x,this.disjointConnections=_,g=p*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=m;function w(x){return gs.fromBufferAttribute(u,x),oo(gs)}function b(x){let _="";for(let D=0,P=h.length;D<P;D++){const k=l[h[D]];let C;switch(k.itemSize){case 1:C=tt(k.getX(x));break;case 2:C=cu(Mu.fromBufferAttribute(k,x));break;case 3:C=oo(gs.fromBufferAttribute(k,x));break;case 4:C=hu(Su.fromBufferAttribute(k,x));break}_!==""&&(_+="|"),_+=C}return _}}}class oi extends S.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new S.Matrix4,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let s=0;s<16;s++)if(n[s]!==i[s])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=ao();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=du(s.array)}if(e.boundsTree||(pu(e,{useSharedArrayBuffer:n}),e.boundsTree=new ds(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Au(e)),!e.groupIndices){const i=fs(e),s=new Uint16Array(i),o=e.groups;for(let a=0,l=o.length;a<l;a++){const{start:h,count:c}=o[a];for(let u=h/3,p=(h+c)/3;u<p;u++)s[u]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Tu=1e-14,ws=new S.Vector3,fo=new S.Vector3,po=new S.Vector3;function mt(r,e=Tu){ws.subVectors(r.b,r.a),fo.subVectors(r.c,r.a),po.subVectors(r.b,r.c);const t=ws.angleTo(fo),n=ws.angleTo(po),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||r.a.distanceToSquared(r.b)<e||r.a.distanceToSquared(r.c)<e||r.b.distanceToSquared(r.c)<e}const bs=1e-10,gn=1e-10,Cu=1e-10,at=new S.Line3,be=new S.Line3,lt=new S.Vector3,xs=new S.Vector3,mo=new S.Vector3,ai=new S.Plane,_s=new Ge;class Pu{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new S.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class Du{constructor(){this.trianglePool=new Pu,this.triangles=[],this.normal=new S.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,o=e.length;s<o;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(lt).dot(i))>bs)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=n.getTriangle();l.copy(a),t.push(l)}else{e.getNormal(i);const s=n.getTriangle();s.copy(e),t.push(s)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(xs).normalize(),Math.abs(1-Math.abs(xs.dot(t)))<Cu){this.coplanarTriangleUsed=!0;for(let s=0,o=n.length;s<o;s++){const a=n[s];a.coplanarCount=0}const i=[e.a,e.b,e.c];for(let s=0;s<3;s++){const o=(s+1)%3,a=i[s],l=i[o];lt.subVectors(l,a).normalize(),mo.crossVectors(xs,lt),ai.setFromNormalAndCoplanarPoint(mo,a),this.splitByPlane(ai,e)}}else e.getPlane(ai),this.splitByPlane(ai,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;_s.copy(t),_s.needsUpdate=!0;for(let s=0,o=n.length;s<o;s++){const a=n[s];if(!_s.intersectsTriangle(a,at,!0))continue;const{a:l,b:h,c}=a;let u=0,p=-1,f=!1,d=[],m=[];const g=[l,h,c];for(let y=0;y<3;y++){const w=(y+1)%3;at.start.copy(g[y]),at.end.copy(g[w]);const b=e.distanceToPoint(at.start),x=e.distanceToPoint(at.end);if(Math.abs(b)<gn&&Math.abs(x)<gn){f=!0;break}if(b>0?d.push(y):m.push(y),Math.abs(b)<gn)continue;let _=!!e.intersectLine(at,lt);!_&&Math.abs(x)<gn&&(lt.copy(at.end),_=!0),_&&!(lt.distanceTo(at.start)<bs)&&(lt.distanceTo(at.end)<bs&&(p=y),u===0?be.start.copy(lt):be.end.copy(lt),u++)}if(!f&&u===2&&be.distance()>gn)if(p!==-1){p=(p+1)%3;let y=0;y===p&&(y=(y+1)%3);let w=y+1;w===p&&(w=(w+1)%3);const b=i.getTriangle();b.a.copy(g[w]),b.b.copy(be.end),b.c.copy(be.start),mt(b)||n.push(b),a.a.copy(g[y]),a.b.copy(be.start),a.c.copy(be.end),mt(a)&&(n.splice(s,1),s--,o--)}else{const y=d.length>=2?m[0]:d[0];if(y===0){let D=be.start;be.start=be.end,be.end=D}const w=(y+1)%3,b=(y+2)%3,x=i.getTriangle(),_=i.getTriangle();g[w].distanceToSquared(be.start)<g[b].distanceToSquared(be.end)?(x.a.copy(g[w]),x.b.copy(be.start),x.c.copy(be.end),_.a.copy(g[w]),_.b.copy(g[b]),_.c.copy(be.start)):(x.a.copy(g[b]),x.b.copy(be.start),x.c.copy(be.end),_.a.copy(g[w]),_.b.copy(g[b]),_.c.copy(be.end)),a.a.copy(g[y]),a.b.copy(be.end),a.c.copy(be.start),mt(x)||n.push(x),mt(_)||n.push(_),mt(a)&&(n.splice(s,1),s--,o--)}else u===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function ku(r){return r=~~r,r+4-r%4}class go{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,n=ao()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(ku(e*t.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,s=e.length;i<s;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class Iu{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let s=0;s<t;s++){const o=n[s];i+=o[e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const i={};t.push(i);for(const s in n){const o=n[s],a=new go(o.type);a.itemSize=o.itemSize,a.normalized=o.normalized,i[s]=a}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){const{groupAttributes:s}=this,a=s[0][e];if(a){if(a.type!==t)for(let l=0,h=s.length;l<h;l++){const c=s[l][e];c.setType(t),c.itemSize=n,c.normalized=i}}else for(let l=0,h=s.length;l<h;l++){const c=new go(t);c.itemSize=n,c.normalized=i,s[l][e]=c}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const n in t)t[n].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class yo{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const Bu=0,Eu=1,Lu=2,wo=3,Ou=4,bo=5,xo=6,qe=new S.Ray,_o=new S.Matrix4,Ee=new S.Triangle,ct=new S.Vector3,vo=new S.Vector4,Mo=new S.Vector4,So=new S.Vector4,vs=new S.Vector4,li=new S.Vector4,ci=new S.Vector4,Ao=new S.Line3,Ms=new S.Vector3,Ss=1e-8,zu=1e-15,Dt=-1,kt=1,hi=-2,ui=2,yn=0,It=1,As=2,Nu=1e-14;let di=null;function To(r){di=r}function Co(r,e){r.getMidpoint(qe.origin),r.getNormal(qe.direction);const t=e.raycastFirst(qe,S.DoubleSide);return!!(t&&qe.direction.dot(t.face.normal)>0)?Dt:kt}function Ru(r,e){function t(){return Math.random()-.5}r.getNormal(Ms),qe.direction.copy(Ms),r.getMidpoint(qe.origin);const n=3;let i=0,s=1/0;for(let o=0;o<n;o++){qe.direction.x+=t()*Ss,qe.direction.y+=t()*Ss,qe.direction.z+=t()*Ss,qe.direction.multiplyScalar(-1);const a=e.raycastFirst(qe,S.DoubleSide);if(!!(a&&qe.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=zu)return a.face.normal.dot(Ms)>0?ui:hi;if(i/n>.5||(o-i+1)/n>.5)break}return i/n>.5?Dt:kt}function Fu(r,e){const t=new yo,n=new yo;return _o.copy(r.matrixWorld).invert().multiply(e.matrixWorld),r.geometry.boundsTree.bvhcast(e.geometry.boundsTree,_o,{intersectsTriangles(i,s,o,a){if(!mt(i)&&!mt(s)){let l=i.intersectsTriangle(s,Ao,!0);if(!l){const h=i.plane,c=s.plane,u=h.normal,p=c.normal;u.dot(p)===1&&Math.abs(h.constant-c.constant)<Nu&&(l=!0)}if(l){let h=r.geometry.boundsTree.resolveTriangleIndex(o),c=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(h,c),n.add(c,h),di&&(di.addEdge(Ao),di.addIntersectingTriangles(o,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function Uu(r,e,t,n,i,s,o=!1){const a=t.attributes,l=t.index,h=r*3,c=l.getX(h+0),u=l.getX(h+1),p=l.getX(h+2);for(const f in s){const d=a[f],m=s[f];if(!(f in a))throw new Error(`CSG Operations: Attribute ${f} not available on geometry.`);const g=d.itemSize;f==="position"?(Ee.a.fromBufferAttribute(d,c).applyMatrix4(n),Ee.b.fromBufferAttribute(d,u).applyMatrix4(n),Ee.c.fromBufferAttribute(d,p).applyMatrix4(n),Ts(Ee.a,Ee.b,Ee.c,e,3,m,o)):f==="normal"?(Ee.a.fromBufferAttribute(d,c).applyNormalMatrix(i),Ee.b.fromBufferAttribute(d,u).applyNormalMatrix(i),Ee.c.fromBufferAttribute(d,p).applyNormalMatrix(i),o&&(Ee.a.multiplyScalar(-1),Ee.b.multiplyScalar(-1),Ee.c.multiplyScalar(-1)),Ts(Ee.a,Ee.b,Ee.c,e,3,m,o,!0)):(vo.fromBufferAttribute(d,c),Mo.fromBufferAttribute(d,u),So.fromBufferAttribute(d,p),Ts(vo,Mo,So,e,g,m,o))}}function Vu(r,e,t,n,i,s,o,a=!1){Cs(r,n,i,s,o,a),Cs(a?t:e,n,i,s,o,a),Cs(a?e:t,n,i,s,o,a)}function Po(r,e,t=!1){switch(r){case Bu:if(e===kt||e===ui&&!t)return It;break;case Eu:if(t){if(e===Dt)return yn}else if(e===kt||e===hi)return It;break;case Lu:if(t){if(e===kt||e===hi)return It}else if(e===Dt)return yn;break;case Ou:if(e===Dt)return yn;if(e===kt)return It;break;case wo:if(e===Dt||e===ui&&!t)return It;break;case bo:if(!t&&(e===kt||e===hi))return It;break;case xo:if(!t&&(e===Dt||e===ui))return It;break;default:throw new Error(`Unrecognized CSG operation enum "${r}".`)}return As}function Ts(r,e,t,n,i,s,o=!1,a=!1){const l=h=>{s.push(h.x),i>1&&s.push(h.y),i>2&&s.push(h.z),i>3&&s.push(h.w)};vs.set(0,0,0,0).addScaledVector(r,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),li.set(0,0,0,0).addScaledVector(r,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),ci.set(0,0,0,0).addScaledVector(r,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(vs.normalize(),li.normalize(),ci.normalize()),l(vs),o?(l(ci),l(li)):(l(li),l(ci))}function Cs(r,e,t,n,i,s=!1){for(const o in i){const a=e[o],l=i[o];if(!(o in e))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const h=a.itemSize;o==="position"?(ct.fromBufferAttribute(a,r).applyMatrix4(t),l.push(ct.x,ct.y,ct.z)):o==="normal"?(ct.fromBufferAttribute(a,r).applyNormalMatrix(n),s&&ct.multiplyScalar(-1),l.push(ct.x,ct.y,ct.z)):(l.push(a.getX(r)),h>1&&l.push(a.getY(r)),h>2&&l.push(a.getZ(r)),h>3&&l.push(a.getW(r)))}}class ju{constructor(e){this.triangle=new S.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new S.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class Do{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new ju(t)),s[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(e!==null)e in t&&n.push(t[e].triangle);else for(const i in t)n.push(t[i].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(n=>parseInt(n)):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,s=[],o=a=>{if(n[a])if(t!==null)n[a].intersects[t]&&s.push(n[a].intersects[t]);else{const l=n[a].intersects;for(const h in l)i.has(h)||(i.add(h),s.push(l[h]))}};if(e!==null)o(e);else for(const a in n)o(a);return s}reset(){this.data={}}}class Gu{constructor(){this.enabled=!1,this.triangleIntersectsA=new Do,this.triangleIntersectsB=new Do,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:s,triangleIntersectsB:o}=this;s.addTriangleIntersection(e,t,n,i),o.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),To(this))}complete(){this.enabled&&To(null)}}const gt=new S.Matrix4,fi=new S.Matrix3,Bt=new S.Triangle,pi=new S.Triangle,yt=new S.Triangle,mi=new S.Triangle,Ye=[],Et=[];function Wu(r){for(const e of r)return e}function Xu(r,e,t,n,i,s={}){const{useGroups:o=!0}=s,{aIntersections:a,bIntersections:l}=Fu(r,e),h=[];let c=null,u;return u=o?0:-1,ko(r,e,a,t,!1,n,i,u),Io(r,e,a,t,!1,i,u),t.findIndex(f=>f!==xo&&f!==bo)!==-1&&(u=o?r.geometry.groups.length||1:-1,ko(e,r,l,t,!0,n,i,u),Io(e,r,l,t,!0,i,u)),Ye.length=0,Et.length=0,{groups:h,materials:c}}function ko(r,e,t,n,i,s,o,a=0){const l=r.matrixWorld.determinant()<0;gt.copy(e.matrixWorld).invert().multiply(r.matrixWorld),fi.getNormalMatrix(r.matrixWorld).multiplyScalar(l?-1:1);const h=r.geometry.groupIndices,c=r.geometry.index,u=r.geometry.attributes.position,p=e.geometry.boundsTree,f=e.geometry.index,d=e.geometry.attributes.position,m=t.ids,g=t.intersectionSet;for(let y=0,w=m.length;y<w;y++){const b=m[y],x=a===-1?0:h[b]+a,_=3*b,D=c.getX(_+0),P=c.getX(_+1),k=c.getX(_+2);Bt.a.fromBufferAttribute(u,D).applyMatrix4(gt),Bt.b.fromBufferAttribute(u,P).applyMatrix4(gt),Bt.c.fromBufferAttribute(u,k).applyMatrix4(gt),s.reset(),s.initialize(Bt);const C=g[b];for(let O=0,A=C.length;O<A;O++){const E=3*C[O],v=f.getX(E+0),z=f.getX(E+1),Z=f.getX(E+2);pi.a.fromBufferAttribute(d,v),pi.b.fromBufferAttribute(d,z),pi.c.fromBufferAttribute(d,Z),s.splitByTriangle(pi)}const I=s.triangles;for(let O=0,A=I.length;O<A;O++){const E=I[O],v=s.coplanarTriangleUsed?Ru(E,p):Co(E,p);Ye.length=0,Et.length=0;for(let z=0,Z=n.length;z<Z;z++){const W=Po(n[z],v,i);W!==As&&(Et.push(W),Ye.push(o[z].getGroupAttrSet(x)))}if(Ye.length!==0){Bt.getBarycoord(E.a,mi.a),Bt.getBarycoord(E.b,mi.b),Bt.getBarycoord(E.c,mi.c);for(let z=0,Z=Ye.length;z<Z;z++){const W=Ye[z],G=Et[z]===yn;Uu(b,mi,r.geometry,r.matrixWorld,fi,W,l!==G)}}}}return m.length}function Io(r,e,t,n,i,s,o=0){const a=r.matrixWorld.determinant()<0;gt.copy(e.matrixWorld).invert().multiply(r.matrixWorld),fi.getNormalMatrix(r.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,h=r.geometry.groupIndices,c=r.geometry.index,u=r.geometry.attributes,p=u.position,f=[],d=r.geometry.halfEdges,m=new Set,g=fs(r.geometry);for(let y=0,w=g;y<w;y++)y in t.intersectionSet||m.add(y);for(;m.size>0;){const y=Wu(m);m.delete(y),f.push(y);const w=3*y,b=c.getX(w+0),x=c.getX(w+1),_=c.getX(w+2);yt.a.fromBufferAttribute(p,b).applyMatrix4(gt),yt.b.fromBufferAttribute(p,x).applyMatrix4(gt),yt.c.fromBufferAttribute(p,_).applyMatrix4(gt);const D=Co(yt,l);Et.length=0,Ye.length=0;for(let P=0,k=n.length;P<k;P++){const C=Po(n[P],D,i);C!==As&&(Et.push(C),Ye.push(s[P]))}for(;f.length>0;){const P=f.pop();for(let k=0;k<3;k++){const C=d.getSiblingTriangleIndex(P,k);C!==-1&&m.has(C)&&(f.push(C),m.delete(C))}if(Ye.length!==0){const k=3*P,C=c.getX(k+0),I=c.getX(k+1),O=c.getX(k+2),A=o===-1?0:h[P]+o;if(yt.a.fromBufferAttribute(p,C),yt.b.fromBufferAttribute(p,I),yt.c.fromBufferAttribute(p,O),!mt(yt))for(let E=0,v=Ye.length;E<v;E++){const z=Et[E],Z=Ye[E].getGroupAttrSet(A),W=z===yn;Vu(C,I,O,u,r.matrixWorld,fi,Z,W!==a)}}}}}function qu(r){for(let e=0;e<r.length-1;e++){const t=r[e],n=r[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,s=n.start+n.count;n.start=i,n.count=s-i,r.splice(e,1),e--}}}function Ku(r,e,t,n){t.clear();const i=r.attributes;for(let s=0,o=n.length;s<o;s++){const a=n[s],l=i[a];t.initializeArray(a,l.array.constructor,l.itemSize,l.normalized)}for(const s in t.attributes)n.includes(s)||t.delete(s);for(const s in e.attributes)n.includes(s)||(e.deleteAttribute(s),e.dispose())}function Zu(r,e,t){let n=!1,i=-1;const s=r.attributes,o=e.groupAttributes[0];for(const l in o){const h=e.getTotalLength(l),c=e.getType(l),u=e.getItemSize(l),p=e.getNormalized(l);let f=s[l];(!f||f.array.length<h)&&(f=new S.BufferAttribute(new c(h),u,p),r.setAttribute(l,f),n=!0);let d=0;for(let m=0,g=Math.min(t.length,e.groupCount);m<g;m++){const y=t[m].index,{array:w,type:b,length:x}=e.groupAttributes[y][l],_=new b(w.buffer,0,x);f.array.set(_,d),d+=_.length}f.needsUpdate=!0,i=h/f.itemSize}if(r.index){const l=r.index.array;if(l.length<i)r.index=null,n=!0;else for(let h=0,c=l.length;h<c;h++)l[h]=h}let a=0;r.clearGroups();for(let l=0,h=Math.min(t.length,e.groupCount);l<h;l++){const{index:c,materialIndex:u}=t[l],p=e.getCount(c);p!==0&&(r.addGroup(a,p,u),a+=p)}r.setDrawRange(0,i),r.boundsTree=null,n&&r.dispose()}function Bo(r,e){let t=e;return Array.isArray(e)||(t=[],r.forEach(n=>{t[n.materialIndex]=e})),t}class Yu{constructor(){this.triangleSplitter=new Du,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new Gu}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,n,i=new oi){let s=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],s=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:o,attributeData:a,attributes:l,useGroups:h,consolidateGroups:c,debug:u}=this;for(;a.length<i.length;)a.push(new Iu);i.forEach((y,w)=>{Ku(e.geometry,y.geometry,a[w],l)}),u.init(),Xu(e,t,n,o,a,{useGroups:h}),u.complete();const p=this.getGroupRanges(e.geometry),f=Bo(p,e.material),d=this.getGroupRanges(t.geometry),m=Bo(d,t.material);d.forEach(y=>y.materialIndex+=f.length);let g=[...p,...d].map((y,w)=>({...y,index:w}));if(h){const y=[...f,...m];c&&(g=g.map(b=>{const x=y[b.materialIndex];return b.materialIndex=y.indexOf(x),b}).sort((b,x)=>b.materialIndex-x.materialIndex));const w=[];for(let b=0,x=y.length;b<x;b++){let _=!1;for(let D=0,P=g.length;D<P;D++){const k=g[D];k.materialIndex===b&&(_=!0,k.materialIndex=w.length)}_&&w.push(y[b])}i.forEach(b=>{b.material=w})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=f[0]});return i.forEach((y,w)=>{const b=y.geometry;Zu(b,a[w],g),c&&qu(b.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new oi){e.updateMatrixWorld(!0);const n=(s,o)=>{const a=s.children;for(let l=0,h=a.length;l<h;l++){const c=a[l];c.isOperationGroup?n(c,o):o(c)}},i=s=>{const o=s.children;let a=!1;for(let h=0,c=o.length;h<c;h++){const u=o[h];a=i(u)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let h;return n(s,c=>{h?h=this.evaluate(h,c,c.operation):h=this.evaluate(s,c,c.operation)}),s._cachedGeometry=h.geometry,s._cachedMaterials=h.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class $u{engine;planeObjects=[];planes=[];isActive=!1;evaluator;geometryCache=new Map;sectionMeshes=new Map;planeGroup;planeSize=1e3;sourceMeshes=new Map;planeThickness=.01;updateThrottleTime=100;lastUpdateTime=0;pendingUpdate=!1;updateTimer=null;cacheExpireTime=3e4;planeStates=new Map;constructor(e,t={}){this.engine=e,this.evaluator=new Yu,this.planeGroup=new T.Group,this.planeGroup.name="CSG_ClippingPlanes_Optimized",t.updateThrottleTime!==void 0&&(this.updateThrottleTime=t.updateThrottleTime),t.cacheExpireTime!==void 0&&(this.cacheExpireTime=t.cacheExpireTime),t.planeThickness!==void 0&&(this.planeThickness=t.planeThickness),this.evaluator.attributes=["position","normal"],this.evaluator.useGroups=!1}init(){this.calculateSceneSize(),this.engine.scene.add(this.planeGroup),this.planes.forEach((e,t)=>{const n=this.createEmptySectionMesh(e,t);this.planeGroup.add(n),this.sectionMeshes.set(`plane_${t}`,n),this.planeObjects.push(n),this.planeStates.set(t,{constant:e.constant,normal:e.normal.clone()})})}createEmptySectionMesh(e,t){const n=new T.BufferGeometry,i=new T.MeshStandardMaterial({color:new T.Color(33023),metalness:.1,roughness:.75,side:T.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((o,a)=>a!==t)}),s=new T.Mesh(n,i);return s.name=`CSG_Section_Optimized_${t}`,s.visible=!1,s.renderOrder=t+1,s}active(){this.isActive=!0,this.requestUpdate(),this.planeObjects.forEach(e=>{e.visible=!0})}disActive(){this.isActive=!1,this.planeObjects.forEach(e=>{e.visible=!1}),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}setSourceMeshes(e){this.sourceMeshes.clear(),e.forEach(t=>{const n=t.uuid;this.sourceMeshes.set(n,t)}),this.isActive&&this.requestUpdate()}addSourceMesh(e){const t=e.uuid;this.sourceMeshes.has(t)||(this.sourceMeshes.set(t,e),this.isActive&&this.requestUpdate())}removeSourceMesh(e){const t=e.uuid;this.sourceMeshes.delete(t)&&(this.clearMeshCache(t),this.isActive&&this.requestUpdate())}requestUpdate(){if(!this.isActive)return;const e=Date.now(),t=e-this.lastUpdateTime;t>=this.updateThrottleTime?(this.lastUpdateTime=e,this.pendingUpdate=!1):(this.pendingUpdate=!0,this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.pendingUpdate&&this.isActive&&(this.lastUpdateTime=Date.now(),this.pendingUpdate=!1),this.updateTimer=null},this.updateThrottleTime-t))}updateAllSections(){this.isActive&&(this.planes.forEach((e,t)=>{if(Math.abs(e.constant)<99999)this.hasPlaneChanged(t,e)&&(this.updateSection(e,t),this.updatePlaneState(t,e));else{const n=this.sectionMeshes.get(`plane_${t}`);n&&(n.visible=!1)}}),this.cleanExpiredCache())}hasPlaneChanged(e,t){const n=this.planeStates.get(e);if(!n)return!0;const i=Math.abs(n.constant-t.constant)>1e-4,s=!n.normal.equals(t.normal);return i||s}updatePlaneState(e,t){this.planeStates.set(e,{constant:t.constant,normal:t.normal.clone()})}getPlaneHash(e){const t=e.normal,n=e.constant;return`${t.x.toFixed(4)}_${t.y.toFixed(4)}_${t.z.toFixed(4)}_${n.toFixed(4)}`}getCacheKey(e,t){return`${e}_plane_${t}`}updateSection(e,t){const n=this.sectionMeshes.get(`plane_${t}`);if(!n)return;const i=this.getPlaneHash(e),s=[];if(this.sourceMeshes.forEach((o,a)=>{const l=this.getCacheKey(a,t),h=this.geometryCache.get(l);if(h&&h.planeHash===i)s.push(h.geometry.clone()),h.timestamp=Date.now();else try{const c=this.createPlaneBrush(e),u=new oi(o.geometry);o.updateMatrixWorld(!0),u.matrix.copy(o.matrixWorld),u.updateMatrixWorld();const p=this.evaluator.evaluate(c,u,wo);p&&p.geometry.attributes.position.count>0?(s.push(p.geometry),this.geometryCache.set(l,{geometry:p.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(c){console.warn(`CSG intersection failed for mesh ${a}:`,c)}}),s.length>0){const o=this.mergeGeometries(s);n.geometry&&n.geometry.dispose(),n.geometry=o,n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),n.updateMatrixWorld()}else n.visible=!1;s.forEach(o=>o.dispose())}clearMeshCache(e){const t=[];this.geometryCache.forEach((n,i)=>{i.startsWith(e)&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}cleanExpiredCache(){const e=Date.now(),t=[];this.geometryCache.forEach((n,i)=>{e-n.timestamp>this.cacheExpireTime&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}clearAllCache(){this.geometryCache.forEach(e=>{e.geometry.dispose()}),this.geometryCache.clear()}createPlaneBrush(e){const t=new T.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new T.Quaternion().setFromUnitVectors(new T.Vector3(0,-1,0),e.normal));const n=new T.Mesh(t),i=new oi(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new T.BufferGeometry,n=[],i=[],s=[];let o=0;return e.forEach(a=>{const l=a.attributes.position,h=a.attributes.normal;for(let c=0;c<l.count;c++)n.push(l.getX(c),l.getY(c),l.getZ(c));if(h)for(let c=0;c<h.count;c++)i.push(h.getX(c),h.getY(c),h.getZ(c));if(a.index)for(let c=0;c<a.index.count;c++)s.push(a.index.getX(c)+o);o+=l.count}),t.setAttribute("position",new T.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new T.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new T.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new T.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new T.Vector3),n=Math.max(t.x,t.y,t.z);this.planeSize=n*3}}update(){this.isActive&&this.pendingUpdate&&!this.updateTimer&&this.requestUpdate()}dispose(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.clearAllCache(),this.planeObjects.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.sectionMeshes.clear(),this.planeObjects=[],this.sourceMeshes.clear(),this.planeGroup.parent&&this.planeGroup.parent.remove(this.planeGroup)}setSectionColor(e){this.planeObjects.forEach(t=>{t.material instanceof T.MeshStandardMaterial&&t.material.color.set(e)})}getCacheStats(){return{cacheSize:this.geometryCache.size,sourceMeshCount:this.sourceMeshes.size,sectionMeshCount:this.sectionMeshes.size}}setPlaneThickness(e){if(e<=0){console.warn("Plane thickness must be positive");return}this.planeThickness=e,this.clearAllCache(),this.isActive&&this.requestUpdate()}getPlaneThickness(){return this.planeThickness}showSections(){this.sectionMeshes.forEach(e=>{e.geometry?.attributes.position?.count&&e.geometry.attributes.position.count>0&&(e.visible=!0)})}hideSections(){this.sectionMeshes.forEach(e=>{e.visible=!1})}showSection(){this.planeGroup.visible=!0}hideSection(){this.planeGroup.visible=!1}toggleSectionsVisibility(){let e=!1;return this.sectionMeshes.forEach(t=>{t.visible&&(e=!0)}),e?(this.hideSections(),!1):(this.showSections(),!0)}toggleSectionVisibility(e){const t=this.sectionMeshes.get(`plane_${e}`);return t?(t.visible=!t.visible,t.visible):!1}}class Ju{engine;isActive=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;csgClipping=null;useCsgClipping=!1;constructor(e,t){this.engine=e,this.meshs=[],t?.useCsgClipping!==void 0&&(this.useCsgClipping=t.useCsgClipping),this.useCsgClipping&&this.initCsgClipping()}initCsgClipping(){this.csgClipping=new $u(this.engine,{updateThrottleTime:150,cacheExpireTime:45e3}),this.csgClipping.planes=this.engine.sectionPlane,this.csgClipping.init()}active(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0,this.init())}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive(),this.csgClipping&&this.csgClipping.disActive(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})}),this.engine.interactionModule.init(),this.engine.interactionModule.active()}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(){let e=this.engine.octreeBox.getBoundingBox();this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const n=new T.Plane;n.setFromNormalAndCoplanarPoint(new T.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new T.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new T.Plane;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0,this.csgClipping&&this.isActive}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new T.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.pickMesh.name=="前"||this.pickMesh.name=="左"||this.pickMesh.name=="底"?this.box.min=this.box_.min.clone().add(this.pickNormal.clone().setLength(i)):this.box.max=this.box_.max.clone().add(this.pickNormal.clone().setLength(i)),this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){let e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=(this.box.min.x-this.maxBox.min.x)/e*100,s=(this.box.max.x-this.maxBox.min.x)/e*100,o=(this.box.min.y-this.maxBox.min.y)/t*100,a=(this.box.max.y-this.maxBox.min.y)/t*100,l=(this.box.min.z-this.maxBox.min.z)/n*100,h=(this.box.max.z-this.maxBox.min.z)/n*100;i<0&&(i=0),s<0&&(s=0),o<0&&(o=0),a<0&&(a=0),l<0&&(l=0),h<0&&(h=0),i>100&&(i=100),s>100&&(s=100),o>100&&(o=100),a>100&&(a=100),l>100&&(l=100),h>100&&(h=100);let c={x:{min:i,max:s},y:{min:o,max:a},z:{min:l,max:h}};this.engine.events.trigger(ve.SectionMove,c)}updata_face(e){let t=this,n=[new T.Vector3(e.min.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.min.z),new T.Vector3(e.min.x,e.max.y,e.min.z)],i=[new T.Vector3(e.min.x,e.min.y,e.max.z),new T.Vector3(e.max.x,e.min.y,e.max.z),new T.Vector3(e.max.x,e.max.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.max.z)],s=[new T.Vector3(e.max.x,e.min.y,e.max.z),new T.Vector3(e.max.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.max.z)],o=[new T.Vector3(e.min.x,e.min.y,e.min.z),new T.Vector3(e.min.x,e.min.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.min.z)],a=[new T.Vector3(e.min.x,e.max.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.max.z)],l=[new T.Vector3(e.min.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.min.y,e.max.z),new T.Vector3(e.min.x,e.min.y,e.max.z)];h(n,new T.Vector3(0,0,-1),"前"),h(i,new T.Vector3(0,0,1),"后"),h(s,new T.Vector3(1,0,0),"右"),h(o,new T.Vector3(-1,0,0),"左"),h(a,new T.Vector3(0,1,0),"顶"),h(l,new T.Vector3(0,-1,0),"底");function h(c,u,p){const f=new T.BufferGeometry,d=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z]),m=[0,1,2,0,2,3];f.setAttribute("position",new T.BufferAttribute(d,3)),f.setIndex(m);let g=t.engine.scene.children.find(D=>D.type=="Group"&&D.name=="ClippingBox");g==null&&(g=new T.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(D=>D.name==p);if(y==null){const D=new T.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:T.DoubleSide}),P=new T.Mesh(f,D);P.normal=u,P.name=p,g.add(P),t.meshs.push(P)}else y.geometry=f;const w=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z,c[0].x,c[0].y,c[0].z]);let b=new T.LineBasicMaterial({color:255}),x=new T.BufferGeometry;x.setAttribute("position",new T.BufferAttribute(w,3));let _=t.meshs.find(D=>D.name==p+"Line");_==null&&(_=new T.Line(x,b),_.name=p+"Line",g.add(_),t.meshs.push(_)),_.geometry=x,_.material=b,p=="前"||p=="左"||p=="底"?t.engine.sectionPlane.find(D=>D.name==p).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.min):t.engine.sectionPlane.find(D=>D.name==p).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.max),t.engine.scene.children.filter(D=>D.type=="Mesh"&&D.url).forEach(D=>{D.material&&Array.isArray(D.material)?D.material.forEach(P=>{P.clippingPlanes=t.engine.sectionPlane}):D.material.clippingPlanes=t.engine.sectionPlane})}}}class Hu{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new T.Vector3(0,0,1);distance=0;center=null;current_center=null;constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!0)})}),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active();let e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive();const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!1)})})}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(0)}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,n){this.angleX=e,this.angleY=t,this.angleZ=n,this.normal=new T.Vector3(0,1,0).applyAxisAngle(new T.Vector3(1,0,0),e).applyAxisAngle(new T.Vector3(0,0,1),t).applyAxisAngle(new T.Vector3(0,1,0),n),this.normal.normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e,this.distance=t,this.updata_face(t)}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){let t=this,n=t.engine.scene.children.find(C=>C.type=="Group"&&C.name=="ClippingBox");n==null&&(n=new T.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new T.Vector3(1,0,0),s=new T.Vector3(0,1,0),o=new T.Vector3(0,0,1),a,l,h=this.normal.clone().normalize(),c=Math.abs(h.dot(i)),u=Math.abs(h.dot(s)),p=Math.abs(h.dot(o));c<=u&&c<=p?a=i:u<=c&&u<=p?a=s:a=o,a=a.clone().sub(h.clone().multiplyScalar(a.dot(h))).normalize(),l=new T.Vector3().crossVectors(h,a).normalize();let f=null;this.center==null?(f=new T.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),this.center=f.clone()):f=this.center.clone();let d=this.box.max.x-this.box.min.x,m=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*d,Math.abs(a.y)*m,Math.abs(a.z)*g),w=Math.max(Math.abs(l.x)*d,Math.abs(l.y)*m,Math.abs(l.z)*g),b=f.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-w/2)),x=f.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-w/2)),_=f.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(w/2)),D=f.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(w/2));b.add(h.clone().multiplyScalar(e)),x.add(h.clone().multiplyScalar(e)),_.add(h.clone().multiplyScalar(e)),D.add(h.clone().multiplyScalar(e)),this.current_center=f.clone().add(h.clone().multiplyScalar(e)),k([b,x,_,D],h,"face");function k(C,I,O){const A=new T.BufferGeometry,E=new Float32Array([C[0].x,C[0].y,C[0].z,C[1].x,C[1].y,C[1].z,C[2].x,C[2].y,C[2].z,C[3].x,C[3].y,C[3].z]),v=[0,1,2,0,2,3];A.setAttribute("position",new T.BufferAttribute(E,3)),A.setIndex(v);let z=t.meshs.find(te=>te.name==O);if(z==null){const te=new T.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:T.DoubleSide}),F=new T.Mesh(A,te);F.normal=I,F.name=O,n.add(F),t.meshs.push(F)}else z.geometry=A;const Z=new Float32Array([C[0].x,C[0].y,C[0].z,C[1].x,C[1].y,C[1].z,C[2].x,C[2].y,C[2].z,C[3].x,C[3].y,C[3].z,C[0].x,C[0].y,C[0].z]);let W=new T.LineBasicMaterial({color:255}),Q=new T.BufferGeometry;Q.setAttribute("position",new T.BufferAttribute(Z,3));let G=t.meshs.find(te=>te.name==O+"Line");G==null&&(G=new T.Line(Q,W),G.name=O+"Line",n.add(G),t.meshs.push(G)),G.geometry=Q,G.material=W,t.engine.sectionPlane.find(te=>te.name==O).setFromNormalAndCoplanarPoint(I.clone().setLength(t.direction),C[0])}}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.center=this.current_center.clone(),this.pickNormal.y==0){const n=new T.Plane;n.setFromNormalAndCoplanarPoint(new T.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new T.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new T.Plane;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new T.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.distance=i,this.updata_face(this.distance)}}}}class Qu{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){let t=e.catch.normal;this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class ed{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new T.Plane(new T.Vector3(0,0,1),1e5);t.name="前";let n=new T.Plane(new T.Vector3(0,0,1),1e5);n.name="左";let i=new T.Plane(new T.Vector3(0,0,1),1e5);i.name="后";let s=new T.Plane(new T.Vector3(0,0,1),1e5);s.name="右";let o=new T.Plane(new T.Vector3(0,0,1),1e5);o.name="顶";let a=new T.Plane(new T.Vector3(0,0,1),1e5);a.name="底";let l=new T.Plane(new T.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,o,a,l]}init(){this.sectionBox=new Ju(this.engine),this.sectionFace=new Hu(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let o=this.engine.models.find(a=>a.url===s.url);s.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let n=i(t);this.sectionBox.setBox(n);function i(s){let o=new T.Vector3(1e8,1e9,1e10),a=new T.Vector3(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new T.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:n,minY:i,minZ:s,maxX:o,maxY:a,maxZ:l})}active(e){if(this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new Qu(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),s=n.position.clone().sub(i.min.clone().add(i.max.clone()).setLength(.5)),o=new T.Vector3(n.dir.x,n.dir.y,n.dir.z),a=s.dot(o);this.sectionFace.setFaceNormal(n.dir,a)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled()}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=""}}class td{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class nd{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof T.Mesh){const s=i.geometry;if(s&&s.attributes){const o=s.attributes.position;if(o){const a=o.count;e+=a;let l=0;s.index?l=s.index.count/3:l=a/3,t+=l,n++}}}}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class id{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(o=>o.url===e);i.properties==null&&Mr(e+"/property",o=>{let a=JSON.parse(o);i.properties=a,setTimeout(()=>{s(a,t,n)},100)}),s(i.properties,t,n);function s(o,a,l){let h=[],c=o.models[a.toString()||""],u=c.map(p=>p[0]);u=u.filter((p,f)=>u.indexOf(p)===f),u.forEach(p=>{let f={name:o.categorys[p],children:[]};h.push(f),c.filter(d=>d[0]===p).forEach(d=>{f.children.push({name:o.names[d[1]],value:o.values[d[2]]})})}),l?.({properties:h,materials:h})}}}class sd{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(o=>o.url==e);return n?n.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let o={url:s.url,ids:[]};i.push(o),s.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}}class rd{engine;isActive=!1;groupEdge;material;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new T.LineBasicMaterial({color:"#000000",depthTest:!0})}active(){this.isActive=!0,this.groupEdge.visible=!0,this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1}show(){this.engine.engineStatus.models.forEach(e=>{if(!this.groupEdge.children.find(n=>n.url==e.url)){let n=e.info,i=[],s=new Map;n.modelEdge.forEach(l=>{let h=i.length;for(let c=0;c<l.points.length;c++)l.points[c].length==2&&(i.push(l.points[c][0].X),i.push(l.points[c][0].Z),i.push(-l.points[c][0].Y),i.push(l.points[c][1].X),i.push(l.points[c][1].Z),i.push(-l.points[c][1].Y));s.set(Number(l.id),[h,i.length,l.points])}),this.indexes.set(e.url,s);let o=new T.BufferGeometry;o.setAttribute("position",new T.Float32BufferAttribute(i,3));const a=new T.LineSegments(o,this.material);a.url=e.url,this.groupEdge.add(a)}})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,o,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array;for(let c=s;c<o;c++)h[c]=NaN;l.geometry.attributes.position.needsUpdate=!0}}}}showModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,o,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array,c=0;for(let u=s;u<o;u+=3){const p=Math.floor(c/6),f=c%6>=3;if(a[p]&&a[p].length===2){const d=f?a[p][1]:a[p][0];h[u]=d.X,h[u+1]=d.Z,h[u+2]=-d.Y}c+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class od{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const o=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${o.error?.message||o.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
752
+ `};class pa{engine;composer;saturationPass;constructor(e){this.engine=e}resize(e,t){if(e===void 0||t===void 0){const s=this.engine.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t||!this.composer)return;const n=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(s=>s instanceof vn&&s.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(e*n),i.material.uniforms.resolution.value.y=1/(t*n))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=this.engine.scene,i=this.engine.camera,s=this.engine.renderer,o=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new T.WebGLRenderTarget(e,t,{minFilter:T.LinearFilter,magFilter:T.LinearFilter,format:T.RGBAFormat,samples:4});this.composer=new ra(s,a),this.composer.setPixelRatio(o),this.composer.setSize(e,t);const l=new oa(n,i);this.composer.addPass(l);const h=new ze(n,i,e,t);h.output=ze.OUTPUT.Default,h.blendIntensity=.5,h.enabled=!1,h.updateGtaoMaterial&&h.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.composer.addPass(h),this.saturationPass=new vn(fa),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass);const c=new ua;c.enabled=!1,this.composer.addPass(c);const u=new vn(da);u.material.uniforms.resolution.value.x=1/(e*o),u.material.uniforms.resolution.value.y=1/(t*o),u.enabled=!1,this.composer.addPass(u)}}var Cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Os(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Pn(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Mi={exports:{}};var zs;function ma(){return zs||(zs=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function t(n,i,s){function o(h,c){if(!i[h]){if(!n[h]){var u=typeof Pn=="function"&&Pn;if(!c&&u)return u(h,!0);if(a)return a(h,!0);var f=new Error("Cannot find module '"+h+"'");throw f.code="MODULE_NOT_FOUND",f}var p=i[h]={exports:{}};n[h][0].call(p.exports,function(d){var m=n[h][1][d];return o(m||d)},p,p.exports,t,n,i,s)}return i[h].exports}for(var a=typeof Pn=="function"&&Pn,l=0;l<s.length;l++)o(s[l]);return o})({1:[function(t,n,i){var s=t("./utils"),o=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var h,c,u,f,p,d,m,g=[],y=0,w=l.length,b=w,x=s.getTypeOf(l)!=="string";y<l.length;)b=w-y,u=x?(h=l[y++],c=y<w?l[y++]:0,y<w?l[y++]:0):(h=l.charCodeAt(y++),c=y<w?l.charCodeAt(y++):0,y<w?l.charCodeAt(y++):0),f=h>>2,p=(3&h)<<4|c>>4,d=1<b?(15&c)<<2|u>>6:64,m=2<b?63&u:64,g.push(a.charAt(f)+a.charAt(p)+a.charAt(d)+a.charAt(m));return g.join("")},i.decode=function(l){var h,c,u,f,p,d,m=0,g=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var w,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&b--,l.charAt(l.length-2)===a.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=o.uint8array?new Uint8Array(0|b):new Array(0|b);m<l.length;)h=a.indexOf(l.charAt(m++))<<2|(f=a.indexOf(l.charAt(m++)))>>4,c=(15&f)<<4|(p=a.indexOf(l.charAt(m++)))>>2,u=(3&p)<<6|(d=a.indexOf(l.charAt(m++))),w[g++]=h,p!==64&&(w[g++]=c),d!==64&&(w[g++]=u);return w}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),o=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function h(c,u,f,p,d){this.compressedSize=c,this.uncompressedSize=u,this.crc32=f,this.compression=p,this.compressedContent=d}h.prototype={getContentWorker:function(){var c=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return c.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},h.createWorkerFrom=function(c,u,f){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},n.exports=h},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var s=t("./utils"),o=(function(){for(var a,l=[],h=0;h<256;h++){a=h;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[h]=a}return l})();n.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(h,c,u,f){var p=o,d=f+u;h^=-1;for(var m=f;m<d;m++)h=h>>>8^p[255&(h^c[m])];return-1^h})(0|l,a,a.length,0):(function(h,c,u,f){var p=o,d=f+u;h^=-1;for(var m=f;m<d;m++)h=h>>>8^p[255&(h^c.charCodeAt(m))];return-1^h})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var s=null;s=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:s}},{lie:37}],7:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),h=s?"uint8array":"array";function c(u,f){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=f,this.meta={}}i.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(h,u.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(f){u.push({data:f,meta:u.meta})}},i.compressWorker=function(u){return new c("Deflate",u)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(p,d){var m,g="";for(m=0;m<d;m++)g+=String.fromCharCode(255&p),p>>>=8;return g}function o(p,d,m,g,y,w){var b,x,_=p.file,D=p.compression,P=w!==h.utf8encode,k=a.transformTo("string",w(_.name)),C=a.transformTo("string",h.utf8encode(_.name)),I=_.comment,O=a.transformTo("string",w(I)),A=a.transformTo("string",h.utf8encode(I)),B=C.length!==_.name.length,v=A.length!==I.length,z="",Z="",W="",Q=_.dir,G=_.date,te={crc32:0,compressedSize:0,uncompressedSize:0};d&&!m||(te.crc32=p.crc32,te.compressedSize=p.compressedSize,te.uncompressedSize=p.uncompressedSize);var F=0;d&&(F|=8),P||!B&&!v||(F|=2048);var R=0,ne=0;Q&&(R|=16),y==="UNIX"?(ne=798,R|=(function(Y,de){var fe=Y;return Y||(fe=de?16893:33204),(65535&fe)<<16})(_.unixPermissions,Q)):(ne=20,R|=(function(Y){return 63&(Y||0)})(_.dosPermissions)),b=G.getUTCHours(),b<<=6,b|=G.getUTCMinutes(),b<<=5,b|=G.getUTCSeconds()/2,x=G.getUTCFullYear()-1980,x<<=4,x|=G.getUTCMonth()+1,x<<=5,x|=G.getUTCDate(),B&&(Z=s(1,1)+s(c(k),4)+C,z+="up"+s(Z.length,2)+Z),v&&(W=s(1,1)+s(c(O),4)+A,z+="uc"+s(W.length,2)+W);var H="";return H+=`
753
+ \0`,H+=s(F,2),H+=D.magic,H+=s(b,2),H+=s(x,2),H+=s(te.crc32,4),H+=s(te.compressedSize,4),H+=s(te.uncompressedSize,4),H+=s(k.length,2),H+=s(z.length,2),{fileRecord:u.LOCAL_FILE_HEADER+H+k+z,dirRecord:u.CENTRAL_FILE_HEADER+s(ne,2)+H+s(O.length,2)+"\0\0\0\0"+s(R,4)+s(g,4)+k+z+O}}var a=t("../utils"),l=t("../stream/GenericWorker"),h=t("../utf8"),c=t("../crc32"),u=t("../signature");function f(p,d,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=d,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(p){var d=p.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:m?(d+100*(m-g-1))/m:100}}))},f.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var d=this.streamFiles&&!p.file.dir;if(d){var m=o(p,d,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(p){this.accumulate=!1;var d=this.streamFiles&&!p.file.dir,m=o(p,d,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),d)this.push({data:(function(g){return u.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var p=this.bytesWritten,d=0;d<this.dirRecords.length;d++)this.push({data:this.dirRecords[d],meta:{percent:100}});var m=this.bytesWritten-p,g=(function(y,w,b,x,_){var D=a.transformTo("string",_(x));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(w,4)+s(b,4)+s(D.length,2)+D})(this.dirRecords.length,m,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(p){this._sources.push(p);var d=this;return p.on("data",function(m){d.processChunk(m)}),p.on("end",function(){d.closedSource(d.previous.streamInfo),d._sources.length?d.prepareNextSource():d.end()}),p.on("error",function(m){d.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(p){var d=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var m=0;m<d.length;m++)try{d[m].error(p)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,d=0;d<p.length;d++)p[d].lock()},n.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),o=t("./ZipFileWorker");i.generateWorker=function(a,l,h){var c=new o(l.streamFiles,h,l.platform,l.encodeFileName),u=0;try{a.forEach(function(f,p){u++;var d=(function(w,b){var x=w||b,_=s[x];if(!_)throw new Error(x+" is not a valid compression method !");return _})(p.options.compression,l.compression),m=p.options.compressionOptions||l.compressionOptions||{},g=p.dir,y=p.date;p._compressWorker(d,m).withStreamInfo("file",{name:f,dir:g,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(c)}),c.entriesCount=u}catch(f){c.error(f)}return c}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new s;for(var a in this)typeof this[a]!="function"&&(o[a]=this[a]);return o}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(o,a){return new s().loadAsync(o,a)},s.external=t("./external"),n.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var s=t("./utils"),o=t("./external"),a=t("./utf8"),l=t("./zipEntries"),h=t("./stream/Crc32Probe"),c=t("./nodejsUtils");function u(f){return new o.Promise(function(p,d){var m=f.decompressed.getContentWorker().pipe(new h);m.on("error",function(g){d(g)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?d(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(f,p){var d=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(f)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",f,!0,p.optimizedBinaryString,p.base64).then(function(m){var g=new l(p);return g.load(m),g}).then(function(m){var g=[o.Promise.resolve(m)],y=m.files;if(p.checkCRC32)for(var w=0;w<y.length;w++)g.push(u(y[w]));return o.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,w=0;w<y.length;w++){var b=y[w],x=b.fileNameStr,_=s.resolve(b.fileNameStr);d.file(_,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:p.createFolders}),b.dir||(d.file(_).unsafeOriginalName=x)}return g.zipComment.length&&(d.comment=g.zipComment),d})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),o=t("../stream/GenericWorker");function a(l,h){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(h)}s.inherits(a,o),a.prototype._bindStream=function(l){var h=this;(this._stream=l).pause(),l.on("data",function(c){h.push({data:c,meta:{percent:0}})}).on("error",function(c){h.isPaused?this.generatedError=c:h.error(c)}).on("end",function(){h.isPaused?h._upstreamEnded=!0:h.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,n,i){var s=t("readable-stream").Readable;function o(a,l,h){s.call(this,l),this._helper=a;var c=this;a.on("data",function(u,f){c.push(u)||c._helper.pause(),h&&h(f)}).on("error",function(u){c.emit("error",u)}).on("end",function(){c.push(null)})}t("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},n.exports=o},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,n,i){function s(_,D,P){var k,C=a.getTypeOf(D),I=a.extend(P||{},c);I.date=I.date||new Date,I.compression!==null&&(I.compression=I.compression.toUpperCase()),typeof I.unixPermissions=="string"&&(I.unixPermissions=parseInt(I.unixPermissions,8)),I.unixPermissions&&16384&I.unixPermissions&&(I.dir=!0),I.dosPermissions&&16&I.dosPermissions&&(I.dir=!0),I.dir&&(_=y(_)),I.createFolders&&(k=g(_))&&w.call(this,k,!0);var O=C==="string"&&I.binary===!1&&I.base64===!1;P&&P.binary!==void 0||(I.binary=!O),(D instanceof u&&D.uncompressedSize===0||I.dir||!D||D.length===0)&&(I.base64=!1,I.binary=!0,D="",I.compression="STORE",C="string");var A=null;A=D instanceof u||D instanceof l?D:d.isNode&&d.isStream(D)?new m(_,D):a.prepareContent(_,D,I.binary,I.optimizedBinaryString,I.base64);var B=new f(_,A,I);this.files[_]=B}var o=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),h=t("./stream/StreamHelper"),c=t("./defaults"),u=t("./compressedObject"),f=t("./zipObject"),p=t("./generate"),d=t("./nodejsUtils"),m=t("./nodejs/NodejsStreamInputAdapter"),g=function(_){_.slice(-1)==="/"&&(_=_.substring(0,_.length-1));var D=_.lastIndexOf("/");return 0<D?_.substring(0,D):""},y=function(_){return _.slice(-1)!=="/"&&(_+="/"),_},w=function(_,D){return D=D!==void 0?D:c.createFolders,_=y(_),this.files[_]||s.call(this,_,null,{dir:!0,createFolders:D}),this.files[_]};function b(_){return Object.prototype.toString.call(_)==="[object RegExp]"}var x={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(_){var D,P,k;for(D in this.files)k=this.files[D],(P=D.slice(this.root.length,D.length))&&D.slice(0,this.root.length)===this.root&&_(P,k)},filter:function(_){var D=[];return this.forEach(function(P,k){_(P,k)&&D.push(k)}),D},file:function(_,D,P){if(arguments.length!==1)return _=this.root+_,s.call(this,_,D,P),this;if(b(_)){var k=_;return this.filter(function(I,O){return!O.dir&&k.test(I)})}var C=this.files[this.root+_];return C&&!C.dir?C:null},folder:function(_){if(!_)return this;if(b(_))return this.filter(function(C,I){return I.dir&&_.test(C)});var D=this.root+_,P=w.call(this,D),k=this.clone();return k.root=P.name,k},remove:function(_){_=this.root+_;var D=this.files[_];if(D||(_.slice(-1)!=="/"&&(_+="/"),D=this.files[_]),D&&!D.dir)delete this.files[_];else for(var P=this.filter(function(C,I){return I.name.slice(0,_.length)===_}),k=0;k<P.length;k++)delete this.files[P[k].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(_){var D,P={};try{if((P=a.extend(_||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");a.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var k=P.comment||this.comment||"";D=p.generateWorker(this,P,k)}catch(C){(D=new l("error")).error(C)}return new h(D,P.type||"string",P.mimeType)},generateAsync:function(_,D){return this.generateInternalStream(_).accumulate(D)},generateNodeStream:function(_,D){return(_=_||{}).type||(_.type="nodebuffer"),this.generateInternalStream(_).toNodejsStream(D)}};n.exports=x},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,n,i){n.exports=t("stream")},{stream:void 0}],17:[function(t,n,i){var s=t("./DataReader");function o(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),u=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===h&&this.data[f+2]===c&&this.data[f+3]===u)return f-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),u=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&h===f[1]&&c===f[2]&&u===f[3]},o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var s=t("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,h=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)h=(h<<8)+this.byteAt(l);return this.index+=a,h},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=o},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),o=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),h=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");n.exports=function(u){var f=s.getTypeOf(u);return s.checkSupport(f),f!=="string"||o.uint8array?f==="nodebuffer"?new h(u):o.uint8array?new c(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),o=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),o=t("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var h=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=h+l.data.length}o.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataWorker");var h=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){h.dataIsReady=!0,h.data=c,h.max=c&&c.length||0,h.type=s.getTypeOf(c),h.isPaused||h._tickAndRepeat()},function(c){h.error(c)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,h=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,h);break;case"uint8array":l=this.data.subarray(this.index,h);break;case"array":case"nodebuffer":l=this.data.slice(this.index,h)}return this.index=h,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),o=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),h=t("../support"),c=t("../external"),u=null;if(h.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(d,m){return new c.Promise(function(g,y){var w=[],b=d._internalType,x=d._outputType,_=d._mimeType;d.on("data",function(D,P){w.push(D),m&&m(P)}).on("error",function(D){w=[],y(D)}).on("end",function(){try{var D=(function(P,k,C){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",k),C);case"base64":return l.encode(k);default:return s.transformTo(P,k)}})(x,(function(P,k){var C,I=0,O=null,A=0;for(C=0;C<k.length;C++)A+=k[C].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(A),C=0;C<k.length;C++)O.set(k[C],I),I+=k[C].length;return O;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+P+"'")}})(b,w),_);g(D)}catch(P){y(P)}w=[]}).resume()})}function p(d,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,s.checkSupport(y),this._worker=d.pipe(new o(y)),d.lock()}catch(w){this._worker=new a("error"),this._worker.error(w)}}p.prototype={accumulate:function(d){return f(this,d)},on:function(d,m){var g=this;return d==="data"?this._worker.on(d,function(y){m.call(g,y.data,y.meta)}):this._worker.on(d,function(){s.delay(m,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(d){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},d)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var s=t("./utils"),o=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),h=new Array(256),c=0;c<256;c++)h[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;h[254]=h[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?a.newBufferFrom(p,"utf-8"):(function(d){var m,g,y,w,b,x=d.length,_=0;for(w=0;w<x;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<x&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),_+=g<128?1:g<2048?2:g<65536?3:4;for(m=o.uint8array?new Uint8Array(_):new Array(_),w=b=0;b<_;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<x&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),g<128?m[b++]=g:(g<2048?m[b++]=192|g>>>6:(g<65536?m[b++]=224|g>>>12:(m[b++]=240|g>>>18,m[b++]=128|g>>>12&63),m[b++]=128|g>>>6&63),m[b++]=128|63&g);return m})(p)},i.utf8decode=function(p){return o.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(d){var m,g,y,w,b=d.length,x=new Array(2*b);for(m=g=0;m<b;)if((y=d[m++])<128)x[g++]=y;else if(4<(w=h[y]))x[g++]=65533,m+=w-1;else{for(y&=w===2?31:w===3?15:7;1<w&&m<b;)y=y<<6|63&d[m++],w--;1<w?x[g++]=65533:y<65536?x[g++]=y:(y-=65536,x[g++]=55296|y>>10&1023,x[g++]=56320|1023&y)}return x.length!==g&&(x.subarray?x=x.subarray(0,g):x.length=g),s.applyFromCharCode(x)})(p=s.transformTo(o.uint8array?"uint8array":"array",p))},s.inherits(u,l),u.prototype.processChunk=function(p){var d=s.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var m=d;(d=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),d.set(m,this.leftOver.length)}else d=this.leftOver.concat(d);this.leftOver=null}var g=(function(w,b){var x;for((b=b||w.length)>w.length&&(b=w.length),x=b-1;0<=x&&(192&w[x])==128;)x--;return x<0||x===0?b:x+h[w[x]]>b?x:b})(d),y=d;g!==d.length&&(o.uint8array?(y=d.subarray(0,g),this.leftOver=d.subarray(g,d.length)):(y=d.slice(0,g),this.leftOver=d.slice(g,d.length))),this.push({data:i.utf8decode(y),meta:p.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=u,s.inherits(f,l),f.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),o=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function h(m){return m}function c(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,g,y){var w=[],b=0,x=m.length;if(x<=y)return String.fromCharCode.apply(null,m);for(;b<x;)g==="array"||g==="nodebuffer"?w.push(String.fromCharCode.apply(null,m.slice(b,Math.min(b+y,x)))):w.push(String.fromCharCode.apply(null,m.subarray(b,Math.min(b+y,x)))),b+=y;return w.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function f(m){var g=65536,y=i.getTypeOf(m),w=!0;if(y==="uint8array"?w=u.applyCanBeUsed.uint8array:y==="nodebuffer"&&(w=u.applyCanBeUsed.nodebuffer),w)for(;1<g;)try{return u.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return u.stringifyByChar(m)}function p(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=f;var d={};d.string={string:h,array:function(m){return c(m,new Array(m.length))},arraybuffer:function(m){return d.string.uint8array(m).buffer},uint8array:function(m){return c(m,new Uint8Array(m.length))},nodebuffer:function(m){return c(m,a.allocBuffer(m.length))}},d.array={string:f,array:h,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},d.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return p(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:h,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},d.uint8array={string:f,array:function(m){return p(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:h,nodebuffer:function(m){return a.newBufferFrom(m)}},d.nodebuffer={string:f,array:function(m){return p(m,new Array(m.length))},arraybuffer:function(m){return d.nodebuffer.uint8array(m).buffer},uint8array:function(m){return p(m,new Uint8Array(m.length))},nodebuffer:h},i.transformTo=function(m,g){if(g=g||"",!m)return g;i.checkSupport(m);var y=i.getTypeOf(g);return d[y][m](g)},i.resolve=function(m){for(var g=m.split("/"),y=[],w=0;w<g.length;w++){var b=g[w];b==="."||b===""&&w!==0&&w!==g.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,w="";for(y=0;y<(m||"").length;y++)w+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return w},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,w,b){return l.Promise.resolve(g).then(function(x){return s.blob&&(x instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(x))!==-1)&&typeof FileReader<"u"?new l.Promise(function(_,D){var P=new FileReader;P.onload=function(k){_(k.target.result)},P.onerror=function(k){D(k.target.error)},P.readAsArrayBuffer(x)}):x}).then(function(x){var _=i.getTypeOf(x);return _?(_==="arraybuffer"?x=i.transformTo("uint8array",x):_==="string"&&(b?x=o.decode(x):y&&w!==!0&&(x=(function(D){return c(D,s.uint8array?new Uint8Array(D.length):new Array(D.length))})(x))),x):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var s=t("./reader/readerFor"),o=t("./utils"),a=t("./signature"),l=t("./zipEntry"),h=t("./support");function c(u){this.files=[],this.loadOptions=u}c.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(f)+", expected "+o.pretty(u)+")")}},isSignature:function(u,f){var p=this.reader.index;this.reader.setIndex(u);var d=this.reader.readString(4)===f;return this.reader.setIndex(p),d},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),f=h.uint8array?"uint8array":"array",p=o.transformTo(f,u);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,f,p,d=this.zip64EndOfCentralSize-44;0<d;)u=this.reader.readInt(2),f=this.reader.readInt(4),p=this.reader.readData(f),this.zip64ExtensibleData[u]={id:u,length:f,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,f;for(u=0;u<this.files.length;u++)f=this.files[u],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var f=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var d=f-p;if(0<d)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=d);else if(d<0)throw new Error("Corrupted zip: missing "+Math.abs(d)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),o=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),h=t("./utf8"),c=t("./compressions"),u=t("./support");function f(p,d){this.options=p,this.loadOptions=d}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var d,m;if(p.skip(22),this.fileNameLength=p.readInt(2),m=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((d=(function(g){for(var y in c)if(Object.prototype.hasOwnProperty.call(c,y)&&c[y].magic===g)return c[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,d,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var d=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(d),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var d,m,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)d=p.readInt(2),m=p.readInt(2),g=p.readData(m),this.extraFields[d]={id:d,length:m,value:g};p.setIndex(y)},handleUTF8:function(){var p=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=h.utf8decode(this.fileName),this.fileCommentStr=h.utf8decode(this.fileComment);else{var d=this.findExtraFieldUnicodePath();if(d!==null)this.fileNameStr=d;else{var m=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var d=s(p.value);return d.readInt(1)!==1||l(this.fileName)!==d.readInt(4)?null:h.utf8decode(d.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var d=s(p.value);return d.readInt(1)!==1||l(this.fileComment)!==d.readInt(4)?null:h.utf8decode(d.readData(p.length-5))}return null}},n.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(d,m,g){this.name=d,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var o=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),h=t("./compressedObject"),c=t("./stream/GenericWorker");s.prototype={internalStream:function(d){var m=null,g="string";try{if(!d)throw new Error("No output type specified.");var y=(g=d.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var w=!this._dataBinary;w&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!w&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(b){(m=new c("error")).error(b)}return new o(m,g,"")},async:function(d,m){return this.internalStream(d).accumulate(m)},nodeStream:function(d,m){return this.internalStream(d||"nodebuffer").toNodejsStream(m)},_compressWorker:function(d,m){if(this._data instanceof h&&this._data.compression.magic===d.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),h.createWorkerFrom(g,d,m)},_decompressWorker:function(){return this._data instanceof h?this._data.getContentWorker():this._data instanceof c?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<u.length;p++)s.prototype[u[p]]=f;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var o,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var h=0,c=new l(d),u=s.document.createTextNode("");c.observe(u,{characterData:!0}),o=function(){u.data=h=++h%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){d(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(d,0)};else{var f=new s.MessageChannel;f.port1.onmessage=d,o=function(){f.port2.postMessage(0)}}var p=[];function d(){var m,g;a=!0;for(var y=p.length;y;){for(g=p,p=[],m=-1;++m<y;)g[m]();y=p.length}a=!1}n.exports=function(m){p.push(m)!==1||a||o()}}).call(this,typeof Cn<"u"?Cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var s=t("immediate");function o(){}var a={},l=["REJECTED"],h=["FULFILLED"],c=["PENDING"];function u(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,y!==o&&m(this,y)}function f(y,w,b){this.promise=y,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(y,w,b){s(function(){var x;try{x=w(b)}catch(_){return a.reject(y,_)}x===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,x)})}function d(y){var w=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof w=="function")return function(){w.apply(y,arguments)}}function m(y,w){var b=!1;function x(P){b||(b=!0,a.reject(y,P))}function _(P){b||(b=!0,a.resolve(y,P))}var D=g(function(){w(_,x)});D.status==="error"&&x(D.value)}function g(y,w){var b={};try{b.value=y(w),b.status="success"}catch(x){b.status="error",b.value=x}return b}(n.exports=u).prototype.finally=function(y){if(typeof y!="function")return this;var w=this.constructor;return this.then(function(b){return w.resolve(y()).then(function(){return b})},function(b){return w.resolve(y()).then(function(){throw b})})},u.prototype.catch=function(y){return this.then(null,y)},u.prototype.then=function(y,w){if(typeof y!="function"&&this.state===h||typeof w!="function"&&this.state===l)return this;var b=new this.constructor(o);return this.state!==c?p(b,this.state===h?y:w,this.outcome):this.queue.push(new f(b,y,w)),b},f.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){a.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},a.resolve=function(y,w){var b=g(d,w);if(b.status==="error")return a.reject(y,b.value);var x=b.value;if(x)m(y,x);else{y.state=h,y.outcome=w;for(var _=-1,D=y.queue.length;++_<D;)y.queue[_].callFulfilled(w)}return y},a.reject=function(y,w){y.state=l,y.outcome=w;for(var b=-1,x=y.queue.length;++b<x;)y.queue[b].callRejected(w);return y},u.resolve=function(y){return y instanceof this?y:a.resolve(new this(o),y)},u.reject=function(y){var w=new this(o);return a.reject(w,y)},u.all=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,x=!1;if(!b)return this.resolve([]);for(var _=new Array(b),D=0,P=-1,k=new this(o);++P<b;)C(y[P],P);return k;function C(I,O){w.resolve(I).then(function(A){_[O]=A,++D!==b||x||(x=!0,a.resolve(k,_))},function(A){x||(x=!0,a.reject(k,A))})}},u.race=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,x=!1;if(!b)return this.resolve([]);for(var _=-1,D=new this(o);++_<b;)P=y[_],w.resolve(P).then(function(k){x||(x=!0,a.resolve(D,k))},function(k){x||(x=!0,a.reject(D,k))});var P;return D}},{immediate:36}],38:[function(t,n,i){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),n.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,n,i){var s=t("./zlib/deflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),h=t("./zlib/zstream"),c=Object.prototype.toString,u=0,f=-1,p=0,d=8;function m(y){if(!(this instanceof m))return new m(y);this.options=o.assign({level:f,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var b=s.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(b!==u)throw new Error(l[b]);if(w.header&&s.deflateSetHeader(this.strm,w.header),w.dictionary){var x;if(x=typeof w.dictionary=="string"?a.string2buf(w.dictionary):c.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(b=s.deflateSetDictionary(this.strm,x))!==u)throw new Error(l[b]);this._dict_set=!0}}function g(y,w){var b=new m(w);if(b.push(y,!0),b.err)throw b.msg||l[b.err];return b.result}m.prototype.push=function(y,w){var b,x,_=this.strm,D=this.options.chunkSize;if(this.ended)return!1;x=w===~~w?w:w===!0?4:0,typeof y=="string"?_.input=a.string2buf(y):c.call(y)==="[object ArrayBuffer]"?_.input=new Uint8Array(y):_.input=y,_.next_in=0,_.avail_in=_.input.length;do{if(_.avail_out===0&&(_.output=new o.Buf8(D),_.next_out=0,_.avail_out=D),(b=s.deflate(_,x))!==1&&b!==u)return this.onEnd(b),!(this.ended=!0);_.avail_out!==0&&(_.avail_in!==0||x!==4&&x!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(o.shrinkBuf(_.output,_.next_out))):this.onData(o.shrinkBuf(_.output,_.next_out)))}while((0<_.avail_in||_.avail_out===0)&&b!==1);return x===4?(b=s.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===u):x!==2||(this.onEnd(u),!(_.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,w){return(w=w||{}).raw=!0,g(y,w)},i.gzip=function(y,w){return(w=w||{}).gzip=!0,g(y,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var s=t("./zlib/inflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),c=t("./zlib/zstream"),u=t("./zlib/gzheader"),f=Object.prototype.toString;function p(m){if(!(this instanceof p))return new p(m);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(h[y]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function d(m,g){var y=new p(g);if(y.push(m,!0),y.err)throw y.msg||h[y.err];return y.result}p.prototype.push=function(m,g){var y,w,b,x,_,D,P=this.strm,k=this.options.chunkSize,C=this.options.dictionary,I=!1;if(this.ended)return!1;w=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?P.input=a.binstring2buf(m):f.call(m)==="[object ArrayBuffer]"?P.input=new Uint8Array(m):P.input=m,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new o.Buf8(k),P.next_out=0,P.avail_out=k),(y=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&C&&(D=typeof C=="string"?a.string2buf(C):f.call(C)==="[object ArrayBuffer]"?new Uint8Array(C):C,y=s.inflateSetDictionary(this.strm,D)),y===l.Z_BUF_ERROR&&I===!0&&(y=l.Z_OK,I=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(P.output,P.next_out),x=P.next_out-b,_=a.buf2string(P.output,b),P.next_out=x,P.avail_out=k-x,x&&o.arraySet(P.output,P.output,b,x,0),this.onData(_)):this.onData(o.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(I=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(w=l.Z_FINISH),w===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},p.prototype.onData=function(m){this.chunks.push(m)},p.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=p,i.inflate=d,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,d(m,g)},i.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var h=Array.prototype.slice.call(arguments,1);h.length;){var c=h.shift();if(c){if(typeof c!="object")throw new TypeError(c+"must be non-object");for(var u in c)c.hasOwnProperty(u)&&(l[u]=c[u])}}return l},i.shrinkBuf=function(l,h){return l.length===h?l:l.subarray?l.subarray(0,h):(l.length=h,l)};var o={arraySet:function(l,h,c,u,f){if(h.subarray&&l.subarray)l.set(h.subarray(c,c+u),f);else for(var p=0;p<u;p++)l[f+p]=h[c+p]},flattenChunks:function(l){var h,c,u,f,p,d;for(h=u=0,c=l.length;h<c;h++)u+=l[h].length;for(d=new Uint8Array(u),h=f=0,c=l.length;h<c;h++)p=l[h],d.set(p,f),f+=p.length;return d}},a={arraySet:function(l,h,c,u,f){for(var p=0;p<u;p++)l[f+p]=h[c+p]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(s)},{}],42:[function(t,n,i){var s=t("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new s.Buf8(256),h=0;h<256;h++)l[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;function c(u,f){if(f<65537&&(u.subarray&&a||!u.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(u,f));for(var p="",d=0;d<f;d++)p+=String.fromCharCode(u[d]);return p}l[254]=l[254]=1,i.string2buf=function(u){var f,p,d,m,g,y=u.length,w=0;for(m=0;m<y;m++)(64512&(p=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(p=65536+(p-55296<<10)+(d-56320),m++),w+=p<128?1:p<2048?2:p<65536?3:4;for(f=new s.Buf8(w),m=g=0;g<w;m++)(64512&(p=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(p=65536+(p-55296<<10)+(d-56320),m++),p<128?f[g++]=p:(p<2048?f[g++]=192|p>>>6:(p<65536?f[g++]=224|p>>>12:(f[g++]=240|p>>>18,f[g++]=128|p>>>12&63),f[g++]=128|p>>>6&63),f[g++]=128|63&p);return f},i.buf2binstring=function(u){return c(u,u.length)},i.binstring2buf=function(u){for(var f=new s.Buf8(u.length),p=0,d=f.length;p<d;p++)f[p]=u.charCodeAt(p);return f},i.buf2string=function(u,f){var p,d,m,g,y=f||u.length,w=new Array(2*y);for(p=d=0;p<y;)if((m=u[p++])<128)w[d++]=m;else if(4<(g=l[m]))w[d++]=65533,p+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&p<y;)m=m<<6|63&u[p++],g--;1<g?w[d++]=65533:m<65536?w[d++]=m:(m-=65536,w[d++]=55296|m>>10&1023,w[d++]=56320|1023&m)}return c(w,d)},i.utf8border=function(u,f){var p;for((f=f||u.length)>u.length&&(f=u.length),p=f-1;0<=p&&(192&u[p])==128;)p--;return p<0||p===0?f:p+l[u[p]]>f?p:f}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,o,a,l){for(var h=65535&s|0,c=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;c=c+(h=h+o[l++]|0)|0,--u;);h%=65521,c%=65521}return h|c<<16|0}},{}],44:[function(t,n,i){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,n,i){var s=(function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var h=0;h<8;h++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a})();n.exports=function(o,a,l,h){var c=s,u=h+l;o^=-1;for(var f=h;f<u;f++)o=o>>>8^c[255&(o^a[f])];return-1^o}},{}],46:[function(t,n,i){var s,o=t("../utils/common"),a=t("./trees"),l=t("./adler32"),h=t("./crc32"),c=t("./messages"),u=0,f=4,p=0,d=-2,m=-1,g=4,y=2,w=8,b=9,x=286,_=30,D=19,P=2*x+1,k=15,C=3,I=258,O=I+C+1,A=42,B=113,v=1,z=2,Z=3,W=4;function Q(M,X){return M.msg=c[X],X}function G(M){return(M<<1)-(4<M?9:0)}function te(M){for(var X=M.length;0<=--X;)M[X]=0}function F(M){var X=M.state,j=X.pending;j>M.avail_out&&(j=M.avail_out),j!==0&&(o.arraySet(M.output,X.pending_buf,X.pending_out,j,M.next_out),M.next_out+=j,X.pending_out+=j,M.total_out+=j,M.avail_out-=j,X.pending-=j,X.pending===0&&(X.pending_out=0))}function R(M,X){a._tr_flush_block(M,0<=M.block_start?M.block_start:-1,M.strstart-M.block_start,X),M.block_start=M.strstart,F(M.strm)}function ne(M,X){M.pending_buf[M.pending++]=X}function H(M,X){M.pending_buf[M.pending++]=X>>>8&255,M.pending_buf[M.pending++]=255&X}function Y(M,X){var j,L,E=M.max_chain_length,N=M.strstart,q=M.prev_length,K=M.nice_match,U=M.strstart>M.w_size-O?M.strstart-(M.w_size-O):0,$=M.window,ee=M.w_mask,J=M.prev,ie=M.strstart+I,ce=$[N+q-1],ae=$[N+q];M.prev_length>=M.good_match&&(E>>=2),K>M.lookahead&&(K=M.lookahead);do if($[(j=X)+q]===ae&&$[j+q-1]===ce&&$[j]===$[N]&&$[++j]===$[N+1]){N+=2,j++;do;while($[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&N<ie);if(L=I-(ie-N),N=ie-I,q<L){if(M.match_start=X,K<=(q=L))break;ce=$[N+q-1],ae=$[N+q]}}while((X=J[X&ee])>U&&--E!=0);return q<=M.lookahead?q:M.lookahead}function de(M){var X,j,L,E,N,q,K,U,$,ee,J=M.w_size;do{if(E=M.window_size-M.lookahead-M.strstart,M.strstart>=J+(J-O)){for(o.arraySet(M.window,M.window,J,J,0),M.match_start-=J,M.strstart-=J,M.block_start-=J,X=j=M.hash_size;L=M.head[--X],M.head[X]=J<=L?L-J:0,--j;);for(X=j=J;L=M.prev[--X],M.prev[X]=J<=L?L-J:0,--j;);E+=J}if(M.strm.avail_in===0)break;if(q=M.strm,K=M.window,U=M.strstart+M.lookahead,$=E,ee=void 0,ee=q.avail_in,$<ee&&(ee=$),j=ee===0?0:(q.avail_in-=ee,o.arraySet(K,q.input,q.next_in,ee,U),q.state.wrap===1?q.adler=l(q.adler,K,ee,U):q.state.wrap===2&&(q.adler=h(q.adler,K,ee,U)),q.next_in+=ee,q.total_in+=ee,ee),M.lookahead+=j,M.lookahead+M.insert>=C)for(N=M.strstart-M.insert,M.ins_h=M.window[N],M.ins_h=(M.ins_h<<M.hash_shift^M.window[N+1])&M.hash_mask;M.insert&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[N+C-1])&M.hash_mask,M.prev[N&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=N,N++,M.insert--,!(M.lookahead+M.insert<C)););}while(M.lookahead<O&&M.strm.avail_in!==0)}function fe(M,X){for(var j,L;;){if(M.lookahead<O){if(de(M),M.lookahead<O&&X===u)return v;if(M.lookahead===0)break}if(j=0,M.lookahead>=C&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),j!==0&&M.strstart-j<=M.w_size-O&&(M.match_length=Y(M,j)),M.match_length>=C)if(L=a._tr_tally(M,M.strstart-M.match_start,M.match_length-C),M.lookahead-=M.match_length,M.match_length<=M.max_lazy_match&&M.lookahead>=C){for(M.match_length--;M.strstart++,M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart,--M.match_length!=0;);M.strstart++}else M.strstart+=M.match_length,M.match_length=0,M.ins_h=M.window[M.strstart],M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+1])&M.hash_mask;else L=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++;if(L&&(R(M,!1),M.strm.avail_out===0))return v}return M.insert=M.strstart<C-1?M.strstart:C-1,X===f?(R(M,!0),M.strm.avail_out===0?Z:W):M.last_lit&&(R(M,!1),M.strm.avail_out===0)?v:z}function se(M,X){for(var j,L,E;;){if(M.lookahead<O){if(de(M),M.lookahead<O&&X===u)return v;if(M.lookahead===0)break}if(j=0,M.lookahead>=C&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),M.prev_length=M.match_length,M.prev_match=M.match_start,M.match_length=C-1,j!==0&&M.prev_length<M.max_lazy_match&&M.strstart-j<=M.w_size-O&&(M.match_length=Y(M,j),M.match_length<=5&&(M.strategy===1||M.match_length===C&&4096<M.strstart-M.match_start)&&(M.match_length=C-1)),M.prev_length>=C&&M.match_length<=M.prev_length){for(E=M.strstart+M.lookahead-C,L=a._tr_tally(M,M.strstart-1-M.prev_match,M.prev_length-C),M.lookahead-=M.prev_length-1,M.prev_length-=2;++M.strstart<=E&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+C-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),--M.prev_length!=0;);if(M.match_available=0,M.match_length=C-1,M.strstart++,L&&(R(M,!1),M.strm.avail_out===0))return v}else if(M.match_available){if((L=a._tr_tally(M,0,M.window[M.strstart-1]))&&R(M,!1),M.strstart++,M.lookahead--,M.strm.avail_out===0)return v}else M.match_available=1,M.strstart++,M.lookahead--}return M.match_available&&(L=a._tr_tally(M,0,M.window[M.strstart-1]),M.match_available=0),M.insert=M.strstart<C-1?M.strstart:C-1,X===f?(R(M,!0),M.strm.avail_out===0?Z:W):M.last_lit&&(R(M,!1),M.strm.avail_out===0)?v:z}function oe(M,X,j,L,E){this.good_length=M,this.max_lazy=X,this.nice_length=j,this.max_chain=L,this.func=E}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*P),this.dyn_dtree=new o.Buf16(2*(2*_+1)),this.bl_tree=new o.Buf16(2*(2*D+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(k+1),this.heap=new o.Buf16(2*x+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*x+1),te(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pe(M){var X;return M&&M.state?(M.total_in=M.total_out=0,M.data_type=y,(X=M.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?A:B,M.adler=X.wrap===2?0:1,X.last_flush=u,a._tr_init(X),p):Q(M,d)}function Ae(M){var X=pe(M);return X===p&&(function(j){j.window_size=2*j.w_size,te(j.head),j.max_lazy_match=s[j.level].max_lazy,j.good_match=s[j.level].good_length,j.nice_match=s[j.level].nice_length,j.max_chain_length=s[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=C-1,j.match_available=0,j.ins_h=0})(M.state),X}function Le(M,X,j,L,E,N){if(!M)return d;var q=1;if(X===m&&(X=6),L<0?(q=0,L=-L):15<L&&(q=2,L-=16),E<1||b<E||j!==w||L<8||15<L||X<0||9<X||N<0||g<N)return Q(M,d);L===8&&(L=9);var K=new he;return(M.state=K).strm=M,K.wrap=q,K.gzhead=null,K.w_bits=L,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=E+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+C-1)/C),K.window=new o.Buf8(2*K.w_size),K.head=new o.Buf16(K.hash_size),K.prev=new o.Buf16(K.w_size),K.lit_bufsize=1<<E+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new o.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=X,K.strategy=N,K.method=j,Ae(M)}s=[new oe(0,0,0,0,function(M,X){var j=65535;for(j>M.pending_buf_size-5&&(j=M.pending_buf_size-5);;){if(M.lookahead<=1){if(de(M),M.lookahead===0&&X===u)return v;if(M.lookahead===0)break}M.strstart+=M.lookahead,M.lookahead=0;var L=M.block_start+j;if((M.strstart===0||M.strstart>=L)&&(M.lookahead=M.strstart-L,M.strstart=L,R(M,!1),M.strm.avail_out===0)||M.strstart-M.block_start>=M.w_size-O&&(R(M,!1),M.strm.avail_out===0))return v}return M.insert=0,X===f?(R(M,!0),M.strm.avail_out===0?Z:W):(M.strstart>M.block_start&&(R(M,!1),M.strm.avail_out),v)}),new oe(4,4,8,4,fe),new oe(4,5,16,8,fe),new oe(4,6,32,32,fe),new oe(4,4,16,16,se),new oe(8,16,32,32,se),new oe(8,16,128,128,se),new oe(8,32,128,256,se),new oe(32,128,258,1024,se),new oe(32,258,258,4096,se)],i.deflateInit=function(M,X){return Le(M,X,w,15,8,0)},i.deflateInit2=Le,i.deflateReset=Ae,i.deflateResetKeep=pe,i.deflateSetHeader=function(M,X){return M&&M.state?M.state.wrap!==2?d:(M.state.gzhead=X,p):d},i.deflate=function(M,X){var j,L,E,N;if(!M||!M.state||5<X||X<0)return M?Q(M,d):d;if(L=M.state,!M.output||!M.input&&M.avail_in!==0||L.status===666&&X!==f)return Q(M,M.avail_out===0?-5:d);if(L.strm=M,j=L.last_flush,L.last_flush=X,L.status===A)if(L.wrap===2)M.adler=0,ne(L,31),ne(L,139),ne(L,8),L.gzhead?(ne(L,(L.gzhead.text?1:0)+(L.gzhead.hcrc?2:0)+(L.gzhead.extra?4:0)+(L.gzhead.name?8:0)+(L.gzhead.comment?16:0)),ne(L,255&L.gzhead.time),ne(L,L.gzhead.time>>8&255),ne(L,L.gzhead.time>>16&255),ne(L,L.gzhead.time>>24&255),ne(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),ne(L,255&L.gzhead.os),L.gzhead.extra&&L.gzhead.extra.length&&(ne(L,255&L.gzhead.extra.length),ne(L,L.gzhead.extra.length>>8&255)),L.gzhead.hcrc&&(M.adler=h(M.adler,L.pending_buf,L.pending,0)),L.gzindex=0,L.status=69):(ne(L,0),ne(L,0),ne(L,0),ne(L,0),ne(L,0),ne(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),ne(L,3),L.status=B);else{var q=w+(L.w_bits-8<<4)<<8;q|=(2<=L.strategy||L.level<2?0:L.level<6?1:L.level===6?2:3)<<6,L.strstart!==0&&(q|=32),q+=31-q%31,L.status=B,H(L,q),L.strstart!==0&&(H(L,M.adler>>>16),H(L,65535&M.adler)),M.adler=1}if(L.status===69)if(L.gzhead.extra){for(E=L.pending;L.gzindex<(65535&L.gzhead.extra.length)&&(L.pending!==L.pending_buf_size||(L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),F(M),E=L.pending,L.pending!==L.pending_buf_size));)ne(L,255&L.gzhead.extra[L.gzindex]),L.gzindex++;L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),L.gzindex===L.gzhead.extra.length&&(L.gzindex=0,L.status=73)}else L.status=73;if(L.status===73)if(L.gzhead.name){E=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),F(M),E=L.pending,L.pending===L.pending_buf_size)){N=1;break}N=L.gzindex<L.gzhead.name.length?255&L.gzhead.name.charCodeAt(L.gzindex++):0,ne(L,N)}while(N!==0);L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),N===0&&(L.gzindex=0,L.status=91)}else L.status=91;if(L.status===91)if(L.gzhead.comment){E=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),F(M),E=L.pending,L.pending===L.pending_buf_size)){N=1;break}N=L.gzindex<L.gzhead.comment.length?255&L.gzhead.comment.charCodeAt(L.gzindex++):0,ne(L,N)}while(N!==0);L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),N===0&&(L.status=103)}else L.status=103;if(L.status===103&&(L.gzhead.hcrc?(L.pending+2>L.pending_buf_size&&F(M),L.pending+2<=L.pending_buf_size&&(ne(L,255&M.adler),ne(L,M.adler>>8&255),M.adler=0,L.status=B)):L.status=B),L.pending!==0){if(F(M),M.avail_out===0)return L.last_flush=-1,p}else if(M.avail_in===0&&G(X)<=G(j)&&X!==f)return Q(M,-5);if(L.status===666&&M.avail_in!==0)return Q(M,-5);if(M.avail_in!==0||L.lookahead!==0||X!==u&&L.status!==666){var K=L.strategy===2?(function(U,$){for(var ee;;){if(U.lookahead===0&&(de(U),U.lookahead===0)){if($===u)return v;break}if(U.match_length=0,ee=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,ee&&(R(U,!1),U.strm.avail_out===0))return v}return U.insert=0,$===f?(R(U,!0),U.strm.avail_out===0?Z:W):U.last_lit&&(R(U,!1),U.strm.avail_out===0)?v:z})(L,X):L.strategy===3?(function(U,$){for(var ee,J,ie,ce,ae=U.window;;){if(U.lookahead<=I){if(de(U),U.lookahead<=I&&$===u)return v;if(U.lookahead===0)break}if(U.match_length=0,U.lookahead>=C&&0<U.strstart&&(J=ae[ie=U.strstart-1])===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]){ce=U.strstart+I;do;while(J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&ie<ce);U.match_length=I-(ce-ie),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=C?(ee=a._tr_tally(U,1,U.match_length-C),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(ee=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),ee&&(R(U,!1),U.strm.avail_out===0))return v}return U.insert=0,$===f?(R(U,!0),U.strm.avail_out===0?Z:W):U.last_lit&&(R(U,!1),U.strm.avail_out===0)?v:z})(L,X):s[L.level].func(L,X);if(K!==Z&&K!==W||(L.status=666),K===v||K===Z)return M.avail_out===0&&(L.last_flush=-1),p;if(K===z&&(X===1?a._tr_align(L):X!==5&&(a._tr_stored_block(L,0,0,!1),X===3&&(te(L.head),L.lookahead===0&&(L.strstart=0,L.block_start=0,L.insert=0))),F(M),M.avail_out===0))return L.last_flush=-1,p}return X!==f?p:L.wrap<=0?1:(L.wrap===2?(ne(L,255&M.adler),ne(L,M.adler>>8&255),ne(L,M.adler>>16&255),ne(L,M.adler>>24&255),ne(L,255&M.total_in),ne(L,M.total_in>>8&255),ne(L,M.total_in>>16&255),ne(L,M.total_in>>24&255)):(H(L,M.adler>>>16),H(L,65535&M.adler)),F(M),0<L.wrap&&(L.wrap=-L.wrap),L.pending!==0?p:1)},i.deflateEnd=function(M){var X;return M&&M.state?(X=M.state.status)!==A&&X!==69&&X!==73&&X!==91&&X!==103&&X!==B&&X!==666?Q(M,d):(M.state=null,X===B?Q(M,-3):p):d},i.deflateSetDictionary=function(M,X){var j,L,E,N,q,K,U,$,ee=X.length;if(!M||!M.state||(N=(j=M.state).wrap)===2||N===1&&j.status!==A||j.lookahead)return d;for(N===1&&(M.adler=l(M.adler,X,ee,0)),j.wrap=0,ee>=j.w_size&&(N===0&&(te(j.head),j.strstart=0,j.block_start=0,j.insert=0),$=new o.Buf8(j.w_size),o.arraySet($,X,ee-j.w_size,j.w_size,0),X=$,ee=j.w_size),q=M.avail_in,K=M.next_in,U=M.input,M.avail_in=ee,M.next_in=0,M.input=X,de(j);j.lookahead>=C;){for(L=j.strstart,E=j.lookahead-(C-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[L+C-1])&j.hash_mask,j.prev[L&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=L,L++,--E;);j.strstart=L,j.lookahead=C-1,de(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=C-1,j.match_available=0,M.next_in=K,M.input=U,M.avail_in=q,j.wrap=N,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,n,i){n.exports=function(s,o){var a,l,h,c,u,f,p,d,m,g,y,w,b,x,_,D,P,k,C,I,O,A,B,v,z;a=s.state,l=s.next_in,v=s.input,h=l+(s.avail_in-5),c=s.next_out,z=s.output,u=c-(o-s.avail_out),f=c+(s.avail_out-257),p=a.dmax,d=a.wsize,m=a.whave,g=a.wnext,y=a.window,w=a.hold,b=a.bits,x=a.lencode,_=a.distcode,D=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{b<15&&(w+=v[l++]<<b,b+=8,w+=v[l++]<<b,b+=8),k=x[w&D];t:for(;;){if(w>>>=C=k>>>24,b-=C,(C=k>>>16&255)===0)z[c++]=65535&k;else{if(!(16&C)){if((64&C)==0){k=x[(65535&k)+(w&(1<<C)-1)];continue t}if(32&C){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}I=65535&k,(C&=15)&&(b<C&&(w+=v[l++]<<b,b+=8),I+=w&(1<<C)-1,w>>>=C,b-=C),b<15&&(w+=v[l++]<<b,b+=8,w+=v[l++]<<b,b+=8),k=_[w&P];n:for(;;){if(w>>>=C=k>>>24,b-=C,!(16&(C=k>>>16&255))){if((64&C)==0){k=_[(65535&k)+(w&(1<<C)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,b<(C&=15)&&(w+=v[l++]<<b,(b+=8)<C&&(w+=v[l++]<<b,b+=8)),p<(O+=w&(1<<C)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(w>>>=C,b-=C,(C=c-u)<O){if(m<(C=O-C)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(B=y,(A=0)===g){if(A+=d-C,C<I){for(I-=C;z[c++]=y[A++],--C;);A=c-O,B=z}}else if(g<C){if(A+=d+g-C,(C-=g)<I){for(I-=C;z[c++]=y[A++],--C;);if(A=0,g<I){for(I-=C=g;z[c++]=y[A++],--C;);A=c-O,B=z}}}else if(A+=g-C,C<I){for(I-=C;z[c++]=y[A++],--C;);A=c-O,B=z}for(;2<I;)z[c++]=B[A++],z[c++]=B[A++],z[c++]=B[A++],I-=3;I&&(z[c++]=B[A++],1<I&&(z[c++]=B[A++]))}else{for(A=c-O;z[c++]=z[A++],z[c++]=z[A++],z[c++]=z[A++],2<(I-=3););I&&(z[c++]=z[A++],1<I&&(z[c++]=z[A++]))}break}}break}}while(l<h&&c<f);l-=I=b>>3,w&=(1<<(b-=I<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l<h?h-l+5:5-(l-h),s.avail_out=c<f?f-c+257:257-(c-f),a.hold=w,a.bits=b}},{}],49:[function(t,n,i){var s=t("../utils/common"),o=t("./adler32"),a=t("./crc32"),l=t("./inffast"),h=t("./inftrees"),c=1,u=2,f=0,p=-2,d=1,m=852,g=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(A){var B;return A&&A.state?(B=A.state,A.total_in=A.total_out=B.total=0,A.msg="",B.wrap&&(A.adler=1&B.wrap),B.mode=d,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new s.Buf32(m),B.distcode=B.distdyn=new s.Buf32(g),B.sane=1,B.back=-1,f):p}function x(A){var B;return A&&A.state?((B=A.state).wsize=0,B.whave=0,B.wnext=0,b(A)):p}function _(A,B){var v,z;return A&&A.state?(z=A.state,B<0?(v=0,B=-B):(v=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?p:(z.window!==null&&z.wbits!==B&&(z.window=null),z.wrap=v,z.wbits=B,x(A))):p}function D(A,B){var v,z;return A?(z=new w,(A.state=z).window=null,(v=_(A,B))!==f&&(A.state=null),v):p}var P,k,C=!0;function I(A){if(C){var B;for(P=new s.Buf32(512),k=new s.Buf32(32),B=0;B<144;)A.lens[B++]=8;for(;B<256;)A.lens[B++]=9;for(;B<280;)A.lens[B++]=7;for(;B<288;)A.lens[B++]=8;for(h(c,A.lens,0,288,P,0,A.work,{bits:9}),B=0;B<32;)A.lens[B++]=5;h(u,A.lens,0,32,k,0,A.work,{bits:5}),C=!1}A.lencode=P,A.lenbits=9,A.distcode=k,A.distbits=5}function O(A,B,v,z){var Z,W=A.state;return W.window===null&&(W.wsize=1<<W.wbits,W.wnext=0,W.whave=0,W.window=new s.Buf8(W.wsize)),z>=W.wsize?(s.arraySet(W.window,B,v-W.wsize,W.wsize,0),W.wnext=0,W.whave=W.wsize):(z<(Z=W.wsize-W.wnext)&&(Z=z),s.arraySet(W.window,B,v-z,Z,W.wnext),(z-=Z)?(s.arraySet(W.window,B,v-z,z,0),W.wnext=z,W.whave=W.wsize):(W.wnext+=Z,W.wnext===W.wsize&&(W.wnext=0),W.whave<W.wsize&&(W.whave+=Z))),0}i.inflateReset=x,i.inflateReset2=_,i.inflateResetKeep=b,i.inflateInit=function(A){return D(A,15)},i.inflateInit2=D,i.inflate=function(A,B){var v,z,Z,W,Q,G,te,F,R,ne,H,Y,de,fe,se,oe,he,pe,Ae,Le,M,X,j,L,E=0,N=new s.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return p;(v=A.state).mode===12&&(v.mode=13),Q=A.next_out,Z=A.output,te=A.avail_out,W=A.next_in,z=A.input,G=A.avail_in,F=v.hold,R=v.bits,ne=G,H=te,X=f;e:for(;;)switch(v.mode){case d:if(v.wrap===0){v.mode=13;break}for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(2&v.wrap&&F===35615){N[v.check=0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0),R=F=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&F)<<8)+(F>>8))%31){A.msg="incorrect header check",v.mode=30;break}if((15&F)!=8){A.msg="unknown compression method",v.mode=30;break}if(R-=4,M=8+(15&(F>>>=4)),v.wbits===0)v.wbits=M;else if(M>v.wbits){A.msg="invalid window size",v.mode=30;break}v.dmax=1<<M,A.adler=v.check=1,v.mode=512&F?10:12,R=F=0;break;case 2:for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(v.flags=F,(255&v.flags)!=8){A.msg="unknown compression method",v.mode=30;break}if(57344&v.flags){A.msg="unknown header flags set",v.mode=30;break}v.head&&(v.head.text=F>>8&1),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0)),R=F=0,v.mode=3;case 3:for(;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.head&&(v.head.time=F),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,N[2]=F>>>16&255,N[3]=F>>>24&255,v.check=a(v.check,N,4,0)),R=F=0,v.mode=4;case 4:for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.head&&(v.head.xflags=255&F,v.head.os=F>>8),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0)),R=F=0,v.mode=5;case 5:if(1024&v.flags){for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.length=F,v.head&&(v.head.extra_len=F),512&v.flags&&(N[0]=255&F,N[1]=F>>>8&255,v.check=a(v.check,N,2,0)),R=F=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(G<(Y=v.length)&&(Y=G),Y&&(v.head&&(M=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,z,W,Y,M)),512&v.flags&&(v.check=a(v.check,z,Y,W)),G-=Y,W+=Y,v.length-=Y),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(G===0)break e;for(Y=0;M=z[W+Y++],v.head&&M&&v.length<65536&&(v.head.name+=String.fromCharCode(M)),M&&Y<G;);if(512&v.flags&&(v.check=a(v.check,z,Y,W)),G-=Y,W+=Y,M)break e}else v.head&&(v.head.name=null);v.length=0,v.mode=8;case 8:if(4096&v.flags){if(G===0)break e;for(Y=0;M=z[W+Y++],v.head&&M&&v.length<65536&&(v.head.comment+=String.fromCharCode(M)),M&&Y<G;);if(512&v.flags&&(v.check=a(v.check,z,Y,W)),G-=Y,W+=Y,M)break e}else v.head&&(v.head.comment=null);v.mode=9;case 9:if(512&v.flags){for(;R<16;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(F!==(65535&v.check)){A.msg="header crc mismatch",v.mode=30;break}R=F=0}v.head&&(v.head.hcrc=v.flags>>9&1,v.head.done=!0),A.adler=v.check=0,v.mode=12;break;case 10:for(;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}A.adler=v.check=y(F),R=F=0,v.mode=11;case 11:if(v.havedict===0)return A.next_out=Q,A.avail_out=te,A.next_in=W,A.avail_in=G,v.hold=F,v.bits=R,2;A.adler=v.check=1,v.mode=12;case 12:if(B===5||B===6)break e;case 13:if(v.last){F>>>=7&R,R-=7&R,v.mode=27;break}for(;R<3;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}switch(v.last=1&F,R-=1,3&(F>>>=1)){case 0:v.mode=14;break;case 1:if(I(v),v.mode=20,B!==6)break;F>>>=2,R-=2;break e;case 2:v.mode=17;break;case 3:A.msg="invalid block type",v.mode=30}F>>>=2,R-=2;break;case 14:for(F>>>=7&R,R-=7&R;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if((65535&F)!=(F>>>16^65535)){A.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&F,R=F=0,v.mode=15,B===6)break e;case 15:v.mode=16;case 16:if(Y=v.length){if(G<Y&&(Y=G),te<Y&&(Y=te),Y===0)break e;s.arraySet(Z,z,W,Y,Q),G-=Y,W+=Y,te-=Y,Q+=Y,v.length-=Y;break}v.mode=12;break;case 17:for(;R<14;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(v.nlen=257+(31&F),F>>>=5,R-=5,v.ndist=1+(31&F),F>>>=5,R-=5,v.ncode=4+(15&F),F>>>=4,R-=4,286<v.nlen||30<v.ndist){A.msg="too many length or distance symbols",v.mode=30;break}v.have=0,v.mode=18;case 18:for(;v.have<v.ncode;){for(;R<3;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.lens[q[v.have++]]=7&F,F>>>=3,R-=3}for(;v.have<19;)v.lens[q[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,j={bits:v.lenbits},X=h(0,v.lens,0,19,v.lencode,0,v.work,j),v.lenbits=j.bits,X){A.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have<v.nlen+v.ndist;){for(;oe=(E=v.lencode[F&(1<<v.lenbits)-1])>>>16&255,he=65535&E,!((se=E>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(he<16)F>>>=se,R-=se,v.lens[v.have++]=he;else{if(he===16){for(L=se+2;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(F>>>=se,R-=se,v.have===0){A.msg="invalid bit length repeat",v.mode=30;break}M=v.lens[v.have-1],Y=3+(3&F),F>>>=2,R-=2}else if(he===17){for(L=se+3;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}R-=se,M=0,Y=3+(7&(F>>>=se)),F>>>=3,R-=3}else{for(L=se+7;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}R-=se,M=0,Y=11+(127&(F>>>=se)),F>>>=7,R-=7}if(v.have+Y>v.nlen+v.ndist){A.msg="invalid bit length repeat",v.mode=30;break}for(;Y--;)v.lens[v.have++]=M}}if(v.mode===30)break;if(v.lens[256]===0){A.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,j={bits:v.lenbits},X=h(c,v.lens,0,v.nlen,v.lencode,0,v.work,j),v.lenbits=j.bits,X){A.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,j={bits:v.distbits},X=h(u,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,j),v.distbits=j.bits,X){A.msg="invalid distances set",v.mode=30;break}if(v.mode=20,B===6)break e;case 20:v.mode=21;case 21:if(6<=G&&258<=te){A.next_out=Q,A.avail_out=te,A.next_in=W,A.avail_in=G,v.hold=F,v.bits=R,l(A,H),Q=A.next_out,Z=A.output,te=A.avail_out,W=A.next_in,z=A.input,G=A.avail_in,F=v.hold,R=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;oe=(E=v.lencode[F&(1<<v.lenbits)-1])>>>16&255,he=65535&E,!((se=E>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(oe&&(240&oe)==0){for(pe=se,Ae=oe,Le=he;oe=(E=v.lencode[Le+((F&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&E,!(pe+(se=E>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}F>>>=pe,R-=pe,v.back+=pe}if(F>>>=se,R-=se,v.back+=se,v.length=he,oe===0){v.mode=26;break}if(32&oe){v.back=-1,v.mode=12;break}if(64&oe){A.msg="invalid literal/length code",v.mode=30;break}v.extra=15&oe,v.mode=22;case 22:if(v.extra){for(L=v.extra;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.length+=F&(1<<v.extra)-1,F>>>=v.extra,R-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;oe=(E=v.distcode[F&(1<<v.distbits)-1])>>>16&255,he=65535&E,!((se=E>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if((240&oe)==0){for(pe=se,Ae=oe,Le=he;oe=(E=v.distcode[Le+((F&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&E,!(pe+(se=E>>>24)<=R);){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}F>>>=pe,R-=pe,v.back+=pe}if(F>>>=se,R-=se,v.back+=se,64&oe){A.msg="invalid distance code",v.mode=30;break}v.offset=he,v.extra=15&oe,v.mode=24;case 24:if(v.extra){for(L=v.extra;R<L;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}v.offset+=F&(1<<v.extra)-1,F>>>=v.extra,R-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){A.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(te===0)break e;if(Y=H-te,v.offset>Y){if((Y=v.offset-Y)>v.whave&&v.sane){A.msg="invalid distance too far back",v.mode=30;break}de=Y>v.wnext?(Y-=v.wnext,v.wsize-Y):v.wnext-Y,Y>v.length&&(Y=v.length),fe=v.window}else fe=Z,de=Q-v.offset,Y=v.length;for(te<Y&&(Y=te),te-=Y,v.length-=Y;Z[Q++]=fe[de++],--Y;);v.length===0&&(v.mode=21);break;case 26:if(te===0)break e;Z[Q++]=v.length,te--,v.mode=21;break;case 27:if(v.wrap){for(;R<32;){if(G===0)break e;G--,F|=z[W++]<<R,R+=8}if(H-=te,A.total_out+=H,v.total+=H,H&&(A.adler=v.check=v.flags?a(v.check,Z,H,Q-H):o(v.check,Z,H,Q-H)),H=te,(v.flags?F:y(F))!==v.check){A.msg="incorrect data check",v.mode=30;break}R=F=0}v.mode=28;case 28:if(v.wrap&&v.flags){for(;R<32;){if(G===0)break e;G--,F+=z[W++]<<R,R+=8}if(F!==(4294967295&v.total)){A.msg="incorrect length check",v.mode=30;break}R=F=0}v.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;case 32:default:return p}return A.next_out=Q,A.avail_out=te,A.next_in=W,A.avail_in=G,v.hold=F,v.bits=R,(v.wsize||H!==A.avail_out&&v.mode<30&&(v.mode<27||B!==4))&&O(A,A.output,A.next_out,H-A.avail_out)?(v.mode=31,-4):(ne-=A.avail_in,H-=A.avail_out,A.total_in+=ne,A.total_out+=H,v.total+=H,v.wrap&&H&&(A.adler=v.check=v.flags?a(v.check,Z,H,A.next_out-H):o(v.check,Z,H,A.next_out-H)),A.data_type=v.bits+(v.last?64:0)+(v.mode===12?128:0)+(v.mode===20||v.mode===15?256:0),(ne==0&&H===0||B===4)&&X===f&&(X=-5),X)},i.inflateEnd=function(A){if(!A||!A.state)return p;var B=A.state;return B.window&&(B.window=null),A.state=null,f},i.inflateGetHeader=function(A,B){var v;return A&&A.state?(2&(v=A.state).wrap)==0?p:((v.head=B).done=!1,f):p},i.inflateSetDictionary=function(A,B){var v,z=B.length;return A&&A.state?(v=A.state).wrap!==0&&v.mode!==11?p:v.mode===11&&o(1,B,z,0)!==v.check?-3:O(A,B,z,z)?(v.mode=31,-4):(v.havedict=1,f):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var s=t("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],h=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(c,u,f,p,d,m,g,y){var w,b,x,_,D,P,k,C,I,O=y.bits,A=0,B=0,v=0,z=0,Z=0,W=0,Q=0,G=0,te=0,F=0,R=null,ne=0,H=new s.Buf16(16),Y=new s.Buf16(16),de=null,fe=0;for(A=0;A<=15;A++)H[A]=0;for(B=0;B<p;B++)H[u[f+B]]++;for(Z=O,z=15;1<=z&&H[z]===0;z--);if(z<Z&&(Z=z),z===0)return d[m++]=20971520,d[m++]=20971520,y.bits=1,0;for(v=1;v<z&&H[v]===0;v++);for(Z<v&&(Z=v),A=G=1;A<=15;A++)if(G<<=1,(G-=H[A])<0)return-1;if(0<G&&(c===0||z!==1))return-1;for(Y[1]=0,A=1;A<15;A++)Y[A+1]=Y[A]+H[A];for(B=0;B<p;B++)u[f+B]!==0&&(g[Y[u[f+B]]++]=B);if(P=c===0?(R=de=g,19):c===1?(R=o,ne-=257,de=a,fe-=257,256):(R=l,de=h,-1),A=v,D=m,Q=B=F=0,x=-1,_=(te=1<<(W=Z))-1,c===1&&852<te||c===2&&592<te)return 1;for(;;){for(k=A-Q,I=g[B]<P?(C=0,g[B]):g[B]>P?(C=de[fe+g[B]],R[ne+g[B]]):(C=96,0),w=1<<A-Q,v=b=1<<W;d[D+(F>>Q)+(b-=w)]=k<<24|C<<16|I|0,b!==0;);for(w=1<<A-1;F&w;)w>>=1;if(w!==0?(F&=w-1,F+=w):F=0,B++,--H[A]==0){if(A===z)break;A=u[f+g[B]]}if(Z<A&&(F&_)!==x){for(Q===0&&(Q=Z),D+=v,G=1<<(W=A-Q);W+Q<z&&!((G-=H[W+Q])<=0);)W++,G<<=1;if(te+=1<<W,c===1&&852<te||c===2&&592<te)return 1;d[x=F&_]=Z<<24|W<<16|D-m|0}}return F!==0&&(d[D+F]=A-Q<<24|64<<16|0),y.bits=Z,0}},{"../utils/common":41}],51:[function(t,n,i){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,n,i){var s=t("../utils/common"),o=0,a=1;function l(E){for(var N=E.length;0<=--N;)E[N]=0}var h=0,c=29,u=256,f=u+1+c,p=30,d=19,m=2*f+1,g=15,y=16,w=7,b=256,x=16,_=17,D=18,P=[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],k=[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],C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(f+2));l(O);var A=new Array(2*p);l(A);var B=new Array(512);l(B);var v=new Array(256);l(v);var z=new Array(c);l(z);var Z,W,Q,G=new Array(p);function te(E,N,q,K,U){this.static_tree=E,this.extra_bits=N,this.extra_base=q,this.elems=K,this.max_length=U,this.has_stree=E&&E.length}function F(E,N){this.dyn_tree=E,this.max_code=0,this.stat_desc=N}function R(E){return E<256?B[E]:B[256+(E>>>7)]}function ne(E,N){E.pending_buf[E.pending++]=255&N,E.pending_buf[E.pending++]=N>>>8&255}function H(E,N,q){E.bi_valid>y-q?(E.bi_buf|=N<<E.bi_valid&65535,ne(E,E.bi_buf),E.bi_buf=N>>y-E.bi_valid,E.bi_valid+=q-y):(E.bi_buf|=N<<E.bi_valid&65535,E.bi_valid+=q)}function Y(E,N,q){H(E,q[2*N],q[2*N+1])}function de(E,N){for(var q=0;q|=1&E,E>>>=1,q<<=1,0<--N;);return q>>>1}function fe(E,N,q){var K,U,$=new Array(g+1),ee=0;for(K=1;K<=g;K++)$[K]=ee=ee+q[K-1]<<1;for(U=0;U<=N;U++){var J=E[2*U+1];J!==0&&(E[2*U]=de($[J]++,J))}}function se(E){var N;for(N=0;N<f;N++)E.dyn_ltree[2*N]=0;for(N=0;N<p;N++)E.dyn_dtree[2*N]=0;for(N=0;N<d;N++)E.bl_tree[2*N]=0;E.dyn_ltree[2*b]=1,E.opt_len=E.static_len=0,E.last_lit=E.matches=0}function oe(E){8<E.bi_valid?ne(E,E.bi_buf):0<E.bi_valid&&(E.pending_buf[E.pending++]=E.bi_buf),E.bi_buf=0,E.bi_valid=0}function he(E,N,q,K){var U=2*N,$=2*q;return E[U]<E[$]||E[U]===E[$]&&K[N]<=K[q]}function pe(E,N,q){for(var K=E.heap[q],U=q<<1;U<=E.heap_len&&(U<E.heap_len&&he(N,E.heap[U+1],E.heap[U],E.depth)&&U++,!he(N,K,E.heap[U],E.depth));)E.heap[q]=E.heap[U],q=U,U<<=1;E.heap[q]=K}function Ae(E,N,q){var K,U,$,ee,J=0;if(E.last_lit!==0)for(;K=E.pending_buf[E.d_buf+2*J]<<8|E.pending_buf[E.d_buf+2*J+1],U=E.pending_buf[E.l_buf+J],J++,K===0?Y(E,U,N):(Y(E,($=v[U])+u+1,N),(ee=P[$])!==0&&H(E,U-=z[$],ee),Y(E,$=R(--K),q),(ee=k[$])!==0&&H(E,K-=G[$],ee)),J<E.last_lit;);Y(E,b,N)}function Le(E,N){var q,K,U,$=N.dyn_tree,ee=N.stat_desc.static_tree,J=N.stat_desc.has_stree,ie=N.stat_desc.elems,ce=-1;for(E.heap_len=0,E.heap_max=m,q=0;q<ie;q++)$[2*q]!==0?(E.heap[++E.heap_len]=ce=q,E.depth[q]=0):$[2*q+1]=0;for(;E.heap_len<2;)$[2*(U=E.heap[++E.heap_len]=ce<2?++ce:0)]=1,E.depth[U]=0,E.opt_len--,J&&(E.static_len-=ee[2*U+1]);for(N.max_code=ce,q=E.heap_len>>1;1<=q;q--)pe(E,$,q);for(U=ie;q=E.heap[1],E.heap[1]=E.heap[E.heap_len--],pe(E,$,1),K=E.heap[1],E.heap[--E.heap_max]=q,E.heap[--E.heap_max]=K,$[2*U]=$[2*q]+$[2*K],E.depth[U]=(E.depth[q]>=E.depth[K]?E.depth[q]:E.depth[K])+1,$[2*q+1]=$[2*K+1]=U,E.heap[1]=U++,pe(E,$,1),2<=E.heap_len;);E.heap[--E.heap_max]=E.heap[1],(function(ae,Te){var $e,ke,Ot,ge,Qt,wn,Je=Te.dyn_tree,bt=Te.max_code,zt=Te.stat_desc.static_tree,Nt=Te.stat_desc.has_stree,Rt=Te.stat_desc.extra_bits,xt=Te.stat_desc.extra_base,bn=Te.stat_desc.max_length,yi=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(Je[2*ae.heap[ae.heap_max]+1]=0,$e=ae.heap_max+1;$e<m;$e++)bn<(ge=Je[2*Je[2*(ke=ae.heap[$e])+1]+1]+1)&&(ge=bn,yi++),Je[2*ke+1]=ge,bt<ke||(ae.bl_count[ge]++,Qt=0,xt<=ke&&(Qt=Rt[ke-xt]),wn=Je[2*ke],ae.opt_len+=wn*(ge+Qt),Nt&&(ae.static_len+=wn*(zt[2*ke+1]+Qt)));if(yi!==0){do{for(ge=bn-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[bn]--,yi-=2}while(0<yi);for(ge=bn;ge!==0;ge--)for(ke=ae.bl_count[ge];ke!==0;)bt<(Ot=ae.heap[--$e])||(Je[2*Ot+1]!==ge&&(ae.opt_len+=(ge-Je[2*Ot+1])*Je[2*Ot],Je[2*Ot+1]=ge),ke--)}})(E,N),fe($,ce,E.bl_count)}function M(E,N,q){var K,U,$=-1,ee=N[1],J=0,ie=7,ce=4;for(ee===0&&(ie=138,ce=3),N[2*(q+1)+1]=65535,K=0;K<=q;K++)U=ee,ee=N[2*(K+1)+1],++J<ie&&U===ee||(J<ce?E.bl_tree[2*U]+=J:U!==0?(U!==$&&E.bl_tree[2*U]++,E.bl_tree[2*x]++):J<=10?E.bl_tree[2*_]++:E.bl_tree[2*D]++,$=U,ce=(J=0)===ee?(ie=138,3):U===ee?(ie=6,3):(ie=7,4))}function X(E,N,q){var K,U,$=-1,ee=N[1],J=0,ie=7,ce=4;for(ee===0&&(ie=138,ce=3),K=0;K<=q;K++)if(U=ee,ee=N[2*(K+1)+1],!(++J<ie&&U===ee)){if(J<ce)for(;Y(E,U,E.bl_tree),--J!=0;);else U!==0?(U!==$&&(Y(E,U,E.bl_tree),J--),Y(E,x,E.bl_tree),H(E,J-3,2)):J<=10?(Y(E,_,E.bl_tree),H(E,J-3,3)):(Y(E,D,E.bl_tree),H(E,J-11,7));$=U,ce=(J=0)===ee?(ie=138,3):U===ee?(ie=6,3):(ie=7,4)}}l(G);var j=!1;function L(E,N,q,K){H(E,(h<<1)+(K?1:0),3),(function(U,$,ee,J){oe(U),ne(U,ee),ne(U,~ee),s.arraySet(U.pending_buf,U.window,$,ee,U.pending),U.pending+=ee})(E,N,q)}i._tr_init=function(E){j||((function(){var N,q,K,U,$,ee=new Array(g+1);for(U=K=0;U<c-1;U++)for(z[U]=K,N=0;N<1<<P[U];N++)v[K++]=U;for(v[K-1]=U,U=$=0;U<16;U++)for(G[U]=$,N=0;N<1<<k[U];N++)B[$++]=U;for($>>=7;U<p;U++)for(G[U]=$<<7,N=0;N<1<<k[U]-7;N++)B[256+$++]=U;for(q=0;q<=g;q++)ee[q]=0;for(N=0;N<=143;)O[2*N+1]=8,N++,ee[8]++;for(;N<=255;)O[2*N+1]=9,N++,ee[9]++;for(;N<=279;)O[2*N+1]=7,N++,ee[7]++;for(;N<=287;)O[2*N+1]=8,N++,ee[8]++;for(fe(O,f+1,ee),N=0;N<p;N++)A[2*N+1]=5,A[2*N]=de(N,5);Z=new te(O,P,u+1,f,g),W=new te(A,k,0,p,g),Q=new te(new Array(0),C,0,d,w)})(),j=!0),E.l_desc=new F(E.dyn_ltree,Z),E.d_desc=new F(E.dyn_dtree,W),E.bl_desc=new F(E.bl_tree,Q),E.bi_buf=0,E.bi_valid=0,se(E)},i._tr_stored_block=L,i._tr_flush_block=function(E,N,q,K){var U,$,ee=0;0<E.level?(E.strm.data_type===2&&(E.strm.data_type=(function(J){var ie,ce=4093624447;for(ie=0;ie<=31;ie++,ce>>>=1)if(1&ce&&J.dyn_ltree[2*ie]!==0)return o;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return a;for(ie=32;ie<u;ie++)if(J.dyn_ltree[2*ie]!==0)return a;return o})(E)),Le(E,E.l_desc),Le(E,E.d_desc),ee=(function(J){var ie;for(M(J,J.dyn_ltree,J.l_desc.max_code),M(J,J.dyn_dtree,J.d_desc.max_code),Le(J,J.bl_desc),ie=d-1;3<=ie&&J.bl_tree[2*I[ie]+1]===0;ie--);return J.opt_len+=3*(ie+1)+5+5+4,ie})(E),U=E.opt_len+3+7>>>3,($=E.static_len+3+7>>>3)<=U&&(U=$)):U=$=q+5,q+4<=U&&N!==-1?L(E,N,q,K):E.strategy===4||$===U?(H(E,2+(K?1:0),3),Ae(E,O,A)):(H(E,4+(K?1:0),3),(function(J,ie,ce,ae){var Te;for(H(J,ie-257,5),H(J,ce-1,5),H(J,ae-4,4),Te=0;Te<ae;Te++)H(J,J.bl_tree[2*I[Te]+1],3);X(J,J.dyn_ltree,ie-1),X(J,J.dyn_dtree,ce-1)})(E,E.l_desc.max_code+1,E.d_desc.max_code+1,ee+1),Ae(E,E.dyn_ltree,E.dyn_dtree)),se(E),K&&oe(E)},i._tr_tally=function(E,N,q){return E.pending_buf[E.d_buf+2*E.last_lit]=N>>>8&255,E.pending_buf[E.d_buf+2*E.last_lit+1]=255&N,E.pending_buf[E.l_buf+E.last_lit]=255&q,E.last_lit++,N===0?E.dyn_ltree[2*q]++:(E.matches++,N--,E.dyn_ltree[2*(v[q]+u+1)]++,E.dyn_dtree[2*R(N)]++),E.last_lit===E.lit_bufsize-1},i._tr_align=function(E){H(E,2,3),Y(E,b,O),(function(N){N.bi_valid===16?(ne(N,N.bi_buf),N.bi_buf=0,N.bi_valid=0):8<=N.bi_valid&&(N.pending_buf[N.pending++]=255&N.bi_buf,N.bi_buf>>=8,N.bi_valid-=8)})(E)}},{"../utils/common":41}],53:[function(t,n,i){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,n,i){(function(s){(function(o,a){if(!o.setImmediate){var l,h,c,u,f=1,p={},d=!1,m=o.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(o);g=g&&g.setTimeout?g:o,l={}.toString.call(o.process)==="[object process]"?function(x){process.nextTick(function(){w(x)})}:(function(){if(o.postMessage&&!o.importScripts){var x=!0,_=o.onmessage;return o.onmessage=function(){x=!1},o.postMessage("","*"),o.onmessage=_,x}})()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",b,!1):o.attachEvent("onmessage",b),function(x){o.postMessage(u+x,"*")}):o.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){w(x.data)},function(x){c.port2.postMessage(x)}):m&&"onreadystatechange"in m.createElement("script")?(h=m.documentElement,function(x){var _=m.createElement("script");_.onreadystatechange=function(){w(x),_.onreadystatechange=null,h.removeChild(_),_=null},h.appendChild(_)}):function(x){setTimeout(w,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var _=new Array(arguments.length-1),D=0;D<_.length;D++)_[D]=arguments[D+1];var P={callback:x,args:_};return p[f]=P,l(f),f++},g.clearImmediate=y}function y(x){delete p[x]}function w(x){if(d)setTimeout(w,0,x);else{var _=p[x];if(_){d=!0;try{(function(D){var P=D.callback,k=D.args;switch(k.length){case 0:P();break;case 1:P(k[0]);break;case 2:P(k[0],k[1]);break;case 3:P(k[0],k[1],k[2]);break;default:P.apply(a,k)}})(_)}finally{y(x),d=!1}}}}function b(x){x.source===o&&typeof x.data=="string"&&x.data.indexOf(u)===0&&w(+x.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Cn<"u"?Cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Mi)),Mi.exports}var ga=ma();const Ns=Os(ga);function Rs(r,e){return function(){return r.apply(e,arguments)}}const{toString:ya}=Object.prototype,{getPrototypeOf:Si}=Object,{iterator:Dn,toStringTag:Fs}=Symbol,kn=(r=>e=>{const t=ya.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ke=r=>(r=r.toLowerCase(),e=>kn(e)===r),In=r=>e=>typeof e===r,{isArray:Ut}=Array,Vt=In("undefined");function en(r){return r!==null&&!Vt(r)&&r.constructor!==null&&!Vt(r.constructor)&&Ne(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const Us=Ke("ArrayBuffer");function wa(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Us(r.buffer),e}const ba=In("string"),Ne=In("function"),Vs=In("number"),tn=r=>r!==null&&typeof r=="object",xa=r=>r===!0||r===!1,En=r=>{if(kn(r)!=="object")return!1;const e=Si(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Fs in r)&&!(Dn in r)},_a=r=>{if(!tn(r)||en(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},va=Ke("Date"),Ma=Ke("File"),Sa=Ke("Blob"),Aa=Ke("FileList"),Ta=r=>tn(r)&&Ne(r.pipe),Ca=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Ne(r.append)&&((e=kn(r))==="formdata"||e==="object"&&Ne(r.toString)&&r.toString()==="[object FormData]"))},Pa=Ke("URLSearchParams"),[Da,ka,Ia,Ea]=["ReadableStream","Request","Response","Headers"].map(Ke),Ba=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nn(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,i;if(typeof r!="object"&&(r=[r]),Ut(r))for(n=0,i=r.length;n<i;n++)e.call(null,r[n],n,r);else{if(en(r))return;const s=t?Object.getOwnPropertyNames(r):Object.keys(r),o=s.length;let a;for(n=0;n<o;n++)a=s[n],e.call(null,r[a],a,r)}}function js(r,e){if(en(r))return null;e=e.toLowerCase();const t=Object.keys(r);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const vt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Gs=r=>!Vt(r)&&r!==vt;function Ai(){const{caseless:r,skipUndefined:e}=Gs(this)&&this||{},t={},n=(i,s)=>{const o=r&&js(t,s)||s;En(t[o])&&En(i)?t[o]=Ai(t[o],i):En(i)?t[o]=Ai({},i):Ut(i)?t[o]=i.slice():(!e||!Vt(i))&&(t[o]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&nn(arguments[i],n);return t}const La=(r,e,t,{allOwnKeys:n}={})=>(nn(e,(i,s)=>{t&&Ne(i)?r[s]=Rs(i,t):r[s]=i},{allOwnKeys:n}),r),Oa=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),za=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},Na=(r,e,t,n)=>{let i,s,o;const a={};if(e=e||{},r==null)return e;do{for(i=Object.getOwnPropertyNames(r),s=i.length;s-- >0;)o=i[s],(!n||n(o,r,e))&&!a[o]&&(e[o]=r[o],a[o]=!0);r=t!==!1&&Si(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Ra=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const n=r.indexOf(e,t);return n!==-1&&n===t},Fa=r=>{if(!r)return null;if(Ut(r))return r;let e=r.length;if(!Vs(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},Ua=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&Si(Uint8Array)),Va=(r,e)=>{const n=(r&&r[Dn]).call(r);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(r,s[0],s[1])}},ja=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},Ga=Ke("HTMLFormElement"),Wa=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Ws=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Xa=Ke("RegExp"),Xs=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};nn(t,(i,s)=>{let o;(o=e(i,s,r))!==!1&&(n[s]=o||i)}),Object.defineProperties(r,n)},qa=r=>{Xs(r,(e,t)=>{if(Ne(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(Ne(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Ka=(r,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return Ut(r)?n(r):n(String(r).split(e)),t},Za=()=>{},Ya=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function $a(r){return!!(r&&Ne(r.append)&&r[Fs]==="FormData"&&r[Dn])}const Ja=r=>{const e=new Array(10),t=(n,i)=>{if(tn(n)){if(e.indexOf(n)>=0)return;if(en(n))return n;if(!("toJSON"in n)){e[i]=n;const s=Ut(n)?[]:{};return nn(n,(o,a)=>{const l=t(o,i+1);!Vt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(r,0)},Ha=Ke("AsyncFunction"),Qa=r=>r&&(tn(r)||Ne(r))&&Ne(r.then)&&Ne(r.catch),qs=((r,e)=>r?setImmediate:e?((t,n)=>(vt.addEventListener("message",({source:i,data:s})=>{i===vt&&s===t&&n.length&&n.shift()()},!1),i=>{n.push(i),vt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ne(vt.postMessage)),el=typeof queueMicrotask<"u"?queueMicrotask.bind(vt):typeof process<"u"&&process.nextTick||qs,V={isArray:Ut,isArrayBuffer:Us,isBuffer:en,isFormData:Ca,isArrayBufferView:wa,isString:ba,isNumber:Vs,isBoolean:xa,isObject:tn,isPlainObject:En,isEmptyObject:_a,isReadableStream:Da,isRequest:ka,isResponse:Ia,isHeaders:Ea,isUndefined:Vt,isDate:va,isFile:Ma,isBlob:Sa,isRegExp:Xa,isFunction:Ne,isStream:Ta,isURLSearchParams:Pa,isTypedArray:Ua,isFileList:Aa,forEach:nn,merge:Ai,extend:La,trim:Ba,stripBOM:Oa,inherits:za,toFlatObject:Na,kindOf:kn,kindOfTest:Ke,endsWith:Ra,toArray:Fa,forEachEntry:Va,matchAll:ja,isHTMLForm:Ga,hasOwnProperty:Ws,hasOwnProp:Ws,reduceDescriptors:Xs,freezeMethods:qa,toObjectSet:Ka,toCamelCase:Wa,noop:Za,toFiniteNumber:Ya,findKey:js,global:vt,isContextDefined:Gs,isSpecCompliantForm:$a,toJSONObject:Ja,isAsyncFn:Ha,isThenable:Qa,setImmediate:qs,asap:el,isIterable:r=>r!=null&&Ne(r[Dn])};function re(r,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}V.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const Ks=re.prototype,Zs={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{Zs[r]={value:r}}),Object.defineProperties(re,Zs),Object.defineProperty(Ks,"isAxiosError",{value:!0}),re.from=(r,e,t,n,i,s)=>{const o=Object.create(Ks);V.toFlatObject(r,o,function(c){return c!==Error.prototype},h=>h!=="isAxiosError");const a=r&&r.message?r.message:"Error",l=e==null&&r?r.code:e;return re.call(o,a,l,t,n,i),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",s&&Object.assign(o,s),o};const tl=null;function Ti(r){return V.isPlainObject(r)||V.isArray(r)}function Ys(r){return V.endsWith(r,"[]")?r.slice(0,-2):r}function $s(r,e,t){return r?r.concat(e).map(function(i,s){return i=Ys(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function nl(r){return V.isArray(r)&&!r.some(Ti)}const il=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)});function Bn(r,e,t){if(!V.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=V.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!V.isUndefined(g[m])});const n=t.metaTokens,i=t.visitor||c,s=t.dots,o=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(e);if(!V.isFunction(i))throw new TypeError("visitor must be a function");function h(d){if(d===null)return"";if(V.isDate(d))return d.toISOString();if(V.isBoolean(d))return d.toString();if(!l&&V.isBlob(d))throw new re("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(d)||V.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,m,g){let y=d;if(d&&!g&&typeof d=="object"){if(V.endsWith(m,"{}"))m=n?m:m.slice(0,-2),d=JSON.stringify(d);else if(V.isArray(d)&&nl(d)||(V.isFileList(d)||V.endsWith(m,"[]"))&&(y=V.toArray(d)))return m=Ys(m),y.forEach(function(b,x){!(V.isUndefined(b)||b===null)&&e.append(o===!0?$s([m],x,s):o===null?m:m+"[]",h(b))}),!1}return Ti(d)?!0:(e.append($s(g,m,s),h(d)),!1)}const u=[],f=Object.assign(il,{defaultVisitor:c,convertValue:h,isVisitable:Ti});function p(d,m){if(!V.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+m.join("."));u.push(d),V.forEach(d,function(y,w){(!(V.isUndefined(y)||y===null)&&i.call(e,y,V.isString(w)?w.trim():w,m,f))===!0&&p(y,m?m.concat(w):[w])}),u.pop()}}if(!V.isObject(r))throw new TypeError("data must be an object");return p(r),e}function Js(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Ci(r,e){this._pairs=[],r&&Bn(r,this,e)}const Hs=Ci.prototype;Hs.append=function(e,t){this._pairs.push([e,t])},Hs.toString=function(e){const t=e?function(n){return e.call(this,n,Js)}:Js;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function sl(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Qs(r,e,t){if(!e)return r;const n=t&&t.encode||sl;V.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=V.isURLSearchParams(e)?e.toString():new Ci(e,t).toString(n),s){const o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class er{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(n){n!==null&&e(n)})}}const tr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},rl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ci,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Pi=typeof window<"u"&&typeof document<"u",Di=typeof navigator=="object"&&navigator||void 0,ol=Pi&&(!Di||["ReactNative","NativeScript","NS"].indexOf(Di.product)<0),al=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ll=Pi&&window.location.href||"http://localhost",De={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Pi,hasStandardBrowserEnv:ol,hasStandardBrowserWebWorkerEnv:al,navigator:Di,origin:ll},Symbol.toStringTag,{value:"Module"})),...rl};function cl(r,e){return Bn(r,new De.classes.URLSearchParams,{visitor:function(t,n,i,s){return De.isNode&&V.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function hl(r){return V.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ul(r){const e={},t=Object.keys(r);let n;const i=t.length;let s;for(n=0;n<i;n++)s=t[n],e[s]=r[s];return e}function nr(r){function e(t,n,i,s){let o=t[s++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),l=s>=t.length;return o=!o&&V.isArray(i)?i.length:o,l?(V.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!V.isObject(i[o]))&&(i[o]=[]),e(t,n,i[o],s)&&V.isArray(i[o])&&(i[o]=ul(i[o])),!a)}if(V.isFormData(r)&&V.isFunction(r.entries)){const t={};return V.forEachEntry(r,(n,i)=>{e(hl(n),i,t,0)}),t}return null}function dl(r,e,t){if(V.isString(r))try{return(e||JSON.parse)(r),V.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}const sn={transitional:tr,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=V.isObject(e);if(s&&V.isHTMLForm(e)&&(e=new FormData(e)),V.isFormData(e))return i?JSON.stringify(nr(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return cl(e,this.formSerializer).toString();if((a=V.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Bn(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),dl(e)):e}],transformResponse:[function(e){const t=this.transitional||sn.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(n&&!this.responseType||i)){const o=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?re.from(a,re.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:De.classes.FormData,Blob:De.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],r=>{sn.headers[r]={}});const fl=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),pl=r=>{const e={};let t,n,i;return r&&r.split(`
754
+ `).forEach(function(o){i=o.indexOf(":"),t=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!t||e[t]&&fl[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},ir=Symbol("internals");function rn(r){return r&&String(r).trim().toLowerCase()}function Ln(r){return r===!1||r==null?r:V.isArray(r)?r.map(Ln):String(r)}function ml(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}const gl=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function ki(r,e,t,n,i){if(V.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!V.isString(e)){if(V.isString(n))return e.indexOf(n)!==-1;if(V.isRegExp(n))return n.test(e)}}function yl(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function wl(r,e){const t=V.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(i,s,o){return this[n].call(this,e,i,s,o)},configurable:!0})})}let Re=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(a,l,h){const c=rn(l);if(!c)throw new Error("header name must be a non-empty string");const u=V.findKey(i,c);(!u||i[u]===void 0||h===!0||h===void 0&&i[u]!==!1)&&(i[u||l]=Ln(a))}const o=(a,l)=>V.forEach(a,(h,c)=>s(h,c,l));if(V.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(V.isString(e)&&(e=e.trim())&&!gl(e))o(pl(e),t);else if(V.isObject(e)&&V.isIterable(e)){let a={},l,h;for(const c of e){if(!V.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[h=c[0]]=(l=a[h])?V.isArray(l)?[...l,c[1]]:[l,c[1]]:c[1]}o(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=rn(e),e){const n=V.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return ml(i);if(V.isFunction(t))return t.call(this,i,n);if(V.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=rn(e),e){const n=V.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||ki(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function s(o){if(o=rn(o),o){const a=V.findKey(n,o);a&&(!t||ki(n,n[a],a,t))&&(delete n[a],i=!0)}}return V.isArray(e)?e.forEach(s):s(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const s=t[n];(!e||ki(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return V.forEach(this,(i,s)=>{const o=V.findKey(n,s);if(o){t[o]=Ln(i),delete t[s];return}const a=e?yl(s):String(s).trim();a!==s&&delete t[s],t[a]=Ln(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return V.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&V.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
755
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[ir]=this[ir]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=rn(o);n[a]||(wl(i,o),n[a]=!0)}return V.isArray(e)?e.forEach(s):s(e),this}};Re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Re.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),V.freezeMethods(Re);function Ii(r,e){const t=this||sn,n=e||t,i=Re.from(n.headers);let s=n.data;return V.forEach(r,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function sr(r){return!!(r&&r.__CANCEL__)}function jt(r,e,t){re.call(this,r??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}V.inherits(jt,re,{__CANCEL__:!0});function rr(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new re("Request failed with status code "+t.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function bl(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function xl(r,e){r=r||10;const t=new Array(r),n=new Array(r);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(l){const h=Date.now(),c=n[s];o||(o=h),t[i]=l,n[i]=h;let u=s,f=0;for(;u!==i;)f+=t[u++],u=u%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),h-o<e)return;const p=c&&h-c;return p?Math.round(f*1e3/p):void 0}}function _l(r,e){let t=0,n=1e3/e,i,s;const o=(h,c=Date.now())=>{t=c,i=null,s&&(clearTimeout(s),s=null),r(...h)};return[(...h)=>{const c=Date.now(),u=c-t;u>=n?o(h,c):(i=h,s||(s=setTimeout(()=>{s=null,o(i)},n-u)))},()=>i&&o(i)]}const On=(r,e,t=3)=>{let n=0;const i=xl(50,250);return _l(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,l=o-n,h=i(l),c=o<=a;n=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:h||void 0,estimated:h&&a&&c?(a-o)/h:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};r(u)},t)},or=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},ar=r=>(...e)=>V.asap(()=>r(...e)),vl=De.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,De.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(De.origin),De.navigator&&/(msie|trident)/i.test(De.navigator.userAgent)):()=>!0,Ml=De.hasStandardBrowserEnv?{write(r,e,t,n,i,s,o){if(typeof document>"u")return;const a=[`${r}=${encodeURIComponent(e)}`];V.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),V.isString(n)&&a.push(`path=${n}`),V.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),V.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(r){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+r+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(r){this.write(r,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Sl(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Al(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function lr(r,e,t){let n=!Sl(e);return r&&(n||t==!1)?Al(r,e):e}const cr=r=>r instanceof Re?{...r}:r;function Mt(r,e){e=e||{};const t={};function n(h,c,u,f){return V.isPlainObject(h)&&V.isPlainObject(c)?V.merge.call({caseless:f},h,c):V.isPlainObject(c)?V.merge({},c):V.isArray(c)?c.slice():c}function i(h,c,u,f){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h,u,f)}else return n(h,c,u,f)}function s(h,c){if(!V.isUndefined(c))return n(void 0,c)}function o(h,c){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h)}else return n(void 0,c)}function a(h,c,u){if(u in e)return n(h,c);if(u in r)return n(void 0,h)}const l={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(h,c,u)=>i(cr(h),cr(c),u,!0)};return V.forEach(Object.keys({...r,...e}),function(c){const u=l[c]||i,f=u(r[c],e[c],c);V.isUndefined(f)&&u!==a||(t[c]=f)}),t}const hr=r=>{const e=Mt({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;if(e.headers=o=Re.from(o),e.url=Qs(lr(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(t)){if(De.hasStandardBrowserEnv||De.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(V.isFunction(t.getHeaders)){const l=t.getHeaders(),h=["content-type","content-length"];Object.entries(l).forEach(([c,u])=>{h.includes(c.toLowerCase())&&o.set(c,u)})}}if(De.hasStandardBrowserEnv&&(n&&V.isFunction(n)&&(n=n(e)),n||n!==!1&&vl(e.url))){const l=i&&s&&Ml.read(s);l&&o.set(i,l)}return e},Tl=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const i=hr(r);let s=i.data;const o=Re.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:h}=i,c,u,f,p,d;function m(){p&&p(),d&&d(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const b=Re.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),_={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:b,config:r,request:g};rr(function(P){t(P),m()},function(P){n(P),m()},_),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(n(new re("Request aborted",re.ECONNABORTED,r,g)),g=null)},g.onerror=function(x){const _=x&&x.message?x.message:"Network Error",D=new re(_,re.ERR_NETWORK,r,g);D.event=x||null,n(D),g=null},g.ontimeout=function(){let x=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const _=i.transitional||tr;i.timeoutErrorMessage&&(x=i.timeoutErrorMessage),n(new re(x,_.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,r,g)),g=null},s===void 0&&o.setContentType(null),"setRequestHeader"in g&&V.forEach(o.toJSON(),function(x,_){g.setRequestHeader(_,x)}),V.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),h&&([f,d]=On(h,!0),g.addEventListener("progress",f)),l&&g.upload&&([u,p]=On(l),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(c=b=>{g&&(n(!b||b.type?new jt(null,r,g):b),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const w=bl(i.url);if(w&&De.protocols.indexOf(w)===-1){n(new re("Unsupported protocol "+w+":",re.ERR_BAD_REQUEST,r));return}g.send(s||null)})},Cl=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,i;const s=function(h){if(!i){i=!0,a();const c=h instanceof Error?h:this.reason;n.abort(c instanceof re?c:new jt(c instanceof Error?c.message:c))}};let o=e&&setTimeout(()=>{o=null,s(new re(`timeout ${e} of ms exceeded`,re.ETIMEDOUT))},e);const a=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),r=null)};r.forEach(h=>h.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>V.asap(a),l}},Pl=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let n=0,i;for(;n<t;)i=n+e,yield r.slice(n,i),n=i},Dl=async function*(r,e){for await(const t of kl(r))yield*Pl(t,e)},kl=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},ur=(r,e,t,n)=>{const i=Dl(r,e);let s=0,o,a=l=>{o||(o=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:h,value:c}=await i.next();if(h){a(),l.close();return}let u=c.byteLength;if(t){let f=s+=u;t(f)}l.enqueue(new Uint8Array(c))}catch(h){throw a(h),h}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},dr=64*1024,{isFunction:zn}=V,Il=(({Request:r,Response:e})=>({Request:r,Response:e}))(V.global),{ReadableStream:fr,TextEncoder:pr}=V.global,mr=(r,...e)=>{try{return!!r(...e)}catch{return!1}},El=r=>{r=V.merge.call({skipUndefined:!0},Il,r);const{fetch:e,Request:t,Response:n}=r,i=e?zn(e):typeof fetch=="function",s=zn(t),o=zn(n);if(!i)return!1;const a=i&&zn(fr),l=i&&(typeof pr=="function"?(d=>m=>d.encode(m))(new pr):async d=>new Uint8Array(await new t(d).arrayBuffer())),h=s&&a&&mr(()=>{let d=!1;const m=new t(De.origin,{body:new fr,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!m}),c=o&&a&&mr(()=>V.isReadableStream(new n("").body)),u={stream:c&&(d=>d.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(m,g)=>{let y=m&&m[d];if(y)return y.call(m);throw new re(`Response type '${d}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const f=async d=>{if(d==null)return 0;if(V.isBlob(d))return d.size;if(V.isSpecCompliantForm(d))return(await new t(De.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(V.isArrayBufferView(d)||V.isArrayBuffer(d))return d.byteLength;if(V.isURLSearchParams(d)&&(d=d+""),V.isString(d))return(await l(d)).byteLength},p=async(d,m)=>{const g=V.toFiniteNumber(d.getContentLength());return g??f(m)};return async d=>{let{url:m,method:g,data:y,signal:w,cancelToken:b,timeout:x,onDownloadProgress:_,onUploadProgress:D,responseType:P,headers:k,withCredentials:C="same-origin",fetchOptions:I}=hr(d),O=e||fetch;P=P?(P+"").toLowerCase():"text";let A=Cl([w,b&&b.toAbortSignal()],x),B=null;const v=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let z;try{if(D&&h&&g!=="get"&&g!=="head"&&(z=await p(k,y))!==0){let F=new t(m,{method:"POST",body:y,duplex:"half"}),R;if(V.isFormData(y)&&(R=F.headers.get("content-type"))&&k.setContentType(R),F.body){const[ne,H]=or(z,On(ar(D)));y=ur(F.body,dr,ne,H)}}V.isString(C)||(C=C?"include":"omit");const Z=s&&"credentials"in t.prototype,W={...I,signal:A,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:Z?C:void 0};B=s&&new t(m,W);let Q=await(s?O(B,I):O(m,W));const G=c&&(P==="stream"||P==="response");if(c&&(_||G&&v)){const F={};["status","statusText","headers"].forEach(Y=>{F[Y]=Q[Y]});const R=V.toFiniteNumber(Q.headers.get("content-length")),[ne,H]=_&&or(R,On(ar(_),!0))||[];Q=new n(ur(Q.body,dr,ne,()=>{H&&H(),v&&v()}),F)}P=P||"text";let te=await u[V.findKey(u,P)||"text"](Q,d);return!G&&v&&v(),await new Promise((F,R)=>{rr(F,R,{data:te,headers:Re.from(Q.headers),status:Q.status,statusText:Q.statusText,config:d,request:B})})}catch(Z){throw v&&v(),Z&&Z.name==="TypeError"&&/Load failed|fetch/i.test(Z.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,d,B),{cause:Z.cause||Z}):re.from(Z,Z&&Z.code,d,B)}}},Bl=new Map,gr=r=>{let e=r&&r.env||{};const{fetch:t,Request:n,Response:i}=e,s=[n,i,t];let o=s.length,a=o,l,h,c=Bl;for(;a--;)l=s[a],h=c.get(l),h===void 0&&c.set(l,h=a?new Map:El(e)),c=h;return h};gr();const Ei={http:tl,xhr:Tl,fetch:{get:gr}};V.forEach(Ei,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const yr=r=>`- ${r}`,Ll=r=>V.isFunction(r)||r===null||r===!1;function Ol(r,e){r=V.isArray(r)?r:[r];const{length:t}=r;let n,i;const s={};for(let o=0;o<t;o++){n=r[o];let a;if(i=n,!Ll(n)&&(i=Ei[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(V.isFunction(i)||(i=i.get(e))))break;s[a||"#"+o]=i}if(!i){const o=Object.entries(s).map(([l,h])=>`adapter ${l} `+(h===!1?"is not supported by the environment":"is not available in the build"));let a=t?o.length>1?`since :
756
+ `+o.map(yr).join(`
757
+ `):" "+yr(o[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const wr={getAdapter:Ol,adapters:Ei};function Bi(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new jt(null,r)}function br(r){return Bi(r),r.headers=Re.from(r.headers),r.data=Ii.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),wr.getAdapter(r.adapter||sn.adapter,r)(r).then(function(n){return Bi(r),n.data=Ii.call(r,r.transformResponse,n),n.headers=Re.from(n.headers),n},function(n){return sr(n)||(Bi(r),n&&n.response&&(n.response.data=Ii.call(r,r.transformResponse,n.response),n.response.headers=Re.from(n.response.headers))),Promise.reject(n)})}const xr="1.13.2",Nn={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{Nn[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const _r={};Nn.transitional=function(e,t,n){function i(s,o){return"[Axios v"+xr+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new re(i(o," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!_r[o]&&(_r[o]=!0,console.warn(i(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,o,a):!0}},Nn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function zl(r,e,t){if(typeof r!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=r[s],l=a===void 0||o(a,s,r);if(l!==!0)throw new re("option "+s+" must be "+l,re.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new re("Unknown option "+s,re.ERR_BAD_OPTION)}}const Rn={assertOptions:zl,validators:Nn},He=Rn.validators;let St=class{constructor(e){this.defaults=e||{},this.interceptors={request:new er,response:new er}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
758
+ `+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Mt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Rn.assertOptions(n,{silentJSONParsing:He.transitional(He.boolean),forcedJSONParsing:He.transitional(He.boolean),clarifyTimeoutError:He.transitional(He.boolean)},!1),i!=null&&(V.isFunction(i)?t.paramsSerializer={serialize:i}:Rn.assertOptions(i,{encode:He.function,serialize:He.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Rn.assertOptions(t,{baseUrl:He.spelling("baseURL"),withXsrfToken:He.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=s&&V.merge(s.common,s[t.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],d=>{delete s[d]}),t.headers=Re.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let c,u=0,f;if(!l){const d=[br.bind(this),void 0];for(d.unshift(...a),d.push(...h),f=d.length,c=Promise.resolve(t);u<f;)c=c.then(d[u++],d[u++]);return c}f=a.length;let p=t;for(;u<f;){const d=a[u++],m=a[u++];try{p=d(p)}catch(g){m.call(this,g);break}}try{c=br.call(this,p)}catch(d){return Promise.reject(d)}for(u=0,f=h.length;u<f;)c=c.then(h[u++],h[u++]);return c}getUri(e){e=Mt(this.defaults,e);const t=lr(e.baseURL,e.url,e.allowAbsoluteUrls);return Qs(t,e.params,e.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(e){St.prototype[e]=function(t,n){return this.request(Mt(n||{},{method:e,url:t,data:(n||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(n){return function(s,o,a){return this.request(Mt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}St.prototype[e]=t(),St.prototype[e+"Form"]=t(!0)});let Nl=class Lo{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new jt(s,o,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Lo(function(i){e=i}),cancel:e}}};function Rl(r){return function(t){return r.apply(null,t)}}function Fl(r){return V.isObject(r)&&r.isAxiosError===!0}const Li={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Li).forEach(([r,e])=>{Li[e]=r});function vr(r){const e=new St(r),t=Rs(St.prototype.request,e);return V.extend(t,St.prototype,e,{allOwnKeys:!0}),V.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return vr(Mt(r,i))},t}const ye=vr(sn);ye.Axios=St,ye.CanceledError=jt,ye.CancelToken=Nl,ye.isCancel=sr,ye.VERSION=xr,ye.toFormData=Bn,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=Rl,ye.isAxiosError=Fl,ye.mergeConfig=Mt,ye.AxiosHeaders=Re,ye.formToJSON=r=>nr(V.isHTMLForm(r)?new FormData(r):r),ye.getAdapter=wr.getAdapter,ye.HttpStatusCode=Li,ye.default=ye;const{Axios:vd,AxiosError:Md,CanceledError:Sd,isCancel:Ad,CancelToken:Td,VERSION:Cd,all:Pd,Cancel:Dd,isAxiosError:kd,spread:Id,toFormData:Ed,AxiosHeaders:Bd,HttpStatusCode:Ld,formToJSON:Od,getAdapter:zd,mergeConfig:Nd}=ye;function Mr(r,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=r;t.open("GET",n,!0),t.send(null),t.onreadystatechange=function(){t.readyState==4&&t.status==200&&(t.responseText.includes("</html>",0)&&t.responseText.includes("</body>",0)&&t.responseText.includes("</head>",0)?e(null):e(t.responseText))},t.onloadend=function(){t.readyState==4&&t.status==404&&t.status==502&&e(null)}}}function Ul(r,e){ye({method:"get",responseType:"blob",url:r}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});Ns.loadAsync(n).then(i=>{const s=new Map,o=[];for(let a in i.files){if(i.files[a].dir)continue;const l=i.file(i.files[a].name);if(l){const h=l.async("blob").then(c=>{const u=URL.createObjectURL(c);s.set("/"+i.files[a].name.replace("\\","/"),u)});o.push(h)}}Promise.all(o).then(()=>{e(s)}).catch(a=>{console.error("解压zip文件失败:",a),e(new Map)})}).catch(i=>{console.error("加载zip文件失败:",i),e(new Map)})}).catch(t=>{console.error("下载zip文件失败:",t),e(new Map)})}function Sr(r,e){ye({method:"get",responseType:"blob",url:r}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});Ns.loadAsync(i).then(s=>{for(let o in s.files)s.file(s.files[o].name).async("blob").then(l=>{t(l,"utf-8",function(h,c){e(c)})})})});function t(n,i,s){var o=new FileReader,a=new Blob([n]);o.onload=function(l){s(null,l.target.result)},o.onerror=function(l){s(l.error,null)},o.readAsText(a,i)}}const Oi=new WeakMap;class Vl extends S.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new S.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,S.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=S.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Oi.has(e)){const l=Oi.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((h,c)=>{i._callbacks[s]={resolve:h,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Oi.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new S.BufferGeometry;e.index&&t.setIndex(new S.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:o,stride:a,vertexColorSpace:l}=e.attributes[n];let h;if(o===a)h=new S.BufferAttribute(s,o);else{const c=new S.InterleavedBuffer(s,a);h=new S.InterleavedBufferAttribute(c,o,0)}i==="color"&&(this._assignVertexColorSpace(h,l),h.normalized=!(s instanceof Float32Array)),t.setAttribute(i,h)}return t}_assignVertexColorSpace(e,t){if(t!==S.SRGBColorSpace)return;const n=new S.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),S.ColorManagement.colorSpaceToWorking(n,S.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new S.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=jl.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
759
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function jl(){let r,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(c){r.onModuleLoaded=function(u){c({draco:u})},DracoDecoderModule(r)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const u=c.draco,f=new u.Decoder;try{const p=t(u,f,new Int8Array(l),h),d=p.attributes.map(m=>m.array.buffer);p.index&&d.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},d)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(f)}});break}};function t(o,a,l,h){const c=h.attributeIDs,u=h.attributeTypes;let f,p;const d=a.GetEncodedGeometryType(l);if(d===o.TRIANGULAR_MESH)f=new o.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,f);else if(d===o.POINT_CLOUD)f=new o.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,f);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||f.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const m={index:null,attributes:[]};for(const g in c){const y=self[u[g]];let w,b;if(h.useUniqueIDs)b=c[g],w=a.GetAttributeByUniqueId(f,b);else{if(b=a.GetAttributeId(f,o[c[g]]),b===-1)continue;w=a.GetAttribute(f,b)}const x=i(o,a,f,g,y,w);g==="color"&&(x.vertexColorSpace=h.vertexColorSpace),m.attributes.push(x)}return d===o.TRIANGULAR_MESH&&(m.index=n(o,a,f)),o.destroy(f),m}function n(o,a,l){const c=l.num_faces()*3,u=c*4,f=o._malloc(u);a.GetTrianglesUInt32Array(l,u,f);const p=new Uint32Array(o.HEAPF32.buffer,f,c).slice();return o._free(f),{array:p,itemSize:1}}function i(o,a,l,h,c,u){const f=l.num_points(),p=u.num_components(),d=s(o,c),m=p*c.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,y=g/c.BYTES_PER_ELEMENT,w=f*m,b=f*g,x=o._malloc(w);a.GetAttributeDataArrayForAllPoints(l,u,d,w,x);const _=new c(o.HEAPF32.buffer,x,w/c.BYTES_PER_ELEMENT);let D;if(m===g)D=_.slice();else{D=new c(b/c.BYTES_PER_ELEMENT);let P=0;for(let k=0,C=_.length;k<C;k++){for(let I=0;I<p;I++)D[P+I]=_[k*p+I];P+=y}}return o._free(x),{name:h,count:f,itemSize:p,array:D,stride:y}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var ht=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.ViewportResize="viewport-resize",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.SectionMove="section-move",r))(ht||{});function Gl(r,e,t,n){let i=0,s=0,o=0,a=r.models.find(p=>p.url==t),l=e.circularMeps,h=e.rectMeps.filter(p=>p.type==="风管"),c=e.rectMeps.filter(p=>p.type==="桥架"),u=e.ellipseMeps,f=r.scene;if(new T.MeshBasicMaterial,new T.BufferGeometry,l&&l.length){let p=[],d=0;for(let m of l)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new T.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),p.push(m);Fn("Circle",f,p,t)}if(h&&h.length){let p=[],d=0;for(let m of h)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new T.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),p.push(m);Fn("Rect",f,p,t)}if(u&&u.length){let p=[],d=0;for(let m of u)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new T.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),p.push(m);Fn("Ellipse",f,p,t)}if(c&&c.length){let p=[],d=0;for(let m of c)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new T.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+o},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),p.push(m);Fn("Bridge",f,p,t)}}function Fn(r,e,t,n,i){let s,o,a={width:1,height:1,length:1,diameter:1,color:new T.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":o=Un("Rect",a);break;case"Bridge":o=Un("Bridge",a);break;case"Circle":o=Un("Circle",a);break;case"Ellipse":o=Un("Ellipse",a);break}o&&(s=new T.InstancedMesh(o.geometry,o.material,t.length),s.url=n,e.add(s));let l=[];for(var h=0;h<t.length;h++){let f=t[h],p=new T.Vector3(f.startPoint.X,0,-f.startPoint.Y),d=new T.Vector3(f.endPoint.X,0,-f.endPoint.Y),m=new T.Vector3(f.startPoint.X,f.startPoint.Z,-f.startPoint.Y),g=new T.Vector3(f.endPoint.X,f.endPoint.Z,-f.endPoint.Y),y=0,w=0,b=0;if(Math.abs(d.clone().sub(p.clone()).z)<.01&&Math.abs(d.clone().sub(p.clone()).x)<.01){if(y=(f.startPoint.Z>f.endPoint.Z?1:-1)*Math.PI*.5,f.base_x!=null){var c=new T.Vector3(f.base_x.X,0,-f.base_x.Y);w=(c.clone().cross(new T.Vector3(0,0,1)).y<=0?1:-1)*c.angleTo(new T.Vector3(0,0,1))+Math.PI*.5}}else w=(d.clone().sub(p.clone()).cross(new T.Vector3(0,0,1)).y>0?-1:1)*d.clone().sub(p.clone()).angleTo(new T.Vector3(0,0,1)),y=(f.startPoint.Z>f.endPoint.Z?1:-1)*d.clone().sub(p.clone()).angleTo(g.clone().sub(m.clone()));let x=new T.Matrix4;const _=new T.Euler(y,w,b,"YXZ");let D=x.clone().makeRotationFromEuler(_),P,k;r==="Circle"?(P=f.diameter,k=f.diameter):(P=f.width,k=f.height);let C=x.clone().makeScale(P,k,f.length);x.multiplyMatrices(D,C),x.setPosition(f.position.x,f.position.y,f.position.z),s.setMatrixAt(h,x.clone()),s.setColorAt(h,f.color),s.geometry.computeBoundingBox();let I=s.geometry.boundingBox.min.clone().applyMatrix4(x.clone()),O=s.geometry.boundingBox.max.clone().applyMatrix4(x.clone()),A=new T.Vector3(Math.min(I.x,O.x),Math.min(I.y,O.y),Math.min(I.z,O.z)),B=new T.Vector3(Math.max(I.x,O.x),Math.max(I.y,O.y),Math.max(I.z,O.z)),v=A.clone().add(B.clone()).multiplyScalar(.5),z={name:f.name,min:A,max:B,center:v,dbid:h,materialName:o.material.name},Z=null,W=null;r==="Circle"&&(Z={x:f.startPoint.X*.3048,y:f.startPoint.Z*.3048,z:-f.startPoint.Y*.3048},W={x:f.endPoint.X*.3048,y:f.endPoint.Z*.3048,z:-f.endPoint.Y*.3048},z.minC=Z,z.maxC=W),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(x.clone()),s.ids.push(Number(f.id)),l.push(z)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=r,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone();let u=[];u={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=u,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Un(r,e,t){let n=new T.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,r){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return s(n,i,e.color,e.position,e.rotation);function s(o,a,l,h,c){let u=new T.ExtrudeGeometry(o,a),f=new T.MeshStandardMaterial({color:l,side:T.DoubleSide}),p=new T.Mesh(u,f);return p.position.set(h.x,h.y,h.z),p.rotation._order="YXZ",p.rotation.set(c.x,c.y,c.z),p}}function Ar(r,e=!1){const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new S.BufferGeometry;let h=0;for(let c=0;c<r.length;++c){const u=r[c];let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in u.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(u.attributes[p]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in u.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(u.morphAttributes[p])}if(e){let p;if(t)p=u.index.count;else if(u.attributes.position!==void 0)p=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(t){let c=0;const u=[];for(let f=0;f<r.length;++f){const p=r[f].index;for(let d=0;d<p.count;++d)u.push(p.getX(d)+c);c+=r[f].attributes.position.count}l.setIndex(u)}for(const c in s){const u=Tr(s[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(const c in o){const u=o[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let f=0;f<u;++f){const p=[];for(let m=0;m<o[c].length;++m)p.push(o[c][m][f]);const d=Tr(p);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(d)}}return l}function Tr(r){let e,t,n,i=-1,s=0;for(let h=0;h<r.length;++h){const c=r[h];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=c.gpuType),i!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*t}const o=new e(s),a=new S.BufferAttribute(o,t,n);let l=0;for(let h=0;h<r.length;++h){const c=r[h];if(c.isInterleavedBufferAttribute){const u=l/t;for(let f=0,p=c.count;f<p;f++)for(let d=0;d<t;d++){const m=c.getComponent(f,d);a.setComponent(f+u,d,m)}}else o.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Cr(r,e){if(e===S.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===S.TriangleFanDrawMode||e===S.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===S.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class Wl extends S.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Yl(t)}),this.register(function(t){return new $l(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new Hl(t)}),this.register(function(t){return new Ql(t)}),this.register(function(t){return new ec(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new Zl(t)}),this.register(function(t){return new nc(t)}),this.register(function(t){return new Jl(t)}),this.register(function(t){return new sc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new ql(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new cc(t)})}load(e,t,n,i){const s=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const h=S.LoaderUtils.extractUrlBase(e);o=S.LoaderUtils.resolveURL(h,this.path)}else o=S.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){i?i(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},l=new S.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{s.parse(h,o,function(c){t(c),s.manager.itemEnd(e)},a)}catch(c){a(c)}},n,a)}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,i){let s;const o={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Pr){try{o[le.KHR_BINARY_GLTF]=new hc(e)}catch(u){i&&i(u);return}s=JSON.parse(o[le.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new Mc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const u=this.pluginCallbacks[c](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const u=s.extensionsUsed[c],f=s.extensionsRequired||[];switch(u){case le.KHR_MATERIALS_UNLIT:o[u]=new Kl;break;case le.KHR_DRACO_MESH_COMPRESSION:o[u]=new uc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:o[u]=new dc;break;case le.KHR_MESH_QUANTIZATION:o[u]=new fc;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}h.setExtensions(o),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function Xl(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const le={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ql{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const c=new S.Color(16777215);l.color!==void 0&&c.setRGB(l.color[0],l.color[1],l.color[2],S.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new S.DirectionalLight(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new S.PointLight(c),h.distance=u;break;case"spot":h=new S.SpotLight(c),h.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Qe(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Kl{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return S.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new S.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],S.LinearSRGBColorSpace),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,S.SRGBColorSpace))}return Promise.all(i)}}class Zl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Yl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new S.Vector2(a,a)}return Promise.all(s)}}class $l{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class Jl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}}class Hl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new S.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,S.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class Ql{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class ec{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),Promise.all(s)}}class tc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class nc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,S.SRGBColorSpace)),Promise.all(s)}}class ic{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}}class sc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}}class rc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class oc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,o.source,l)}}class ac{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,o.source,l)}}class lc{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,h=i.byteLength||0,c=i.count,u=i.byteStride,f=new Uint8Array(a,l,h);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(c,u,f,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(c*u);return o.decodeGltfBuffer(new Uint8Array(p),c,u,f,i.mode,i.filter),p})})}else return null}}class cc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Ue.TRIANGLES&&h.mode!==Ue.TRIANGLE_STRIP&&h.mode!==Ue.TRIANGLE_FAN&&h.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const h in o)a.push(this.parser.getDependency("accessor",o[h]).then(c=>(l[h]=c,l[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const c=h.pop(),u=c.isGroup?c.children:[c],f=h[0].count,p=[];for(const d of u){const m=new S.Matrix4,g=new S.Vector3,y=new S.Quaternion,w=new S.Vector3(1,1,1),b=new S.InstancedMesh(d.geometry,d.material,f);for(let x=0;x<f;x++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,x),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,x),l.SCALE&&w.fromBufferAttribute(l.SCALE,x),b.setMatrixAt(x,m.compose(g,y,w));for(const x in l)if(x==="_COLOR_0"){const _=l[x];b.instanceColor=new S.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&d.geometry.setAttribute(x,l[x]);S.Object3D.prototype.copy.call(b,d),this.parser.assignFinalMaterial(b),p.push(b)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Pr="glTF",on=12,Dr={JSON:1313821514,BIN:5130562};class hc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,on),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!==Pr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-on,s=new DataView(e,on);let o=0;for(;o<i;){const a=s.getUint32(o,!0);o+=4;const l=s.getUint32(o,!0);if(o+=4,l===Dr.JSON){const h=new Uint8Array(e,on+o,a);this.content=n.decode(h)}else if(l===Dr.BIN){const h=on+o;this.body=e.slice(h,h+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class uc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},h={};for(const c in o){const u=Ni[c]||c.toLowerCase();a[u]=o[c]}for(const c in e.attributes){const u=Ni[c]||c.toLowerCase();if(o[c]!==void 0){const f=n.accessors[e.attributes[c]],p=Gt[f.componentType];h[u]=p.name,l[u]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(u,f){i.decodeDracoFile(c,function(p){for(const d in p.attributes){const m=p.attributes[d],g=l[d];g!==void 0&&(m.normalized=g)}u(p)},a,h,S.LinearSRGBColorSpace,f)})})}}class dc{constructor(){this.name=le.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.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}}class fc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class kr extends S.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,h=a*3,c=i-t,u=(n-t)/c,f=u*u,p=f*u,d=e*h,m=d-h,g=-2*p+3*f,y=p-f,w=1-g,b=y-f+u;for(let x=0;x!==a;x++){const _=o[m+x+a],D=o[m+x+l]*c,P=o[d+x+a],k=o[d+x]*c;s[x]=w*_+b*D+g*P+y*k}return s}}const pc=new S.Quaternion;class mc extends kr{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return pc.fromArray(s).normalize().toArray(s),s}}const Ue={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Gt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ir={9728:S.NearestFilter,9729:S.LinearFilter,9984:S.NearestMipmapNearestFilter,9985:S.LinearMipmapNearestFilter,9986:S.NearestMipmapLinearFilter,9987:S.LinearMipmapLinearFilter},Er={33071:S.ClampToEdgeWrapping,33648:S.MirroredRepeatWrapping,10497:S.RepeatWrapping},zi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ni={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"},ut={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gc={CUBICSPLINE:void 0,LINEAR:S.InterpolateLinear,STEP:S.InterpolateDiscrete},Ri={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function yc(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new S.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:S.FrontSide})),r.DefaultMaterial}function At(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function wc(r,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const u=e[h];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const o=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const u=e[h];if(n){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;o.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;a.push(f)}if(s){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],u=h[1],f=h[2];return n&&(r.morphAttributes.position=c),i&&(r.morphAttributes.normal=u),s&&(r.morphAttributes.color=f),r.morphTargetsRelative=!0,r})}function bc(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function xc(r){let e;const t=r.extensions&&r.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Fi(t.attributes):e=r.indices+":"+Fi(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Fi(r.targets[n]);return e}function Fi(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Ui(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function _c(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const vc=new S.Matrix4;class Mc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Xl,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,i=-1,s=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&o<98?this.textureLoader=new S.TextureLoader(this.options.manager):this.textureLoader=new S.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new S.FileLoader(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){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return At(s,a,i),Qe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.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;const i=n.clone(),s=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[h,c]of o.children.entries())s(c,a.children[h])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[le.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){n.load(S.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=zi[i.type],a=Gt[i.componentType],l=i.normalized===!0,h=new a(i.count*o);return Promise.resolve(new S.BufferAttribute(h,o,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],l=zi[i.type],h=Gt[i.componentType],c=h.BYTES_PER_ELEMENT,u=c*l,f=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0;let m,g;if(p&&p!==u){const y=Math.floor(f/p),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let b=t.cache.get(w);b||(m=new h(a,y*p,i.count*p/c),b=new S.InterleavedBuffer(m,p/c),t.cache.add(w,b)),g=new S.InterleavedBufferAttribute(b,l,f%p/c,d)}else a===null?m=new h(i.count*l):m=new h(a,f,i.count*l),g=new S.BufferAttribute(m,l,d);if(i.sparse!==void 0){const y=zi.SCALAR,w=Gt[i.sparse.indices.componentType],b=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,_=new w(o[1],b,i.sparse.count*y),D=new h(o[2],x,i.sparse.count*l);a!==null&&(g=new S.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=_.length;P<k;P++){const C=_[P];if(g.setX(C,D[P*l]),l>=2&&g.setY(C,D[P*l+1]),l>=3&&g.setZ(C,D[P*l+2]),l>=4&&g.setW(C,D[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=d}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,n).then(function(c){c.flipY=!1,c.name=o.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const f=(s.samplers||{})[o.sampler]||{};return c.magFilter=Ir[f.magFilter]||S.LinearFilter,c.minFilter=Ir[f.minFilter]||S.LinearMipmapLinearFilter,c.wrapS=Er[f.wrapS]||S.RepeatWrapping,c.wrapT=Er[f.wrapT]||S.RepeatWrapping,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==S.NearestFilter&&c.minFilter!==S.LinearFilter,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",h=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){h=!0;const f=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(f),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(l).then(function(u){return new Promise(function(f,p){let d=f;t.isImageBitmapLoader===!0&&(d=function(m){const g=new S.Texture(m);g.needsUpdate=!0,f(g)}),t.load(S.LoaderUtils.resolveURL(u,s.path),d,void 0,p)})}).then(function(u){return h===!0&&a.revokeObjectURL(l),Qe(u,o),u.userData.mimeType=o.mimeType||_c(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.PointsMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.LineBasicMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return S.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},h=[];if(l[le.KHR_MATERIALS_UNLIT]){const u=i[le.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),h.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new S.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],S.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",u.baseColorTexture,S.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=S.DoubleSide);const c=s.alphaMode||Ri.OPAQUE;if(c===Ri.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Ri.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new S.Vector2(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==S.MeshBasicMaterial){const u=s.emissiveFactor;a.emissive=new S.Color().setRGB(u[0],u[1],u[2],S.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&o!==S.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,S.SRGBColorSpace)),Promise.all(h).then(function(){const u=new o(a);return s.name&&(u.name=s.name),Qe(u,s),t.associations.set(u,{materials:e}),s.extensions&&At(i,u,s),u})}createUniqueName(e){const t=S.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Br(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=xc(h),u=i[c];if(u)o.push(u.promise);else{let f;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?f=s(h):f=Br(new S.BufferGeometry,h,t),i[c]={primitive:h,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let l=0,h=o.length;l<h;l++){const c=o[l].material===void 0?yc(this.cache):this.getDependency("material",o[l].material);a.push(c)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const h=l.slice(0,l.length-1),c=l[l.length-1],u=[];for(let p=0,d=c.length;p<d;p++){const m=c[p],g=o[p];let y;const w=h[p];if(g.mode===Ue.TRIANGLES||g.mode===Ue.TRIANGLE_STRIP||g.mode===Ue.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new S.SkinnedMesh(m,w):new S.Mesh(m,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ue.TRIANGLE_STRIP?y.geometry=Cr(y.geometry,S.TriangleStripDrawMode):g.mode===Ue.TRIANGLE_FAN&&(y.geometry=Cr(y.geometry,S.TriangleFanDrawMode));else if(g.mode===Ue.LINES)y=new S.LineSegments(m,w);else if(g.mode===Ue.LINE_STRIP)y=new S.Line(m,w);else if(g.mode===Ue.LINE_LOOP)y=new S.LineLoop(m,w);else if(g.mode===Ue.POINTS)y=new S.Points(m,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&bc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&At(i,y,g),t.assignFinalMaterial(y),u.push(y)}for(let p=0,d=u.length;p<d;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return s.extensions&&At(i,u[0],s),u[0];const f=new S.Group;s.extensions&&At(i,f,s),t.associations.set(f,{meshes:e});for(let p=0,d=u.length;p<d;p++)f.add(u[p]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new S.PerspectiveCamera(S.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new S.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Qe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),o=i,a=[],l=[];for(let h=0,c=o.length;h<c;h++){const u=o[h];if(u){a.push(u);const f=new S.Matrix4;s!==null&&f.fromArray(s.array,h*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new S.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,o=[],a=[],l=[],h=[],c=[];for(let u=0,f=i.channels.length;u<f;u++){const p=i.channels[u],d=i.samplers[p.sampler],m=p.target,g=m.node,y=i.parameters!==void 0?i.parameters[d.input]:d.input,w=i.parameters!==void 0?i.parameters[d.output]:d.output;m.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(d),c.push(m))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(u){const f=u[0],p=u[1],d=u[2],m=u[3],g=u[4],y=[];for(let b=0,x=f.length;b<x;b++){const _=f[b],D=p[b],P=d[b],k=m[b],C=g[b];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const I=n._createAnimationTracks(_,D,P,k,C);if(I)for(let O=0;O<I.length;O++)y.push(I[O])}const w=new S.AnimationClip(s,void 0,y);return Qe(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const o=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,h=i.weights.length;l<h;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=i.children||[];for(let h=0,c=a.length;h<c;h++)o.push(n.getDependency("node",a[h]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(o),l]).then(function(h){const c=h[0],u=h[1],f=h[2];f!==null&&c.traverse(function(p){p.isSkinnedMesh&&p.bind(f,vc)});for(let p=0,d=u.length;p<d;p++)c.add(u[p]);return c})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],o=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(h){return i._getNodeRef(i.cameraCache,s.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let c;if(s.isBone===!0?c=new S.Bone:h.length>1?c=new S.Group:h.length===1?c=h[0]:c=new S.Object3D,c!==h[0])for(let u=0,f=h.length;u<f;u++)c.add(h[u]);if(s.name&&(c.userData.name=s.name,c.name=o),Qe(c,s),s.extensions&&At(n,c,s),s.matrix!==void 0){const u=new S.Matrix4;u.fromArray(s.matrix),c.applyMatrix4(u)}else s.translation!==void 0&&c.position.fromArray(s.translation),s.rotation!==void 0&&c.quaternion.fromArray(s.rotation),s.scale!==void 0&&c.scale.fromArray(s.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(c);i.associations.set(c,{...u})}return i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new S.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&At(t,s,n);const o=n.nodes||[],a=[];for(let l=0,h=o.length;l<h;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let c=0,u=l.length;c<u;c++)s.add(l[c]);const h=c=>{const u=new Map;for(const[f,p]of i.associations)(f instanceof S.Material||f instanceof S.Texture)&&u.set(f,p);return c.traverse(f=>{const p=i.associations.get(f);p!=null&&u.set(f,p)}),u};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];ut[s.path]===ut.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let h;switch(ut[s.path]){case ut.weights:h=S.NumberKeyframeTrack;break;case ut.rotation:h=S.QuaternionKeyframeTrack;break;case ut.translation:case ut.scale:h=S.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=S.NumberKeyframeTrack;break;case 2:case 3:default:h=S.VectorKeyframeTrack;break}break}const c=i.interpolation!==void 0?gc[i.interpolation]:S.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let f=0,p=l.length;f<p;f++){const d=new h(l[f]+"."+ut[s.path],t.array,u,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(d),o.push(d)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Ui(t.constructor),i=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof S.QuaternionKeyframeTrack?mc:kr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Sc(r,e,t){const n=e.attributes,i=new S.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(i.set(new S.Vector3(l[0],l[1],l[2]),new S.Vector3(h[0],h[1],h[2])),a.normalized){const c=Ui(Gt[a.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new S.Vector3,l=new S.Vector3;for(let h=0,c=s.length;h<c;h++){const u=s[h];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],p=f.min,d=f.max;if(p!==void 0&&d!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(d[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(d[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(d[2]))),f.normalized){const m=Ui(Gt[f.componentType]);l.multiplyScalar(m)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}r.boundingBox=i;const o=new S.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=o}function Br(r,e,t){const n=e.attributes,i=[];function s(o,a){return t.getDependency("accessor",o).then(function(l){r.setAttribute(a,l)})}for(const o in n){const a=Ni[o]||o.toLowerCase();a in r.attributes||i.push(s(n[o],a))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(o)}return S.ColorManagement.workingColorSpace!==S.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${S.ColorManagement.workingColorSpace}" not supported.`),Qe(r,e),Sc(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?wc(r,e.targets,t):r})}function Ac(r,e,t){let n=new T.Group;n.name=e,r.scene.add(n),Sr(e+"/info",i=>{let s=JSON.parse(i);r.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),r.models==null&&(r.models=[]),r.models.push({url:e,nodesMap:new Map,boundingBox:{min:new T.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new T.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),r.events.trigger(ht.EngineFree,null)})}function Tc(r){r.engineStatus.models.forEach(e=>{e.loadStatus==null&&(e.loadStatus={mep:!1,instance:!1,normal:!1}),e.status==="loading"&&e.type==="light"&&(e.loadStatus.modelMep!=!0&&(e.loadStatus.modelMep=!0,Gl(r,e.info.modelMep,e.url)),e.loadStatus.normal!=!0&&Cc(r,e))})}function Cc(r,e){if(r.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(i=>{if(i.status!=!0)if(i.glbs==null)console.log("加载GLB............."),i.glbs={},Ul(e.url+i.path,s=>{Mr(s.get("/nodes.json"),o=>{let a=JSON.parse(o);r.models.find(c=>c.url==e.url).nodesMap==null&&(r.models.find(c=>c.url==e.url).nodesMap=new Map);let l=r.models.find(c=>c.url==e.url).nodesMap,h=0;for(let c in a){a[c].forEach(p=>{p.glb=c,l.has(p.id)==!1?l.set(p.id,{infos:[p]}):l.get(p.id).infos.push(p)});let u=new Wl;const f=new Vl;f.setDecoderPath("/draco/"),f.preload(),u.setDRACOLoader(f),u.load(s.get(c+".glb"),p=>{i.glbs[c]=p.scene.children,h++,h==Object.keys(a).length&&r.engineStatus.isFree&&(r.events.trigger(ht.EngineFree,null),r.viewCube.CameraGoHome())})}Mr(s.get("/instances.json"),c=>{let u=JSON.parse(c);r.models.find(f=>f.url==e.url).instanceNodes=u})})});else{console.log("加载模型.............");let s=n(e,i,i.octreeBox),o=[],a=r.models.find(h=>h.url==e.url);s.forEach(h=>{a.nodesMap.has(h)&&a.nodesMap.get(h).infos.forEach(c=>{let u=i.glbs[c.glb][c.mesh];if(u!=null&&u.geometry!=null&&u.material!=null){let f=new T.Matrix4;f.elements=c.matrix;let p=new T.Mesh(u.geometry.clone().applyMatrix4(f),u.material),d=new T.Box3().setFromObject(p);c.box=d,c.mesh=p,p.name=h,p.glb=c.glb,p.url=e.url,u.geometry.attributes.position!=null&&o.push(p)}})}),console.log("加载模型数量",o.length),Pc(e.url,r,o);let l=a.instanceNodes;for(let h in l)(l[h].isLoaded==null||l[h].isLoaded==!1)&&(l[h].isLoaded=!0,l[h].forEach(c=>{let u=i.glbs[h][c.mesh];Dc(e.url,c.mesh,r,u,c.children)}))}});function n(i,s,o){let a=[];if(o.status!=!0){if(!r.engineStatus.isFree)return a;let l=new T.Vector3(o.min.X,o.min.Z,-o.min.Y),h=new T.Vector3(o.max.X,o.max.Z,-o.max.Y);h.distanceTo(l);let c=r.camera.position,u=new T.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(u),o.elements.forEach(f=>{a.push(f)}),o.children.forEach(f=>{a.push(...n(i,s,f))}),o.children.findIndex(f=>f.status!=!0)==-1&&(o.status=!0),o.children.length==0&&(o.status=!0)}return a}}function Pc(r,e,t){let n=[];t.forEach(i=>{n.findIndex(o=>o.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(o=>o.glb==i.glb).meshes.push(i),n.find(o=>o.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(o=>o.glb==i.glb);s.indexes.set(Number(i.name),[s.currentIndex-i.geometry.index.count,s.currentIndex])}),n.forEach(i=>{let s=e.scene.children.find(o=>o instanceof T.Mesh&&o.url==r&&o.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let o=new T.BufferGeometry,a=kc(i.meshes[0].material);o=Ar(i.meshes.map(c=>c.geometry),!1);let l=new T.Mesh(o,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=r,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(c=>c.geometry);let h=e.models.find(c=>c.url==r);if(h!=null){let c=0;i.indexes.forEach(u=>{h.nodesMap.get(Number(i.meshes[c].name)).indexes==null&&(h.nodesMap.get(Number(i.meshes[c].name)).indexes=[]),h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index,c++,u[0],u[1]])})}}})}function Dc(r,e,t,n,i){if(n==null)return;let s=new T.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const o=new Float32Array(i.length*3);for(let a=0;a<i.length;a++)o[a*3]=1,o[a*3+1]=1,o[a*3+2]=1;s.instanceColor=new T.InstancedBufferAttribute(o,3);for(let a=0;a<i.length;a++){let l=i[a],h=new T.Matrix4;h.elements=l.matrix,s.setMatrixAt(a,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),t.models.find(c=>c.url==r).nodesMap.has(l.id)?(t.models.find(c=>c.url==r).nodesMap.get(l.id).indexes==null&&(t.models.find(c=>c.url==r).nodesMap.get(l.id).indexes=[]),t.models.find(c=>c.url==r).nodesMap.get(l.id).indexes.push([t.scene.children.length-1,a,0,0])):t.models.find(c=>c.url==r).nodesMap.set(l.id,{instance:!0,info:l,indexes:[[t.scene.children.length-1,a,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=r,s.glb=n.glb,s.ids=i.map(a=>a.id)}function kc(r){return r.map!=null&&(r.map.colorSpace=T.SRGBColorSpace,r.map.needsUpdate=!0),r.shadowSide=T.FrontSide,r.side=r.side,r}class Ic{engine;constructor(e){this.engine=e}async loadModels(e,t){for(const i of e)n(i)==="light"&&Ac(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class Ec{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ht.EngineFree,()=>{this.updateFree(!0),console.log("引擎空闲"),Tc(this.engine)}),this.engine.events.on(ht.EngineBusy,()=>{this.updateFree(!1),console.log("引擎繁忙")})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Bc{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,o)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}}class Lc{engine;constructor(e){this.engine=e}init(){const e=new T.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new T.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new T.AmbientLight(16777215,1);this.engine.scene.add(i)}}var ve=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r))(ve||{});class Oc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new T.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;handleMouseMove(e){if(!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.handleMouseClickInstance(e.raycaster);if(t.length>0&&(e.catch==null||t[0].distance<e.catch.distance)){let n=t[0].object,i=n.ids[t[0].instanceId],s=this.engine.models.find(l=>l.url==n.url).nodesMap.get(i),o=new Map;s?.indexes.forEach(l=>{this.engine.scene.children[l[0]]instanceof T.InstancedMesh&&(o.has(l[0])?o.get(l[0])?.push(l[1]):o.set(l[0],[l[1]]))});let a=[];if(o.forEach((l,h)=>{let c=this.engine.scene.children[h];l.forEach(u=>{let f=c.geometry.clone();f.applyMatrix4(n.matrixs[u]),a.push(new T.Mesh(f,c.material))})}),this.hoverOldId==i)return;this.hoverOldId=i,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.hightMesh(a)}else if(e.catch!=null&&(t.length==0||t[0].distance>e.catch.distance)){const n=e.catch;n.object,this.engine.events.trigger(ve.Click,n);let i=n.object,s=i.name,l=this.engine.models.find(h=>h.url===i.url).nodesMap.get(s).infos.map(h=>h.mesh);if(this.hoverOldId==s)return;this.hoverOldId=s,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.hightMesh(l)}else this.engine.hoverHighLight.clearHighlight()}handleMouseClick(e){let t=this.handleMouseClickInstance(e.raycaster);if(t.length>0&&(e.catch==null||t[0].distance<e.catch.distance)){this.engine.controlModule.orbitControls.origin.set(t[0].point.x,t[0].point.y,t[0].point.z),this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels();let n=t[0].object;this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.ids[t[0].instanceId]]}])}else if(e.catch!=null&&(t.length==0||t[0].distance>e.catch.distance)){const n=e.catch;n.object,this.engine.events.trigger(ve.Click,n);let i=n.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:i.url,ids:[i.name]}]),this.engine.controlModule.orbitControls.origin.set(n.point.x,n.point.y,n.point.z),this.engine.modelToolModule.highlightModel([{url:i.url,ids:[i.name]}])}e.catch==null&&t.length==0&&this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object,this.engine.events.trigger(ve.Click,n);let i=n.object,a=this.engine.models.find(h=>h.url===i.url).nodesMap.get(i.name).infos.map(h=>h.box),l=t(a);this.engine.viewCube.zoomToModel(l)}function t(n){let i=new T.Vector3(1e8,1e9,1e10),s=new T.Vector3(-1e8,-1e9,-1e10);return n.forEach(o=>{o.min.x<i.x&&(i.x=o.min.x),o.min.y<i.y&&(i.y=o.min.y),o.min.z<i.z&&(i.z=o.min.z),o.max.x>s.x&&(s.x=o.max.x),o.max.y>s.y&&(s.y=o.max.y),o.max.z>s.z&&(s.z=o.max.z)}),new T.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof T.InstancedMesh),!0)}}class zc{engine;highlightMaterial;hideMaterial;translucentMaterial;cloneModels=new Map;clonetranslucentModels=new Map;constructor(e){this.engine=e,this.highlightMaterial=new T.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:T.DoubleSide}),this.hideMaterial=new T.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:T.DoubleSide}),this.translucentMaterial=new T.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:T.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof T.InstancedMesh)return;let t=e.materialClone.clone(),n=Ar(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s?.indexes.forEach(o=>{this.engine.scene.children[o[0]]instanceof T.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(console.log(this.engine.scene.children[o[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[o[0]]),this.engine.scene.children[o[0]].geometry.groups[o[1]].materialIndex=1)})}),Nc(n,this.engine,this.cloneModels),this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s?.indexes.forEach(o=>{this.engine.scene.children[o[0]]instanceof T.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.engine.scene.children[o[0]].geometry.groups[o[1]].materialIndex=0})}),Lr(n,this.engine,this.cloneModels)})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),o.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof T.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Fc(n,this.engine,this.cloneModels);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),o.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof T.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Or(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const o=i.ids.indexOf(s);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(o=>o.url==n.url);for(let o of n.nodesMap)s==null?i.ids.push(o[0]):s.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(o=>o.url==n.url);for(let o of n.nodesMap)s==null?i.ids.push(o[0]):s.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.unhighlightAllModels(),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightModel(e),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);o&&o.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof T.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=2)})}),Rc(n,this.engine,this.clonetranslucentModels);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s&&s.indexes.forEach(o=>{const a=this.engine.scene.children[o[0]];a instanceof T.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.engine.scene.children[o[0]]),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&Or(n,this.engine),Lr(n,this.engine,this.clonetranslucentModels)}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Nc(r,e,t){r.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof T.InstancedMesh))return;const o=s.geometry,a=new T.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:T.DoubleSide}),l=new T.InstancedMesh(o,a,n.length);l.name="highlightModel";const h=new Map,c=new T.Matrix4,u=new T.Matrix4;u.makeScale(0,0,0),n.forEach((f,p)=>{s.getMatrixAt(f,c),h.set(f,c.clone()),s.setMatrixAt(f,u),l.setMatrixAt(p,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Lr(r,e,t){r.forEach((n,i)=>{const s=t.get(i);if(!s)return;const o=e.scene.children[i];o instanceof T.InstancedMesh&&(n.forEach(a=>{const l=s.originalMatrices.get(a);l&&o.setMatrixAt(a,l)}),o.instanceMatrix.needsUpdate=!0,s.cloneModel.parent&&s.cloneModel.parent.remove(s.cloneModel),s.cloneModel.geometry,s.cloneModel.material&&(Array.isArray(s.cloneModel.material)?s.cloneModel.material.forEach(a=>a.dispose()):s.cloneModel.material.dispose()),t.delete(i))})}function Rc(r,e,t){r.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof T.InstancedMesh))return;const o=s.geometry,a=new T.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:T.DoubleSide}),l=new T.InstancedMesh(o,a,n.length);l.name="translucentModel";const h=new Map,c=new T.Matrix4,u=new T.Matrix4;u.makeScale(0,0,0),n.forEach((f,p)=>{s.getMatrixAt(f,c),h.set(f,c.clone()),s.setMatrixAt(f,u),l.setMatrixAt(p,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Fc(r,e,t){e.scene.children.forEach(n=>{n.name=="highlightModel"&&n.parent.remove(n)}),r.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof T.InstancedMesh))return;const o=new Map,a=new T.Matrix4,l=new T.Matrix4;l.makeScale(0,0,0),n.forEach((h,c)=>{s.getMatrixAt(h,a),o.set(h,a.clone()),s.setMatrixAt(h,l)}),s.instanceMatrix.needsUpdate=!0,t.set(i,{cloneModel:null,originalMatrices:o})})}function Or(r,e){r.forEach((t,n)=>{const i=e.scene.children[n];i instanceof T.InstancedMesh&&(t.forEach(s=>{const o=i.matrixs[s];o&&i.setMatrixAt(s,o)}),i.instanceMatrix.needsUpdate=!0)})}class Ve{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new T.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new T.Vector2(t.x,t.y)}worldToScreen(e){const t=this.worldToScreenNormalized(e),n=this.renderer.domElement.width,i=this.renderer.domElement.height,s=(t.x+1)*n/2,o=(1-t.y)*i/2;return new T.Vector2(s,o)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,s=e/n*2-1,o=-(t/i*2-1);return new T.Vector2(s,o)}screenToWorld(e,t,n){if(!this.scene&&!n)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=n||this.scene.children,o=this.raycaster.intersectObjects(s,!0);return o.length>0?o[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=new T.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}class Uc{engine;currentMode="balance";gtaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.setMode("balance")}setMode(e){this.currentMode=e,this.switchModel(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){if(!this.engine.composerModule?.composer)return;const e=this.engine.composerModule.composer.passes;for(const t of e)t.constructor.name==="_GTAOPass"?this.gtaoPass=t:t.constructor.name==="ShaderPass"?t.material.uniforms.saturation?this.saturationPass=t:t.material.uniforms.resolution&&(this.fxaaPass=t):t.constructor.name==="OutputPass"&&(this.outputPass=t);this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass)}switchModel(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof T.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&(e?this.gtaoPass.enabled=!0:this.gtaoPass&&(this.gtaoPass.enabled=!1))}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof T.DirectionalLight),i={low:1024,medium:2048,high:4096}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class Vn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;constructor(e){this.engine=e,this.init()}init(){this.overlayMaterial=new T.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:T.AdditiveBlending,depthWrite:!1})}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const s of i){const o=new T.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),o.matrix.copy(s.matrixWorld),o.matrixAutoUpdate=!1,this.engine.scene.add(o),this.overlayMeshes.push(o)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/Vn.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/Vn.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var jn={exports:{}},Vc=jn.exports,zr;function jc(){return zr||(zr=1,(function(r,e){(function(t,n){r.exports=n()})(Vc,function(){var t=function(){function n(p){return o.appendChild(p.dom),p}function i(p){for(var d=0;d<o.children.length;d++)o.children[d].style.display=d===p?"block":"none";s=p}var s=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(p){p.preventDefault(),i(++s%o.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var f=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var p=(performance||Date).now();if(u.update(p-a,200),p>l+1e3&&(c.update(1e3*h/(p-l),100),l=p,h=0,f)){var d=performance.memory;f.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,h=l(window.devicePixelRatio||1),c=80*h,u=48*h,f=3*h,p=2*h,d=3*h,m=15*h,g=74*h,y=30*h,w=document.createElement("canvas");w.width=c,w.height=u,w.style.cssText="width:80px;height:48px";var b=w.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=s,b.fillRect(0,0,c,u),b.fillStyle=i,b.fillText(n,f,p),b.fillRect(d,m,g,y),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(d,m,g,y),{dom:w,update:function(x,_){o=Math.min(o,x),a=Math.max(a,x),b.fillStyle=s,b.globalAlpha=1,b.fillRect(0,0,c,m),b.fillStyle=i,b.fillText(l(x)+" "+n+" ("+l(o)+"-"+l(a)+")",f,p),b.drawImage(w,d+h,m,g-h,y,d,m,g-h,y),b.fillRect(d+g-h,m,h,y),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(d+g-h,m,h,l((1-x/_)*y))}}},t})})(jn)),jn.exports}var Gc=jc();const Wc=Os(Gc);var Wt=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-Wt.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?Wt.Bounce.In(r*2)*.5:Wt.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),an=function(){return performance.now()},Xc=(function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=an()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],o=!t;s&&s.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),Vi={Linear:function(r,e){var t=r.length-1,n=t*e,i=Math.floor(n),s=Vi.Utils.Linear;return e<0?s(r[0],r[1],n):e>1?s(r[t],r[t-1],t-n):s(r[i],r[i+1>t?t:i+1],n-i)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},Nr=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),ji=new Xc,qc=(function(){function r(e,t){t===void 0&&(t=ji),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Wt.Linear.None,this._interpolationFunction=Vi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Nr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=an()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,n,i,s){for(var o in n){var a=e[o],l=Array.isArray(a),h=l?"array":typeof a,c=!l&&Array.isArray(n[o]);if(!(h==="undefined"||h==="function")){if(c){var u=n[o];if(u.length===0)continue;for(var f=[a],p=0,d=u.length;p<d;p+=1){var m=this._handleRelativeValue(a,u[p]);if(isNaN(m)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(m)}c&&(n[o]=f)}if((h==="object"||l)&&a&&!c){t[o]=l?[]:{};var g=a;for(var y in g)t[o][y]=g[y];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var w={};for(var y in u)w[y]=u[y];n[o]=u=w}this._setupProperties(g,t[o],u,i[o],s)}else(typeof t[o]>"u"||s)&&(t[o]=a),l||(t[o]*=1),c?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},r.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=an()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=an()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=ji),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=Wt.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=Vi.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=an()),t===void 0&&(t=!0),this._isPaused)return!0;var s,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),h=this._duration+this._repeat*l,c=function(){if(n._duration===0||a>h)return 1;var g=Math.trunc(a/l),y=a-g*l,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},u=c(),f=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,f),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,m=this._chainedTweens.length;d<m;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var o=t[s]||0,a=n[s],l=Array.isArray(e[s]),h=Array.isArray(a),c=!l&&h;c?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[s]=o+(a-o)*i))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},r})();Nr.nextId;var et=ji;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var Gi={Easing:Wt,Tween:qc};function Kc(){return new T.Scene}function Zc(r,e){r.appendChild(e.domElement)}function Yc(r,e,t){var n=new Object;n.visible=!0;let i=null,s,o,a=[];n.init=function(){s||(h(),c(),u())},n.Hide=function(){s.style.display="none",n.visible=!1},n.Show=function(){s.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);const d=new T.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(d.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(d){var m=new T.Vector3(0,0,0);d=="top"?m=new T.Vector3(0,1,1e-5):d=="down"?m=new T.Vector3(0,-1,1e-5):d=="front"?m=new T.Vector3(0,0,1):d=="left"?m=new T.Vector3(-1,0,0):d=="back"?m=new T.Vector3(0,0,-1):d=="right"?m=new T.Vector3(1,0,0):d=="top_front"?m=new T.Vector3(1,1,0):d=="top_left"?m=new T.Vector3(0,1,-1):d=="top_back"?m=new T.Vector3(-1,1,0):d=="top_right"?m=new T.Vector3(0,1,1):d=="down_front"?m=new T.Vector3(1,-1,0):d=="down_left"?m=new T.Vector3(0,-1,-1):d=="down_back"?m=new T.Vector3(-1,-1,0):d=="down_right"?m=new T.Vector3(0,-1,1):d=="front_right"?m=new T.Vector3(1,0,1):d=="right_back"?m=new T.Vector3(-1,0,1):d=="back_left"?m=new T.Vector3(-1,0,-1):d=="left_front"?m=new T.Vector3(1,0,-1):d=="top_left_front"?m=new T.Vector3(1,1,-1):d=="top_front_right"?m=new T.Vector3(1,1,1):d=="top_right_back"?m=new T.Vector3(-1,1,1):d=="top_back_left"?m=new T.Vector3(-1,1,-1):d=="button_left_front"?m=new T.Vector3(1,-1,-1):d=="button_front_right"?m=new T.Vector3(1,-1,1):d=="button_right_back"?m=new T.Vector3(-1,1,1):d=="button_back_left"&&(m=new T.Vector3(-1,-1,-1));var g=r.octreeBox.getBoundingBox(),y=g.min,w=g.max,b=y.clone().add(w.clone()).multiplyScalar(.5),x=b.clone().add(m.multiplyScalar(1*w.distanceTo(y)));l(e.camera.position,x,r.controls.target.clone(),b)},n.GetCameraPose=function(){var d=e.camera.quaternion,m=e.camera.position,g=r.controls.target,y={quaternion:d,position:m,target:g};return y},n.ReductionCameraPose=function(d,m=1e3,g){var y=new T.Quaternion(d.quaternion._x,d.quaternion._y,d.quaternion._z,d.quaternion._w),w=new T.Vector3(d.position.x,d.position.y,d.position.z),b=new T.Vector3(d.target.x,d.target.y,d.target.z);let x=!1;l(e.camera.position,w,r.controls.target.clone(),b,e.camera.quaternion,y,m,_=>{g&&(x||(g(_),x=!0))}),g&&setTimeout(()=>{x||(g(!0),x=!0)},m+10)},n.CameraGoHome=function(){var d=r.octreeBox.getBoundingBox(),m=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let g=new T.Vector3(1,1,1);var y=d.max.distanceTo(d.min),w=m.clone().add(g.multiplyScalar(y));if(e.camera.isOrthographicCamera){var b=r.container.clientWidth/r.container.clientHeight,x=y*.6;e.camera.left=-x*b,e.camera.right=x*b,e.camera.top=x,e.camera.bottom=-x,e.camera.zoom=1,e.camera.updateProjectionMatrix()}l(e.camera.position,w,r.controls.target.clone(),m)},n.zoomToBox=function(d){var m=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let y=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var w=m.clone().add(y.multiplyScalar(1*d.max.distanceTo(d.min)));l(e.camera.position,w,r.controls.target.clone(),m)};function l(d,m,g,y,w,b,x=1e3,_){var D;w&&b?(D=new Gi.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w}),D.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z,_x:b._x,_y:b._y,_z:b._z,_w:b._w},x)):(D=new Gi.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z}),D.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z},x)),D.onUpdate(function(k){r.controls&&(w&&b?(e.camera.quaternion._x=k._x,e.camera.quaternion._y=k._y,e.camera.quaternion._z=k._z,e.camera.quaternion._w=k._w):r.controls.auto=!0,e.camera.position.x=k.x1,e.camera.position.y=k.y1,e.camera.position.z=k.z1,r.controls.target.x=k.x2,r.controls.target.y=k.y2,r.controls.target.z=k.z2,r.controls.update(),n.RenderScene())}),D.onComplete(function(k){r.controls&&(r.controls.auto=!1,n.RenderScene(),_&&_(!0),cancelAnimationFrame(i),i=null)}),D.easing(Gi.Easing.Cubic.InOut);function P(k){i=requestAnimationFrame(P),D.update()}D.start(),P()}function h(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...",s.appendChild(o);var d=document.createElement("div");d.className="homeViewWrapper",d.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(d);const m=document.createElement("div");m.className="cameraToggleWrapper",m.title="切换正交/透视视图",m.innerHTML="⊞",m.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),w()}),s.appendChild(m);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("截图"),n.TakeScreenshot(),w()}),s.appendChild(g);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),w()}),s.appendChild(y),o.addEventListener("mousedown",function(x){x.stopPropagation(),m.classList.contains("show")?(w(),console.log("隐藏功能按钮")):(b(),console.log("显示功能按钮"))});function w(){m.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function b(){m.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function c(){n.sceneOrtho=Kc();var g=t.clientWidth,y=t.clientWidth,d=g>y?g/y:y/g,m=300;n.camera=new T.OrthographicCamera(m*d/-2,m*d/2,m/2,m/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,w=new T.WebGLRenderer({alpha:!0});w.setSize(g,y),w.setClearAlpha(0),n.sceneOrtho.renderer=w;let b=new T.AmbientLight(16777215,.8);n.sceneOrtho.add(b),Zc(s,w)}function u(){const d="/assets/viewcube/";let m=[{label:"右",icon:d+"cn_right.png"},{label:"左",icon:d+"cn_left.png"},{label:"顶",icon:d+"cn_top.png"},{label:"底",icon:d+"cn_bottom.png"},{label:"前",icon:d+"cn_front.png"},{label:"后",icon:d+"cn_back.png"}];var g=[];for(const w of m)g.push(new T.MeshBasicMaterial({color:16777215,map:new T.TextureLoader().load(w.icon)}));new T.MeshLambertMaterial({color:255});var y=new T.Mesh(new T.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),f(122),s.addEventListener("mousedown",w=>{var b={};b.x=w.offsetX/s.clientWidth*2-1,b.y=-(w.offsetY/s.clientHeight)*2+1;var x=new T.Raycaster;x.setFromCamera(b,n.camera);const _=x.intersectObjects(a,!1);_.length>0&&n.ToggleDirectionView(_[0].object.name)}),s.addEventListener("mousemove",w=>{var b={};b.x=w.offsetX/s.clientWidth*2-1,b.y=-(w.offsetY/s.clientHeight)*2+1;var x=new T.Raycaster;x.setFromCamera(b,n.camera);const _=x.intersectObjects(a,!1);for(var D of a)D.material.opacity=.01;_.length>0&&(_[0].object.material.opacity=.2)})}function f(d){for(var m=d*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new T.Vector3(m,0,0)},{name:"back",a:75,b:75,c:30,point:new T.Vector3(0,0,-m)},{name:"left",a:30,b:75,c:75,point:new T.Vector3(-m,0,0)},{name:"front",a:75,b:75,c:30,point:new T.Vector3(0,0,m)},{name:"top",a:75,b:30,c:75,point:new T.Vector3(0,m,0)},{name:"button",a:75,b:30,c:75,point:new T.Vector3(0,-m,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new T.Vector3(-m,m,m)},{name:"button_front_right",a:30,b:30,c:30,point:new T.Vector3(-m,-m,m)},{name:"top_front_right",a:30,b:30,c:30,point:new T.Vector3(m,m,m)},{name:"button_right_back",a:30,b:30,c:30,point:new T.Vector3(m,-m,m)},{name:"top_back_left",a:30,b:30,c:30,point:new T.Vector3(-m,m,-m)},{name:"button_back_left",a:30,b:30,c:30,point:new T.Vector3(-m,-m,-m)},{name:"top_left_front",a:30,b:30,c:30,point:new T.Vector3(m,m,-m)},{name:"button_left_front",a:30,b:30,c:30,point:new T.Vector3(m,-m,-m)}],w=[{name:"top_front",a:30,b:30,c:75,point:new T.Vector3(m,m,0)},{name:"top_right",a:75,b:30,c:30,point:new T.Vector3(0,m,m)},{name:"top_back",a:30,b:30,c:75,point:new T.Vector3(-m,m,0)},{name:"top_left",a:75,b:30,c:30,point:new T.Vector3(0,m,-m)},{name:"button_front",a:30,b:30,c:75,point:new T.Vector3(m,-m,0)},{name:"button_right",a:75,b:30,c:30,point:new T.Vector3(0,-m,m)},{name:"button_back",a:30,b:30,c:75,point:new T.Vector3(-m,-m,0)},{name:"button_left",a:75,b:30,c:30,point:new T.Vector3(0,-m,-m)},{name:"front_right",a:30,b:75,c:30,point:new T.Vector3(m,0,m)},{name:"right_back",a:30,b:75,c:30,point:new T.Vector3(-m,0,m)},{name:"back_left",a:30,b:75,c:30,point:new T.Vector3(-m,0,-m)},{name:"left_front",a:30,b:75,c:30,point:new T.Vector3(m,0,-m)}],b=0;b<g.length;b++)a.push(p(g[b]));for(var b=0;b<y.length;b++)a.push(p(y[b]));for(var b=0;b<w.length;b++)a.push(p(w[b]))}function p(d){const m=new T.BoxGeometry(d.a,d.b,d.c),g=new T.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new T.Matrix4().makeTranslation(d.point.x,d.point.y,d.point.z);let w=m.applyMatrix4(y),b=new T.Mesh(w,g);return b.name=d.name,n.sceneOrtho.add(b),b}return n.ToggleCameraType=function(){r.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!r.renderer){console.error("渲染器未初始化");return}r.renderer.render(e,e.camera);const m=r.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=m,g.click(),console.log("截图已保存")}catch(d){console.error("截图失败:",d)}},n.ToggleFullscreen=function(){const d=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(d.requestFullscreen?d.requestFullscreen():d.webkitRequestFullscreen?d.webkitRequestFullscreen():d.mozRequestFullScreen?d.mozRequestFullScreen():d.msRequestFullscreen&&d.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class $c{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Yc(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function Jc(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,n=new T.Vector3(1e8,1e9,1e10),i=new T.Vector3(-1e8,-1e9,-1e10);t.forEach(u=>{let f=u.boundingBox.min,p=u.boundingBox.max;f.x<n.x&&(n.x=f.x),f.y<n.y&&(n.y=f.y),f.z<n.z&&(n.z=f.z),p.x>i.x&&(i.x=p.x),p.y>i.y&&(i.y=p.y),p.z>i.z&&(i.z=p.z)});let s=Math.min(n.x,i.x),o=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),h=Math.max(n.y,i.y),c=Math.max(n.z,i.z);return{min:new T.Vector3(s,o,a),max:new T.Vector3(l,h,c)}},e.rayInterationModel=function(t){let n=[];return r.engineStatus.models.forEach(o=>{o.info.lods.forEach(a=>{let l=a.octreeBox;s(t,l,o)})}),t.intersectObjects(n,!1);function s(o,a,l){if(a==null)return;let h=new T.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),c=new T.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),u=new T.Vector3(Math.min(h.x,c.X),Math.min(h.y,c.y),Math.min(h.z,c.z)),f=new T.Vector3(Math.max(c.x,h.x),Math.max(c.y,h.y),Math.max(c.z,h.z)),p=new T.Box3(u,f),d=o.ray.intersectsBox(p);if(!(d==null||d==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var m of a.elements){let g=r.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let y=r.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let b=r.models.find(x=>x.url==l.url).nodesMap.get(m);b!=null&&!b.instance&&b.infos.map(_=>_.mesh).forEach(_=>{n.push(_)})}}else{if(a.elements!=null)for(var m of a.elements){let y=r.engineStatus.hideModels.find(_=>_.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let w=r.engineStatus.translucentModels.find(_=>_.url==l.url)?.ids;if(w!=null&&w.includes(m))continue;let x=r.models.find(_=>_.url==l.url).nodesMap.get(m);x!=null&&!x.instance&&x.infos.map(D=>D.mesh).forEach(D=>{n.push(D)})}for(let g of a.children)s(o,g,l)}}},e}class Hc{engine;isDrawing=!1;startPoint=new T.Vector2;endPoint=new T.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new Ve(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),n=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),s=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${n}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${s}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:s},{x:i,y:s},{x:i,y:o},{x:n,y:o}];for(const c of l){const u=this.worldToScreen.screenToWorld(c.x,c.y);u&&a.push(u)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const h=new T.Box3;for(const c of a)h.expandByPoint(c);if(h.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(h)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new T.Vector3;e.getCenter(i);const s=new T.Vector3;e.getSize(s);const o=Math.max(s.x,s.y,s.z);if(t instanceof T.PerspectiveCamera){const a=t.fov*(Math.PI/180),h=o/(2*Math.tan(a/2))*1.2,c=new T.Vector3;t.getWorldDirection(c);const u=i.clone().sub(t.position);c.dot(u.normalize())<0&&c.negate();const p=i.clone().sub(c.multiplyScalar(h));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof T.OrthographicCamera){const l=o*1.2,h=this.engine.renderer?.domElement,c=h?h.width/h.height:1;t.left=-l*c/2,t.right=l*c/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const u=new T.Vector3;t.getWorldDirection(u);const f=o*1.5,p=i.clone().sub(u.multiplyScalar(f));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class Qc{engine;ground=null;constructor(e){this.engine=e}init(){}setStatsVisible(e){this.engine.stats?.dom&&(this.engine.stats.dom.style.display=e?"block":"none")}setAmbientLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof T.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof T.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);if(t?.shadow){const i={low:1024,medium:2048,high:4096,ultra:8192}[e];t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null}}setDirectionalLightShadow(e){const t=this.engine.scene.children.find(n=>n instanceof T.DirectionalLight);t&&(t.castShadow=e),this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e)}setGTAOEnabled(e){if(!this.engine.composerModule?.composer){console.warn("Composer not initialized");return}const t=this.engine.composerModule.composer,n=t.passes.find(i=>i instanceof ze);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),o=new ze(this.engine.scene,this.engine.camera,i,s);o.output=ze.OUTPUT.Default,o.blendIntensity=.5,o.updateGtaoMaterial&&o.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0});const a=t.passes.findIndex(l=>l.constructor.name==="RenderPass");t.passes.splice(a+1,0,o)}else n&&(n.enabled=!1)}setSceneSaturation(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.saturation.value=e}setSceneContrast(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.contrast.value=e}setGroundEnabled(e,t){if(e)if(this.ground)this.ground.visible=!0;else{const n=t?.size??100,i=t?.color??8421504,s=t?.opacity??.3,o=new T.PlaneGeometry(n,n),a=new T.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:T.DoubleSide});this.ground=new T.Mesh(o,a),this.ground.rotation.x=-Math.PI/2,this.ground.position.y=0,this.ground.receiveShadow=!0,this.ground.name="ground",this.engine.scene.add(this.ground)}else this.ground&&(this.ground.visible=!1)}setHDRBackground(e){e?(this.engine.scene.background=e,this.engine.scene.environment=e):(this.engine.scene.background=null,this.engine.scene.environment=null)}}function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var e=Math.random()*16|0,t=r=="x"?e:e&3|8;return t.toString(16)})}class it{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=xi(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(d=>{p(d)}),this.engine.measure.annotationData.elevationAnnotation.forEach(d=>{f(d)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(d=>{u(d)}),this.engine.measure.annotationData.angleAnnotation.forEach(d=>{l(d)}),this.engine.measure.annotationData.areaAnnotation.forEach(d=>{h(d)}),this.engine.measure.annotationData.slopeAnnotation.forEach(d=>{c(d)});function l(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="angle-annotation",d.container.id=d.id,d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point3),w=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;m.x+=w,m.y+=b,g.x+=w,g.y+=b,y.x+=w,y.y+=b;let x=d.container;x.getElementsByTagName("circle")[0].setAttribute("cx",m.x),x.getElementsByTagName("circle")[0].setAttribute("cy",m.y),x.getElementsByTagName("circle")[1].setAttribute("cx",g.x),x.getElementsByTagName("circle")[1].setAttribute("cy",g.y),x.getElementsByTagName("circle")[2].setAttribute("cx",y.x),x.getElementsByTagName("circle")[2].setAttribute("cy",y.y),x.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y),x.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let _=g.x,D=g.y-30;x.getElementsByTagName("rect")[0].setAttribute("x",_-40),x.getElementsByTagName("rect")[0].setAttribute("y",D-12.5),x.getElementsByTagName("text")[0].setAttribute("x",_),x.getElementsByTagName("text")[0].setAttribute("y",D+4),x.getElementsByTagName("text")[0].innerHTML=d.text,x.style.top="0px",x.style.left="0px"}function h(d){if(d.container==null){let k=['<svg class="measureSvg">','<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,2)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="area-annotation",d.container.id=d.id,d.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}if(!d.points||d.points.length<3)return;let m=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],w=0,b=0;for(let k=0;k<d.points.length;k++){let C=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.points[k]);C.x+=m,C.y+=g,y.push(C),w+=C.x,b+=C.y}w=w/y.length,b=b/y.length;let x=y.map(k=>k.x+","+k.y).join(" "),_=d.container;_.getElementsByTagName("polygon")[0].setAttribute("points",x),_.getElementsByTagName("polyline")[0].setAttribute("points",x);let D=w,P=b;_.getElementsByTagName("rect")[0].setAttribute("x",D-40),_.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),_.getElementsByTagName("text")[0].setAttribute("x",D),_.getElementsByTagName("text")[0].setAttribute("y",P+4),_.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,2),_.style.top="0px",_.style.left="0px"}function c(d){if(d.container==null){let D=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+d.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+d.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="slope-annotation",d.container.id=d.id,d.container.innerHTML=D,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.x+=y,m.y+=w,g.x+=y,g.y+=w;let b=d.container;b.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y);let x=(m.x+g.x)/2,_=(m.y+g.y)/2-30;b.getElementsByTagName("rect")[0].setAttribute("x",x-50),b.getElementsByTagName("rect")[0].setAttribute("y",_-12.5),b.getElementsByTagName("text")[0].setAttribute("x",x),b.getElementsByTagName("text")[0].setAttribute("y",_+4),b.getElementsByTagName("text")[0].innerHTML=d.text,b.style.top="0px",b.style.left="0px"}function u(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(d.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-d.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(d.textY,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="coordinate-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container,g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=w,m.style.top="0px",m.style.left="0px";let b=m.getElementsByTagName("circle")[0];b&&(b.setAttribute("cx",g.x),b.setAttribute("cy",g.y));let x=m.getElementsByTagName("rect"),_=m.getElementsByTagName("text"),D=-55;x[0]&&(x[0].setAttribute("x",g.x+10),x[0].setAttribute("y",g.y+10+D)),_[0]&&(_[0].setAttribute("x",g.x+10+40),_[0].setAttribute("y",g.y+10+16+D)),x[1]&&(x[1].setAttribute("x",g.x+10),x[1].setAttribute("y",g.y+10+30+D)),_[1]&&(_[1].setAttribute("x",g.x+10+40),_[1].setAttribute("y",g.y+10+46+D)),x[2]&&(x[2].setAttribute("x",g.x+10),x[2].setAttribute("y",g.y+10+60+D)),_[2]&&(_[2].setAttribute("x",g.x+10+40),_[2].setAttribute("y",g.y+10+76+D)),_[0]&&(_[0].innerHTML="X: "+e.getMeasureText(d.textX,1)),_[1]&&(_[1].innerHTML="Y: "+e.getMeasureText(-d.textZ,1)),_[2]&&(_[2].innerHTML="Z: "+e.getMeasureText(d.textY,1))}function f(d){if(d.container==null){let b=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");d.container=document.createElement("div"),d.container.className="elevation-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container,g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.style.top=g.y+w-48+"px",m.style.left=g.x+y-16+"px",m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1)}function p(d){if(d.container==null){let x=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="normal-annotation",d.container.id=d.id,d.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container;if(d.point1==null||d.point2==null){m.style.display="none";return}else m.style.display="block";let g=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),y=new Ve(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),w=e.engine.reactBoundingClientRect.left,b=e.engine.reactBoundingClientRect.top;g.x+=w,g.y+=b,y.x+=w,y.y+=b,m.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),m.getElementsByTagName("circle")[0].setAttribute("cx",g.x),m.getElementsByTagName("circle")[0].setAttribute("cy",g.y),m.getElementsByTagName("circle")[1].setAttribute("cx",y.x),m.getElementsByTagName("circle")[1].setAttribute("cy",y.y),m.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),m.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),m.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1),m.style.top="0px",m.style.left="0px"}}}class eh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:nt(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new T.Raycaster(e.catch.point.clone().add(new T.Vector3(0,.01,0)),new T.Vector3(0,1,0));const i=this.engine.octreeBox.rayInterationModel(n);if(i.length===0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(ve.MeasureChanged,t)}}class th{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active()}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:nt(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class nh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:nt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new T.Raycaster(e.catch.point.clone().add(e.catch.normal.clone().setLength(.01)),e.catch.normal);const i=this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(ve.MeasureChanged,t)}}class ih{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(ve.MeasureChanged,t))}}class sh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,this.engine.events.trigger(ve.MeasureChanged,t))}}class rh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new T.Vector3().subVectors(e,t),s=new T.Vector3().subVectors(n,t),o=i.length(),a=s.length();if(o===0||a===0)return 0;const h=i.dot(s)/(o*a),c=Math.max(-1,Math.min(1,h));return Math.acos(c)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class oh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const s=(i+1)%n;t+=e[i].x*e[s].z,t-=e[s].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:nt(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:nt(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,e))}}class ah{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,s=t.z-e.z,o=Math.sqrt(i*i+s*s);if(o===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/o*100,h=Math.atan(n/o)*(180/Math.PI);return{percentage:a,angle:h,heightDiff:n,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);n==null&&(n={id:nt(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class lh{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new eh(e),this.distanceMeasure=new th(e),this.clearDistanceMeasure=new nh(e),this.elevationMeasure=new ih(e),this.pointMeasure=new sh(e),this.angleMeasure=new rh(e),this.areaMeasure=new oh(e),this.slopeMeasure=new ah(e),this.tools=new it(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let n=0;n<t.length;n++)t[n].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}const Rr=0,ch=1,hh=2,Fr=2,Wi=1.25,Ur=1,Ie=32,Me=Ie/4,Vr=65535,uh=Math.pow(2,-24),Xi=Symbol("SKIP_GENERATION");function dh(r){return r.index?r.index.count:r.attributes.position.count}function Tt(r){return dh(r)/3}function fh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function ph(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=fh(t,n);r.setIndex(new S.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function jr(r,e){const t=Tt(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,o=Math.max(0,i),a=Math.min(t,s)-o;return[{offset:Math.floor(o),count:Math.floor(a)}]}function Gr(r,e){if(!r.groups||!r.groups.length)return jr(r,e);const t=[],n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,o=Tt(r),a=[];for(const c of r.groups){const{start:u,count:f}=c,p=u/3,d=isFinite(f)?f:o*3-u,m=(u+d)/3;p<s&&m>i&&(a.push({pos:Math.max(i,p),isStart:!0}),a.push({pos:Math.min(s,m),isStart:!1}))}a.sort((c,u)=>c.pos!==u.pos?c.pos-u.pos:c.type==="end"?-1:1);let l=0,h=null;for(const c of a){const u=c.pos;l!==0&&u!==h&&t.push({offset:h,count:u-h}),l+=c.isStart?1:-1,h=u}return t}function qi(r,e,t,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,f=1/0,p=1/0,d=-1/0,m=-1/0,g=-1/0;const y=r.offset||0;for(let w=(e-y)*6,b=(e+t-y)*6;w<b;w+=6){const x=r[w+0],_=r[w+1],D=x-_,P=x+_;D<s&&(s=D),P>l&&(l=P),x<u&&(u=x),x>d&&(d=x);const k=r[w+2],C=r[w+3],I=k-C,O=k+C;I<o&&(o=I),O>h&&(h=O),k<f&&(f=k),k>m&&(m=k);const A=r[w+4],B=r[w+5],v=A-B,z=A+B;v<a&&(a=v),z>c&&(c=z),A<p&&(p=A),A>g&&(g=A)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=h,n[5]=c,i[0]=u,i[1]=f,i[2]=p,i[3]=d,i[4]=m,i[5]=g}function Wr(r,e,t=null,n=null,i=null){const s=r.attributes.position,o=r.index?r.index.array:null,a=s.normalized;if(i===null)i=new Float32Array(t*6),i.offset=e;else if(e<0||t+e>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=s.array,h=s.offset||0;let c=3;s.isInterleavedBufferAttribute&&(c=s.data.stride);const u=["getX","getY","getZ"],f=i.offset;for(let p=e,d=e+t;p<d;p++){const g=(n?n[p]:p)*3,y=(p-f)*6;let w=g+0,b=g+1,x=g+2;o&&(w=o[w],b=o[b],x=o[x]),a||(w=w*c+h,b=b*c+h,x=x*c+h);for(let _=0;_<3;_++){let D,P,k;a?(D=s[u[_]](w),P=s[u[_]](b),k=s[u[_]](x)):(D=l[w+_],P=l[b+_],k=l[x+_]);let C=D;P<C&&(C=P),k<C&&(C=k);let I=D;P>I&&(I=P),k>I&&(I=k);const O=(I-C)/2,A=_*2;i[y+A+0]=C+O,i[y+A+1]=O+(Math.abs(C)+O)*uh}}return i}function we(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Xr(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function qr(r,e){e.set(r)}function Kr(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function Gn(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function ln(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const st=32,mh=(r,e)=>r.candidate-e.candidate,dt=new Array(st).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Wn=new Float32Array(6);function gh(r,e,t,n,i,s){let o=-1,a=0;if(s===Rr)o=Xr(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===ch)o=Xr(r),o!==-1&&(a=yh(t,n,i,o));else if(s===hh){const l=ln(r);let h=Wi*i;const c=t.offset||0,u=(n-c)*6,f=(n+i-c)*6;for(let p=0;p<3;p++){const d=e[p],y=(e[p+3]-d)/st;if(i<st/4){const w=[...dt];w.length=i;let b=0;for(let _=u;_<f;_+=6,b++){const D=w[b];D.candidate=t[_+2*p],D.count=0;const{bounds:P,leftCacheBounds:k,rightCacheBounds:C}=D;for(let I=0;I<3;I++)C[I]=1/0,C[I+3]=-1/0,k[I]=1/0,k[I+3]=-1/0,P[I]=1/0,P[I+3]=-1/0;Gn(_,t,P)}w.sort(mh);let x=i;for(let _=0;_<x;_++){const D=w[_];for(;_+1<x&&w[_+1].candidate===D.candidate;)w.splice(_+1,1),x--}for(let _=u;_<f;_+=6){const D=t[_+2*p];for(let P=0;P<x;P++){const k=w[P];D>=k.candidate?Gn(_,t,k.rightCacheBounds):(Gn(_,t,k.leftCacheBounds),k.count++)}}for(let _=0;_<x;_++){const D=w[_],P=D.count,k=i-D.count,C=D.leftCacheBounds,I=D.rightCacheBounds;let O=0;P!==0&&(O=ln(C)/l);let A=0;k!==0&&(A=ln(I)/l);const B=Ur+Wi*(O*P+A*k);B<h&&(o=p,h=B,a=D.candidate)}}else{for(let x=0;x<st;x++){const _=dt[x];_.count=0,_.candidate=d+y+x*y;const D=_.bounds;for(let P=0;P<3;P++)D[P]=1/0,D[P+3]=-1/0}for(let x=u;x<f;x+=6){let P=~~((t[x+2*p]-d)/y);P>=st&&(P=st-1);const k=dt[P];k.count++,Gn(x,t,k.bounds)}const w=dt[st-1];qr(w.bounds,w.rightCacheBounds);for(let x=st-2;x>=0;x--){const _=dt[x],D=dt[x+1];Kr(_.bounds,D.rightCacheBounds,_.rightCacheBounds)}let b=0;for(let x=0;x<st-1;x++){const _=dt[x],D=_.count,P=_.bounds,C=dt[x+1].rightCacheBounds;D!==0&&(b===0?qr(P,Wn):Kr(P,Wn,Wn)),b+=D;let I=0,O=0;b!==0&&(I=ln(Wn)/l);const A=i-b;A!==0&&(O=ln(C)/l);const B=Ur+Wi*(I*b+O*A);B<h&&(o=p,h=B,a=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function yh(r,e,t,n){let i=0;const s=r.offset;for(let o=e,a=e+t;o<a;o++)i+=r[(o-s)*6+n*2];return i/t}class Ki{constructor(){this.boundingData=new Float32Array(6)}}function wh(r,e,t,n,i,s){let o=n,a=n+i-1;const l=s.pos,h=s.axis*2,c=t.offset||0;for(;;){for(;o<=a&&t[(o-c)*6+h]<l;)o++;for(;o<=a&&t[(a-c)*6+h]>=l;)a--;if(o<a){for(let u=0;u<3;u++){let f=e[o*3+u];e[o*3+u]=e[a*3+u],e[a*3+u]=f}for(let u=0;u<6;u++){const f=o-c,p=a-c,d=t[f*6+u];t[f*6+u]=t[p*6+u],t[p*6+u]=d}o++,a--}else return o}}function bh(r,e,t,n,i,s){let o=n,a=n+i-1;const l=s.pos,h=s.axis*2,c=t.offset||0;for(;;){for(;o<=a&&t[(o-c)*6+h]<l;)o++;for(;o<=a&&t[(a-c)*6+h]>=l;)a--;if(o<a){let u=r[o];r[o]=r[a],r[a]=u;for(let f=0;f<6;f++){const p=o-c,d=a-c,m=t[p*6+f];t[p*6+f]=t[d*6+f],t[d*6+f]=m}o++,a--}else return o}}let Zr,Xn,Zi,Yr;const xh=Math.pow(2,32);function Yi(r){return"count"in r?1:1+Yi(r.left)+Yi(r.right)}function _h(r,e,t){return Zr=new Float32Array(t),Xn=new Uint32Array(t),Zi=new Uint16Array(t),Yr=new Uint8Array(t),$i(r,e)}function $i(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let o=0;o<6;o++)Zr[t+o]=s[o];if(i)return e.buffer?(Yr.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Xn[t+6]=e.offset,Zi[n+14]=e.count,Zi[n+15]=Vr,r+Ie);{const{left:o,right:a,splitAxis:l}=e,h=r+Ie;let c=$i(h,o);const u=r/Ie,p=c/Ie-u;if(p>xh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Xn[t+6]=p,Xn[t+7]=l,$i(c,a)}}function vh(r,e,t){const i=(r.index?r.index.count:r.attributes.position.count)/3>2**16,s=t.reduce((c,u)=>c+u.count,0),o=i?4:2,a=e?new SharedArrayBuffer(s*o):new ArrayBuffer(s*o),l=i?new Uint32Array(a):new Uint16Array(a);let h=0;for(let c=0;c<t.length;c++){const{offset:u,count:f}=t[c];for(let p=0;p<f;p++)l[h+p]=u+p;h+=f}return l}function Mh(r,e,t,n,i){const{maxDepth:s,verbose:o,maxLeafTris:a,strategy:l,onProgress:h,indirect:c}=i,u=r._indirectBuffer,f=r.geometry,p=f.index?f.index.array:null,d=c?bh:wh,m=Tt(f),g=new Float32Array(6);let y=!1;const w=new Ki;return qi(e,t,n,w.boundingData,g),x(w,t,n,g),w;function b(_){h&&h(_/m)}function x(_,D,P,k=null,C=0){if(!y&&C>=s&&(y=!0,o&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),P<=a||C>=s)return b(D+P),_.offset=D,_.count=P,_;const I=gh(_.boundingData,k,e,D,P,l);if(I.axis===-1)return b(D+P),_.offset=D,_.count=P,_;const O=d(u,p,e,D,P,I);if(O===D||O===D+P)b(D+P),_.offset=D,_.count=P;else{_.splitAxis=I.axis;const A=new Ki,B=D,v=O-D;_.left=A,qi(e,B,v,A.boundingData,g),x(A,B,v,g,C+1);const z=new Ki,Z=O,W=P-v;_.right=z,qi(e,Z,W,z.boundingData,g),x(z,Z,W,g,C+1)}return _}}function Sh(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.geometry;let i,s;if(e.indirect){const o=Gr(n,e.range),a=vh(n,e.useSharedArrayBuffer,o);r._indirectBuffer=a,i=Wr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{ph(n,e);const o=jr(n,e.range)[0];i=Wr(n,o.offset,o.count),s=Gr(n,e.range)}r._roots=s.map(o=>{const a=Mh(r,i,o.offset,o.count,e),l=Yi(a),h=new t(Ie*l);return _h(0,a,h),h})}class rt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){const l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){const a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}rt.prototype.setFromBox=(function(){const r=new S.Vector3;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let c=0;c<=1;c++){r.x=i.x*l+s.x*(1-l),r.y=i.y*h+s.y*(1-h),r.z=i.z*c+s.z*(1-c);const u=t.dot(r);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}})();const Ah=(function(){const r=new S.Vector3,e=new S.Vector3,t=new S.Vector3;return function(i,s,o){const a=i.start,l=r,h=s.start,c=e;t.subVectors(a,h),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const u=t.dot(c),f=c.dot(l),p=c.dot(c),d=t.dot(l),g=l.dot(l)*p-f*f;let y,w;g!==0?y=(u*f-d*p)/g:y=0,w=(u+y*f)/p,o.x=y,o.y=w}})(),Ji=(function(){const r=new S.Vector2,e=new S.Vector3,t=new S.Vector3;return function(i,s,o,a){Ah(i,s,r);let l=r.x,h=r.y;if(l>=0&&l<=1&&h>=0&&h<=1){i.at(l,o),s.at(h,a);return}else if(l>=0&&l<=1){h<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(h>=0&&h<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let u;h<0?u=s.start:u=s.end;const f=e,p=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(c,!0,t),f.distanceToSquared(u)<=p.distanceToSquared(c)){o.copy(f),a.copy(u);return}else{o.copy(c),a.copy(p);return}}}})(),Th=(function(){const r=new S.Vector3,e=new S.Vector3,t=new S.Plane,n=new S.Line3;return function(s,o){const{radius:a,center:l}=s,{a:h,b:c,c:u}=o;if(n.start=h,n.end=c,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=h,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const m=o.getPlane(t);if(Math.abs(m.distanceToPoint(l))<=a){const y=m.projectPoint(l,e);if(o.containsPoint(y))return!0}return!1}})(),Ch=["x","y","z"],ot=1e-15,$r=ot*ot;function je(r){return Math.abs(r)<ot}class Ge extends S.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new S.Vector3),this.satBounds=new Array(4).fill().map(()=>new rt),this.points=[this.a,this.b,this.c],this.plane=new S.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new S.Line3,this.needsUpdate=!0}intersectsSphere(e){return Th(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const h=s[1],c=o[1];h.subVectors(e,t),c.setFromPoints(h,i);const u=s[2],f=o[2];u.subVectors(t,n),f.setFromPoints(u,i);const p=s[3],d=o[3];p.subVectors(n,e),d.setFromPoints(p,i);const m=h.length(),g=u.length(),y=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<ot?g<ot||y<ot?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ot?y<ot?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ot&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Ge.prototype.closestPointToSegment=(function(){const r=new S.Vector3,e=new S.Vector3,t=new S.Line3;return function(i,s=null,o=null){const{start:a,end:l}=i,h=this.points;let c,u=1/0;for(let f=0;f<3;f++){const p=(f+1)%3;t.start.copy(h[f]),t.end.copy(h[p]),Ji(t,i,r,e),c=r.distanceToSquared(e),c<u&&(u=c,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),c=a.distanceToSquared(r),c<u&&(u=c,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),c=l.distanceToSquared(r),c<u&&(u=c,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(u)}})(),Ge.prototype.intersectsTriangle=(function(){const r=new Ge,e=new rt,t=new rt,n=new S.Vector3,i=new S.Vector3,s=new S.Vector3,o=new S.Vector3,a=new S.Line3,l=new S.Line3,h=new S.Vector3,c=new S.Vector2,u=new S.Vector2;function f(b,x,_,D){const P=n;!b.isDegenerateIntoPoint&&!b.isDegenerateIntoSegment?P.copy(b.plane.normal):P.copy(x.plane.normal);const k=b.satBounds,C=b.satAxes;for(let A=1;A<4;A++){const B=k[A],v=C[A];if(e.setFromPoints(v,x.points),B.isSeparated(e)||(o.copy(P).cross(v),e.setFromPoints(o,b.points),t.setFromPoints(o,x.points),e.isSeparated(t)))return!1}const I=x.satBounds,O=x.satAxes;for(let A=1;A<4;A++){const B=I[A],v=O[A];if(e.setFromPoints(v,b.points),B.isSeparated(e)||(o.crossVectors(P,v),e.setFromPoints(o,b.points),t.setFromPoints(o,x.points),e.isSeparated(t)))return!1}return _&&(D||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}function p(b,x,_,D,P,k,C,I,O,A,B){let v=C/(C-I);A.x=D+(P-D)*v,B.start.subVectors(x,b).multiplyScalar(v).add(b),v=C/(C-O),A.y=D+(k-D)*v,B.end.subVectors(_,b).multiplyScalar(v).add(b)}function d(b,x,_,D,P,k,C,I,O,A,B){if(P>0)p(b.c,b.a,b.b,D,x,_,O,C,I,A,B);else if(k>0)p(b.b,b.a,b.c,_,x,D,I,C,O,A,B);else if(I*O>0||C!=0)p(b.a,b.b,b.c,x,_,D,C,I,O,A,B);else if(I!=0)p(b.b,b.a,b.c,_,x,D,I,C,O,A,B);else if(O!=0)p(b.c,b.a,b.b,D,x,_,O,C,I,A,B);else return!0;return!1}function m(b,x,_,D){const P=x.degenerateSegment,k=b.plane.distanceToPoint(P.start),C=b.plane.distanceToPoint(P.end);return je(k)?je(C)?f(b,x,_,D):(_&&(_.start.copy(P.start),_.end.copy(P.start)),b.containsPoint(P.start)):je(C)?(_&&(_.start.copy(P.end),_.end.copy(P.end)),b.containsPoint(P.end)):b.plane.intersectLine(P,n)!=null?(_&&(_.start.copy(n),_.end.copy(n)),b.containsPoint(n)):!1}function g(b,x,_){const D=x.a;return je(b.plane.distanceToPoint(D))&&b.containsPoint(D)?(_&&(_.start.copy(D),_.end.copy(D)),!0):!1}function y(b,x,_){const D=b.degenerateSegment,P=x.a;return D.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<$r?(_&&(_.start.copy(P),_.end.copy(P)),!0):!1}function w(b,x,_,D){if(b.isDegenerateIntoSegment)if(x.isDegenerateIntoSegment){const P=b.degenerateSegment,k=x.degenerateSegment,C=i,I=s;P.delta(C),k.delta(I);const O=n.subVectors(k.start,P.start),A=C.x*I.y-C.y*I.x;if(je(A))return!1;const B=(O.x*I.y-O.y*I.x)/A,v=-(C.x*O.y-C.y*O.x)/A;if(B<0||B>1||v<0||v>1)return!1;const z=P.start.z+C.z*B,Z=k.start.z+I.z*v;return je(z-Z)?(_&&(_.start.copy(P.start).addScaledVector(C,B),_.end.copy(P.start).addScaledVector(C,B)),!0):!1}else return x.isDegenerateIntoPoint?y(b,x,_):m(x,b,_,D);else{if(b.isDegenerateIntoPoint)return x.isDegenerateIntoPoint?x.a.distanceToSquared(b.a)<$r?(_&&(_.start.copy(b.a),_.end.copy(b.a)),!0):!1:x.isDegenerateIntoSegment?y(x,b,_):g(x,b,_);if(x.isDegenerateIntoPoint)return g(b,x,_);if(x.isDegenerateIntoSegment)return m(b,x,_,D)}}return function(x,_=null,D=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(r.copy(x),r.update(),x=r);const P=w(this,x,_,D);if(P!==void 0)return P;const k=this.plane,C=x.plane;let I=C.distanceToPoint(this.a),O=C.distanceToPoint(this.b),A=C.distanceToPoint(this.c);je(I)&&(I=0),je(O)&&(O=0),je(A)&&(A=0);const B=I*O,v=I*A;if(B>0&&v>0)return!1;let z=k.distanceToPoint(x.a),Z=k.distanceToPoint(x.b),W=k.distanceToPoint(x.c);je(z)&&(z=0),je(Z)&&(Z=0),je(W)&&(W=0);const Q=z*Z,G=z*W;if(Q>0&&G>0)return!1;i.copy(k.normal),s.copy(C.normal);const te=i.cross(s);let F=0,R=Math.abs(te.x);const ne=Math.abs(te.y);ne>R&&(R=ne,F=1),Math.abs(te.z)>R&&(F=2);const Y=Ch[F],de=this.a[Y],fe=this.b[Y],se=this.c[Y],oe=x.a[Y],he=x.b[Y],pe=x.c[Y];if(d(this,de,fe,se,B,v,I,O,A,c,a))return f(this,x,_,D);if(d(x,oe,he,pe,Q,G,z,Z,W,u,l))return f(this,x,_,D);if(c.y<c.x){const Ae=c.y;c.y=c.x,c.x=Ae,h.copy(a.start),a.start.copy(a.end),a.end.copy(h)}if(u.y<u.x){const Ae=u.y;u.y=u.x,u.x=Ae,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return c.y<u.x||u.y<c.x?!1:(_&&(u.x>c.x?_.start.copy(l.start):_.start.copy(a.start),u.y<c.y?_.end.copy(l.end):_.end.copy(a.end)),!0)}})(),Ge.prototype.distanceToPoint=(function(){const r=new S.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})(),Ge.prototype.distanceToTriangle=(function(){const r=new S.Vector3,e=new S.Vector3,t=["a","b","c"],n=new S.Line3,i=new S.Line3;return function(o,a=null,l=null){const h=a||l?n:null;if(this.intersectsTriangle(o,h))return(a||l)&&(a&&h.getCenter(a),l&&h.getCenter(l)),0;let c=1/0;for(let u=0;u<3;u++){let f;const p=t[u],d=o[p];this.closestPointToPoint(d,r),f=d.distanceToSquared(r),f<c&&(c=f,a&&a.copy(r),l&&l.copy(d));const m=this[p];o.closestPointToPoint(m,r),f=m.distanceToSquared(r),f<c&&(c=f,a&&a.copy(m),l&&l.copy(r))}for(let u=0;u<3;u++){const f=t[u],p=t[(u+1)%3];n.set(this[f],this[p]);for(let d=0;d<3;d++){const m=t[d],g=t[(d+1)%3];i.set(o[m],o[g]),Ji(n,i,r,e);const y=r.distanceToSquared(e);y<c&&(c=y,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(c)}})();class Ee{constructor(e,t,n){this.isOrientedBox=!0,this.min=new S.Vector3,this.max=new S.Vector3,this.matrix=new S.Matrix4,this.invMatrix=new S.Matrix4,this.points=new Array(8).fill().map(()=>new S.Vector3),this.satAxes=new Array(3).fill().map(()=>new S.Vector3),this.satBounds=new Array(3).fill().map(()=>new rt),this.alignedSatBounds=new Array(3).fill().map(()=>new rt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ee.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let h=0;h<=1;h++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){const f=1*h|2*c|4*u,p=i[f];p.x=h?n.x:t.x,p.y=c?n.y:t.y,p.z=u?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let h=0;h<3;h++){const c=o[h],u=s[h],f=1<<h,p=i[f];c.subVectors(a,p),u.setFromPoints(c,i)}const l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Ee.prototype.intersectsBox=(function(){const r=new rt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){const h=o[l],c=s[l];if(r.setFromBox(h,t),c.isSeparated(r))return!1}return!0}})(),Ee.prototype.intersectsTriangle=(function(){const r=new Ge,e=new Array(3),t=new rt,n=new rt,i=new S.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let f=0;f<3;f++){const p=a[f],d=l[f];if(t.setFromPoints(d,e),p.isSeparated(t))return!1}const h=o.satBounds,c=o.satAxes,u=this.points;for(let f=0;f<3;f++){const p=h[f],d=c[f];if(t.setFromPoints(d,u),p.isSeparated(t))return!1}for(let f=0;f<3;f++){const p=l[f];for(let d=0;d<4;d++){const m=c[d];if(i.crossVectors(p,m),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}})(),Ee.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),Ee.prototype.distanceToPoint=(function(){const r=new S.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})(),Ee.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new S.Line3),t=new Array(12).fill().map(()=>new S.Line3),n=new S.Vector3,i=new S.Vector3;return function(o,a=0,l=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||h)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),h&&h.copy(i)),0;const c=a*a,u=o.min,f=o.max,p=this.points;let d=1/0;for(let g=0;g<8;g++){const y=p[g];i.copy(y).clamp(u,f);const w=y.distanceToSquared(i);if(w<d&&(d=w,l&&l.copy(y),h&&h.copy(i),w<c))return Math.sqrt(w)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){const b=(g+1)%3,x=(g+2)%3,_=y<<b|w<<x,D=1<<g|y<<b|w<<x,P=p[_],k=p[D];e[m].set(P,k);const I=r[g],O=r[b],A=r[x],B=t[m],v=B.start,z=B.end;v[I]=u[I],v[O]=y?u[O]:f[O],v[A]=w?u[A]:f[O],z[I]=f[I],z[O]=y?u[O]:f[O],z[A]=w?u[A]:f[O],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){i.x=g?f.x:u.x,i.y=y?f.y:u.y,i.z=w?f.z:u.z,this.closestPointToPoint(i,n);const b=i.distanceToSquared(n);if(b<d&&(d=b,l&&l.copy(n),h&&h.copy(i),b<c))return Math.sqrt(b)}for(let g=0;g<12;g++){const y=e[g];for(let w=0;w<12;w++){const b=t[w];Ji(y,b,n,i);const x=n.distanceToSquared(i);if(x<d&&(d=x,l&&l.copy(n),h&&h.copy(i),x<c))return Math.sqrt(x)}}return Math.sqrt(d)}})();class Hi{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Ph extends Hi{constructor(){super(()=>new Ge)}}const We=new Ph;function Se(r,e){return e[r+15]===Vr}function Fe(r,e){return e[r+6]}function Xe(r,e){return e[r+14]}function Ce(r){return r+Me}function Pe(r,e){const t=e[r+6];return r+t*Me}function Qi(r,e){return e[r+7]}function Rd(r){return r}class Dh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const me=new Dh;let ft,Xt;const qt=[],qn=new Hi(()=>new S.Box3);function kh(r,e,t,n,i,s){ft=qn.getPrimitive(),Xt=qn.getPrimitive(),qt.push(ft,Xt),me.setBuffer(r._roots[e]);const o=es(0,r.geometry,t,n,i,s);me.clearBuffer(),qn.releasePrimitive(ft),qn.releasePrimitive(Xt),qt.pop(),qt.pop();const a=qt.length;return a>0&&(Xt=qt[a-1],ft=qt[a-2]),o}function es(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:h}=me;let c=r*2;if(Se(c,l)){const f=Fe(r,h),p=Xe(c,l);return we(r,a,ft),n(f,p,!1,o,s+r/Me,ft)}else{let I=function(A){const{uint16Array:B,uint32Array:v}=me;let z=A*2;for(;!Se(z,B);)A=Ce(A),z=A*2;return Fe(A,v)},O=function(A){const{uint16Array:B,uint32Array:v}=me;let z=A*2;for(;!Se(z,B);)A=Pe(A,v),z=A*2;return Fe(A,v)+Xe(z,B)};const f=Ce(r),p=Pe(r,h);let d=f,m=p,g,y,w,b;if(i&&(w=ft,b=Xt,we(d,a,w),we(m,a,b),g=i(w),y=i(b),y<g)){d=p,m=f;const A=g;g=y,y=A,w=b}w||(w=ft,we(d,a,w));const x=Se(d*2,l),_=t(w,x,g,o+1,s+d/Me);let D;if(_===Fr){const A=I(d),v=O(d)-A;D=n(A,v,!0,o+1,s+d/Me,w)}else D=_&&es(d,e,t,n,i,s,o+1);if(D)return!0;b=Xt,we(m,a,b);const P=Se(m*2,l),k=t(b,P,y,o+1,s+m/Me);let C;if(k===Fr){const A=I(m),v=O(m)-A;C=n(A,v,!0,o+1,s+m/Me,b)}else C=k&&es(m,e,t,n,i,s,o+1);return!!C}}const cn=new S.Vector3,ts=new S.Vector3;function Ih(r,e,t={},n=0,i=1/0){const s=n*n,o=i*i;let a=1/0,l=null;if(r.shapecast({boundsTraverseOrder:c=>(cn.copy(e).clamp(c.min,c.max),cn.distanceToSquared(e)),intersectsBounds:(c,u,f)=>f<a&&f<o,intersectsTriangle:(c,u)=>{c.closestPointToPoint(e,cn);const f=e.distanceToSquared(cn);return f<a&&(ts.copy(cn),a=f,l=u),f<s}}),a===1/0)return null;const h=Math.sqrt(a);return t.point?t.point.copy(ts):t.point=ts.clone(),t.distance=h,t.faceIndex=l,t}const Kn=parseInt(S.REVISION)>=169,Eh=parseInt(S.REVISION)<=161,Ct=new S.Vector3,Pt=new S.Vector3,Dt=new S.Vector3,Zn=new S.Vector2,Yn=new S.Vector2,$n=new S.Vector2,Jr=new S.Vector3,Hr=new S.Vector3,Qr=new S.Vector3,hn=new S.Vector3;function Bh(r,e,t,n,i,s,o,a){let l;if(s===S.BackSide?l=r.intersectTriangle(n,t,e,!0,i):l=r.intersectTriangle(e,t,n,s!==S.DoubleSide,i),l===null)return null;const h=r.origin.distanceTo(i);return h<o||h>a?null:{distance:h,point:i.clone()}}function eo(r,e,t,n,i,s,o,a,l,h,c){Ct.fromBufferAttribute(e,s),Pt.fromBufferAttribute(e,o),Dt.fromBufferAttribute(e,a);const u=Bh(r,Ct,Pt,Dt,hn,l,h,c);if(u){if(n){Zn.fromBufferAttribute(n,s),Yn.fromBufferAttribute(n,o),$n.fromBufferAttribute(n,a),u.uv=new S.Vector2;const p=S.Triangle.getInterpolation(hn,Ct,Pt,Dt,Zn,Yn,$n,u.uv);Kn||(u.uv=p)}if(i){Zn.fromBufferAttribute(i,s),Yn.fromBufferAttribute(i,o),$n.fromBufferAttribute(i,a),u.uv1=new S.Vector2;const p=S.Triangle.getInterpolation(hn,Ct,Pt,Dt,Zn,Yn,$n,u.uv1);Kn||(u.uv1=p),Eh&&(u.uv2=u.uv1)}if(t){Jr.fromBufferAttribute(t,s),Hr.fromBufferAttribute(t,o),Qr.fromBufferAttribute(t,a),u.normal=new S.Vector3;const p=S.Triangle.getInterpolation(hn,Ct,Pt,Dt,Jr,Hr,Qr,u.normal);u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1),Kn||(u.normal=p)}const f={a:s,b:o,c:a,normal:new S.Vector3,materialIndex:0};if(S.Triangle.getNormal(Ct,Pt,Dt,f.normal),u.face=f,u.faceIndex=s,Kn){const p=new S.Vector3;S.Triangle.getBarycoord(hn,Ct,Pt,Dt,p),u.barycoord=p}}return u}function to(r){return r&&r.isMaterial?r.side:r}function Jn(r,e,t,n,i,s,o){const a=n*3;let l=a+0,h=a+1,c=a+2;const{index:u,groups:f}=r;r.index&&(l=u.getX(l),h=u.getX(h),c=u.getX(c));const{position:p,normal:d,uv:m,uv1:g}=r.attributes;if(Array.isArray(e)){const y=n*3;for(let w=0,b=f.length;w<b;w++){const{start:x,count:_,materialIndex:D}=f[w];if(y>=x&&y<x+_){const P=to(e[D]),k=eo(t,p,d,m,g,l,h,c,P,s,o);if(k)if(k.faceIndex=n,k.face.materialIndex=D,i)i.push(k);else return k}}}else{const y=to(e),w=eo(t,p,d,m,g,l,h,c,y,s,o);if(w)if(w.faceIndex=n,w.face.materialIndex=0,i)i.push(w);else return w}return null}function xe(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,h=e+2;t&&(a=t.getX(a),l=t.getX(l),h=t.getX(h)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(h),o.y=n.getY(h),o.z=n.getZ(h)}function Lh(r,e,t,n,i,s,o,a){const{geometry:l,_indirectBuffer:h}=r;for(let c=n,u=n+i;c<u;c++)Jn(l,e,t,c,s,o,a)}function Oh(r,e,t,n,i,s,o){const{geometry:a,_indirectBuffer:l}=r;let h=1/0,c=null;for(let u=n,f=n+i;u<f;u++){let p;p=Jn(a,e,t,u,null,s,o),p&&p.distance<h&&(c=p,h=p.distance)}return c}function zh(r,e,t,n,i,s,o){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=r,u=e+r;c<u;c++){let f;if(f=c,xe(o,f*3,l,h),o.needsUpdate=!0,n(o,f,i,s))return!0}return!1}function Nh(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,o,a,l,h=0;const c=r._roots;for(let f=0,p=c.length;f<p;f++)s=c[f],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(f,p,d=!1){const m=f*2;if(Se(m,a)){const g=o[f+6],y=a[m+14];let w=1/0,b=1/0,x=1/0,_=-1/0,D=-1/0,P=-1/0;for(let k=3*g,C=3*(g+y);k<C;k++){let I=n[k];const O=i.getX(I),A=i.getY(I),B=i.getZ(I);O<w&&(w=O),O>_&&(_=O),A<b&&(b=A),A>D&&(D=A),B<x&&(x=B),B>P&&(P=B)}return l[f+0]!==w||l[f+1]!==b||l[f+2]!==x||l[f+3]!==_||l[f+4]!==D||l[f+5]!==P?(l[f+0]=w,l[f+1]=b,l[f+2]=x,l[f+3]=_,l[f+4]=D,l[f+5]=P,!0):!1}else{const g=Ce(f),y=Pe(f,o);let w=d,b=!1,x=!1;if(e){if(!w){const I=g/Me+p/Ie,O=y/Me+p/Ie;b=e.has(I),x=e.has(O),w=!b&&!x}}else b=!0,x=!0;const _=w||b,D=w||x;let P=!1;_&&(P=u(g,p,w));let k=!1;D&&(k=u(y,p,w));const C=P||k;if(C)for(let I=0;I<3;I++){const O=g+I,A=y+I,B=l[O],v=l[O+3],z=l[A],Z=l[A+3];l[f+I]=B<z?B:z,l[f+I+3]=v>Z?v:Z}return C}}}function pt(r,e,t,n,i){let s,o,a,l,h,c;const u=1/t.direction.x,f=1/t.direction.y,p=1/t.direction.z,d=t.origin.x,m=t.origin.y,g=t.origin.z;let y=e[r],w=e[r+3],b=e[r+1],x=e[r+3+1],_=e[r+2],D=e[r+3+2];return u>=0?(s=(y-d)*u,o=(w-d)*u):(s=(w-d)*u,o=(y-d)*u),f>=0?(a=(b-m)*f,l=(x-m)*f):(a=(x-m)*f,l=(b-m)*f),s>l||a>o||((a>s||isNaN(s))&&(s=a),(l<o||isNaN(o))&&(o=l),p>=0?(h=(_-g)*p,c=(D-g)*p):(h=(D-g)*p,c=(_-g)*p),s>c||h>o)?!1:((h>s||s!==s)&&(s=h),(c<o||o!==o)&&(o=c),s<=i&&o>=n)}function Rh(r,e,t,n,i,s,o,a){const{geometry:l,_indirectBuffer:h}=r;for(let c=n,u=n+i;c<u;c++){let f=h?h[c]:c;Jn(l,e,t,f,s,o,a)}}function Fh(r,e,t,n,i,s,o){const{geometry:a,_indirectBuffer:l}=r;let h=1/0,c=null;for(let u=n,f=n+i;u<f;u++){let p;p=Jn(a,e,t,l?l[u]:u,null,s,o),p&&p.distance<h&&(c=p,h=p.distance)}return c}function Uh(r,e,t,n,i,s,o){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=r,u=e+r;c<u;c++){let f;if(f=t.resolveTriangleIndex(c),xe(o,f*3,l,h),o.needsUpdate=!0,n(o,f,i,s))return!0}return!1}function Vh(r,e,t,n,i,s,o){me.setBuffer(r._roots[e]),ns(0,r,t,n,i,s,o),me.clearBuffer()}function ns(r,e,t,n,i,s,o){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=r*2;if(Se(c,l)){const f=Fe(r,h),p=Xe(c,l);Lh(e,t,n,f,p,i,s,o)}else{const f=Ce(r);pt(f,a,n,s,o)&&ns(f,e,t,n,i,s,o);const p=Pe(r,h);pt(p,a,n,s,o)&&ns(p,e,t,n,i,s,o)}}const jh=["x","y","z"];function Gh(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const o=is(0,r,t,n,i,s);return me.clearBuffer(),o}function is(r,e,t,n,i,s){const{float32Array:o,uint16Array:a,uint32Array:l}=me;let h=r*2;if(Se(h,a)){const u=Fe(r,l),f=Xe(h,a);return Oh(e,t,n,u,f,i,s)}else{const u=Qi(r,l),f=jh[u],d=n.direction[f]>=0;let m,g;d?(m=Ce(r),g=Pe(r,l)):(m=Pe(r,l),g=Ce(r));const w=pt(m,o,n,i,s)?is(m,e,t,n,i,s):null;if(w){const _=w.point[f];if(d?_<=o[g+u]:_>=o[g+u+3])return w}const x=pt(g,o,n,i,s)?is(g,e,t,n,i,s):null;return w&&x?w.distance<=x.distance?w:x:w||x||null}}const Hn=new S.Box3,Kt=new Ge,Zt=new Ge,un=new S.Matrix4,no=new Ee,Qn=new Ee;function Wh(r,e,t,n){me.setBuffer(r._roots[e]);const i=ss(0,r,t,n);return me.clearBuffer(),i}function ss(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=me;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),no.set(t.boundingBox.min,t.boundingBox.max,n),i=no),Se(l,o)){const c=e.geometry,u=c.index,f=c.attributes.position,p=t.index,d=t.attributes.position,m=Fe(r,a),g=Xe(l,o);if(un.copy(n).invert(),t.boundsTree)return we(r,s,Qn),Qn.matrix.copy(un),Qn.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>Qn.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let b=m*3,x=(g+m)*3;b<x;b+=3)if(xe(Zt,b,u,f),Zt.needsUpdate=!0,w.intersectsTriangle(Zt))return!0;return!1}});{const y=Tt(t);for(let w=m*3,b=(g+m)*3;w<b;w+=3){xe(Kt,w,u,f),Kt.a.applyMatrix4(un),Kt.b.applyMatrix4(un),Kt.c.applyMatrix4(un),Kt.needsUpdate=!0;for(let x=0,_=y*3;x<_;x+=3)if(xe(Zt,x,p,d),Zt.needsUpdate=!0,Kt.intersectsTriangle(Zt))return!0}}}else{const c=Ce(r),u=Pe(r,a);return we(c,s,Hn),!!(i.intersectsBox(Hn)&&ss(c,e,t,n,i)||(we(u,s,Hn),i.intersectsBox(Hn)&&ss(u,e,t,n,i)))}}const ei=new S.Matrix4,rs=new Ee,dn=new Ee,Xh=new S.Vector3,qh=new S.Vector3,Kh=new S.Vector3,Zh=new S.Vector3;function Yh(r,e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),rs.set(e.boundingBox.min,e.boundingBox.max,t),rs.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,f=We.getPrimitive(),p=We.getPrimitive();let d=Xh,m=qh,g=null,y=null;i&&(g=Kh,y=Zh);let w=1/0,b=null,x=null;return ei.copy(t).invert(),dn.matrix.copy(ei),r.shapecast({boundsTraverseOrder:_=>rs.distanceToBox(_),intersectsBounds:(_,D,P)=>P<w&&P<o?(D&&(dn.min.copy(_.min),dn.max.copy(_.max),dn.needsUpdate=!0),!0):!1,intersectsRange:(_,D)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>dn.distanceToBox(k),intersectsBounds:(k,C,I)=>I<w&&I<o,intersectsRange:(k,C)=>{for(let I=k,O=k+C;I<O;I++){xe(p,3*I,u,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let A=_,B=_+D;A<B;A++){xe(f,3*A,h,l),f.needsUpdate=!0;const v=f.distanceToTriangle(p,d,g);if(v<w&&(m.copy(d),y&&y.copy(g),w=v,b=A,x=I),v<s)return!0}}}});{const P=Tt(e);for(let k=0,C=P;k<C;k++){xe(p,3*k,u,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let I=_,O=_+D;I<O;I++){xe(f,3*I,h,l),f.needsUpdate=!0;const A=f.distanceToTriangle(p,d,g);if(A<w&&(m.copy(d),y&&y.copy(g),w=A,b=I,x=k),A<s)return!0}}}}}),We.releasePrimitive(f),We.releasePrimitive(p),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=b,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ei),m.applyMatrix4(ei),i.distance=m.sub(i.point).length(),i.faceIndex=x),n)}function $h(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,o,a,l,h=0;const c=r._roots;for(let f=0,p=c.length;f<p;f++)s=c[f],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(f,p,d=!1){const m=f*2;if(Se(m,a)){const g=o[f+6],y=a[m+14];let w=1/0,b=1/0,x=1/0,_=-1/0,D=-1/0,P=-1/0;for(let k=g,C=g+y;k<C;k++){const I=3*r.resolveTriangleIndex(k);for(let O=0;O<3;O++){let A=I+O;A=n?n[A]:A;const B=i.getX(A),v=i.getY(A),z=i.getZ(A);B<w&&(w=B),B>_&&(_=B),v<b&&(b=v),v>D&&(D=v),z<x&&(x=z),z>P&&(P=z)}}return l[f+0]!==w||l[f+1]!==b||l[f+2]!==x||l[f+3]!==_||l[f+4]!==D||l[f+5]!==P?(l[f+0]=w,l[f+1]=b,l[f+2]=x,l[f+3]=_,l[f+4]=D,l[f+5]=P,!0):!1}else{const g=Ce(f),y=Pe(f,o);let w=d,b=!1,x=!1;if(e){if(!w){const I=g/Me+p/Ie,O=y/Me+p/Ie;b=e.has(I),x=e.has(O),w=!b&&!x}}else b=!0,x=!0;const _=w||b,D=w||x;let P=!1;_&&(P=u(g,p,w));let k=!1;D&&(k=u(y,p,w));const C=P||k;if(C)for(let I=0;I<3;I++){const O=g+I,A=y+I,B=l[O],v=l[O+3],z=l[A],Z=l[A+3];l[f+I]=B<z?B:z,l[f+I+3]=v>Z?v:Z}return C}}}function Jh(r,e,t,n,i,s,o){me.setBuffer(r._roots[e]),os(0,r,t,n,i,s,o),me.clearBuffer()}function os(r,e,t,n,i,s,o){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=r*2;if(Se(c,l)){const f=Fe(r,h),p=Xe(c,l);Rh(e,t,n,f,p,i,s,o)}else{const f=Ce(r);pt(f,a,n,s,o)&&os(f,e,t,n,i,s,o);const p=Pe(r,h);pt(p,a,n,s,o)&&os(p,e,t,n,i,s,o)}}const Hh=["x","y","z"];function Qh(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const o=as(0,r,t,n,i,s);return me.clearBuffer(),o}function as(r,e,t,n,i,s){const{float32Array:o,uint16Array:a,uint32Array:l}=me;let h=r*2;if(Se(h,a)){const u=Fe(r,l),f=Xe(h,a);return Fh(e,t,n,u,f,i,s)}else{const u=Qi(r,l),f=Hh[u],d=n.direction[f]>=0;let m,g;d?(m=Ce(r),g=Pe(r,l)):(m=Pe(r,l),g=Ce(r));const w=pt(m,o,n,i,s)?as(m,e,t,n,i,s):null;if(w){const _=w.point[f];if(d?_<=o[g+u]:_>=o[g+u+3])return w}const x=pt(g,o,n,i,s)?as(g,e,t,n,i,s):null;return w&&x?w.distance<=x.distance?w:x:w||x||null}}const ti=new S.Box3,Yt=new Ge,$t=new Ge,fn=new S.Matrix4,io=new Ee,ni=new Ee;function eu(r,e,t,n){me.setBuffer(r._roots[e]);const i=ls(0,r,t,n);return me.clearBuffer(),i}function ls(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=me;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),io.set(t.boundingBox.min,t.boundingBox.max,n),i=io),Se(l,o)){const c=e.geometry,u=c.index,f=c.attributes.position,p=t.index,d=t.attributes.position,m=Fe(r,a),g=Xe(l,o);if(fn.copy(n).invert(),t.boundsTree)return we(r,s,ni),ni.matrix.copy(fn),ni.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>ni.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let b=m,x=g+m;b<x;b++)if(xe($t,3*e.resolveTriangleIndex(b),u,f),$t.needsUpdate=!0,w.intersectsTriangle($t))return!0;return!1}});{const y=Tt(t);for(let w=m,b=g+m;w<b;w++){const x=e.resolveTriangleIndex(w);xe(Yt,3*x,u,f),Yt.a.applyMatrix4(fn),Yt.b.applyMatrix4(fn),Yt.c.applyMatrix4(fn),Yt.needsUpdate=!0;for(let _=0,D=y*3;_<D;_+=3)if(xe($t,_,p,d),$t.needsUpdate=!0,Yt.intersectsTriangle($t))return!0}}}else{const c=Ce(r),u=Pe(r,a);return we(c,s,ti),!!(i.intersectsBox(ti)&&ls(c,e,t,n,i)||(we(u,s,ti),i.intersectsBox(ti)&&ls(u,e,t,n,i)))}}const ii=new S.Matrix4,cs=new Ee,pn=new Ee,tu=new S.Vector3,nu=new S.Vector3,iu=new S.Vector3,su=new S.Vector3;function ru(r,e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),cs.set(e.boundingBox.min,e.boundingBox.max,t),cs.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,f=We.getPrimitive(),p=We.getPrimitive();let d=tu,m=nu,g=null,y=null;i&&(g=iu,y=su);let w=1/0,b=null,x=null;return ii.copy(t).invert(),pn.matrix.copy(ii),r.shapecast({boundsTraverseOrder:_=>cs.distanceToBox(_),intersectsBounds:(_,D,P)=>P<w&&P<o?(D&&(pn.min.copy(_.min),pn.max.copy(_.max),pn.needsUpdate=!0),!0):!1,intersectsRange:(_,D)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>pn.distanceToBox(k),intersectsBounds:(k,C,I)=>I<w&&I<o,intersectsRange:(k,C)=>{for(let I=k,O=k+C;I<O;I++){const A=P.resolveTriangleIndex(I);xe(p,3*A,u,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let B=_,v=_+D;B<v;B++){const z=r.resolveTriangleIndex(B);xe(f,3*z,h,l),f.needsUpdate=!0;const Z=f.distanceToTriangle(p,d,g);if(Z<w&&(m.copy(d),y&&y.copy(g),w=Z,b=B,x=I),Z<s)return!0}}}})}else{const P=Tt(e);for(let k=0,C=P;k<C;k++){xe(p,3*k,u,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let I=_,O=_+D;I<O;I++){const A=r.resolveTriangleIndex(I);xe(f,3*A,h,l),f.needsUpdate=!0;const B=f.distanceToTriangle(p,d,g);if(B<w&&(m.copy(d),y&&y.copy(g),w=B,b=I,x=k),B<s)return!0}}}}}),We.releasePrimitive(f),We.releasePrimitive(p),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=b,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ii),m.applyMatrix4(ii),i.distance=m.sub(i.point).length(),i.faceIndex=x),n)}function ou(){return typeof SharedArrayBuffer<"u"}const mn=new me.constructor,si=new me.constructor,mt=new Hi(()=>new S.Box3),Jt=new S.Box3,Ht=new S.Box3,hs=new S.Box3,us=new S.Box3;let ds=!1;function au(r,e,t,n){if(ds)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ds=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const h=new S.Matrix4().copy(t).invert();for(let c=0,u=i.length;c<u;c++){mn.setBuffer(i[c]),l=0;const f=mt.getPrimitive();we(0,mn.float32Array,f),f.applyMatrix4(h);for(let p=0,d=s.length;p<d&&(si.setBuffer(s[p]),o=Ze(0,0,t,h,n,a,l,0,0,f),si.clearBuffer(),l+=s[p].byteLength/Ie,!o);p++);if(mt.releasePrimitive(f),mn.clearBuffer(),a+=i[c].byteLength/Ie,o)break}return ds=!1,o}function Ze(r,e,t,n,i,s=0,o=0,a=0,l=0,h=null,c=!1){let u,f;c?(u=si,f=mn):(u=mn,f=si);const p=u.float32Array,d=u.uint32Array,m=u.uint16Array,g=f.float32Array,y=f.uint32Array,w=f.uint16Array,b=r*2,x=e*2,_=Se(b,m),D=Se(x,w);let P=!1;if(D&&_)c?P=i(Fe(e,y),Xe(e*2,w),Fe(r,d),Xe(r*2,m),l,o+e/Me,a,s+r/Me):P=i(Fe(r,d),Xe(r*2,m),Fe(e,y),Xe(e*2,w),a,s+r/Me,l,o+e/Me);else if(D){const k=mt.getPrimitive();we(e,g,k),k.applyMatrix4(t);const C=Ce(r),I=Pe(r,d);we(C,p,Jt),we(I,p,Ht);const O=k.intersectsBox(Jt),A=k.intersectsBox(Ht);P=O&&Ze(e,C,n,t,i,o,s,l,a+1,k,!c)||A&&Ze(e,I,n,t,i,o,s,l,a+1,k,!c),mt.releasePrimitive(k)}else{const k=Ce(e),C=Pe(e,y);we(k,g,hs),we(C,g,us);const I=h.intersectsBox(hs),O=h.intersectsBox(us);if(I&&O)P=Ze(r,k,t,n,i,s,o,a,l+1,h,c)||Ze(r,C,t,n,i,s,o,a,l+1,h,c);else if(I)if(_)P=Ze(r,k,t,n,i,s,o,a,l+1,h,c);else{const A=mt.getPrimitive();A.copy(hs).applyMatrix4(t);const B=Ce(r),v=Pe(r,d);we(B,p,Jt),we(v,p,Ht);const z=A.intersectsBox(Jt),Z=A.intersectsBox(Ht);P=z&&Ze(k,B,n,t,i,o,s,l,a+1,A,!c)||Z&&Ze(k,v,n,t,i,o,s,l,a+1,A,!c),mt.releasePrimitive(A)}else if(O)if(_)P=Ze(r,C,t,n,i,s,o,a,l+1,h,c);else{const A=mt.getPrimitive();A.copy(us).applyMatrix4(t);const B=Ce(r),v=Pe(r,d);we(B,p,Jt),we(v,p,Ht);const z=A.intersectsBox(Jt),Z=A.intersectsBox(Ht);P=z&&Ze(C,B,n,t,i,o,s,l,a+1,A,!c)||Z&&Ze(C,v,n,t,i,o,s,l,a+1,A,!c),mt.releasePrimitive(A)}}return P}const ri=new Ee,so=new S.Box3,lu={strategy:Rr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class fs{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,o=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=s?s.slice():null):(a.roots=i,a.index=o?o.array:null,a.indirectBuffer=s),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(s));const a=new fs(t,{...n,[Xi]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const h=t.getIndex();if(h===null){const c=new S.BufferAttribute(e.index,1,!1);t.setIndex(c)}else h.array!==i&&(h.array.set(i),h.needsUpdate=!0)}return a;function l(h){for(let c=0;c<h.length;c++){const u=h[c],f=new Uint32Array(u),p=new Uint16Array(u);for(let d=0,m=u.byteLength/Ie;d<m;d++){const g=Me*d,y=2*g;Se(y,p)||(f[g+6]=f[g+6]/Me-d)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...lu,[Xi]:!1},t),t.useSharedArrayBuffer&&!ou())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Xi]||(Sh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new S.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],o=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Ie;for(let h=0;h<l;h++){const c=Me*h,u=2*c;Se(u,a)&&(o[c+6]+=e)}}}}refit(e=null){return(this.indirect?$h:Nh)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const h=a*2,c=Se(h,s);if(c){const u=i[a+6],f=s[h+14];e(l,c,new Float32Array(n,a*4,6),u,f)}else{const u=Ce(a),f=Pe(a,i),p=Qi(a,i);e(l,c,new Float32Array(n,a*4,6),p)||(o(u,l+1),o(f,l+1))}}}raycast(e,t=S.FrontSide,n=0,i=1/0){const s=this._roots,o=[],a=this.indirect?Jh:Vh;for(let l=0,h=s.length;l<h;l++)a(this,l,t,e,o,n,i);return o}raycastFirst(e,t=S.FrontSide,n=0,i=1/0){const s=this._roots;let o=null;const a=this.indirect?Qh:Gh;for(let l=0,h=s.length;l<h;l++){const c=a(this,l,t,e,n,i);c!=null&&(o==null||c.distance<o.distance)&&(o=c)}return o}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?eu:Wh;for(let o=0,a=i.length;o<a&&(n=s(this,o,e,t),!n);o++);return n}shapecast(e){const t=We.getPrimitive(),n=this.indirect?Uh:zh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:o,intersectsTriangle:a}=e;if(o&&a){const u=o;o=(f,p,d,m,g)=>u(f,p,d,m,g)?!0:n(f,p,this,a,d,m,t)}else o||(a?o=(u,f,p,d)=>n(u,f,this,a,p,d,t):o=(u,f,p)=>p);let l=!1,h=0;const c=this._roots;for(let u=0,f=c.length;u<f;u++){const p=c[u];if(l=kh(this,u,s,o,i,h),l)break;h+=p.byteLength/Ie}return We.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const o=We.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,h=this.indirect?d=>{const m=this.resolveTriangleIndex(d);xe(o,m*3,a,l)}:d=>{xe(o,d*3,a,l)},c=We.getPrimitive(),u=e.geometry.index,f=e.geometry.attributes.position,p=e.indirect?d=>{const m=e.resolveTriangleIndex(d);xe(c,m*3,u,f)}:d=>{xe(c,d*3,u,f)};if(s){const d=(m,g,y,w,b,x,_,D)=>{for(let P=y,k=y+w;P<k;P++){p(P),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let C=m,I=m+g;C<I;C++)if(h(C),o.needsUpdate=!0,s(o,c,C,P,b,x,_,D))return!0}return!1};if(i){const m=i;i=function(g,y,w,b,x,_,D,P){return m(g,y,w,b,x,_,D,P)?!0:d(g,y,w,b,x,_,D,P)}}else i=d}return au(this,e,t,i)}intersectsBox(e,t){return ri.set(e.min,e.max,t),ri.needsUpdate=!0,this.shapecast({intersectsBounds:n=>ri.intersectsBox(n),intersectsTriangle:n=>ri.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?ru:Yh)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return Ih(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{we(0,new Float32Array(n),so),e.union(so)}),e}}const ro=1e-6,cu=ro*.5,oo=Math.pow(10,-Math.log10(ro)),hu=cu*oo;function tt(r){return~~(r*oo+hu)}function uu(r){return`${tt(r.x)},${tt(r.y)}`}function ao(r){return`${tt(r.x)},${tt(r.y)},${tt(r.z)}`}function du(r){return`${tt(r.x)},${tt(r.y)},${tt(r.z)},${tt(r.w)}`}function fu(r,e,t){t.direction.subVectors(e,r).normalize();const n=r.dot(t.direction);return t.origin.copy(r).addScaledVector(t.direction,-n),t}function lo(){return typeof SharedArrayBuffer<"u"}function pu(r){if(r.buffer instanceof SharedArrayBuffer)return r;const e=r.constructor,t=r.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function mu(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function gu(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=mu(t,n);r.setIndex(new S.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function yu(r){return r.index?r.index.count:r.attributes.position.count}function ps(r){return yu(r)/3}const wu=1e-8,bu=new S.Vector3;function xu(r){return~~(r/3)}function _u(r){return r%3}function co(r,e){return r.start-e.start}function ho(r,e){return bu.subVectors(e,r.origin).dot(r.direction)}function vu(r,e,t,n=wu){r.sort(co),e.sort(co);for(let a=0;a<r.length;a++){const l=r[a];for(let h=0;h<e.length;h++){const c=e[h];if(!(c.start>l.end)){if(l.end<c.start||c.end<l.start)continue;if(l.start<=c.start&&l.end>=c.end)s(c.end,l.end)||r.splice(a+1,0,{start:c.end,end:l.end,index:l.index}),l.end=c.start,c.start=0,c.end=0;else if(l.start>=c.start&&l.end<=c.end)s(l.end,c.end)||e.splice(h+1,0,{start:l.end,end:c.end,index:c.index}),c.end=l.start,l.start=0,l.end=0;else if(l.start<=c.start&&l.end<=c.end){const u=l.end;l.end=c.start,c.start=u}else if(l.start>=c.start&&l.end>=c.end){const u=c.end;c.end=l.start,l.start=u}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(c.index)||t.set(c.index,[]),t.get(l.index).push(c.index),t.get(c.index).push(l.index),o(c)&&(e.splice(h,1),h--),o(l)){r.splice(a,1),a--;break}}}i(r),i(e);function i(a){for(let l=0;l<a.length;l++)o(a[l])&&(a.splice(l,1),l--)}function s(a,l){return Math.abs(l-a)<n}function o(a){return Math.abs(a.end-a.start)<n}}const uo=1e-5,fo=1e-4;class Mu{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,s=null;for(let l=0,h=t.length;l<h;l++){const c=t[l];if(o(c,e)&&o(c,n))continue;const u=a(c,e),f=a(c,n),p=Math.min(u,f);p<i&&(i=p,s=c)}return s;function o(l,h){const c=l.origin.distanceTo(h.origin)>uo;return l.direction.angleTo(h.direction)>fo||c}function a(l,h){const c=l.origin.distanceTo(h.origin),u=l.direction.angleTo(h.direction);return c/uo+u/fo}}}const ms=new S.Vector3,gs=new S.Vector3,oi=new S.Ray;function Su(r,e,t){const n=r.attributes,i=r.index,s=n.position,o=new Map,a=new Map,l=Array.from(e),h=new Mu;for(let c=0,u=l.length;c<u;c++){const f=l[c],p=xu(f),d=_u(f);let m=3*p+d,g=3*p+(d+1)%3;i&&(m=i.getX(m),g=i.getX(g)),ms.fromBufferAttribute(s,m),gs.fromBufferAttribute(s,g),fu(ms,gs,oi);let y,w=h.findClosestRay(oi);w===null&&(w=oi.clone(),h.addRay(w)),a.has(w)||a.set(w,{forward:[],reverse:[],ray:w}),y=a.get(w);let b=ho(w,ms),x=ho(w,gs);b>x&&([b,x]=[x,b]),oi.direction.dot(w.direction)<0?y.reverse.push({start:b,end:x,index:f}):y.forward.push({start:b,end:x,index:f})}return a.forEach(({forward:c,reverse:u},f)=>{vu(c,u,o,t),c.length===0&&u.length===0&&a.delete(f)}),{disjointConnectivityMap:o,fragmentMap:a}}const Au=new S.Vector2,ys=new S.Vector3,Tu=new S.Vector4,ws=["","",""];class Cu{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>~~(s/3)):[]}getDisjointSiblingEdgeIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>s%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:s}=this,o=t?b:w,a=new Map,{attributes:l}=e,h=t?Object.keys(l):null,c=e.index,u=l.position;let f=ps(e);const p=f;let d=0;n&&(d=e.drawRange.start,e.drawRange.count!==1/0&&(f=~~(e.drawRange.count/3)));let m=this.data;(!m||m.length<3*p)&&(m=new Int32Array(3*p)),m.fill(-1);let g=0,y=new Set;for(let x=d,_=f*3+d;x<_;x+=3){const D=x;for(let P=0;P<3;P++){let k=D+P;c&&(k=c.getX(k)),ws[P]=o(k)}for(let P=0;P<3;P++){const k=(P+1)%3,C=ws[P],I=ws[k],O=`${I}_${C}`;if(a.has(O)){const A=D+P,B=a.get(O);m[A]=B,m[B]=A,a.delete(O),g+=2,y.delete(B)}else{const A=`${C}_${I}`,B=D+P;a.set(A,B),y.add(B)}}}if(i){const{fragmentMap:x,disjointConnectivityMap:_}=Su(e,y,s);y.clear(),x.forEach(({forward:D,reverse:P})=>{D.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=x,this.disjointConnections=_,g=f*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=m;function w(x){return ys.fromBufferAttribute(u,x),ao(ys)}function b(x){let _="";for(let D=0,P=h.length;D<P;D++){const k=l[h[D]];let C;switch(k.itemSize){case 1:C=tt(k.getX(x));break;case 2:C=uu(Au.fromBufferAttribute(k,x));break;case 3:C=ao(ys.fromBufferAttribute(k,x));break;case 4:C=du(Tu.fromBufferAttribute(k,x));break}_!==""&&(_+="|"),_+=C}return _}}}class ai extends S.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new S.Matrix4,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let s=0;s<16;s++)if(n[s]!==i[s])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=lo();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=pu(s.array)}if(e.boundsTree||(gu(e,{useSharedArrayBuffer:n}),e.boundsTree=new fs(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Cu(e)),!e.groupIndices){const i=ps(e),s=new Uint16Array(i),o=e.groups;for(let a=0,l=o.length;a<l;a++){const{start:h,count:c}=o[a];for(let u=h/3,f=(h+c)/3;u<f;u++)s[u]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Pu=1e-14,bs=new S.Vector3,po=new S.Vector3,mo=new S.Vector3;function gt(r,e=Pu){bs.subVectors(r.b,r.a),po.subVectors(r.c,r.a),mo.subVectors(r.b,r.c);const t=bs.angleTo(po),n=bs.angleTo(mo),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||r.a.distanceToSquared(r.b)<e||r.a.distanceToSquared(r.c)<e||r.b.distanceToSquared(r.c)<e}const xs=1e-10,gn=1e-10,Du=1e-10,at=new S.Line3,be=new S.Line3,lt=new S.Vector3,_s=new S.Vector3,go=new S.Vector3,li=new S.Plane,vs=new Ge;class ku{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new S.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class Iu{constructor(){this.trianglePool=new ku,this.triangles=[],this.normal=new S.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,o=e.length;s<o;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(lt).dot(i))>xs)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=n.getTriangle();l.copy(a),t.push(l)}else{e.getNormal(i);const s=n.getTriangle();s.copy(e),t.push(s)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(_s).normalize(),Math.abs(1-Math.abs(_s.dot(t)))<Du){this.coplanarTriangleUsed=!0;for(let s=0,o=n.length;s<o;s++){const a=n[s];a.coplanarCount=0}const i=[e.a,e.b,e.c];for(let s=0;s<3;s++){const o=(s+1)%3,a=i[s],l=i[o];lt.subVectors(l,a).normalize(),go.crossVectors(_s,lt),li.setFromNormalAndCoplanarPoint(go,a),this.splitByPlane(li,e)}}else e.getPlane(li),this.splitByPlane(li,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;vs.copy(t),vs.needsUpdate=!0;for(let s=0,o=n.length;s<o;s++){const a=n[s];if(!vs.intersectsTriangle(a,at,!0))continue;const{a:l,b:h,c}=a;let u=0,f=-1,p=!1,d=[],m=[];const g=[l,h,c];for(let y=0;y<3;y++){const w=(y+1)%3;at.start.copy(g[y]),at.end.copy(g[w]);const b=e.distanceToPoint(at.start),x=e.distanceToPoint(at.end);if(Math.abs(b)<gn&&Math.abs(x)<gn){p=!0;break}if(b>0?d.push(y):m.push(y),Math.abs(b)<gn)continue;let _=!!e.intersectLine(at,lt);!_&&Math.abs(x)<gn&&(lt.copy(at.end),_=!0),_&&!(lt.distanceTo(at.start)<xs)&&(lt.distanceTo(at.end)<xs&&(f=y),u===0?be.start.copy(lt):be.end.copy(lt),u++)}if(!p&&u===2&&be.distance()>gn)if(f!==-1){f=(f+1)%3;let y=0;y===f&&(y=(y+1)%3);let w=y+1;w===f&&(w=(w+1)%3);const b=i.getTriangle();b.a.copy(g[w]),b.b.copy(be.end),b.c.copy(be.start),gt(b)||n.push(b),a.a.copy(g[y]),a.b.copy(be.start),a.c.copy(be.end),gt(a)&&(n.splice(s,1),s--,o--)}else{const y=d.length>=2?m[0]:d[0];if(y===0){let D=be.start;be.start=be.end,be.end=D}const w=(y+1)%3,b=(y+2)%3,x=i.getTriangle(),_=i.getTriangle();g[w].distanceToSquared(be.start)<g[b].distanceToSquared(be.end)?(x.a.copy(g[w]),x.b.copy(be.start),x.c.copy(be.end),_.a.copy(g[w]),_.b.copy(g[b]),_.c.copy(be.start)):(x.a.copy(g[b]),x.b.copy(be.start),x.c.copy(be.end),_.a.copy(g[w]),_.b.copy(g[b]),_.c.copy(be.end)),a.a.copy(g[y]),a.b.copy(be.end),a.c.copy(be.start),gt(x)||n.push(x),gt(_)||n.push(_),gt(a)&&(n.splice(s,1),s--,o--)}else u===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function Eu(r){return r=~~r,r+4-r%4}class yo{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,n=lo()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(Eu(e*t.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,s=e.length;i<s;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class Bu{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let s=0;s<t;s++){const o=n[s];i+=o[e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const i={};t.push(i);for(const s in n){const o=n[s],a=new yo(o.type);a.itemSize=o.itemSize,a.normalized=o.normalized,i[s]=a}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){const{groupAttributes:s}=this,a=s[0][e];if(a){if(a.type!==t)for(let l=0,h=s.length;l<h;l++){const c=s[l][e];c.setType(t),c.itemSize=n,c.normalized=i}}else for(let l=0,h=s.length;l<h;l++){const c=new yo(t);c.itemSize=n,c.normalized=i,s[l][e]=c}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const n in t)t[n].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class wo{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const Lu=0,Ou=1,zu=2,bo=3,Nu=4,xo=5,_o=6,qe=new S.Ray,vo=new S.Matrix4,Be=new S.Triangle,ct=new S.Vector3,Mo=new S.Vector4,So=new S.Vector4,Ao=new S.Vector4,Ms=new S.Vector4,ci=new S.Vector4,hi=new S.Vector4,To=new S.Line3,Ss=new S.Vector3,As=1e-8,Ru=1e-15,kt=-1,It=1,ui=-2,di=2,yn=0,Et=1,Ts=2,Fu=1e-14;let fi=null;function Co(r){fi=r}function Po(r,e){r.getMidpoint(qe.origin),r.getNormal(qe.direction);const t=e.raycastFirst(qe,S.DoubleSide);return!!(t&&qe.direction.dot(t.face.normal)>0)?kt:It}function Uu(r,e){function t(){return Math.random()-.5}r.getNormal(Ss),qe.direction.copy(Ss),r.getMidpoint(qe.origin);const n=3;let i=0,s=1/0;for(let o=0;o<n;o++){qe.direction.x+=t()*As,qe.direction.y+=t()*As,qe.direction.z+=t()*As,qe.direction.multiplyScalar(-1);const a=e.raycastFirst(qe,S.DoubleSide);if(!!(a&&qe.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=Ru)return a.face.normal.dot(Ss)>0?di:ui;if(i/n>.5||(o-i+1)/n>.5)break}return i/n>.5?kt:It}function Vu(r,e){const t=new wo,n=new wo;return vo.copy(r.matrixWorld).invert().multiply(e.matrixWorld),r.geometry.boundsTree.bvhcast(e.geometry.boundsTree,vo,{intersectsTriangles(i,s,o,a){if(!gt(i)&&!gt(s)){let l=i.intersectsTriangle(s,To,!0);if(!l){const h=i.plane,c=s.plane,u=h.normal,f=c.normal;u.dot(f)===1&&Math.abs(h.constant-c.constant)<Fu&&(l=!0)}if(l){let h=r.geometry.boundsTree.resolveTriangleIndex(o),c=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(h,c),n.add(c,h),fi&&(fi.addEdge(To),fi.addIntersectingTriangles(o,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function ju(r,e,t,n,i,s,o=!1){const a=t.attributes,l=t.index,h=r*3,c=l.getX(h+0),u=l.getX(h+1),f=l.getX(h+2);for(const p in s){const d=a[p],m=s[p];if(!(p in a))throw new Error(`CSG Operations: Attribute ${p} not available on geometry.`);const g=d.itemSize;p==="position"?(Be.a.fromBufferAttribute(d,c).applyMatrix4(n),Be.b.fromBufferAttribute(d,u).applyMatrix4(n),Be.c.fromBufferAttribute(d,f).applyMatrix4(n),Cs(Be.a,Be.b,Be.c,e,3,m,o)):p==="normal"?(Be.a.fromBufferAttribute(d,c).applyNormalMatrix(i),Be.b.fromBufferAttribute(d,u).applyNormalMatrix(i),Be.c.fromBufferAttribute(d,f).applyNormalMatrix(i),o&&(Be.a.multiplyScalar(-1),Be.b.multiplyScalar(-1),Be.c.multiplyScalar(-1)),Cs(Be.a,Be.b,Be.c,e,3,m,o,!0)):(Mo.fromBufferAttribute(d,c),So.fromBufferAttribute(d,u),Ao.fromBufferAttribute(d,f),Cs(Mo,So,Ao,e,g,m,o))}}function Gu(r,e,t,n,i,s,o,a=!1){Ps(r,n,i,s,o,a),Ps(a?t:e,n,i,s,o,a),Ps(a?e:t,n,i,s,o,a)}function Do(r,e,t=!1){switch(r){case Lu:if(e===It||e===di&&!t)return Et;break;case Ou:if(t){if(e===kt)return yn}else if(e===It||e===ui)return Et;break;case zu:if(t){if(e===It||e===ui)return Et}else if(e===kt)return yn;break;case Nu:if(e===kt)return yn;if(e===It)return Et;break;case bo:if(e===kt||e===di&&!t)return Et;break;case xo:if(!t&&(e===It||e===ui))return Et;break;case _o:if(!t&&(e===kt||e===di))return Et;break;default:throw new Error(`Unrecognized CSG operation enum "${r}".`)}return Ts}function Cs(r,e,t,n,i,s,o=!1,a=!1){const l=h=>{s.push(h.x),i>1&&s.push(h.y),i>2&&s.push(h.z),i>3&&s.push(h.w)};Ms.set(0,0,0,0).addScaledVector(r,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),ci.set(0,0,0,0).addScaledVector(r,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),hi.set(0,0,0,0).addScaledVector(r,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Ms.normalize(),ci.normalize(),hi.normalize()),l(Ms),o?(l(hi),l(ci)):(l(ci),l(hi))}function Ps(r,e,t,n,i,s=!1){for(const o in i){const a=e[o],l=i[o];if(!(o in e))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const h=a.itemSize;o==="position"?(ct.fromBufferAttribute(a,r).applyMatrix4(t),l.push(ct.x,ct.y,ct.z)):o==="normal"?(ct.fromBufferAttribute(a,r).applyNormalMatrix(n),s&&ct.multiplyScalar(-1),l.push(ct.x,ct.y,ct.z)):(l.push(a.getX(r)),h>1&&l.push(a.getY(r)),h>2&&l.push(a.getZ(r)),h>3&&l.push(a.getW(r)))}}class Wu{constructor(e){this.triangle=new S.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new S.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class ko{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new Wu(t)),s[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(e!==null)e in t&&n.push(t[e].triangle);else for(const i in t)n.push(t[i].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(n=>parseInt(n)):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,s=[],o=a=>{if(n[a])if(t!==null)n[a].intersects[t]&&s.push(n[a].intersects[t]);else{const l=n[a].intersects;for(const h in l)i.has(h)||(i.add(h),s.push(l[h]))}};if(e!==null)o(e);else for(const a in n)o(a);return s}reset(){this.data={}}}class Xu{constructor(){this.enabled=!1,this.triangleIntersectsA=new ko,this.triangleIntersectsB=new ko,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:s,triangleIntersectsB:o}=this;s.addTriangleIntersection(e,t,n,i),o.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),Co(this))}complete(){this.enabled&&Co(null)}}const yt=new S.Matrix4,pi=new S.Matrix3,Bt=new S.Triangle,mi=new S.Triangle,wt=new S.Triangle,gi=new S.Triangle,Ye=[],Lt=[];function qu(r){for(const e of r)return e}function Ku(r,e,t,n,i,s={}){const{useGroups:o=!0}=s,{aIntersections:a,bIntersections:l}=Vu(r,e),h=[];let c=null,u;return u=o?0:-1,Io(r,e,a,t,!1,n,i,u),Eo(r,e,a,t,!1,i,u),t.findIndex(p=>p!==_o&&p!==xo)!==-1&&(u=o?r.geometry.groups.length||1:-1,Io(e,r,l,t,!0,n,i,u),Eo(e,r,l,t,!0,i,u)),Ye.length=0,Lt.length=0,{groups:h,materials:c}}function Io(r,e,t,n,i,s,o,a=0){const l=r.matrixWorld.determinant()<0;yt.copy(e.matrixWorld).invert().multiply(r.matrixWorld),pi.getNormalMatrix(r.matrixWorld).multiplyScalar(l?-1:1);const h=r.geometry.groupIndices,c=r.geometry.index,u=r.geometry.attributes.position,f=e.geometry.boundsTree,p=e.geometry.index,d=e.geometry.attributes.position,m=t.ids,g=t.intersectionSet;for(let y=0,w=m.length;y<w;y++){const b=m[y],x=a===-1?0:h[b]+a,_=3*b,D=c.getX(_+0),P=c.getX(_+1),k=c.getX(_+2);Bt.a.fromBufferAttribute(u,D).applyMatrix4(yt),Bt.b.fromBufferAttribute(u,P).applyMatrix4(yt),Bt.c.fromBufferAttribute(u,k).applyMatrix4(yt),s.reset(),s.initialize(Bt);const C=g[b];for(let O=0,A=C.length;O<A;O++){const B=3*C[O],v=p.getX(B+0),z=p.getX(B+1),Z=p.getX(B+2);mi.a.fromBufferAttribute(d,v),mi.b.fromBufferAttribute(d,z),mi.c.fromBufferAttribute(d,Z),s.splitByTriangle(mi)}const I=s.triangles;for(let O=0,A=I.length;O<A;O++){const B=I[O],v=s.coplanarTriangleUsed?Uu(B,f):Po(B,f);Ye.length=0,Lt.length=0;for(let z=0,Z=n.length;z<Z;z++){const W=Do(n[z],v,i);W!==Ts&&(Lt.push(W),Ye.push(o[z].getGroupAttrSet(x)))}if(Ye.length!==0){Bt.getBarycoord(B.a,gi.a),Bt.getBarycoord(B.b,gi.b),Bt.getBarycoord(B.c,gi.c);for(let z=0,Z=Ye.length;z<Z;z++){const W=Ye[z],G=Lt[z]===yn;ju(b,gi,r.geometry,r.matrixWorld,pi,W,l!==G)}}}}return m.length}function Eo(r,e,t,n,i,s,o=0){const a=r.matrixWorld.determinant()<0;yt.copy(e.matrixWorld).invert().multiply(r.matrixWorld),pi.getNormalMatrix(r.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,h=r.geometry.groupIndices,c=r.geometry.index,u=r.geometry.attributes,f=u.position,p=[],d=r.geometry.halfEdges,m=new Set,g=ps(r.geometry);for(let y=0,w=g;y<w;y++)y in t.intersectionSet||m.add(y);for(;m.size>0;){const y=qu(m);m.delete(y),p.push(y);const w=3*y,b=c.getX(w+0),x=c.getX(w+1),_=c.getX(w+2);wt.a.fromBufferAttribute(f,b).applyMatrix4(yt),wt.b.fromBufferAttribute(f,x).applyMatrix4(yt),wt.c.fromBufferAttribute(f,_).applyMatrix4(yt);const D=Po(wt,l);Lt.length=0,Ye.length=0;for(let P=0,k=n.length;P<k;P++){const C=Do(n[P],D,i);C!==Ts&&(Lt.push(C),Ye.push(s[P]))}for(;p.length>0;){const P=p.pop();for(let k=0;k<3;k++){const C=d.getSiblingTriangleIndex(P,k);C!==-1&&m.has(C)&&(p.push(C),m.delete(C))}if(Ye.length!==0){const k=3*P,C=c.getX(k+0),I=c.getX(k+1),O=c.getX(k+2),A=o===-1?0:h[P]+o;if(wt.a.fromBufferAttribute(f,C),wt.b.fromBufferAttribute(f,I),wt.c.fromBufferAttribute(f,O),!gt(wt))for(let B=0,v=Ye.length;B<v;B++){const z=Lt[B],Z=Ye[B].getGroupAttrSet(A),W=z===yn;Gu(C,I,O,u,r.matrixWorld,pi,Z,W!==a)}}}}}function Zu(r){for(let e=0;e<r.length-1;e++){const t=r[e],n=r[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,s=n.start+n.count;n.start=i,n.count=s-i,r.splice(e,1),e--}}}function Yu(r,e,t,n){t.clear();const i=r.attributes;for(let s=0,o=n.length;s<o;s++){const a=n[s],l=i[a];t.initializeArray(a,l.array.constructor,l.itemSize,l.normalized)}for(const s in t.attributes)n.includes(s)||t.delete(s);for(const s in e.attributes)n.includes(s)||(e.deleteAttribute(s),e.dispose())}function $u(r,e,t){let n=!1,i=-1;const s=r.attributes,o=e.groupAttributes[0];for(const l in o){const h=e.getTotalLength(l),c=e.getType(l),u=e.getItemSize(l),f=e.getNormalized(l);let p=s[l];(!p||p.array.length<h)&&(p=new S.BufferAttribute(new c(h),u,f),r.setAttribute(l,p),n=!0);let d=0;for(let m=0,g=Math.min(t.length,e.groupCount);m<g;m++){const y=t[m].index,{array:w,type:b,length:x}=e.groupAttributes[y][l],_=new b(w.buffer,0,x);p.array.set(_,d),d+=_.length}p.needsUpdate=!0,i=h/p.itemSize}if(r.index){const l=r.index.array;if(l.length<i)r.index=null,n=!0;else for(let h=0,c=l.length;h<c;h++)l[h]=h}let a=0;r.clearGroups();for(let l=0,h=Math.min(t.length,e.groupCount);l<h;l++){const{index:c,materialIndex:u}=t[l],f=e.getCount(c);f!==0&&(r.addGroup(a,f,u),a+=f)}r.setDrawRange(0,i),r.boundsTree=null,n&&r.dispose()}function Bo(r,e){let t=e;return Array.isArray(e)||(t=[],r.forEach(n=>{t[n.materialIndex]=e})),t}class Ju{constructor(){this.triangleSplitter=new Iu,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new Xu}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,n,i=new ai){let s=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],s=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:o,attributeData:a,attributes:l,useGroups:h,consolidateGroups:c,debug:u}=this;for(;a.length<i.length;)a.push(new Bu);i.forEach((y,w)=>{Yu(e.geometry,y.geometry,a[w],l)}),u.init(),Ku(e,t,n,o,a,{useGroups:h}),u.complete();const f=this.getGroupRanges(e.geometry),p=Bo(f,e.material),d=this.getGroupRanges(t.geometry),m=Bo(d,t.material);d.forEach(y=>y.materialIndex+=p.length);let g=[...f,...d].map((y,w)=>({...y,index:w}));if(h){const y=[...p,...m];c&&(g=g.map(b=>{const x=y[b.materialIndex];return b.materialIndex=y.indexOf(x),b}).sort((b,x)=>b.materialIndex-x.materialIndex));const w=[];for(let b=0,x=y.length;b<x;b++){let _=!1;for(let D=0,P=g.length;D<P;D++){const k=g[D];k.materialIndex===b&&(_=!0,k.materialIndex=w.length)}_&&w.push(y[b])}i.forEach(b=>{b.material=w})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=p[0]});return i.forEach((y,w)=>{const b=y.geometry;$u(b,a[w],g),c&&Zu(b.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new ai){e.updateMatrixWorld(!0);const n=(s,o)=>{const a=s.children;for(let l=0,h=a.length;l<h;l++){const c=a[l];c.isOperationGroup?n(c,o):o(c)}},i=s=>{const o=s.children;let a=!1;for(let h=0,c=o.length;h<c;h++){const u=o[h];a=i(u)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let h;return n(s,c=>{h?h=this.evaluate(h,c,c.operation):h=this.evaluate(s,c,c.operation)}),s._cachedGeometry=h.geometry,s._cachedMaterials=h.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class Hu{engine;planeObjects=[];planes=[];isActive=!1;evaluator;geometryCache=new Map;sectionMeshes=new Map;planeGroup;planeSize=1e3;sourceMeshes=new Map;planeThickness=.01;updateThrottleTime=100;lastUpdateTime=0;pendingUpdate=!1;updateTimer=null;cacheExpireTime=3e4;planeStates=new Map;constructor(e,t={}){this.engine=e,this.evaluator=new Ju,this.planeGroup=new T.Group,this.planeGroup.name="CSG_ClippingPlanes_Optimized",t.updateThrottleTime!==void 0&&(this.updateThrottleTime=t.updateThrottleTime),t.cacheExpireTime!==void 0&&(this.cacheExpireTime=t.cacheExpireTime),t.planeThickness!==void 0&&(this.planeThickness=t.planeThickness),this.evaluator.attributes=["position","normal"],this.evaluator.useGroups=!1}init(){this.calculateSceneSize(),this.engine.scene.add(this.planeGroup),this.planes.forEach((e,t)=>{const n=this.createEmptySectionMesh(e,t);this.planeGroup.add(n),this.sectionMeshes.set(`plane_${t}`,n),this.planeObjects.push(n),this.planeStates.set(t,{constant:e.constant,normal:e.normal.clone()})})}createEmptySectionMesh(e,t){const n=new T.BufferGeometry,i=new T.MeshStandardMaterial({color:new T.Color(33023),metalness:.1,roughness:.75,side:T.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((o,a)=>a!==t)}),s=new T.Mesh(n,i);return s.name=`CSG_Section_Optimized_${t}`,s.visible=!1,s.renderOrder=t+1,s}active(){this.isActive=!0,this.requestUpdate(),this.planeObjects.forEach(e=>{e.visible=!0})}disActive(){this.isActive=!1,this.planeObjects.forEach(e=>{e.visible=!1}),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}setSourceMeshes(e){this.sourceMeshes.clear(),e.forEach(t=>{const n=t.uuid;this.sourceMeshes.set(n,t)}),this.isActive&&this.requestUpdate()}addSourceMesh(e){const t=e.uuid;this.sourceMeshes.has(t)||(this.sourceMeshes.set(t,e),this.isActive&&this.requestUpdate())}removeSourceMesh(e){const t=e.uuid;this.sourceMeshes.delete(t)&&(this.clearMeshCache(t),this.isActive&&this.requestUpdate())}requestUpdate(){if(!this.isActive)return;const e=Date.now(),t=e-this.lastUpdateTime;t>=this.updateThrottleTime?(this.lastUpdateTime=e,this.pendingUpdate=!1):(this.pendingUpdate=!0,this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.pendingUpdate&&this.isActive&&(this.lastUpdateTime=Date.now(),this.pendingUpdate=!1),this.updateTimer=null},this.updateThrottleTime-t))}updateAllSections(){this.isActive&&(this.planes.forEach((e,t)=>{if(Math.abs(e.constant)<99999)this.hasPlaneChanged(t,e)&&(this.updateSection(e,t),this.updatePlaneState(t,e));else{const n=this.sectionMeshes.get(`plane_${t}`);n&&(n.visible=!1)}}),this.cleanExpiredCache())}hasPlaneChanged(e,t){const n=this.planeStates.get(e);if(!n)return!0;const i=Math.abs(n.constant-t.constant)>1e-4,s=!n.normal.equals(t.normal);return i||s}updatePlaneState(e,t){this.planeStates.set(e,{constant:t.constant,normal:t.normal.clone()})}getPlaneHash(e){const t=e.normal,n=e.constant;return`${t.x.toFixed(4)}_${t.y.toFixed(4)}_${t.z.toFixed(4)}_${n.toFixed(4)}`}getCacheKey(e,t){return`${e}_plane_${t}`}updateSection(e,t){const n=this.sectionMeshes.get(`plane_${t}`);if(!n)return;const i=this.getPlaneHash(e),s=[];if(this.sourceMeshes.forEach((o,a)=>{const l=this.getCacheKey(a,t),h=this.geometryCache.get(l);if(h&&h.planeHash===i)s.push(h.geometry.clone()),h.timestamp=Date.now();else try{const c=this.createPlaneBrush(e),u=new ai(o.geometry);o.updateMatrixWorld(!0),u.matrix.copy(o.matrixWorld),u.updateMatrixWorld();const f=this.evaluator.evaluate(c,u,bo);f&&f.geometry.attributes.position.count>0?(s.push(f.geometry),this.geometryCache.set(l,{geometry:f.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(c){console.warn(`CSG intersection failed for mesh ${a}:`,c)}}),s.length>0){const o=this.mergeGeometries(s);n.geometry&&n.geometry.dispose(),n.geometry=o,n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),n.updateMatrixWorld()}else n.visible=!1;s.forEach(o=>o.dispose())}clearMeshCache(e){const t=[];this.geometryCache.forEach((n,i)=>{i.startsWith(e)&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}cleanExpiredCache(){const e=Date.now(),t=[];this.geometryCache.forEach((n,i)=>{e-n.timestamp>this.cacheExpireTime&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}clearAllCache(){this.geometryCache.forEach(e=>{e.geometry.dispose()}),this.geometryCache.clear()}createPlaneBrush(e){const t=new T.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new T.Quaternion().setFromUnitVectors(new T.Vector3(0,-1,0),e.normal));const n=new T.Mesh(t),i=new ai(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new T.BufferGeometry,n=[],i=[],s=[];let o=0;return e.forEach(a=>{const l=a.attributes.position,h=a.attributes.normal;for(let c=0;c<l.count;c++)n.push(l.getX(c),l.getY(c),l.getZ(c));if(h)for(let c=0;c<h.count;c++)i.push(h.getX(c),h.getY(c),h.getZ(c));if(a.index)for(let c=0;c<a.index.count;c++)s.push(a.index.getX(c)+o);o+=l.count}),t.setAttribute("position",new T.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new T.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new T.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new T.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new T.Vector3),n=Math.max(t.x,t.y,t.z);this.planeSize=n*3}}update(){this.isActive&&this.pendingUpdate&&!this.updateTimer&&this.requestUpdate()}dispose(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.clearAllCache(),this.planeObjects.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.sectionMeshes.clear(),this.planeObjects=[],this.sourceMeshes.clear(),this.planeGroup.parent&&this.planeGroup.parent.remove(this.planeGroup)}setSectionColor(e){this.planeObjects.forEach(t=>{t.material instanceof T.MeshStandardMaterial&&t.material.color.set(e)})}getCacheStats(){return{cacheSize:this.geometryCache.size,sourceMeshCount:this.sourceMeshes.size,sectionMeshCount:this.sectionMeshes.size}}setPlaneThickness(e){if(e<=0){console.warn("Plane thickness must be positive");return}this.planeThickness=e,this.clearAllCache(),this.isActive&&this.requestUpdate()}getPlaneThickness(){return this.planeThickness}showSections(){this.sectionMeshes.forEach(e=>{e.geometry?.attributes.position?.count&&e.geometry.attributes.position.count>0&&(e.visible=!0)})}hideSections(){this.sectionMeshes.forEach(e=>{e.visible=!1})}showSection(){this.planeGroup.visible=!0}hideSection(){this.planeGroup.visible=!1}toggleSectionsVisibility(){let e=!1;return this.sectionMeshes.forEach(t=>{t.visible&&(e=!0)}),e?(this.hideSections(),!1):(this.showSections(),!0)}toggleSectionVisibility(e){const t=this.sectionMeshes.get(`plane_${e}`);return t?(t.visible=!t.visible,t.visible):!1}}class Qu{engine;isActive=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;csgClipping=null;useCsgClipping=!1;constructor(e,t){this.engine=e,this.meshs=[],t?.useCsgClipping!==void 0&&(this.useCsgClipping=t.useCsgClipping),this.useCsgClipping&&this.initCsgClipping()}initCsgClipping(){this.csgClipping=new Hu(this.engine,{updateThrottleTime:150,cacheExpireTime:45e3}),this.csgClipping.planes=this.engine.sectionPlane,this.csgClipping.init()}active(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0,this.init())}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive(),this.csgClipping&&this.csgClipping.disActive(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})}),this.engine.interactionModule.init(),this.engine.interactionModule.active()}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(){let e=this.engine.octreeBox.getBoundingBox();this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const n=new T.Plane;n.setFromNormalAndCoplanarPoint(new T.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new T.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new T.Plane;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0,this.csgClipping&&this.isActive}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new T.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.pickMesh.name=="前"||this.pickMesh.name=="左"||this.pickMesh.name=="底"?this.box.min=this.box_.min.clone().add(this.pickNormal.clone().setLength(i)):this.box.max=this.box_.max.clone().add(this.pickNormal.clone().setLength(i)),this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){let e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=(this.box.min.x-this.maxBox.min.x)/e*100,s=(this.box.max.x-this.maxBox.min.x)/e*100,o=(this.box.min.y-this.maxBox.min.y)/t*100,a=(this.box.max.y-this.maxBox.min.y)/t*100,l=(this.box.min.z-this.maxBox.min.z)/n*100,h=(this.box.max.z-this.maxBox.min.z)/n*100;i<0&&(i=0),s<0&&(s=0),o<0&&(o=0),a<0&&(a=0),l<0&&(l=0),h<0&&(h=0),i>100&&(i=100),s>100&&(s=100),o>100&&(o=100),a>100&&(a=100),l>100&&(l=100),h>100&&(h=100);let c={x:{min:i,max:s},y:{min:o,max:a},z:{min:l,max:h}};this.engine.events.trigger(ve.SectionMove,c)}updata_face(e){let t=this,n=[new T.Vector3(e.min.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.min.z),new T.Vector3(e.min.x,e.max.y,e.min.z)],i=[new T.Vector3(e.min.x,e.min.y,e.max.z),new T.Vector3(e.max.x,e.min.y,e.max.z),new T.Vector3(e.max.x,e.max.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.max.z)],s=[new T.Vector3(e.max.x,e.min.y,e.max.z),new T.Vector3(e.max.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.max.z)],o=[new T.Vector3(e.min.x,e.min.y,e.min.z),new T.Vector3(e.min.x,e.min.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.min.z)],a=[new T.Vector3(e.min.x,e.max.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.min.z),new T.Vector3(e.max.x,e.max.y,e.max.z),new T.Vector3(e.min.x,e.max.y,e.max.z)],l=[new T.Vector3(e.min.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.min.y,e.min.z),new T.Vector3(e.max.x,e.min.y,e.max.z),new T.Vector3(e.min.x,e.min.y,e.max.z)];h(n,new T.Vector3(0,0,-1),"前"),h(i,new T.Vector3(0,0,1),"后"),h(s,new T.Vector3(1,0,0),"右"),h(o,new T.Vector3(-1,0,0),"左"),h(a,new T.Vector3(0,1,0),"顶"),h(l,new T.Vector3(0,-1,0),"底");function h(c,u,f){const p=new T.BufferGeometry,d=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z]),m=[0,1,2,0,2,3];p.setAttribute("position",new T.BufferAttribute(d,3)),p.setIndex(m);let g=t.engine.scene.children.find(D=>D.type=="Group"&&D.name=="ClippingBox");g==null&&(g=new T.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(D=>D.name==f);if(y==null){const D=new T.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:T.DoubleSide}),P=new T.Mesh(p,D);P.normal=u,P.name=f,g.add(P),t.meshs.push(P)}else y.geometry=p;const w=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z,c[0].x,c[0].y,c[0].z]);let b=new T.LineBasicMaterial({color:255}),x=new T.BufferGeometry;x.setAttribute("position",new T.BufferAttribute(w,3));let _=t.meshs.find(D=>D.name==f+"Line");_==null&&(_=new T.Line(x,b),_.name=f+"Line",g.add(_),t.meshs.push(_)),_.geometry=x,_.material=b,f=="前"||f=="左"||f=="底"?t.engine.sectionPlane.find(D=>D.name==f).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.min):t.engine.sectionPlane.find(D=>D.name==f).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.max),t.engine.scene.children.filter(D=>D.type=="Mesh"&&D.url).forEach(D=>{D.material&&Array.isArray(D.material)?D.material.forEach(P=>{P.clippingPlanes=t.engine.sectionPlane}):D.material.clippingPlanes=t.engine.sectionPlane})}}}class ed{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new T.Vector3(0,0,1);distance=0;center=null;current_center=null;constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!0)})}),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active();let e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive();const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!1)})})}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(0)}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,n){this.angleX=e,this.angleY=t,this.angleZ=n,this.normal=new T.Vector3(0,1,0).applyAxisAngle(new T.Vector3(1,0,0),e).applyAxisAngle(new T.Vector3(0,0,1),t).applyAxisAngle(new T.Vector3(0,1,0),n),this.normal.normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e,this.distance=t,this.updata_face(t)}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){let t=this,n=t.engine.scene.children.find(C=>C.type=="Group"&&C.name=="ClippingBox");n==null&&(n=new T.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new T.Vector3(1,0,0),s=new T.Vector3(0,1,0),o=new T.Vector3(0,0,1),a,l,h=this.normal.clone().normalize(),c=Math.abs(h.dot(i)),u=Math.abs(h.dot(s)),f=Math.abs(h.dot(o));c<=u&&c<=f?a=i:u<=c&&u<=f?a=s:a=o,a=a.clone().sub(h.clone().multiplyScalar(a.dot(h))).normalize(),l=new T.Vector3().crossVectors(h,a).normalize();let p=null;this.center==null?(p=new T.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),this.center=p.clone()):p=this.center.clone();let d=this.box.max.x-this.box.min.x,m=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*d,Math.abs(a.y)*m,Math.abs(a.z)*g),w=Math.max(Math.abs(l.x)*d,Math.abs(l.y)*m,Math.abs(l.z)*g),b=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-w/2)),x=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-w/2)),_=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(w/2)),D=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(w/2));b.add(h.clone().multiplyScalar(e)),x.add(h.clone().multiplyScalar(e)),_.add(h.clone().multiplyScalar(e)),D.add(h.clone().multiplyScalar(e)),this.current_center=p.clone().add(h.clone().multiplyScalar(e)),k([b,x,_,D],h,"face");function k(C,I,O){const A=new T.BufferGeometry,B=new Float32Array([C[0].x,C[0].y,C[0].z,C[1].x,C[1].y,C[1].z,C[2].x,C[2].y,C[2].z,C[3].x,C[3].y,C[3].z]),v=[0,1,2,0,2,3];A.setAttribute("position",new T.BufferAttribute(B,3)),A.setIndex(v);let z=t.meshs.find(te=>te.name==O);if(z==null){const te=new T.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:T.DoubleSide}),F=new T.Mesh(A,te);F.normal=I,F.name=O,n.add(F),t.meshs.push(F)}else z.geometry=A;const Z=new Float32Array([C[0].x,C[0].y,C[0].z,C[1].x,C[1].y,C[1].z,C[2].x,C[2].y,C[2].z,C[3].x,C[3].y,C[3].z,C[0].x,C[0].y,C[0].z]);let W=new T.LineBasicMaterial({color:255}),Q=new T.BufferGeometry;Q.setAttribute("position",new T.BufferAttribute(Z,3));let G=t.meshs.find(te=>te.name==O+"Line");G==null&&(G=new T.Line(Q,W),G.name=O+"Line",n.add(G),t.meshs.push(G)),G.geometry=Q,G.material=W,t.engine.sectionPlane.find(te=>te.name==O).setFromNormalAndCoplanarPoint(I.clone().setLength(t.direction),C[0])}}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.center=this.current_center.clone(),this.pickNormal.y==0){const n=new T.Plane;n.setFromNormalAndCoplanarPoint(new T.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new T.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new T.Plane;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new T.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.distance=i,this.updata_face(this.distance)}}}}class td{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){let t=e.catch.normal;this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class nd{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new T.Plane(new T.Vector3(0,0,1),1e5);t.name="前";let n=new T.Plane(new T.Vector3(0,0,1),1e5);n.name="左";let i=new T.Plane(new T.Vector3(0,0,1),1e5);i.name="后";let s=new T.Plane(new T.Vector3(0,0,1),1e5);s.name="右";let o=new T.Plane(new T.Vector3(0,0,1),1e5);o.name="顶";let a=new T.Plane(new T.Vector3(0,0,1),1e5);a.name="底";let l=new T.Plane(new T.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,o,a,l]}init(){this.sectionBox=new Qu(this.engine),this.sectionFace=new ed(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let o=this.engine.models.find(a=>a.url===s.url);s.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let n=i(t);this.sectionBox.setBox(n);function i(s){let o=new T.Vector3(1e8,1e9,1e10),a=new T.Vector3(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new T.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:n,minY:i,minZ:s,maxX:o,maxY:a,maxZ:l})}active(e){if(this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new td(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),s=n.position.clone().sub(i.min.clone().add(i.max.clone()).setLength(.5)),o=new T.Vector3(n.dir.x,n.dir.y,n.dir.z),a=s.dot(o);this.sectionFace.setFaceNormal(n.dir,a)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled()}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=""}}class id{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class sd{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof T.Mesh){const s=i.geometry;if(s&&s.attributes){const o=s.attributes.position;if(o){const a=o.count;e+=a;let l=0;s.index?l=s.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(i=>{n=n+i.info.modelEdge.length}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class rd{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(o=>o.url===e);i.properties==null&&Sr(e+"/property",o=>{let a=JSON.parse(o);i.properties=a,setTimeout(()=>{s(a,t,n)},100)}),s(i.properties,t,n);function s(o,a,l){let h=[],c=o.models[a.toString()||""],u=c.map(f=>f[0]);u=u.filter((f,p)=>u.indexOf(f)===p),u.forEach(f=>{let p={name:o.categorys[f],children:[]};h.push(p),c.filter(d=>d[0]===f).forEach(d=>{p.children.push({name:o.names[d[1]],value:o.values[d[2]]})})}),l?.({properties:h,materials:h})}}}class od{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(o=>o.url==e);return n?n.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let o={url:s.url,ids:[]};i.push(o),s.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}}class ad{engine;isActive=!1;groupEdge;material;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new T.LineBasicMaterial({color:"#000000",depthTest:!0})}active(){this.isActive=!0,this.groupEdge.visible=!0,this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1}show(){this.engine.engineStatus.models.forEach(e=>{if(!this.groupEdge.children.find(n=>n.url==e.url)){let n=e.info,i=[],s=new Map;n.modelEdge.forEach(l=>{let h=i.length;for(let c=0;c<l.points.length;c++)l.points[c].length==2&&(i.push(l.points[c][0].X),i.push(l.points[c][0].Z),i.push(-l.points[c][0].Y),i.push(l.points[c][1].X),i.push(l.points[c][1].Z),i.push(-l.points[c][1].Y));s.set(Number(l.id),[h,i.length,l.points])}),this.indexes.set(e.url,s);let o=new T.BufferGeometry;o.setAttribute("position",new T.Float32BufferAttribute(i,3));const a=new T.LineSegments(o,this.material);a.url=e.url,this.groupEdge.add(a)}})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,o,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array;for(let c=s;c<o;c++)h[c]=NaN;l.geometry.attributes.position.needsUpdate=!0}}}}showModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,o,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array,c=0;for(let u=s;u<o;u+=3){const f=Math.floor(c/6),p=c%6>=3;if(a[f]&&a[f].length===2){const d=p?a[f][1]:a[f][0];h[u]=d.X,h[u+1]=d.Z,h[u+2]=-d.Y}c+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class ld{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const o=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${o.error?.message||o.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
760
760
  1. 网络连接
761
761
  2. API地址是否正确
762
762
  3. 是否有CORS限制`):i}}async chatStream(e,t){const n=new AbortController,i=setTimeout(()=>n.abort(),this.config.timeout);try{const s=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!0}),signal:n.signal});if(clearTimeout(i),!s.ok){const h=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${h.error?.message||h.message||s.statusText}`)}const o=s.body?.getReader();if(!o)throw new Error("无法读取响应流");const a=new TextDecoder;let l="";for(;;){const{done:h,value:c}=await o.read();if(h){t("",!0);break}l+=a.decode(c,{stream:!0});const u=l.split(`
763
- `);l=u.pop()||"";for(const p of u){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const d=f.slice(6);if(d!=="[DONE]")try{const g=JSON.parse(d).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(m){console.warn("解析流式数据失败:",m)}}}}catch(s){throw clearTimeout(i),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error("网络请求失败,请检查网络连接"):s}}updateConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}}class ad{engine;steps=[];stepResults=new Map;conversationHistory=[];state="idle";llmApi=null;config=null;_callback_message;_callback_question;_callback_content;prompts={};constructor(e){this.engine=e}async init(e,t,n){this._callback_message=e,this._callback_question=t,this._callback_content=n,this.conversationHistory=[];let i={llmConfig:{baseURL:"https://open.bigmodel.cn/api/coding/paas/v4",apiKey:"4041336a72f14d8fa3800bd651a80fec.vZWUxssXOXB37vlV",model:"GLM-4.5-Air",temperature:.7,maxTokens:2e3},debug:!0,stepExecution:{maxRetries:5},prompts:{main:"",step:"",apiDoc:""}};try{this.config=i,this.llmApi=new od(i.llmConfig);try{const s=await Promise.resolve().then(()=>ud);this.prompts.main=s.default;const o=await Promise.resolve().then(()=>dd);this.prompts.step=o.default;const a=await Promise.resolve().then(()=>fd);this.prompts.apiDoc=a.default}catch(s){throw console.error("[AI Manager] 提示词文件加载失败:",s),new Error(`提示词文件加载失败: ${s.message||"未知错误"}`)}}catch(s){throw console.error("[AI Manager] 初始化失败:",s),s}}async conversationV2(e){if(this.conversationHistory.length===0){const i={role:"system",content:`${this.prompts.main}`},s={role:"system",content:`## BIM引擎API文档
763
+ `);l=u.pop()||"";for(const f of u){const p=f.trim();if(!p||!p.startsWith("data: "))continue;const d=p.slice(6);if(d!=="[DONE]")try{const g=JSON.parse(d).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(m){console.warn("解析流式数据失败:",m)}}}}catch(s){throw clearTimeout(i),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error("网络请求失败,请检查网络连接"):s}}updateConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}}class cd{engine;steps=[];stepResults=new Map;conversationHistory=[];state="idle";llmApi=null;config=null;_callback_message;_callback_question;_callback_content;prompts={};constructor(e){this.engine=e}async init(e,t,n){this._callback_message=e,this._callback_question=t,this._callback_content=n,this.conversationHistory=[];let i={llmConfig:{baseURL:"https://open.bigmodel.cn/api/coding/paas/v4",apiKey:"4041336a72f14d8fa3800bd651a80fec.vZWUxssXOXB37vlV",model:"GLM-4.5-Air",temperature:.7,maxTokens:2e3},debug:!0,stepExecution:{maxRetries:5},prompts:{main:"",step:"",apiDoc:""}};try{this.config=i,this.llmApi=new ld(i.llmConfig);try{const s=await Promise.resolve().then(()=>fd);this.prompts.main=s.default;const o=await Promise.resolve().then(()=>pd);this.prompts.step=o.default;const a=await Promise.resolve().then(()=>md);this.prompts.apiDoc=a.default}catch(s){throw console.error("[AI Manager] 提示词文件加载失败:",s),new Error(`提示词文件加载失败: ${s.message||"未知错误"}`)}}catch(s){throw console.error("[AI Manager] 初始化失败:",s),s}}async conversationV2(e){if(this.conversationHistory.length===0){const i={role:"system",content:`${this.prompts.main}`},s={role:"system",content:`## BIM引擎API文档
764
764
  ${this.prompts.apiDoc}`};this.conversationHistory.push(i),this.conversationHistory.push(s)}this.conversationHistory.push({role:"user",content:e});const t=await this.llmApi.chat(this.conversationHistory);this.conversationHistory.push({role:"assistant",content:t}),this.config?.debug&&console.log("[AI Manager] 大模型响应:",t);let n=await this.parseAnalysisResponse(t);n&&n.questions&&n.questions.length>0&&this._callback_question(n.questions)}async parseAnalysisResponse(e){try{if(e.includes("##question##")){const t=e.match(/##question##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);i&&(n=i[1]);const s=JSON.parse(n);return this.state="waiting_answer",{state:"waiting_answer",questions:s}}}if(e.includes("##steps##")){const t=e.match(/##steps##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);return i&&(n=i[1]),this.steps=JSON.parse(n),this.config?.debug&&console.log("[AI Manager] 步骤规划完成,共",this.steps.length,"个步骤"),this._callback_message(this.steps),await this.executeSteps()}}return{state:"completed",data:e}}catch(t){return console.error("[AI Manager] 解析响应失败:",t),{state:"error",error:"解析大模型响应失败: "+t.message}}}async executeSteps(){try{this.state="executing",this.stepResults.clear();for(const e of this.steps){this._callback_message(e),this.config?.debug&&console.log(`[AI Manager] 执行步骤 ${e.id}: ${e.content}`);const t=await this.getDependenciesOutput(e.dependencies),n=await this.executeStep(e,t);this.stepResults.set(e.id,n),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 执行完成:`,n)}return this.state="completed",{state:"completed",steps:this.steps,result:Array.from(this.stepResults.values())}}catch(e){return console.error("[AI Manager] 步骤执行失败:",e),{state:"error",error:"步骤执行失败: "+e.message}}}async getDependenciesOutput(e){return e.length===0?null:e.length===1?this.stepResults.get(e[0]):e.map(t=>this.stepResults.get(t))}async executeStep(e,t){const n=this.config?.stepExecution?.maxRetries??1,i=[];let s=null,o=!1;for(let a=0;a<=n;a++)try{const l=i.length>0?i[i.length-1]:"",c=await(a===0?this.generateCode(e,t):o?this.regenerateCodeAfterFailure(e,t,l,s,a):this.generateCode(e,t));i.push(c),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 第 ${a+1} 次生成的代码:
765
765
  ${c}`);try{const u=await this.executeCode(c,t);if(u instanceof Object&&u.success==!1||u instanceof String&&(u.includes("undefined")||u.includes("not"))){s=u,o=!0;debugger;throw u}debugger;return u}catch(u){debugger;throw s=u,o=!0,u}}catch(l){if(o||(s=l),a>=n)throw console.error(`[AI Manager] 执行步骤 ${e.id} 失败(已达重试上限):`,l),new Error(`步骤 ${e.id} (${e.content}) 执行失败: ${l.message}`);console.warn(`[AI Manager] 步骤 ${e.id} 第 ${a+1} 次执行失败,将尝试让AI修复后重试(剩余重试次数:${n-a}):`,l)}throw new Error(`步骤 ${e.id} (${e.content}) 执行失败: 未知错误`)}extractCodeFromResponse(e){const t=e.match(/##code##\s*([\s\S]*?)(?=##|$)/);if(t){let o=t[1].trim();if(o=o.replace(/^```javascript\n?/,"").replace(/^```js\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,""),o.length>0)return o}const n=[/```javascript\s*([\s\S]*?)```/i,/```js\s*([\s\S]*?)```/i,/```\s*([\s\S]*?)```/];for(const o of n){const a=e.match(o);if(a&&a[1]){const l=a[1].trim();if(l.length>0)return this.config?.debug&&console.warn("[AI Manager] 未找到 ##code## 标记,从 markdown 代码块中提取代码"),l}}const i=/[请|说明|注意|需要|应该|可以|如果|但是|因为|所以|例如|比如]/i.test(e),s=/(function|const|let|var|return|async|await|=>|engine\.|previousStepOutput)/.test(e);if(!i&&s){const a=e.trim().replace(/^[,。:;!?\s]+/,"").replace(/[,。:;!?\s]+$/,"");if(a.length>10)return this.config?.debug&&console.warn("[AI Manager] 未找到 ##code## 标记和代码块,尝试使用整个响应作为代码"),a}throw new Error(`无法从大模型响应中提取代码。响应内容:${e.substring(0,200)}...`)}async generateCode(e,t){try{const n={role:"system",content:`${this.prompts.step}`},i={role:"system",content:`
766
766
 
@@ -803,423 +803,423 @@ ${JSON.stringify(l,null,2)}
803
803
  4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},c=await this.llmApi.chat([o,a,h]);try{return this.extractCodeFromResponse(c)}catch(u){throw new Error(`无法从大模型响应中提取代码(修复重试阶段):${u.message}`)}}catch(o){throw console.error("[AI Manager] 修复后代码生成失败:",o),o}}async executeCode(e,t){try{const n=this.engine;let i=e;i=i.replace(/\b(const|let|var)\s+previousStepOutput\s*=\s*[^;]*;/g,""),i=i.replace(/\b(const|let|var)\s+previousStepOutput\s*;/g,"");const o=new Function("engine","previousStepOutput",`
804
804
  'use strict';
805
805
  ${i}
806
- `)(n,t);return o&&typeof o.then=="function"?await o:o}catch(n){return console.error("[AI Manager] 代码执行失败:",n),"error"+n.message}}reset(){this.conversationHistory=[],this.steps=[],this.stepResults.clear(),this.state="idle",this.config?.debug&&console.log("[AI Manager] 对话已重置")}getState(){return this.state}getHistory(){return[...this.conversationHistory]}getSteps(){return[...this.steps]}getStepResults(){return new Map(this.stepResults)}}class ld{engine;points=[];isPlaying=!1;animationFrameId=null;playStartTime=0;playFromIndex=0;playToIndex=0;playOptions={};stayTimerId=null;playRangeToIndex=0;constructor(e){this.engine=e}init(){this.points=[],this.stop()}getCurrentPoint(){return{...this.engine.cameraModule.getCameraPose(),stayTime:0}}addPoint(e=0){const t=this.getCurrentPoint();return t.stayTime=e,this.points.push(t),this.points.length}addPoints(e){for(const t of e)this.points.push({...t});return this.points.length}savePoints(e){return this.addPoints(e)}removePoint(e){return e>=0&&e<this.points.length?(this.points.splice(e,1),!0):!1}clearPoints(){this.stop(),this.points=[]}getPoints(){return[...this.points]}getPointCount(){return this.points.length}updatePoint(e,t){return e>=0&&e<this.points.length?(this.points[e]={...t},!0):!1}jumpToPoint(e){return e>=0&&e<this.points.length?(this.stop(),this.engine.cameraModule.restoreCameraPose(this.points[e]),!0):!1}play(e={}){return this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...e},this.engine.controlModule.disActive(),this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate(),!0)}playRange(e,t,n={}){return e<0||t>=this.points.length||e>=t?(console.warn("PathRoaming: 无效的索引范围"),!1):this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...n},this.engine.controlModule.disActive(),this.playFromIndex=e,this.playToIndex=e+1,this.playStartTime=performance.now(),this.playRangeToIndex=t,this.animate(),!0)}stop(){this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null),this.engine.controlModule.active()}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null))}getIsPlaying(){return this.isPlaying}animate=()=>{if(!this.isPlaying)return;const t=performance.now()-this.playStartTime,n=this.playOptions.duration||3e3,i=Math.min(t/n,1),s=this.points[this.playFromIndex],o=this.points[this.playToIndex],a=this.interpolatePose(s,o,i);this.engine.cameraModule.restoreCameraPose(a),i>=1?this.onSegmentComplete():this.animationFrameId=requestAnimationFrame(this.animate)};onSegmentComplete(){const e=this.playToIndex;this.playOptions.onPointComplete&&this.playOptions.onPointComplete(e);const t=this.points[e];t.stayTime&&t.stayTime>0?this.stayTimerId=globalThis.setTimeout(()=>{this.stayTimerId=null,this.moveToNextSegment()},t.stayTime):this.moveToNextSegment()}moveToNextSegment(){const e=this.playToIndex>=this.playRangeToIndex,t=this.playToIndex>=this.points.length-1;e||t?this.playOptions.loop&&this.points.length>=2?(this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate()):this.onPlayComplete():(this.playFromIndex=this.playToIndex,this.playToIndex=this.playToIndex+1,this.playStartTime=performance.now(),this.animate())}onPlayComplete(){this.stop(),this.playOptions.onComplete&&this.playOptions.onComplete()}interpolatePose(e,t,n){const i=this.easeInOutCubic(n),s={type:t.type,position:{x:T.MathUtils.lerp(e.position.x,t.position.x,i),y:T.MathUtils.lerp(e.position.y,t.position.y,i),z:T.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:T.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:T.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:T.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:T.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:T.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:T.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:T.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:T.MathUtils.lerp(e.target.x,t.target.x,i),y:T.MathUtils.lerp(e.target.y,t.target.y,i),z:T.MathUtils.lerp(e.target.z,t.target.z,i)}:t.target&&(s.target={...t.target}),e.zoom!==void 0&&t.zoom!==void 0&&(s.zoom=T.MathUtils.lerp(e.zoom,t.zoom,i)),s}easeInOutCubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}dispose(){this.stop(),this.points=[],this.playOptions={}}}class cd{options;DeviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;models=[];reactBoundingClientRect={left:0,top:0};container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.ai=new ad(this),this.deviceModule=new No(this),this.DeviceType=this.deviceModule.getDeviceType(),this.cameraModule=new zo(this),this.sceneModule=new Oo(this),this.scene=this.sceneModule.scene,this.renderModule=new Ro(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new Qo(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new fa(this),this.composerModule.init(),this.events=new Bc,this.engineStatus=new Ic(this),this.engineStatus.init(),this.loaderModule=new kc(this),this.lightModule=new Ec(this),this.lightModule.init(),this.viewCube=new Zc(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Yc(this),this.rangeScale=new $c(this),this.rangeScale.init(),this.clipping=new ed(this),this.clipping.init(),this.setting=new Jc(this),this.setting.init(),this.handelBehaved=bi(this),this.modelMapperBatch=new sd(this),this.measure=new oh(this),this.modelToolModule=new Oc(this),this.modelProperties=new id(this),this.interactionModule=new Lc(this),this.interactionModule.init(),this.interactionModule.active(),this.modelEdge=new rd(this),this.modelTree=new td(this),this.engineInfo=new nd(this),this.pathRoaming=new ld(this),this.pathRoaming.init(),this.worldToScreen=new Ve(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new jc,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.zIndex="1000",t.style.left="0px",t.style.top="0px",t.style.pointerEvents="none";const n=this.renderer?.domElement.width||1920,i=this.renderer?.domElement.height||1080;t.setAttribute("viewBox",`0 0 ${n} ${i}`),t.setAttribute("preserveAspectRatio","none"),this.container.appendChild(t),this.catchSvg=t,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}if(this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.controlModule.update(),this.stats&&this.stats.end(),this.scene){let s=this.scene?.dirLight;s&&this.camera&&this.updateLightPosition(this.camera,s)}},this.animate()}updateLightPosition(e,t){const n=new T.Vector3;e.getWorldDirection(n);const i=new T.Vector3().copy(n).multiplyScalar(-100);t.position.copy(e.position).add(i);const s=new T.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(s),t.target.updateMatrixWorld()}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,o=this.container.clientWidth/this.container.clientHeight;i.left=s*o/-2,i.right=s*o/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.renderer.domElement.width,s=this.renderer.domElement.height;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(jt.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof T.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof T.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof T.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof T.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof T.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof T.Texture&&i.dispose()}),e.dispose()}}function hd(r){return new cd(r)}const ud=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家
807
-
808
- ## 角色定位
809
-
810
- 你是一位资深的**AI+BIM轻量化引擎架构专家**,具备以下核心能力:
811
-
812
- 1. **深度理解BIM引擎架构**:精通BIM引擎的模块化设计、API体系、数据结构和交互模式
813
- 2. **需求分析能力**:能够准确理解用户意图,识别模糊需求,提出精准的澄清问题
814
- 3. **任务分解能力**:将复杂需求拆解为可执行的、原子化的操作步骤
815
- 4. **技术决策能力**:根据需求特点选择最优的API组合和实现路径
816
-
817
- 你的职责是通过分析用户需求,生成结构化的执行步骤,指导代码生成模块完成BIM引擎的功能实现。
818
-
819
- ## 工作流程
820
-
821
- 如果存在疑问,你就不能输出最终的步骤,只有当你把所有的疑问清楚后,你才可以输出步骤,如果存在疑问,你要以bim模型为载体,不能问一下和bim模型不想干的问题,尽量没有或减少问题
822
-
823
- ### 阶段一:需求理解与分析
824
-
825
- 当接收到用户需求时,你需要:
826
-
827
- 1. **深度分析需求**:
828
- - 理解用户的核心目标
829
- - 识别涉及到的BIM引擎模块(场景、相机、模型、测量、剖切等)
830
- - 分析数据流向和依赖关系
831
- - 评估需求的复杂度和可行性
832
-
833
- 2. **识别模糊点**:
834
- - 检查需求中是否存在歧义、缺失信息或边界条件不明确的情况
835
- - 判断是否需要用户澄清才能继续
836
-
837
- 3. **决策是否需要提问**:
838
- - **仅在必要时提问**:如果需求足够清晰,直接进入步骤规划阶段
839
- - **避免过度提问**:不要为了提问而提问,不要询问可以从上下文推断的信息
840
- - **精准提问**:每个问题都应该针对关键决策点,影响后续实现路径
841
-
842
- ### 阶段二:需求澄清(如需要)
843
-
844
- 如果需要用户澄清,请按照以下格式输出:
845
-
846
- **输出格式**:
847
- \`\`\`
848
- ##question##
849
- json内容
850
- \`\`\`
851
-
852
- **JSON格式规范**:
853
- \`\`\`json
854
- [
855
- {
856
- "id": 0,
857
- "question": "您是否需要设置所有的构件?",
858
- "answers": [
859
- "A. 是的,设置所有构件",
860
- "B. 只设置1F层的构件",
861
- "C. 根据特定条件筛选构件"
862
- ]
863
- },
864
- {
865
- "id": 1,
866
- "question": "颜色设置的优先级是什么?",
867
- "answers": [
868
- "A. 按构件类型设置",
869
- "B. 按楼层设置",
870
- "C. 按自定义属性设置"
871
- ]
872
- }
873
- ]
874
- \`\`\`
875
-
876
- **提问原则**:
877
- - 每个问题必须针对一个明确的决策点
878
- - 答案选项应该互斥且覆盖主要场景
879
- - 问题数量控制在3个以内,优先询问最关键的问题
880
- - 问题描述清晰、具体,避免模糊表述
881
- - 不要强行提问,尽量减少或不提问题
882
- ### 阶段三:步骤规划
883
-
884
- 当需求清晰后,你需要将用户意图拆解为一系列可执行的步骤。
885
-
886
- **输出格式**:
887
- \`\`\`
888
- ##steps##
889
- json内容
890
-
891
- \`\`\`
892
-
893
- **JSON格式规范**:
894
- \`\`\`json
895
- [
896
- {
897
- "id": 0,
898
- "content": "获取所有桩基模型",
899
- "description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件,返回构件ID数组和构件对象数组",
900
- "output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\", ...], \\"models\\": [modelObject1, modelObject2, ...]}",
901
- "dependencies": [],
902
- "apiModules": ["modelTree", "dataModule"]
903
- },
904
- {
905
- "id": 1,
906
- "content": "设置桩基模型颜色为红色",
907
- "description": "使用modelMapperBatch模块的批量设置方法,将上一步获取的所有桩基模型的颜色属性设置为红色(RGB: 255, 0, 0)",
908
- "output": "{\\"success\\": true, \\"count\\": 10, \\"failedIds\\": []}",
909
- "dependencies": [0],
910
- "apiModules": ["modelMapperBatch"]
911
- }
912
- ]
913
- \`\`\`
914
-
915
- **字段说明**:
916
- - \`id\`: 步骤唯一标识符,从0开始递增
917
- - \`content\`: 步骤的简短描述(一句话概括)
918
- - \`description\`: 步骤的详细功能说明,包括:
919
- - 具体要做什么
920
- - 使用哪些API模块
921
- - 如何处理数据
922
- - 可能的边界情况
923
- - \`output\`: 步骤输出的数据格式说明(JSON Schema格式),用于:
924
- - 指导代码生成模块返回正确的数据结构
925
- - 确保步骤间的数据传递正确
926
- - \`dependencies\`: 依赖的步骤ID数组,表示此步骤需要等待哪些步骤完成
927
- - \`apiModules\`: 此步骤涉及到的BIM引擎模块名称数组(如:modelTree, cameraModule, measure等)
928
-
929
- **步骤规划原则**:
930
- 1. **原子化**:每个步骤应该只完成一个明确的功能点
931
- 2. **可执行**:每个步骤都应该能够独立生成可执行的代码
932
- 3. **依赖清晰**:明确标注步骤间的依赖关系,确保执行顺序正确
933
- 4. **数据流转**:每个步骤的输出格式要明确,便于后续步骤使用
934
- 5. **模块化**:合理利用BIM引擎的模块化设计,选择最合适的API
935
- 6. **错误处理**:在关键步骤中考虑异常情况的处理
936
-
937
- ## 硬性要求
938
-
939
- ### 1. 输出格式规范
940
- - **必须严格遵循**上述JSON格式,字段名称和类型不能改变
941
- - JSON必须是有效的、可解析的格式
942
- - 步骤ID必须连续且从0开始
943
- - 依赖关系必须正确,不能出现循环依赖
944
-
945
- ### 2. 需求理解要求
946
- - **深度理解**:不能停留在表面理解,要理解用户的真实意图和业务场景
947
- - **上下文感知**:结合BIM引擎的特性,理解每个需求在BIM场景下的实际意义
948
- - **技术可行性**:确保规划的步骤在BIM引擎API能力范围内
949
-
950
- ### 3. 步骤质量要求
951
- - **完整性**:步骤应该覆盖用户需求的所有方面,不能遗漏关键环节
952
- - **准确性**:步骤描述要准确,不能有歧义或错误
953
- - **可执行性**:每个步骤都应该能够生成可执行的代码
954
- - **效率性**:优先选择高效的API组合,避免不必要的中间步骤
955
-
956
- ### 4. 错误预防
957
- - 检查步骤间的数据格式是否匹配
958
- - 确保依赖关系正确,避免执行顺序错误
959
- - 验证API模块名称是否正确
960
- - 考虑边界情况和异常处理
961
-
962
- ### 5. 代码生成友好
963
- - 步骤描述要足够详细,让代码生成模块能够准确理解意图
964
- - 输出格式说明要具体,使用JSON Schema或示例数据
965
- - 明确标注使用的API模块,便于代码生成时快速定位
966
-
967
- ## 最佳实践
968
-
969
- 1. **先理解后规划**:充分理解需求后再开始规划步骤,避免返工
970
- 2. **模块优先**:优先使用BIM引擎提供的功能模块,而不是底层API
971
- 3. **数据驱动**:明确每个步骤的输入输出,确保数据流清晰
972
- 4. **可扩展性**:考虑未来可能的扩展需求,设计灵活的步骤结构
973
- 5. **用户友好**:步骤描述要清晰易懂,便于用户理解整个执行流程
974
-
975
-
976
- ''`},Symbol.toStringTag,{value:"Module"})),dd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家
977
-
978
- ## 角色定位
979
-
980
- 你是一位资深的**BIM引擎代码生成专家**,具备以下核心能力:
981
-
982
- 1. **BIM引擎API精通**:深度掌握BIM引擎的所有模块API、方法签名、参数类型和返回值
983
- 2. **代码生成能力**:能够根据步骤描述,生成高质量、可执行、符合规范的JavaScript代码
984
- 3. **上下文理解**:能够理解步骤间的数据流转,正确处理前序步骤的输出结果
985
- 4. **错误处理能力**:具备完善的异常处理和边界情况处理能力
986
- 5. **代码质量意识**:生成的代码应该具备良好的可读性、可维护性和性能
987
-
988
- 你的职责是根据步骤规划模块提供的步骤描述,生成可直接在BIM引擎环境中执行的JavaScript代码片段。
989
-
990
- ## 工作流程
991
-
992
- ### 阶段一:理解步骤要求
993
-
994
- 当接收到步骤执行请求时,你需要:
995
-
996
- 1. **解析步骤信息**:
997
- - 理解步骤的\`content\`(简短描述)和\`description\`(详细说明)
998
- - 识别步骤涉及到的BIM引擎模块(\`apiModules\`字段)
999
- - 理解步骤的依赖关系(\`dependencies\`字段)
1000
- - 明确步骤的预期输出格式(\`output\`字段)
1001
-
1002
- 2. **分析上下文数据**:
1003
- - 如果有前序步骤的输出结果,分析其数据结构
1004
- - 理解当前步骤需要使用的输入数据
1005
- - 验证数据格式是否匹配步骤要求
1006
-
1007
- 3. **确定实现方案**:
1008
- - 根据步骤描述,选择最合适的BIM引擎API
1009
- - 设计数据转换和处理逻辑
1010
- - 规划错误处理策略
1011
-
1012
- ### 阶段二:生成代码
1013
-
1014
- 根据步骤要求生成可执行的JavaScript代码。
1015
-
1016
- **输出格式**:
1017
- \`\`\`
1018
- ##code##
1019
- [可执行的JavaScript代码]
1020
- \`\`\`
1021
-
1022
- **代码生成规范**:
1023
-
1024
- 1. **代码结构**:
1025
- - 代码必须是一个完整的、可执行的JavaScript代码片段
1026
- - 可以是函数、立即执行函数(IIFE)或代码块
1027
- - 代码应该能够直接运行,不需要额外的包装
1028
-
1029
- 2. **引擎实例访问**:
1030
- - 假设BIM引擎实例通过变量\`engine\`访问(全局作用域)
1031
- - 通过\`engine.moduleName\`访问各个功能模块
1032
- - 例如:\`engine.modelTree\`、\`engine.cameraModule\`、\`engine.measure\`等
1033
-
1034
- 3. **数据输入处理**:
1035
- - 如果步骤有依赖,使用前序步骤的输出数据
1036
- - 假设前序步骤的输出数据存储在变量\`previousStepOutput\`中(如果是第一步,则为\`null\`)
1037
- - 需要根据\`output\`字段的格式说明,正确解析和使用输入数据
1038
-
1039
- 4. **API调用规范**:
1040
- - 严格按照BIM引擎API文档使用API
1041
- - 参数类型和数量必须正确
1042
- - 处理API的返回值和可能的异常
1043
-
1044
- 5. **数据输出规范**:
1045
- - 代码执行后,必须返回符合步骤\`output\`字段要求的数据格式
1046
- - 使用\`return\`语句返回结果
1047
- - 返回的数据必须是可序列化的(JSON格式)
1048
-
1049
- 6. **错误处理**:
1050
- - 必须包含完善的错误处理逻辑
1051
- - 使用try-catch捕获可能的异常
1052
- - 对于关键操作,添加参数验证
1053
- - 错误信息要清晰,便于调试
1054
-
1055
- 7. **代码质量要求**:
1056
- - 代码要有清晰的注释,说明关键逻辑
1057
- - 变量命名要有意义,符合JavaScript命名规范
1058
- - 避免使用过于复杂的嵌套结构
1059
- - 优先使用可读性高的写法,而不是过于"高级"的技巧
1060
-
1061
- ## 硬性要求
1062
-
1063
- ### 1. 代码格式要求
1064
- - **单一代码块**:输出必须且只能包含一个JavaScript代码片段
1065
- - **可执行性**:代码必须能够直接执行,不需要额外的依赖或配置
1066
- - **完整性**:代码必须完整,不能有语法错误或未定义的变量
1067
-
1068
- ### 2. 数据格式要求
1069
- - **输入解析**:正确解析和使用前序步骤的输出数据
1070
- - **输出格式**:严格按照步骤\`output\`字段的格式要求返回数据
1071
- - **类型安全**:确保数据类型正确,必要时进行类型转换
1072
-
1073
- ### 3. API使用要求
1074
- - **准确性**:API调用必须准确,参数必须正确
1075
- - **模块识别**:正确识别和使用BIM引擎的各个模块
1076
- - **方法调用**:使用正确的方法名和参数签名
1077
-
1078
- ### 4. 错误处理要求
1079
- - **异常捕获**:所有可能抛出异常的操作都要有try-catch保护
1080
- - **参数验证**:对关键参数进行验证,避免无效输入
1081
- - **错误信息**:错误信息要清晰,包含足够的上下文信息
1082
- - **优雅降级**:在可能的情况下,提供降级方案
1083
-
1084
- ### 5. 代码质量要求
1085
- - **可读性**:代码结构清晰,逻辑易懂
1086
- - **注释完整**:关键逻辑要有注释说明
1087
- - **命名规范**:变量和函数命名要有意义
1088
- - **性能考虑**:避免不必要的循环和计算
1089
-
1090
- ## 代码生成示例
1091
-
1092
- ### 示例1:获取模型数据
1093
-
1094
- **步骤描述**:
1095
- \`\`\`json
1096
- {
1097
- "id": 0,
1098
- "content": "获取所有桩基模型",
1099
- "description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件",
1100
- "output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\"], \\"models\\": [modelObject1, modelObject2]}",
1101
- "dependencies": [],
1102
- "apiModules": ["modelTree"]
1103
- }
1104
- \`\`\`
1105
-
1106
- **生成代码**:
1107
- \`\`\`javascript
1108
- // 获取所有桩基模型
1109
- try {
1110
- // 获取模型树模块
1111
- const modelTree = engine.modelTree;
1112
- if (!modelTree) {
1113
- throw new Error('模型树模块未初始化');
1114
- }
1115
-
1116
- // 获取所有模型
1117
- const allModels = modelTree.getAllModels();
1118
- if (!allModels || allModels.length === 0) {
1119
- return {
1120
- modelIds: [],
1121
- models: []
1122
- };
1123
- }
1124
-
1125
- // 筛选桩基模型
1126
- const pileModels = [];
1127
- const pileModelIds = [];
1128
-
1129
- for (let i = 0; i < allModels.length; i++) {
1130
- const model = allModels[i];
1131
- // 根据模型属性判断是否为桩基
1132
- const modelType = model.getProperty('类型') || model.getProperty('category');
1133
- if (modelType && (modelType.includes('桩基') || modelType.includes('Pile'))) {
1134
- pileModels.push(model);
1135
- pileModelIds.push(model.id || model.uuid);
1136
- }
1137
- }
1138
-
1139
- // 返回结果
1140
- return {
1141
- modelIds: pileModelIds,
1142
- models: pileModels
1143
- };
1144
- } catch (error) {
1145
- console.error('获取桩基模型失败:', error);
1146
- return {
1147
- modelIds: [],
1148
- models: [],
1149
- error: error.message
1150
- };
1151
- }
1152
- \`\`\`
1153
-
1154
- ### 示例2:使用前序步骤的输出
1155
-
1156
- **步骤描述**:
1157
- \`\`\`json
1158
- {
1159
- "id": 1,
1160
- "content": "设置桩基模型颜色为红色",
1161
- "description": "使用modelMapperBatch模块批量设置上一步获取的桩基模型颜色",
1162
- "output": "{\\"success\\": true, \\"count\\": 10}",
1163
- "dependencies": [0],
1164
- "apiModules": ["modelMapperBatch"]
1165
- }
1166
- \`\`\`
1167
-
1168
- **生成代码**:
1169
- \`\`\`javascript
1170
- // 设置桩基模型颜色为红色
1171
- try {
1172
- // 获取前序步骤的输出数据
1173
- if (!previousStepOutput || !previousStepOutput.modelIds) {
1174
- throw new Error('前序步骤输出数据无效,缺少modelIds字段');
1175
- }
1176
-
1177
- const modelIds = previousStepOutput.modelIds;
1178
- if (modelIds.length === 0) {
1179
- return {
1180
- success: true,
1181
- count: 0,
1182
- message: '没有需要设置的模型'
1183
- };
1184
- }
1185
-
1186
- // 获取批量映射模块
1187
- const modelMapperBatch = engine.modelMapperBatch;
1188
- if (!modelMapperBatch) {
1189
- throw new Error('批量映射模块未初始化');
1190
- }
1191
-
1192
- // 设置颜色为红色 (RGB: 255, 0, 0)
1193
- const redColor = { r: 255, g: 0, b: 0 };
1194
-
1195
- // 批量设置模型颜色
1196
- const result = modelMapperBatch.setModelColor(modelIds, redColor);
1197
-
1198
- return {
1199
- success: result.success !== false,
1200
- count: result.count || modelIds.length,
1201
- failedIds: result.failedIds || []
1202
- };
1203
- } catch (error) {
1204
- console.error('设置模型颜色失败:', error);
1205
- return {
1206
- success: false,
1207
- count: 0,
1208
- error: error.message
1209
- };
1210
- }
1211
- \`\`\`
1212
-
1213
- ## 最佳实践
1214
-
1215
- 1. **充分理解步骤**:仔细阅读步骤描述,确保理解每个细节
1216
- 2. **查阅API文档**:不确定的API用法,参考BIM引擎API文档
1217
- 3. **数据验证优先**:在处理数据前,先验证数据的有效性
1218
- 4. **错误处理完善**:考虑各种可能的异常情况
1219
- 5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"写法
1220
- 6. **注释清晰**:关键逻辑要有注释,但不要过度注释
1221
- 7. **性能考虑**:对于大量数据的处理,考虑性能优化
1222
- 8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),fd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
806
+ `)(n,t);return o&&typeof o.then=="function"?await o:o}catch(n){return console.error("[AI Manager] 代码执行失败:",n),"error"+n.message}}reset(){this.conversationHistory=[],this.steps=[],this.stepResults.clear(),this.state="idle",this.config?.debug&&console.log("[AI Manager] 对话已重置")}getState(){return this.state}getHistory(){return[...this.conversationHistory]}getSteps(){return[...this.steps]}getStepResults(){return new Map(this.stepResults)}}class hd{engine;points=[];isPlaying=!1;animationFrameId=null;playStartTime=0;playFromIndex=0;playToIndex=0;playOptions={};stayTimerId=null;playRangeToIndex=0;constructor(e){this.engine=e}init(){this.points=[],this.stop()}getCurrentPoint(){return{...this.engine.cameraModule.getCameraPose(),stayTime:0}}addPoint(e=0){const t=this.getCurrentPoint();return t.stayTime=e,this.points.push(t),this.points.length}addPoints(e){for(const t of e)this.points.push({...t});return this.points.length}savePoints(e){return this.addPoints(e)}removePoint(e){return e>=0&&e<this.points.length?(this.points.splice(e,1),!0):!1}clearPoints(){this.stop(),this.points=[]}getPoints(){return[...this.points]}getPointCount(){return this.points.length}updatePoint(e,t){return e>=0&&e<this.points.length?(this.points[e]={...t},!0):!1}jumpToPoint(e){return e>=0&&e<this.points.length?(this.stop(),this.engine.cameraModule.restoreCameraPose(this.points[e]),!0):!1}play(e={}){return this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...e},this.engine.controlModule.disActive(),this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate(),!0)}playRange(e,t,n={}){return e<0||t>=this.points.length||e>=t?(console.warn("PathRoaming: 无效的索引范围"),!1):this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...n},this.engine.controlModule.disActive(),this.playFromIndex=e,this.playToIndex=e+1,this.playStartTime=performance.now(),this.playRangeToIndex=t,this.animate(),!0)}stop(){this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null),this.engine.controlModule.active()}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null))}getIsPlaying(){return this.isPlaying}animate=()=>{if(!this.isPlaying)return;const t=performance.now()-this.playStartTime,n=this.playOptions.duration||3e3,i=Math.min(t/n,1),s=this.points[this.playFromIndex],o=this.points[this.playToIndex],a=this.interpolatePose(s,o,i);this.engine.cameraModule.restoreCameraPose(a),i>=1?this.onSegmentComplete():this.animationFrameId=requestAnimationFrame(this.animate)};onSegmentComplete(){const e=this.playToIndex;this.playOptions.onPointComplete&&this.playOptions.onPointComplete(e);const t=this.points[e];t.stayTime&&t.stayTime>0?this.stayTimerId=globalThis.setTimeout(()=>{this.stayTimerId=null,this.moveToNextSegment()},t.stayTime):this.moveToNextSegment()}moveToNextSegment(){const e=this.playToIndex>=this.playRangeToIndex,t=this.playToIndex>=this.points.length-1;e||t?this.playOptions.loop&&this.points.length>=2?(this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate()):this.onPlayComplete():(this.playFromIndex=this.playToIndex,this.playToIndex=this.playToIndex+1,this.playStartTime=performance.now(),this.animate())}onPlayComplete(){this.stop(),this.playOptions.onComplete&&this.playOptions.onComplete()}interpolatePose(e,t,n){const i=this.easeInOutCubic(n),s={type:t.type,position:{x:T.MathUtils.lerp(e.position.x,t.position.x,i),y:T.MathUtils.lerp(e.position.y,t.position.y,i),z:T.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:T.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:T.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:T.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:T.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:T.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:T.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:T.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:T.MathUtils.lerp(e.target.x,t.target.x,i),y:T.MathUtils.lerp(e.target.y,t.target.y,i),z:T.MathUtils.lerp(e.target.z,t.target.z,i)}:t.target&&(s.target={...t.target}),e.zoom!==void 0&&t.zoom!==void 0&&(s.zoom=T.MathUtils.lerp(e.zoom,t.zoom,i)),s}easeInOutCubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}dispose(){this.stop(),this.points=[],this.playOptions={}}}class ud{options;DeviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;models=[];reactBoundingClientRect={left:0,top:0};version="2.0.0";container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.engineModelModule=new Uc(this),this.engineModelModule.init(),this.ai=new cd(this),this.deviceModule=new Ro(this),this.DeviceType=this.deviceModule.getDeviceType(),this.cameraModule=new No(this),this.sceneModule=new zo(this),this.scene=this.sceneModule.scene,this.renderModule=new Fo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ea(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new pa(this),this.composerModule.init(),this.events=new Bc,this.engineStatus=new Ec(this),this.engineStatus.init(),this.loaderModule=new Ic(this),this.lightModule=new Lc(this),this.lightModule.init(),this.viewCube=new $c(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Jc(this),this.rangeScale=new Hc(this),this.rangeScale.init(),this.clipping=new nd(this),this.clipping.init(),this.setting=new Qc(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=xi(this),this.modelMapperBatch=new od(this),this.measure=new lh(this),this.modelToolModule=new zc(this),this.modelProperties=new rd(this),this.interactionModule=new Oc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Vn(this),this.modelEdge=new ad(this),this.modelTree=new id(this),this.engineInfo=new sd(this),this.pathRoaming=new hd(this),this.pathRoaming.init(),this.worldToScreen=new Ve(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Wc,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",t.innerHTML=`v${this.version}`,this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none";const i=this.renderer?.domElement.width||1920,s=this.renderer?.domElement.height||1080;n.setAttribute("viewBox",`0 0 ${i} ${s}`),n.setAttribute("preserveAspectRatio","none"),this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let o=this;this.controls.addEventListener("start",()=>{o.events.trigger(ht.EngineBusy)}),this.controls.addEventListener("end",()=>{o.events.trigger(ht.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}if(this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.hoverHighLight.update(),this.controlModule.update(),this.stats&&this.stats.end(),this.scene){let a=this.scene?.dirLight;a&&this.camera&&this.updateLightPosition(this.camera,a)}},this.animate()}updateLightPosition(e,t){const n=new T.Vector3;e.getWorldDirection(n);const i=new T.Vector3().copy(n).multiplyScalar(-100);t.position.copy(e.position).add(i);const s=new T.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(s),t.target.updateMatrixWorld()}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,o=this.container.clientWidth/this.container.clientHeight;i.left=s*o/-2,i.right=s*o/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.renderer.domElement.width,s=this.renderer.domElement.height;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ht.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof T.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof T.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof T.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof T.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof T.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof T.Texture&&i.dispose()}),e.dispose()}}function dd(r){return new ud(r)}const fd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
807
+ \r
808
+ ## 角色定位\r
809
+ \r
810
+ 你是一位资深的**AI+BIM轻量化引擎架构专家**,具备以下核心能力:\r
811
+ \r
812
+ 1. **深度理解BIM引擎架构**:精通BIM引擎的模块化设计、API体系、数据结构和交互模式\r
813
+ 2. **需求分析能力**:能够准确理解用户意图,识别模糊需求,提出精准的澄清问题\r
814
+ 3. **任务分解能力**:将复杂需求拆解为可执行的、原子化的操作步骤\r
815
+ 4. **技术决策能力**:根据需求特点选择最优的API组合和实现路径\r
816
+ \r
817
+ 你的职责是通过分析用户需求,生成结构化的执行步骤,指导代码生成模块完成BIM引擎的功能实现。\r
818
+ \r
819
+ ## 工作流程\r
820
+ \r
821
+ 如果存在疑问,你就不能输出最终的步骤,只有当你把所有的疑问清楚后,你才可以输出步骤,如果存在疑问,你要以bim模型为载体,不能问一下和bim模型不想干的问题,尽量没有或减少问题\r
822
+ \r
823
+ ### 阶段一:需求理解与分析\r
824
+ \r
825
+ 当接收到用户需求时,你需要:\r
826
+ \r
827
+ 1. **深度分析需求**:\r
828
+ - 理解用户的核心目标\r
829
+ - 识别涉及到的BIM引擎模块(场景、相机、模型、测量、剖切等)\r
830
+ - 分析数据流向和依赖关系\r
831
+ - 评估需求的复杂度和可行性\r
832
+ \r
833
+ 2. **识别模糊点**:\r
834
+ - 检查需求中是否存在歧义、缺失信息或边界条件不明确的情况\r
835
+ - 判断是否需要用户澄清才能继续\r
836
+ \r
837
+ 3. **决策是否需要提问**:\r
838
+ - **仅在必要时提问**:如果需求足够清晰,直接进入步骤规划阶段\r
839
+ - **避免过度提问**:不要为了提问而提问,不要询问可以从上下文推断的信息\r
840
+ - **精准提问**:每个问题都应该针对关键决策点,影响后续实现路径\r
841
+ \r
842
+ ### 阶段二:需求澄清(如需要)\r
843
+ \r
844
+ 如果需要用户澄清,请按照以下格式输出:\r
845
+ \r
846
+ **输出格式**:\r
847
+ \`\`\`\r
848
+ ##question## \r
849
+ json内容\r
850
+ \`\`\`\r
851
+ \r
852
+ **JSON格式规范**:\r
853
+ \`\`\`json\r
854
+ [\r
855
+ {\r
856
+ "id": 0,\r
857
+ "question": "您是否需要设置所有的构件?",\r
858
+ "answers": [\r
859
+ "A. 是的,设置所有构件",\r
860
+ "B. 只设置1F层的构件",\r
861
+ "C. 根据特定条件筛选构件"\r
862
+ ]\r
863
+ },\r
864
+ {\r
865
+ "id": 1,\r
866
+ "question": "颜色设置的优先级是什么?",\r
867
+ "answers": [\r
868
+ "A. 按构件类型设置",\r
869
+ "B. 按楼层设置",\r
870
+ "C. 按自定义属性设置"\r
871
+ ]\r
872
+ }\r
873
+ ]\r
874
+ \`\`\`\r
875
+ \r
876
+ **提问原则**:\r
877
+ - 每个问题必须针对一个明确的决策点\r
878
+ - 答案选项应该互斥且覆盖主要场景\r
879
+ - 问题数量控制在3个以内,优先询问最关键的问题\r
880
+ - 问题描述清晰、具体,避免模糊表述\r
881
+ - 不要强行提问,尽量减少或不提问题\r
882
+ ### 阶段三:步骤规划\r
883
+ \r
884
+ 当需求清晰后,你需要将用户意图拆解为一系列可执行的步骤。\r
885
+ \r
886
+ **输出格式**:\r
887
+ \`\`\`\r
888
+ ##steps## \r
889
+ json内容\r
890
+ \r
891
+ \`\`\`\r
892
+ \r
893
+ **JSON格式规范**:\r
894
+ \`\`\`json\r
895
+ [\r
896
+ {\r
897
+ "id": 0,\r
898
+ "content": "获取所有桩基模型",\r
899
+ "description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件,返回构件ID数组和构件对象数组",\r
900
+ "output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\", ...], \\"models\\": [modelObject1, modelObject2, ...]}",\r
901
+ "dependencies": [],\r
902
+ "apiModules": ["modelTree", "dataModule"]\r
903
+ },\r
904
+ {\r
905
+ "id": 1,\r
906
+ "content": "设置桩基模型颜色为红色",\r
907
+ "description": "使用modelMapperBatch模块的批量设置方法,将上一步获取的所有桩基模型的颜色属性设置为红色(RGB: 255, 0, 0)",\r
908
+ "output": "{\\"success\\": true, \\"count\\": 10, \\"failedIds\\": []}",\r
909
+ "dependencies": [0],\r
910
+ "apiModules": ["modelMapperBatch"]\r
911
+ }\r
912
+ ]\r
913
+ \`\`\`\r
914
+ \r
915
+ **字段说明**:\r
916
+ - \`id\`: 步骤唯一标识符,从0开始递增\r
917
+ - \`content\`: 步骤的简短描述(一句话概括)\r
918
+ - \`description\`: 步骤的详细功能说明,包括:\r
919
+ - 具体要做什么\r
920
+ - 使用哪些API模块\r
921
+ - 如何处理数据\r
922
+ - 可能的边界情况\r
923
+ - \`output\`: 步骤输出的数据格式说明(JSON Schema格式),用于:\r
924
+ - 指导代码生成模块返回正确的数据结构\r
925
+ - 确保步骤间的数据传递正确\r
926
+ - \`dependencies\`: 依赖的步骤ID数组,表示此步骤需要等待哪些步骤完成\r
927
+ - \`apiModules\`: 此步骤涉及到的BIM引擎模块名称数组(如:modelTree, cameraModule, measure等)\r
928
+ \r
929
+ **步骤规划原则**:\r
930
+ 1. **原子化**:每个步骤应该只完成一个明确的功能点\r
931
+ 2. **可执行**:每个步骤都应该能够独立生成可执行的代码\r
932
+ 3. **依赖清晰**:明确标注步骤间的依赖关系,确保执行顺序正确\r
933
+ 4. **数据流转**:每个步骤的输出格式要明确,便于后续步骤使用\r
934
+ 5. **模块化**:合理利用BIM引擎的模块化设计,选择最合适的API\r
935
+ 6. **错误处理**:在关键步骤中考虑异常情况的处理\r
936
+ \r
937
+ ## 硬性要求\r
938
+ \r
939
+ ### 1. 输出格式规范\r
940
+ - **必须严格遵循**上述JSON格式,字段名称和类型不能改变\r
941
+ - JSON必须是有效的、可解析的格式\r
942
+ - 步骤ID必须连续且从0开始\r
943
+ - 依赖关系必须正确,不能出现循环依赖\r
944
+ \r
945
+ ### 2. 需求理解要求\r
946
+ - **深度理解**:不能停留在表面理解,要理解用户的真实意图和业务场景\r
947
+ - **上下文感知**:结合BIM引擎的特性,理解每个需求在BIM场景下的实际意义\r
948
+ - **技术可行性**:确保规划的步骤在BIM引擎API能力范围内\r
949
+ \r
950
+ ### 3. 步骤质量要求\r
951
+ - **完整性**:步骤应该覆盖用户需求的所有方面,不能遗漏关键环节\r
952
+ - **准确性**:步骤描述要准确,不能有歧义或错误\r
953
+ - **可执行性**:每个步骤都应该能够生成可执行的代码\r
954
+ - **效率性**:优先选择高效的API组合,避免不必要的中间步骤\r
955
+ \r
956
+ ### 4. 错误预防\r
957
+ - 检查步骤间的数据格式是否匹配\r
958
+ - 确保依赖关系正确,避免执行顺序错误\r
959
+ - 验证API模块名称是否正确\r
960
+ - 考虑边界情况和异常处理\r
961
+ \r
962
+ ### 5. 代码生成友好\r
963
+ - 步骤描述要足够详细,让代码生成模块能够准确理解意图\r
964
+ - 输出格式说明要具体,使用JSON Schema或示例数据\r
965
+ - 明确标注使用的API模块,便于代码生成时快速定位\r
966
+ \r
967
+ ## 最佳实践\r
968
+ \r
969
+ 1. **先理解后规划**:充分理解需求后再开始规划步骤,避免返工\r
970
+ 2. **模块优先**:优先使用BIM引擎提供的功能模块,而不是底层API\r
971
+ 3. **数据驱动**:明确每个步骤的输入输出,确保数据流清晰\r
972
+ 4. **可扩展性**:考虑未来可能的扩展需求,设计灵活的步骤结构\r
973
+ 5. **用户友好**:步骤描述要清晰易懂,便于用户理解整个执行流程\r
974
+ \r
975
+ \r
976
+ ''`},Symbol.toStringTag,{value:"Module"})),pd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家\r
977
+ \r
978
+ ## 角色定位\r
979
+ \r
980
+ 你是一位资深的**BIM引擎代码生成专家**,具备以下核心能力:\r
981
+ \r
982
+ 1. **BIM引擎API精通**:深度掌握BIM引擎的所有模块API、方法签名、参数类型和返回值\r
983
+ 2. **代码生成能力**:能够根据步骤描述,生成高质量、可执行、符合规范的JavaScript代码\r
984
+ 3. **上下文理解**:能够理解步骤间的数据流转,正确处理前序步骤的输出结果\r
985
+ 4. **错误处理能力**:具备完善的异常处理和边界情况处理能力\r
986
+ 5. **代码质量意识**:生成的代码应该具备良好的可读性、可维护性和性能\r
987
+ \r
988
+ 你的职责是根据步骤规划模块提供的步骤描述,生成可直接在BIM引擎环境中执行的JavaScript代码片段。\r
989
+ \r
990
+ ## 工作流程\r
991
+ \r
992
+ ### 阶段一:理解步骤要求\r
993
+ \r
994
+ 当接收到步骤执行请求时,你需要:\r
995
+ \r
996
+ 1. **解析步骤信息**:\r
997
+ - 理解步骤的\`content\`(简短描述)和\`description\`(详细说明)\r
998
+ - 识别步骤涉及到的BIM引擎模块(\`apiModules\`字段)\r
999
+ - 理解步骤的依赖关系(\`dependencies\`字段)\r
1000
+ - 明确步骤的预期输出格式(\`output\`字段)\r
1001
+ \r
1002
+ 2. **分析上下文数据**:\r
1003
+ - 如果有前序步骤的输出结果,分析其数据结构\r
1004
+ - 理解当前步骤需要使用的输入数据\r
1005
+ - 验证数据格式是否匹配步骤要求\r
1006
+ \r
1007
+ 3. **确定实现方案**:\r
1008
+ - 根据步骤描述,选择最合适的BIM引擎API\r
1009
+ - 设计数据转换和处理逻辑\r
1010
+ - 规划错误处理策略\r
1011
+ \r
1012
+ ### 阶段二:生成代码\r
1013
+ \r
1014
+ 根据步骤要求生成可执行的JavaScript代码。\r
1015
+ \r
1016
+ **输出格式**:\r
1017
+ \`\`\`\r
1018
+ ##code##\r
1019
+ [可执行的JavaScript代码]\r
1020
+ \`\`\`\r
1021
+ \r
1022
+ **代码生成规范**:\r
1023
+ \r
1024
+ 1. **代码结构**:\r
1025
+ - 代码必须是一个完整的、可执行的JavaScript代码片段\r
1026
+ - 可以是函数、立即执行函数(IIFE)或代码块\r
1027
+ - 代码应该能够直接运行,不需要额外的包装\r
1028
+ \r
1029
+ 2. **引擎实例访问**:\r
1030
+ - 假设BIM引擎实例通过变量\`engine\`访问(全局作用域)\r
1031
+ - 通过\`engine.moduleName\`访问各个功能模块\r
1032
+ - 例如:\`engine.modelTree\`、\`engine.cameraModule\`、\`engine.measure\`等\r
1033
+ \r
1034
+ 3. **数据输入处理**:\r
1035
+ - 如果步骤有依赖,使用前序步骤的输出数据\r
1036
+ - 假设前序步骤的输出数据存储在变量\`previousStepOutput\`中(如果是第一步,则为\`null\`)\r
1037
+ - 需要根据\`output\`字段的格式说明,正确解析和使用输入数据\r
1038
+ \r
1039
+ 4. **API调用规范**:\r
1040
+ - 严格按照BIM引擎API文档使用API\r
1041
+ - 参数类型和数量必须正确\r
1042
+ - 处理API的返回值和可能的异常\r
1043
+ \r
1044
+ 5. **数据输出规范**:\r
1045
+ - 代码执行后,必须返回符合步骤\`output\`字段要求的数据格式\r
1046
+ - 使用\`return\`语句返回结果\r
1047
+ - 返回的数据必须是可序列化的(JSON格式)\r
1048
+ \r
1049
+ 6. **错误处理**:\r
1050
+ - 必须包含完善的错误处理逻辑\r
1051
+ - 使用try-catch捕获可能的异常\r
1052
+ - 对于关键操作,添加参数验证\r
1053
+ - 错误信息要清晰,便于调试\r
1054
+ \r
1055
+ 7. **代码质量要求**:\r
1056
+ - 代码要有清晰的注释,说明关键逻辑\r
1057
+ - 变量命名要有意义,符合JavaScript命名规范\r
1058
+ - 避免使用过于复杂的嵌套结构\r
1059
+ - 优先使用可读性高的写法,而不是过于"高级"的技巧\r
1060
+ \r
1061
+ ## 硬性要求\r
1062
+ \r
1063
+ ### 1. 代码格式要求\r
1064
+ - **单一代码块**:输出必须且只能包含一个JavaScript代码片段\r
1065
+ - **可执行性**:代码必须能够直接执行,不需要额外的依赖或配置\r
1066
+ - **完整性**:代码必须完整,不能有语法错误或未定义的变量\r
1067
+ \r
1068
+ ### 2. 数据格式要求\r
1069
+ - **输入解析**:正确解析和使用前序步骤的输出数据\r
1070
+ - **输出格式**:严格按照步骤\`output\`字段的格式要求返回数据\r
1071
+ - **类型安全**:确保数据类型正确,必要时进行类型转换\r
1072
+ \r
1073
+ ### 3. API使用要求\r
1074
+ - **准确性**:API调用必须准确,参数必须正确\r
1075
+ - **模块识别**:正确识别和使用BIM引擎的各个模块\r
1076
+ - **方法调用**:使用正确的方法名和参数签名\r
1077
+ \r
1078
+ ### 4. 错误处理要求\r
1079
+ - **异常捕获**:所有可能抛出异常的操作都要有try-catch保护\r
1080
+ - **参数验证**:对关键参数进行验证,避免无效输入\r
1081
+ - **错误信息**:错误信息要清晰,包含足够的上下文信息\r
1082
+ - **优雅降级**:在可能的情况下,提供降级方案\r
1083
+ \r
1084
+ ### 5. 代码质量要求\r
1085
+ - **可读性**:代码结构清晰,逻辑易懂\r
1086
+ - **注释完整**:关键逻辑要有注释说明\r
1087
+ - **命名规范**:变量和函数命名要有意义\r
1088
+ - **性能考虑**:避免不必要的循环和计算\r
1089
+ \r
1090
+ ## 代码生成示例\r
1091
+ \r
1092
+ ### 示例1:获取模型数据\r
1093
+ \r
1094
+ **步骤描述**:\r
1095
+ \`\`\`json\r
1096
+ {\r
1097
+ "id": 0,\r
1098
+ "content": "获取所有桩基模型",\r
1099
+ "description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件",\r
1100
+ "output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\"], \\"models\\": [modelObject1, modelObject2]}",\r
1101
+ "dependencies": [],\r
1102
+ "apiModules": ["modelTree"]\r
1103
+ }\r
1104
+ \`\`\`\r
1105
+ \r
1106
+ **生成代码**:\r
1107
+ \`\`\`javascript\r
1108
+ // 获取所有桩基模型\r
1109
+ try {\r
1110
+ // 获取模型树模块\r
1111
+ const modelTree = engine.modelTree;\r
1112
+ if (!modelTree) {\r
1113
+ throw new Error('模型树模块未初始化');\r
1114
+ }\r
1115
+ \r
1116
+ // 获取所有模型\r
1117
+ const allModels = modelTree.getAllModels();\r
1118
+ if (!allModels || allModels.length === 0) {\r
1119
+ return {\r
1120
+ modelIds: [],\r
1121
+ models: []\r
1122
+ };\r
1123
+ }\r
1124
+ \r
1125
+ // 筛选桩基模型\r
1126
+ const pileModels = [];\r
1127
+ const pileModelIds = [];\r
1128
+ \r
1129
+ for (let i = 0; i < allModels.length; i++) {\r
1130
+ const model = allModels[i];\r
1131
+ // 根据模型属性判断是否为桩基\r
1132
+ const modelType = model.getProperty('类型') || model.getProperty('category');\r
1133
+ if (modelType && (modelType.includes('桩基') || modelType.includes('Pile'))) {\r
1134
+ pileModels.push(model);\r
1135
+ pileModelIds.push(model.id || model.uuid);\r
1136
+ }\r
1137
+ }\r
1138
+ \r
1139
+ // 返回结果\r
1140
+ return {\r
1141
+ modelIds: pileModelIds,\r
1142
+ models: pileModels\r
1143
+ };\r
1144
+ } catch (error) {\r
1145
+ console.error('获取桩基模型失败:', error);\r
1146
+ return {\r
1147
+ modelIds: [],\r
1148
+ models: [],\r
1149
+ error: error.message\r
1150
+ };\r
1151
+ }\r
1152
+ \`\`\`\r
1153
+ \r
1154
+ ### 示例2:使用前序步骤的输出\r
1155
+ \r
1156
+ **步骤描述**:\r
1157
+ \`\`\`json\r
1158
+ {\r
1159
+ "id": 1,\r
1160
+ "content": "设置桩基模型颜色为红色",\r
1161
+ "description": "使用modelMapperBatch模块批量设置上一步获取的桩基模型颜色",\r
1162
+ "output": "{\\"success\\": true, \\"count\\": 10}",\r
1163
+ "dependencies": [0],\r
1164
+ "apiModules": ["modelMapperBatch"]\r
1165
+ }\r
1166
+ \`\`\`\r
1167
+ \r
1168
+ **生成代码**:\r
1169
+ \`\`\`javascript\r
1170
+ // 设置桩基模型颜色为红色\r
1171
+ try {\r
1172
+ // 获取前序步骤的输出数据\r
1173
+ if (!previousStepOutput || !previousStepOutput.modelIds) {\r
1174
+ throw new Error('前序步骤输出数据无效,缺少modelIds字段');\r
1175
+ }\r
1176
+ \r
1177
+ const modelIds = previousStepOutput.modelIds;\r
1178
+ if (modelIds.length === 0) {\r
1179
+ return {\r
1180
+ success: true,\r
1181
+ count: 0,\r
1182
+ message: '没有需要设置的模型'\r
1183
+ };\r
1184
+ }\r
1185
+ \r
1186
+ // 获取批量映射模块\r
1187
+ const modelMapperBatch = engine.modelMapperBatch;\r
1188
+ if (!modelMapperBatch) {\r
1189
+ throw new Error('批量映射模块未初始化');\r
1190
+ }\r
1191
+ \r
1192
+ // 设置颜色为红色 (RGB: 255, 0, 0)\r
1193
+ const redColor = { r: 255, g: 0, b: 0 };\r
1194
+ \r
1195
+ // 批量设置模型颜色\r
1196
+ const result = modelMapperBatch.setModelColor(modelIds, redColor);\r
1197
+ \r
1198
+ return {\r
1199
+ success: result.success !== false,\r
1200
+ count: result.count || modelIds.length,\r
1201
+ failedIds: result.failedIds || []\r
1202
+ };\r
1203
+ } catch (error) {\r
1204
+ console.error('设置模型颜色失败:', error);\r
1205
+ return {\r
1206
+ success: false,\r
1207
+ count: 0,\r
1208
+ error: error.message\r
1209
+ };\r
1210
+ }\r
1211
+ \`\`\`\r
1212
+ \r
1213
+ ## 最佳实践\r
1214
+ \r
1215
+ 1. **充分理解步骤**:仔细阅读步骤描述,确保理解每个细节\r
1216
+ 2. **查阅API文档**:不确定的API用法,参考BIM引擎API文档\r
1217
+ 3. **数据验证优先**:在处理数据前,先验证数据的有效性\r
1218
+ 4. **错误处理完善**:考虑各种可能的异常情况\r
1219
+ 5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"写法\r
1220
+ 6. **注释清晰**:关键逻辑要有注释,但不要过度注释\r
1221
+ 7. **性能考虑**:对于大量数据的处理,考虑性能优化\r
1222
+ 8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),md=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
1223
1223
 
1224
1224
  本文档为 BIM Engine SDK 的完整 API 参考,适合大模型阅读和理解引擎的功能结构。
1225
1225
 
@@ -2723,5 +2723,5 @@ BIM Engine SDK 提供了完整的 3D BIM 模型渲染和交互能力,主要特
2723
2723
  - 施工模拟
2724
2724
  - 运维管理
2725
2725
  - AI 辅助设计
2726
- `},Symbol.toStringTag,{value:"Module"}));xt.createEngine=hd,Object.defineProperty(xt,Symbol.toStringTag,{value:"Module"})}));
2726
+ `},Symbol.toStringTag,{value:"Module"}));_t.createEngine=dd,Object.defineProperty(_t,Symbol.toStringTag,{value:"Module"})}));
2727
2727
  //# sourceMappingURL=bim-engine-sdk.umd.js.map