iflow-engine-base 3.1.0 → 3.1.2

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(it,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],_):(it=typeof globalThis<"u"?globalThis:it||self,_(it.BimEngineSDK={},it.THREE))})(this,(function(it,_){"use strict";function Xo(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const b=Xo(_);class Zo{engine;scene;constructor(e){this.engine=e,this.scene=new b.Scene;let t=new b.Group;t.name="groupEdge",this.scene.add(t)}}class Yo{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new b.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 b.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 Ko{engine;deviceType;constructor(e){this.engine=e,this.deviceType=this.detectDeviceType()}detectDeviceType(){const e=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i,/Mobile/i],t=navigator.userAgent||globalThis.opera,n=e.some(c=>c.test(t)),i="ontouchstart"in globalThis||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,s=globalThis.screen.width,r=globalThis.screen.height,a=s<=768||r<=768,h=(globalThis.devicePixelRatio||1)>=2;return n||i&&a||i&&h?"mobile":"PC"}getDeviceType(){return this.deviceType}isMobile(){return this.deviceType==="mobile"}isPC(){return this.deviceType==="PC"}redetectDeviceType(){return this.deviceType=this.detectDeviceType(),this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class qo{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new b.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=b.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=b.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Ns={type:"change"},Pi={type:"start"},Fs={type:"end"},An=new _.Ray,Us=new _.Plane,$o=Math.cos(70*_.MathUtils.DEG2RAD),xe=new _.Vector3,Oe=.25*Math.PI,de={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ti=1e-6;class Ho extends _.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=de.NONE,this.target=new _.Vector3,this.cursor=new _.Vector3,this.origin=new _.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:_.MOUSE.ROTATE,MIDDLE:_.MOUSE.DOLLY,RIGHT:_.MOUSE.PAN},this.touches={ONE:_.TOUCH.ROTATE,TWO:_.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 _.Vector3,this._lastQuaternion=new _.Quaternion,this._lastTargetPosition=new _.Vector3,this._quat=new _.Quaternion().setFromUnitVectors(t.up,new _.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new _.Spherical,this._sphericalDelta=new _.Spherical,this._scale=1,this._panOffset=new _.Vector3,this._rotateStart=new _.Vector2,this._rotateEnd=new _.Vector2,this._rotateDelta=new _.Vector2,this._panStart=new _.Vector2,this._panEnd=new _.Vector2,this._panDelta=new _.Vector2,this._dollyStart=new _.Vector2,this._dollyEnd=new _.Vector2,this._dollyDelta=new _.Vector2,this._dollyDirection=new _.Vector3,this._mouse=new _.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Qo.bind(this),this._onPointerDown=Jo.bind(this),this._onPointerUp=ea.bind(this),this._onContextMenu=aa.bind(this),this._onMouseWheel=ia.bind(this),this._onKeyDown=sa.bind(this),this._onTouchStart=ra.bind(this),this._onTouchMove=oa.bind(this),this._onMouseDown=ta.bind(this),this._onMouseMove=na.bind(this),this._interceptControlDown=la.bind(this),this._interceptControlUp=ca.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(Ns),this.update(),this.state=de.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===de.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 r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=r!=this._spherical.radius}if(xe.setFromSpherical(this._spherical),xe.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const r=new _.Vector3;if(r.copy(this.origin).sub(this.target),r.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,h=new _.Vector3(0,1,0),c=new _.Vector3;this.object.getWorldDirection(c);const d=c.clone().cross(h).normalize(),m=new _.Vector3().copy(this.object.position).sub(this.origin);m.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),m.applyAxisAngle(d,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(m);const p=new _.Vector3().copy(this.target).sub(this.origin);p.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(d,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(p)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const l=new _.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 r=null;if(this.object.isPerspectiveCamera){const a=xe.length();r=this._clampDistance(a*this._scale);const l=a-r;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new _.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 _.Vector3(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(a),this.object.updateMatrixWorld(),r=xe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(An.origin.copy(this.object.position),An.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(An.direction))<$o?this.object.lookAt(this.target):(Us.setFromNormalAndCoplanarPoint(this.object.up,this.target),An.intersectPlane(Us,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Ti||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ti||this._lastTargetPosition.distanceToSquared(this.target)>Ti?(this.dispatchEvent(Ns),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,r=n.width,a=n.height;this._mouse.x=i/r*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 r=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(r,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 _.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(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function Qo(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function ea(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Fs),this.state=de.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 ta(o){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(o.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 _.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=de.DOLLY;break;case _.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=de.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=de.ROTATE}break;case _.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=de.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=de.PAN}break;default:this.state=de.NONE}this.state!==de.NONE&&this.dispatchEvent(Pi)}function na(o){switch(this.state){case de.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case de.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case de.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function ia(o){this.enabled===!1||this.enableZoom===!1||this.state!==de.NONE||(o.preventDefault(),this.dispatchEvent(Pi),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(Fs))}function sa(o){this.enabled!==!1&&this._handleKeyDown(o)}function ra(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case _.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=de.TOUCH_ROTATE;break;case _.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=de.TOUCH_PAN;break;default:this.state=de.NONE}break;case 2:switch(this.touches.TWO){case _.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=de.TOUCH_DOLLY_PAN;break;case _.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=de.TOUCH_DOLLY_ROTATE;break;default:this.state=de.NONE}break;default:this.state=de.NONE}this.state!==de.NONE&&this.dispatchEvent(Pi)}function oa(o){switch(this._trackPointer(o),this.state){case de.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case de.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case de.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case de.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=de.NONE}}function aa(o){this.enabled!==!1&&o.preventDefault()}function la(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ca(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Vs{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new b.Vector3(0,-1,0),this._camerLocalDirection=new b.Vector3,this._tmpVector=new b.Vector3,this._rayCaster=new b.Raycaster,this._fallingTime=0,this._euler=new b.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 r=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(r)}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 r=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(r)}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 b.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 b.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}}class De{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new b.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new b.Vector2(t.x,t.y)}worldToScreen(e){const t=new b.Vector3;return t.copy(e).project(this.camera),t.x=t.x*this.renderer.domElement.clientWidth*.5,t.y=-t.y*this.renderer.domElement.clientHeight*.5,t.z=(t.z+1)*.5,t.x+=this.renderer.domElement.clientWidth*.5,t.y+=this.renderer.domElement.clientHeight*.5,new b.Vector2(t.x,t.y)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,s=e/n*2-1,r=-(t/i*2-1);return new b.Vector2(s,r)}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,r=this.raycaster.intersectObjects(s,!0);return r.length>0?r[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=new b.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}function Di(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",h),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),o.renderer.domElement.addEventListener("touchend",p,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",a),o.renderer.domElement.removeEventListener("mouseup",h),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",d),o.renderer.domElement.removeEventListener("touchend",p),o.renderer.domElement.removeEventListener("touchmove",m),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 g=new b.Vector2,y=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return g.x=u.offsetX/y*2-1,g.y=-(u.offsetY/v)*2+1,g}function s(u){const g=new b.Raycaster,y=i(u);return g.setFromCamera(y,o.camera),g}function r(u,g=!1){const y=s(u);if(u.raycaster=y,g){const v=f(y,u);u.catch=v}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new b.Vector3(u.offsetX,u.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,r(u,!0),u.catch!=null&&o.controlModule.orbitControls.origin.set(u.catch.point.x,u.catch.point.y,u.catch.point.z),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&(r(u,!0),e.self.handleMouseMove(u))}function h(u){if(u.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new b.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const w=v.distanceTo(e.mouseDownPosition);if((y<100||w==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const x=g-e.lastClickTime;console.log(x),x<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function c(u){const g=u.touches[0]||u.changedTouches[0];if(!g)return null;const v=o.renderer.domElement.getBoundingClientRect(),w=g.clientX-v.left,x=g.clientY-v.top;return{offsetX:w,offsetY:x,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>u.preventDefault(),stopPropagation:()=>u.stopPropagation(),originalEvent:u}}function d(u){if(u.preventDefault(),u.touches.length!==1)return;const g=c(u);g&&a(g)}function m(u){if(u.preventDefault(),u.touches.length!==1)return;const g=c(u);g&&l(g)}function p(u){u.preventDefault();const g=c(u);g&&h(g)}function f(u,g){if(!o.engineStatus.isFree){o.hoverHighLight.clearHighlight();return}o.catchSvg.innerHTML="";const y=o.octreeBox.rayInterationModel(u);let v=u.intersectObjects(o.scene.children.filter(z=>z instanceof b.InstancedMesh),!0);if(v.length>0&&(y.length==0||v[0].distance<y[0].distance)){let z=v[0].object;if(z.ids!=null&&z.ids.length!=0){let V=z.ids[v[0].instanceId],U={object:{url:z.url,id:V,name:V,isInstance:!0},face:v[0].face,distance:v[0].distance,point:v[0].point,instanceId:v[0].instanceId,matrix:z.matrixs[v[0].instanceId]};y.splice(0,0,U)}}if(y.length===0)return;let w=y[0].object.url,x=y[0].object.name,M=o.modelEdge.getModelEdge(w,x);M||(M=[0,0,[]]);let T=[];M[2].forEach(z=>{z[0]!=null&&z[1]!=null&&T.push({X:z[0].X*.5+z[1].X*.5,Y:z[0].Y*.5+z[1].Y*.5,Z:z[0].Z*.5+z[1].Z*.5})});let P=[...M[2].map(z=>z[0]),...T],k="face",D=[],E=[],O=10;if(P.forEach(z=>{if(z!=null){let V=new b.Vector3(z.X,z.Z,-z.Y),U=o.worldToScreen.worldToScreen(V),H=Math.sqrt(Math.pow(U.x-g.offsetX,2)+Math.pow(U.y-g.offsetY,2));H<O&&(O=H,D.push({point:V,distance:H,pointxy:U}))}}),D.length>0?(D.sort((z,V)=>z.distance-V.distance),k="point"):(M[2].forEach(z=>{if(z[0]!=null&&z[1]!=null){let V=new b.Vector3(z[0].X,z[0].Z,-z[0].Y),U=new b.Vector3(z[1].X,z[1].Z,-z[1].Y),H=o.worldToScreen.worldToScreen(V),G=o.worldToScreen.worldToScreen(U),$=A(new b.Vector2(g.offsetX,g.offsetY),H,G);if($<O){let F=I(new b.Vector2(g.offsetX,g.offsetY),H,G),R=S(F,V,U);E.push({distance:$,point:R,pointxy:o.worldToScreen.worldToScreen(R),start:H,end:G})}}}),E.length>0&&(E.sort((z,V)=>z.distance-V.distance),k="line")),k=="point"&&e.options.showCatch){const z=new De(o.camera,o.renderer,o.scene).worldToScreen(D[0].point);o.catchSvg.innerHTML="";const V=z.x+o.reactBoundingClientRect.left,U=z.y+o.reactBoundingClientRect.top;console.log(V,U);const H=document.createElementNS("http://www.w3.org/2000/svg","polygon");H.setAttribute("class","catchPoint"),H.setAttribute("points",`${V},${U-8} ${V-7},${U+4} ${V+7},${U+4}`),o.catchSvg.appendChild(H),y[0].point=D[0].point}else if(k=="line"&&e.options.showCatch){o.worldToScreen.worldToScreen(E[0].point);const z=E[0].start,V=E[0].end;o.catchSvg.innerHTML="";const U=document.createElementNS("http://www.w3.org/2000/svg","line");U.setAttribute("class","catchLine"),U.setAttribute("x1",(z.x+o.reactBoundingClientRect.left).toString()),U.setAttribute("y1",(z.y+o.reactBoundingClientRect.top).toString()),U.setAttribute("x2",(V.x+o.reactBoundingClientRect.left).toString()),U.setAttribute("y2",(V.y+o.reactBoundingClientRect.top).toString()),U.setAttribute("stroke","rgb(8, 223, 215)"),U.setAttribute("stroke-width","2"),o.catchSvg.appendChild(U),y[0].point=E[0].point}else if(k=="face"&&e.options.showCatch){let z=y[0].point.clone(),V=y[0].normal||(y[0].face?y[0].face.normal:null);const U=(V?V.clone():new b.Vector3(0,0,1)).normalize(),H=Math.abs(U.y)<.9?new b.Vector3(0,1,0):new b.Vector3(1,0,0),G=new b.Vector3().crossVectors(U,H).normalize(),$=new b.Vector3().crossVectors(U,G).normalize(),F=.05,ee=[new b.Vector3().copy(G).add($).multiplyScalar(F),new b.Vector3().copy(G).sub($).multiplyScalar(F),new b.Vector3().copy(G).multiplyScalar(-1).sub($).multiplyScalar(F),new b.Vector3().copy(G).multiplyScalar(-1).add($).multiplyScalar(F)].map(ce=>new b.Vector3().copy(z).add(ce)).map(ce=>o.worldToScreen.worldToScreen(ce));o.catchSvg.innerHTML="";const q=document.createElementNS("http://www.w3.org/2000/svg","polygon");q.setAttribute("class","catchFace"),q.setAttribute("points",ee.map(ce=>`${ce.x+o.reactBoundingClientRect.left},${ce.y+o.reactBoundingClientRect.top}`).join(" ")),q.setAttribute("fill","rgba(1, 238, 255, 0.2)"),q.setAttribute("stroke","rgb(0, 255, 247)"),q.setAttribute("stroke-width","1"),o.catchSvg.appendChild(q)}return y[0];function A(z,V,U){const H=new b.Vector2().subVectors(U,V),G=H.lengthSq();if(G<1e-10)return z.distanceTo(V);const $=new b.Vector2().subVectors(z,V),F=b.MathUtils.clamp($.dot(H)/G,0,1),R=new b.Vector2().copy(H).multiplyScalar(F).add(V);return z.distanceTo(R)}function I(z,V,U){const H=new b.Vector2().subVectors(U,V),G=H.lengthSq();if(G<1e-10)return 0;const $=new b.Vector2().subVectors(z,V);return b.MathUtils.clamp($.dot(H)/G,0,1)}function S(z,V,U){const H=b.MathUtils.clamp(z,0,1);return new b.Vector3().lerpVectors(V,U,H)}}return e}class ha{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=Di(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Ho(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Vs(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*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}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 Vs(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.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 St={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
1
+ (function(it,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],_):(it=typeof globalThis<"u"?globalThis:it||self,_(it.BimEngineSDK={},it.THREE))})(this,(function(it,_){"use strict";function Xo(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const b=Xo(_);class Zo{engine;scene;constructor(e){this.engine=e,this.scene=new b.Scene;let t=new b.Group;t.name="groupEdge",this.scene.add(t)}}class Yo{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new b.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 b.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 Ko{engine;deviceType;constructor(e){this.engine=e,this.deviceType=this.detectDeviceType()}detectDeviceType(){const e=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i,/Mobile/i],t=navigator.userAgent||globalThis.opera,n=e.some(h=>h.test(t)),i="ontouchstart"in globalThis||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,s=globalThis.screen.width,r=globalThis.screen.height,a=s<=768||r<=768,c=(globalThis.devicePixelRatio||1)>=2;return n||i&&a||i&&c?"mobile":"PC"}getDeviceType(){return this.deviceType}isMobile(){return this.deviceType==="mobile"}isPC(){return this.deviceType==="PC"}redetectDeviceType(){return this.deviceType=this.detectDeviceType(),this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class qo{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new b.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=b.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=b.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Ns={type:"change"},Ti={type:"start"},Fs={type:"end"},Pn=new _.Ray,Us=new _.Plane,$o=Math.cos(70*_.MathUtils.DEG2RAD),xe=new _.Vector3,Oe=.25*Math.PI,de={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Di=1e-6;class Ho extends _.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=de.NONE,this.target=new _.Vector3,this.cursor=new _.Vector3,this.origin=new _.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:_.MOUSE.ROTATE,MIDDLE:_.MOUSE.DOLLY,RIGHT:_.MOUSE.PAN},this.touches={ONE:_.TOUCH.ROTATE,TWO:_.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 _.Vector3,this._lastQuaternion=new _.Quaternion,this._lastTargetPosition=new _.Vector3,this._quat=new _.Quaternion().setFromUnitVectors(t.up,new _.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new _.Spherical,this._sphericalDelta=new _.Spherical,this._scale=1,this._panOffset=new _.Vector3,this._rotateStart=new _.Vector2,this._rotateEnd=new _.Vector2,this._rotateDelta=new _.Vector2,this._panStart=new _.Vector2,this._panEnd=new _.Vector2,this._panDelta=new _.Vector2,this._dollyStart=new _.Vector2,this._dollyEnd=new _.Vector2,this._dollyDelta=new _.Vector2,this._dollyDirection=new _.Vector3,this._mouse=new _.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Qo.bind(this),this._onPointerDown=Jo.bind(this),this._onPointerUp=ea.bind(this),this._onContextMenu=aa.bind(this),this._onMouseWheel=ia.bind(this),this._onKeyDown=sa.bind(this),this._onTouchStart=ra.bind(this),this._onTouchMove=oa.bind(this),this._onMouseDown=ta.bind(this),this._onMouseMove=na.bind(this),this._interceptControlDown=la.bind(this),this._interceptControlUp=ca.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(Ns),this.update(),this.state=de.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===de.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 r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=r!=this._spherical.radius}if(xe.setFromSpherical(this._spherical),xe.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const r=new _.Vector3;if(r.copy(this.origin).sub(this.target),r.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,c=new _.Vector3(0,1,0),h=new _.Vector3;this.object.getWorldDirection(h);const d=h.clone().cross(c).normalize(),m=new _.Vector3().copy(this.object.position).sub(this.origin);m.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),m.applyAxisAngle(d,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(m);const p=new _.Vector3().copy(this.target).sub(this.origin);p.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(d,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(p)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const l=new _.Vector3;this.object.getWorldDirection(l);const c=this._spherical.radius*.05*(this._scale-1);t.add(l.multiplyScalar(c))}}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 r=null;if(this.object.isPerspectiveCamera){const a=xe.length();r=this._clampDistance(a*this._scale);const l=a-r;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new _.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 c=new _.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),r=xe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(Pn.origin.copy(this.object.position),Pn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Pn.direction))<$o?this.object.lookAt(this.target):(Us.setFromNormalAndCoplanarPoint(this.object.up,this.target),Pn.intersectPlane(Us,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Di||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Di||this._lastTargetPosition.distanceToSquared(this.target)>Di?(this.dispatchEvent(Ns),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,r=n.width,a=n.height;this._mouse.x=i/r*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 r=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(r,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 _.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(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function Qo(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function ea(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Fs),this.state=de.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 ta(o){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(o.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 _.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=de.DOLLY;break;case _.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=de.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=de.ROTATE}break;case _.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=de.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=de.PAN}break;default:this.state=de.NONE}this.state!==de.NONE&&this.dispatchEvent(Ti)}function na(o){switch(this.state){case de.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case de.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case de.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function ia(o){this.enabled===!1||this.enableZoom===!1||this.state!==de.NONE||(o.preventDefault(),this.dispatchEvent(Ti),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(Fs))}function sa(o){this.enabled!==!1&&this._handleKeyDown(o)}function ra(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case _.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=de.TOUCH_ROTATE;break;case _.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=de.TOUCH_PAN;break;default:this.state=de.NONE}break;case 2:switch(this.touches.TWO){case _.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=de.TOUCH_DOLLY_PAN;break;case _.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=de.TOUCH_DOLLY_ROTATE;break;default:this.state=de.NONE}break;default:this.state=de.NONE}this.state!==de.NONE&&this.dispatchEvent(Ti)}function oa(o){switch(this._trackPointer(o),this.state){case de.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case de.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case de.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case de.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=de.NONE}}function aa(o){this.enabled!==!1&&o.preventDefault()}function la(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ca(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Vs{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new b.Vector3(0,-1,0),this._camerLocalDirection=new b.Vector3,this._tmpVector=new b.Vector3,this._rayCaster=new b.Raycaster,this._fallingTime=0,this._euler=new b.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 r=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(r)}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 r=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(r)}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 b.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 b.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}}class De{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new b.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new b.Vector2(t.x,t.y)}worldToScreen(e){const t=new b.Vector3;return t.copy(e).project(this.camera),t.x=t.x*this.renderer.domElement.clientWidth*.5,t.y=-t.y*this.renderer.domElement.clientHeight*.5,t.z=(t.z+1)*.5,t.x+=this.renderer.domElement.clientWidth*.5,t.y+=this.renderer.domElement.clientHeight*.5,new b.Vector2(t.x,t.y)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,s=e/n*2-1,r=-(t/i*2-1);return new b.Vector2(s,r)}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,r=this.raycaster.intersectObjects(s,!0);return r.length>0?r[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=new b.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}function ki(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",c),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),o.renderer.domElement.addEventListener("touchend",p,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",a),o.renderer.domElement.removeEventListener("mouseup",c),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",d),o.renderer.domElement.removeEventListener("touchend",p),o.renderer.domElement.removeEventListener("touchmove",m),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 g=new b.Vector2,y=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return g.x=u.offsetX/y*2-1,g.y=-(u.offsetY/v)*2+1,g}function s(u){const g=new b.Raycaster,y=i(u);return g.setFromCamera(y,o.camera),g}function r(u,g=!1){const y=s(u);if(u.raycaster=y,g){const v=f(y,u);u.catch=v}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new b.Vector3(u.offsetX,u.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,r(u,!0),u.catch!=null&&o.controlModule.orbitControls.origin.set(u.catch.point.x,u.catch.point.y,u.catch.point.z),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&(r(u,!0),e.self.handleMouseMove(u))}function c(u){if(u.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new b.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const w=v.distanceTo(e.mouseDownPosition);if((y<100||w==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const x=g-e.lastClickTime;console.log(x),x<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function h(u){const g=u.touches[0]||u.changedTouches[0];if(!g)return null;const v=o.renderer.domElement.getBoundingClientRect(),w=g.clientX-v.left,x=g.clientY-v.top;return{offsetX:w,offsetY:x,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>u.preventDefault(),stopPropagation:()=>u.stopPropagation(),originalEvent:u}}function d(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&a(g)}function m(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&l(g)}function p(u){u.preventDefault();const g=h(u);g&&c(g)}function f(u,g){if(!o.engineStatus.isFree){o.hoverHighLight.clearHighlight();return}o.catchSvg.innerHTML="";const y=o.octreeBox.rayInterationModel(u);let v=u.intersectObjects(o.scene.children.filter(z=>z instanceof b.InstancedMesh),!0);if(v.length>0&&(y.length==0||v[0].distance<y[0].distance)){let z=v[0].object;if(z.ids!=null&&z.ids.length!=0){let V=z.ids[v[0].instanceId],U={object:{url:z.url,id:V,name:V,isInstance:!0},face:v[0].face,distance:v[0].distance,point:v[0].point,instanceId:v[0].instanceId,matrix:z.matrixs[v[0].instanceId]};y.splice(0,0,U)}}if(y.length===0)return;let w=y[0].object.url,x=y[0].object.name,M=o.modelEdge.getModelEdge(w,x);M||(M=[0,0,[]]);let T=[];M[2].forEach(z=>{z[0]!=null&&z[1]!=null&&T.push({X:z[0].X*.5+z[1].X*.5,Y:z[0].Y*.5+z[1].Y*.5,Z:z[0].Z*.5+z[1].Z*.5})});let P=[...M[2].map(z=>z[0]),...T],k="face",D=[],E=[],O=10;if(P.forEach(z=>{if(z!=null){let V=new b.Vector3(z.X,z.Z,-z.Y),U=o.worldToScreen.worldToScreen(V),H=Math.sqrt(Math.pow(U.x-g.offsetX,2)+Math.pow(U.y-g.offsetY,2));H<O&&(O=H,D.push({point:V,distance:H,pointxy:U}))}}),D.length>0?(D.sort((z,V)=>z.distance-V.distance),k="point"):(M[2].forEach(z=>{if(z[0]!=null&&z[1]!=null){let V=new b.Vector3(z[0].X,z[0].Z,-z[0].Y),U=new b.Vector3(z[1].X,z[1].Z,-z[1].Y),H=o.worldToScreen.worldToScreen(V),G=o.worldToScreen.worldToScreen(U),$=A(new b.Vector2(g.offsetX,g.offsetY),H,G);if($<O){let F=I(new b.Vector2(g.offsetX,g.offsetY),H,G),R=S(F,V,U);E.push({distance:$,point:R,pointxy:o.worldToScreen.worldToScreen(R),start:H,end:G})}}}),E.length>0&&(E.sort((z,V)=>z.distance-V.distance),k="line")),k=="point"&&e.options.showCatch){const z=new De(o.camera,o.renderer,o.scene).worldToScreen(D[0].point);o.catchSvg.innerHTML="";const V=z.x+o.reactBoundingClientRect.left,U=z.y+o.reactBoundingClientRect.top;console.log(V,U);const H=document.createElementNS("http://www.w3.org/2000/svg","polygon");H.setAttribute("class","catchPoint"),H.setAttribute("points",`${V},${U-8} ${V-7},${U+4} ${V+7},${U+4}`),o.catchSvg.appendChild(H),y[0].point=D[0].point}else if(k=="line"&&e.options.showCatch){o.worldToScreen.worldToScreen(E[0].point);const z=E[0].start,V=E[0].end;o.catchSvg.innerHTML="";const U=document.createElementNS("http://www.w3.org/2000/svg","line");U.setAttribute("class","catchLine"),U.setAttribute("x1",(z.x+o.reactBoundingClientRect.left).toString()),U.setAttribute("y1",(z.y+o.reactBoundingClientRect.top).toString()),U.setAttribute("x2",(V.x+o.reactBoundingClientRect.left).toString()),U.setAttribute("y2",(V.y+o.reactBoundingClientRect.top).toString()),U.setAttribute("stroke","rgb(8, 223, 215)"),U.setAttribute("stroke-width","2"),o.catchSvg.appendChild(U),y[0].point=E[0].point}else if(k=="face"&&e.options.showCatch){let z=y[0].point.clone(),V=y[0].normal||(y[0].face?y[0].face.normal:null);const U=(V?V.clone():new b.Vector3(0,0,1)).normalize(),H=Math.abs(U.y)<.9?new b.Vector3(0,1,0):new b.Vector3(1,0,0),G=new b.Vector3().crossVectors(U,H).normalize(),$=new b.Vector3().crossVectors(U,G).normalize(),F=.05,ee=[new b.Vector3().copy(G).add($).multiplyScalar(F),new b.Vector3().copy(G).sub($).multiplyScalar(F),new b.Vector3().copy(G).multiplyScalar(-1).sub($).multiplyScalar(F),new b.Vector3().copy(G).multiplyScalar(-1).add($).multiplyScalar(F)].map(ce=>new b.Vector3().copy(z).add(ce)).map(ce=>o.worldToScreen.worldToScreen(ce));o.catchSvg.innerHTML="";const q=document.createElementNS("http://www.w3.org/2000/svg","polygon");q.setAttribute("class","catchFace"),q.setAttribute("points",ee.map(ce=>`${ce.x+o.reactBoundingClientRect.left},${ce.y+o.reactBoundingClientRect.top}`).join(" ")),q.setAttribute("fill","rgba(1, 238, 255, 0.2)"),q.setAttribute("stroke","rgb(0, 255, 247)"),q.setAttribute("stroke-width","1"),o.catchSvg.appendChild(q)}return y[0];function A(z,V,U){const H=new b.Vector2().subVectors(U,V),G=H.lengthSq();if(G<1e-10)return z.distanceTo(V);const $=new b.Vector2().subVectors(z,V),F=b.MathUtils.clamp($.dot(H)/G,0,1),R=new b.Vector2().copy(H).multiplyScalar(F).add(V);return z.distanceTo(R)}function I(z,V,U){const H=new b.Vector2().subVectors(U,V),G=H.lengthSq();if(G<1e-10)return 0;const $=new b.Vector2().subVectors(z,V);return b.MathUtils.clamp($.dot(H)/G,0,1)}function S(z,V,U){const H=b.MathUtils.clamp(z,0,1);return new b.Vector3().lerpVectors(V,U,H)}}return e}class ha{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=ki(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Ho(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Vs(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*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}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 Vs(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.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 St={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 Ct{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 ua=new _.OrthographicCamera(-1,1,1,-1,0,1);class da extends _.BufferGeometry{constructor(){super(),this.setAttribute("position",new _.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _.Float32BufferAttribute([0,2,0,0,2,0],2))}}const fa=new da;class Pn{constructor(e){this._mesh=new _.Mesh(fa,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ua)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Tn extends Ct{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof _.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=_.UniformsUtils.clone(e.uniforms),this.material=new _.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 Pn(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 js extends Ct{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 r,a;this.inverse?(r=0,a=1):(r=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,r,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 pa extends Ct{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ma{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new _.Vector2);this._width=n.width,this._height=n.height,t=new _.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:_.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 Tn(St),this.copyPass.material.blending=_.NoBlending,this.clock=new _.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 r=this.passes[i];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.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()}js!==void 0&&(r instanceof js?n=!0:r instanceof pa&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new _.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 ga extends Ct{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 _.Color}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,r;this.overrideMaterial!==null&&(r=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=r),e.autoClear=i}}const Dn={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 _.Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new _.Matrix4},cameraProjectionMatrixInverse:{value:new _.Matrix4},cameraWorldMatrix:{value:new _.Matrix4},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new _.Vector3(-1,-1,-1)},sceneBoxMax:{value:new _.Vector3(1,1,1)}},vertexShader:`
24
+ }`};class Ct{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 ua=new _.OrthographicCamera(-1,1,1,-1,0,1);class da extends _.BufferGeometry{constructor(){super(),this.setAttribute("position",new _.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new _.Float32BufferAttribute([0,2,0,0,2,0],2))}}const fa=new da;class Tn{constructor(e){this._mesh=new _.Mesh(fa,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ua)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Dn extends Ct{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof _.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=_.UniformsUtils.clone(e.uniforms),this.material=new _.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 Tn(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 js extends Ct{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 r,a;this.inverse?(r=0,a=1):(r=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,r,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 pa extends Ct{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ma{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new _.Vector2);this._width=n.width,this._height=n.height,t=new _.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:_.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 Dn(St),this.copyPass.material.blending=_.NoBlending,this.clock=new _.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 r=this.passes[i];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),r.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()}js!==void 0&&(r instanceof js?n=!0:r instanceof pa&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new _.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 ga extends Ct{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 _.Color}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,r;this.overrideMaterial!==null&&(r=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=r),e.autoClear=i}}const kn={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 _.Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new _.Matrix4},cameraProjectionMatrixInverse:{value:new _.Matrix4},cameraWorldMatrix:{value:new _.Matrix4},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new _.Vector3(-1,-1,-1)},sceneBoxMax:{value:new _.Vector3(1,1,1)}},vertexShader:`
25
25
 
26
26
  varying vec2 vUv;
27
27
 
@@ -204,7 +204,7 @@
204
204
  ao = pow(ao, scale);
205
205
 
206
206
  gl_FragColor = FRAGMENT_OUTPUT;
207
- }`},kn={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
207
+ }`},En={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
208
208
  varying vec2 vUv;
209
209
 
210
210
  void main() {
@@ -232,7 +232,7 @@
232
232
  float depth = getLinearDepth( vUv );
233
233
  gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
234
234
 
235
- }`},ki={uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
235
+ }`},Ei={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 ya(o=5){const e=Math.floor(o)%2===0?Math.floor(o)+1:Math.floor(o),t=va(e),n=t.length,i=new Uint8Array(n*4);for(let r=0;r<n;++r){const a=t[r],l=2*Math.PI*a/n,h=new _.Vector3(Math.cos(l),Math.sin(l),0).normalize();i[r*4]=(h.x*.5+.5)*255,i[r*4+1]=(h.y*.5+.5)*255,i[r*4+2]=127,i[r*4+3]=255}const s=new _.DataTexture(i,e,e);return s.wrapS=_.RepeatWrapping,s.wrapT=_.RepeatWrapping,s.needsUpdate=!0,s}function va(o){const e=Math.floor(o)%2===0?Math.floor(o)+1:Math.floor(o),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),s=e-1;for(let r=1;r<=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]=r++;s++,i--}return n}const En={defines:{SAMPLES:16,SAMPLE_VECTORS:Gs(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 _.Vector2},cameraProjectionMatrixInverse:{value:new _.Matrix4},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
249
+ }`};function ya(o=5){const e=Math.floor(o)%2===0?Math.floor(o)+1:Math.floor(o),t=va(e),n=t.length,i=new Uint8Array(n*4);for(let r=0;r<n;++r){const a=t[r],l=2*Math.PI*a/n,c=new _.Vector3(Math.cos(l),Math.sin(l),0).normalize();i[r*4]=(c.x*.5+.5)*255,i[r*4+1]=(c.y*.5+.5)*255,i[r*4+2]=127,i[r*4+3]=255}const s=new _.DataTexture(i,e,e);return s.wrapS=_.RepeatWrapping,s.wrapT=_.RepeatWrapping,s.needsUpdate=!0,s}function va(o){const e=Math.floor(o)%2===0?Math.floor(o)+1:Math.floor(o),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),s=e-1;for(let r=1;r<=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]=r++;s++,i--}return n}const Ln={defines:{SAMPLES:16,SAMPLE_VECTORS:Gs(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 _.Vector2},cameraProjectionMatrixInverse:{value:new _.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 Gs(o,e,t){const n=wa(o,e,t);let i="vec3[SAMPLES](";for(let s=0;s<o;s++){const r=n[s];i+=`vec3(${r.x}, ${r.y}, ${r.z})${s<o-1?",":")"}`}return i}function wa(o,e,t){const n=[];for(let i=0;i<o;i++){const s=2*Math.PI*e*i/o,r=Math.pow(i/(o-1),t);n.push(new _.Vector3(Math.cos(s),Math.sin(s),r))}return n}class Ws{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 r=.5*(Math.sqrt(3)-1),a=(e+t)*r,l=Math.floor(e+a),h=Math.floor(t+a),c=(3-Math.sqrt(3))/6,d=(l+h)*c,m=l-d,p=h-d,f=e-m,u=t-p;let g,y;f>u?(g=1,y=0):(g=0,y=1);const v=f-g+c,w=u-y+c,x=f-1+2*c,M=u-1+2*c,T=l&255,P=h&255,k=this.perm[T+this.perm[P]]%12,D=this.perm[T+g+this.perm[P+y]]%12,E=this.perm[T+1+this.perm[P+1]]%12;let O=.5-f*f-u*u;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],f,u));let A=.5-v*v-w*w;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[D],v,w));let I=.5-x*x-M*M;return I<0?s=0:(I*=I,s=I*I*this._dot(this.grad3[E],x,M)),70*(n+i+s)}noise3d(e,t,n){let i,s,r,a;const h=(e+t+n)*.3333333333333333,c=Math.floor(e+h),d=Math.floor(t+h),m=Math.floor(n+h),p=1/6,f=(c+d+m)*p,u=c-f,g=d-f,y=m-f,v=e-u,w=t-g,x=n-y;let M,T,P,k,D,E;v>=w?w>=x?(M=1,T=0,P=0,k=1,D=1,E=0):v>=x?(M=1,T=0,P=0,k=1,D=0,E=1):(M=0,T=0,P=1,k=1,D=0,E=1):w<x?(M=0,T=0,P=1,k=0,D=1,E=1):v<x?(M=0,T=1,P=0,k=0,D=1,E=1):(M=0,T=1,P=0,k=1,D=1,E=0);const O=v-M+p,A=w-T+p,I=x-P+p,S=v-k+2*p,z=w-D+2*p,V=x-E+2*p,U=v-1+3*p,H=w-1+3*p,G=x-1+3*p,$=c&255,F=d&255,R=m&255,te=this.perm[$+this.perm[F+this.perm[R]]]%12,ee=this.perm[$+M+this.perm[F+T+this.perm[R+P]]]%12,q=this.perm[$+k+this.perm[F+D+this.perm[R+E]]]%12,ce=this.perm[$+1+this.perm[F+1+this.perm[R+1]]]%12;let fe=.6-v*v-w*w-x*x;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[te],v,w,x));let se=.6-O*O-A*A-I*I;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[ee],O,A,I));let oe=.6-S*S-z*z-V*V;oe<0?r=0:(oe*=oe,r=oe*oe*this._dot3(this.grad3[q],S,z,V));let ue=.6-U*U-H*H-G*G;return ue<0?a=0:(ue*=ue,a=ue*ue*this._dot3(this.grad3[ce],U,H,G)),32*(i+s+r+a)}noise4d(e,t,n,i){const s=this.grad4,r=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,h=(5-Math.sqrt(5))/20;let c,d,m,p,f;const u=(e+t+n+i)*l,g=Math.floor(e+u),y=Math.floor(t+u),v=Math.floor(n+u),w=Math.floor(i+u),x=(g+y+v+w)*h,M=g-x,T=y-x,P=v-x,k=w-x,D=e-M,E=t-T,O=n-P,A=i-k,I=D>E?32:0,S=D>O?16:0,z=E>O?8:0,V=D>A?4:0,U=E>A?2:0,H=O>A?1:0,G=I+S+z+V+U+H,$=r[G][0]>=3?1:0,F=r[G][1]>=3?1:0,R=r[G][2]>=3?1:0,te=r[G][3]>=3?1:0,ee=r[G][0]>=2?1:0,q=r[G][1]>=2?1:0,ce=r[G][2]>=2?1:0,fe=r[G][3]>=2?1:0,se=r[G][0]>=1?1:0,oe=r[G][1]>=1?1:0,ue=r[G][2]>=1?1:0,pe=r[G][3]>=1?1:0,Ce=D-$+h,Be=E-F+h,C=O-R+h,Z=A-te+h,X=D-ee+2*h,B=E-q+2*h,L=O-ce+2*h,N=A-fe+2*h,Y=D-se+3*h,K=E-oe+3*h,j=O-ue+3*h,J=A-pe+3*h,ne=D-1+4*h,Q=E-1+4*h,ie=O-1+4*h,he=A-1+4*h,ae=g&255,Ae=y&255,$e=v&255,Ee=w&255,Ft=a[ae+a[Ae+a[$e+a[Ee]]]]%32,ge=a[ae+$+a[Ae+F+a[$e+R+a[Ee+te]]]]%32,nn=a[ae+ee+a[Ae+q+a[$e+ce+a[Ee+fe]]]]%32,Sn=a[ae+se+a[Ae+oe+a[$e+ue+a[Ee+pe]]]]%32,He=a[ae+1+a[Ae+1+a[$e+1+a[Ee+1]]]]%32;let Mt=.6-D*D-E*E-O*O-A*A;Mt<0?c=0:(Mt*=Mt,c=Mt*Mt*this._dot4(s[Ft],D,E,O,A));let Ut=.6-Ce*Ce-Be*Be-C*C-Z*Z;Ut<0?d=0:(Ut*=Ut,d=Ut*Ut*this._dot4(s[ge],Ce,Be,C,Z));let Vt=.6-X*X-B*B-L*L-N*N;Vt<0?m=0:(Vt*=Vt,m=Vt*Vt*this._dot4(s[nn],X,B,L,N));let jt=.6-Y*Y-K*K-j*j-J*J;jt<0?p=0:(jt*=jt,p=jt*jt*this._dot4(s[Sn],Y,K,j,J));let _t=.6-ne*ne-Q*Q-ie*ie-he*he;return _t<0?f=0:(_t*=_t,f=_t*_t*this._dot4(s[He],ne,Q,ie,he)),27*(c+d+m+p+f)}_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 Re extends Ct{constructor(e,t,n=512,i=512,s,r,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=ya(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{type:_.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new _.ShaderMaterial({defines:Object.assign({},Dn.defines),uniforms:_.UniformsUtils.clone(Dn.uniforms),vertexShader:Dn.vertexShader,fragmentShader:Dn.fragmentShader,blending:_.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 _.MeshNormalMaterial,this.normalMaterial.blending=_.NoBlending,this.pdMaterial=new _.ShaderMaterial({defines:Object.assign({},En.defines),uniforms:_.UniformsUtils.clone(En.uniforms),vertexShader:En.vertexShader,fragmentShader:En.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 _.ShaderMaterial({defines:Object.assign({},kn.defines),uniforms:_.UniformsUtils.clone(kn.uniforms),vertexShader:kn.vertexShader,fragmentShader:kn.fragmentShader,blending:_.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this.blendMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(ki.uniforms),vertexShader:ki.vertexShader,fragmentShader:ki.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:_.CustomBlending,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Pn(null),this._originalClearColor=new _.Color,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),r!==void 0&&this.updateGtaoMaterial(r),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 _.DepthTexture,this.depthTexture.format=_.DepthStencilFormat,this.depthTexture.type=_.UnsignedInt248Type,this.normalRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{minFilter:_.NearestFilter,magFilter:_.NearestFilter,type:_.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=Gs(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 Re.OUTPUT.Off:break;case Re.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.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 Re.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.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 r=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(r)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=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(r)}_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 Ws,n=e*e*4,i=new Uint8Array(n);for(let r=0;r<e;r++)for(let a=0;a<e;a++){const l=r,h=a;i[(r*e+a)*4]=(t.noise(l,h)*.5+.5)*255,i[(r*e+a)*4+1]=(t.noise(l+e,h)*.5+.5)*255,i[(r*e+a)*4+2]=(t.noise(l,h+e)*.5+.5)*255,i[(r*e+a)*4+3]=(t.noise(l+e,h+e)*.5+.5)*255}const s=new _.DataTexture(i,e,e,_.RGBAFormat,_.UnsignedByteType);return s.wrapS=_.RepeatWrapping,s.wrapT=_.RepeatWrapping,s.needsUpdate=!0,s}}Re.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Ln={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new _.Vector2},cameraProjectionMatrix:{value:new _.Matrix4},cameraInverseProjectionMatrix:{value:new _.Matrix4},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:`
394
+ }`};function Gs(o,e,t){const n=wa(o,e,t);let i="vec3[SAMPLES](";for(let s=0;s<o;s++){const r=n[s];i+=`vec3(${r.x}, ${r.y}, ${r.z})${s<o-1?",":")"}`}return i}function wa(o,e,t){const n=[];for(let i=0;i<o;i++){const s=2*Math.PI*e*i/o,r=Math.pow(i/(o-1),t);n.push(new _.Vector3(Math.cos(s),Math.sin(s),r))}return n}class Ws{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 r=.5*(Math.sqrt(3)-1),a=(e+t)*r,l=Math.floor(e+a),c=Math.floor(t+a),h=(3-Math.sqrt(3))/6,d=(l+c)*h,m=l-d,p=c-d,f=e-m,u=t-p;let g,y;f>u?(g=1,y=0):(g=0,y=1);const v=f-g+h,w=u-y+h,x=f-1+2*h,M=u-1+2*h,T=l&255,P=c&255,k=this.perm[T+this.perm[P]]%12,D=this.perm[T+g+this.perm[P+y]]%12,E=this.perm[T+1+this.perm[P+1]]%12;let O=.5-f*f-u*u;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],f,u));let A=.5-v*v-w*w;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[D],v,w));let I=.5-x*x-M*M;return I<0?s=0:(I*=I,s=I*I*this._dot(this.grad3[E],x,M)),70*(n+i+s)}noise3d(e,t,n){let i,s,r,a;const c=(e+t+n)*.3333333333333333,h=Math.floor(e+c),d=Math.floor(t+c),m=Math.floor(n+c),p=1/6,f=(h+d+m)*p,u=h-f,g=d-f,y=m-f,v=e-u,w=t-g,x=n-y;let M,T,P,k,D,E;v>=w?w>=x?(M=1,T=0,P=0,k=1,D=1,E=0):v>=x?(M=1,T=0,P=0,k=1,D=0,E=1):(M=0,T=0,P=1,k=1,D=0,E=1):w<x?(M=0,T=0,P=1,k=0,D=1,E=1):v<x?(M=0,T=1,P=0,k=0,D=1,E=1):(M=0,T=1,P=0,k=1,D=1,E=0);const O=v-M+p,A=w-T+p,I=x-P+p,S=v-k+2*p,z=w-D+2*p,V=x-E+2*p,U=v-1+3*p,H=w-1+3*p,G=x-1+3*p,$=h&255,F=d&255,R=m&255,te=this.perm[$+this.perm[F+this.perm[R]]]%12,ee=this.perm[$+M+this.perm[F+T+this.perm[R+P]]]%12,q=this.perm[$+k+this.perm[F+D+this.perm[R+E]]]%12,ce=this.perm[$+1+this.perm[F+1+this.perm[R+1]]]%12;let fe=.6-v*v-w*w-x*x;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[te],v,w,x));let se=.6-O*O-A*A-I*I;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[ee],O,A,I));let oe=.6-S*S-z*z-V*V;oe<0?r=0:(oe*=oe,r=oe*oe*this._dot3(this.grad3[q],S,z,V));let ue=.6-U*U-H*H-G*G;return ue<0?a=0:(ue*=ue,a=ue*ue*this._dot3(this.grad3[ce],U,H,G)),32*(i+s+r+a)}noise4d(e,t,n,i){const s=this.grad4,r=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,d,m,p,f;const u=(e+t+n+i)*l,g=Math.floor(e+u),y=Math.floor(t+u),v=Math.floor(n+u),w=Math.floor(i+u),x=(g+y+v+w)*c,M=g-x,T=y-x,P=v-x,k=w-x,D=e-M,E=t-T,O=n-P,A=i-k,I=D>E?32:0,S=D>O?16:0,z=E>O?8:0,V=D>A?4:0,U=E>A?2:0,H=O>A?1:0,G=I+S+z+V+U+H,$=r[G][0]>=3?1:0,F=r[G][1]>=3?1:0,R=r[G][2]>=3?1:0,te=r[G][3]>=3?1:0,ee=r[G][0]>=2?1:0,q=r[G][1]>=2?1:0,ce=r[G][2]>=2?1:0,fe=r[G][3]>=2?1:0,se=r[G][0]>=1?1:0,oe=r[G][1]>=1?1:0,ue=r[G][2]>=1?1:0,pe=r[G][3]>=1?1:0,Ce=D-$+c,Be=E-F+c,C=O-R+c,Z=A-te+c,X=D-ee+2*c,B=E-q+2*c,L=O-ce+2*c,N=A-fe+2*c,Y=D-se+3*c,K=E-oe+3*c,j=O-ue+3*c,J=A-pe+3*c,ne=D-1+4*c,Q=E-1+4*c,ie=O-1+4*c,he=A-1+4*c,ae=g&255,Ae=y&255,$e=v&255,Ee=w&255,Ft=a[ae+a[Ae+a[$e+a[Ee]]]]%32,ge=a[ae+$+a[Ae+F+a[$e+R+a[Ee+te]]]]%32,nn=a[ae+ee+a[Ae+q+a[$e+ce+a[Ee+fe]]]]%32,Cn=a[ae+se+a[Ae+oe+a[$e+ue+a[Ee+pe]]]]%32,He=a[ae+1+a[Ae+1+a[$e+1+a[Ee+1]]]]%32;let Mt=.6-D*D-E*E-O*O-A*A;Mt<0?h=0:(Mt*=Mt,h=Mt*Mt*this._dot4(s[Ft],D,E,O,A));let Ut=.6-Ce*Ce-Be*Be-C*C-Z*Z;Ut<0?d=0:(Ut*=Ut,d=Ut*Ut*this._dot4(s[ge],Ce,Be,C,Z));let Vt=.6-X*X-B*B-L*L-N*N;Vt<0?m=0:(Vt*=Vt,m=Vt*Vt*this._dot4(s[nn],X,B,L,N));let jt=.6-Y*Y-K*K-j*j-J*J;jt<0?p=0:(jt*=jt,p=jt*jt*this._dot4(s[Cn],Y,K,j,J));let _t=.6-ne*ne-Q*Q-ie*ie-he*he;return _t<0?f=0:(_t*=_t,f=_t*_t*this._dot4(s[He],ne,Q,ie,he)),27*(h+d+m+p+f)}_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 Re extends Ct{constructor(e,t,n=512,i=512,s,r,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=ya(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{type:_.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new _.ShaderMaterial({defines:Object.assign({},kn.defines),uniforms:_.UniformsUtils.clone(kn.uniforms),vertexShader:kn.vertexShader,fragmentShader:kn.fragmentShader,blending:_.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 _.MeshNormalMaterial,this.normalMaterial.blending=_.NoBlending,this.pdMaterial=new _.ShaderMaterial({defines:Object.assign({},Ln.defines),uniforms:_.UniformsUtils.clone(Ln.uniforms),vertexShader:Ln.vertexShader,fragmentShader:Ln.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 _.ShaderMaterial({defines:Object.assign({},En.defines),uniforms:_.UniformsUtils.clone(En.uniforms),vertexShader:En.vertexShader,fragmentShader:En.fragmentShader,blending:_.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this.blendMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(Ei.uniforms),vertexShader:Ei.vertexShader,fragmentShader:Ei.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:_.CustomBlending,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Tn(null),this._originalClearColor=new _.Color,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),r!==void 0&&this.updateGtaoMaterial(r),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 _.DepthTexture,this.depthTexture.format=_.DepthStencilFormat,this.depthTexture.type=_.UnsignedInt248Type,this.normalRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{minFilter:_.NearestFilter,magFilter:_.NearestFilter,type:_.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=Gs(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 Re.OUTPUT.Off:break;case Re.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.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 Re.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.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 r=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(r)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=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(r)}_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 Ws,n=e*e*4,i=new Uint8Array(n);for(let r=0;r<e;r++)for(let a=0;a<e;a++){const l=r,c=a;i[(r*e+a)*4]=(t.noise(l,c)*.5+.5)*255,i[(r*e+a)*4+1]=(t.noise(l+e,c)*.5+.5)*255,i[(r*e+a)*4+2]=(t.noise(l,c+e)*.5+.5)*255,i[(r*e+a)*4+3]=(t.noise(l+e,c+e)*.5+.5)*255}const s=new _.DataTexture(i,e,e,_.RGBAFormat,_.UnsignedByteType);return s.wrapS=_.RepeatWrapping,s.wrapT=_.RepeatWrapping,s.needsUpdate=!0,s}}Re.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const In={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new _.Vector2},cameraProjectionMatrix:{value:new _.Matrix4},cameraInverseProjectionMatrix:{value:new _.Matrix4},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:`
395
395
 
396
396
  varying vec2 vUv;
397
397
 
@@ -531,7 +531,7 @@
531
531
 
532
532
  }
533
533
 
534
- }`},In={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`varying vec2 vUv;
534
+ }`},zn={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`varying vec2 vUv;
535
535
 
536
536
  void main() {
537
537
 
@@ -568,7 +568,7 @@
568
568
  float depth = getLinearDepth( vUv );
569
569
  gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
570
570
 
571
- }`},zn={uniforms:{tDiffuse:{value:null},resolution:{value:new _.Vector2}},vertexShader:`varying vec2 vUv;
571
+ }`},Bn={uniforms:{tDiffuse:{value:null},resolution:{value:new _.Vector2}},vertexShader:`varying vec2 vUv;
572
572
 
573
573
  void main() {
574
574
 
@@ -599,7 +599,7 @@
599
599
 
600
600
  gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );
601
601
 
602
- }`};class st extends Ct{constructor(e,t,n=512,i=512,s=32){super(),this.width=n,this.height=i,this.clear=!0,this.needsSwap=!1,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=[],this._generateSampleKernel(s),this._generateRandomKernelRotations();const r=new _.DepthTexture;r.format=_.DepthStencilFormat,r.type=_.UnsignedInt248Type,this.normalRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{minFilter:_.NearestFilter,magFilter:_.NearestFilter,type:_.HalfFloatType,depthTexture:r}),this.ssaoRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{type:_.HalfFloatType}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new _.ShaderMaterial({defines:Object.assign({},Ln.defines),uniforms:_.UniformsUtils.clone(Ln.uniforms),vertexShader:Ln.vertexShader,fragmentShader:Ln.fragmentShader,blending:_.NoBlending}),this.ssaoMaterial.defines.KERNEL_SIZE=s,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new _.MeshNormalMaterial,this.normalMaterial.blending=_.NoBlending,this.blurMaterial=new _.ShaderMaterial({defines:Object.assign({},zn.defines),uniforms:_.UniformsUtils.clone(zn.uniforms),vertexShader:zn.vertexShader,fragmentShader:zn.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new _.ShaderMaterial({defines:Object.assign({},In.defines),uniforms:_.UniformsUtils.clone(In.uniforms),vertexShader:In.vertexShader,fragmentShader:In.fragmentShader,blending:_.NoBlending}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Pn(null),this._originalClearColor=new _.Color}dispose(){this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}render(e,t,n){switch(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this._renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this._renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case st.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=_.CustomBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}setSize(e,t){this.width=e,this.height=t,this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(e,t)}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=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(r)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=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(r)}_generateSampleKernel(e){const t=this.kernel;for(let n=0;n<e;n++){const i=new _.Vector3;i.x=Math.random()*2-1,i.y=Math.random()*2-1,i.z=Math.random(),i.normalize();let s=n/e;s=_.MathUtils.lerp(.1,1,s*s),i.multiplyScalar(s),t.push(i)}}_generateRandomKernelRotations(){const n=new Ws,i=16,s=new Float32Array(i);for(let r=0;r<i;r++){const a=Math.random()*2-1,l=Math.random()*2-1,h=0;s[r]=n.noise3d(a,l,h)}this.noiseTexture=new _.DataTexture(s,4,4,_.RedFormat,_.FloatType),this.noiseTexture.wrapS=_.RepeatWrapping,this.noiseTexture.wrapT=_.RepeatWrapping,this.noiseTexture.needsUpdate=!0}_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}}st.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const Bn={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
602
+ }`};class st extends Ct{constructor(e,t,n=512,i=512,s=32){super(),this.width=n,this.height=i,this.clear=!0,this.needsSwap=!1,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=[],this._generateSampleKernel(s),this._generateRandomKernelRotations();const r=new _.DepthTexture;r.format=_.DepthStencilFormat,r.type=_.UnsignedInt248Type,this.normalRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{minFilter:_.NearestFilter,magFilter:_.NearestFilter,type:_.HalfFloatType,depthTexture:r}),this.ssaoRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{type:_.HalfFloatType}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new _.ShaderMaterial({defines:Object.assign({},In.defines),uniforms:_.UniformsUtils.clone(In.uniforms),vertexShader:In.vertexShader,fragmentShader:In.fragmentShader,blending:_.NoBlending}),this.ssaoMaterial.defines.KERNEL_SIZE=s,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new _.MeshNormalMaterial,this.normalMaterial.blending=_.NoBlending,this.blurMaterial=new _.ShaderMaterial({defines:Object.assign({},Bn.defines),uniforms:_.UniformsUtils.clone(Bn.uniforms),vertexShader:Bn.vertexShader,fragmentShader:Bn.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new _.ShaderMaterial({defines:Object.assign({},zn.defines),uniforms:_.UniformsUtils.clone(zn.uniforms),vertexShader:zn.vertexShader,fragmentShader:zn.fragmentShader,blending:_.NoBlending}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Tn(null),this._originalClearColor=new _.Color}dispose(){this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}render(e,t,n){switch(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this._renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this._renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case st.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case st.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=_.CustomBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}setSize(e,t){this.width=e,this.height=t,this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(e,t)}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=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(r)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=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(r)}_generateSampleKernel(e){const t=this.kernel;for(let n=0;n<e;n++){const i=new _.Vector3;i.x=Math.random()*2-1,i.y=Math.random()*2-1,i.z=Math.random(),i.normalize();let s=n/e;s=_.MathUtils.lerp(.1,1,s*s),i.multiplyScalar(s),t.push(i)}}_generateRandomKernelRotations(){const n=new Ws,i=16,s=new Float32Array(i);for(let r=0;r<i;r++){const a=Math.random()*2-1,l=Math.random()*2-1,c=0;s[r]=n.noise3d(a,l,c)}this.noiseTexture=new _.DataTexture(s,4,4,_.RedFormat,_.FloatType),this.noiseTexture.wrapS=_.RepeatWrapping,this.noiseTexture.wrapT=_.RepeatWrapping,this.noiseTexture.needsUpdate=!0}_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}}st.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const On={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
603
603
  precision highp float;
604
604
 
605
605
  uniform mat4 modelViewMatrix;
@@ -670,7 +670,7 @@
670
670
 
671
671
  #endif
672
672
 
673
- }`};class xa extends Ct{constructor(){super(),this.uniforms=_.UniformsUtils.clone(Bn.uniforms),this.material=new _.RawShaderMaterial({name:Bn.name,uniforms:this.uniforms,vertexShader:Bn.vertexShader,fragmentShader:Bn.fragmentShader}),this._fsQuad=new Pn(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={},_.ColorManagement.getTransfer(this._outputColorSpace)===_.SRGBTransfer&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===_.LinearToneMapping?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===_.ReinhardToneMapping?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===_.CineonToneMapping?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===_.ACESFilmicToneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===_.AgXToneMapping?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===_.NeutralToneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===_.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 ba={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new _.Vector2(1/1024,1/512)}},vertexShader:`
673
+ }`};class xa extends Ct{constructor(){super(),this.uniforms=_.UniformsUtils.clone(On.uniforms),this.material=new _.RawShaderMaterial({name:On.name,uniforms:this.uniforms,vertexShader:On.vertexShader,fragmentShader:On.fragmentShader}),this._fsQuad=new Tn(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={},_.ColorManagement.getTransfer(this._outputColorSpace)===_.SRGBTransfer&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===_.LinearToneMapping?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===_.ReinhardToneMapping?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===_.CineonToneMapping?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===_.ACESFilmicToneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===_.AgXToneMapping?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===_.NeutralToneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===_.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 ba={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new _.Vector2(1/1024,1/512)}},vertexShader:`
674
674
 
675
675
  varying vec2 vUv;
676
676
 
@@ -957,24 +957,24 @@
957
957
 
958
958
  gl_FragColor = color;
959
959
  }
960
- `};class _a{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;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 Tn&&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,r=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new b.WebGLRenderTarget(e,t,{minFilter:b.LinearFilter,magFilter:b.LinearFilter,format:b.RGBAFormat,samples:4});this.composer=new ma(s,a),this.composer.setPixelRatio(r),this.composer.setSize(e,t);const l=new ga(n,i);this.composer.addPass(l),this.gtaoPass=new Re(n,i,e,t),this.gtaoPass.output=Re.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.composer.addPass(this.gtaoPass),this.ssaoPass=new st(n,i,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=st.OUTPUT.Default,this.ssaoPass.enabled=!1,this.composer.addPass(this.ssaoPass),this.saturationPass=new Tn(Ma),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new xa,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new Tn(ba),this.fxaaPass.material.uniforms.resolution.value.x=1/(e*r),this.fxaaPass.material.uniforms.resolution.value.y=1/(t*r),this.fxaaPass.enabled=!1,this.composer.addPass(this.fxaaPass)}}var On=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xs(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Rn(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ei={exports:{}};var Zs;function Sa(){return Zs||(Zs=1,(function(o,e){(function(t){o.exports=t()})(function(){return(function t(n,i,s){function r(h,c){if(!i[h]){if(!n[h]){var d=typeof Rn=="function"&&Rn;if(!c&&d)return d(h,!0);if(a)return a(h,!0);var m=new Error("Cannot find module '"+h+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[h]={exports:{}};n[h][0].call(p.exports,function(f){var u=n[h][1][f];return r(u||f)},p,p.exports,t,n,i,s)}return i[h].exports}for(var a=typeof Rn=="function"&&Rn,l=0;l<s.length;l++)r(s[l]);return r})({1:[function(t,n,i){var s=t("./utils"),r=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var h,c,d,m,p,f,u,g=[],y=0,v=l.length,w=v,x=s.getTypeOf(l)!=="string";y<l.length;)w=v-y,d=x?(h=l[y++],c=y<v?l[y++]:0,y<v?l[y++]:0):(h=l.charCodeAt(y++),c=y<v?l.charCodeAt(y++):0,y<v?l.charCodeAt(y++):0),m=h>>2,p=(3&h)<<4|c>>4,f=1<w?(15&c)<<2|d>>6:64,u=2<w?63&d:64,g.push(a.charAt(m)+a.charAt(p)+a.charAt(f)+a.charAt(u));return g.join("")},i.decode=function(l){var h,c,d,m,p,f,u=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 v,w=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&w--,l.charAt(l.length-2)===a.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=r.uint8array?new Uint8Array(0|w):new Array(0|w);u<l.length;)h=a.indexOf(l.charAt(u++))<<2|(m=a.indexOf(l.charAt(u++)))>>4,c=(15&m)<<4|(p=a.indexOf(l.charAt(u++)))>>2,d=(3&p)<<6|(f=a.indexOf(l.charAt(u++))),v[g++]=h,p!==64&&(v[g++]=c),f!==64&&(v[g++]=d);return v}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function h(c,d,m,p,f){this.compressedSize=c,this.uncompressedSize=d,this.crc32=m,this.compression=p,this.compressedContent=f}h.prototype={getContentWorker:function(){var c=new r(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return c.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new r(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,d,m){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(m)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},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"),r=(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,d,m){var p=r,f=m+d;h^=-1;for(var u=m;u<f;u++)h=h>>>8^p[255&(h^c[u])];return-1^h})(0|l,a,a.length,0):(function(h,c,d,m){var p=r,f=m+d;h^=-1;for(var u=m;u<f;u++)h=h>>>8^p[255&(h^c.charCodeAt(u))];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",r=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),h=s?"uint8array":"array";function c(d,m){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=m,this.meta={}}i.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(h,d.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 r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(m){d.push({data:m,meta:d.meta})}},i.compressWorker=function(d){return new c("Deflate",d)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(p,f){var u,g="";for(u=0;u<f;u++)g+=String.fromCharCode(255&p),p>>>=8;return g}function r(p,f,u,g,y,v){var w,x,M=p.file,T=p.compression,P=v!==h.utf8encode,k=a.transformTo("string",v(M.name)),D=a.transformTo("string",h.utf8encode(M.name)),E=M.comment,O=a.transformTo("string",v(E)),A=a.transformTo("string",h.utf8encode(E)),I=D.length!==M.name.length,S=A.length!==E.length,z="",V="",U="",H=M.dir,G=M.date,$={crc32:0,compressedSize:0,uncompressedSize:0};f&&!u||($.crc32=p.crc32,$.compressedSize=p.compressedSize,$.uncompressedSize=p.uncompressedSize);var F=0;f&&(F|=8),P||!I&&!S||(F|=2048);var R=0,te=0;H&&(R|=16),y==="UNIX"?(te=798,R|=(function(q,ce){var fe=q;return q||(fe=ce?16893:33204),(65535&fe)<<16})(M.unixPermissions,H)):(te=20,R|=(function(q){return 63&(q||0)})(M.dosPermissions)),w=G.getUTCHours(),w<<=6,w|=G.getUTCMinutes(),w<<=5,w|=G.getUTCSeconds()/2,x=G.getUTCFullYear()-1980,x<<=4,x|=G.getUTCMonth()+1,x<<=5,x|=G.getUTCDate(),I&&(V=s(1,1)+s(c(k),4)+D,z+="up"+s(V.length,2)+V),S&&(U=s(1,1)+s(c(O),4)+A,z+="uc"+s(U.length,2)+U);var ee="";return ee+=`
961
- \0`,ee+=s(F,2),ee+=T.magic,ee+=s(w,2),ee+=s(x,2),ee+=s($.crc32,4),ee+=s($.compressedSize,4),ee+=s($.uncompressedSize,4),ee+=s(k.length,2),ee+=s(z.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ee+k+z,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+ee+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"),d=t("../signature");function m(p,f,u,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=u,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(m,l),m.prototype.push=function(p){var f=p.meta.percent||0,u=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:u?(f+100*(u-g-1))/u:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var f=this.streamFiles&&!p.file.dir;if(f){var u=r(p,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:u.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var f=this.streamFiles&&!p.file.dir,u=r(p,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(u.dirRecord),f)this.push({data:(function(g){return d.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:u.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,f=0;f<this.dirRecords.length;f++)this.push({data:this.dirRecords[f],meta:{percent:100}});var u=this.bytesWritten-p,g=(function(y,v,w,x,M){var T=a.transformTo("string",M(x));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(v,4)+s(w,4)+s(T.length,2)+T})(this.dirRecords.length,u,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var f=this;return p.on("data",function(u){f.processChunk(u)}),p.on("end",function(){f.closedSource(f.previous.streamInfo),f._sources.length?f.prepareNextSource():f.end()}),p.on("error",function(u){f.error(u)}),this},m.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))},m.prototype.error=function(p){var f=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var u=0;u<f.length;u++)try{f[u].error(p)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,f=0;f<p.length;f++)p[f].lock()},n.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),r=t("./ZipFileWorker");i.generateWorker=function(a,l,h){var c=new r(l.streamFiles,h,l.platform,l.encodeFileName),d=0;try{a.forEach(function(m,p){d++;var f=(function(v,w){var x=v||w,M=s[x];if(!M)throw new Error(x+" is not a valid compression method !");return M})(p.options.compression,l.compression),u=p.options.compressionOptions||l.compressionOptions||{},g=p.dir,y=p.date;p._compressWorker(f,u).withStreamInfo("file",{name:m,dir:g,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(c)}),c.entriesCount=d}catch(m){c.error(m)}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 r=new s;for(var a in this)typeof this[a]!="function"&&(r[a]=this[a]);return r}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(r,a){return new s().loadAsync(r,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"),r=t("./external"),a=t("./utf8"),l=t("./zipEntries"),h=t("./stream/Crc32Probe"),c=t("./nodejsUtils");function d(m){return new r.Promise(function(p,f){var u=m.decompressed.getContentWorker().pipe(new h);u.on("error",function(g){f(g)}).on("end",function(){u.streamInfo.crc32!==m.decompressed.crc32?f(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(m,p){var f=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(m)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(u){var g=new l(p);return g.load(u),g}).then(function(u){var g=[r.Promise.resolve(u)],y=u.files;if(p.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return r.Promise.all(g)}).then(function(u){for(var g=u.shift(),y=g.files,v=0;v<y.length;v++){var w=y[v],x=w.fileNameStr,M=s.resolve(w.fileNameStr);f.file(M,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(f.file(M).unsafeOriginalName=x)}return g.zipComment.length&&(f.comment=g.zipComment),f})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),r=t("../stream/GenericWorker");function a(l,h){r.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(h)}s.inherits(a,r),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!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.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 r(a,l,h){s.call(this,l),this._helper=a;var c=this;a.on("data",function(d,m){c.push(d)||c._helper.pause(),h&&h(m)}).on("error",function(d){c.emit("error",d)}).on("end",function(){c.push(null)})}t("../utils").inherits(r,s),r.prototype._read=function(){this._helper.resume()},n.exports=r},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,r);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,r)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var r=new Buffer(s);return r.fill(0),r},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(M,T,P){var k,D=a.getTypeOf(T),E=a.extend(P||{},c);E.date=E.date||new Date,E.compression!==null&&(E.compression=E.compression.toUpperCase()),typeof E.unixPermissions=="string"&&(E.unixPermissions=parseInt(E.unixPermissions,8)),E.unixPermissions&&16384&E.unixPermissions&&(E.dir=!0),E.dosPermissions&&16&E.dosPermissions&&(E.dir=!0),E.dir&&(M=y(M)),E.createFolders&&(k=g(M))&&v.call(this,k,!0);var O=D==="string"&&E.binary===!1&&E.base64===!1;P&&P.binary!==void 0||(E.binary=!O),(T instanceof d&&T.uncompressedSize===0||E.dir||!T||T.length===0)&&(E.base64=!1,E.binary=!0,T="",E.compression="STORE",D="string");var A=null;A=T instanceof d||T instanceof l?T:f.isNode&&f.isStream(T)?new u(M,T):a.prepareContent(M,T,E.binary,E.optimizedBinaryString,E.base64);var I=new m(M,A,E);this.files[M]=I}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),h=t("./stream/StreamHelper"),c=t("./defaults"),d=t("./compressedObject"),m=t("./zipObject"),p=t("./generate"),f=t("./nodejsUtils"),u=t("./nodejs/NodejsStreamInputAdapter"),g=function(M){M.slice(-1)==="/"&&(M=M.substring(0,M.length-1));var T=M.lastIndexOf("/");return 0<T?M.substring(0,T):""},y=function(M){return M.slice(-1)!=="/"&&(M+="/"),M},v=function(M,T){return T=T!==void 0?T:c.createFolders,M=y(M),this.files[M]||s.call(this,M,null,{dir:!0,createFolders:T}),this.files[M]};function w(M){return Object.prototype.toString.call(M)==="[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(M){var T,P,k;for(T in this.files)k=this.files[T],(P=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&M(P,k)},filter:function(M){var T=[];return this.forEach(function(P,k){M(P,k)&&T.push(k)}),T},file:function(M,T,P){if(arguments.length!==1)return M=this.root+M,s.call(this,M,T,P),this;if(w(M)){var k=M;return this.filter(function(E,O){return!O.dir&&k.test(E)})}var D=this.files[this.root+M];return D&&!D.dir?D:null},folder:function(M){if(!M)return this;if(w(M))return this.filter(function(D,E){return E.dir&&M.test(D)});var T=this.root+M,P=v.call(this,T),k=this.clone();return k.root=P.name,k},remove:function(M){M=this.root+M;var T=this.files[M];if(T||(M.slice(-1)!=="/"&&(M+="/"),T=this.files[M]),T&&!T.dir)delete this.files[M];else for(var P=this.filter(function(D,E){return E.name.slice(0,M.length)===M}),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(M){var T,P={};try{if((P=a.extend(M||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.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||"";T=p.generateWorker(this,P,k)}catch(D){(T=new l("error")).error(D)}return new h(T,P.type||"string",P.mimeType)},generateAsync:function(M,T){return this.generateInternalStream(M).accumulate(T)},generateNodeStream:function(M,T){return(M=M||{}).type||(M.type="nodebuffer"),this.generateInternalStream(M).toNodejsStream(T)}};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 r(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),d=a.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===h&&this.data[m+2]===c&&this.data[m+3]===d)return m-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),d=a.charCodeAt(3),m=this.readData(4);return l===m[0]&&h===m[1]&&c===m[2]&&d===m[3]},r.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=r},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var s=t("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.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=r},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.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=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.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=r},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.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=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),r=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),h=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");n.exports=function(d){var m=s.getTypeOf(d);return s.checkSupport(m),m!=="string"||r.uint8array?m==="nodebuffer"?new h(d):r.uint8array?new c(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../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"),r=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}r.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:r.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),r=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=r(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"),r=t("./GenericWorker");function a(l){r.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,r),a.prototype.processChunk=function(l){if(l){var h=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=h+l.data.length}r.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),r=t("./GenericWorker");function a(l){r.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,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.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(r){this.name=r||"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(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var l=0;l<this._listeners[r].length;l++)this._listeners[r][l].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(l){a.processChunk(l)}),r.on("end",function(){a.end()}),r.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 r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},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 r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),h=t("../support"),c=t("../external"),d=null;if(h.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(f,u){return new c.Promise(function(g,y){var v=[],w=f._internalType,x=f._outputType,M=f._mimeType;f.on("data",function(T,P){v.push(T),u&&u(P)}).on("error",function(T){v=[],y(T)}).on("end",function(){try{var T=(function(P,k,D){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",k),D);case"base64":return l.encode(k);default:return s.transformTo(P,k)}})(x,(function(P,k){var D,E=0,O=null,A=0;for(D=0;D<k.length;D++)A+=k[D].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(A),D=0;D<k.length;D++)O.set(k[D],E),E+=k[D].length;return O;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+P+"'")}})(w,v),M);g(T)}catch(P){y(P)}v=[]}).resume()})}function p(f,u,g){var y=u;switch(u){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=u,this._mimeType=g,s.checkSupport(y),this._worker=f.pipe(new r(y)),f.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}p.prototype={accumulate:function(f){return m(this,f)},on:function(f,u){var g=this;return f==="data"?this._worker.on(f,function(y){u.call(g,y.data,y.meta)}):this._worker.on(f,function(){s.delay(u,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(f){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},f)}},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 r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(s),i.blob=r.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"),r=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 d(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}i.utf8encode=function(p){return r.nodebuffer?a.newBufferFrom(p,"utf-8"):(function(f){var u,g,y,v,w,x=f.length,M=0;for(v=0;v<x;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),M+=g<128?1:g<2048?2:g<65536?3:4;for(u=r.uint8array?new Uint8Array(M):new Array(M),v=w=0;w<M;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?u[w++]=g:(g<2048?u[w++]=192|g>>>6:(g<65536?u[w++]=224|g>>>12:(u[w++]=240|g>>>18,u[w++]=128|g>>>12&63),u[w++]=128|g>>>6&63),u[w++]=128|63&g);return u})(p)},i.utf8decode=function(p){return r.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(f){var u,g,y,v,w=f.length,x=new Array(2*w);for(u=g=0;u<w;)if((y=f[u++])<128)x[g++]=y;else if(4<(v=h[y]))x[g++]=65533,u+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&u<w;)y=y<<6|63&f[u++],v--;1<v?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(r.uint8array?"uint8array":"array",p))},s.inherits(d,l),d.prototype.processChunk=function(p){var f=s.transformTo(r.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var u=f;(f=new Uint8Array(u.length+this.leftOver.length)).set(this.leftOver,0),f.set(u,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var g=(function(v,w){var x;for((w=w||v.length)>v.length&&(w=v.length),x=w-1;0<=x&&(192&v[x])==128;)x--;return x<0||x===0?w:x+h[v[x]]>w?x:w})(f),y=f;g!==f.length&&(r.uint8array?(y=f.subarray(0,g),this.leftOver=f.subarray(g,f.length)):(y=f.slice(0,g),this.leftOver=f.slice(g,f.length))),this.push({data:i.utf8decode(y),meta:p.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,s.inherits(m,l),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function h(u){return u}function c(u,g){for(var y=0;y<u.length;++y)g[y]=255&u.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(u,g){i.checkSupport("blob");try{return new Blob([u],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(u),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(u,g,y){var v=[],w=0,x=u.length;if(x<=y)return String.fromCharCode.apply(null,u);for(;w<x;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,u.slice(w,Math.min(w+y,x)))):v.push(String.fromCharCode.apply(null,u.subarray(w,Math.min(w+y,x)))),w+=y;return v.join("")},stringifyByChar:function(u){for(var g="",y=0;y<u.length;y++)g+=String.fromCharCode(u[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 m(u){var g=65536,y=i.getTypeOf(u),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(u,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(u)}function p(u,g){for(var y=0;y<u.length;y++)g[y]=u[y];return g}i.applyFromCharCode=m;var f={};f.string={string:h,array:function(u){return c(u,new Array(u.length))},arraybuffer:function(u){return f.string.uint8array(u).buffer},uint8array:function(u){return c(u,new Uint8Array(u.length))},nodebuffer:function(u){return c(u,a.allocBuffer(u.length))}},f.array={string:m,array:h,arraybuffer:function(u){return new Uint8Array(u).buffer},uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return a.newBufferFrom(u)}},f.arraybuffer={string:function(u){return m(new Uint8Array(u))},array:function(u){return p(new Uint8Array(u),new Array(u.byteLength))},arraybuffer:h,uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return a.newBufferFrom(new Uint8Array(u))}},f.uint8array={string:m,array:function(u){return p(u,new Array(u.length))},arraybuffer:function(u){return u.buffer},uint8array:h,nodebuffer:function(u){return a.newBufferFrom(u)}},f.nodebuffer={string:m,array:function(u){return p(u,new Array(u.length))},arraybuffer:function(u){return f.nodebuffer.uint8array(u).buffer},uint8array:function(u){return p(u,new Uint8Array(u.length))},nodebuffer:h},i.transformTo=function(u,g){if(g=g||"",!u)return g;i.checkSupport(u);var y=i.getTypeOf(g);return f[y][u](g)},i.resolve=function(u){for(var g=u.split("/"),y=[],v=0;v<g.length;v++){var w=g[v];w==="."||w===""&&v!==0&&v!==g.length-1||(w===".."?y.pop():y.push(w))}return y.join("/")},i.getTypeOf=function(u){return typeof u=="string"?"string":Object.prototype.toString.call(u)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(u)?"nodebuffer":s.uint8array&&u instanceof Uint8Array?"uint8array":s.arraybuffer&&u instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(u){if(!s[u.toLowerCase()])throw new Error(u+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(u){var g,y,v="";for(y=0;y<(u||"").length;y++)v+="\\x"+((g=u.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(u,g,y){setImmediate(function(){u.apply(y||null,g||[])})},i.inherits=function(u,g){function y(){}y.prototype=g.prototype,u.prototype=new y},i.extend=function(){var u,g,y={};for(u=0;u<arguments.length;u++)for(g in arguments[u])Object.prototype.hasOwnProperty.call(arguments[u],g)&&y[g]===void 0&&(y[g]=arguments[u][g]);return y},i.prepareContent=function(u,g,y,v,w){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(M,T){var P=new FileReader;P.onload=function(k){M(k.target.result)},P.onerror=function(k){T(k.target.error)},P.readAsArrayBuffer(x)}):x}).then(function(x){var M=i.getTypeOf(x);return M?(M==="arraybuffer"?x=i.transformTo("uint8array",x):M==="string"&&(w?x=r.decode(x):y&&v!==!0&&(x=(function(T){return c(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(x))),x):l.Promise.reject(new Error("Can't read the data of '"+u+"'. 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"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),h=t("./support");function c(d){this.files=[],this.loadOptions=d}c.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(m)+", expected "+r.pretty(d)+")")}},isSignature:function(d,m){var p=this.reader.index;this.reader.setIndex(d);var f=this.reader.readString(4)===m;return this.reader.setIndex(p),f},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 d=this.reader.readData(this.zipCommentLength),m=h.uint8array?"uint8array":"array",p=r.transformTo(m,d);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 d,m,p,f=this.zip64EndOfCentralSize-44;0<f;)d=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[d]={id:d,length:m,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 d,m;for(d=0;d<this.files.length;d++)m=this.files[d],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);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 d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<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(d);var m=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(d=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(d),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 f=m-p;if(0<f)this.isSignature(m,a.CENTRAL_FILE_HEADER)||(this.reader.zero=f);else if(f<0)throw new Error("Corrupted zip: missing "+Math.abs(f)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),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"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),h=t("./utf8"),c=t("./compressions"),d=t("./support");function m(p,f){this.options=p,this.loadOptions=f}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var f,u;if(p.skip(22),this.fileNameLength=p.readInt(2),u=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(u),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((f=(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 "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,f,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 f=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(f),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===r.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var f,u,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)f=p.readInt(2),u=p.readInt(2),g=p.readData(u),this.extraFields[f]={id:f,length:u,value:g};p.setIndex(y)},handleUTF8:function(){var p=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=h.utf8decode(this.fileName),this.fileCommentStr=h.utf8decode(this.fileComment);else{var f=this.findExtraFieldUnicodePath();if(f!==null)this.fileNameStr=f;else{var u=r.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(u)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=r.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileName)!==f.readInt(4)?null:h.utf8decode(f.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileComment)!==f.readInt(4)?null:h.utf8decode(f.readData(p.length-5))}return null}},n.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(f,u,g){this.name=f,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=u,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),h=t("./compressedObject"),c=t("./stream/GenericWorker");s.prototype={internalStream:function(f){var u=null,g="string";try{if(!f)throw new Error("No output type specified.");var y=(g=f.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),u=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(u=u.pipe(new l.Utf8EncodeWorker)),!v&&y&&(u=u.pipe(new l.Utf8DecodeWorker))}catch(w){(u=new c("error")).error(w)}return new r(u,g,"")},async:function(f,u){return this.internalStream(f).accumulate(u)},nodeStream:function(f,u){return this.internalStream(f||"nodebuffer").toNodejsStream(u)},_compressWorker:function(f,u){if(this._data instanceof h&&this._data.compression.magic===f.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),h.createWorkerFrom(g,f,u)},_decompressWorker:function(){return this._data instanceof h?this._data.getContentWorker():this._data instanceof c?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<d.length;p++)s.prototype[d[p]]=m;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var r,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var h=0,c=new l(f),d=s.document.createTextNode("");c.observe(d,{characterData:!0}),r=function(){d.data=h=++h%2}}else if(s.setImmediate||s.MessageChannel===void 0)r="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var u=s.document.createElement("script");u.onreadystatechange=function(){f(),u.onreadystatechange=null,u.parentNode.removeChild(u),u=null},s.document.documentElement.appendChild(u)}:function(){setTimeout(f,0)};else{var m=new s.MessageChannel;m.port1.onmessage=f,r=function(){m.port2.postMessage(0)}}var p=[];function f(){var u,g;a=!0;for(var y=p.length;y;){for(g=p,p=[],u=-1;++u<y;)g[u]();y=p.length}a=!1}n.exports=function(u){p.push(u)!==1||a||r()}}).call(this,typeof On<"u"?On:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var s=t("immediate");function r(){}var a={},l=["REJECTED"],h=["FULFILLED"],c=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,y!==r&&u(this,y)}function m(y,v,w){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(y,v,w){s(function(){var x;try{x=v(w)}catch(M){return a.reject(y,M)}x===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,x)})}function f(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function u(y,v){var w=!1;function x(P){w||(w=!0,a.reject(y,P))}function M(P){w||(w=!0,a.resolve(y,P))}var T=g(function(){v(M,x)});T.status==="error"&&x(T.value)}function g(y,v){var w={};try{w.value=y(v),w.status="success"}catch(x){w.status="error",w.value=x}return w}(n.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(w){return v.resolve(y()).then(function(){return w})},function(w){return v.resolve(y()).then(function(){throw w})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===h||typeof v!="function"&&this.state===l)return this;var w=new this.constructor(r);return this.state!==c?p(w,this.state===h?y:v,this.outcome):this.queue.push(new m(w,y,v)),w},m.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},m.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},m.prototype.callRejected=function(y){a.reject(this.promise,y)},m.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},a.resolve=function(y,v){var w=g(f,v);if(w.status==="error")return a.reject(y,w.value);var x=w.value;if(x)u(y,x);else{y.state=h,y.outcome=v;for(var M=-1,T=y.queue.length;++M<T;)y.queue[M].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var w=-1,x=y.queue.length;++w<x;)y.queue[w].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(r),y)},d.reject=function(y){var v=new this(r);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,x=!1;if(!w)return this.resolve([]);for(var M=new Array(w),T=0,P=-1,k=new this(r);++P<w;)D(y[P],P);return k;function D(E,O){v.resolve(E).then(function(A){M[O]=A,++T!==w||x||(x=!0,a.resolve(k,M))},function(A){x||(x=!0,a.reject(k,A))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,x=!1;if(!w)return this.resolve([]);for(var M=-1,T=new this(r);++M<w;)P=y[M],v.resolve(P).then(function(k){x||(x=!0,a.resolve(T,k))},function(k){x||(x=!0,a.reject(T,k))});var P;return T}},{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"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),h=t("./zlib/zstream"),c=Object.prototype.toString,d=0,m=-1,p=0,f=8;function u(y){if(!(this instanceof u))return new u(y);this.options=r.assign({level:m,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var w=s.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(w!==d)throw new Error(l[w]);if(v.header&&s.deflateSetHeader(this.strm,v.header),v.dictionary){var x;if(x=typeof v.dictionary=="string"?a.string2buf(v.dictionary):c.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(w=s.deflateSetDictionary(this.strm,x))!==d)throw new Error(l[w]);this._dict_set=!0}}function g(y,v){var w=new u(v);if(w.push(y,!0),w.err)throw w.msg||l[w.err];return w.result}u.prototype.push=function(y,v){var w,x,M=this.strm,T=this.options.chunkSize;if(this.ended)return!1;x=v===~~v?v:v===!0?4:0,typeof y=="string"?M.input=a.string2buf(y):c.call(y)==="[object ArrayBuffer]"?M.input=new Uint8Array(y):M.input=y,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new r.Buf8(T),M.next_out=0,M.avail_out=T),(w=s.deflate(M,x))!==1&&w!==d)return this.onEnd(w),!(this.ended=!0);M.avail_out!==0&&(M.avail_in!==0||x!==4&&x!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(r.shrinkBuf(M.output,M.next_out))):this.onData(r.shrinkBuf(M.output,M.next_out)))}while((0<M.avail_in||M.avail_out===0)&&w!==1);return x===4?(w=s.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===d):x!==2||(this.onEnd(d),!(M.avail_out=0))},u.prototype.onData=function(y){this.chunks.push(y)},u.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=u,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./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"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),c=t("./zlib/zstream"),d=t("./zlib/gzheader"),m=Object.prototype.toString;function p(u){if(!(this instanceof p))return new p(u);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},u||{});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)||u&&u.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 d,s.inflateGetHeader(this.strm,this.header)}function f(u,g){var y=new p(g);if(y.push(u,!0),y.err)throw y.msg||h[y.err];return y.result}p.prototype.push=function(u,g){var y,v,w,x,M,T,P=this.strm,k=this.options.chunkSize,D=this.options.dictionary,E=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof u=="string"?P.input=a.binstring2buf(u):m.call(u)==="[object ArrayBuffer]"?P.input=new Uint8Array(u):P.input=u,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new r.Buf8(k),P.next_out=0,P.avail_out=k),(y=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&D&&(T=typeof D=="string"?a.string2buf(D):m.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,y=s.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&E===!0&&(y=l.Z_OK,E=!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||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=a.utf8border(P.output,P.next_out),x=P.next_out-w,M=a.buf2string(P.output,w),P.next_out=x,P.avail_out=k-x,x&&r.arraySet(P.output,P.output,w,x,0),this.onData(M)):this.onData(r.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(E=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},p.prototype.onData=function(u){this.chunks.push(u)},p.prototype.onEnd=function(u){u===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg},i.Inflate=p,i.inflate=f,i.inflateRaw=function(u,g){return(g=g||{}).raw=!0,f(u,g)},i.ungzip=f},{"./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 d in c)c.hasOwnProperty(d)&&(l[d]=c[d])}}return l},i.shrinkBuf=function(l,h){return l.length===h?l:l.subarray?l.subarray(0,h):(l.length=h,l)};var r={arraySet:function(l,h,c,d,m){if(h.subarray&&l.subarray)l.set(h.subarray(c,c+d),m);else for(var p=0;p<d;p++)l[m+p]=h[c+p]},flattenChunks:function(l){var h,c,d,m,p,f;for(h=d=0,c=l.length;h<c;h++)d+=l[h].length;for(f=new Uint8Array(d),h=m=0,c=l.length;h<c;h++)p=l[h],f.set(p,m),m+=p.length;return f}},a={arraySet:function(l,h,c,d,m){for(var p=0;p<d;p++)l[m+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,r)):(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"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!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(d,m){if(m<65537&&(d.subarray&&a||!d.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(d,m));for(var p="",f=0;f<m;f++)p+=String.fromCharCode(d[f]);return p}l[254]=l[254]=1,i.string2buf=function(d){var m,p,f,u,g,y=d.length,v=0;for(u=0;u<y;u++)(64512&(p=d.charCodeAt(u)))==55296&&u+1<y&&(64512&(f=d.charCodeAt(u+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),u++),v+=p<128?1:p<2048?2:p<65536?3:4;for(m=new s.Buf8(v),u=g=0;g<v;u++)(64512&(p=d.charCodeAt(u)))==55296&&u+1<y&&(64512&(f=d.charCodeAt(u+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),u++),p<128?m[g++]=p:(p<2048?m[g++]=192|p>>>6:(p<65536?m[g++]=224|p>>>12:(m[g++]=240|p>>>18,m[g++]=128|p>>>12&63),m[g++]=128|p>>>6&63),m[g++]=128|63&p);return m},i.buf2binstring=function(d){return c(d,d.length)},i.binstring2buf=function(d){for(var m=new s.Buf8(d.length),p=0,f=m.length;p<f;p++)m[p]=d.charCodeAt(p);return m},i.buf2string=function(d,m){var p,f,u,g,y=m||d.length,v=new Array(2*y);for(p=f=0;p<y;)if((u=d[p++])<128)v[f++]=u;else if(4<(g=l[u]))v[f++]=65533,p+=g-1;else{for(u&=g===2?31:g===3?15:7;1<g&&p<y;)u=u<<6|63&d[p++],g--;1<g?v[f++]=65533:u<65536?v[f++]=u:(u-=65536,v[f++]=55296|u>>10&1023,v[f++]=56320|1023&u)}return c(v,f)},i.utf8border=function(d,m){var p;for((m=m||d.length)>d.length&&(m=d.length),p=m-1;0<=p&&(192&d[p])==128;)p--;return p<0||p===0?m:p+l[d[p]]>m?p:m}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,r,a,l){for(var h=65535&s|0,c=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;c=c+(h=h+r[l++]|0)|0,--d;);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 r,a=[],l=0;l<256;l++){r=l;for(var h=0;h<8;h++)r=1&r?3988292384^r>>>1:r>>>1;a[l]=r}return a})();n.exports=function(r,a,l,h){var c=s,d=h+l;r^=-1;for(var m=h;m<d;m++)r=r>>>8^c[255&(r^a[m])];return-1^r}},{}],46:[function(t,n,i){var s,r=t("../utils/common"),a=t("./trees"),l=t("./adler32"),h=t("./crc32"),c=t("./messages"),d=0,m=4,p=0,f=-2,u=-1,g=4,y=2,v=8,w=9,x=286,M=30,T=19,P=2*x+1,k=15,D=3,E=258,O=E+D+1,A=42,I=113,S=1,z=2,V=3,U=4;function H(C,Z){return C.msg=c[Z],Z}function G(C){return(C<<1)-(4<C?9:0)}function $(C){for(var Z=C.length;0<=--Z;)C[Z]=0}function F(C){var Z=C.state,X=Z.pending;X>C.avail_out&&(X=C.avail_out),X!==0&&(r.arraySet(C.output,Z.pending_buf,Z.pending_out,X,C.next_out),C.next_out+=X,Z.pending_out+=X,C.total_out+=X,C.avail_out-=X,Z.pending-=X,Z.pending===0&&(Z.pending_out=0))}function R(C,Z){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,Z),C.block_start=C.strstart,F(C.strm)}function te(C,Z){C.pending_buf[C.pending++]=Z}function ee(C,Z){C.pending_buf[C.pending++]=Z>>>8&255,C.pending_buf[C.pending++]=255&Z}function q(C,Z){var X,B,L=C.max_chain_length,N=C.strstart,Y=C.prev_length,K=C.nice_match,j=C.strstart>C.w_size-O?C.strstart-(C.w_size-O):0,J=C.window,ne=C.w_mask,Q=C.prev,ie=C.strstart+E,he=J[N+Y-1],ae=J[N+Y];C.prev_length>=C.good_match&&(L>>=2),K>C.lookahead&&(K=C.lookahead);do if(J[(X=Z)+Y]===ae&&J[X+Y-1]===he&&J[X]===J[N]&&J[++X]===J[N+1]){N+=2,X++;do;while(J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&N<ie);if(B=E-(ie-N),N=ie-E,Y<B){if(C.match_start=Z,K<=(Y=B))break;he=J[N+Y-1],ae=J[N+Y]}}while((Z=Q[Z&ne])>j&&--L!=0);return Y<=C.lookahead?Y:C.lookahead}function ce(C){var Z,X,B,L,N,Y,K,j,J,ne,Q=C.w_size;do{if(L=C.window_size-C.lookahead-C.strstart,C.strstart>=Q+(Q-O)){for(r.arraySet(C.window,C.window,Q,Q,0),C.match_start-=Q,C.strstart-=Q,C.block_start-=Q,Z=X=C.hash_size;B=C.head[--Z],C.head[Z]=Q<=B?B-Q:0,--X;);for(Z=X=Q;B=C.prev[--Z],C.prev[Z]=Q<=B?B-Q:0,--X;);L+=Q}if(C.strm.avail_in===0)break;if(Y=C.strm,K=C.window,j=C.strstart+C.lookahead,J=L,ne=void 0,ne=Y.avail_in,J<ne&&(ne=J),X=ne===0?0:(Y.avail_in-=ne,r.arraySet(K,Y.input,Y.next_in,ne,j),Y.state.wrap===1?Y.adler=l(Y.adler,K,ne,j):Y.state.wrap===2&&(Y.adler=h(Y.adler,K,ne,j)),Y.next_in+=ne,Y.total_in+=ne,ne),C.lookahead+=X,C.lookahead+C.insert>=D)for(N=C.strstart-C.insert,C.ins_h=C.window[N],C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+D-1])&C.hash_mask,C.prev[N&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=N,N++,C.insert--,!(C.lookahead+C.insert<D)););}while(C.lookahead<O&&C.strm.avail_in!==0)}function fe(C,Z){for(var X,B;;){if(C.lookahead<O){if(ce(C),C.lookahead<O&&Z===d)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=D&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),X!==0&&C.strstart-X<=C.w_size-O&&(C.match_length=q(C,X)),C.match_length>=D)if(B=a._tr_tally(C,C.strstart-C.match_start,C.match_length-D),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=D){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,--C.match_length!=0;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else B=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(B&&(R(C,!1),C.strm.avail_out===0))return S}return C.insert=C.strstart<D-1?C.strstart:D-1,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?S:z}function se(C,Z){for(var X,B,L;;){if(C.lookahead<O){if(ce(C),C.lookahead<O&&Z===d)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=D&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=D-1,X!==0&&C.prev_length<C.max_lazy_match&&C.strstart-X<=C.w_size-O&&(C.match_length=q(C,X),C.match_length<=5&&(C.strategy===1||C.match_length===D&&4096<C.strstart-C.match_start)&&(C.match_length=D-1)),C.prev_length>=D&&C.match_length<=C.prev_length){for(L=C.strstart+C.lookahead-D,B=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-D),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=L&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),--C.prev_length!=0;);if(C.match_available=0,C.match_length=D-1,C.strstart++,B&&(R(C,!1),C.strm.avail_out===0))return S}else if(C.match_available){if((B=a._tr_tally(C,0,C.window[C.strstart-1]))&&R(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return S}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(B=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<D-1?C.strstart:D-1,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?S:z}function oe(C,Z,X,B,L){this.good_length=C,this.max_lazy=Z,this.nice_length=X,this.max_chain=B,this.func=L}function ue(){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=v,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 r.Buf16(2*P),this.dyn_dtree=new r.Buf16(2*(2*M+1)),this.bl_tree=new r.Buf16(2*(2*T+1)),$(this.dyn_ltree),$(this.dyn_dtree),$(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(k+1),this.heap=new r.Buf16(2*x+1),$(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*x+1),$(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(C){var Z;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=y,(Z=C.state).pending=0,Z.pending_out=0,Z.wrap<0&&(Z.wrap=-Z.wrap),Z.status=Z.wrap?A:I,C.adler=Z.wrap===2?0:1,Z.last_flush=d,a._tr_init(Z),p):H(C,f)}function Ce(C){var Z=pe(C);return Z===p&&(function(X){X.window_size=2*X.w_size,$(X.head),X.max_lazy_match=s[X.level].max_lazy,X.good_match=s[X.level].good_length,X.nice_match=s[X.level].nice_length,X.max_chain_length=s[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=D-1,X.match_available=0,X.ins_h=0})(C.state),Z}function Be(C,Z,X,B,L,N){if(!C)return f;var Y=1;if(Z===u&&(Z=6),B<0?(Y=0,B=-B):15<B&&(Y=2,B-=16),L<1||w<L||X!==v||B<8||15<B||Z<0||9<Z||N<0||g<N)return H(C,f);B===8&&(B=9);var K=new ue;return(C.state=K).strm=C,K.wrap=Y,K.gzhead=null,K.w_bits=B,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=L+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+D-1)/D),K.window=new r.Buf8(2*K.w_size),K.head=new r.Buf16(K.hash_size),K.prev=new r.Buf16(K.w_size),K.lit_bufsize=1<<L+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new r.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=Z,K.strategy=N,K.method=X,Ce(C)}s=[new oe(0,0,0,0,function(C,Z){var X=65535;for(X>C.pending_buf_size-5&&(X=C.pending_buf_size-5);;){if(C.lookahead<=1){if(ce(C),C.lookahead===0&&Z===d)return S;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var B=C.block_start+X;if((C.strstart===0||C.strstart>=B)&&(C.lookahead=C.strstart-B,C.strstart=B,R(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-O&&(R(C,!1),C.strm.avail_out===0))return S}return C.insert=0,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):(C.strstart>C.block_start&&(R(C,!1),C.strm.avail_out),S)}),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(C,Z){return Be(C,Z,v,15,8,0)},i.deflateInit2=Be,i.deflateReset=Ce,i.deflateResetKeep=pe,i.deflateSetHeader=function(C,Z){return C&&C.state?C.state.wrap!==2?f:(C.state.gzhead=Z,p):f},i.deflate=function(C,Z){var X,B,L,N;if(!C||!C.state||5<Z||Z<0)return C?H(C,f):f;if(B=C.state,!C.output||!C.input&&C.avail_in!==0||B.status===666&&Z!==m)return H(C,C.avail_out===0?-5:f);if(B.strm=C,X=B.last_flush,B.last_flush=Z,B.status===A)if(B.wrap===2)C.adler=0,te(B,31),te(B,139),te(B,8),B.gzhead?(te(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),te(B,255&B.gzhead.time),te(B,B.gzhead.time>>8&255),te(B,B.gzhead.time>>16&255),te(B,B.gzhead.time>>24&255),te(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),te(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(te(B,255&B.gzhead.extra.length),te(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(C.adler=h(C.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(te(B,0),te(B,0),te(B,0),te(B,0),te(B,0),te(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),te(B,3),B.status=I);else{var Y=v+(B.w_bits-8<<4)<<8;Y|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Y|=32),Y+=31-Y%31,B.status=I,ee(B,Y),B.strstart!==0&&(ee(B,C.adler>>>16),ee(B,65535&C.adler)),C.adler=1}if(B.status===69)if(B.gzhead.extra){for(L=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>L&&(C.adler=h(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending!==B.pending_buf_size));)te(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>L&&(C.adler=h(C.adler,B.pending_buf,B.pending-L,L)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=h(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending===B.pending_buf_size)){N=1;break}N=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,te(B,N)}while(N!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=h(C.adler,B.pending_buf,B.pending-L,L)),N===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=h(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending===B.pending_buf_size)){N=1;break}N=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,te(B,N)}while(N!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=h(C.adler,B.pending_buf,B.pending-L,L)),N===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&F(C),B.pending+2<=B.pending_buf_size&&(te(B,255&C.adler),te(B,C.adler>>8&255),C.adler=0,B.status=I)):B.status=I),B.pending!==0){if(F(C),C.avail_out===0)return B.last_flush=-1,p}else if(C.avail_in===0&&G(Z)<=G(X)&&Z!==m)return H(C,-5);if(B.status===666&&C.avail_in!==0)return H(C,-5);if(C.avail_in!==0||B.lookahead!==0||Z!==d&&B.status!==666){var K=B.strategy===2?(function(j,J){for(var ne;;){if(j.lookahead===0&&(ce(j),j.lookahead===0)){if(J===d)return S;break}if(j.match_length=0,ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++,ne&&(R(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(R(j,!0),j.strm.avail_out===0?V:U):j.last_lit&&(R(j,!1),j.strm.avail_out===0)?S:z})(B,Z):B.strategy===3?(function(j,J){for(var ne,Q,ie,he,ae=j.window;;){if(j.lookahead<=E){if(ce(j),j.lookahead<=E&&J===d)return S;if(j.lookahead===0)break}if(j.match_length=0,j.lookahead>=D&&0<j.strstart&&(Q=ae[ie=j.strstart-1])===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]){he=j.strstart+E;do;while(Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&ie<he);j.match_length=E-(he-ie),j.match_length>j.lookahead&&(j.match_length=j.lookahead)}if(j.match_length>=D?(ne=a._tr_tally(j,1,j.match_length-D),j.lookahead-=j.match_length,j.strstart+=j.match_length,j.match_length=0):(ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++),ne&&(R(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(R(j,!0),j.strm.avail_out===0?V:U):j.last_lit&&(R(j,!1),j.strm.avail_out===0)?S:z})(B,Z):s[B.level].func(B,Z);if(K!==V&&K!==U||(B.status=666),K===S||K===V)return C.avail_out===0&&(B.last_flush=-1),p;if(K===z&&(Z===1?a._tr_align(B):Z!==5&&(a._tr_stored_block(B,0,0,!1),Z===3&&($(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),F(C),C.avail_out===0))return B.last_flush=-1,p}return Z!==m?p:B.wrap<=0?1:(B.wrap===2?(te(B,255&C.adler),te(B,C.adler>>8&255),te(B,C.adler>>16&255),te(B,C.adler>>24&255),te(B,255&C.total_in),te(B,C.total_in>>8&255),te(B,C.total_in>>16&255),te(B,C.total_in>>24&255)):(ee(B,C.adler>>>16),ee(B,65535&C.adler)),F(C),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(C){var Z;return C&&C.state?(Z=C.state.status)!==A&&Z!==69&&Z!==73&&Z!==91&&Z!==103&&Z!==I&&Z!==666?H(C,f):(C.state=null,Z===I?H(C,-3):p):f},i.deflateSetDictionary=function(C,Z){var X,B,L,N,Y,K,j,J,ne=Z.length;if(!C||!C.state||(N=(X=C.state).wrap)===2||N===1&&X.status!==A||X.lookahead)return f;for(N===1&&(C.adler=l(C.adler,Z,ne,0)),X.wrap=0,ne>=X.w_size&&(N===0&&($(X.head),X.strstart=0,X.block_start=0,X.insert=0),J=new r.Buf8(X.w_size),r.arraySet(J,Z,ne-X.w_size,X.w_size,0),Z=J,ne=X.w_size),Y=C.avail_in,K=C.next_in,j=C.input,C.avail_in=ne,C.next_in=0,C.input=Z,ce(X);X.lookahead>=D;){for(B=X.strstart,L=X.lookahead-(D-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[B+D-1])&X.hash_mask,X.prev[B&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=B,B++,--L;);X.strstart=B,X.lookahead=D-1,ce(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=D-1,X.match_available=0,C.next_in=K,C.input=j,C.avail_in=Y,X.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,r){var a,l,h,c,d,m,p,f,u,g,y,v,w,x,M,T,P,k,D,E,O,A,I,S,z;a=s.state,l=s.next_in,S=s.input,h=l+(s.avail_in-5),c=s.next_out,z=s.output,d=c-(r-s.avail_out),m=c+(s.avail_out-257),p=a.dmax,f=a.wsize,u=a.whave,g=a.wnext,y=a.window,v=a.hold,w=a.bits,x=a.lencode,M=a.distcode,T=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{w<15&&(v+=S[l++]<<w,w+=8,v+=S[l++]<<w,w+=8),k=x[v&T];t:for(;;){if(v>>>=D=k>>>24,w-=D,(D=k>>>16&255)===0)z[c++]=65535&k;else{if(!(16&D)){if((64&D)==0){k=x[(65535&k)+(v&(1<<D)-1)];continue t}if(32&D){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}E=65535&k,(D&=15)&&(w<D&&(v+=S[l++]<<w,w+=8),E+=v&(1<<D)-1,v>>>=D,w-=D),w<15&&(v+=S[l++]<<w,w+=8,v+=S[l++]<<w,w+=8),k=M[v&P];n:for(;;){if(v>>>=D=k>>>24,w-=D,!(16&(D=k>>>16&255))){if((64&D)==0){k=M[(65535&k)+(v&(1<<D)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,w<(D&=15)&&(v+=S[l++]<<w,(w+=8)<D&&(v+=S[l++]<<w,w+=8)),p<(O+=v&(1<<D)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=D,w-=D,(D=c-d)<O){if(u<(D=O-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=y,(A=0)===g){if(A+=f-D,D<E){for(E-=D;z[c++]=y[A++],--D;);A=c-O,I=z}}else if(g<D){if(A+=f+g-D,(D-=g)<E){for(E-=D;z[c++]=y[A++],--D;);if(A=0,g<E){for(E-=D=g;z[c++]=y[A++],--D;);A=c-O,I=z}}}else if(A+=g-D,D<E){for(E-=D;z[c++]=y[A++],--D;);A=c-O,I=z}for(;2<E;)z[c++]=I[A++],z[c++]=I[A++],z[c++]=I[A++],E-=3;E&&(z[c++]=I[A++],1<E&&(z[c++]=I[A++]))}else{for(A=c-O;z[c++]=z[A++],z[c++]=z[A++],z[c++]=z[A++],2<(E-=3););E&&(z[c++]=z[A++],1<E&&(z[c++]=z[A++]))}break}}break}}while(l<h&&c<m);l-=E=w>>3,v&=(1<<(w-=E<<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<m?m-c+257:257-(c-m),a.hold=v,a.bits=w}},{}],49:[function(t,n,i){var s=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),h=t("./inftrees"),c=1,d=2,m=0,p=-2,f=1,u=852,g=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function v(){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 w(A){var I;return A&&A.state?(I=A.state,A.total_in=A.total_out=I.total=0,A.msg="",I.wrap&&(A.adler=1&I.wrap),I.mode=f,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new s.Buf32(u),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,m):p}function x(A){var I;return A&&A.state?((I=A.state).wsize=0,I.whave=0,I.wnext=0,w(A)):p}function M(A,I){var S,z;return A&&A.state?(z=A.state,I<0?(S=0,I=-I):(S=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?p:(z.window!==null&&z.wbits!==I&&(z.window=null),z.wrap=S,z.wbits=I,x(A))):p}function T(A,I){var S,z;return A?(z=new v,(A.state=z).window=null,(S=M(A,I))!==m&&(A.state=null),S):p}var P,k,D=!0;function E(A){if(D){var I;for(P=new s.Buf32(512),k=new s.Buf32(32),I=0;I<144;)A.lens[I++]=8;for(;I<256;)A.lens[I++]=9;for(;I<280;)A.lens[I++]=7;for(;I<288;)A.lens[I++]=8;for(h(c,A.lens,0,288,P,0,A.work,{bits:9}),I=0;I<32;)A.lens[I++]=5;h(d,A.lens,0,32,k,0,A.work,{bits:5}),D=!1}A.lencode=P,A.lenbits=9,A.distcode=k,A.distbits=5}function O(A,I,S,z){var V,U=A.state;return U.window===null&&(U.wsize=1<<U.wbits,U.wnext=0,U.whave=0,U.window=new s.Buf8(U.wsize)),z>=U.wsize?(s.arraySet(U.window,I,S-U.wsize,U.wsize,0),U.wnext=0,U.whave=U.wsize):(z<(V=U.wsize-U.wnext)&&(V=z),s.arraySet(U.window,I,S-z,V,U.wnext),(z-=V)?(s.arraySet(U.window,I,S-z,z,0),U.wnext=z,U.whave=U.wsize):(U.wnext+=V,U.wnext===U.wsize&&(U.wnext=0),U.whave<U.wsize&&(U.whave+=V))),0}i.inflateReset=x,i.inflateReset2=M,i.inflateResetKeep=w,i.inflateInit=function(A){return T(A,15)},i.inflateInit2=T,i.inflate=function(A,I){var S,z,V,U,H,G,$,F,R,te,ee,q,ce,fe,se,oe,ue,pe,Ce,Be,C,Z,X,B,L=0,N=new s.Buf8(4),Y=[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;(S=A.state).mode===12&&(S.mode=13),H=A.next_out,V=A.output,$=A.avail_out,U=A.next_in,z=A.input,G=A.avail_in,F=S.hold,R=S.bits,te=G,ee=$,Z=m;e:for(;;)switch(S.mode){case f:if(S.wrap===0){S.mode=13;break}for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(2&S.wrap&&F===35615){N[S.check=0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0),R=F=0,S.mode=2;break}if(S.flags=0,S.head&&(S.head.done=!1),!(1&S.wrap)||(((255&F)<<8)+(F>>8))%31){A.msg="incorrect header check",S.mode=30;break}if((15&F)!=8){A.msg="unknown compression method",S.mode=30;break}if(R-=4,C=8+(15&(F>>>=4)),S.wbits===0)S.wbits=C;else if(C>S.wbits){A.msg="invalid window size",S.mode=30;break}S.dmax=1<<C,A.adler=S.check=1,S.mode=512&F?10:12,R=F=0;break;case 2:for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(S.flags=F,(255&S.flags)!=8){A.msg="unknown compression method",S.mode=30;break}if(57344&S.flags){A.msg="unknown header flags set",S.mode=30;break}S.head&&(S.head.text=F>>8&1),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0,S.mode=3;case 3:for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.head&&(S.head.time=F),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,N[2]=F>>>16&255,N[3]=F>>>24&255,S.check=a(S.check,N,4,0)),R=F=0,S.mode=4;case 4:for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.head&&(S.head.xflags=255&F,S.head.os=F>>8),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0,S.mode=5;case 5:if(1024&S.flags){for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.length=F,S.head&&(S.head.extra_len=F),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0}else S.head&&(S.head.extra=null);S.mode=6;case 6:if(1024&S.flags&&(G<(q=S.length)&&(q=G),q&&(S.head&&(C=S.head.extra_len-S.length,S.head.extra||(S.head.extra=new Array(S.head.extra_len)),s.arraySet(S.head.extra,z,U,q,C)),512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,S.length-=q),S.length))break e;S.length=0,S.mode=7;case 7:if(2048&S.flags){if(G===0)break e;for(q=0;C=z[U+q++],S.head&&C&&S.length<65536&&(S.head.name+=String.fromCharCode(C)),C&&q<G;);if(512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,C)break e}else S.head&&(S.head.name=null);S.length=0,S.mode=8;case 8:if(4096&S.flags){if(G===0)break e;for(q=0;C=z[U+q++],S.head&&C&&S.length<65536&&(S.head.comment+=String.fromCharCode(C)),C&&q<G;);if(512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,C)break e}else S.head&&(S.head.comment=null);S.mode=9;case 9:if(512&S.flags){for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F!==(65535&S.check)){A.msg="header crc mismatch",S.mode=30;break}R=F=0}S.head&&(S.head.hcrc=S.flags>>9&1,S.head.done=!0),A.adler=S.check=0,S.mode=12;break;case 10:for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}A.adler=S.check=y(F),R=F=0,S.mode=11;case 11:if(S.havedict===0)return A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,2;A.adler=S.check=1,S.mode=12;case 12:if(I===5||I===6)break e;case 13:if(S.last){F>>>=7&R,R-=7&R,S.mode=27;break}for(;R<3;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}switch(S.last=1&F,R-=1,3&(F>>>=1)){case 0:S.mode=14;break;case 1:if(E(S),S.mode=20,I!==6)break;F>>>=2,R-=2;break e;case 2:S.mode=17;break;case 3:A.msg="invalid block type",S.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[U++]<<R,R+=8}if((65535&F)!=(F>>>16^65535)){A.msg="invalid stored block lengths",S.mode=30;break}if(S.length=65535&F,R=F=0,S.mode=15,I===6)break e;case 15:S.mode=16;case 16:if(q=S.length){if(G<q&&(q=G),$<q&&(q=$),q===0)break e;s.arraySet(V,z,U,q,H),G-=q,U+=q,$-=q,H+=q,S.length-=q;break}S.mode=12;break;case 17:for(;R<14;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(S.nlen=257+(31&F),F>>>=5,R-=5,S.ndist=1+(31&F),F>>>=5,R-=5,S.ncode=4+(15&F),F>>>=4,R-=4,286<S.nlen||30<S.ndist){A.msg="too many length or distance symbols",S.mode=30;break}S.have=0,S.mode=18;case 18:for(;S.have<S.ncode;){for(;R<3;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.lens[Y[S.have++]]=7&F,F>>>=3,R-=3}for(;S.have<19;)S.lens[Y[S.have++]]=0;if(S.lencode=S.lendyn,S.lenbits=7,X={bits:S.lenbits},Z=h(0,S.lens,0,19,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid code lengths set",S.mode=30;break}S.have=0,S.mode=19;case 19:for(;S.have<S.nlen+S.ndist;){for(;oe=(L=S.lencode[F&(1<<S.lenbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(ue<16)F>>>=se,R-=se,S.lens[S.have++]=ue;else{if(ue===16){for(B=se+2;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F>>>=se,R-=se,S.have===0){A.msg="invalid bit length repeat",S.mode=30;break}C=S.lens[S.have-1],q=3+(3&F),F>>>=2,R-=2}else if(ue===17){for(B=se+3;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}R-=se,C=0,q=3+(7&(F>>>=se)),F>>>=3,R-=3}else{for(B=se+7;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}R-=se,C=0,q=11+(127&(F>>>=se)),F>>>=7,R-=7}if(S.have+q>S.nlen+S.ndist){A.msg="invalid bit length repeat",S.mode=30;break}for(;q--;)S.lens[S.have++]=C}}if(S.mode===30)break;if(S.lens[256]===0){A.msg="invalid code -- missing end-of-block",S.mode=30;break}if(S.lenbits=9,X={bits:S.lenbits},Z=h(c,S.lens,0,S.nlen,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid literal/lengths set",S.mode=30;break}if(S.distbits=6,S.distcode=S.distdyn,X={bits:S.distbits},Z=h(d,S.lens,S.nlen,S.ndist,S.distcode,0,S.work,X),S.distbits=X.bits,Z){A.msg="invalid distances set",S.mode=30;break}if(S.mode=20,I===6)break e;case 20:S.mode=21;case 21:if(6<=G&&258<=$){A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,l(A,ee),H=A.next_out,V=A.output,$=A.avail_out,U=A.next_in,z=A.input,G=A.avail_in,F=S.hold,R=S.bits,S.mode===12&&(S.back=-1);break}for(S.back=0;oe=(L=S.lencode[F&(1<<S.lenbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(oe&&(240&oe)==0){for(pe=se,Ce=oe,Be=ue;oe=(L=S.lencode[Be+((F&(1<<pe+Ce)-1)>>pe)])>>>16&255,ue=65535&L,!(pe+(se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}F>>>=pe,R-=pe,S.back+=pe}if(F>>>=se,R-=se,S.back+=se,S.length=ue,oe===0){S.mode=26;break}if(32&oe){S.back=-1,S.mode=12;break}if(64&oe){A.msg="invalid literal/length code",S.mode=30;break}S.extra=15&oe,S.mode=22;case 22:if(S.extra){for(B=S.extra;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.length+=F&(1<<S.extra)-1,F>>>=S.extra,R-=S.extra,S.back+=S.extra}S.was=S.length,S.mode=23;case 23:for(;oe=(L=S.distcode[F&(1<<S.distbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if((240&oe)==0){for(pe=se,Ce=oe,Be=ue;oe=(L=S.distcode[Be+((F&(1<<pe+Ce)-1)>>pe)])>>>16&255,ue=65535&L,!(pe+(se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}F>>>=pe,R-=pe,S.back+=pe}if(F>>>=se,R-=se,S.back+=se,64&oe){A.msg="invalid distance code",S.mode=30;break}S.offset=ue,S.extra=15&oe,S.mode=24;case 24:if(S.extra){for(B=S.extra;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.offset+=F&(1<<S.extra)-1,F>>>=S.extra,R-=S.extra,S.back+=S.extra}if(S.offset>S.dmax){A.msg="invalid distance too far back",S.mode=30;break}S.mode=25;case 25:if($===0)break e;if(q=ee-$,S.offset>q){if((q=S.offset-q)>S.whave&&S.sane){A.msg="invalid distance too far back",S.mode=30;break}ce=q>S.wnext?(q-=S.wnext,S.wsize-q):S.wnext-q,q>S.length&&(q=S.length),fe=S.window}else fe=V,ce=H-S.offset,q=S.length;for($<q&&(q=$),$-=q,S.length-=q;V[H++]=fe[ce++],--q;);S.length===0&&(S.mode=21);break;case 26:if($===0)break e;V[H++]=S.length,$--,S.mode=21;break;case 27:if(S.wrap){for(;R<32;){if(G===0)break e;G--,F|=z[U++]<<R,R+=8}if(ee-=$,A.total_out+=ee,S.total+=ee,ee&&(A.adler=S.check=S.flags?a(S.check,V,ee,H-ee):r(S.check,V,ee,H-ee)),ee=$,(S.flags?F:y(F))!==S.check){A.msg="incorrect data check",S.mode=30;break}R=F=0}S.mode=28;case 28:if(S.wrap&&S.flags){for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F!==(4294967295&S.total)){A.msg="incorrect length check",S.mode=30;break}R=F=0}S.mode=29;case 29:Z=1;break e;case 30:Z=-3;break e;case 31:return-4;case 32:default:return p}return A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,(S.wsize||ee!==A.avail_out&&S.mode<30&&(S.mode<27||I!==4))&&O(A,A.output,A.next_out,ee-A.avail_out)?(S.mode=31,-4):(te-=A.avail_in,ee-=A.avail_out,A.total_in+=te,A.total_out+=ee,S.total+=ee,S.wrap&&ee&&(A.adler=S.check=S.flags?a(S.check,V,ee,A.next_out-ee):r(S.check,V,ee,A.next_out-ee)),A.data_type=S.bits+(S.last?64:0)+(S.mode===12?128:0)+(S.mode===20||S.mode===15?256:0),(te==0&&ee===0||I===4)&&Z===m&&(Z=-5),Z)},i.inflateEnd=function(A){if(!A||!A.state)return p;var I=A.state;return I.window&&(I.window=null),A.state=null,m},i.inflateGetHeader=function(A,I){var S;return A&&A.state?(2&(S=A.state).wrap)==0?p:((S.head=I).done=!1,m):p},i.inflateSetDictionary=function(A,I){var S,z=I.length;return A&&A.state?(S=A.state).wrap!==0&&S.mode!==11?p:S.mode===11&&r(1,I,z,0)!==S.check?-3:O(A,I,z,z)?(S.mode=31,-4):(S.havedict=1,m):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"),r=[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,d,m,p,f,u,g,y){var v,w,x,M,T,P,k,D,E,O=y.bits,A=0,I=0,S=0,z=0,V=0,U=0,H=0,G=0,$=0,F=0,R=null,te=0,ee=new s.Buf16(16),q=new s.Buf16(16),ce=null,fe=0;for(A=0;A<=15;A++)ee[A]=0;for(I=0;I<p;I++)ee[d[m+I]]++;for(V=O,z=15;1<=z&&ee[z]===0;z--);if(z<V&&(V=z),z===0)return f[u++]=20971520,f[u++]=20971520,y.bits=1,0;for(S=1;S<z&&ee[S]===0;S++);for(V<S&&(V=S),A=G=1;A<=15;A++)if(G<<=1,(G-=ee[A])<0)return-1;if(0<G&&(c===0||z!==1))return-1;for(q[1]=0,A=1;A<15;A++)q[A+1]=q[A]+ee[A];for(I=0;I<p;I++)d[m+I]!==0&&(g[q[d[m+I]]++]=I);if(P=c===0?(R=ce=g,19):c===1?(R=r,te-=257,ce=a,fe-=257,256):(R=l,ce=h,-1),A=S,T=u,H=I=F=0,x=-1,M=($=1<<(U=V))-1,c===1&&852<$||c===2&&592<$)return 1;for(;;){for(k=A-H,E=g[I]<P?(D=0,g[I]):g[I]>P?(D=ce[fe+g[I]],R[te+g[I]]):(D=96,0),v=1<<A-H,S=w=1<<U;f[T+(F>>H)+(w-=v)]=k<<24|D<<16|E|0,w!==0;);for(v=1<<A-1;F&v;)v>>=1;if(v!==0?(F&=v-1,F+=v):F=0,I++,--ee[A]==0){if(A===z)break;A=d[m+g[I]]}if(V<A&&(F&M)!==x){for(H===0&&(H=V),T+=S,G=1<<(U=A-H);U+H<z&&!((G-=ee[U+H])<=0);)U++,G<<=1;if($+=1<<U,c===1&&852<$||c===2&&592<$)return 1;f[x=F&M]=V<<24|U<<16|T-u|0}}return F!==0&&(f[T+F]=A-H<<24|64<<16|0),y.bits=V,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"),r=0,a=1;function l(L){for(var N=L.length;0<=--N;)L[N]=0}var h=0,c=29,d=256,m=d+1+c,p=30,f=19,u=2*m+1,g=15,y=16,v=7,w=256,x=16,M=17,T=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],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(m+2));l(O);var A=new Array(2*p);l(A);var I=new Array(512);l(I);var S=new Array(256);l(S);var z=new Array(c);l(z);var V,U,H,G=new Array(p);function $(L,N,Y,K,j){this.static_tree=L,this.extra_bits=N,this.extra_base=Y,this.elems=K,this.max_length=j,this.has_stree=L&&L.length}function F(L,N){this.dyn_tree=L,this.max_code=0,this.stat_desc=N}function R(L){return L<256?I[L]:I[256+(L>>>7)]}function te(L,N){L.pending_buf[L.pending++]=255&N,L.pending_buf[L.pending++]=N>>>8&255}function ee(L,N,Y){L.bi_valid>y-Y?(L.bi_buf|=N<<L.bi_valid&65535,te(L,L.bi_buf),L.bi_buf=N>>y-L.bi_valid,L.bi_valid+=Y-y):(L.bi_buf|=N<<L.bi_valid&65535,L.bi_valid+=Y)}function q(L,N,Y){ee(L,Y[2*N],Y[2*N+1])}function ce(L,N){for(var Y=0;Y|=1&L,L>>>=1,Y<<=1,0<--N;);return Y>>>1}function fe(L,N,Y){var K,j,J=new Array(g+1),ne=0;for(K=1;K<=g;K++)J[K]=ne=ne+Y[K-1]<<1;for(j=0;j<=N;j++){var Q=L[2*j+1];Q!==0&&(L[2*j]=ce(J[Q]++,Q))}}function se(L){var N;for(N=0;N<m;N++)L.dyn_ltree[2*N]=0;for(N=0;N<p;N++)L.dyn_dtree[2*N]=0;for(N=0;N<f;N++)L.bl_tree[2*N]=0;L.dyn_ltree[2*w]=1,L.opt_len=L.static_len=0,L.last_lit=L.matches=0}function oe(L){8<L.bi_valid?te(L,L.bi_buf):0<L.bi_valid&&(L.pending_buf[L.pending++]=L.bi_buf),L.bi_buf=0,L.bi_valid=0}function ue(L,N,Y,K){var j=2*N,J=2*Y;return L[j]<L[J]||L[j]===L[J]&&K[N]<=K[Y]}function pe(L,N,Y){for(var K=L.heap[Y],j=Y<<1;j<=L.heap_len&&(j<L.heap_len&&ue(N,L.heap[j+1],L.heap[j],L.depth)&&j++,!ue(N,K,L.heap[j],L.depth));)L.heap[Y]=L.heap[j],Y=j,j<<=1;L.heap[Y]=K}function Ce(L,N,Y){var K,j,J,ne,Q=0;if(L.last_lit!==0)for(;K=L.pending_buf[L.d_buf+2*Q]<<8|L.pending_buf[L.d_buf+2*Q+1],j=L.pending_buf[L.l_buf+Q],Q++,K===0?q(L,j,N):(q(L,(J=S[j])+d+1,N),(ne=P[J])!==0&&ee(L,j-=z[J],ne),q(L,J=R(--K),Y),(ne=k[J])!==0&&ee(L,K-=G[J],ne)),Q<L.last_lit;);q(L,w,N)}function Be(L,N){var Y,K,j,J=N.dyn_tree,ne=N.stat_desc.static_tree,Q=N.stat_desc.has_stree,ie=N.stat_desc.elems,he=-1;for(L.heap_len=0,L.heap_max=u,Y=0;Y<ie;Y++)J[2*Y]!==0?(L.heap[++L.heap_len]=he=Y,L.depth[Y]=0):J[2*Y+1]=0;for(;L.heap_len<2;)J[2*(j=L.heap[++L.heap_len]=he<2?++he:0)]=1,L.depth[j]=0,L.opt_len--,Q&&(L.static_len-=ne[2*j+1]);for(N.max_code=he,Y=L.heap_len>>1;1<=Y;Y--)pe(L,J,Y);for(j=ie;Y=L.heap[1],L.heap[1]=L.heap[L.heap_len--],pe(L,J,1),K=L.heap[1],L.heap[--L.heap_max]=Y,L.heap[--L.heap_max]=K,J[2*j]=J[2*Y]+J[2*K],L.depth[j]=(L.depth[Y]>=L.depth[K]?L.depth[Y]:L.depth[K])+1,J[2*Y+1]=J[2*K+1]=j,L.heap[1]=j++,pe(L,J,1),2<=L.heap_len;);L.heap[--L.heap_max]=L.heap[1],(function(ae,Ae){var $e,Ee,Ft,ge,nn,Sn,He=Ae.dyn_tree,Mt=Ae.max_code,Ut=Ae.stat_desc.static_tree,Vt=Ae.stat_desc.has_stree,jt=Ae.stat_desc.extra_bits,_t=Ae.stat_desc.extra_base,Cn=Ae.stat_desc.max_length,Ai=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(He[2*ae.heap[ae.heap_max]+1]=0,$e=ae.heap_max+1;$e<u;$e++)Cn<(ge=He[2*He[2*(Ee=ae.heap[$e])+1]+1]+1)&&(ge=Cn,Ai++),He[2*Ee+1]=ge,Mt<Ee||(ae.bl_count[ge]++,nn=0,_t<=Ee&&(nn=jt[Ee-_t]),Sn=He[2*Ee],ae.opt_len+=Sn*(ge+nn),Vt&&(ae.static_len+=Sn*(Ut[2*Ee+1]+nn)));if(Ai!==0){do{for(ge=Cn-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[Cn]--,Ai-=2}while(0<Ai);for(ge=Cn;ge!==0;ge--)for(Ee=ae.bl_count[ge];Ee!==0;)Mt<(Ft=ae.heap[--$e])||(He[2*Ft+1]!==ge&&(ae.opt_len+=(ge-He[2*Ft+1])*He[2*Ft],He[2*Ft+1]=ge),Ee--)}})(L,N),fe(J,he,L.bl_count)}function C(L,N,Y){var K,j,J=-1,ne=N[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),N[2*(Y+1)+1]=65535,K=0;K<=Y;K++)j=ne,ne=N[2*(K+1)+1],++Q<ie&&j===ne||(Q<he?L.bl_tree[2*j]+=Q:j!==0?(j!==J&&L.bl_tree[2*j]++,L.bl_tree[2*x]++):Q<=10?L.bl_tree[2*M]++:L.bl_tree[2*T]++,J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4))}function Z(L,N,Y){var K,j,J=-1,ne=N[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),K=0;K<=Y;K++)if(j=ne,ne=N[2*(K+1)+1],!(++Q<ie&&j===ne)){if(Q<he)for(;q(L,j,L.bl_tree),--Q!=0;);else j!==0?(j!==J&&(q(L,j,L.bl_tree),Q--),q(L,x,L.bl_tree),ee(L,Q-3,2)):Q<=10?(q(L,M,L.bl_tree),ee(L,Q-3,3)):(q(L,T,L.bl_tree),ee(L,Q-11,7));J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4)}}l(G);var X=!1;function B(L,N,Y,K){ee(L,(h<<1)+(K?1:0),3),(function(j,J,ne,Q){oe(j),te(j,ne),te(j,~ne),s.arraySet(j.pending_buf,j.window,J,ne,j.pending),j.pending+=ne})(L,N,Y)}i._tr_init=function(L){X||((function(){var N,Y,K,j,J,ne=new Array(g+1);for(j=K=0;j<c-1;j++)for(z[j]=K,N=0;N<1<<P[j];N++)S[K++]=j;for(S[K-1]=j,j=J=0;j<16;j++)for(G[j]=J,N=0;N<1<<k[j];N++)I[J++]=j;for(J>>=7;j<p;j++)for(G[j]=J<<7,N=0;N<1<<k[j]-7;N++)I[256+J++]=j;for(Y=0;Y<=g;Y++)ne[Y]=0;for(N=0;N<=143;)O[2*N+1]=8,N++,ne[8]++;for(;N<=255;)O[2*N+1]=9,N++,ne[9]++;for(;N<=279;)O[2*N+1]=7,N++,ne[7]++;for(;N<=287;)O[2*N+1]=8,N++,ne[8]++;for(fe(O,m+1,ne),N=0;N<p;N++)A[2*N+1]=5,A[2*N]=ce(N,5);V=new $(O,P,d+1,m,g),U=new $(A,k,0,p,g),H=new $(new Array(0),D,0,f,v)})(),X=!0),L.l_desc=new F(L.dyn_ltree,V),L.d_desc=new F(L.dyn_dtree,U),L.bl_desc=new F(L.bl_tree,H),L.bi_buf=0,L.bi_valid=0,se(L)},i._tr_stored_block=B,i._tr_flush_block=function(L,N,Y,K){var j,J,ne=0;0<L.level?(L.strm.data_type===2&&(L.strm.data_type=(function(Q){var ie,he=4093624447;for(ie=0;ie<=31;ie++,he>>>=1)if(1&he&&Q.dyn_ltree[2*ie]!==0)return r;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return a;for(ie=32;ie<d;ie++)if(Q.dyn_ltree[2*ie]!==0)return a;return r})(L)),Be(L,L.l_desc),Be(L,L.d_desc),ne=(function(Q){var ie;for(C(Q,Q.dyn_ltree,Q.l_desc.max_code),C(Q,Q.dyn_dtree,Q.d_desc.max_code),Be(Q,Q.bl_desc),ie=f-1;3<=ie&&Q.bl_tree[2*E[ie]+1]===0;ie--);return Q.opt_len+=3*(ie+1)+5+5+4,ie})(L),j=L.opt_len+3+7>>>3,(J=L.static_len+3+7>>>3)<=j&&(j=J)):j=J=Y+5,Y+4<=j&&N!==-1?B(L,N,Y,K):L.strategy===4||J===j?(ee(L,2+(K?1:0),3),Ce(L,O,A)):(ee(L,4+(K?1:0),3),(function(Q,ie,he,ae){var Ae;for(ee(Q,ie-257,5),ee(Q,he-1,5),ee(Q,ae-4,4),Ae=0;Ae<ae;Ae++)ee(Q,Q.bl_tree[2*E[Ae]+1],3);Z(Q,Q.dyn_ltree,ie-1),Z(Q,Q.dyn_dtree,he-1)})(L,L.l_desc.max_code+1,L.d_desc.max_code+1,ne+1),Ce(L,L.dyn_ltree,L.dyn_dtree)),se(L),K&&oe(L)},i._tr_tally=function(L,N,Y){return L.pending_buf[L.d_buf+2*L.last_lit]=N>>>8&255,L.pending_buf[L.d_buf+2*L.last_lit+1]=255&N,L.pending_buf[L.l_buf+L.last_lit]=255&Y,L.last_lit++,N===0?L.dyn_ltree[2*Y]++:(L.matches++,N--,L.dyn_ltree[2*(S[Y]+d+1)]++,L.dyn_dtree[2*R(N)]++),L.last_lit===L.lit_bufsize-1},i._tr_align=function(L){ee(L,2,3),q(L,w,O),(function(N){N.bi_valid===16?(te(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)})(L)}},{"../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(r,a){if(!r.setImmediate){var l,h,c,d,m=1,p={},f=!1,u=r.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(r);g=g&&g.setTimeout?g:r,l={}.toString.call(r.process)==="[object process]"?function(x){process.nextTick(function(){v(x)})}:(function(){if(r.postMessage&&!r.importScripts){var x=!0,M=r.onmessage;return r.onmessage=function(){x=!1},r.postMessage("","*"),r.onmessage=M,x}})()?(d="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",w,!1):r.attachEvent("onmessage",w),function(x){r.postMessage(d+x,"*")}):r.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){v(x.data)},function(x){c.port2.postMessage(x)}):u&&"onreadystatechange"in u.createElement("script")?(h=u.documentElement,function(x){var M=u.createElement("script");M.onreadystatechange=function(){v(x),M.onreadystatechange=null,h.removeChild(M),M=null},h.appendChild(M)}):function(x){setTimeout(v,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var M=new Array(arguments.length-1),T=0;T<M.length;T++)M[T]=arguments[T+1];var P={callback:x,args:M};return p[m]=P,l(m),m++},g.clearImmediate=y}function y(x){delete p[x]}function v(x){if(f)setTimeout(v,0,x);else{var M=p[x];if(M){f=!0;try{(function(T){var P=T.callback,k=T.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)}})(M)}finally{y(x),f=!1}}}}function w(x){x.source===r&&typeof x.data=="string"&&x.data.indexOf(d)===0&&v(+x.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof On<"u"?On:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Ei)),Ei.exports}var Ca=Sa();const Ys=Xs(Ca);function Ks(o,e){return function(){return o.apply(e,arguments)}}const{toString:Aa}=Object.prototype,{getPrototypeOf:Li}=Object,{iterator:Nn,toStringTag:qs}=Symbol,Fn=(o=>e=>{const t=Aa.call(e);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ye=o=>(o=o.toLowerCase(),e=>Fn(e)===o),Un=o=>e=>typeof e===o,{isArray:Gt}=Array,Wt=Un("undefined");function sn(o){return o!==null&&!Wt(o)&&o.constructor!==null&&!Wt(o.constructor)&&Ne(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const $s=Ye("ArrayBuffer");function Pa(o){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&$s(o.buffer),e}const Ta=Un("string"),Ne=Un("function"),Hs=Un("number"),rn=o=>o!==null&&typeof o=="object",Da=o=>o===!0||o===!1,Vn=o=>{if(Fn(o)!=="object")return!1;const e=Li(o);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(qs in o)&&!(Nn in o)},ka=o=>{if(!rn(o)||sn(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},Ea=Ye("Date"),La=Ye("File"),Ia=Ye("Blob"),za=Ye("FileList"),Ba=o=>rn(o)&&Ne(o.pipe),Oa=o=>{let e;return o&&(typeof FormData=="function"&&o instanceof FormData||Ne(o.append)&&((e=Fn(o))==="formdata"||e==="object"&&Ne(o.toString)&&o.toString()==="[object FormData]"))},Ra=Ye("URLSearchParams"),[Na,Fa,Ua,Va]=["ReadableStream","Request","Response","Headers"].map(Ye),ja=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function on(o,e,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let n,i;if(typeof o!="object"&&(o=[o]),Gt(o))for(n=0,i=o.length;n<i;n++)e.call(null,o[n],n,o);else{if(sn(o))return;const s=t?Object.getOwnPropertyNames(o):Object.keys(o),r=s.length;let a;for(n=0;n<r;n++)a=s[n],e.call(null,o[a],a,o)}}function Js(o,e){if(sn(o))return null;e=e.toLowerCase();const t=Object.keys(o);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const At=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Qs=o=>!Wt(o)&&o!==At;function Ii(){const{caseless:o,skipUndefined:e}=Qs(this)&&this||{},t={},n=(i,s)=>{const r=o&&Js(t,s)||s;Vn(t[r])&&Vn(i)?t[r]=Ii(t[r],i):Vn(i)?t[r]=Ii({},i):Gt(i)?t[r]=i.slice():(!e||!Wt(i))&&(t[r]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&on(arguments[i],n);return t}const Ga=(o,e,t,{allOwnKeys:n}={})=>(on(e,(i,s)=>{t&&Ne(i)?o[s]=Ks(i,t):o[s]=i},{allOwnKeys:n}),o),Wa=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),Xa=(o,e,t,n)=>{o.prototype=Object.create(e.prototype,n),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:e.prototype}),t&&Object.assign(o.prototype,t)},Za=(o,e,t,n)=>{let i,s,r;const a={};if(e=e||{},o==null)return e;do{for(i=Object.getOwnPropertyNames(o),s=i.length;s-- >0;)r=i[s],(!n||n(r,o,e))&&!a[r]&&(e[r]=o[r],a[r]=!0);o=t!==!1&&Li(o)}while(o&&(!t||t(o,e))&&o!==Object.prototype);return e},Ya=(o,e,t)=>{o=String(o),(t===void 0||t>o.length)&&(t=o.length),t-=e.length;const n=o.indexOf(e,t);return n!==-1&&n===t},Ka=o=>{if(!o)return null;if(Gt(o))return o;let e=o.length;if(!Hs(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=o[e];return t},qa=(o=>e=>o&&e instanceof o)(typeof Uint8Array<"u"&&Li(Uint8Array)),$a=(o,e)=>{const n=(o&&o[Nn]).call(o);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(o,s[0],s[1])}},Ha=(o,e)=>{let t;const n=[];for(;(t=o.exec(e))!==null;)n.push(t);return n},Ja=Ye("HTMLFormElement"),Qa=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),er=(({hasOwnProperty:o})=>(e,t)=>o.call(e,t))(Object.prototype),el=Ye("RegExp"),tr=(o,e)=>{const t=Object.getOwnPropertyDescriptors(o),n={};on(t,(i,s)=>{let r;(r=e(i,s,o))!==!1&&(n[s]=r||i)}),Object.defineProperties(o,n)},tl=o=>{tr(o,(e,t)=>{if(Ne(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=o[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+"'")})}})},nl=(o,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return Gt(o)?n(o):n(String(o).split(e)),t},il=()=>{},sl=(o,e)=>o!=null&&Number.isFinite(o=+o)?o:e;function rl(o){return!!(o&&Ne(o.append)&&o[qs]==="FormData"&&o[Nn])}const ol=o=>{const e=new Array(10),t=(n,i)=>{if(rn(n)){if(e.indexOf(n)>=0)return;if(sn(n))return n;if(!("toJSON"in n)){e[i]=n;const s=Gt(n)?[]:{};return on(n,(r,a)=>{const l=t(r,i+1);!Wt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(o,0)},al=Ye("AsyncFunction"),ll=o=>o&&(rn(o)||Ne(o))&&Ne(o.then)&&Ne(o.catch),nr=((o,e)=>o?setImmediate:e?((t,n)=>(At.addEventListener("message",({source:i,data:s})=>{i===At&&s===t&&n.length&&n.shift()()},!1),i=>{n.push(i),At.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ne(At.postMessage)),cl=typeof queueMicrotask<"u"?queueMicrotask.bind(At):typeof process<"u"&&process.nextTick||nr,W={isArray:Gt,isArrayBuffer:$s,isBuffer:sn,isFormData:Oa,isArrayBufferView:Pa,isString:Ta,isNumber:Hs,isBoolean:Da,isObject:rn,isPlainObject:Vn,isEmptyObject:ka,isReadableStream:Na,isRequest:Fa,isResponse:Ua,isHeaders:Va,isUndefined:Wt,isDate:Ea,isFile:La,isBlob:Ia,isRegExp:el,isFunction:Ne,isStream:Ba,isURLSearchParams:Ra,isTypedArray:qa,isFileList:za,forEach:on,merge:Ii,extend:Ga,trim:ja,stripBOM:Wa,inherits:Xa,toFlatObject:Za,kindOf:Fn,kindOfTest:Ye,endsWith:Ya,toArray:Ka,forEachEntry:$a,matchAll:Ha,isHTMLForm:Ja,hasOwnProperty:er,hasOwnProp:er,reduceDescriptors:tr,freezeMethods:tl,toObjectSet:nl,toCamelCase:Qa,noop:il,toFiniteNumber:sl,findKey:Js,global:At,isContextDefined:Qs,isSpecCompliantForm:rl,toJSONObject:ol,isAsyncFn:al,isThenable:ll,setImmediate:nr,asap:cl,isIterable:o=>o!=null&&Ne(o[Nn])};function re(o,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,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)}W.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:W.toJSONObject(this.config),code:this.code,status:this.status}}});const ir=re.prototype,sr={};["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(o=>{sr[o]={value:o}}),Object.defineProperties(re,sr),Object.defineProperty(ir,"isAxiosError",{value:!0}),re.from=(o,e,t,n,i,s)=>{const r=Object.create(ir);W.toFlatObject(o,r,function(c){return c!==Error.prototype},h=>h!=="isAxiosError");const a=o&&o.message?o.message:"Error",l=e==null&&o?o.code:e;return re.call(r,a,l,t,n,i),o&&r.cause==null&&Object.defineProperty(r,"cause",{value:o,configurable:!0}),r.name=o&&o.name||"Error",s&&Object.assign(r,s),r};const hl=null;function zi(o){return W.isPlainObject(o)||W.isArray(o)}function rr(o){return W.endsWith(o,"[]")?o.slice(0,-2):o}function or(o,e,t){return o?o.concat(e).map(function(i,s){return i=rr(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function ul(o){return W.isArray(o)&&!o.some(zi)}const dl=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function jn(o,e,t){if(!W.isObject(o))throw new TypeError("target must be an object");e=e||new FormData,t=W.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,g){return!W.isUndefined(g[u])});const n=t.metaTokens,i=t.visitor||c,s=t.dots,r=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(e);if(!W.isFunction(i))throw new TypeError("visitor must be a function");function h(f){if(f===null)return"";if(W.isDate(f))return f.toISOString();if(W.isBoolean(f))return f.toString();if(!l&&W.isBlob(f))throw new re("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(f)||W.isTypedArray(f)?l&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function c(f,u,g){let y=f;if(f&&!g&&typeof f=="object"){if(W.endsWith(u,"{}"))u=n?u:u.slice(0,-2),f=JSON.stringify(f);else if(W.isArray(f)&&ul(f)||(W.isFileList(f)||W.endsWith(u,"[]"))&&(y=W.toArray(f)))return u=rr(u),y.forEach(function(w,x){!(W.isUndefined(w)||w===null)&&e.append(r===!0?or([u],x,s):r===null?u:u+"[]",h(w))}),!1}return zi(f)?!0:(e.append(or(g,u,s),h(f)),!1)}const d=[],m=Object.assign(dl,{defaultVisitor:c,convertValue:h,isVisitable:zi});function p(f,u){if(!W.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+u.join("."));d.push(f),W.forEach(f,function(y,v){(!(W.isUndefined(y)||y===null)&&i.call(e,y,W.isString(v)?v.trim():v,u,m))===!0&&p(y,u?u.concat(v):[v])}),d.pop()}}if(!W.isObject(o))throw new TypeError("data must be an object");return p(o),e}function ar(o){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Bi(o,e){this._pairs=[],o&&jn(o,this,e)}const lr=Bi.prototype;lr.append=function(e,t){this._pairs.push([e,t])},lr.toString=function(e){const t=e?function(n){return e.call(this,n,ar)}:ar;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function fl(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function cr(o,e,t){if(!e)return o;const n=t&&t.encode||fl;W.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=W.isURLSearchParams(e)?e.toString():new Bi(e,t).toString(n),s){const r=o.indexOf("#");r!==-1&&(o=o.slice(0,r)),o+=(o.indexOf("?")===-1?"?":"&")+s}return o}class hr{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){W.forEach(this.handlers,function(n){n!==null&&e(n)})}}const ur={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Bi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Oi=typeof window<"u"&&typeof document<"u",Ri=typeof navigator=="object"&&navigator||void 0,ml=Oi&&(!Ri||["ReactNative","NativeScript","NS"].indexOf(Ri.product)<0),gl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yl=Oi&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Oi,hasStandardBrowserEnv:ml,hasStandardBrowserWebWorkerEnv:gl,navigator:Ri,origin:yl},Symbol.toStringTag,{value:"Module"})),...pl};function vl(o,e){return jn(o,new ke.classes.URLSearchParams,{visitor:function(t,n,i,s){return ke.isNode&&W.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function wl(o){return W.matchAll(/\w+|\[(\w*)]/g,o).map(e=>e[0]==="[]"?"":e[1]||e[0])}function xl(o){const e={},t=Object.keys(o);let n;const i=t.length;let s;for(n=0;n<i;n++)s=t[n],e[s]=o[s];return e}function dr(o){function e(t,n,i,s){let r=t[s++];if(r==="__proto__")return!0;const a=Number.isFinite(+r),l=s>=t.length;return r=!r&&W.isArray(i)?i.length:r,l?(W.hasOwnProp(i,r)?i[r]=[i[r],n]:i[r]=n,!a):((!i[r]||!W.isObject(i[r]))&&(i[r]=[]),e(t,n,i[r],s)&&W.isArray(i[r])&&(i[r]=xl(i[r])),!a)}if(W.isFormData(o)&&W.isFunction(o.entries)){const t={};return W.forEachEntry(o,(n,i)=>{e(wl(n),i,t,0)}),t}return null}function bl(o,e,t){if(W.isString(o))try{return(e||JSON.parse)(o),W.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(o)}const an={transitional:ur,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=W.isObject(e);if(s&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return i?JSON.stringify(dr(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.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 vl(e,this.formSerializer).toString();if((a=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return jn(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),bl(e)):e}],transformResponse:[function(e){const t=this.transitional||an.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||i)){const r=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(r)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:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],o=>{an.headers[o]={}});const Ml=W.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"]),_l=o=>{const e={};let t,n,i;return o&&o.split(`
962
- `).forEach(function(r){i=r.indexOf(":"),t=r.substring(0,i).trim().toLowerCase(),n=r.substring(i+1).trim(),!(!t||e[t]&&Ml[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},fr=Symbol("internals");function ln(o){return o&&String(o).trim().toLowerCase()}function Gn(o){return o===!1||o==null?o:W.isArray(o)?o.map(Gn):String(o)}function Sl(o){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(o);)e[n[1]]=n[2];return e}const Cl=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function Ni(o,e,t,n,i){if(W.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!W.isString(e)){if(W.isString(n))return e.indexOf(n)!==-1;if(W.isRegExp(n))return n.test(e)}}function Al(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Pl(o,e){const t=W.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(o,n+t,{value:function(i,s,r){return this[n].call(this,e,i,s,r)},configurable:!0})})}let Fe=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(a,l,h){const c=ln(l);if(!c)throw new Error("header name must be a non-empty string");const d=W.findKey(i,c);(!d||i[d]===void 0||h===!0||h===void 0&&i[d]!==!1)&&(i[d||l]=Gn(a))}const r=(a,l)=>W.forEach(a,(h,c)=>s(h,c,l));if(W.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(W.isString(e)&&(e=e.trim())&&!Cl(e))r(_l(e),t);else if(W.isObject(e)&&W.isIterable(e)){let a={},l,h;for(const c of e){if(!W.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[h=c[0]]=(l=a[h])?W.isArray(l)?[...l,c[1]]:[l,c[1]]:c[1]}r(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=ln(e),e){const n=W.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return Sl(i);if(W.isFunction(t))return t.call(this,i,n);if(W.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ln(e),e){const n=W.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Ni(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function s(r){if(r=ln(r),r){const a=W.findKey(n,r);a&&(!t||Ni(n,n[a],a,t))&&(delete n[a],i=!0)}}return W.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||Ni(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return W.forEach(this,(i,s)=>{const r=W.findKey(n,s);if(r){t[r]=Gn(i),delete t[s];return}const a=e?Al(s):String(s).trim();a!==s&&delete t[s],t[a]=Gn(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&W.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(`
963
- `)}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[fr]=this[fr]={accessors:{}}).accessors,i=this.prototype;function s(r){const a=ln(r);n[a]||(Pl(i,r),n[a]=!0)}return W.isArray(e)?e.forEach(s):s(e),this}};Fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Fe.prototype,({value:o},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>o,set(n){this[t]=n}}}),W.freezeMethods(Fe);function Fi(o,e){const t=this||an,n=e||t,i=Fe.from(n.headers);let s=n.data;return W.forEach(o,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function pr(o){return!!(o&&o.__CANCEL__)}function Xt(o,e,t){re.call(this,o??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}W.inherits(Xt,re,{__CANCEL__:!0});function mr(o,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?o(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 Tl(o){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return e&&e[1]||""}function Dl(o,e){o=o||10;const t=new Array(o),n=new Array(o);let i=0,s=0,r;return e=e!==void 0?e:1e3,function(l){const h=Date.now(),c=n[s];r||(r=h),t[i]=l,n[i]=h;let d=s,m=0;for(;d!==i;)m+=t[d++],d=d%o;if(i=(i+1)%o,i===s&&(s=(s+1)%o),h-r<e)return;const p=c&&h-c;return p?Math.round(m*1e3/p):void 0}}function kl(o,e){let t=0,n=1e3/e,i,s;const r=(h,c=Date.now())=>{t=c,i=null,s&&(clearTimeout(s),s=null),o(...h)};return[(...h)=>{const c=Date.now(),d=c-t;d>=n?r(h,c):(i=h,s||(s=setTimeout(()=>{s=null,r(i)},n-d)))},()=>i&&r(i)]}const Wn=(o,e,t=3)=>{let n=0;const i=Dl(50,250);return kl(s=>{const r=s.loaded,a=s.lengthComputable?s.total:void 0,l=r-n,h=i(l),c=r<=a;n=r;const d={loaded:r,total:a,progress:a?r/a:void 0,bytes:l,rate:h||void 0,estimated:h&&a&&c?(a-r)/h:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};o(d)},t)},gr=(o,e)=>{const t=o!=null;return[n=>e[0]({lengthComputable:t,total:o,loaded:n}),e[1]]},yr=o=>(...e)=>W.asap(()=>o(...e)),El=ke.hasStandardBrowserEnv?((o,e)=>t=>(t=new URL(t,ke.origin),o.protocol===t.protocol&&o.host===t.host&&(e||o.port===t.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,Ll=ke.hasStandardBrowserEnv?{write(o,e,t,n,i,s,r){if(typeof document>"u")return;const a=[`${o}=${encodeURIComponent(e)}`];W.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),W.isString(n)&&a.push(`path=${n}`),W.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),W.isString(r)&&a.push(`SameSite=${r}`),document.cookie=a.join("; ")},read(o){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+o+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(o){this.write(o,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Il(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function zl(o,e){return e?o.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):o}function vr(o,e,t){let n=!Il(e);return o&&(n||t==!1)?zl(o,e):e}const wr=o=>o instanceof Fe?{...o}:o;function Pt(o,e){e=e||{};const t={};function n(h,c,d,m){return W.isPlainObject(h)&&W.isPlainObject(c)?W.merge.call({caseless:m},h,c):W.isPlainObject(c)?W.merge({},c):W.isArray(c)?c.slice():c}function i(h,c,d,m){if(W.isUndefined(c)){if(!W.isUndefined(h))return n(void 0,h,d,m)}else return n(h,c,d,m)}function s(h,c){if(!W.isUndefined(c))return n(void 0,c)}function r(h,c){if(W.isUndefined(c)){if(!W.isUndefined(h))return n(void 0,h)}else return n(void 0,c)}function a(h,c,d){if(d in e)return n(h,c);if(d in o)return n(void 0,h)}const l={url:s,method:s,data:s,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:a,headers:(h,c,d)=>i(wr(h),wr(c),d,!0)};return W.forEach(Object.keys({...o,...e}),function(c){const d=l[c]||i,m=d(o[c],e[c],c);W.isUndefined(m)&&d!==a||(t[c]=m)}),t}const xr=o=>{const e=Pt({},o);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Fe.from(r),e.url=cr(vr(e.baseURL,e.url,e.allowAbsoluteUrls),o.params,o.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(t)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(W.isFunction(t.getHeaders)){const l=t.getHeaders(),h=["content-type","content-length"];Object.entries(l).forEach(([c,d])=>{h.includes(c.toLowerCase())&&r.set(c,d)})}}if(ke.hasStandardBrowserEnv&&(n&&W.isFunction(n)&&(n=n(e)),n||n!==!1&&El(e.url))){const l=i&&s&&Ll.read(s);l&&r.set(i,l)}return e},Bl=typeof XMLHttpRequest<"u"&&function(o){return new Promise(function(t,n){const i=xr(o);let s=i.data;const r=Fe.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:h}=i,c,d,m,p,f;function u(){p&&p(),f&&f(),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 w=Fe.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),M={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:w,config:o,request:g};mr(function(P){t(P),u()},function(P){n(P),u()},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,o,g)),g=null)},g.onerror=function(x){const M=x&&x.message?x.message:"Network Error",T=new re(M,re.ERR_NETWORK,o,g);T.event=x||null,n(T),g=null},g.ontimeout=function(){let x=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const M=i.transitional||ur;i.timeoutErrorMessage&&(x=i.timeoutErrorMessage),n(new re(x,M.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,o,g)),g=null},s===void 0&&r.setContentType(null),"setRequestHeader"in g&&W.forEach(r.toJSON(),function(x,M){g.setRequestHeader(M,x)}),W.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),h&&([m,f]=Wn(h,!0),g.addEventListener("progress",m)),l&&g.upload&&([d,p]=Wn(l),g.upload.addEventListener("progress",d),g.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(c=w=>{g&&(n(!w||w.type?new Xt(null,o,g):w),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const v=Tl(i.url);if(v&&ke.protocols.indexOf(v)===-1){n(new re("Unsupported protocol "+v+":",re.ERR_BAD_REQUEST,o));return}g.send(s||null)})},Ol=(o,e)=>{const{length:t}=o=o?o.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 Xt(c instanceof Error?c.message:c))}};let r=e&&setTimeout(()=>{r=null,s(new re(`timeout ${e} of ms exceeded`,re.ETIMEDOUT))},e);const a=()=>{o&&(r&&clearTimeout(r),r=null,o.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),o=null)};o.forEach(h=>h.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>W.asap(a),l}},Rl=function*(o,e){let t=o.byteLength;if(t<e){yield o;return}let n=0,i;for(;n<t;)i=n+e,yield o.slice(n,i),n=i},Nl=async function*(o,e){for await(const t of Fl(o))yield*Rl(t,e)},Fl=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const e=o.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},br=(o,e,t,n)=>{const i=Nl(o,e);let s=0,r,a=l=>{r||(r=!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 d=c.byteLength;if(t){let m=s+=d;t(m)}l.enqueue(new Uint8Array(c))}catch(h){throw a(h),h}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},Mr=64*1024,{isFunction:Xn}=W,Ul=(({Request:o,Response:e})=>({Request:o,Response:e}))(W.global),{ReadableStream:_r,TextEncoder:Sr}=W.global,Cr=(o,...e)=>{try{return!!o(...e)}catch{return!1}},Vl=o=>{o=W.merge.call({skipUndefined:!0},Ul,o);const{fetch:e,Request:t,Response:n}=o,i=e?Xn(e):typeof fetch=="function",s=Xn(t),r=Xn(n);if(!i)return!1;const a=i&&Xn(_r),l=i&&(typeof Sr=="function"?(f=>u=>f.encode(u))(new Sr):async f=>new Uint8Array(await new t(f).arrayBuffer())),h=s&&a&&Cr(()=>{let f=!1;const u=new t(ke.origin,{body:new _r,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!u}),c=r&&a&&Cr(()=>W.isReadableStream(new n("").body)),d={stream:c&&(f=>f.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!d[f]&&(d[f]=(u,g)=>{let y=u&&u[f];if(y)return y.call(u);throw new re(`Response type '${f}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const m=async f=>{if(f==null)return 0;if(W.isBlob(f))return f.size;if(W.isSpecCompliantForm(f))return(await new t(ke.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(W.isArrayBufferView(f)||W.isArrayBuffer(f))return f.byteLength;if(W.isURLSearchParams(f)&&(f=f+""),W.isString(f))return(await l(f)).byteLength},p=async(f,u)=>{const g=W.toFiniteNumber(f.getContentLength());return g??m(u)};return async f=>{let{url:u,method:g,data:y,signal:v,cancelToken:w,timeout:x,onDownloadProgress:M,onUploadProgress:T,responseType:P,headers:k,withCredentials:D="same-origin",fetchOptions:E}=xr(f),O=e||fetch;P=P?(P+"").toLowerCase():"text";let A=Ol([v,w&&w.toAbortSignal()],x),I=null;const S=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let z;try{if(T&&h&&g!=="get"&&g!=="head"&&(z=await p(k,y))!==0){let F=new t(u,{method:"POST",body:y,duplex:"half"}),R;if(W.isFormData(y)&&(R=F.headers.get("content-type"))&&k.setContentType(R),F.body){const[te,ee]=gr(z,Wn(yr(T)));y=br(F.body,Mr,te,ee)}}W.isString(D)||(D=D?"include":"omit");const V=s&&"credentials"in t.prototype,U={...E,signal:A,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:V?D:void 0};I=s&&new t(u,U);let H=await(s?O(I,E):O(u,U));const G=c&&(P==="stream"||P==="response");if(c&&(M||G&&S)){const F={};["status","statusText","headers"].forEach(q=>{F[q]=H[q]});const R=W.toFiniteNumber(H.headers.get("content-length")),[te,ee]=M&&gr(R,Wn(yr(M),!0))||[];H=new n(br(H.body,Mr,te,()=>{ee&&ee(),S&&S()}),F)}P=P||"text";let $=await d[W.findKey(d,P)||"text"](H,f);return!G&&S&&S(),await new Promise((F,R)=>{mr(F,R,{data:$,headers:Fe.from(H.headers),status:H.status,statusText:H.statusText,config:f,request:I})})}catch(V){throw S&&S(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,f,I),{cause:V.cause||V}):re.from(V,V&&V.code,f,I)}}},jl=new Map,Ar=o=>{let e=o&&o.env||{};const{fetch:t,Request:n,Response:i}=e,s=[n,i,t];let r=s.length,a=r,l,h,c=jl;for(;a--;)l=s[a],h=c.get(l),h===void 0&&c.set(l,h=a?new Map:Vl(e)),c=h;return h};Ar();const Ui={http:hl,xhr:Bl,fetch:{get:Ar}};W.forEach(Ui,(o,e)=>{if(o){try{Object.defineProperty(o,"name",{value:e})}catch{}Object.defineProperty(o,"adapterName",{value:e})}});const Pr=o=>`- ${o}`,Gl=o=>W.isFunction(o)||o===null||o===!1;function Wl(o,e){o=W.isArray(o)?o:[o];const{length:t}=o;let n,i;const s={};for(let r=0;r<t;r++){n=o[r];let a;if(i=n,!Gl(n)&&(i=Ui[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(W.isFunction(i)||(i=i.get(e))))break;s[a||"#"+r]=i}if(!i){const r=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?r.length>1?`since :
960
+ `};class _a{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;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 Dn&&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,r=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new b.WebGLRenderTarget(e,t,{minFilter:b.LinearFilter,magFilter:b.LinearFilter,format:b.RGBAFormat,samples:4});this.composer=new ma(s,a),this.composer.setPixelRatio(r),this.composer.setSize(e,t);const l=new ga(n,i);this.composer.addPass(l),this.gtaoPass=new Re(n,i,e,t),this.gtaoPass.output=Re.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.composer.addPass(this.gtaoPass),this.ssaoPass=new st(n,i,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=st.OUTPUT.Default,this.ssaoPass.enabled=!1,this.composer.addPass(this.ssaoPass),this.saturationPass=new Dn(Ma),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new xa,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new Dn(ba),this.fxaaPass.material.uniforms.resolution.value.x=1/(e*r),this.fxaaPass.material.uniforms.resolution.value.y=1/(t*r),this.fxaaPass.enabled=!1,this.composer.addPass(this.fxaaPass)}}var Rn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xs(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Nn(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Li={exports:{}};var Zs;function Sa(){return Zs||(Zs=1,(function(o,e){(function(t){o.exports=t()})(function(){return(function t(n,i,s){function r(c,h){if(!i[c]){if(!n[c]){var d=typeof Nn=="function"&&Nn;if(!h&&d)return d(c,!0);if(a)return a(c,!0);var m=new Error("Cannot find module '"+c+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[c]={exports:{}};n[c][0].call(p.exports,function(f){var u=n[c][1][f];return r(u||f)},p,p.exports,t,n,i,s)}return i[c].exports}for(var a=typeof Nn=="function"&&Nn,l=0;l<s.length;l++)r(s[l]);return r})({1:[function(t,n,i){var s=t("./utils"),r=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,h,d,m,p,f,u,g=[],y=0,v=l.length,w=v,x=s.getTypeOf(l)!=="string";y<l.length;)w=v-y,d=x?(c=l[y++],h=y<v?l[y++]:0,y<v?l[y++]:0):(c=l.charCodeAt(y++),h=y<v?l.charCodeAt(y++):0,y<v?l.charCodeAt(y++):0),m=c>>2,p=(3&c)<<4|h>>4,f=1<w?(15&h)<<2|d>>6:64,u=2<w?63&d:64,g.push(a.charAt(m)+a.charAt(p)+a.charAt(f)+a.charAt(u));return g.join("")},i.decode=function(l){var c,h,d,m,p,f,u=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 v,w=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&w--,l.charAt(l.length-2)===a.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=r.uint8array?new Uint8Array(0|w):new Array(0|w);u<l.length;)c=a.indexOf(l.charAt(u++))<<2|(m=a.indexOf(l.charAt(u++)))>>4,h=(15&m)<<4|(p=a.indexOf(l.charAt(u++)))>>2,d=(3&p)<<6|(f=a.indexOf(l.charAt(u++))),v[g++]=c,p!==64&&(v[g++]=h),f!==64&&(v[g++]=d);return v}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,d,m,p,f){this.compressedSize=h,this.uncompressedSize=d,this.crc32=m,this.compression=p,this.compressedContent=f}c.prototype={getContentWorker:function(){var h=new r(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return h.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new r(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,d,m){return h.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(m)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},n.exports=c},{"./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"),r=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var h=0;h<8;h++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();n.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(c,h,d,m){var p=r,f=m+d;c^=-1;for(var u=m;u<f;u++)c=c>>>8^p[255&(c^h[u])];return-1^c})(0|l,a,a.length,0):(function(c,h,d,m){var p=r,f=m+d;c^=-1;for(var u=m;u<f;u++)c=c>>>8^p[255&(c^h.charCodeAt(u))];return-1^c})(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",r=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),c=s?"uint8array":"array";function h(d,m){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=m,this.meta={}}i.magic="\b\0",a.inherits(h,l),h.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(m){d.push({data:m,meta:d.meta})}},i.compressWorker=function(d){return new h("Deflate",d)},i.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(p,f){var u,g="";for(u=0;u<f;u++)g+=String.fromCharCode(255&p),p>>>=8;return g}function r(p,f,u,g,y,v){var w,x,M=p.file,T=p.compression,P=v!==c.utf8encode,k=a.transformTo("string",v(M.name)),D=a.transformTo("string",c.utf8encode(M.name)),E=M.comment,O=a.transformTo("string",v(E)),A=a.transformTo("string",c.utf8encode(E)),I=D.length!==M.name.length,S=A.length!==E.length,z="",V="",U="",H=M.dir,G=M.date,$={crc32:0,compressedSize:0,uncompressedSize:0};f&&!u||($.crc32=p.crc32,$.compressedSize=p.compressedSize,$.uncompressedSize=p.uncompressedSize);var F=0;f&&(F|=8),P||!I&&!S||(F|=2048);var R=0,te=0;H&&(R|=16),y==="UNIX"?(te=798,R|=(function(q,ce){var fe=q;return q||(fe=ce?16893:33204),(65535&fe)<<16})(M.unixPermissions,H)):(te=20,R|=(function(q){return 63&(q||0)})(M.dosPermissions)),w=G.getUTCHours(),w<<=6,w|=G.getUTCMinutes(),w<<=5,w|=G.getUTCSeconds()/2,x=G.getUTCFullYear()-1980,x<<=4,x|=G.getUTCMonth()+1,x<<=5,x|=G.getUTCDate(),I&&(V=s(1,1)+s(h(k),4)+D,z+="up"+s(V.length,2)+V),S&&(U=s(1,1)+s(h(O),4)+A,z+="uc"+s(U.length,2)+U);var ee="";return ee+=`
961
+ \0`,ee+=s(F,2),ee+=T.magic,ee+=s(w,2),ee+=s(x,2),ee+=s($.crc32,4),ee+=s($.compressedSize,4),ee+=s($.uncompressedSize,4),ee+=s(k.length,2),ee+=s(z.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ee+k+z,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+ee+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"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function m(p,f,u,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=u,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(m,l),m.prototype.push=function(p){var f=p.meta.percent||0,u=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:u?(f+100*(u-g-1))/u:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var f=this.streamFiles&&!p.file.dir;if(f){var u=r(p,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:u.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var f=this.streamFiles&&!p.file.dir,u=r(p,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(u.dirRecord),f)this.push({data:(function(g){return d.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:u.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,f=0;f<this.dirRecords.length;f++)this.push({data:this.dirRecords[f],meta:{percent:100}});var u=this.bytesWritten-p,g=(function(y,v,w,x,M){var T=a.transformTo("string",M(x));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(v,4)+s(w,4)+s(T.length,2)+T})(this.dirRecords.length,u,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var f=this;return p.on("data",function(u){f.processChunk(u)}),p.on("end",function(){f.closedSource(f.previous.streamInfo),f._sources.length?f.prepareNextSource():f.end()}),p.on("error",function(u){f.error(u)}),this},m.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))},m.prototype.error=function(p){var f=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var u=0;u<f.length;u++)try{f[u].error(p)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,f=0;f<p.length;f++)p[f].lock()},n.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),r=t("./ZipFileWorker");i.generateWorker=function(a,l,c){var h=new r(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(m,p){d++;var f=(function(v,w){var x=v||w,M=s[x];if(!M)throw new Error(x+" is not a valid compression method !");return M})(p.options.compression,l.compression),u=p.options.compressionOptions||l.compressionOptions||{},g=p.dir,y=p.date;p._compressWorker(f,u).withStreamInfo("file",{name:m,dir:g,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(m){h.error(m)}return h}},{"../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 r=new s;for(var a in this)typeof this[a]!="function"&&(r[a]=this[a]);return r}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(r,a){return new s().loadAsync(r,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"),r=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(m){return new r.Promise(function(p,f){var u=m.decompressed.getContentWorker().pipe(new c);u.on("error",function(g){f(g)}).on("end",function(){u.streamInfo.crc32!==m.decompressed.crc32?f(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(m,p){var f=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(m)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(u){var g=new l(p);return g.load(u),g}).then(function(u){var g=[r.Promise.resolve(u)],y=u.files;if(p.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return r.Promise.all(g)}).then(function(u){for(var g=u.shift(),y=g.files,v=0;v<y.length;v++){var w=y[v],x=w.fileNameStr,M=s.resolve(w.fileNameStr);f.file(M,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(f.file(M).unsafeOriginalName=x)}return g.zipComment.length&&(f.comment=g.zipComment),f})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),r=t("../stream/GenericWorker");function a(l,c){r.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(a,r),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.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 r(a,l,c){s.call(this,l),this._helper=a;var h=this;a.on("data",function(d,m){h.push(d)||h._helper.pause(),c&&c(m)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(r,s),r.prototype._read=function(){this._helper.resume()},n.exports=r},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,r);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,r)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var r=new Buffer(s);return r.fill(0),r},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(M,T,P){var k,D=a.getTypeOf(T),E=a.extend(P||{},h);E.date=E.date||new Date,E.compression!==null&&(E.compression=E.compression.toUpperCase()),typeof E.unixPermissions=="string"&&(E.unixPermissions=parseInt(E.unixPermissions,8)),E.unixPermissions&&16384&E.unixPermissions&&(E.dir=!0),E.dosPermissions&&16&E.dosPermissions&&(E.dir=!0),E.dir&&(M=y(M)),E.createFolders&&(k=g(M))&&v.call(this,k,!0);var O=D==="string"&&E.binary===!1&&E.base64===!1;P&&P.binary!==void 0||(E.binary=!O),(T instanceof d&&T.uncompressedSize===0||E.dir||!T||T.length===0)&&(E.base64=!1,E.binary=!0,T="",E.compression="STORE",D="string");var A=null;A=T instanceof d||T instanceof l?T:f.isNode&&f.isStream(T)?new u(M,T):a.prepareContent(M,T,E.binary,E.optimizedBinaryString,E.base64);var I=new m(M,A,E);this.files[M]=I}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),m=t("./zipObject"),p=t("./generate"),f=t("./nodejsUtils"),u=t("./nodejs/NodejsStreamInputAdapter"),g=function(M){M.slice(-1)==="/"&&(M=M.substring(0,M.length-1));var T=M.lastIndexOf("/");return 0<T?M.substring(0,T):""},y=function(M){return M.slice(-1)!=="/"&&(M+="/"),M},v=function(M,T){return T=T!==void 0?T:h.createFolders,M=y(M),this.files[M]||s.call(this,M,null,{dir:!0,createFolders:T}),this.files[M]};function w(M){return Object.prototype.toString.call(M)==="[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(M){var T,P,k;for(T in this.files)k=this.files[T],(P=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&M(P,k)},filter:function(M){var T=[];return this.forEach(function(P,k){M(P,k)&&T.push(k)}),T},file:function(M,T,P){if(arguments.length!==1)return M=this.root+M,s.call(this,M,T,P),this;if(w(M)){var k=M;return this.filter(function(E,O){return!O.dir&&k.test(E)})}var D=this.files[this.root+M];return D&&!D.dir?D:null},folder:function(M){if(!M)return this;if(w(M))return this.filter(function(D,E){return E.dir&&M.test(D)});var T=this.root+M,P=v.call(this,T),k=this.clone();return k.root=P.name,k},remove:function(M){M=this.root+M;var T=this.files[M];if(T||(M.slice(-1)!=="/"&&(M+="/"),T=this.files[M]),T&&!T.dir)delete this.files[M];else for(var P=this.filter(function(D,E){return E.name.slice(0,M.length)===M}),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(M){var T,P={};try{if((P=a.extend(M||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.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||"";T=p.generateWorker(this,P,k)}catch(D){(T=new l("error")).error(D)}return new c(T,P.type||"string",P.mimeType)},generateAsync:function(M,T){return this.generateInternalStream(M).accumulate(T)},generateNodeStream:function(M,T){return(M=M||{}).type||(M.type="nodebuffer"),this.generateInternalStream(M).toNodejsStream(T)}};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 r(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),d=a.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===c&&this.data[m+2]===h&&this.data[m+3]===d)return m-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),d=a.charCodeAt(3),m=this.readData(4);return l===m[0]&&c===m[1]&&h===m[2]&&d===m[3]},r.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=r},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var s=t("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.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,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},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=r},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.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=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.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=r},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.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=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),r=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");n.exports=function(d){var m=s.getTypeOf(d);return s.checkSupport(m),m!=="string"||r.uint8array?m==="nodebuffer"?new c(d):r.uint8array?new h(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../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"),r=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}r.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:r.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),r=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=r(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"),r=t("./GenericWorker");function a(l){r.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,r),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}r.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=s.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}s.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.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,c=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,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,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(r){this.name=r||"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(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var l=0;l<this._listeners[r].length;l++)this._listeners[r][l].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(l){a.processChunk(l)}),r.on("end",function(){a.end()}),r.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 r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},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 r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),d=null;if(c.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(f,u){return new h.Promise(function(g,y){var v=[],w=f._internalType,x=f._outputType,M=f._mimeType;f.on("data",function(T,P){v.push(T),u&&u(P)}).on("error",function(T){v=[],y(T)}).on("end",function(){try{var T=(function(P,k,D){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",k),D);case"base64":return l.encode(k);default:return s.transformTo(P,k)}})(x,(function(P,k){var D,E=0,O=null,A=0;for(D=0;D<k.length;D++)A+=k[D].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(A),D=0;D<k.length;D++)O.set(k[D],E),E+=k[D].length;return O;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+P+"'")}})(w,v),M);g(T)}catch(P){y(P)}v=[]}).resume()})}function p(f,u,g){var y=u;switch(u){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=u,this._mimeType=g,s.checkSupport(y),this._worker=f.pipe(new r(y)),f.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}p.prototype={accumulate:function(f){return m(this,f)},on:function(f,u){var g=this;return f==="data"?this._worker.on(f,function(y){u.call(g,y.data,y.meta)}):this._worker.on(f,function(){s.delay(u,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(f){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},f)}},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 r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(s),i.blob=r.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"),r=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}i.utf8encode=function(p){return r.nodebuffer?a.newBufferFrom(p,"utf-8"):(function(f){var u,g,y,v,w,x=f.length,M=0;for(v=0;v<x;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),M+=g<128?1:g<2048?2:g<65536?3:4;for(u=r.uint8array?new Uint8Array(M):new Array(M),v=w=0;w<M;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?u[w++]=g:(g<2048?u[w++]=192|g>>>6:(g<65536?u[w++]=224|g>>>12:(u[w++]=240|g>>>18,u[w++]=128|g>>>12&63),u[w++]=128|g>>>6&63),u[w++]=128|63&g);return u})(p)},i.utf8decode=function(p){return r.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(f){var u,g,y,v,w=f.length,x=new Array(2*w);for(u=g=0;u<w;)if((y=f[u++])<128)x[g++]=y;else if(4<(v=c[y]))x[g++]=65533,u+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&u<w;)y=y<<6|63&f[u++],v--;1<v?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(r.uint8array?"uint8array":"array",p))},s.inherits(d,l),d.prototype.processChunk=function(p){var f=s.transformTo(r.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var u=f;(f=new Uint8Array(u.length+this.leftOver.length)).set(this.leftOver,0),f.set(u,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var g=(function(v,w){var x;for((w=w||v.length)>v.length&&(w=v.length),x=w-1;0<=x&&(192&v[x])==128;)x--;return x<0||x===0?w:x+c[v[x]]>w?x:w})(f),y=f;g!==f.length&&(r.uint8array?(y=f.subarray(0,g),this.leftOver=f.subarray(g,f.length)):(y=f.slice(0,g),this.leftOver=f.slice(g,f.length))),this.push({data:i.utf8decode(y),meta:p.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,s.inherits(m,l),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(u){return u}function h(u,g){for(var y=0;y<u.length;++y)g[y]=255&u.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(u,g){i.checkSupport("blob");try{return new Blob([u],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(u),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(u,g,y){var v=[],w=0,x=u.length;if(x<=y)return String.fromCharCode.apply(null,u);for(;w<x;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,u.slice(w,Math.min(w+y,x)))):v.push(String.fromCharCode.apply(null,u.subarray(w,Math.min(w+y,x)))),w+=y;return v.join("")},stringifyByChar:function(u){for(var g="",y=0;y<u.length;y++)g+=String.fromCharCode(u[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 m(u){var g=65536,y=i.getTypeOf(u),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(u,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(u)}function p(u,g){for(var y=0;y<u.length;y++)g[y]=u[y];return g}i.applyFromCharCode=m;var f={};f.string={string:c,array:function(u){return h(u,new Array(u.length))},arraybuffer:function(u){return f.string.uint8array(u).buffer},uint8array:function(u){return h(u,new Uint8Array(u.length))},nodebuffer:function(u){return h(u,a.allocBuffer(u.length))}},f.array={string:m,array:c,arraybuffer:function(u){return new Uint8Array(u).buffer},uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return a.newBufferFrom(u)}},f.arraybuffer={string:function(u){return m(new Uint8Array(u))},array:function(u){return p(new Uint8Array(u),new Array(u.byteLength))},arraybuffer:c,uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return a.newBufferFrom(new Uint8Array(u))}},f.uint8array={string:m,array:function(u){return p(u,new Array(u.length))},arraybuffer:function(u){return u.buffer},uint8array:c,nodebuffer:function(u){return a.newBufferFrom(u)}},f.nodebuffer={string:m,array:function(u){return p(u,new Array(u.length))},arraybuffer:function(u){return f.nodebuffer.uint8array(u).buffer},uint8array:function(u){return p(u,new Uint8Array(u.length))},nodebuffer:c},i.transformTo=function(u,g){if(g=g||"",!u)return g;i.checkSupport(u);var y=i.getTypeOf(g);return f[y][u](g)},i.resolve=function(u){for(var g=u.split("/"),y=[],v=0;v<g.length;v++){var w=g[v];w==="."||w===""&&v!==0&&v!==g.length-1||(w===".."?y.pop():y.push(w))}return y.join("/")},i.getTypeOf=function(u){return typeof u=="string"?"string":Object.prototype.toString.call(u)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(u)?"nodebuffer":s.uint8array&&u instanceof Uint8Array?"uint8array":s.arraybuffer&&u instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(u){if(!s[u.toLowerCase()])throw new Error(u+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(u){var g,y,v="";for(y=0;y<(u||"").length;y++)v+="\\x"+((g=u.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(u,g,y){setImmediate(function(){u.apply(y||null,g||[])})},i.inherits=function(u,g){function y(){}y.prototype=g.prototype,u.prototype=new y},i.extend=function(){var u,g,y={};for(u=0;u<arguments.length;u++)for(g in arguments[u])Object.prototype.hasOwnProperty.call(arguments[u],g)&&y[g]===void 0&&(y[g]=arguments[u][g]);return y},i.prepareContent=function(u,g,y,v,w){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(M,T){var P=new FileReader;P.onload=function(k){M(k.target.result)},P.onerror=function(k){T(k.target.error)},P.readAsArrayBuffer(x)}):x}).then(function(x){var M=i.getTypeOf(x);return M?(M==="arraybuffer"?x=i.transformTo("uint8array",x):M==="string"&&(w?x=r.decode(x):y&&v!==!0&&(x=(function(T){return h(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(x))),x):l.Promise.reject(new Error("Can't read the data of '"+u+"'. 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"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function h(d){this.files=[],this.loadOptions=d}h.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(m)+", expected "+r.pretty(d)+")")}},isSignature:function(d,m){var p=this.reader.index;this.reader.setIndex(d);var f=this.reader.readString(4)===m;return this.reader.setIndex(p),f},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 d=this.reader.readData(this.zipCommentLength),m=c.uint8array?"uint8array":"array",p=r.transformTo(m,d);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 d,m,p,f=this.zip64EndOfCentralSize-44;0<f;)d=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[d]={id:d,length:m,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 d,m;for(d=0;d<this.files.length;d++)m=this.files[d],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);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 d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<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(d);var m=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(d=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(d),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 f=m-p;if(0<f)this.isSignature(m,a.CENTRAL_FILE_HEADER)||(this.reader.zero=f);else if(f<0)throw new Error("Corrupted zip: missing "+Math.abs(f)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function m(p,f){this.options=p,this.loadOptions=f}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var f,u;if(p.skip(22),this.fileNameLength=p.readInt(2),u=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(u),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((f=(function(g){for(var y in h)if(Object.prototype.hasOwnProperty.call(h,y)&&h[y].magic===g)return h[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,f,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 f=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(f),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===r.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var f,u,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)f=p.readInt(2),u=p.readInt(2),g=p.readData(u),this.extraFields[f]={id:f,length:u,value:g};p.setIndex(y)},handleUTF8:function(){var p=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var f=this.findExtraFieldUnicodePath();if(f!==null)this.fileNameStr=f;else{var u=r.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(u)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=r.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileName)!==f.readInt(4)?null:c.utf8decode(f.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileComment)!==f.readInt(4)?null:c.utf8decode(f.readData(p.length-5))}return null}},n.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(f,u,g){this.name=f,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=u,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");s.prototype={internalStream:function(f){var u=null,g="string";try{if(!f)throw new Error("No output type specified.");var y=(g=f.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),u=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(u=u.pipe(new l.Utf8EncodeWorker)),!v&&y&&(u=u.pipe(new l.Utf8DecodeWorker))}catch(w){(u=new h("error")).error(w)}return new r(u,g,"")},async:function(f,u){return this.internalStream(f).accumulate(u)},nodeStream:function(f,u){return this.internalStream(f||"nodebuffer").toNodejsStream(u)},_compressWorker:function(f,u){if(this._data instanceof c&&this._data.compression.magic===f.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,f,u)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<d.length;p++)s.prototype[d[p]]=m;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var r,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,h=new l(f),d=s.document.createTextNode("");h.observe(d,{characterData:!0}),r=function(){d.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)r="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var u=s.document.createElement("script");u.onreadystatechange=function(){f(),u.onreadystatechange=null,u.parentNode.removeChild(u),u=null},s.document.documentElement.appendChild(u)}:function(){setTimeout(f,0)};else{var m=new s.MessageChannel;m.port1.onmessage=f,r=function(){m.port2.postMessage(0)}}var p=[];function f(){var u,g;a=!0;for(var y=p.length;y;){for(g=p,p=[],u=-1;++u<y;)g[u]();y=p.length}a=!1}n.exports=function(u){p.push(u)!==1||a||r()}}).call(this,typeof Rn<"u"?Rn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var s=t("immediate");function r(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,y!==r&&u(this,y)}function m(y,v,w){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(y,v,w){s(function(){var x;try{x=v(w)}catch(M){return a.reject(y,M)}x===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,x)})}function f(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function u(y,v){var w=!1;function x(P){w||(w=!0,a.reject(y,P))}function M(P){w||(w=!0,a.resolve(y,P))}var T=g(function(){v(M,x)});T.status==="error"&&x(T.value)}function g(y,v){var w={};try{w.value=y(v),w.status="success"}catch(x){w.status="error",w.value=x}return w}(n.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(w){return v.resolve(y()).then(function(){return w})},function(w){return v.resolve(y()).then(function(){throw w})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var w=new this.constructor(r);return this.state!==h?p(w,this.state===c?y:v,this.outcome):this.queue.push(new m(w,y,v)),w},m.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},m.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},m.prototype.callRejected=function(y){a.reject(this.promise,y)},m.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},a.resolve=function(y,v){var w=g(f,v);if(w.status==="error")return a.reject(y,w.value);var x=w.value;if(x)u(y,x);else{y.state=c,y.outcome=v;for(var M=-1,T=y.queue.length;++M<T;)y.queue[M].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var w=-1,x=y.queue.length;++w<x;)y.queue[w].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(r),y)},d.reject=function(y){var v=new this(r);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,x=!1;if(!w)return this.resolve([]);for(var M=new Array(w),T=0,P=-1,k=new this(r);++P<w;)D(y[P],P);return k;function D(E,O){v.resolve(E).then(function(A){M[O]=A,++T!==w||x||(x=!0,a.resolve(k,M))},function(A){x||(x=!0,a.reject(k,A))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,x=!1;if(!w)return this.resolve([]);for(var M=-1,T=new this(r);++M<w;)P=y[M],v.resolve(P).then(function(k){x||(x=!0,a.resolve(T,k))},function(k){x||(x=!0,a.reject(T,k))});var P;return T}},{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"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString,d=0,m=-1,p=0,f=8;function u(y){if(!(this instanceof u))return new u(y);this.options=r.assign({level:m,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var w=s.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(w!==d)throw new Error(l[w]);if(v.header&&s.deflateSetHeader(this.strm,v.header),v.dictionary){var x;if(x=typeof v.dictionary=="string"?a.string2buf(v.dictionary):h.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(w=s.deflateSetDictionary(this.strm,x))!==d)throw new Error(l[w]);this._dict_set=!0}}function g(y,v){var w=new u(v);if(w.push(y,!0),w.err)throw w.msg||l[w.err];return w.result}u.prototype.push=function(y,v){var w,x,M=this.strm,T=this.options.chunkSize;if(this.ended)return!1;x=v===~~v?v:v===!0?4:0,typeof y=="string"?M.input=a.string2buf(y):h.call(y)==="[object ArrayBuffer]"?M.input=new Uint8Array(y):M.input=y,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new r.Buf8(T),M.next_out=0,M.avail_out=T),(w=s.deflate(M,x))!==1&&w!==d)return this.onEnd(w),!(this.ended=!0);M.avail_out!==0&&(M.avail_in!==0||x!==4&&x!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(r.shrinkBuf(M.output,M.next_out))):this.onData(r.shrinkBuf(M.output,M.next_out)))}while((0<M.avail_in||M.avail_out===0)&&w!==1);return x===4?(w=s.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===d):x!==2||(this.onEnd(d),!(M.avail_out=0))},u.prototype.onData=function(y){this.chunks.push(y)},u.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=u,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./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"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),d=t("./zlib/gzheader"),m=Object.prototype.toString;function p(u){if(!(this instanceof p))return new p(u);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},u||{});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)||u&&u.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 h,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,s.inflateGetHeader(this.strm,this.header)}function f(u,g){var y=new p(g);if(y.push(u,!0),y.err)throw y.msg||c[y.err];return y.result}p.prototype.push=function(u,g){var y,v,w,x,M,T,P=this.strm,k=this.options.chunkSize,D=this.options.dictionary,E=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof u=="string"?P.input=a.binstring2buf(u):m.call(u)==="[object ArrayBuffer]"?P.input=new Uint8Array(u):P.input=u,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new r.Buf8(k),P.next_out=0,P.avail_out=k),(y=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&D&&(T=typeof D=="string"?a.string2buf(D):m.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,y=s.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&E===!0&&(y=l.Z_OK,E=!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||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=a.utf8border(P.output,P.next_out),x=P.next_out-w,M=a.buf2string(P.output,w),P.next_out=x,P.avail_out=k-x,x&&r.arraySet(P.output,P.output,w,x,0),this.onData(M)):this.onData(r.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(E=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},p.prototype.onData=function(u){this.chunks.push(u)},p.prototype.onEnd=function(u){u===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg},i.Inflate=p,i.inflate=f,i.inflateRaw=function(u,g){return(g=g||{}).raw=!0,f(u,g)},i.ungzip=f},{"./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 c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var d in h)h.hasOwnProperty(d)&&(l[d]=h[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var r={arraySet:function(l,c,h,d,m){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),m);else for(var p=0;p<d;p++)l[m+p]=c[h+p]},flattenChunks:function(l){var c,h,d,m,p,f;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(f=new Uint8Array(d),c=m=0,h=l.length;c<h;c++)p=l[c],f.set(p,m),m+=p.length;return f}},a={arraySet:function(l,c,h,d,m){for(var p=0;p<d;p++)l[m+p]=c[h+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,r)):(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"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(d,m){if(m<65537&&(d.subarray&&a||!d.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(d,m));for(var p="",f=0;f<m;f++)p+=String.fromCharCode(d[f]);return p}l[254]=l[254]=1,i.string2buf=function(d){var m,p,f,u,g,y=d.length,v=0;for(u=0;u<y;u++)(64512&(p=d.charCodeAt(u)))==55296&&u+1<y&&(64512&(f=d.charCodeAt(u+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),u++),v+=p<128?1:p<2048?2:p<65536?3:4;for(m=new s.Buf8(v),u=g=0;g<v;u++)(64512&(p=d.charCodeAt(u)))==55296&&u+1<y&&(64512&(f=d.charCodeAt(u+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),u++),p<128?m[g++]=p:(p<2048?m[g++]=192|p>>>6:(p<65536?m[g++]=224|p>>>12:(m[g++]=240|p>>>18,m[g++]=128|p>>>12&63),m[g++]=128|p>>>6&63),m[g++]=128|63&p);return m},i.buf2binstring=function(d){return h(d,d.length)},i.binstring2buf=function(d){for(var m=new s.Buf8(d.length),p=0,f=m.length;p<f;p++)m[p]=d.charCodeAt(p);return m},i.buf2string=function(d,m){var p,f,u,g,y=m||d.length,v=new Array(2*y);for(p=f=0;p<y;)if((u=d[p++])<128)v[f++]=u;else if(4<(g=l[u]))v[f++]=65533,p+=g-1;else{for(u&=g===2?31:g===3?15:7;1<g&&p<y;)u=u<<6|63&d[p++],g--;1<g?v[f++]=65533:u<65536?v[f++]=u:(u-=65536,v[f++]=55296|u>>10&1023,v[f++]=56320|1023&u)}return h(v,f)},i.utf8border=function(d,m){var p;for((m=m||d.length)>d.length&&(m=d.length),p=m-1;0<=p&&(192&d[p])==128;)p--;return p<0||p===0?m:p+l[d[p]]>m?p:m}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,r,a,l){for(var c=65535&s|0,h=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;h=h+(c=c+r[l++]|0)|0,--d;);c%=65521,h%=65521}return c|h<<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 r,a=[],l=0;l<256;l++){r=l;for(var c=0;c<8;c++)r=1&r?3988292384^r>>>1:r>>>1;a[l]=r}return a})();n.exports=function(r,a,l,c){var h=s,d=c+l;r^=-1;for(var m=c;m<d;m++)r=r>>>8^h[255&(r^a[m])];return-1^r}},{}],46:[function(t,n,i){var s,r=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,m=4,p=0,f=-2,u=-1,g=4,y=2,v=8,w=9,x=286,M=30,T=19,P=2*x+1,k=15,D=3,E=258,O=E+D+1,A=42,I=113,S=1,z=2,V=3,U=4;function H(C,Z){return C.msg=h[Z],Z}function G(C){return(C<<1)-(4<C?9:0)}function $(C){for(var Z=C.length;0<=--Z;)C[Z]=0}function F(C){var Z=C.state,X=Z.pending;X>C.avail_out&&(X=C.avail_out),X!==0&&(r.arraySet(C.output,Z.pending_buf,Z.pending_out,X,C.next_out),C.next_out+=X,Z.pending_out+=X,C.total_out+=X,C.avail_out-=X,Z.pending-=X,Z.pending===0&&(Z.pending_out=0))}function R(C,Z){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,Z),C.block_start=C.strstart,F(C.strm)}function te(C,Z){C.pending_buf[C.pending++]=Z}function ee(C,Z){C.pending_buf[C.pending++]=Z>>>8&255,C.pending_buf[C.pending++]=255&Z}function q(C,Z){var X,B,L=C.max_chain_length,N=C.strstart,Y=C.prev_length,K=C.nice_match,j=C.strstart>C.w_size-O?C.strstart-(C.w_size-O):0,J=C.window,ne=C.w_mask,Q=C.prev,ie=C.strstart+E,he=J[N+Y-1],ae=J[N+Y];C.prev_length>=C.good_match&&(L>>=2),K>C.lookahead&&(K=C.lookahead);do if(J[(X=Z)+Y]===ae&&J[X+Y-1]===he&&J[X]===J[N]&&J[++X]===J[N+1]){N+=2,X++;do;while(J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&N<ie);if(B=E-(ie-N),N=ie-E,Y<B){if(C.match_start=Z,K<=(Y=B))break;he=J[N+Y-1],ae=J[N+Y]}}while((Z=Q[Z&ne])>j&&--L!=0);return Y<=C.lookahead?Y:C.lookahead}function ce(C){var Z,X,B,L,N,Y,K,j,J,ne,Q=C.w_size;do{if(L=C.window_size-C.lookahead-C.strstart,C.strstart>=Q+(Q-O)){for(r.arraySet(C.window,C.window,Q,Q,0),C.match_start-=Q,C.strstart-=Q,C.block_start-=Q,Z=X=C.hash_size;B=C.head[--Z],C.head[Z]=Q<=B?B-Q:0,--X;);for(Z=X=Q;B=C.prev[--Z],C.prev[Z]=Q<=B?B-Q:0,--X;);L+=Q}if(C.strm.avail_in===0)break;if(Y=C.strm,K=C.window,j=C.strstart+C.lookahead,J=L,ne=void 0,ne=Y.avail_in,J<ne&&(ne=J),X=ne===0?0:(Y.avail_in-=ne,r.arraySet(K,Y.input,Y.next_in,ne,j),Y.state.wrap===1?Y.adler=l(Y.adler,K,ne,j):Y.state.wrap===2&&(Y.adler=c(Y.adler,K,ne,j)),Y.next_in+=ne,Y.total_in+=ne,ne),C.lookahead+=X,C.lookahead+C.insert>=D)for(N=C.strstart-C.insert,C.ins_h=C.window[N],C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+D-1])&C.hash_mask,C.prev[N&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=N,N++,C.insert--,!(C.lookahead+C.insert<D)););}while(C.lookahead<O&&C.strm.avail_in!==0)}function fe(C,Z){for(var X,B;;){if(C.lookahead<O){if(ce(C),C.lookahead<O&&Z===d)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=D&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),X!==0&&C.strstart-X<=C.w_size-O&&(C.match_length=q(C,X)),C.match_length>=D)if(B=a._tr_tally(C,C.strstart-C.match_start,C.match_length-D),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=D){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,--C.match_length!=0;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else B=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(B&&(R(C,!1),C.strm.avail_out===0))return S}return C.insert=C.strstart<D-1?C.strstart:D-1,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?S:z}function se(C,Z){for(var X,B,L;;){if(C.lookahead<O){if(ce(C),C.lookahead<O&&Z===d)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=D&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=D-1,X!==0&&C.prev_length<C.max_lazy_match&&C.strstart-X<=C.w_size-O&&(C.match_length=q(C,X),C.match_length<=5&&(C.strategy===1||C.match_length===D&&4096<C.strstart-C.match_start)&&(C.match_length=D-1)),C.prev_length>=D&&C.match_length<=C.prev_length){for(L=C.strstart+C.lookahead-D,B=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-D),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=L&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),--C.prev_length!=0;);if(C.match_available=0,C.match_length=D-1,C.strstart++,B&&(R(C,!1),C.strm.avail_out===0))return S}else if(C.match_available){if((B=a._tr_tally(C,0,C.window[C.strstart-1]))&&R(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return S}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(B=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<D-1?C.strstart:D-1,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?S:z}function oe(C,Z,X,B,L){this.good_length=C,this.max_lazy=Z,this.nice_length=X,this.max_chain=B,this.func=L}function ue(){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=v,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 r.Buf16(2*P),this.dyn_dtree=new r.Buf16(2*(2*M+1)),this.bl_tree=new r.Buf16(2*(2*T+1)),$(this.dyn_ltree),$(this.dyn_dtree),$(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(k+1),this.heap=new r.Buf16(2*x+1),$(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*x+1),$(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(C){var Z;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=y,(Z=C.state).pending=0,Z.pending_out=0,Z.wrap<0&&(Z.wrap=-Z.wrap),Z.status=Z.wrap?A:I,C.adler=Z.wrap===2?0:1,Z.last_flush=d,a._tr_init(Z),p):H(C,f)}function Ce(C){var Z=pe(C);return Z===p&&(function(X){X.window_size=2*X.w_size,$(X.head),X.max_lazy_match=s[X.level].max_lazy,X.good_match=s[X.level].good_length,X.nice_match=s[X.level].nice_length,X.max_chain_length=s[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=D-1,X.match_available=0,X.ins_h=0})(C.state),Z}function Be(C,Z,X,B,L,N){if(!C)return f;var Y=1;if(Z===u&&(Z=6),B<0?(Y=0,B=-B):15<B&&(Y=2,B-=16),L<1||w<L||X!==v||B<8||15<B||Z<0||9<Z||N<0||g<N)return H(C,f);B===8&&(B=9);var K=new ue;return(C.state=K).strm=C,K.wrap=Y,K.gzhead=null,K.w_bits=B,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=L+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+D-1)/D),K.window=new r.Buf8(2*K.w_size),K.head=new r.Buf16(K.hash_size),K.prev=new r.Buf16(K.w_size),K.lit_bufsize=1<<L+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new r.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=Z,K.strategy=N,K.method=X,Ce(C)}s=[new oe(0,0,0,0,function(C,Z){var X=65535;for(X>C.pending_buf_size-5&&(X=C.pending_buf_size-5);;){if(C.lookahead<=1){if(ce(C),C.lookahead===0&&Z===d)return S;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var B=C.block_start+X;if((C.strstart===0||C.strstart>=B)&&(C.lookahead=C.strstart-B,C.strstart=B,R(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-O&&(R(C,!1),C.strm.avail_out===0))return S}return C.insert=0,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):(C.strstart>C.block_start&&(R(C,!1),C.strm.avail_out),S)}),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(C,Z){return Be(C,Z,v,15,8,0)},i.deflateInit2=Be,i.deflateReset=Ce,i.deflateResetKeep=pe,i.deflateSetHeader=function(C,Z){return C&&C.state?C.state.wrap!==2?f:(C.state.gzhead=Z,p):f},i.deflate=function(C,Z){var X,B,L,N;if(!C||!C.state||5<Z||Z<0)return C?H(C,f):f;if(B=C.state,!C.output||!C.input&&C.avail_in!==0||B.status===666&&Z!==m)return H(C,C.avail_out===0?-5:f);if(B.strm=C,X=B.last_flush,B.last_flush=Z,B.status===A)if(B.wrap===2)C.adler=0,te(B,31),te(B,139),te(B,8),B.gzhead?(te(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),te(B,255&B.gzhead.time),te(B,B.gzhead.time>>8&255),te(B,B.gzhead.time>>16&255),te(B,B.gzhead.time>>24&255),te(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),te(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(te(B,255&B.gzhead.extra.length),te(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(C.adler=c(C.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(te(B,0),te(B,0),te(B,0),te(B,0),te(B,0),te(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),te(B,3),B.status=I);else{var Y=v+(B.w_bits-8<<4)<<8;Y|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Y|=32),Y+=31-Y%31,B.status=I,ee(B,Y),B.strstart!==0&&(ee(B,C.adler>>>16),ee(B,65535&C.adler)),C.adler=1}if(B.status===69)if(B.gzhead.extra){for(L=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending!==B.pending_buf_size));)te(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending===B.pending_buf_size)){N=1;break}N=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,te(B,N)}while(N!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending===B.pending_buf_size)){N=1;break}N=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,te(B,N)}while(N!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&F(C),B.pending+2<=B.pending_buf_size&&(te(B,255&C.adler),te(B,C.adler>>8&255),C.adler=0,B.status=I)):B.status=I),B.pending!==0){if(F(C),C.avail_out===0)return B.last_flush=-1,p}else if(C.avail_in===0&&G(Z)<=G(X)&&Z!==m)return H(C,-5);if(B.status===666&&C.avail_in!==0)return H(C,-5);if(C.avail_in!==0||B.lookahead!==0||Z!==d&&B.status!==666){var K=B.strategy===2?(function(j,J){for(var ne;;){if(j.lookahead===0&&(ce(j),j.lookahead===0)){if(J===d)return S;break}if(j.match_length=0,ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++,ne&&(R(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(R(j,!0),j.strm.avail_out===0?V:U):j.last_lit&&(R(j,!1),j.strm.avail_out===0)?S:z})(B,Z):B.strategy===3?(function(j,J){for(var ne,Q,ie,he,ae=j.window;;){if(j.lookahead<=E){if(ce(j),j.lookahead<=E&&J===d)return S;if(j.lookahead===0)break}if(j.match_length=0,j.lookahead>=D&&0<j.strstart&&(Q=ae[ie=j.strstart-1])===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]){he=j.strstart+E;do;while(Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&ie<he);j.match_length=E-(he-ie),j.match_length>j.lookahead&&(j.match_length=j.lookahead)}if(j.match_length>=D?(ne=a._tr_tally(j,1,j.match_length-D),j.lookahead-=j.match_length,j.strstart+=j.match_length,j.match_length=0):(ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++),ne&&(R(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(R(j,!0),j.strm.avail_out===0?V:U):j.last_lit&&(R(j,!1),j.strm.avail_out===0)?S:z})(B,Z):s[B.level].func(B,Z);if(K!==V&&K!==U||(B.status=666),K===S||K===V)return C.avail_out===0&&(B.last_flush=-1),p;if(K===z&&(Z===1?a._tr_align(B):Z!==5&&(a._tr_stored_block(B,0,0,!1),Z===3&&($(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),F(C),C.avail_out===0))return B.last_flush=-1,p}return Z!==m?p:B.wrap<=0?1:(B.wrap===2?(te(B,255&C.adler),te(B,C.adler>>8&255),te(B,C.adler>>16&255),te(B,C.adler>>24&255),te(B,255&C.total_in),te(B,C.total_in>>8&255),te(B,C.total_in>>16&255),te(B,C.total_in>>24&255)):(ee(B,C.adler>>>16),ee(B,65535&C.adler)),F(C),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(C){var Z;return C&&C.state?(Z=C.state.status)!==A&&Z!==69&&Z!==73&&Z!==91&&Z!==103&&Z!==I&&Z!==666?H(C,f):(C.state=null,Z===I?H(C,-3):p):f},i.deflateSetDictionary=function(C,Z){var X,B,L,N,Y,K,j,J,ne=Z.length;if(!C||!C.state||(N=(X=C.state).wrap)===2||N===1&&X.status!==A||X.lookahead)return f;for(N===1&&(C.adler=l(C.adler,Z,ne,0)),X.wrap=0,ne>=X.w_size&&(N===0&&($(X.head),X.strstart=0,X.block_start=0,X.insert=0),J=new r.Buf8(X.w_size),r.arraySet(J,Z,ne-X.w_size,X.w_size,0),Z=J,ne=X.w_size),Y=C.avail_in,K=C.next_in,j=C.input,C.avail_in=ne,C.next_in=0,C.input=Z,ce(X);X.lookahead>=D;){for(B=X.strstart,L=X.lookahead-(D-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[B+D-1])&X.hash_mask,X.prev[B&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=B,B++,--L;);X.strstart=B,X.lookahead=D-1,ce(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=D-1,X.match_available=0,C.next_in=K,C.input=j,C.avail_in=Y,X.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,r){var a,l,c,h,d,m,p,f,u,g,y,v,w,x,M,T,P,k,D,E,O,A,I,S,z;a=s.state,l=s.next_in,S=s.input,c=l+(s.avail_in-5),h=s.next_out,z=s.output,d=h-(r-s.avail_out),m=h+(s.avail_out-257),p=a.dmax,f=a.wsize,u=a.whave,g=a.wnext,y=a.window,v=a.hold,w=a.bits,x=a.lencode,M=a.distcode,T=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{w<15&&(v+=S[l++]<<w,w+=8,v+=S[l++]<<w,w+=8),k=x[v&T];t:for(;;){if(v>>>=D=k>>>24,w-=D,(D=k>>>16&255)===0)z[h++]=65535&k;else{if(!(16&D)){if((64&D)==0){k=x[(65535&k)+(v&(1<<D)-1)];continue t}if(32&D){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}E=65535&k,(D&=15)&&(w<D&&(v+=S[l++]<<w,w+=8),E+=v&(1<<D)-1,v>>>=D,w-=D),w<15&&(v+=S[l++]<<w,w+=8,v+=S[l++]<<w,w+=8),k=M[v&P];n:for(;;){if(v>>>=D=k>>>24,w-=D,!(16&(D=k>>>16&255))){if((64&D)==0){k=M[(65535&k)+(v&(1<<D)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,w<(D&=15)&&(v+=S[l++]<<w,(w+=8)<D&&(v+=S[l++]<<w,w+=8)),p<(O+=v&(1<<D)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=D,w-=D,(D=h-d)<O){if(u<(D=O-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=y,(A=0)===g){if(A+=f-D,D<E){for(E-=D;z[h++]=y[A++],--D;);A=h-O,I=z}}else if(g<D){if(A+=f+g-D,(D-=g)<E){for(E-=D;z[h++]=y[A++],--D;);if(A=0,g<E){for(E-=D=g;z[h++]=y[A++],--D;);A=h-O,I=z}}}else if(A+=g-D,D<E){for(E-=D;z[h++]=y[A++],--D;);A=h-O,I=z}for(;2<E;)z[h++]=I[A++],z[h++]=I[A++],z[h++]=I[A++],E-=3;E&&(z[h++]=I[A++],1<E&&(z[h++]=I[A++]))}else{for(A=h-O;z[h++]=z[A++],z[h++]=z[A++],z[h++]=z[A++],2<(E-=3););E&&(z[h++]=z[A++],1<E&&(z[h++]=z[A++]))}break}}break}}while(l<c&&h<m);l-=E=w>>3,v&=(1<<(w-=E<<3))-1,s.next_in=l,s.next_out=h,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=h<m?m-h+257:257-(h-m),a.hold=v,a.bits=w}},{}],49:[function(t,n,i){var s=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,m=0,p=-2,f=1,u=852,g=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function v(){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 w(A){var I;return A&&A.state?(I=A.state,A.total_in=A.total_out=I.total=0,A.msg="",I.wrap&&(A.adler=1&I.wrap),I.mode=f,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new s.Buf32(u),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,m):p}function x(A){var I;return A&&A.state?((I=A.state).wsize=0,I.whave=0,I.wnext=0,w(A)):p}function M(A,I){var S,z;return A&&A.state?(z=A.state,I<0?(S=0,I=-I):(S=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?p:(z.window!==null&&z.wbits!==I&&(z.window=null),z.wrap=S,z.wbits=I,x(A))):p}function T(A,I){var S,z;return A?(z=new v,(A.state=z).window=null,(S=M(A,I))!==m&&(A.state=null),S):p}var P,k,D=!0;function E(A){if(D){var I;for(P=new s.Buf32(512),k=new s.Buf32(32),I=0;I<144;)A.lens[I++]=8;for(;I<256;)A.lens[I++]=9;for(;I<280;)A.lens[I++]=7;for(;I<288;)A.lens[I++]=8;for(c(h,A.lens,0,288,P,0,A.work,{bits:9}),I=0;I<32;)A.lens[I++]=5;c(d,A.lens,0,32,k,0,A.work,{bits:5}),D=!1}A.lencode=P,A.lenbits=9,A.distcode=k,A.distbits=5}function O(A,I,S,z){var V,U=A.state;return U.window===null&&(U.wsize=1<<U.wbits,U.wnext=0,U.whave=0,U.window=new s.Buf8(U.wsize)),z>=U.wsize?(s.arraySet(U.window,I,S-U.wsize,U.wsize,0),U.wnext=0,U.whave=U.wsize):(z<(V=U.wsize-U.wnext)&&(V=z),s.arraySet(U.window,I,S-z,V,U.wnext),(z-=V)?(s.arraySet(U.window,I,S-z,z,0),U.wnext=z,U.whave=U.wsize):(U.wnext+=V,U.wnext===U.wsize&&(U.wnext=0),U.whave<U.wsize&&(U.whave+=V))),0}i.inflateReset=x,i.inflateReset2=M,i.inflateResetKeep=w,i.inflateInit=function(A){return T(A,15)},i.inflateInit2=T,i.inflate=function(A,I){var S,z,V,U,H,G,$,F,R,te,ee,q,ce,fe,se,oe,ue,pe,Ce,Be,C,Z,X,B,L=0,N=new s.Buf8(4),Y=[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;(S=A.state).mode===12&&(S.mode=13),H=A.next_out,V=A.output,$=A.avail_out,U=A.next_in,z=A.input,G=A.avail_in,F=S.hold,R=S.bits,te=G,ee=$,Z=m;e:for(;;)switch(S.mode){case f:if(S.wrap===0){S.mode=13;break}for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(2&S.wrap&&F===35615){N[S.check=0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0),R=F=0,S.mode=2;break}if(S.flags=0,S.head&&(S.head.done=!1),!(1&S.wrap)||(((255&F)<<8)+(F>>8))%31){A.msg="incorrect header check",S.mode=30;break}if((15&F)!=8){A.msg="unknown compression method",S.mode=30;break}if(R-=4,C=8+(15&(F>>>=4)),S.wbits===0)S.wbits=C;else if(C>S.wbits){A.msg="invalid window size",S.mode=30;break}S.dmax=1<<C,A.adler=S.check=1,S.mode=512&F?10:12,R=F=0;break;case 2:for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(S.flags=F,(255&S.flags)!=8){A.msg="unknown compression method",S.mode=30;break}if(57344&S.flags){A.msg="unknown header flags set",S.mode=30;break}S.head&&(S.head.text=F>>8&1),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0,S.mode=3;case 3:for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.head&&(S.head.time=F),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,N[2]=F>>>16&255,N[3]=F>>>24&255,S.check=a(S.check,N,4,0)),R=F=0,S.mode=4;case 4:for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.head&&(S.head.xflags=255&F,S.head.os=F>>8),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0,S.mode=5;case 5:if(1024&S.flags){for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.length=F,S.head&&(S.head.extra_len=F),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0}else S.head&&(S.head.extra=null);S.mode=6;case 6:if(1024&S.flags&&(G<(q=S.length)&&(q=G),q&&(S.head&&(C=S.head.extra_len-S.length,S.head.extra||(S.head.extra=new Array(S.head.extra_len)),s.arraySet(S.head.extra,z,U,q,C)),512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,S.length-=q),S.length))break e;S.length=0,S.mode=7;case 7:if(2048&S.flags){if(G===0)break e;for(q=0;C=z[U+q++],S.head&&C&&S.length<65536&&(S.head.name+=String.fromCharCode(C)),C&&q<G;);if(512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,C)break e}else S.head&&(S.head.name=null);S.length=0,S.mode=8;case 8:if(4096&S.flags){if(G===0)break e;for(q=0;C=z[U+q++],S.head&&C&&S.length<65536&&(S.head.comment+=String.fromCharCode(C)),C&&q<G;);if(512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,C)break e}else S.head&&(S.head.comment=null);S.mode=9;case 9:if(512&S.flags){for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F!==(65535&S.check)){A.msg="header crc mismatch",S.mode=30;break}R=F=0}S.head&&(S.head.hcrc=S.flags>>9&1,S.head.done=!0),A.adler=S.check=0,S.mode=12;break;case 10:for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}A.adler=S.check=y(F),R=F=0,S.mode=11;case 11:if(S.havedict===0)return A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,2;A.adler=S.check=1,S.mode=12;case 12:if(I===5||I===6)break e;case 13:if(S.last){F>>>=7&R,R-=7&R,S.mode=27;break}for(;R<3;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}switch(S.last=1&F,R-=1,3&(F>>>=1)){case 0:S.mode=14;break;case 1:if(E(S),S.mode=20,I!==6)break;F>>>=2,R-=2;break e;case 2:S.mode=17;break;case 3:A.msg="invalid block type",S.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[U++]<<R,R+=8}if((65535&F)!=(F>>>16^65535)){A.msg="invalid stored block lengths",S.mode=30;break}if(S.length=65535&F,R=F=0,S.mode=15,I===6)break e;case 15:S.mode=16;case 16:if(q=S.length){if(G<q&&(q=G),$<q&&(q=$),q===0)break e;s.arraySet(V,z,U,q,H),G-=q,U+=q,$-=q,H+=q,S.length-=q;break}S.mode=12;break;case 17:for(;R<14;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(S.nlen=257+(31&F),F>>>=5,R-=5,S.ndist=1+(31&F),F>>>=5,R-=5,S.ncode=4+(15&F),F>>>=4,R-=4,286<S.nlen||30<S.ndist){A.msg="too many length or distance symbols",S.mode=30;break}S.have=0,S.mode=18;case 18:for(;S.have<S.ncode;){for(;R<3;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.lens[Y[S.have++]]=7&F,F>>>=3,R-=3}for(;S.have<19;)S.lens[Y[S.have++]]=0;if(S.lencode=S.lendyn,S.lenbits=7,X={bits:S.lenbits},Z=c(0,S.lens,0,19,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid code lengths set",S.mode=30;break}S.have=0,S.mode=19;case 19:for(;S.have<S.nlen+S.ndist;){for(;oe=(L=S.lencode[F&(1<<S.lenbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(ue<16)F>>>=se,R-=se,S.lens[S.have++]=ue;else{if(ue===16){for(B=se+2;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F>>>=se,R-=se,S.have===0){A.msg="invalid bit length repeat",S.mode=30;break}C=S.lens[S.have-1],q=3+(3&F),F>>>=2,R-=2}else if(ue===17){for(B=se+3;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}R-=se,C=0,q=3+(7&(F>>>=se)),F>>>=3,R-=3}else{for(B=se+7;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}R-=se,C=0,q=11+(127&(F>>>=se)),F>>>=7,R-=7}if(S.have+q>S.nlen+S.ndist){A.msg="invalid bit length repeat",S.mode=30;break}for(;q--;)S.lens[S.have++]=C}}if(S.mode===30)break;if(S.lens[256]===0){A.msg="invalid code -- missing end-of-block",S.mode=30;break}if(S.lenbits=9,X={bits:S.lenbits},Z=c(h,S.lens,0,S.nlen,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid literal/lengths set",S.mode=30;break}if(S.distbits=6,S.distcode=S.distdyn,X={bits:S.distbits},Z=c(d,S.lens,S.nlen,S.ndist,S.distcode,0,S.work,X),S.distbits=X.bits,Z){A.msg="invalid distances set",S.mode=30;break}if(S.mode=20,I===6)break e;case 20:S.mode=21;case 21:if(6<=G&&258<=$){A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,l(A,ee),H=A.next_out,V=A.output,$=A.avail_out,U=A.next_in,z=A.input,G=A.avail_in,F=S.hold,R=S.bits,S.mode===12&&(S.back=-1);break}for(S.back=0;oe=(L=S.lencode[F&(1<<S.lenbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(oe&&(240&oe)==0){for(pe=se,Ce=oe,Be=ue;oe=(L=S.lencode[Be+((F&(1<<pe+Ce)-1)>>pe)])>>>16&255,ue=65535&L,!(pe+(se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}F>>>=pe,R-=pe,S.back+=pe}if(F>>>=se,R-=se,S.back+=se,S.length=ue,oe===0){S.mode=26;break}if(32&oe){S.back=-1,S.mode=12;break}if(64&oe){A.msg="invalid literal/length code",S.mode=30;break}S.extra=15&oe,S.mode=22;case 22:if(S.extra){for(B=S.extra;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.length+=F&(1<<S.extra)-1,F>>>=S.extra,R-=S.extra,S.back+=S.extra}S.was=S.length,S.mode=23;case 23:for(;oe=(L=S.distcode[F&(1<<S.distbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if((240&oe)==0){for(pe=se,Ce=oe,Be=ue;oe=(L=S.distcode[Be+((F&(1<<pe+Ce)-1)>>pe)])>>>16&255,ue=65535&L,!(pe+(se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}F>>>=pe,R-=pe,S.back+=pe}if(F>>>=se,R-=se,S.back+=se,64&oe){A.msg="invalid distance code",S.mode=30;break}S.offset=ue,S.extra=15&oe,S.mode=24;case 24:if(S.extra){for(B=S.extra;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.offset+=F&(1<<S.extra)-1,F>>>=S.extra,R-=S.extra,S.back+=S.extra}if(S.offset>S.dmax){A.msg="invalid distance too far back",S.mode=30;break}S.mode=25;case 25:if($===0)break e;if(q=ee-$,S.offset>q){if((q=S.offset-q)>S.whave&&S.sane){A.msg="invalid distance too far back",S.mode=30;break}ce=q>S.wnext?(q-=S.wnext,S.wsize-q):S.wnext-q,q>S.length&&(q=S.length),fe=S.window}else fe=V,ce=H-S.offset,q=S.length;for($<q&&(q=$),$-=q,S.length-=q;V[H++]=fe[ce++],--q;);S.length===0&&(S.mode=21);break;case 26:if($===0)break e;V[H++]=S.length,$--,S.mode=21;break;case 27:if(S.wrap){for(;R<32;){if(G===0)break e;G--,F|=z[U++]<<R,R+=8}if(ee-=$,A.total_out+=ee,S.total+=ee,ee&&(A.adler=S.check=S.flags?a(S.check,V,ee,H-ee):r(S.check,V,ee,H-ee)),ee=$,(S.flags?F:y(F))!==S.check){A.msg="incorrect data check",S.mode=30;break}R=F=0}S.mode=28;case 28:if(S.wrap&&S.flags){for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F!==(4294967295&S.total)){A.msg="incorrect length check",S.mode=30;break}R=F=0}S.mode=29;case 29:Z=1;break e;case 30:Z=-3;break e;case 31:return-4;case 32:default:return p}return A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,(S.wsize||ee!==A.avail_out&&S.mode<30&&(S.mode<27||I!==4))&&O(A,A.output,A.next_out,ee-A.avail_out)?(S.mode=31,-4):(te-=A.avail_in,ee-=A.avail_out,A.total_in+=te,A.total_out+=ee,S.total+=ee,S.wrap&&ee&&(A.adler=S.check=S.flags?a(S.check,V,ee,A.next_out-ee):r(S.check,V,ee,A.next_out-ee)),A.data_type=S.bits+(S.last?64:0)+(S.mode===12?128:0)+(S.mode===20||S.mode===15?256:0),(te==0&&ee===0||I===4)&&Z===m&&(Z=-5),Z)},i.inflateEnd=function(A){if(!A||!A.state)return p;var I=A.state;return I.window&&(I.window=null),A.state=null,m},i.inflateGetHeader=function(A,I){var S;return A&&A.state?(2&(S=A.state).wrap)==0?p:((S.head=I).done=!1,m):p},i.inflateSetDictionary=function(A,I){var S,z=I.length;return A&&A.state?(S=A.state).wrap!==0&&S.mode!==11?p:S.mode===11&&r(1,I,z,0)!==S.check?-3:O(A,I,z,z)?(S.mode=31,-4):(S.havedict=1,m):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"),r=[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],c=[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(h,d,m,p,f,u,g,y){var v,w,x,M,T,P,k,D,E,O=y.bits,A=0,I=0,S=0,z=0,V=0,U=0,H=0,G=0,$=0,F=0,R=null,te=0,ee=new s.Buf16(16),q=new s.Buf16(16),ce=null,fe=0;for(A=0;A<=15;A++)ee[A]=0;for(I=0;I<p;I++)ee[d[m+I]]++;for(V=O,z=15;1<=z&&ee[z]===0;z--);if(z<V&&(V=z),z===0)return f[u++]=20971520,f[u++]=20971520,y.bits=1,0;for(S=1;S<z&&ee[S]===0;S++);for(V<S&&(V=S),A=G=1;A<=15;A++)if(G<<=1,(G-=ee[A])<0)return-1;if(0<G&&(h===0||z!==1))return-1;for(q[1]=0,A=1;A<15;A++)q[A+1]=q[A]+ee[A];for(I=0;I<p;I++)d[m+I]!==0&&(g[q[d[m+I]]++]=I);if(P=h===0?(R=ce=g,19):h===1?(R=r,te-=257,ce=a,fe-=257,256):(R=l,ce=c,-1),A=S,T=u,H=I=F=0,x=-1,M=($=1<<(U=V))-1,h===1&&852<$||h===2&&592<$)return 1;for(;;){for(k=A-H,E=g[I]<P?(D=0,g[I]):g[I]>P?(D=ce[fe+g[I]],R[te+g[I]]):(D=96,0),v=1<<A-H,S=w=1<<U;f[T+(F>>H)+(w-=v)]=k<<24|D<<16|E|0,w!==0;);for(v=1<<A-1;F&v;)v>>=1;if(v!==0?(F&=v-1,F+=v):F=0,I++,--ee[A]==0){if(A===z)break;A=d[m+g[I]]}if(V<A&&(F&M)!==x){for(H===0&&(H=V),T+=S,G=1<<(U=A-H);U+H<z&&!((G-=ee[U+H])<=0);)U++,G<<=1;if($+=1<<U,h===1&&852<$||h===2&&592<$)return 1;f[x=F&M]=V<<24|U<<16|T-u|0}}return F!==0&&(f[T+F]=A-H<<24|64<<16|0),y.bits=V,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"),r=0,a=1;function l(L){for(var N=L.length;0<=--N;)L[N]=0}var c=0,h=29,d=256,m=d+1+h,p=30,f=19,u=2*m+1,g=15,y=16,v=7,w=256,x=16,M=17,T=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],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(m+2));l(O);var A=new Array(2*p);l(A);var I=new Array(512);l(I);var S=new Array(256);l(S);var z=new Array(h);l(z);var V,U,H,G=new Array(p);function $(L,N,Y,K,j){this.static_tree=L,this.extra_bits=N,this.extra_base=Y,this.elems=K,this.max_length=j,this.has_stree=L&&L.length}function F(L,N){this.dyn_tree=L,this.max_code=0,this.stat_desc=N}function R(L){return L<256?I[L]:I[256+(L>>>7)]}function te(L,N){L.pending_buf[L.pending++]=255&N,L.pending_buf[L.pending++]=N>>>8&255}function ee(L,N,Y){L.bi_valid>y-Y?(L.bi_buf|=N<<L.bi_valid&65535,te(L,L.bi_buf),L.bi_buf=N>>y-L.bi_valid,L.bi_valid+=Y-y):(L.bi_buf|=N<<L.bi_valid&65535,L.bi_valid+=Y)}function q(L,N,Y){ee(L,Y[2*N],Y[2*N+1])}function ce(L,N){for(var Y=0;Y|=1&L,L>>>=1,Y<<=1,0<--N;);return Y>>>1}function fe(L,N,Y){var K,j,J=new Array(g+1),ne=0;for(K=1;K<=g;K++)J[K]=ne=ne+Y[K-1]<<1;for(j=0;j<=N;j++){var Q=L[2*j+1];Q!==0&&(L[2*j]=ce(J[Q]++,Q))}}function se(L){var N;for(N=0;N<m;N++)L.dyn_ltree[2*N]=0;for(N=0;N<p;N++)L.dyn_dtree[2*N]=0;for(N=0;N<f;N++)L.bl_tree[2*N]=0;L.dyn_ltree[2*w]=1,L.opt_len=L.static_len=0,L.last_lit=L.matches=0}function oe(L){8<L.bi_valid?te(L,L.bi_buf):0<L.bi_valid&&(L.pending_buf[L.pending++]=L.bi_buf),L.bi_buf=0,L.bi_valid=0}function ue(L,N,Y,K){var j=2*N,J=2*Y;return L[j]<L[J]||L[j]===L[J]&&K[N]<=K[Y]}function pe(L,N,Y){for(var K=L.heap[Y],j=Y<<1;j<=L.heap_len&&(j<L.heap_len&&ue(N,L.heap[j+1],L.heap[j],L.depth)&&j++,!ue(N,K,L.heap[j],L.depth));)L.heap[Y]=L.heap[j],Y=j,j<<=1;L.heap[Y]=K}function Ce(L,N,Y){var K,j,J,ne,Q=0;if(L.last_lit!==0)for(;K=L.pending_buf[L.d_buf+2*Q]<<8|L.pending_buf[L.d_buf+2*Q+1],j=L.pending_buf[L.l_buf+Q],Q++,K===0?q(L,j,N):(q(L,(J=S[j])+d+1,N),(ne=P[J])!==0&&ee(L,j-=z[J],ne),q(L,J=R(--K),Y),(ne=k[J])!==0&&ee(L,K-=G[J],ne)),Q<L.last_lit;);q(L,w,N)}function Be(L,N){var Y,K,j,J=N.dyn_tree,ne=N.stat_desc.static_tree,Q=N.stat_desc.has_stree,ie=N.stat_desc.elems,he=-1;for(L.heap_len=0,L.heap_max=u,Y=0;Y<ie;Y++)J[2*Y]!==0?(L.heap[++L.heap_len]=he=Y,L.depth[Y]=0):J[2*Y+1]=0;for(;L.heap_len<2;)J[2*(j=L.heap[++L.heap_len]=he<2?++he:0)]=1,L.depth[j]=0,L.opt_len--,Q&&(L.static_len-=ne[2*j+1]);for(N.max_code=he,Y=L.heap_len>>1;1<=Y;Y--)pe(L,J,Y);for(j=ie;Y=L.heap[1],L.heap[1]=L.heap[L.heap_len--],pe(L,J,1),K=L.heap[1],L.heap[--L.heap_max]=Y,L.heap[--L.heap_max]=K,J[2*j]=J[2*Y]+J[2*K],L.depth[j]=(L.depth[Y]>=L.depth[K]?L.depth[Y]:L.depth[K])+1,J[2*Y+1]=J[2*K+1]=j,L.heap[1]=j++,pe(L,J,1),2<=L.heap_len;);L.heap[--L.heap_max]=L.heap[1],(function(ae,Ae){var $e,Ee,Ft,ge,nn,Cn,He=Ae.dyn_tree,Mt=Ae.max_code,Ut=Ae.stat_desc.static_tree,Vt=Ae.stat_desc.has_stree,jt=Ae.stat_desc.extra_bits,_t=Ae.stat_desc.extra_base,An=Ae.stat_desc.max_length,Pi=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(He[2*ae.heap[ae.heap_max]+1]=0,$e=ae.heap_max+1;$e<u;$e++)An<(ge=He[2*He[2*(Ee=ae.heap[$e])+1]+1]+1)&&(ge=An,Pi++),He[2*Ee+1]=ge,Mt<Ee||(ae.bl_count[ge]++,nn=0,_t<=Ee&&(nn=jt[Ee-_t]),Cn=He[2*Ee],ae.opt_len+=Cn*(ge+nn),Vt&&(ae.static_len+=Cn*(Ut[2*Ee+1]+nn)));if(Pi!==0){do{for(ge=An-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[An]--,Pi-=2}while(0<Pi);for(ge=An;ge!==0;ge--)for(Ee=ae.bl_count[ge];Ee!==0;)Mt<(Ft=ae.heap[--$e])||(He[2*Ft+1]!==ge&&(ae.opt_len+=(ge-He[2*Ft+1])*He[2*Ft],He[2*Ft+1]=ge),Ee--)}})(L,N),fe(J,he,L.bl_count)}function C(L,N,Y){var K,j,J=-1,ne=N[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),N[2*(Y+1)+1]=65535,K=0;K<=Y;K++)j=ne,ne=N[2*(K+1)+1],++Q<ie&&j===ne||(Q<he?L.bl_tree[2*j]+=Q:j!==0?(j!==J&&L.bl_tree[2*j]++,L.bl_tree[2*x]++):Q<=10?L.bl_tree[2*M]++:L.bl_tree[2*T]++,J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4))}function Z(L,N,Y){var K,j,J=-1,ne=N[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),K=0;K<=Y;K++)if(j=ne,ne=N[2*(K+1)+1],!(++Q<ie&&j===ne)){if(Q<he)for(;q(L,j,L.bl_tree),--Q!=0;);else j!==0?(j!==J&&(q(L,j,L.bl_tree),Q--),q(L,x,L.bl_tree),ee(L,Q-3,2)):Q<=10?(q(L,M,L.bl_tree),ee(L,Q-3,3)):(q(L,T,L.bl_tree),ee(L,Q-11,7));J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4)}}l(G);var X=!1;function B(L,N,Y,K){ee(L,(c<<1)+(K?1:0),3),(function(j,J,ne,Q){oe(j),te(j,ne),te(j,~ne),s.arraySet(j.pending_buf,j.window,J,ne,j.pending),j.pending+=ne})(L,N,Y)}i._tr_init=function(L){X||((function(){var N,Y,K,j,J,ne=new Array(g+1);for(j=K=0;j<h-1;j++)for(z[j]=K,N=0;N<1<<P[j];N++)S[K++]=j;for(S[K-1]=j,j=J=0;j<16;j++)for(G[j]=J,N=0;N<1<<k[j];N++)I[J++]=j;for(J>>=7;j<p;j++)for(G[j]=J<<7,N=0;N<1<<k[j]-7;N++)I[256+J++]=j;for(Y=0;Y<=g;Y++)ne[Y]=0;for(N=0;N<=143;)O[2*N+1]=8,N++,ne[8]++;for(;N<=255;)O[2*N+1]=9,N++,ne[9]++;for(;N<=279;)O[2*N+1]=7,N++,ne[7]++;for(;N<=287;)O[2*N+1]=8,N++,ne[8]++;for(fe(O,m+1,ne),N=0;N<p;N++)A[2*N+1]=5,A[2*N]=ce(N,5);V=new $(O,P,d+1,m,g),U=new $(A,k,0,p,g),H=new $(new Array(0),D,0,f,v)})(),X=!0),L.l_desc=new F(L.dyn_ltree,V),L.d_desc=new F(L.dyn_dtree,U),L.bl_desc=new F(L.bl_tree,H),L.bi_buf=0,L.bi_valid=0,se(L)},i._tr_stored_block=B,i._tr_flush_block=function(L,N,Y,K){var j,J,ne=0;0<L.level?(L.strm.data_type===2&&(L.strm.data_type=(function(Q){var ie,he=4093624447;for(ie=0;ie<=31;ie++,he>>>=1)if(1&he&&Q.dyn_ltree[2*ie]!==0)return r;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return a;for(ie=32;ie<d;ie++)if(Q.dyn_ltree[2*ie]!==0)return a;return r})(L)),Be(L,L.l_desc),Be(L,L.d_desc),ne=(function(Q){var ie;for(C(Q,Q.dyn_ltree,Q.l_desc.max_code),C(Q,Q.dyn_dtree,Q.d_desc.max_code),Be(Q,Q.bl_desc),ie=f-1;3<=ie&&Q.bl_tree[2*E[ie]+1]===0;ie--);return Q.opt_len+=3*(ie+1)+5+5+4,ie})(L),j=L.opt_len+3+7>>>3,(J=L.static_len+3+7>>>3)<=j&&(j=J)):j=J=Y+5,Y+4<=j&&N!==-1?B(L,N,Y,K):L.strategy===4||J===j?(ee(L,2+(K?1:0),3),Ce(L,O,A)):(ee(L,4+(K?1:0),3),(function(Q,ie,he,ae){var Ae;for(ee(Q,ie-257,5),ee(Q,he-1,5),ee(Q,ae-4,4),Ae=0;Ae<ae;Ae++)ee(Q,Q.bl_tree[2*E[Ae]+1],3);Z(Q,Q.dyn_ltree,ie-1),Z(Q,Q.dyn_dtree,he-1)})(L,L.l_desc.max_code+1,L.d_desc.max_code+1,ne+1),Ce(L,L.dyn_ltree,L.dyn_dtree)),se(L),K&&oe(L)},i._tr_tally=function(L,N,Y){return L.pending_buf[L.d_buf+2*L.last_lit]=N>>>8&255,L.pending_buf[L.d_buf+2*L.last_lit+1]=255&N,L.pending_buf[L.l_buf+L.last_lit]=255&Y,L.last_lit++,N===0?L.dyn_ltree[2*Y]++:(L.matches++,N--,L.dyn_ltree[2*(S[Y]+d+1)]++,L.dyn_dtree[2*R(N)]++),L.last_lit===L.lit_bufsize-1},i._tr_align=function(L){ee(L,2,3),q(L,w,O),(function(N){N.bi_valid===16?(te(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)})(L)}},{"../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(r,a){if(!r.setImmediate){var l,c,h,d,m=1,p={},f=!1,u=r.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(r);g=g&&g.setTimeout?g:r,l={}.toString.call(r.process)==="[object process]"?function(x){process.nextTick(function(){v(x)})}:(function(){if(r.postMessage&&!r.importScripts){var x=!0,M=r.onmessage;return r.onmessage=function(){x=!1},r.postMessage("","*"),r.onmessage=M,x}})()?(d="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",w,!1):r.attachEvent("onmessage",w),function(x){r.postMessage(d+x,"*")}):r.MessageChannel?((h=new MessageChannel).port1.onmessage=function(x){v(x.data)},function(x){h.port2.postMessage(x)}):u&&"onreadystatechange"in u.createElement("script")?(c=u.documentElement,function(x){var M=u.createElement("script");M.onreadystatechange=function(){v(x),M.onreadystatechange=null,c.removeChild(M),M=null},c.appendChild(M)}):function(x){setTimeout(v,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var M=new Array(arguments.length-1),T=0;T<M.length;T++)M[T]=arguments[T+1];var P={callback:x,args:M};return p[m]=P,l(m),m++},g.clearImmediate=y}function y(x){delete p[x]}function v(x){if(f)setTimeout(v,0,x);else{var M=p[x];if(M){f=!0;try{(function(T){var P=T.callback,k=T.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)}})(M)}finally{y(x),f=!1}}}}function w(x){x.source===r&&typeof x.data=="string"&&x.data.indexOf(d)===0&&v(+x.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Rn<"u"?Rn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Li)),Li.exports}var Ca=Sa();const Ys=Xs(Ca);function Ks(o,e){return function(){return o.apply(e,arguments)}}const{toString:Aa}=Object.prototype,{getPrototypeOf:Ii}=Object,{iterator:Fn,toStringTag:qs}=Symbol,Un=(o=>e=>{const t=Aa.call(e);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ye=o=>(o=o.toLowerCase(),e=>Un(e)===o),Vn=o=>e=>typeof e===o,{isArray:Gt}=Array,Wt=Vn("undefined");function sn(o){return o!==null&&!Wt(o)&&o.constructor!==null&&!Wt(o.constructor)&&Ne(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const $s=Ye("ArrayBuffer");function Pa(o){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&$s(o.buffer),e}const Ta=Vn("string"),Ne=Vn("function"),Hs=Vn("number"),rn=o=>o!==null&&typeof o=="object",Da=o=>o===!0||o===!1,jn=o=>{if(Un(o)!=="object")return!1;const e=Ii(o);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(qs in o)&&!(Fn in o)},ka=o=>{if(!rn(o)||sn(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},Ea=Ye("Date"),La=Ye("File"),Ia=Ye("Blob"),za=Ye("FileList"),Ba=o=>rn(o)&&Ne(o.pipe),Oa=o=>{let e;return o&&(typeof FormData=="function"&&o instanceof FormData||Ne(o.append)&&((e=Un(o))==="formdata"||e==="object"&&Ne(o.toString)&&o.toString()==="[object FormData]"))},Ra=Ye("URLSearchParams"),[Na,Fa,Ua,Va]=["ReadableStream","Request","Response","Headers"].map(Ye),ja=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function on(o,e,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let n,i;if(typeof o!="object"&&(o=[o]),Gt(o))for(n=0,i=o.length;n<i;n++)e.call(null,o[n],n,o);else{if(sn(o))return;const s=t?Object.getOwnPropertyNames(o):Object.keys(o),r=s.length;let a;for(n=0;n<r;n++)a=s[n],e.call(null,o[a],a,o)}}function Js(o,e){if(sn(o))return null;e=e.toLowerCase();const t=Object.keys(o);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const At=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Qs=o=>!Wt(o)&&o!==At;function zi(){const{caseless:o,skipUndefined:e}=Qs(this)&&this||{},t={},n=(i,s)=>{const r=o&&Js(t,s)||s;jn(t[r])&&jn(i)?t[r]=zi(t[r],i):jn(i)?t[r]=zi({},i):Gt(i)?t[r]=i.slice():(!e||!Wt(i))&&(t[r]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&on(arguments[i],n);return t}const Ga=(o,e,t,{allOwnKeys:n}={})=>(on(e,(i,s)=>{t&&Ne(i)?o[s]=Ks(i,t):o[s]=i},{allOwnKeys:n}),o),Wa=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),Xa=(o,e,t,n)=>{o.prototype=Object.create(e.prototype,n),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:e.prototype}),t&&Object.assign(o.prototype,t)},Za=(o,e,t,n)=>{let i,s,r;const a={};if(e=e||{},o==null)return e;do{for(i=Object.getOwnPropertyNames(o),s=i.length;s-- >0;)r=i[s],(!n||n(r,o,e))&&!a[r]&&(e[r]=o[r],a[r]=!0);o=t!==!1&&Ii(o)}while(o&&(!t||t(o,e))&&o!==Object.prototype);return e},Ya=(o,e,t)=>{o=String(o),(t===void 0||t>o.length)&&(t=o.length),t-=e.length;const n=o.indexOf(e,t);return n!==-1&&n===t},Ka=o=>{if(!o)return null;if(Gt(o))return o;let e=o.length;if(!Hs(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=o[e];return t},qa=(o=>e=>o&&e instanceof o)(typeof Uint8Array<"u"&&Ii(Uint8Array)),$a=(o,e)=>{const n=(o&&o[Fn]).call(o);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(o,s[0],s[1])}},Ha=(o,e)=>{let t;const n=[];for(;(t=o.exec(e))!==null;)n.push(t);return n},Ja=Ye("HTMLFormElement"),Qa=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),er=(({hasOwnProperty:o})=>(e,t)=>o.call(e,t))(Object.prototype),el=Ye("RegExp"),tr=(o,e)=>{const t=Object.getOwnPropertyDescriptors(o),n={};on(t,(i,s)=>{let r;(r=e(i,s,o))!==!1&&(n[s]=r||i)}),Object.defineProperties(o,n)},tl=o=>{tr(o,(e,t)=>{if(Ne(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=o[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+"'")})}})},nl=(o,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return Gt(o)?n(o):n(String(o).split(e)),t},il=()=>{},sl=(o,e)=>o!=null&&Number.isFinite(o=+o)?o:e;function rl(o){return!!(o&&Ne(o.append)&&o[qs]==="FormData"&&o[Fn])}const ol=o=>{const e=new Array(10),t=(n,i)=>{if(rn(n)){if(e.indexOf(n)>=0)return;if(sn(n))return n;if(!("toJSON"in n)){e[i]=n;const s=Gt(n)?[]:{};return on(n,(r,a)=>{const l=t(r,i+1);!Wt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(o,0)},al=Ye("AsyncFunction"),ll=o=>o&&(rn(o)||Ne(o))&&Ne(o.then)&&Ne(o.catch),nr=((o,e)=>o?setImmediate:e?((t,n)=>(At.addEventListener("message",({source:i,data:s})=>{i===At&&s===t&&n.length&&n.shift()()},!1),i=>{n.push(i),At.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ne(At.postMessage)),cl=typeof queueMicrotask<"u"?queueMicrotask.bind(At):typeof process<"u"&&process.nextTick||nr,W={isArray:Gt,isArrayBuffer:$s,isBuffer:sn,isFormData:Oa,isArrayBufferView:Pa,isString:Ta,isNumber:Hs,isBoolean:Da,isObject:rn,isPlainObject:jn,isEmptyObject:ka,isReadableStream:Na,isRequest:Fa,isResponse:Ua,isHeaders:Va,isUndefined:Wt,isDate:Ea,isFile:La,isBlob:Ia,isRegExp:el,isFunction:Ne,isStream:Ba,isURLSearchParams:Ra,isTypedArray:qa,isFileList:za,forEach:on,merge:zi,extend:Ga,trim:ja,stripBOM:Wa,inherits:Xa,toFlatObject:Za,kindOf:Un,kindOfTest:Ye,endsWith:Ya,toArray:Ka,forEachEntry:$a,matchAll:Ha,isHTMLForm:Ja,hasOwnProperty:er,hasOwnProp:er,reduceDescriptors:tr,freezeMethods:tl,toObjectSet:nl,toCamelCase:Qa,noop:il,toFiniteNumber:sl,findKey:Js,global:At,isContextDefined:Qs,isSpecCompliantForm:rl,toJSONObject:ol,isAsyncFn:al,isThenable:ll,setImmediate:nr,asap:cl,isIterable:o=>o!=null&&Ne(o[Fn])};function re(o,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,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)}W.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:W.toJSONObject(this.config),code:this.code,status:this.status}}});const ir=re.prototype,sr={};["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(o=>{sr[o]={value:o}}),Object.defineProperties(re,sr),Object.defineProperty(ir,"isAxiosError",{value:!0}),re.from=(o,e,t,n,i,s)=>{const r=Object.create(ir);W.toFlatObject(o,r,function(h){return h!==Error.prototype},c=>c!=="isAxiosError");const a=o&&o.message?o.message:"Error",l=e==null&&o?o.code:e;return re.call(r,a,l,t,n,i),o&&r.cause==null&&Object.defineProperty(r,"cause",{value:o,configurable:!0}),r.name=o&&o.name||"Error",s&&Object.assign(r,s),r};const hl=null;function Bi(o){return W.isPlainObject(o)||W.isArray(o)}function rr(o){return W.endsWith(o,"[]")?o.slice(0,-2):o}function or(o,e,t){return o?o.concat(e).map(function(i,s){return i=rr(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function ul(o){return W.isArray(o)&&!o.some(Bi)}const dl=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function Gn(o,e,t){if(!W.isObject(o))throw new TypeError("target must be an object");e=e||new FormData,t=W.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,g){return!W.isUndefined(g[u])});const n=t.metaTokens,i=t.visitor||h,s=t.dots,r=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(e);if(!W.isFunction(i))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(W.isDate(f))return f.toISOString();if(W.isBoolean(f))return f.toString();if(!l&&W.isBlob(f))throw new re("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(f)||W.isTypedArray(f)?l&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function h(f,u,g){let y=f;if(f&&!g&&typeof f=="object"){if(W.endsWith(u,"{}"))u=n?u:u.slice(0,-2),f=JSON.stringify(f);else if(W.isArray(f)&&ul(f)||(W.isFileList(f)||W.endsWith(u,"[]"))&&(y=W.toArray(f)))return u=rr(u),y.forEach(function(w,x){!(W.isUndefined(w)||w===null)&&e.append(r===!0?or([u],x,s):r===null?u:u+"[]",c(w))}),!1}return Bi(f)?!0:(e.append(or(g,u,s),c(f)),!1)}const d=[],m=Object.assign(dl,{defaultVisitor:h,convertValue:c,isVisitable:Bi});function p(f,u){if(!W.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+u.join("."));d.push(f),W.forEach(f,function(y,v){(!(W.isUndefined(y)||y===null)&&i.call(e,y,W.isString(v)?v.trim():v,u,m))===!0&&p(y,u?u.concat(v):[v])}),d.pop()}}if(!W.isObject(o))throw new TypeError("data must be an object");return p(o),e}function ar(o){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Oi(o,e){this._pairs=[],o&&Gn(o,this,e)}const lr=Oi.prototype;lr.append=function(e,t){this._pairs.push([e,t])},lr.toString=function(e){const t=e?function(n){return e.call(this,n,ar)}:ar;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function fl(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function cr(o,e,t){if(!e)return o;const n=t&&t.encode||fl;W.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=W.isURLSearchParams(e)?e.toString():new Oi(e,t).toString(n),s){const r=o.indexOf("#");r!==-1&&(o=o.slice(0,r)),o+=(o.indexOf("?")===-1?"?":"&")+s}return o}class hr{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){W.forEach(this.handlers,function(n){n!==null&&e(n)})}}const ur={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Oi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ri=typeof window<"u"&&typeof document<"u",Ni=typeof navigator=="object"&&navigator||void 0,ml=Ri&&(!Ni||["ReactNative","NativeScript","NS"].indexOf(Ni.product)<0),gl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yl=Ri&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ri,hasStandardBrowserEnv:ml,hasStandardBrowserWebWorkerEnv:gl,navigator:Ni,origin:yl},Symbol.toStringTag,{value:"Module"})),...pl};function vl(o,e){return Gn(o,new ke.classes.URLSearchParams,{visitor:function(t,n,i,s){return ke.isNode&&W.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function wl(o){return W.matchAll(/\w+|\[(\w*)]/g,o).map(e=>e[0]==="[]"?"":e[1]||e[0])}function xl(o){const e={},t=Object.keys(o);let n;const i=t.length;let s;for(n=0;n<i;n++)s=t[n],e[s]=o[s];return e}function dr(o){function e(t,n,i,s){let r=t[s++];if(r==="__proto__")return!0;const a=Number.isFinite(+r),l=s>=t.length;return r=!r&&W.isArray(i)?i.length:r,l?(W.hasOwnProp(i,r)?i[r]=[i[r],n]:i[r]=n,!a):((!i[r]||!W.isObject(i[r]))&&(i[r]=[]),e(t,n,i[r],s)&&W.isArray(i[r])&&(i[r]=xl(i[r])),!a)}if(W.isFormData(o)&&W.isFunction(o.entries)){const t={};return W.forEachEntry(o,(n,i)=>{e(wl(n),i,t,0)}),t}return null}function bl(o,e,t){if(W.isString(o))try{return(e||JSON.parse)(o),W.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(o)}const an={transitional:ur,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=W.isObject(e);if(s&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return i?JSON.stringify(dr(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.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 vl(e,this.formSerializer).toString();if((a=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Gn(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),bl(e)):e}],transformResponse:[function(e){const t=this.transitional||an.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||i)){const r=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(r)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:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],o=>{an.headers[o]={}});const Ml=W.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"]),_l=o=>{const e={};let t,n,i;return o&&o.split(`
962
+ `).forEach(function(r){i=r.indexOf(":"),t=r.substring(0,i).trim().toLowerCase(),n=r.substring(i+1).trim(),!(!t||e[t]&&Ml[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},fr=Symbol("internals");function ln(o){return o&&String(o).trim().toLowerCase()}function Wn(o){return o===!1||o==null?o:W.isArray(o)?o.map(Wn):String(o)}function Sl(o){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(o);)e[n[1]]=n[2];return e}const Cl=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function Fi(o,e,t,n,i){if(W.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!W.isString(e)){if(W.isString(n))return e.indexOf(n)!==-1;if(W.isRegExp(n))return n.test(e)}}function Al(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Pl(o,e){const t=W.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(o,n+t,{value:function(i,s,r){return this[n].call(this,e,i,s,r)},configurable:!0})})}let Fe=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(a,l,c){const h=ln(l);if(!h)throw new Error("header name must be a non-empty string");const d=W.findKey(i,h);(!d||i[d]===void 0||c===!0||c===void 0&&i[d]!==!1)&&(i[d||l]=Wn(a))}const r=(a,l)=>W.forEach(a,(c,h)=>s(c,h,l));if(W.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(W.isString(e)&&(e=e.trim())&&!Cl(e))r(_l(e),t);else if(W.isObject(e)&&W.isIterable(e)){let a={},l,c;for(const h of e){if(!W.isArray(h))throw TypeError("Object iterator must return a key-value pair");a[c=h[0]]=(l=a[c])?W.isArray(l)?[...l,h[1]]:[l,h[1]]:h[1]}r(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=ln(e),e){const n=W.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return Sl(i);if(W.isFunction(t))return t.call(this,i,n);if(W.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ln(e),e){const n=W.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Fi(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function s(r){if(r=ln(r),r){const a=W.findKey(n,r);a&&(!t||Fi(n,n[a],a,t))&&(delete n[a],i=!0)}}return W.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||Fi(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return W.forEach(this,(i,s)=>{const r=W.findKey(n,s);if(r){t[r]=Wn(i),delete t[s];return}const a=e?Al(s):String(s).trim();a!==s&&delete t[s],t[a]=Wn(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&W.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(`
963
+ `)}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[fr]=this[fr]={accessors:{}}).accessors,i=this.prototype;function s(r){const a=ln(r);n[a]||(Pl(i,r),n[a]=!0)}return W.isArray(e)?e.forEach(s):s(e),this}};Fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Fe.prototype,({value:o},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>o,set(n){this[t]=n}}}),W.freezeMethods(Fe);function Ui(o,e){const t=this||an,n=e||t,i=Fe.from(n.headers);let s=n.data;return W.forEach(o,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function pr(o){return!!(o&&o.__CANCEL__)}function Xt(o,e,t){re.call(this,o??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}W.inherits(Xt,re,{__CANCEL__:!0});function mr(o,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?o(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 Tl(o){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return e&&e[1]||""}function Dl(o,e){o=o||10;const t=new Array(o),n=new Array(o);let i=0,s=0,r;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),h=n[s];r||(r=c),t[i]=l,n[i]=c;let d=s,m=0;for(;d!==i;)m+=t[d++],d=d%o;if(i=(i+1)%o,i===s&&(s=(s+1)%o),c-r<e)return;const p=h&&c-h;return p?Math.round(m*1e3/p):void 0}}function kl(o,e){let t=0,n=1e3/e,i,s;const r=(c,h=Date.now())=>{t=h,i=null,s&&(clearTimeout(s),s=null),o(...c)};return[(...c)=>{const h=Date.now(),d=h-t;d>=n?r(c,h):(i=c,s||(s=setTimeout(()=>{s=null,r(i)},n-d)))},()=>i&&r(i)]}const Xn=(o,e,t=3)=>{let n=0;const i=Dl(50,250);return kl(s=>{const r=s.loaded,a=s.lengthComputable?s.total:void 0,l=r-n,c=i(l),h=r<=a;n=r;const d={loaded:r,total:a,progress:a?r/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&h?(a-r)/c:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};o(d)},t)},gr=(o,e)=>{const t=o!=null;return[n=>e[0]({lengthComputable:t,total:o,loaded:n}),e[1]]},yr=o=>(...e)=>W.asap(()=>o(...e)),El=ke.hasStandardBrowserEnv?((o,e)=>t=>(t=new URL(t,ke.origin),o.protocol===t.protocol&&o.host===t.host&&(e||o.port===t.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,Ll=ke.hasStandardBrowserEnv?{write(o,e,t,n,i,s,r){if(typeof document>"u")return;const a=[`${o}=${encodeURIComponent(e)}`];W.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),W.isString(n)&&a.push(`path=${n}`),W.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),W.isString(r)&&a.push(`SameSite=${r}`),document.cookie=a.join("; ")},read(o){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+o+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(o){this.write(o,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Il(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function zl(o,e){return e?o.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):o}function vr(o,e,t){let n=!Il(e);return o&&(n||t==!1)?zl(o,e):e}const wr=o=>o instanceof Fe?{...o}:o;function Pt(o,e){e=e||{};const t={};function n(c,h,d,m){return W.isPlainObject(c)&&W.isPlainObject(h)?W.merge.call({caseless:m},c,h):W.isPlainObject(h)?W.merge({},h):W.isArray(h)?h.slice():h}function i(c,h,d,m){if(W.isUndefined(h)){if(!W.isUndefined(c))return n(void 0,c,d,m)}else return n(c,h,d,m)}function s(c,h){if(!W.isUndefined(h))return n(void 0,h)}function r(c,h){if(W.isUndefined(h)){if(!W.isUndefined(c))return n(void 0,c)}else return n(void 0,h)}function a(c,h,d){if(d in e)return n(c,h);if(d in o)return n(void 0,c)}const l={url:s,method:s,data:s,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:a,headers:(c,h,d)=>i(wr(c),wr(h),d,!0)};return W.forEach(Object.keys({...o,...e}),function(h){const d=l[h]||i,m=d(o[h],e[h],h);W.isUndefined(m)&&d!==a||(t[h]=m)}),t}const xr=o=>{const e=Pt({},o);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Fe.from(r),e.url=cr(vr(e.baseURL,e.url,e.allowAbsoluteUrls),o.params,o.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(t)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(W.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,d])=>{c.includes(h.toLowerCase())&&r.set(h,d)})}}if(ke.hasStandardBrowserEnv&&(n&&W.isFunction(n)&&(n=n(e)),n||n!==!1&&El(e.url))){const l=i&&s&&Ll.read(s);l&&r.set(i,l)}return e},Bl=typeof XMLHttpRequest<"u"&&function(o){return new Promise(function(t,n){const i=xr(o);let s=i.data;const r=Fe.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,h,d,m,p,f;function u(){p&&p(),f&&f(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const w=Fe.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),M={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:w,config:o,request:g};mr(function(P){t(P),u()},function(P){n(P),u()},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,o,g)),g=null)},g.onerror=function(x){const M=x&&x.message?x.message:"Network Error",T=new re(M,re.ERR_NETWORK,o,g);T.event=x||null,n(T),g=null},g.ontimeout=function(){let x=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const M=i.transitional||ur;i.timeoutErrorMessage&&(x=i.timeoutErrorMessage),n(new re(x,M.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,o,g)),g=null},s===void 0&&r.setContentType(null),"setRequestHeader"in g&&W.forEach(r.toJSON(),function(x,M){g.setRequestHeader(M,x)}),W.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),c&&([m,f]=Xn(c,!0),g.addEventListener("progress",m)),l&&g.upload&&([d,p]=Xn(l),g.upload.addEventListener("progress",d),g.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(h=w=>{g&&(n(!w||w.type?new Xt(null,o,g):w),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));const v=Tl(i.url);if(v&&ke.protocols.indexOf(v)===-1){n(new re("Unsupported protocol "+v+":",re.ERR_BAD_REQUEST,o));return}g.send(s||null)})},Ol=(o,e)=>{const{length:t}=o=o?o.filter(Boolean):[];if(e||t){let n=new AbortController,i;const s=function(c){if(!i){i=!0,a();const h=c instanceof Error?c:this.reason;n.abort(h instanceof re?h:new Xt(h instanceof Error?h.message:h))}};let r=e&&setTimeout(()=>{r=null,s(new re(`timeout ${e} of ms exceeded`,re.ETIMEDOUT))},e);const a=()=>{o&&(r&&clearTimeout(r),r=null,o.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),o=null)};o.forEach(c=>c.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>W.asap(a),l}},Rl=function*(o,e){let t=o.byteLength;if(t<e){yield o;return}let n=0,i;for(;n<t;)i=n+e,yield o.slice(n,i),n=i},Nl=async function*(o,e){for await(const t of Fl(o))yield*Rl(t,e)},Fl=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const e=o.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},br=(o,e,t,n)=>{const i=Nl(o,e);let s=0,r,a=l=>{r||(r=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await i.next();if(c){a(),l.close();return}let d=h.byteLength;if(t){let m=s+=d;t(m)}l.enqueue(new Uint8Array(h))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},Mr=64*1024,{isFunction:Zn}=W,Ul=(({Request:o,Response:e})=>({Request:o,Response:e}))(W.global),{ReadableStream:_r,TextEncoder:Sr}=W.global,Cr=(o,...e)=>{try{return!!o(...e)}catch{return!1}},Vl=o=>{o=W.merge.call({skipUndefined:!0},Ul,o);const{fetch:e,Request:t,Response:n}=o,i=e?Zn(e):typeof fetch=="function",s=Zn(t),r=Zn(n);if(!i)return!1;const a=i&&Zn(_r),l=i&&(typeof Sr=="function"?(f=>u=>f.encode(u))(new Sr):async f=>new Uint8Array(await new t(f).arrayBuffer())),c=s&&a&&Cr(()=>{let f=!1;const u=new t(ke.origin,{body:new _r,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!u}),h=r&&a&&Cr(()=>W.isReadableStream(new n("").body)),d={stream:h&&(f=>f.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!d[f]&&(d[f]=(u,g)=>{let y=u&&u[f];if(y)return y.call(u);throw new re(`Response type '${f}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const m=async f=>{if(f==null)return 0;if(W.isBlob(f))return f.size;if(W.isSpecCompliantForm(f))return(await new t(ke.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(W.isArrayBufferView(f)||W.isArrayBuffer(f))return f.byteLength;if(W.isURLSearchParams(f)&&(f=f+""),W.isString(f))return(await l(f)).byteLength},p=async(f,u)=>{const g=W.toFiniteNumber(f.getContentLength());return g??m(u)};return async f=>{let{url:u,method:g,data:y,signal:v,cancelToken:w,timeout:x,onDownloadProgress:M,onUploadProgress:T,responseType:P,headers:k,withCredentials:D="same-origin",fetchOptions:E}=xr(f),O=e||fetch;P=P?(P+"").toLowerCase():"text";let A=Ol([v,w&&w.toAbortSignal()],x),I=null;const S=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let z;try{if(T&&c&&g!=="get"&&g!=="head"&&(z=await p(k,y))!==0){let F=new t(u,{method:"POST",body:y,duplex:"half"}),R;if(W.isFormData(y)&&(R=F.headers.get("content-type"))&&k.setContentType(R),F.body){const[te,ee]=gr(z,Xn(yr(T)));y=br(F.body,Mr,te,ee)}}W.isString(D)||(D=D?"include":"omit");const V=s&&"credentials"in t.prototype,U={...E,signal:A,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:V?D:void 0};I=s&&new t(u,U);let H=await(s?O(I,E):O(u,U));const G=h&&(P==="stream"||P==="response");if(h&&(M||G&&S)){const F={};["status","statusText","headers"].forEach(q=>{F[q]=H[q]});const R=W.toFiniteNumber(H.headers.get("content-length")),[te,ee]=M&&gr(R,Xn(yr(M),!0))||[];H=new n(br(H.body,Mr,te,()=>{ee&&ee(),S&&S()}),F)}P=P||"text";let $=await d[W.findKey(d,P)||"text"](H,f);return!G&&S&&S(),await new Promise((F,R)=>{mr(F,R,{data:$,headers:Fe.from(H.headers),status:H.status,statusText:H.statusText,config:f,request:I})})}catch(V){throw S&&S(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,f,I),{cause:V.cause||V}):re.from(V,V&&V.code,f,I)}}},jl=new Map,Ar=o=>{let e=o&&o.env||{};const{fetch:t,Request:n,Response:i}=e,s=[n,i,t];let r=s.length,a=r,l,c,h=jl;for(;a--;)l=s[a],c=h.get(l),c===void 0&&h.set(l,c=a?new Map:Vl(e)),h=c;return c};Ar();const Vi={http:hl,xhr:Bl,fetch:{get:Ar}};W.forEach(Vi,(o,e)=>{if(o){try{Object.defineProperty(o,"name",{value:e})}catch{}Object.defineProperty(o,"adapterName",{value:e})}});const Pr=o=>`- ${o}`,Gl=o=>W.isFunction(o)||o===null||o===!1;function Wl(o,e){o=W.isArray(o)?o:[o];const{length:t}=o;let n,i;const s={};for(let r=0;r<t;r++){n=o[r];let a;if(i=n,!Gl(n)&&(i=Vi[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(W.isFunction(i)||(i=i.get(e))))break;s[a||"#"+r]=i}if(!i){const r=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=t?r.length>1?`since :
964
964
  `+r.map(Pr).join(`
965
- `):" "+Pr(r[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const Tr={getAdapter:Wl,adapters:Ui};function Vi(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Xt(null,o)}function Dr(o){return Vi(o),o.headers=Fe.from(o.headers),o.data=Fi.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Tr.getAdapter(o.adapter||an.adapter,o)(o).then(function(n){return Vi(o),n.data=Fi.call(o,o.transformResponse,n),n.headers=Fe.from(n.headers),n},function(n){return pr(n)||(Vi(o),n&&n.response&&(n.response.data=Fi.call(o,o.transformResponse,n.response),n.response.headers=Fe.from(n.response.headers))),Promise.reject(n)})}const kr="1.13.2",Zn={};["object","boolean","number","function","string","symbol"].forEach((o,e)=>{Zn[o]=function(n){return typeof n===o||"a"+(e<1?"n ":" ")+o}});const Er={};Zn.transitional=function(e,t,n){function i(s,r){return"[Axios v"+kr+"] Transitional option '"+s+"'"+r+(n?". "+n:"")}return(s,r,a)=>{if(e===!1)throw new re(i(r," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!Er[r]&&(Er[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,r,a):!0}},Zn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Xl(o,e,t){if(typeof o!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const n=Object.keys(o);let i=n.length;for(;i-- >0;){const s=n[i],r=e[s];if(r){const a=o[s],l=a===void 0||r(a,s,o);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 Yn={assertOptions:Xl,validators:Zn},Je=Yn.validators;let Tt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new hr,response:new hr}}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+=`
966
- `+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Pt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Yn.assertOptions(n,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},!1),i!=null&&(W.isFunction(i)?t.paramsSerializer={serialize:i}:Yn.assertOptions(i,{encode:Je.function,serialize:Je.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Yn.assertOptions(t,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=s&&W.merge(s.common,s[t.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),t.headers=Fe.concat(r,s);const a=[];let l=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(t)===!1||(l=l&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const h=[];this.interceptors.response.forEach(function(u){h.push(u.fulfilled,u.rejected)});let c,d=0,m;if(!l){const f=[Dr.bind(this),void 0];for(f.unshift(...a),f.push(...h),m=f.length,c=Promise.resolve(t);d<m;)c=c.then(f[d++],f[d++]);return c}m=a.length;let p=t;for(;d<m;){const f=a[d++],u=a[d++];try{p=f(p)}catch(g){u.call(this,g);break}}try{c=Dr.call(this,p)}catch(f){return Promise.reject(f)}for(d=0,m=h.length;d<m;)c=c.then(h[d++],h[d++]);return c}getUri(e){e=Pt(this.defaults,e);const t=vr(e.baseURL,e.url,e.allowAbsoluteUrls);return cr(t,e.params,e.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(e){Tt.prototype[e]=function(t,n){return this.request(Pt(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(n){return function(s,r,a){return this.request(Pt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}Tt.prototype[e]=t(),Tt.prototype[e+"Form"]=t(!0)});let Zl=class Wo{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 r=new Promise(a=>{n.subscribe(a),s=a}).then(i);return r.cancel=function(){n.unsubscribe(s)},r},e(function(s,r,a){n.reason||(n.reason=new Xt(s,r,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 Wo(function(i){e=i}),cancel:e}}};function Yl(o){return function(t){return o.apply(null,t)}}function Kl(o){return W.isObject(o)&&o.isAxiosError===!0}const ji={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(ji).forEach(([o,e])=>{ji[e]=o});function Lr(o){const e=new Tt(o),t=Ks(Tt.prototype.request,e);return W.extend(t,Tt.prototype,e,{allOwnKeys:!0}),W.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Lr(Pt(o,i))},t}const ye=Lr(an);ye.Axios=Tt,ye.CanceledError=Xt,ye.CancelToken=Zl,ye.isCancel=pr,ye.VERSION=kr,ye.toFormData=jn,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=Yl,ye.isAxiosError=Kl,ye.mergeConfig=Pt,ye.AxiosHeaders=Fe,ye.formToJSON=o=>dr(W.isHTMLForm(o)?new FormData(o):o),ye.getAdapter=Tr.getAdapter,ye.HttpStatusCode=ji,ye.default=ye;const{Axios:If,AxiosError:zf,CanceledError:Bf,isCancel:Of,CancelToken:Rf,VERSION:Nf,all:Ff,Cancel:Uf,isAxiosError:Vf,spread:jf,toFormData:Gf,AxiosHeaders:Wf,HttpStatusCode:Xf,formToJSON:Zf,getAdapter:Yf,mergeConfig:Kf}=ye;function Ir(o,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=o;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 ql(o,e){ye({method:"get",responseType:"blob",url:o}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});Ys.loadAsync(n).then(i=>{const s=new Map,r=[];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 d=URL.createObjectURL(c);s.set("/"+i.files[a].name.replace("\\","/"),d)});r.push(h)}}Promise.all(r).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 Gi(o,e){ye({method:"get",responseType:"blob",url:o}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});Ys.loadAsync(i).then(s=>{for(let r in s.files)s.file(s.files[r].name).async("blob").then(l=>{t(l,"utf-8",function(h,c){e(c)})})})});function t(n,i,s){var r=new FileReader,a=new Blob([n]);r.onload=function(l){s(null,l.target.result)},r.onerror=function(l){s(l.error,null)},r.readAsText(a,i)}}const Wi=new WeakMap;class $l extends _.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 _.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,_.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=_.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Wi.has(e)){const l=Wi.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++,r=e.byteLength,a=this._getWorker(s,r).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)}),Wi.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new _.BufferGeometry;e.index&&t.setIndex(new _.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:r,stride:a,vertexColorSpace:l}=e.attributes[n];let h;if(r===a)h=new _.BufferAttribute(s,r);else{const c=new _.InterleavedBuffer(s,a);h=new _.InterleavedBufferAttribute(c,r,0)}i==="color"&&(this._assignVertexColorSpace(h,l),h.normalized=!(s instanceof Float32Array)),t.setAttribute(i,h)}return t}_assignVertexColorSpace(e,t){if(t!==_.SRGBColorSpace)return;const n=new _.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),_.ColorManagement.colorSpaceToWorking(n,_.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new _.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=Hl.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
967
- `);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),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 r=s.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.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 Hl(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(c){o.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const d=c.draco,m=new d.Decoder;try{const p=t(d,m,new Int8Array(l),h),f=p.attributes.map(u=>u.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{d.destroy(m)}});break}};function t(r,a,l,h){const c=h.attributeIDs,d=h.attributeTypes;let m,p;const f=a.GetEncodedGeometryType(l);if(f===r.TRIANGULAR_MESH)m=new r.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,m);else if(f===r.POINT_CLOUD)m=new r.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const u={index:null,attributes:[]};for(const g in c){const y=self[d[g]];let v,w;if(h.useUniqueIDs)w=c[g],v=a.GetAttributeByUniqueId(m,w);else{if(w=a.GetAttributeId(m,r[c[g]]),w===-1)continue;v=a.GetAttribute(m,w)}const x=i(r,a,m,g,y,v);g==="color"&&(x.vertexColorSpace=h.vertexColorSpace),u.attributes.push(x)}return f===r.TRIANGULAR_MESH&&(u.index=n(r,a,m)),r.destroy(m),u}function n(r,a,l){const c=l.num_faces()*3,d=c*4,m=r._malloc(d);a.GetTrianglesUInt32Array(l,d,m);const p=new Uint32Array(r.HEAPF32.buffer,m,c).slice();return r._free(m),{array:p,itemSize:1}}function i(r,a,l,h,c,d){const m=l.num_points(),p=d.num_components(),f=s(r,c),u=p*c.BYTES_PER_ELEMENT,g=Math.ceil(u/4)*4,y=g/c.BYTES_PER_ELEMENT,v=m*u,w=m*g,x=r._malloc(v);a.GetAttributeDataArrayForAllPoints(l,d,f,v,x);const M=new c(r.HEAPF32.buffer,x,v/c.BYTES_PER_ELEMENT);let T;if(u===g)T=M.slice();else{T=new c(w/c.BYTES_PER_ELEMENT);let P=0;for(let k=0,D=M.length;k<D;k++){for(let E=0;E<p;E++)T[P+E]=M[k*p+E];P+=y}}return r._free(x),{name:h,count:m,itemSize:p,array:T,stride:y}}function s(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var ft=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.ViewportResize="viewport-resize",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.SectionMove="section-move",o))(ft||{});function Jl(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(p=>p.url==t),l=e.circularMeps,h=e.rectMeps?.filter(p=>p.type==="风管"),c=e.rectMeps?.filter(p=>p.type==="桥架"),d=e.ellipseMeps,m=o.scene;if(new b.MeshBasicMaterial,new b.BufferGeometry,l&&l.length){let p=[],f=0;for(let u of l)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Kn("Circle",m,p,t)}if(h&&h.length){let p=[],f=0;for(let u of h)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Kn("Rect",m,p,t)}if(d&&d.length){let p=[],f=0;for(let u of d)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Kn("Ellipse",m,p,t)}if(c&&c.length){let p=[],f=0;for(let u of c)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Kn("Bridge",m,p,t)}}function Kn(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new b.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=qn("Rect",a);break;case"Bridge":r=qn("Bridge",a);break;case"Circle":r=qn("Circle",a);break;case"Ellipse":r=qn("Ellipse",a);break}r&&(s=new b.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[],h=[];for(var c=0;c<t.length;c++){let p=t[c],f=new b.Vector3(p.startPoint.X,0,-p.startPoint.Y),u=new b.Vector3(p.endPoint.X,0,-p.endPoint.Y),g=new b.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),y=new b.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),v=0,w=0,x=0;if(Math.abs(u.clone().sub(f.clone()).z)<.01&&Math.abs(u.clone().sub(f.clone()).x)<.01){if(v=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var d=new b.Vector3(p.base_x.X,0,-p.base_x.Y);w=(d.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else w=(u.clone().sub(f.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*u.clone().sub(f.clone()).angleTo(new b.Vector3(0,0,1)),v=(p.startPoint.Z>p.endPoint.Z?1:-1)*u.clone().sub(f.clone()).angleTo(y.clone().sub(g.clone()));let M=new b.Matrix4;const T=new b.Euler(v,w,x,"YXZ");let P=M.clone().makeRotationFromEuler(T),k,D;o==="Circle"?(k=p.diameter,D=p.diameter):(k=p.width,D=p.height);let E=M.clone().makeScale(k,D,p.length);M.multiplyMatrices(P,E),M.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(c,M.clone()),s.setColorAt(c,p.color),s.geometry.computeBoundingBox();let O=s.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),A=s.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),I=new b.Vector3(Math.min(O.x,A.x),Math.min(O.y,A.y),Math.min(O.z,A.z)),S=new b.Vector3(Math.max(O.x,A.x),Math.max(O.y,A.y),Math.max(O.z,A.z)),z=I.clone().add(S.clone()).multiplyScalar(.5),V={name:p.name,min:I,max:S,center:z,dbid:c,materialName:r.material.name},U=null,H=null;o==="Circle"&&(U={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},H={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},V.minC=U,V.maxC=H),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(M.clone()),h.push(M.clone()),s.ids.push(Number(p.id)),l.push(V)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=h;let m=[];m={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=m,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function qn(o,e,t){let n=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,o){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(r,a,l,h,c){let d=new b.ExtrudeGeometry(r,a),m=new b.MeshStandardMaterial({color:l,side:b.DoubleSide}),p=new b.Mesh(d,m);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 Xi(o,e=!1){const t=o[0].index!==null,n=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),s={},r={},a=o[0].morphTargetsRelative,l=new _.BufferGeometry;let h=0;for(let c=0;c<o.length;++c){const d=o[c];let m=0;if(t!==(d.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 d.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(d.attributes[p]),m++}if(m!==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!==d.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 d.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;r[p]===void 0&&(r[p]=[]),r[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.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 d=[];for(let m=0;m<o.length;++m){const p=o[m].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+c);c+=o[m].attributes.position.count}l.setIndex(d)}for(const c in s){const d=zr(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(const c in r){const d=r[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let m=0;m<d;++m){const p=[];for(let u=0;u<r[c].length;++u)p.push(r[c][u][m]);const f=zr(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function zr(o){let e,t,n,i=-1,s=0;for(let h=0;h<o.length;++h){const c=o[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 r=new e(s),a=new _.BufferAttribute(r,t,n);let l=0;for(let h=0;h<o.length;++h){const c=o[h];if(c.isInterleavedBufferAttribute){const d=l/t;for(let m=0,p=c.count;m<p;m++)for(let f=0;f<t;f++){const u=c.getComponent(m,f);a.setComponent(m+d,f,u)}}else r.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Br(o,e){if(e===_.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===_.TriangleFanDrawMode||e===_.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)r.push(l);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,i=[];if(e===_.TriangleFanDrawMode)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Ql extends _.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new pc(t)}),this.register(function(t){return new mc(t)}),this.register(function(t){return new gc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new cc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new fc(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new yc(t)}),this.register(function(t){return new vc(t)})}load(e,t,n,i){const s=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=_.LoaderUtils.extractUrlBase(e);r=_.LoaderUtils.resolveURL(h,this.path)}else r=_.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 _.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,r,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 r={},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))===Or){try{r[le.KHR_BINARY_GLTF]=new wc(e)}catch(d){i&&i(d);return}s=JSON.parse(r[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 Lc(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 d=this.pluginCallbacks[c](h);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,r[d.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const d=s.extensionsUsed[c],m=s.extensionsRequired||[];switch(d){case le.KHR_MATERIALS_UNLIT:r[d]=new nc;break;case le.KHR_DRACO_MESH_COMPRESSION:r[d]=new xc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[d]=new bc;break;case le.KHR_MESH_QUANTIZATION:r[d]=new Mc;break;default:m.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}h.setExtensions(r),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 ec(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}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 tc{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 _.Color(16777215);l.color!==void 0&&c.setRGB(l.color[0],l.color[1],l.color[2],_.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new _.DirectionalLight(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new _.PointLight(c),h.distance=d;break;case"spot":h=new _.SpotLight(c),h.distance=d,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 nc{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return _.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new _.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const r=s.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],_.LinearSRGBColorSpace),e.opacity=r[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,_.SRGBColorSpace))}return Promise.all(i)}}class ic{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 sc{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:_.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=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new _.Vector2(a,a)}return Promise.all(s)}}class rc{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:_.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 oc{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:_.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=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class ac{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:_.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 _.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,_.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class lc{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:_.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=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class cc{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:_.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=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),Promise.all(s)}}class hc{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:_.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 uc{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:_.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=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,_.SRGBColorSpace)),Promise.all(s)}}class dc{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:_.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=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(s)}}class fc{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:_.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=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(s)}}class pc{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],r=t.options.ktx2Loader;if(!r){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,r)}}class mc{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 r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,r.source,l)}}class gc{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 r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,r.source,l)}}class yc{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),r=this.parser.options.meshoptDecoder;if(!r||!r.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,d=i.byteStride,m=new Uint8Array(a,l,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,d,m,i.mode,i.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(c*d);return r.decodeGltfBuffer(new Uint8Array(p),c,d,m,i.mode,i.filter),p})})}else return null}}class vc{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!==Ve.TRIANGLES&&h.mode!==Ve.TRIANGLE_STRIP&&h.mode!==Ve.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],l={};for(const h in r)a.push(this.parser.getDependency("accessor",r[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(),d=c.isGroup?c.children:[c],m=h[0].count,p=[];for(const f of d){const u=new _.Matrix4,g=new _.Vector3,y=new _.Quaternion,v=new _.Vector3(1,1,1),w=new _.InstancedMesh(f.geometry,f.material,m);for(let x=0;x<m;x++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,x),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,x),l.SCALE&&v.fromBufferAttribute(l.SCALE,x),w.setMatrixAt(x,u.compose(g,y,v));for(const x in l)if(x==="_COLOR_0"){const M=l[x];w.instanceColor=new _.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&f.geometry.setAttribute(x,l[x]);_.Object3D.prototype.copy.call(w,f),this.parser.assignFinalMaterial(w),p.push(w)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Or="glTF",cn=12,Rr={JSON:1313821514,BIN:5130562};class wc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,cn),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!==Or)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-cn,s=new DataView(e,cn);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Rr.JSON){const h=new Uint8Array(e,cn+r,a);this.content=n.decode(h)}else if(l===Rr.BIN){const h=cn+r;this.body=e.slice(h,h+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class xc{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,r=e.extensions[this.name].attributes,a={},l={},h={};for(const c in r){const d=Yi[c]||c.toLowerCase();a[d]=r[c]}for(const c in e.attributes){const d=Yi[c]||c.toLowerCase();if(r[c]!==void 0){const m=n.accessors[e.attributes[c]],p=Zt[m.componentType];h[d]=p.name,l[d]=m.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(d,m){i.decodeDracoFile(c,function(p){for(const f in p.attributes){const u=p.attributes[f],g=l[f];g!==void 0&&(u.normalized=g)}d(p)},a,h,_.LinearSRGBColorSpace,m)})})}}class bc{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 Mc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Nr extends _.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 r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=a*2,h=a*3,c=i-t,d=(n-t)/c,m=d*d,p=m*d,f=e*h,u=f-h,g=-2*p+3*m,y=p-m,v=1-g,w=y-m+d;for(let x=0;x!==a;x++){const M=r[u+x+a],T=r[u+x+l]*c,P=r[f+x+a],k=r[f+x]*c;s[x]=v*M+w*T+g*P+y*k}return s}}const _c=new _.Quaternion;class Sc extends Nr{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return _c.fromArray(s).normalize().toArray(s),s}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Zt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Fr={9728:_.NearestFilter,9729:_.LinearFilter,9984:_.NearestMipmapNearestFilter,9985:_.LinearMipmapNearestFilter,9986:_.NearestMipmapLinearFilter,9987:_.LinearMipmapLinearFilter},Ur={33071:_.ClampToEdgeWrapping,33648:_.MirroredRepeatWrapping,10497:_.RepeatWrapping},Zi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yi={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"},pt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Cc={CUBICSPLINE:void 0,LINEAR:_.InterpolateLinear,STEP:_.InterpolateDiscrete},Ki={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ac(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new _.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_.FrontSide})),o.DefaultMaterial}function Dt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Pc(o,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const d=e[h];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const d=e[h];if(n){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;r.push(m)}if(i){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(m)}if(s){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(m)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],d=h[1],m=h[2];return n&&(o.morphAttributes.position=c),i&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=m),o.morphTargetsRelative=!0,o})}function Tc(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Dc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qi(t.attributes):e=o.indices+":"+qi(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+qi(o.targets[n]);return e}function qi(o){let e="";const t=Object.keys(o).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+o[t[n]]+";";return e}function $i(o){switch(o){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 kc(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ec=new _.Matrix4;class Lc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ec,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,r=-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,r=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&r<98?this.textureLoader=new _.TextureLoader(this.options.manager):this.textureLoader=new _.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _.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(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Dt(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 r=t[i].joints;for(let a=0,l=r.length;a<l;a++)e[r[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(r,a)=>{const l=this.associations.get(r);l!=null&&this.associations.set(a,l);for(const[h,c]of r.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,r){return n.getDependency(e,r)})),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,r){n.load(_.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){r(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 r=Zi[i.type],a=Zt[i.componentType],l=i.normalized===!0,h=new a(i.count*r);return Promise.resolve(new _.BufferAttribute(h,r,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(r){const a=r[0],l=Zi[i.type],h=Zt[i.componentType],c=h.BYTES_PER_ELEMENT,d=c*l,m=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let u,g;if(p&&p!==d){const y=Math.floor(m/p),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let w=t.cache.get(v);w||(u=new h(a,y*p,i.count*p/c),w=new _.InterleavedBuffer(u,p/c),t.cache.add(v,w)),g=new _.InterleavedBufferAttribute(w,l,m%p/c,f)}else a===null?u=new h(i.count*l):u=new h(a,m,i.count*l),g=new _.BufferAttribute(u,l,f);if(i.sparse!==void 0){const y=Zi.SCALAR,v=Zt[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,M=new v(r[1],w,i.sparse.count*y),T=new h(r[2],x,i.sparse.count*l);a!==null&&(g=new _.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=M.length;P<k;P++){const D=M[P];if(g.setX(D,T[P*l]),l>=2&&g.setY(D,T[P*l+1]),l>=3&&g.setZ(D,T[P*l+2]),l>=4&&g.setW(D,T[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=f}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const l=n.manager.getHandler(r.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,n).then(function(c){c.flipY=!1,c.name=r.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const m=(s.samplers||{})[r.sampler]||{};return c.magFilter=Fr[m.magFilter]||_.LinearFilter,c.minFilter=Fr[m.minFilter]||_.LinearMipmapLinearFilter,c.wrapS=Ur[m.wrapS]||_.RepeatWrapping,c.wrapT=Ur[m.wrapT]||_.RepeatWrapping,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==_.NearestFilter&&c.minFilter!==_.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(d=>d.clone());const r=i.images[e],a=self.URL||self.webkitURL;let l=r.uri||"",h=!1;if(r.bufferView!==void 0)l=n.getDependency("bufferView",r.bufferView).then(function(d){h=!0;const m=new Blob([d],{type:r.mimeType});return l=a.createObjectURL(m),l});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(l).then(function(d){return new Promise(function(m,p){let f=m;t.isImageBitmapLoader===!0&&(f=function(u){const g=new _.Texture(u);g.needsUpdate=!0,m(g)}),t.load(_.LoaderUtils.resolveURL(d,s.path),f,void 0,p)})}).then(function(d){return h===!0&&a.revokeObjectURL(l),Qe(d,r),d.userData.mimeType=r.mimeType||kc(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.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(r);r=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),s.associations.set(r,l)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.PointsMaterial,_.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 _.LineBasicMaterial,_.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||r){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),r&&(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 _.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},l=s.extensions||{},h=[];if(l[le.KHR_MATERIALS_UNLIT]){const d=i[le.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),h.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new _.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;a.color.setRGB(m[0],m[1],m[2],_.LinearSRGBColorSpace),a.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",d.baseColorTexture,_.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=_.DoubleSide);const c=s.alphaMode||Ki.OPAQUE;if(c===Ki.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Ki.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==_.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new _.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&r!==_.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==_.MeshBasicMaterial){const d=s.emissiveFactor;a.emissive=new _.Color().setRGB(d[0],d[1],d[2],_.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==_.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,_.SRGBColorSpace)),Promise.all(h).then(function(){const d=new r(a);return s.name&&(d.name=s.name),Qe(d,s),t.associations.set(d,{materials:e}),s.extensions&&Dt(i,d,s),d})}createUniqueName(e){const t=_.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 Vr(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=Dc(h),d=i[c];if(d)r.push(d.promise);else{let m;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?m=s(h):m=Vr(new _.BufferGeometry,h,t),i[c]={primitive:h,promise:m},r.push(m)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l].material===void 0?Ac(this.cache):this.getDependency("material",r[l].material);a.push(c)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(l){const h=l.slice(0,l.length-1),c=l[l.length-1],d=[];for(let p=0,f=c.length;p<f;p++){const u=c[p],g=r[p];let y;const v=h[p];if(g.mode===Ve.TRIANGLES||g.mode===Ve.TRIANGLE_STRIP||g.mode===Ve.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new _.SkinnedMesh(u,v):new _.Mesh(u,v),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Br(y.geometry,_.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Br(y.geometry,_.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new _.LineSegments(u,v);else if(g.mode===Ve.LINE_STRIP)y=new _.Line(u,v);else if(g.mode===Ve.LINE_LOOP)y=new _.LineLoop(u,v);else if(g.mode===Ve.POINTS)y=new _.Points(u,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Tc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&Dt(i,y,g),t.assignFinalMaterial(y),d.push(y)}for(let p=0,f=d.length;p<f;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return s.extensions&&Dt(i,d[0],s),d[0];const m=new _.Group;s.extensions&&Dt(i,m,s),t.associations.set(m,{meshes:e});for(let p=0,f=d.length;p<f;p++)m.add(d[p]);return m})}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 _.PerspectiveCamera(_.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new _.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(),r=i,a=[],l=[];for(let h=0,c=r.length;h<c;h++){const d=r[h];if(d){a.push(d);const m=new _.Matrix4;s!==null&&m.fromArray(s.array,h*16),l.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new _.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,r=[],a=[],l=[],h=[],c=[];for(let d=0,m=i.channels.length;d<m;d++){const p=i.channels[d],f=i.samplers[p.sampler],u=p.target,g=u.node,y=i.parameters!==void 0?i.parameters[f.input]:f.input,v=i.parameters!==void 0?i.parameters[f.output]:f.output;u.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",v)),h.push(f),c.push(u))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(d){const m=d[0],p=d[1],f=d[2],u=d[3],g=d[4],y=[];for(let w=0,x=m.length;w<x;w++){const M=m[w],T=p[w],P=f[w],k=u[w],D=g[w];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const E=n._createAnimationTracks(M,T,P,k,D);if(E)for(let O=0;O<E.length;O++)y.push(E[O])}const v=new _.AnimationClip(s,void 0,y);return Qe(v,i),v})}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 r=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let l=0,h=i.weights.length;l<h;l++)a.morphTargetInfluences[l]=i.weights[l]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),r=[],a=i.children||[];for(let h=0,c=a.length;h<c;h++)r.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(r),l]).then(function(h){const c=h[0],d=h[1],m=h[2];m!==null&&c.traverse(function(p){p.isSkinnedMesh&&p.bind(m,Ec)});for(let p=0,f=d.length;p<f;p++)c.add(d[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],r=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 _.Bone:h.length>1?c=new _.Group:h.length===1?c=h[0]:c=new _.Object3D,c!==h[0])for(let d=0,m=h.length;d<m;d++)c.add(h[d]);if(s.name&&(c.userData.name=s.name,c.name=r),Qe(c,s),s.extensions&&Dt(n,c,s),s.matrix!==void 0){const d=new _.Matrix4;d.fromArray(s.matrix),c.applyMatrix4(d)}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 d=i.associations.get(c);i.associations.set(c,{...d})}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 _.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&Dt(t,s,n);const r=n.nodes||[],a=[];for(let l=0,h=r.length;l<h;l++)a.push(i.getDependency("node",r[l]));return Promise.all(a).then(function(l){for(let c=0,d=l.length;c<d;c++)s.add(l[c]);const h=c=>{const d=new Map;for(const[m,p]of i.associations)(m instanceof _.Material||m instanceof _.Texture)&&d.set(m,p);return c.traverse(m=>{const p=i.associations.get(m);p!=null&&d.set(m,p)}),d};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];pt[s.path]===pt.weights?e.traverse(function(m){m.morphTargetInfluences&&l.push(m.name?m.name:m.uuid)}):l.push(a);let h;switch(pt[s.path]){case pt.weights:h=_.NumberKeyframeTrack;break;case pt.rotation:h=_.QuaternionKeyframeTrack;break;case pt.translation:case pt.scale:h=_.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=_.NumberKeyframeTrack;break;case 2:case 3:default:h=_.VectorKeyframeTrack;break}break}const c=i.interpolation!==void 0?Cc[i.interpolation]:_.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let m=0,p=l.length;m<p;m++){const f=new h(l[m]+"."+pt[s.path],t.array,d,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),r.push(f)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=$i(t.constructor),i=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof _.QuaternionKeyframeTrack?Sc:Nr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ic(o,e,t){const n=e.attributes,i=new _.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 _.Vector3(l[0],l[1],l[2]),new _.Vector3(h[0],h[1],h[2])),a.normalized){const c=$i(Zt[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 _.Vector3,l=new _.Vector3;for(let h=0,c=s.length;h<c;h++){const d=s[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],p=m.min,f=m.max;if(p!==void 0&&f!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),m.normalized){const u=$i(Zt[m.componentType]);l.multiplyScalar(u)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new _.Sphere;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Vr(o,e,t){const n=e.attributes,i=[];function s(r,a){return t.getDependency("accessor",r).then(function(l){o.setAttribute(a,l)})}for(const r in n){const a=Yi[r]||r.toLowerCase();a in o.attributes||i.push(s(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return _.ColorManagement.workingColorSpace!==_.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${_.ColorManagement.workingColorSpace}" not supported.`),Qe(o,e),Ic(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Pc(o,e.targets,t):o})}function zc(o,e,t){let n=new b.Group;n.name=e,o.scene.add(n),Gi(e+"/info",i=>{let s=JSON.parse(i);o.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),o.models==null&&(o.models=[]),o.models.push({url:e,nodesMap:new Map,boundingBox:{min:new b.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new b.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ft.EngineFree,e)})}function Bc(o,e){o.engineStatus.models.filter(t=>e==null||t.url==e).forEach(t=>{t.loadStatus==null&&(t.loadStatus={mep:!1,instance:!1,normal:!1}),t.status==="loading"&&t.type==="light"&&(t.loadStatus.modelMep!=!0&&(t.loadStatus.modelMep=!0,Jl(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Oc(o,t))})}function Oc(o,e){if(o.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={},ql(e.url+i.path,s=>{Ir(s.get("/nodes.json"),r=>{let a=JSON.parse(r);o.models.find(c=>c.url==e.url).nodesMap==null&&(o.models.find(c=>c.url==e.url).nodesMap=new Map);let l=o.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 d=new Ql;const m=new $l;m.setDecoderPath("/draco/"),m.preload(),d.setDRACOLoader(m),d.load(s.get(c+".glb"),p=>{i.glbs[c]=p.scene.children,i.glbs[c].forEach(f=>{f.geometry.computeVertexNormals()}),h++,h==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ft.EngineFree,e.url),o.viewCube.CameraGoHome())})}Ir(s.get("/instances.json"),c=>{let d=JSON.parse(c);o.models.find(m=>m.url==e.url).instanceNodes=d})})});else{let s=n(e,i,i.octreeBox),r=[],a=o.models.find(h=>h.url==e.url);s.forEach(h=>{a.nodesMap.has(h)&&a.nodesMap.get(h).infos.forEach(c=>{let d=i.glbs[c.glb][c.mesh];if(d!=null&&d.geometry!=null&&d.material!=null){let m=new b.Matrix4;m.elements=c.matrix;let p=new b.Mesh(d.geometry.clone().applyMatrix4(m),d.material),f=new b.Box3().setFromObject(p);c.box=f,c.mesh=p,p.name=h,p.glb=c.glb,p.url=e.url,d.geometry.attributes.position!=null&&r.push(p)}})}),Rc(e.url,o,r);let l=a.instanceNodes;if(l!=null)for(let h in l)(l[h].isLoaded==null||l[h].isLoaded==!1)&&(l[h].isLoaded=!0,l[h].forEach(c=>{if(i.glbs[h]!=null){let d=i.glbs[h][c.mesh];Nc(e.url,c.mesh,o,d,c.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new b.Vector3(r.min.X,r.min.Z,-r.min.Y),h=new b.Vector3(r.max.X,r.max.Z,-r.max.Y);h.distanceTo(l);let c=o.camera.position,d=new b.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(d),r.elements.forEach(m=>{a.push(m)}),r.children.forEach(m=>{a.push(...n(i,s,m))}),r.children.findIndex(m=>m.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Rc(o,e,t){let n=[];t.forEach(i=>{n.findIndex(r=>r.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(r=>r.glb==i.glb).meshes.push(i),n.find(r=>r.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(r=>r.glb==i.glb);s.indexes.has(Number(i.name))?s.indexes.get(Number(i.name)).push([s.currentIndex-i.geometry.index.count,s.currentIndex]):s.indexes.set(Number(i.name),[[s.currentIndex-i.geometry.index.count,s.currentIndex]])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof b.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new b.BufferGeometry,a=Fc(i.meshes[0].material);r=Xi(i.meshes.map(c=>c.geometry),!1);let l=new b.Mesh(r,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=o,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==o);if(h!=null){let c=0;i.indexes.forEach(d=>{d.forEach(m=>{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++,m[0],m[1]])})})}}})}function Nc(o,e,t,n,i){if(n==null)return;let s=new b.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)r[l*3]=1,r[l*3+1]=1,r[l*3+2]=1;s.instanceColor=new b.InstancedBufferAttribute(r,3);let a=[];for(let l=0;l<i.length;l++){let h=i[l],c=new b.Matrix4;c.elements=h.matrix,s.setMatrixAt(l,c),s.matrixs||(s.matrixs=[]),s.matrixs.push(c.clone()),a.push(c.clone()),t.models.find(d=>d.url==o).nodesMap.has(h.id)?(t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes==null&&(t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes=[]),t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(d=>d.url==o).nodesMap.set(h.id,{instance:!0,info:h,indexes:[[t.scene.children.length-1,l,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(l=>l.id),s.matrixsClone=a}function Fc(o){return o.map!=null&&(o.map.colorSpace=b.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=b.FrontSide,o.side=o.side,o}class Uc{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&zc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class Vc{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(ft.EngineFree,e=>{this.updateFree(!0),Bc(this.engine,e)}),this.engine.events.on(ft.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let jc=class{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,r)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${r}:`,a)}})}};class Gc{engine;constructor(e){this.engine=e}init(){const e=new b.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 b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new b.AmbientLight(16777215,1);this.engine.scene.add(i)}}var Me=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.MeasureClick="measure-click",o.SectionMove="section-move",o))(Me||{});class Wc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new b.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;timeOutEvent;handleMouseMove(e){if(this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null),e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;let n=this.getCatchMeshs(e,!0);n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let n=e.catch.object,i=e.catch.object.id,s=this.engine.models.find(l=>l.url==n.url).nodesMap.get(i),r=new Map;s?.indexes.forEach(l=>{this.engine.scene.children[l[0]]instanceof b.InstancedMesh&&(r.has(l[0])?r.get(l[0])?.push(l[1]):r.set(l[0],[l[1]]))});let a=[];return r.forEach((l,h)=>{let c=this.engine.scene.children[h];l.forEach(d=>{let m=c.geometry.clone();m.applyMatrix4(c.matrixs[d]),a.push(new b.Mesh(m,c.material))})}),this.hoverOldId==i?[]:(this.hoverOldId=i,t||this.engine.hoverHighLight.clearHighlight(),a)}else{let i=e.catch.object,s=i.name,l=this.engine.models.find(h=>h.url===i.url).nodesMap.get(s).infos.map(h=>h.mesh);return this.hoverOldId==s?[]:(this.hoverOldId=s,t||this.engine.hoverHighLight.clearHighlight(),l)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(Me.Click,[{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;let i=n.object,r=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix;const l=[];r.indexes.forEach(c=>{let d=c[0],m=this.engine.scene.children[d].geometry.boundingSphere;const p=new b.Box3,f=m.center.clone().applyMatrix4(a),u=m.radius,g=new b.Vector3;g.setFromMatrixScale(a);const y=Math.max(g.x,g.y,g.z),v=u*y;p.min.set(f.x-v,f.y-v,f.z-v),p.max.set(f.x+v,f.y+v,f.z+v),l.push(p)});let h=t(l);this.engine.viewCube.zoomToModel(h)}else{const a=r.infos.map(h=>h.box);let l=t(a);this.engine.viewCube.zoomToModel(l)}}function t(n){let i=new b.Vector3(1e8,1e9,1e10),s=new b.Vector3(-1e8,-1e9,-1e10);return n.forEach(r=>{r.min.x<i.x&&(i.x=r.min.x),r.min.y<i.y&&(i.y=r.min.y),r.min.z<i.z&&(i.z=r.min.z),r.max.x>s.x&&(s.x=r.max.x),r.max.y>s.y&&(s.y=r.max.y),r.max.z>s.z&&(s.z=r.max.z)}),new b.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof b.InstancedMesh),!0)}}class Xc{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),this.hideMaterial=new b.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.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 b.InstancedMesh)return;let t=e.materialClone.clone(),n=Xi(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(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.engine.scene.children[a[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[a[0]]),this.engine.scene.children[a[0]].geometry.groups[a[1]].materialIndex=1)})}),Zc(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):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(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof b.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=0})}),jr(n,this.engine,"highlightModel")})}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 r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.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&&Kc(n,this.engine);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 r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.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&&Gr(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const r=i.ids.indexOf(s);r!==-1&&i.ids.splice(r,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(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[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(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),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.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.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)})}),Yc(n,this.engine);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(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof b.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(this.split_merge_model(this.engine.scene.children[r[0]]),a.geometry.groups[r[1]].materialIndex=0)})}),n.size>0&&Gr(n,this.engine),jr(n,this.engine,"translucentModel")}),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(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=i.geometry,r=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),a=new b.InstancedMesh(s,r,t.length);a.name="highlightModel",a.key=n;const l=new Map,h=new b.Matrix4,c=new b.Matrix4;c.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,h),l.set(d,h.clone()),i.setMatrixAt(d,c),a.setMatrixAt(m,h)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function jr(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof b.InstancedMesh))return;n.forEach(a=>{const l=s.matrixsClone[a];l&&s.setMatrixAt(a,l)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function Yc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=i.geometry,r=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),a=new b.InstancedMesh(s,r,t.length);a.name="translucentModel",a.key=n;const l=new Map,h=new b.Matrix4,c=new b.Matrix4;c.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,h),l.set(d,h.clone()),i.setMatrixAt(d,c),a.setMatrixAt(m,h)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Kc(o,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=new Map,r=new b.Matrix4,a=new b.Matrix4;a.makeScale(0,0,0),t.forEach((l,h)=>{i.getMatrixAt(l,r),s.set(l,r.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Gr(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof b.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class qc{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof b.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&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}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")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof b.DirectionalLight),i={low:1024,medium:2048,high:2048}[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 $n{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);i.infos&&i.infos.length>0&&(this.tagDiv.innerHTML=i.infos[0].name);const r=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=r.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=r.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:b.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}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 r=new b.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),r.matrix.copy(s.matrixWorld),r.matrixAutoUpdate=!1,this.engine.scene.add(r),this.overlayMeshes.push(r)}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/$n.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/$n.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 Hn={exports:{}},$c=Hn.exports,Wr;function Hc(){return Wr||(Wr=1,(function(o,e){(function(t,n){o.exports=n()})($c,function(){var t=function(){function n(p){return r.appendChild(p.dom),p}function i(p){for(var f=0;f<r.children.length;f++)r.children[f].style.display=f===p?"block":"none";s=p}var s=0,r=document.createElement("div");r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(p){p.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var p=(performance||Date).now();if(d.update(p-a,200),p>l+1e3&&(c.update(1e3*h/(p-l),100),l=p,h=0,m)){var f=performance.memory;m.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:r,setMode:i}};return t.Panel=function(n,i,s){var r=1/0,a=0,l=Math.round,h=l(window.devicePixelRatio||1),c=80*h,d=48*h,m=3*h,p=2*h,f=3*h,u=15*h,g=74*h,y=30*h,v=document.createElement("canvas");v.width=c,v.height=d,v.style.cssText="width:80px;height:48px";var w=v.getContext("2d");return w.font="bold "+9*h+"px Helvetica,Arial,sans-serif",w.textBaseline="top",w.fillStyle=s,w.fillRect(0,0,c,d),w.fillStyle=i,w.fillText(n,m,p),w.fillRect(f,u,g,y),w.fillStyle=s,w.globalAlpha=.9,w.fillRect(f,u,g,y),{dom:v,update:function(x,M){r=Math.min(r,x),a=Math.max(a,x),w.fillStyle=s,w.globalAlpha=1,w.fillRect(0,0,c,u),w.fillStyle=i,w.fillText(l(x)+" "+n+" ("+l(r)+"-"+l(a)+")",m,p),w.drawImage(v,f+h,u,g-h,y,f,u,g-h,y),w.fillRect(f+g-h,u,h,y),w.fillStyle=s,w.globalAlpha=.9,w.fillRect(f+g-h,u,h,l((1-x/M)*y))}}},t})})(Hn)),Hn.exports}var Jc=Hc();const Qc=Xs(Jc);var Yt=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-Yt.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?Yt.Bounce.In(o*2)*.5:Yt.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),hn=function(){return performance.now()},eh=(function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=hn()),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]],r=!t;s&&s.update(e,r)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o})(),Hi={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=Hi.Utils.Linear;return e<0?s(o[0],o[1],n):e>1?s(o[t],o[t-1],t-n):s(o[i],o[i+1>t?t:i+1],n-i)},Utils:{Linear:function(o,e,t){return(e-o)*t+o}}},Xr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),Ji=new eh,th=(function(){function o(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=Yt.Linear.None,this._interpolationFunction=Hi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Xr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.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},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=hn()),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},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,n,i,s){for(var r in n){var a=e[r],l=Array.isArray(a),h=l?"array":typeof a,c=!l&&Array.isArray(n[r]);if(!(h==="undefined"||h==="function")){if(c){var d=n[r];if(d.length===0)continue;for(var m=[a],p=0,f=d.length;p<f;p+=1){var u=this._handleRelativeValue(a,d[p]);if(isNaN(u)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(u)}c&&(n[r]=m)}if((h==="object"||l)&&a&&!c){t[r]=l?[]:{};var g=a;for(var y in g)t[r][y]=g[y];i[r]=l?[]:{};var d=n[r];if(!this._isDynamic){var v={};for(var y in d)v[y]=d[y];n[r]=d=v}this._setupProperties(g,t[r],d,i[r],s)}else(typeof t[r]>"u"||s)&&(t[r]=a),l||(t[r]*=1),c?i[r]=n[r].slice().reverse():i[r]=t[r]||0}}},o.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},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=hn()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=hn()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=Ji),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=Yt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Hi.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=hn()),t===void 0&&(t=!0),this._isPaused)return!0;var s,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)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,v=Math.min(y/n._duration,1);return v===0&&a===n._duration?1:v},d=c(),m=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),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 f=0,u=this._chainedTweens.length;f<u;f++)this._chainedTweens[f].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var r=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],r,a,i):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(e[s]=r+(a-r)*i))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.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},o})();Xr.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 un={Easing:Yt,Tween:th};class nh extends _.DataTextureLoader{constructor(e){super(e),this.type=_.HalfFloatType}parse(e){const r=function(k,D){switch(k){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(D||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(D||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(D||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(D||""))}},d=function(k,D,E){D=D||1024;let A=k.pos,I=-1,S=0,z="",V=String.fromCharCode.apply(null,new Uint16Array(k.subarray(A,A+128)));for(;0>(I=V.indexOf(`
965
+ `):" "+Pr(r[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const Tr={getAdapter:Wl,adapters:Vi};function ji(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Xt(null,o)}function Dr(o){return ji(o),o.headers=Fe.from(o.headers),o.data=Ui.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Tr.getAdapter(o.adapter||an.adapter,o)(o).then(function(n){return ji(o),n.data=Ui.call(o,o.transformResponse,n),n.headers=Fe.from(n.headers),n},function(n){return pr(n)||(ji(o),n&&n.response&&(n.response.data=Ui.call(o,o.transformResponse,n.response),n.response.headers=Fe.from(n.response.headers))),Promise.reject(n)})}const kr="1.13.2",Yn={};["object","boolean","number","function","string","symbol"].forEach((o,e)=>{Yn[o]=function(n){return typeof n===o||"a"+(e<1?"n ":" ")+o}});const Er={};Yn.transitional=function(e,t,n){function i(s,r){return"[Axios v"+kr+"] Transitional option '"+s+"'"+r+(n?". "+n:"")}return(s,r,a)=>{if(e===!1)throw new re(i(r," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!Er[r]&&(Er[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,r,a):!0}},Yn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Xl(o,e,t){if(typeof o!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const n=Object.keys(o);let i=n.length;for(;i-- >0;){const s=n[i],r=e[s];if(r){const a=o[s],l=a===void 0||r(a,s,o);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 Kn={assertOptions:Xl,validators:Yn},Je=Kn.validators;let Tt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new hr,response:new hr}}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+=`
966
+ `+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Pt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Kn.assertOptions(n,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},!1),i!=null&&(W.isFunction(i)?t.paramsSerializer={serialize:i}:Kn.assertOptions(i,{encode:Je.function,serialize:Je.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Kn.assertOptions(t,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=s&&W.merge(s.common,s[t.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),t.headers=Fe.concat(r,s);const a=[];let l=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(t)===!1||(l=l&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const c=[];this.interceptors.response.forEach(function(u){c.push(u.fulfilled,u.rejected)});let h,d=0,m;if(!l){const f=[Dr.bind(this),void 0];for(f.unshift(...a),f.push(...c),m=f.length,h=Promise.resolve(t);d<m;)h=h.then(f[d++],f[d++]);return h}m=a.length;let p=t;for(;d<m;){const f=a[d++],u=a[d++];try{p=f(p)}catch(g){u.call(this,g);break}}try{h=Dr.call(this,p)}catch(f){return Promise.reject(f)}for(d=0,m=c.length;d<m;)h=h.then(c[d++],c[d++]);return h}getUri(e){e=Pt(this.defaults,e);const t=vr(e.baseURL,e.url,e.allowAbsoluteUrls);return cr(t,e.params,e.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(e){Tt.prototype[e]=function(t,n){return this.request(Pt(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(n){return function(s,r,a){return this.request(Pt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}Tt.prototype[e]=t(),Tt.prototype[e+"Form"]=t(!0)});let Zl=class Wo{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 r=new Promise(a=>{n.subscribe(a),s=a}).then(i);return r.cancel=function(){n.unsubscribe(s)},r},e(function(s,r,a){n.reason||(n.reason=new Xt(s,r,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 Wo(function(i){e=i}),cancel:e}}};function Yl(o){return function(t){return o.apply(null,t)}}function Kl(o){return W.isObject(o)&&o.isAxiosError===!0}const Gi={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(Gi).forEach(([o,e])=>{Gi[e]=o});function Lr(o){const e=new Tt(o),t=Ks(Tt.prototype.request,e);return W.extend(t,Tt.prototype,e,{allOwnKeys:!0}),W.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Lr(Pt(o,i))},t}const ye=Lr(an);ye.Axios=Tt,ye.CanceledError=Xt,ye.CancelToken=Zl,ye.isCancel=pr,ye.VERSION=kr,ye.toFormData=Gn,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=Yl,ye.isAxiosError=Kl,ye.mergeConfig=Pt,ye.AxiosHeaders=Fe,ye.formToJSON=o=>dr(W.isHTMLForm(o)?new FormData(o):o),ye.getAdapter=Tr.getAdapter,ye.HttpStatusCode=Gi,ye.default=ye;const{Axios:Lf,AxiosError:If,CanceledError:zf,isCancel:Bf,CancelToken:Of,VERSION:Rf,all:Nf,Cancel:Ff,isAxiosError:Uf,spread:Vf,toFormData:jf,AxiosHeaders:Gf,HttpStatusCode:Wf,formToJSON:Xf,getAdapter:Zf,mergeConfig:Yf}=ye;function Ir(o,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=o;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 ql(o,e){ye({method:"get",responseType:"blob",url:o}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});Ys.loadAsync(n).then(i=>{const s=new Map,r=[];for(let a in i.files){if(i.files[a].dir)continue;const l=i.file(i.files[a].name);if(l){const c=l.async("blob").then(h=>{const d=URL.createObjectURL(h);s.set("/"+i.files[a].name.replace("\\","/"),d)});r.push(c)}}Promise.all(r).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 Wi(o,e){ye({method:"get",responseType:"blob",url:o}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});Ys.loadAsync(i).then(s=>{for(let r in s.files)s.file(s.files[r].name).async("blob").then(l=>{t(l,"utf-8",function(c,h){e(h)})})})});function t(n,i,s){var r=new FileReader,a=new Blob([n]);r.onload=function(l){s(null,l.target.result)},r.onerror=function(l){s(l.error,null)},r.readAsText(a,i)}}const Xi=new WeakMap;class $l extends _.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 _.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,_.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=_.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Xi.has(e)){const l=Xi.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++,r=e.byteLength,a=this._getWorker(s,r).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},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)}),Xi.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new _.BufferGeometry;e.index&&t.setIndex(new _.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:r,stride:a,vertexColorSpace:l}=e.attributes[n];let c;if(r===a)c=new _.BufferAttribute(s,r);else{const h=new _.InterleavedBuffer(s,a);c=new _.InterleavedBufferAttribute(h,r,0)}i==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(s instanceof Float32Array)),t.setAttribute(i,c)}return t}_assignVertexColorSpace(e,t){if(t!==_.SRGBColorSpace)return;const n=new _.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),_.ColorManagement.colorSpaceToWorking(n,_.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new _.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=Hl.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
967
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),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 r=s.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.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 Hl(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(h){o.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,m=new d.Decoder;try{const p=t(d,m,new Int8Array(l),c),f=p.attributes.map(u=>u.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{d.destroy(m)}});break}};function t(r,a,l,c){const h=c.attributeIDs,d=c.attributeTypes;let m,p;const f=a.GetEncodedGeometryType(l);if(f===r.TRIANGULAR_MESH)m=new r.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,m);else if(f===r.POINT_CLOUD)m=new r.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const u={index:null,attributes:[]};for(const g in h){const y=self[d[g]];let v,w;if(c.useUniqueIDs)w=h[g],v=a.GetAttributeByUniqueId(m,w);else{if(w=a.GetAttributeId(m,r[h[g]]),w===-1)continue;v=a.GetAttribute(m,w)}const x=i(r,a,m,g,y,v);g==="color"&&(x.vertexColorSpace=c.vertexColorSpace),u.attributes.push(x)}return f===r.TRIANGULAR_MESH&&(u.index=n(r,a,m)),r.destroy(m),u}function n(r,a,l){const h=l.num_faces()*3,d=h*4,m=r._malloc(d);a.GetTrianglesUInt32Array(l,d,m);const p=new Uint32Array(r.HEAPF32.buffer,m,h).slice();return r._free(m),{array:p,itemSize:1}}function i(r,a,l,c,h,d){const m=l.num_points(),p=d.num_components(),f=s(r,h),u=p*h.BYTES_PER_ELEMENT,g=Math.ceil(u/4)*4,y=g/h.BYTES_PER_ELEMENT,v=m*u,w=m*g,x=r._malloc(v);a.GetAttributeDataArrayForAllPoints(l,d,f,v,x);const M=new h(r.HEAPF32.buffer,x,v/h.BYTES_PER_ELEMENT);let T;if(u===g)T=M.slice();else{T=new h(w/h.BYTES_PER_ELEMENT);let P=0;for(let k=0,D=M.length;k<D;k++){for(let E=0;E<p;E++)T[P+E]=M[k*p+E];P+=y}}return r._free(x),{name:c,count:m,itemSize:p,array:T,stride:y}}function s(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var ft=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.ViewportResize="viewport-resize",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.SectionMove="section-move",o))(ft||{});function Jl(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(p=>p.url==t),l=e.circularMeps,c=e.rectMeps?.filter(p=>p.type==="风管"),h=e.rectMeps?.filter(p=>p.type==="桥架"),d=e.ellipseMeps,m=o.scene;if(new b.MeshBasicMaterial,new b.BufferGeometry,l&&l.length){let p=[],f=0;for(let u of l)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Circle",m,p,t)}if(c&&c.length){let p=[],f=0;for(let u of c)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Rect",m,p,t)}if(d&&d.length){let p=[],f=0;for(let u of d)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Ellipse",m,p,t)}if(h&&h.length){let p=[],f=0;for(let u of h)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Bridge",m,p,t)}}function qn(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new b.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=$n("Rect",a);break;case"Bridge":r=$n("Bridge",a);break;case"Circle":r=$n("Circle",a);break;case"Ellipse":r=$n("Ellipse",a);break}r&&(s=new b.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[],c=[];for(var h=0;h<t.length;h++){let p=t[h],f=new b.Vector3(p.startPoint.X,0,-p.startPoint.Y),u=new b.Vector3(p.endPoint.X,0,-p.endPoint.Y),g=new b.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),y=new b.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),v=0,w=0,x=0;if(Math.abs(u.clone().sub(f.clone()).z)<.01&&Math.abs(u.clone().sub(f.clone()).x)<.01){if(v=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var d=new b.Vector3(p.base_x.X,0,-p.base_x.Y);w=(d.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else w=(u.clone().sub(f.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*u.clone().sub(f.clone()).angleTo(new b.Vector3(0,0,1)),v=(p.startPoint.Z>p.endPoint.Z?1:-1)*u.clone().sub(f.clone()).angleTo(y.clone().sub(g.clone()));let M=new b.Matrix4;const T=new b.Euler(v,w,x,"YXZ");let P=M.clone().makeRotationFromEuler(T),k,D;o==="Circle"?(k=p.diameter,D=p.diameter):(k=p.width,D=p.height);let E=M.clone().makeScale(k,D,p.length);M.multiplyMatrices(P,E),M.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(h,M.clone()),s.setColorAt(h,p.color),s.geometry.computeBoundingBox();let O=s.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),A=s.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),I=new b.Vector3(Math.min(O.x,A.x),Math.min(O.y,A.y),Math.min(O.z,A.z)),S=new b.Vector3(Math.max(O.x,A.x),Math.max(O.y,A.y),Math.max(O.z,A.z)),z=I.clone().add(S.clone()).multiplyScalar(.5),V={name:p.name,min:I,max:S,center:z,dbid:h,materialName:r.material.name},U=null,H=null;o==="Circle"&&(U={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},H={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},V.minC=U,V.maxC=H),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(M.clone()),c.push(M.clone()),s.ids.push(Number(p.id)),l.push(V)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=c;let m=[];m={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=m,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function $n(o,e,t){let n=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,o){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(r,a,l,c,h){let d=new b.ExtrudeGeometry(r,a),m=new b.MeshStandardMaterial({color:l,side:b.DoubleSide}),p=new b.Mesh(d,m);return p.position.set(c.x,c.y,c.z),p.rotation._order="YXZ",p.rotation.set(h.x,h.y,h.z),p}}function cn(o,e=!1){const t=o[0].index!==null,n=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),s={},r={},a=o[0].morphTargetsRelative,l=new _.BufferGeometry;let c=0;for(let h=0;h<o.length;++h){const d=o[h];let m=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. 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(d.attributes[p]),m++}if(m!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,p,h),c+=p}}if(t){let h=0;const d=[];for(let m=0;m<o.length;++m){const p=o[m].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+h);h+=o[m].attributes.position.count}l.setIndex(d)}for(const h in s){const d=zr(s[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in r){const d=r[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let m=0;m<d;++m){const p=[];for(let u=0;u<r[h].length;++u)p.push(r[h][u][m]);const f=zr(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}return l}function zr(o){let e,t,n,i=-1,s=0;for(let c=0;c<o.length;++c){const h=o[c];if(e===void 0&&(e=h.array.constructor),e!==h.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=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const r=new e(s),a=new _.BufferAttribute(r,t,n);let l=0;for(let c=0;c<o.length;++c){const h=o[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let m=0,p=h.count;m<p;m++)for(let f=0;f<t;f++){const u=h.getComponent(m,f);a.setComponent(m+d,f,u)}}else r.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Br(o,e){if(e===_.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===_.TriangleFanDrawMode||e===_.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)r.push(l);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,i=[];if(e===_.TriangleFanDrawMode)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Ql extends _.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new pc(t)}),this.register(function(t){return new mc(t)}),this.register(function(t){return new gc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new cc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new fc(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new yc(t)}),this.register(function(t){return new vc(t)})}load(e,t,n,i){const s=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=_.LoaderUtils.extractUrlBase(e);r=_.LoaderUtils.resolveURL(c,this.path)}else r=_.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new _.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,r,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},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 r={},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))===Or){try{r[le.KHR_BINARY_GLTF]=new wc(e)}catch(d){i&&i(d);return}s=JSON.parse(r[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 c=new Lc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,r[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const d=s.extensionsUsed[h],m=s.extensionsRequired||[];switch(d){case le.KHR_MATERIALS_UNLIT:r[d]=new nc;break;case le.KHR_DRACO_MESH_COMPRESSION:r[d]=new xc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[d]=new bc;break;case le.KHR_MESH_QUANTIZATION:r[d]=new Mc;break;default:m.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function ec(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}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 tc{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 c;const h=new _.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],_.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new _.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new _.PointLight(h),c.distance=d;break;case"spot":c=new _.SpotLight(h),c.distance=d,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,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),Qe(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),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 nc{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return _.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new _.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const r=s.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],_.LinearSRGBColorSpace),e.opacity=r[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,_.SRGBColorSpace))}return Promise.all(i)}}class ic{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 sc{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:_.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=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new _.Vector2(a,a)}return Promise.all(s)}}class rc{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:_.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 oc{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:_.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=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class ac{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:_.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 _.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,_.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class lc{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:_.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=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class cc{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:_.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=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),Promise.all(s)}}class hc{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:_.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 uc{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:_.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=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,_.SRGBColorSpace)),Promise.all(s)}}class dc{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:_.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=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(s)}}class fc{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:_.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=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(s)}}class pc{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],r=t.options.ktx2Loader;if(!r){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,r)}}class mc{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 r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,r.source,l)}}class gc{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 r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,r.source,l)}}class yc{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),r=this.parser.options.meshoptDecoder;if(!r||!r.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,c=i.byteLength||0,h=i.count,d=i.byteStride,m=new Uint8Array(a,l,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,d,m,i.mode,i.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(h*d);return r.decodeGltfBuffer(new Uint8Array(p),h,d,m,i.mode,i.filter),p})})}else return null}}class vc{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 c of i.primitives)if(c.mode!==Ve.TRIANGLES&&c.mode!==Ve.TRIANGLE_STRIP&&c.mode!==Ve.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],l={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],m=c[0].count,p=[];for(const f of d){const u=new _.Matrix4,g=new _.Vector3,y=new _.Quaternion,v=new _.Vector3(1,1,1),w=new _.InstancedMesh(f.geometry,f.material,m);for(let x=0;x<m;x++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,x),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,x),l.SCALE&&v.fromBufferAttribute(l.SCALE,x),w.setMatrixAt(x,u.compose(g,y,v));for(const x in l)if(x==="_COLOR_0"){const M=l[x];w.instanceColor=new _.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&f.geometry.setAttribute(x,l[x]);_.Object3D.prototype.copy.call(w,f),this.parser.assignFinalMaterial(w),p.push(w)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const Or="glTF",hn=12,Rr={JSON:1313821514,BIN:5130562};class wc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,hn),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!==Or)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-hn,s=new DataView(e,hn);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Rr.JSON){const c=new Uint8Array(e,hn+r,a);this.content=n.decode(c)}else if(l===Rr.BIN){const c=hn+r;this.body=e.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class xc{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,r=e.extensions[this.name].attributes,a={},l={},c={};for(const h in r){const d=Yi[h]||h.toLowerCase();a[d]=r[h]}for(const h in e.attributes){const d=Yi[h]||h.toLowerCase();if(r[h]!==void 0){const m=n.accessors[e.attributes[h]],p=Zt[m.componentType];c[d]=p.name,l[d]=m.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d,m){i.decodeDracoFile(h,function(p){for(const f in p.attributes){const u=p.attributes[f],g=l[f];g!==void 0&&(u.normalized=g)}d(p)},a,c,_.LinearSRGBColorSpace,m)})})}}class bc{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 Mc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Nr extends _.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 r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,d=(n-t)/h,m=d*d,p=m*d,f=e*c,u=f-c,g=-2*p+3*m,y=p-m,v=1-g,w=y-m+d;for(let x=0;x!==a;x++){const M=r[u+x+a],T=r[u+x+l]*h,P=r[f+x+a],k=r[f+x]*h;s[x]=v*M+w*T+g*P+y*k}return s}}const _c=new _.Quaternion;class Sc extends Nr{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return _c.fromArray(s).normalize().toArray(s),s}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Zt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Fr={9728:_.NearestFilter,9729:_.LinearFilter,9984:_.NearestMipmapNearestFilter,9985:_.LinearMipmapNearestFilter,9986:_.NearestMipmapLinearFilter,9987:_.LinearMipmapLinearFilter},Ur={33071:_.ClampToEdgeWrapping,33648:_.MirroredRepeatWrapping,10497:_.RepeatWrapping},Zi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yi={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"},pt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Cc={CUBICSPLINE:void 0,LINEAR:_.InterpolateLinear,STEP:_.InterpolateDiscrete},Ki={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ac(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new _.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_.FrontSide})),o.DefaultMaterial}function Dt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Pc(o,e,t){let n=!1,i=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;r.push(m)}if(i){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(m)}if(s){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(m)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],m=c[2];return n&&(o.morphAttributes.position=h),i&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=m),o.morphTargetsRelative=!0,o})}function Tc(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Dc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qi(t.attributes):e=o.indices+":"+qi(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+qi(o.targets[n]);return e}function qi(o){let e="";const t=Object.keys(o).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+o[t[n]]+";";return e}function $i(o){switch(o){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 kc(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ec=new _.Matrix4;class Lc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ec,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,r=-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,r=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&r<98?this.textureLoader=new _.TextureLoader(this.options.manager):this.textureLoader=new _.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _.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(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Dt(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 r=t[i].joints;for(let a=0,l=r.length;a<l;a++)e[r[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(r,a)=>{const l=this.associations.get(r);l!=null&&this.associations.set(a,l);for(const[c,h]of r.children.entries())s(h,a.children[c])};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,r){return n.getDependency(e,r)})),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,r){n.load(_.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){r(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 r=Zi[i.type],a=Zt[i.componentType],l=i.normalized===!0,c=new a(i.count*r);return Promise.resolve(new _.BufferAttribute(c,r,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(r){const a=r[0],l=Zi[i.type],c=Zt[i.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,m=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let u,g;if(p&&p!==d){const y=Math.floor(m/p),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let w=t.cache.get(v);w||(u=new c(a,y*p,i.count*p/h),w=new _.InterleavedBuffer(u,p/h),t.cache.add(v,w)),g=new _.InterleavedBufferAttribute(w,l,m%p/h,f)}else a===null?u=new c(i.count*l):u=new c(a,m,i.count*l),g=new _.BufferAttribute(u,l,f);if(i.sparse!==void 0){const y=Zi.SCALAR,v=Zt[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,M=new v(r[1],w,i.sparse.count*y),T=new c(r[2],x,i.sparse.count*l);a!==null&&(g=new _.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=M.length;P<k;P++){const D=M[P];if(g.setX(D,T[P*l]),l>=2&&g.setY(D,T[P*l+1]),l>=3&&g.setZ(D,T[P*l+2]),l>=4&&g.setW(D,T[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=f}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const l=n.manager.getHandler(r.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const m=(s.samplers||{})[r.sampler]||{};return h.magFilter=Fr[m.magFilter]||_.LinearFilter,h.minFilter=Fr[m.minFilter]||_.LinearMipmapLinearFilter,h.wrapS=Ur[m.wrapS]||_.RepeatWrapping,h.wrapT=Ur[m.wrapT]||_.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==_.NearestFilter&&h.minFilter!==_.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const r=i.images[e],a=self.URL||self.webkitURL;let l=r.uri||"",c=!1;if(r.bufferView!==void 0)l=n.getDependency("bufferView",r.bufferView).then(function(d){c=!0;const m=new Blob([d],{type:r.mimeType});return l=a.createObjectURL(m),l});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(m,p){let f=m;t.isImageBitmapLoader===!0&&(f=function(u){const g=new _.Texture(u);g.needsUpdate=!0,m(g)}),t.load(_.LoaderUtils.resolveURL(d,s.path),f,void 0,p)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),Qe(d,r),d.userData.mimeType=r.mimeType||kc(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.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(r);r=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),s.associations.set(r,l)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.PointsMaterial,_.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 _.LineBasicMaterial,_.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||r){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),r&&(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 _.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},l=s.extensions||{},c=[];if(l[le.KHR_MATERIALS_UNLIT]){const d=i[le.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),c.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new _.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;a.color.setRGB(m[0],m[1],m[2],_.LinearSRGBColorSpace),a.opacity=m[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,_.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=_.DoubleSide);const h=s.alphaMode||Ki.OPAQUE;if(h===Ki.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Ki.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==_.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new _.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&r!==_.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==_.MeshBasicMaterial){const d=s.emissiveFactor;a.emissive=new _.Color().setRGB(d[0],d[1],d[2],_.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==_.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,_.SRGBColorSpace)),Promise.all(c).then(function(){const d=new r(a);return s.name&&(d.name=s.name),Qe(d,s),t.associations.set(d,{materials:e}),s.extensions&&Dt(i,d,s),d})}createUniqueName(e){const t=_.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 Vr(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=Dc(c),d=i[h];if(d)r.push(d.promise);else{let m;c.extensions&&c.extensions[le.KHR_DRACO_MESH_COMPRESSION]?m=s(c):m=Vr(new _.BufferGeometry,c,t),i[h]={primitive:c,promise:m},r.push(m)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let l=0,c=r.length;l<c;l++){const h=r[l].material===void 0?Ac(this.cache):this.getDependency("material",r[l].material);a.push(h)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let p=0,f=h.length;p<f;p++){const u=h[p],g=r[p];let y;const v=c[p];if(g.mode===Ve.TRIANGLES||g.mode===Ve.TRIANGLE_STRIP||g.mode===Ve.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new _.SkinnedMesh(u,v):new _.Mesh(u,v),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Br(y.geometry,_.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Br(y.geometry,_.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new _.LineSegments(u,v);else if(g.mode===Ve.LINE_STRIP)y=new _.Line(u,v);else if(g.mode===Ve.LINE_LOOP)y=new _.LineLoop(u,v);else if(g.mode===Ve.POINTS)y=new _.Points(u,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Tc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&Dt(i,y,g),t.assignFinalMaterial(y),d.push(y)}for(let p=0,f=d.length;p<f;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return s.extensions&&Dt(i,d[0],s),d[0];const m=new _.Group;s.extensions&&Dt(i,m,s),t.associations.set(m,{meshes:e});for(let p=0,f=d.length;p<f;p++)m.add(d[p]);return m})}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 _.PerspectiveCamera(_.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new _.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(),r=i,a=[],l=[];for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d){a.push(d);const m=new _.Matrix4;s!==null&&m.fromArray(s.array,c*16),l.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new _.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,r=[],a=[],l=[],c=[],h=[];for(let d=0,m=i.channels.length;d<m;d++){const p=i.channels[d],f=i.samplers[p.sampler],u=p.target,g=u.node,y=i.parameters!==void 0?i.parameters[f.input]:f.input,v=i.parameters!==void 0?i.parameters[f.output]:f.output;u.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",v)),c.push(f),h.push(u))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const m=d[0],p=d[1],f=d[2],u=d[3],g=d[4],y=[];for(let w=0,x=m.length;w<x;w++){const M=m[w],T=p[w],P=f[w],k=u[w],D=g[w];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const E=n._createAnimationTracks(M,T,P,k,D);if(E)for(let O=0;O<E.length;O++)y.push(E[O])}const v=new _.AnimationClip(s,void 0,y);return Qe(v,i),v})}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 r=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),r=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)r.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(r),l]).then(function(c){const h=c[0],d=c[1],m=c[2];m!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(m,Ec)});for(let p=0,f=d.length;p<f;p++)h.add(d[p]);return h})}_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],r=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(s.isBone===!0?h=new _.Bone:c.length>1?h=new _.Group:c.length===1?h=c[0]:h=new _.Object3D,h!==c[0])for(let d=0,m=c.length;d<m;d++)h.add(c[d]);if(s.name&&(h.userData.name=s.name,h.name=r),Qe(h,s),s.extensions&&Dt(n,h,s),s.matrix!==void 0){const d=new _.Matrix4;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const d=i.associations.get(h);i.associations.set(h,{...d})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new _.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&Dt(t,s,n);const r=n.nodes||[],a=[];for(let l=0,c=r.length;l<c;l++)a.push(i.getDependency("node",r[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++)s.add(l[h]);const c=h=>{const d=new Map;for(const[m,p]of i.associations)(m instanceof _.Material||m instanceof _.Texture)&&d.set(m,p);return h.traverse(m=>{const p=i.associations.get(m);p!=null&&d.set(m,p)}),d};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];pt[s.path]===pt.weights?e.traverse(function(m){m.morphTargetInfluences&&l.push(m.name?m.name:m.uuid)}):l.push(a);let c;switch(pt[s.path]){case pt.weights:c=_.NumberKeyframeTrack;break;case pt.rotation:c=_.QuaternionKeyframeTrack;break;case pt.translation:case pt.scale:c=_.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=_.NumberKeyframeTrack;break;case 2:case 3:default:c=_.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?Cc[i.interpolation]:_.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let m=0,p=l.length;m<p;m++){const f=new c(l[m]+"."+pt[s.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),r.push(f)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=$i(t.constructor),i=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof _.QuaternionKeyframeTrack?Sc:Nr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ic(o,e,t){const n=e.attributes,i=new _.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new _.Vector3(l[0],l[1],l[2]),new _.Vector3(c[0],c[1],c[2])),a.normalized){const h=$i(Zt[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}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 _.Vector3,l=new _.Vector3;for(let c=0,h=s.length;c<h;c++){const d=s[c];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],p=m.min,f=m.max;if(p!==void 0&&f!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),m.normalized){const u=$i(Zt[m.componentType]);l.multiplyScalar(u)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new _.Sphere;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Vr(o,e,t){const n=e.attributes,i=[];function s(r,a){return t.getDependency("accessor",r).then(function(l){o.setAttribute(a,l)})}for(const r in n){const a=Yi[r]||r.toLowerCase();a in o.attributes||i.push(s(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return _.ColorManagement.workingColorSpace!==_.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${_.ColorManagement.workingColorSpace}" not supported.`),Qe(o,e),Ic(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Pc(o,e.targets,t):o})}function zc(o,e,t){let n=new b.Group;n.name=e,o.scene.add(n),Wi(e+"/info",i=>{let s=JSON.parse(i);o.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),o.models==null&&(o.models=[]),o.models.push({url:e,nodesMap:new Map,boundingBox:{min:new b.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new b.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ft.EngineFree,e)})}function Bc(o,e){o.engineStatus.models.filter(t=>e==null||t.url==e).forEach(t=>{t.loadStatus==null&&(t.loadStatus={mep:!1,instance:!1,normal:!1}),t.status==="loading"&&t.type==="light"&&(t.loadStatus.modelMep!=!0&&(t.loadStatus.modelMep=!0,Jl(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Oc(o,t))})}function Oc(o,e){if(o.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={},ql(e.url+i.path,s=>{Ir(s.get("/nodes.json"),r=>{let a=JSON.parse(r);o.models.find(h=>h.url==e.url).nodesMap==null&&(o.models.find(h=>h.url==e.url).nodesMap=new Map);let l=o.models.find(h=>h.url==e.url).nodesMap,c=0;for(let h in a){a[h].forEach(p=>{p.glb=h,l.has(p.id)==!1?l.set(p.id,{infos:[p]}):l.get(p.id).infos.push(p)});let d=new Ql;const m=new $l;m.setDecoderPath("/draco/"),m.preload(),d.setDRACOLoader(m),d.load(s.get(h+".glb"),p=>{i.glbs[h]=p.scene.children,i.glbs[h].forEach(f=>{f.geometry.computeVertexNormals()}),c++,c==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ft.EngineFree,e.url),o.viewCube.CameraGoHome())})}Ir(s.get("/instances.json"),h=>{let d=JSON.parse(h);o.models.find(m=>m.url==e.url).instanceNodes=d})})});else{let s=n(e,i,i.octreeBox),r=[],a=o.models.find(c=>c.url==e.url);s.forEach(c=>{a.nodesMap.has(c)&&a.nodesMap.get(c).infos.forEach(h=>{let d=i.glbs[h.glb][h.mesh];if(d!=null&&d.geometry!=null&&d.material!=null){let m=new b.Matrix4;m.elements=h.matrix;let p=new b.Mesh(d.geometry.clone().applyMatrix4(m),d.material),f=new b.Box3().setFromObject(p);h.box=f,h.mesh=p,p.name=c,p.glb=h.glb,p.url=e.url,d.geometry.attributes.position!=null&&r.push(p)}})}),Rc(e.url,o,r);let l=a.instanceNodes;if(l!=null)for(let c in l)(l[c].isLoaded==null||l[c].isLoaded==!1)&&(l[c].isLoaded=!0,l[c].forEach(h=>{if(i.glbs[c]!=null){let d=i.glbs[c][h.mesh];Nc(e.url,h.mesh,o,d,h.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new b.Vector3(r.min.X,r.min.Z,-r.min.Y),c=new b.Vector3(r.max.X,r.max.Z,-r.max.Y);c.distanceTo(l);let h=o.camera.position,d=new b.Vector3(l.x+c.x/2,l.y+c.y/2,l.z+c.z/2);h.distanceTo(d),r.elements.forEach(m=>{a.push(m)}),r.children.forEach(m=>{a.push(...n(i,s,m))}),r.children.findIndex(m=>m.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Rc(o,e,t){let n=[];t.forEach(i=>{n.findIndex(r=>r.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(r=>r.glb==i.glb).meshes.push(i),n.find(r=>r.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(r=>r.glb==i.glb);s.indexes.has(Number(i.name))?s.indexes.get(Number(i.name)).push([s.currentIndex-i.geometry.index.count,s.currentIndex]):s.indexes.set(Number(i.name),[[s.currentIndex-i.geometry.index.count,s.currentIndex]])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof b.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new b.BufferGeometry,a=Fc(i.meshes[0].material);r=cn(i.meshes.map(h=>h.geometry),!1);let l=new b.Mesh(r,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=o,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(h=>h.geometry);let c=e.models.find(h=>h.url==o);if(c!=null){let h=0;i.indexes.forEach(d=>{d.forEach(m=>{c.nodesMap.get(Number(i.meshes[h].name)).indexes==null&&(c.nodesMap.get(Number(i.meshes[h].name)).indexes=[]),c.nodesMap.get(Number(i.meshes[h].name)).indexes.push([l.index,h++,m[0],m[1]])})})}}})}function Nc(o,e,t,n,i){if(n==null)return;let s=new b.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)r[l*3]=1,r[l*3+1]=1,r[l*3+2]=1;s.instanceColor=new b.InstancedBufferAttribute(r,3);let a=[];for(let l=0;l<i.length;l++){let c=i[l],h=new b.Matrix4;h.elements=c.matrix,s.setMatrixAt(l,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),a.push(h.clone()),t.models.find(d=>d.url==o).nodesMap.has(c.id)?(t.models.find(d=>d.url==o).nodesMap.get(c.id).indexes==null&&(t.models.find(d=>d.url==o).nodesMap.get(c.id).indexes=[]),t.models.find(d=>d.url==o).nodesMap.get(c.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(d=>d.url==o).nodesMap.set(c.id,{instance:!0,info:c,indexes:[[t.scene.children.length-1,l,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(l=>l.id),s.matrixsClone=a}function Fc(o){return o.map!=null&&(o.map.colorSpace=b.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=b.FrontSide,o.side=o.side,o}class Uc{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&zc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class Vc{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(ft.EngineFree,e=>{this.updateFree(!0),Bc(this.engine,e)}),this.engine.events.on(ft.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let jc=class{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,r)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${r}:`,a)}})}};class Gc{engine;constructor(e){this.engine=e}init(){const e=new b.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 b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new b.AmbientLight(16777215,1);this.engine.scene.add(i)}}var Me=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.MeasureClick="measure-click",o.SectionMove="section-move",o))(Me||{});class Wc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new b.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;timeOutEvent;handleMouseMove(e){if(this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null),e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;let n=this.getCatchMeshs(e,!0);n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let n=e.catch.object,i=e.catch.object.id,s=this.engine.models.find(l=>l.url==n.url).nodesMap.get(i),r=new Map;s?.indexes.forEach(l=>{this.engine.scene.children[l[0]]instanceof b.InstancedMesh&&(r.has(l[0])?r.get(l[0])?.push(l[1]):r.set(l[0],[l[1]]))});let a=[];return r.forEach((l,c)=>{let h=this.engine.scene.children[c];l.forEach(d=>{let m=h.geometry.clone();m.applyMatrix4(h.matrixs[d]),a.push(new b.Mesh(m,h.material))})}),this.hoverOldId==i?[]:(this.hoverOldId=i,t||this.engine.hoverHighLight.clearHighlight(),a)}else{let i=e.catch.object,s=i.name,l=this.engine.models.find(c=>c.url===i.url).nodesMap.get(s).infos.map(c=>c.mesh);return this.hoverOldId==s?[]:(this.hoverOldId=s,t||this.engine.hoverHighLight.clearHighlight(),l)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(Me.Click,[{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;let i=n.object,r=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix;const l=[];r.indexes.forEach(h=>{let d=h[0],m=this.engine.scene.children[d].geometry.boundingSphere;const p=new b.Box3,f=m.center.clone().applyMatrix4(a),u=m.radius,g=new b.Vector3;g.setFromMatrixScale(a);const y=Math.max(g.x,g.y,g.z),v=u*y;p.min.set(f.x-v,f.y-v,f.z-v),p.max.set(f.x+v,f.y+v,f.z+v),l.push(p)});let c=t(l);this.engine.viewCube.zoomToModel(c)}else{const a=r.infos.map(c=>c.box);let l=t(a);this.engine.viewCube.zoomToModel(l)}}function t(n){let i=new b.Vector3(1e8,1e9,1e10),s=new b.Vector3(-1e8,-1e9,-1e10);return n.forEach(r=>{r.min.x<i.x&&(i.x=r.min.x),r.min.y<i.y&&(i.y=r.min.y),r.min.z<i.z&&(i.z=r.min.z),r.max.x>s.x&&(s.x=r.max.x),r.max.y>s.y&&(s.y=r.max.y),r.max.z>s.z&&(s.z=r.max.z)}),new b.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof b.InstancedMesh),!0)}}class Xc{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),this.hideMaterial=new b.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.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 b.InstancedMesh)return;let t=e.materialClone.clone(),n=cn(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(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.engine.scene.children[a[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[a[0]]),this.engine.scene.children[a[0]].geometry.groups[a[1]].materialIndex=1)})}),Zc(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):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(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof b.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=0})}),jr(n,this.engine,"highlightModel")})}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 r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.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&&Kc(n,this.engine);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 r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.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&&Gr(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const r=i.ids.indexOf(s);r!==-1&&i.ids.splice(r,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(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[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(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),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.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.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)})}),Yc(n,this.engine);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(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof b.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(this.split_merge_model(this.engine.scene.children[r[0]]),a.geometry.groups[r[1]].materialIndex=0)})}),n.size>0&&Gr(n,this.engine),jr(n,this.engine,"translucentModel")}),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(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=i.geometry,r=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),a=new b.InstancedMesh(s,r,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(m,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function jr(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof b.InstancedMesh))return;n.forEach(a=>{const l=s.matrixsClone[a];l&&s.setMatrixAt(a,l)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function Yc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=i.geometry,r=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),a=new b.InstancedMesh(s,r,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(m,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Kc(o,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=new Map,r=new b.Matrix4,a=new b.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,r),s.set(l,r.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Gr(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof b.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class qc{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof b.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&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}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")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof b.DirectionalLight),i={low:1024,medium:2048,high:2048}[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 Hn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);i.infos&&i.infos.length>0&&(this.tagDiv.innerHTML=i.infos[0].name);const r=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=r.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=r.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:b.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}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 r=new b.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),r.matrix.copy(s.matrixWorld),r.matrixAutoUpdate=!1,this.engine.scene.add(r),this.overlayMeshes.push(r)}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/Hn.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/Hn.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:{}},$c=Jn.exports,Wr;function Hc(){return Wr||(Wr=1,(function(o,e){(function(t,n){o.exports=n()})($c,function(){var t=function(){function n(p){return r.appendChild(p.dom),p}function i(p){for(var f=0;f<r.children.length;f++)r.children[f].style.display=f===p?"block":"none";s=p}var s=0,r=document.createElement("div");r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(p){p.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var p=(performance||Date).now();if(d.update(p-a,200),p>l+1e3&&(h.update(1e3*c/(p-l),100),l=p,c=0,m)){var f=performance.memory;m.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:r,setMode:i}};return t.Panel=function(n,i,s){var r=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,m=3*c,p=2*c,f=3*c,u=15*c,g=74*c,y=30*c,v=document.createElement("canvas");v.width=h,v.height=d,v.style.cssText="width:80px;height:48px";var w=v.getContext("2d");return w.font="bold "+9*c+"px Helvetica,Arial,sans-serif",w.textBaseline="top",w.fillStyle=s,w.fillRect(0,0,h,d),w.fillStyle=i,w.fillText(n,m,p),w.fillRect(f,u,g,y),w.fillStyle=s,w.globalAlpha=.9,w.fillRect(f,u,g,y),{dom:v,update:function(x,M){r=Math.min(r,x),a=Math.max(a,x),w.fillStyle=s,w.globalAlpha=1,w.fillRect(0,0,h,u),w.fillStyle=i,w.fillText(l(x)+" "+n+" ("+l(r)+"-"+l(a)+")",m,p),w.drawImage(v,f+c,u,g-c,y,f,u,g-c,y),w.fillRect(f+g-c,u,c,y),w.fillStyle=s,w.globalAlpha=.9,w.fillRect(f+g-c,u,c,l((1-x/M)*y))}}},t})})(Jn)),Jn.exports}var Jc=Hc();const Qc=Xs(Jc);var Yt=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-Yt.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?Yt.Bounce.In(o*2)*.5:Yt.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),un=function(){return performance.now()},eh=(function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=un()),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]],r=!t;s&&s.update(e,r)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o})(),Hi={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=Hi.Utils.Linear;return e<0?s(o[0],o[1],n):e>1?s(o[t],o[t-1],t-n):s(o[i],o[i+1>t?t:i+1],n-i)},Utils:{Linear:function(o,e,t){return(e-o)*t+o}}},Xr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),Ji=new eh,th=(function(){function o(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=Yt.Linear.None,this._interpolationFunction=Hi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Xr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.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},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=un()),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},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,n,i,s){for(var r in n){var a=e[r],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[r]);if(!(c==="undefined"||c==="function")){if(h){var d=n[r];if(d.length===0)continue;for(var m=[a],p=0,f=d.length;p<f;p+=1){var u=this._handleRelativeValue(a,d[p]);if(isNaN(u)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(u)}h&&(n[r]=m)}if((c==="object"||l)&&a&&!h){t[r]=l?[]:{};var g=a;for(var y in g)t[r][y]=g[y];i[r]=l?[]:{};var d=n[r];if(!this._isDynamic){var v={};for(var y in d)v[y]=d[y];n[r]=d=v}this._setupProperties(g,t[r],d,i[r],s)}else(typeof t[r]>"u"||s)&&(t[r]=a),l||(t[r]*=1),h?i[r]=n[r].slice().reverse():i[r]=t[r]||0}}},o.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},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=un()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=un()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=Ji),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=Yt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Hi.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=un()),t===void 0&&(t=!0),this._isPaused)return!0;var s,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)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),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var g=Math.trunc(a/l),y=a-g*l,v=Math.min(y/n._duration,1);return v===0&&a===n._duration?1:v},d=h(),m=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),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 f=0,u=this._chainedTweens.length;f<u;f++)this._chainedTweens[f].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var r=t[s]||0,a=n[s],l=Array.isArray(e[s]),c=Array.isArray(a),h=!l&&c;h?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],r,a,i):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(e[s]=r+(a-r)*i))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.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},o})();Xr.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 dn={Easing:Yt,Tween:th};class nh extends _.DataTextureLoader{constructor(e){super(e),this.type=_.HalfFloatType}parse(e){const r=function(k,D){switch(k){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(D||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(D||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(D||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(D||""))}},d=function(k,D,E){D=D||1024;let A=k.pos,I=-1,S=0,z="",V=String.fromCharCode.apply(null,new Uint16Array(k.subarray(A,A+128)));for(;0>(I=V.indexOf(`
968
968
  `))&&S<D&&A<k.byteLength;)z+=V,S+=V.length,A+=128,V+=String.fromCharCode.apply(null,new Uint16Array(k.subarray(A,A+128)));return-1<I?(k.pos+=S+I+1,z+V.slice(0,I)):!1},m=function(k){const D=/^#\?(\S+)/,E=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,O=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,A=/^\s*FORMAT=(\S+)\s*$/,I=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,S={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let z,V;for((k.pos>=k.byteLength||!(z=d(k)))&&r(1,"no header found"),(V=z.match(D))||r(3,"bad initial token"),S.valid|=1,S.programtype=V[1],S.string+=z+`
969
969
  `;z=d(k),z!==!1;){if(S.string+=z+`
970
970
  `,z.charAt(0)==="#"){S.comments+=z+`
971
- `;continue}if((V=z.match(E))&&(S.gamma=parseFloat(V[1])),(V=z.match(O))&&(S.exposure=parseFloat(V[1])),(V=z.match(A))&&(S.valid|=2,S.format=V[1]),(V=z.match(I))&&(S.valid|=4,S.height=parseInt(V[1],10),S.width=parseInt(V[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2||r(3,"missing format specifier"),S.valid&4||r(3,"missing image size specifier"),S},p=function(k,D,E){const O=D;if(O<8||O>32767||k[0]!==2||k[1]!==2||k[2]&128)return new Uint8Array(k);O!==(k[2]<<8|k[3])&&r(3,"wrong scanline width");const A=new Uint8Array(4*D*E);A.length||r(4,"unable to allocate buffer space");let I=0,S=0;const z=4*O,V=new Uint8Array(4),U=new Uint8Array(z);let H=E;for(;H>0&&S<k.byteLength;){S+4>k.byteLength&&r(1),V[0]=k[S++],V[1]=k[S++],V[2]=k[S++],V[3]=k[S++],(V[0]!=2||V[1]!=2||(V[2]<<8|V[3])!=O)&&r(3,"bad rgbe scanline format");let G=0,$;for(;G<z&&S<k.byteLength;){$=k[S++];const R=$>128;if(R&&($-=128),($===0||G+$>z)&&r(3,"bad scanline data"),R){const te=k[S++];for(let ee=0;ee<$;ee++)U[G++]=te}else U.set(k.subarray(S,S+$),G),G+=$,S+=$}const F=O;for(let R=0;R<F;R++){let te=0;A[I]=U[R+te],te+=O,A[I+1]=U[R+te],te+=O,A[I+2]=U[R+te],te+=O,A[I+3]=U[R+te],I+=4}H--}return A},f=function(k,D,E,O){const A=k[D+3],I=Math.pow(2,A-128)/255;E[O+0]=k[D+0]*I,E[O+1]=k[D+1]*I,E[O+2]=k[D+2]*I,E[O+3]=1},u=function(k,D,E,O){const A=k[D+3],I=Math.pow(2,A-128)/255;E[O+0]=_.DataUtils.toHalfFloat(Math.min(k[D+0]*I,65504)),E[O+1]=_.DataUtils.toHalfFloat(Math.min(k[D+1]*I,65504)),E[O+2]=_.DataUtils.toHalfFloat(Math.min(k[D+2]*I,65504)),E[O+3]=_.DataUtils.toHalfFloat(1)},g=new Uint8Array(e);g.pos=0;const y=m(g),v=y.width,w=y.height,x=p(g.subarray(g.pos),v,w);let M,T,P;switch(this.type){case _.FloatType:P=x.length/4;const k=new Float32Array(P*4);for(let E=0;E<P;E++)f(x,E*4,k,E*4);M=k,T=_.FloatType;break;case _.HalfFloatType:P=x.length/4;const D=new Uint16Array(P*4);for(let E=0;E<P;E++)u(x,E*4,D,E*4);M=D,T=_.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:v,height:w,data:M,header:y.string,gamma:y.gamma,exposure:y.exposure,type:T}}setDataType(e){return this.type=e,this}load(e,t,n,i){function s(r,a){switch(r.type){case _.FloatType:case _.HalfFloatType:r.colorSpace=_.LinearSRGBColorSpace,r.minFilter=_.LinearFilter,r.magFilter=_.LinearFilter,r.generateMipmaps=!1,r.flipY=!0;break}t&&t(r,a)}return super.load(e,s,n,i)}}function ih(){return new b.Scene}function sh(o,e){o.appendChild(e.domElement)}function rh(o,e,t){var n=new Object;n.visible=!0;let i=null,s,r,a=[];n.init=function(){s||(h(),c(),d())},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 f=new b.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(f.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(f){var u=new b.Vector3(0,0,0);f=="top"?u=new b.Vector3(0,1,1e-5):f=="down"?u=new b.Vector3(0,-1,1e-5):f=="front"?u=new b.Vector3(0,0,1):f=="left"?u=new b.Vector3(-1,0,0):f=="back"?u=new b.Vector3(0,0,-1):f=="right"?u=new b.Vector3(1,0,0):f=="top_front"?u=new b.Vector3(1,1,0):f=="top_left"?u=new b.Vector3(0,1,-1):f=="top_back"?u=new b.Vector3(-1,1,0):f=="top_right"?u=new b.Vector3(0,1,1):f=="down_front"?u=new b.Vector3(1,-1,0):f=="down_left"?u=new b.Vector3(0,-1,-1):f=="down_back"?u=new b.Vector3(-1,-1,0):f=="down_right"?u=new b.Vector3(0,-1,1):f=="front_right"?u=new b.Vector3(1,0,1):f=="right_back"?u=new b.Vector3(-1,0,1):f=="back_left"?u=new b.Vector3(-1,0,-1):f=="left_front"?u=new b.Vector3(1,0,-1):f=="top_left_front"?u=new b.Vector3(1,1,-1):f=="top_front_right"?u=new b.Vector3(1,1,1):f=="top_right_back"?u=new b.Vector3(-1,1,1):f=="top_back_left"?u=new b.Vector3(-1,1,-1):f=="button_left_front"?u=new b.Vector3(1,-1,-1):f=="button_front_right"?u=new b.Vector3(1,-1,1):f=="button_right_back"?u=new b.Vector3(-1,1,1):f=="button_back_left"&&(u=new b.Vector3(-1,-1,-1));var g=o.octreeBox.getBoundingBox(),y=g.min,v=g.max,w=y.clone().add(v.clone()).multiplyScalar(.5),x=w.clone().add(u.multiplyScalar(1*v.distanceTo(y)));l(e.camera.position,x,o.controls.target.clone(),w)},n.GetCameraPose=function(){var f=e.camera.quaternion,u=e.camera.position,g=o.controls.target,y={quaternion:f,position:u,target:g};return y},n.ReductionCameraPose=function(f,u=1e3,g){var y=new b.Quaternion(f.quaternion._x,f.quaternion._y,f.quaternion._z,f.quaternion._w),v=new b.Vector3(f.position.x,f.position.y,f.position.z),w=new b.Vector3(f.target.x,f.target.y,f.target.z);let x=!1;l(e.camera.position,v,o.controls.target.clone(),w,e.camera.quaternion,y,u,M=>{g&&(x||(g(M),x=!0))}),g&&setTimeout(()=>{x||(g(!0),x=!0)},u+10)},n.CameraGoHome=function(){var f=o.octreeBox.getBoundingBox(),u=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let g=new b.Vector3(1,1,1);var y=f.max.distanceTo(f.min),v=u.clone().add(g.multiplyScalar(y*.5));if(e.camera.isOrthographicCamera){var w=o.container.clientWidth/o.container.clientHeight,x=y*.6;e.camera.left=-x*w,e.camera.right=x*w,e.camera.top=x,e.camera.bottom=-x,e.camera.zoom=1,e.camera.updateProjectionMatrix()}o.controlModule.orbitControls.origin=u.clone(),l(e.camera.position,v,o.controls.target.clone(),u)},n.zoomToBox=function(f){if(e.camera.isOrthographicCamera){let R=function(){i=requestAnimationFrame(R),F.update()};var u=f.min.clone().add(f.max.clone()).multiplyScalar(.5),g=e.camera.position.clone().sub(o.controls.target.clone()).normalize(),y=e.camera.position.distanceTo(o.controls.target),v=u.clone().add(g.multiplyScalar(y)),w=e.camera.zoom,x=new b.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),M=new b.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new b.Vector3(f.min.x,f.min.y,f.min.z),new b.Vector3(f.max.x,f.min.y,f.min.z),new b.Vector3(f.min.x,f.max.y,f.min.z),new b.Vector3(f.max.x,f.max.y,f.min.z),new b.Vector3(f.min.x,f.min.y,f.max.z),new b.Vector3(f.max.x,f.min.y,f.max.z),new b.Vector3(f.min.x,f.max.y,f.max.z),new b.Vector3(f.max.x,f.max.y,f.max.z)],P=1/0,k=-1/0,D=1/0,E=-1/0;for(var O of T){var A=O.dot(x),I=O.dot(M);P=Math.min(P,A),k=Math.max(k,A),D=Math.min(D,I),E=Math.max(E,I)}var S=(k-P)/2,z=(E-D)/2,V=(e.camera.right-e.camera.left)/2,U=(e.camera.top-e.camera.bottom)/2;w=Math.min(V/S,U/z)*.75;var H=e.camera.position.clone(),G=o.controls.target.clone(),$=e.camera.zoom,F=new un.Tween({x1:H.x,y1:H.y,z1:H.z,x2:G.x,y2:G.y,z2:G.z,zoom:$}).to({x1:v.x,y1:v.y,z1:v.z,x2:u.x,y2:u.y,z2:u.z,zoom:w},1e3);F.onUpdate(function(te){o.controls&&(e.camera.position.set(te.x1,te.y1,te.z1),o.controls.target.set(te.x2,te.y2,te.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=te.zoom,e.camera.updateProjectionMatrix()),o.controls.auto=!0,o.controls.update(),n.RenderScene())}),F.onComplete(function(){o.controls&&(o.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),F.easing(un.Easing.Cubic.InOut),F.start(),R()}else{var u=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let ee=e.camera.position.clone().sub(o.controls.target.clone()).normalize();var v=u.clone().add(ee.multiplyScalar(2*f.max.distanceTo(f.min)));l(e.camera.position,v,o.controls.target.clone(),u)}};function l(f,u,g,y,v,w,x=1e3,M){var T;v&&w?(T=new un.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z,_x:v._x,_y:v._y,_z:v._z,_w:v._w}),T.to({x1:u.x,y1:u.y,z1:u.z,x2:y.x,y2:y.y,z2:y.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w},x)):(T=new un.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z}),T.to({x1:u.x,y1:u.y,z1:u.z,x2:y.x,y2:y.y,z2:y.z},x)),T.onUpdate(function(k){o.controls&&(v&&w?(e.camera.quaternion._x=k._x,e.camera.quaternion._y=k._y,e.camera.quaternion._z=k._z,e.camera.quaternion._w=k._w):o.controls.auto=!0,e.camera.position.x=k.x1,e.camera.position.y=k.y1,e.camera.position.z=k.z1,o.controls.target.x=k.x2,o.controls.target.y=k.y2,o.controls.target.z=k.z2,o.controls.update(),n.RenderScene())}),T.onComplete(function(k){o.controls&&(o.controls.auto=!1,n.RenderScene(),M&&M(!0),cancelAnimationFrame(i),i=null)}),T.easing(un.Easing.Cubic.InOut);function P(k){i=requestAnimationFrame(P),T.update()}T.start(),P()}function h(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),r=document.createElement("div"),r.className="viewSettingWrapper",r.innerHTML="...",s.appendChild(r);var f=document.createElement("div");f.className="homeViewWrapper",f.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(f);const u=document.createElement("div");u.className="cameraToggleWrapper",u.title="切换正交/透视视图",u.innerHTML="⊞",u.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),v()}),s.appendChild(u);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("截图"),n.TakeScreenshot(),v()}),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(),v()}),s.appendChild(y),r.addEventListener("mousedown",function(x){x.stopPropagation(),u.classList.contains("show")?(v(),console.log("隐藏功能按钮")):(w(),console.log("显示功能按钮"))});function v(){u.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function w(){u.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function c(){n.sceneOrtho=ih();var g=t.clientWidth,y=t.clientWidth,f=g>y?g/y:y/g,u=300;n.camera=new b.OrthographicCamera(u*f/-2,u*f/2,u/2,u/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,v=new b.WebGLRenderer({alpha:!0});v.setSize(g,y),v.setClearAlpha(0),n.sceneOrtho.renderer=v;let w=new b.AmbientLight(16777215,.8);n.sceneOrtho.add(w),sh(s,v)}function d(){const f="/assets/viewcube/";let u=[{label:"右",icon:f+"cn_right.png"},{label:"左",icon:f+"cn_left.png"},{label:"顶",icon:f+"cn_top.png"},{label:"底",icon:f+"cn_bottom.png"},{label:"前",icon:f+"cn_front.png"},{label:"后",icon:f+"cn_back.png"}];var g=[];for(const v of u)g.push(new b.MeshBasicMaterial({color:16777215,map:new b.TextureLoader().load(v.icon)}));new b.MeshLambertMaterial({color:255});var y=new b.Mesh(new b.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),m(122),s.addEventListener("mousedown",v=>{var w={};w.x=v.offsetX/s.clientWidth*2-1,w.y=-(v.offsetY/s.clientHeight)*2+1;var x=new b.Raycaster;x.setFromCamera(w,n.camera);const M=x.intersectObjects(a,!1);M.length>0&&n.ToggleDirectionView(M[0].object.name)}),s.addEventListener("mousemove",v=>{var w={};w.x=v.offsetX/s.clientWidth*2-1,w.y=-(v.offsetY/s.clientHeight)*2+1;var x=new b.Raycaster;x.setFromCamera(w,n.camera);const M=x.intersectObjects(a,!1);for(var T of a)T.material.opacity=.01;M.length>0&&(M[0].object.material.opacity=.2)})}function m(f){for(var u=f*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new b.Vector3(u,0,0)},{name:"back",a:75,b:75,c:30,point:new b.Vector3(0,0,-u)},{name:"left",a:30,b:75,c:75,point:new b.Vector3(-u,0,0)},{name:"front",a:75,b:75,c:30,point:new b.Vector3(0,0,u)},{name:"top",a:75,b:30,c:75,point:new b.Vector3(0,u,0)},{name:"button",a:75,b:30,c:75,point:new b.Vector3(0,-u,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new b.Vector3(-u,u,u)},{name:"button_front_right",a:30,b:30,c:30,point:new b.Vector3(-u,-u,u)},{name:"top_front_right",a:30,b:30,c:30,point:new b.Vector3(u,u,u)},{name:"button_right_back",a:30,b:30,c:30,point:new b.Vector3(u,-u,u)},{name:"top_back_left",a:30,b:30,c:30,point:new b.Vector3(-u,u,-u)},{name:"button_back_left",a:30,b:30,c:30,point:new b.Vector3(-u,-u,-u)},{name:"top_left_front",a:30,b:30,c:30,point:new b.Vector3(u,u,-u)},{name:"button_left_front",a:30,b:30,c:30,point:new b.Vector3(u,-u,-u)}],v=[{name:"top_front",a:30,b:30,c:75,point:new b.Vector3(u,u,0)},{name:"top_right",a:75,b:30,c:30,point:new b.Vector3(0,u,u)},{name:"top_back",a:30,b:30,c:75,point:new b.Vector3(-u,u,0)},{name:"top_left",a:75,b:30,c:30,point:new b.Vector3(0,u,-u)},{name:"button_front",a:30,b:30,c:75,point:new b.Vector3(u,-u,0)},{name:"button_right",a:75,b:30,c:30,point:new b.Vector3(0,-u,u)},{name:"button_back",a:30,b:30,c:75,point:new b.Vector3(-u,-u,0)},{name:"button_left",a:75,b:30,c:30,point:new b.Vector3(0,-u,-u)},{name:"front_right",a:30,b:75,c:30,point:new b.Vector3(u,0,u)},{name:"right_back",a:30,b:75,c:30,point:new b.Vector3(-u,0,u)},{name:"back_left",a:30,b:75,c:30,point:new b.Vector3(-u,0,-u)},{name:"left_front",a:30,b:75,c:30,point:new b.Vector3(u,0,-u)}],w=0;w<g.length;w++)a.push(p(g[w]));for(var w=0;w<y.length;w++)a.push(p(y[w]));for(var w=0;w<v.length;w++)a.push(p(v[w]))}function p(f){const u=new b.BoxGeometry(f.a,f.b,f.c),g=new b.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new b.Matrix4().makeTranslation(f.point.x,f.point.y,f.point.z);let v=u.applyMatrix4(y),w=new b.Mesh(v,g);return w.name=f.name,n.sceneOrtho.add(w),w}return n.ToggleCameraType=function(){o.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!o.renderer){console.error("渲染器未初始化");return}o.renderer.render(e,e.camera);const u=o.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=u,g.click(),console.log("截图已保存")}catch(f){console.error("截图失败:",f)}},n.ToggleFullscreen=function(){const f=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(f.requestFullscreen?f.requestFullscreen():f.webkitRequestFullscreen?f.webkitRequestFullscreen():f.mozRequestFullScreen?f.mozRequestFullScreen():f.msRequestFullscreen&&f.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class oh{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=rh(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function ah(o){let e=new Object;return e.getBoundingBox=function(){let t=o.models,n=new b.Vector3(1e8,1e9,1e10),i=new b.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let m=d.boundingBox.min,p=d.boundingBox.max;m.x<n.x&&(n.x=m.x),m.y<n.y&&(n.y=m.y),m.z<n.z&&(n.z=m.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),r=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 b.Vector3(s,r,a),max:new b.Vector3(l,h,c)}},e.rayInterationModel=function(t){let n=[];return o.engineStatus.models.forEach(r=>{r.info.lods.forEach(a=>{let l=a.octreeBox;s(t,l,r)})}),n=n.filter(r=>r instanceof b.Mesh),t.intersectObjects(n,!1);function s(r,a,l){if(a==null)return;let h=new b.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),c=new b.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),d=new b.Vector3(Math.min(h.x,c.X),Math.min(h.y,c.y),Math.min(h.z,c.z)),m=new b.Vector3(Math.max(c.x,h.x),Math.max(c.y,h.y),Math.max(c.z,h.z)),p=new b.Box3(d,m),f=r.ray.intersectsBox(p);if(!(f==null||f==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var u of a.elements){let g=o.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(u))continue;let y=o.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(y!=null&&y.includes(u))continue;let w=o.models.find(x=>x.url==l.url).nodesMap.get(u);w!=null&&!w.instance&&w.infos.map(M=>M.mesh).forEach(M=>{n.push(M)})}}else{if(a.elements!=null)for(var u of a.elements){let y=o.engineStatus.hideModels.find(M=>M.url==l.url)?.ids;if(y!=null&&y.includes(u))continue;let v=o.engineStatus.translucentModels.find(M=>M.url==l.url)?.ids;if(v!=null&&v.includes(u))continue;let x=o.models.find(M=>M.url==l.url).nodesMap.get(u);x!=null&&!x.instance&&x.infos.map(T=>T.mesh).forEach(T=>{n.push(T)})}for(let g of a.children)s(r,g,l)}}},e}class lh{engine;isDrawing=!1;startPoint=new b.Vector2;endPoint=new b.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 De(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),r=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:s},{x:i,y:s},{x:i,y:r},{x:n,y:r}];for(const c of l){const d=this.worldToScreen.screenToWorld(c.x,c.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const h=new b.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 b.Vector3;e.getCenter(i);const s=new b.Vector3;e.getSize(s);const r=Math.max(s.x,s.y,s.z);if(t instanceof b.PerspectiveCamera){const a=t.fov*(Math.PI/180),h=r/(2*Math.tan(a/2))*1.2,c=new b.Vector3;t.getWorldDirection(c);const d=i.clone().sub(t.position);c.dot(d.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 b.OrthographicCamera){const l=r*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 d=new b.Vector3;t.getWorldDirection(d);const m=r*1.5,p=i.clone().sub(d.multiplyScalar(m));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class ch{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 b.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof b.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof b.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 b.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 Re);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),r=new Re(this.engine.scene,this.engine.camera,i,s);r.output=Re.OUTPUT.Default,r.blendIntensity=.5,r.updateGtaoMaterial&&r.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,r)}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,r=new b.PlaneGeometry(n,n),a=new b.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:b.DoubleSide});this.ground=new b.Mesh(r,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 rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var e=Math.random()*16|0,t=o=="x"?e:e&3|8;return t.toString(16)})}class ot{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=Di(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(f=>{p(f)}),this.engine.measure.annotationData.elevationAnnotation.forEach(f=>{m(f)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(f=>{d(f)}),this.engine.measure.annotationData.angleAnnotation.forEach(f=>{l(f)}),this.engine.measure.annotationData.areaAnnotation.forEach(f=>{h(f)}),this.engine.measure.annotationData.slopeAnnotation.forEach(f=>{c(f)});function l(f){if(f.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">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="angle-annotation",f.container.id=f.id,f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point3),v=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;u.x+=v,u.y+=w,g.x+=v,g.y+=w,y.x+=v,y.y+=w;let x=f.container;x.getElementsByTagName("circle")[0].setAttribute("cx",u.x),x.getElementsByTagName("circle")[0].setAttribute("cy",u.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",u.x+","+u.y+" "+g.x+","+g.y),x.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let M=g.x,T=g.y-30;x.getElementsByTagName("rect")[0].setAttribute("x",M-40),x.getElementsByTagName("rect")[0].setAttribute("y",T-12.5),x.getElementsByTagName("text")[0].setAttribute("x",M),x.getElementsByTagName("text")[0].setAttribute("y",T+4),x.getElementsByTagName("text")[0].innerHTML=f.text,x.style.top="0px",x.style.left="0px"}function h(f){if(f.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(f.text,2)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="area-annotation",f.container.id=f.id,f.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}if(!f.points||f.points.length<3)return;let u=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],v=0,w=0;for(let k=0;k<f.points.length;k++){let D=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.points[k]);D.x+=u,D.y+=g,y.push(D),v+=D.x,w+=D.y}v=v/y.length,w=w/y.length;let x=y.map(k=>k.x+","+k.y).join(" "),M=f.container;M.getElementsByTagName("polygon")[0].setAttribute("points",x),M.getElementsByTagName("polyline")[0].setAttribute("points",x);let T=v,P=w;M.getElementsByTagName("rect")[0].setAttribute("x",T-40),M.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),M.getElementsByTagName("text")[0].setAttribute("x",T),M.getElementsByTagName("text")[0].setAttribute("y",P+4),M.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,2),M.style.top="0px",M.style.left="0px"}function c(f){if(f.container==null){let T=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+f.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-'+f.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">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="slope-annotation",f.container.id=f.id,f.container.innerHTML=T,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;u.x+=y,u.y+=v,g.x+=y,g.y+=v;let w=f.container;w.getElementsByTagName("polyline")[0].setAttribute("points",u.x+","+u.y+" "+g.x+","+g.y);let x=(u.x+g.x)/2,M=(u.y+g.y)/2-30;w.getElementsByTagName("rect")[0].setAttribute("x",x-50),w.getElementsByTagName("rect")[0].setAttribute("y",M-12.5),w.getElementsByTagName("text")[0].setAttribute("x",x),w.getElementsByTagName("text")[0].setAttribute("y",M+4),w.getElementsByTagName("text")[0].innerHTML=f.text,w.style.top="0px",w.style.left="0px"}function d(f){if(f.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(f.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(-f.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(f.textY,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="coordinate-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container,g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=v,u.style.top="0px",u.style.left="0px";let w=u.getElementsByTagName("circle")[0];w&&(w.setAttribute("cx",g.x),w.setAttribute("cy",g.y));let x=u.getElementsByTagName("rect"),M=u.getElementsByTagName("text"),T=-55;x[0]&&(x[0].setAttribute("x",g.x+10),x[0].setAttribute("y",g.y+10+T)),M[0]&&(M[0].setAttribute("x",g.x+10+40),M[0].setAttribute("y",g.y+10+16+T)),x[1]&&(x[1].setAttribute("x",g.x+10),x[1].setAttribute("y",g.y+10+30+T)),M[1]&&(M[1].setAttribute("x",g.x+10+40),M[1].setAttribute("y",g.y+10+46+T)),x[2]&&(x[2].setAttribute("x",g.x+10),x[2].setAttribute("y",g.y+10+60+T)),M[2]&&(M[2].setAttribute("x",g.x+10+40),M[2].setAttribute("y",g.y+10+76+T)),M[0]&&(M[0].innerHTML="X: "+e.getMeasureText(f.textX,1)),M[1]&&(M[1].innerHTML="Y: "+e.getMeasureText(-f.textZ,1)),M[2]&&(M[2].innerHTML="Z: "+e.getMeasureText(f.textY,1))}function m(f){if(f.container==null){let w=['<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(f.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("");f.container=document.createElement("div"),f.container.className="elevation-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=w,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container,g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;u.style.top=g.y+v-48+"px",u.style.left=g.x+y-16+"px",u.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1)}function p(f){if(f.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(f.text,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="normal-annotation",f.container.id=f.id,f.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container;if(f.point1==null||f.point2==null){u.style.display="none";return}else u.style.display="block";let g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),y=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),v=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=v,g.y+=w,y.x+=v,y.y+=w,u.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),u.getElementsByTagName("circle")[0].setAttribute("cx",g.x),u.getElementsByTagName("circle")[0].setAttribute("cy",g.y),u.getElementsByTagName("circle")[1].setAttribute("cx",y.x),u.getElementsByTagName("circle")[1].setAttribute("cy",y.y),u.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),u.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),u.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),u.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),u.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1),u.style.top="0px",u.style.left="0px"}}}class hh{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++){const s=e[i];if(!s)continue;typeof s.updateMatrixWorld=="function"&&s.updateMatrixWorld(!0);const r=new b.Box3().setFromObject(s);!Number.isFinite(r.min.y)||!Number.isFinite(r.max.y)||(r.min.y<t&&(t=r.min.y),r.max.y>n&&(n=r.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let s=new b.Raycaster(i.add(new b.Vector3(0,.01,0)),new b.Vector3(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const r=this.engine.octreeBox.rayInterationModel(s);if(r.length===0){t.point2=null;return}t.point1=i,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}else{let i=new b.Raycaster(e.catch.point.clone().add(new b.Vector3(0,.01,0)),new b.Vector3(0,this.catchDir==0?-1:1,0));const s=this.engine.octreeBox.rayInterationModel(i);if(s.length===0){t.point2=null;return}t.point1=n.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}}}class uh{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(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();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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(Me.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:rt(),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 dh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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(r=>r.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new b.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.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(Me.MeasureChanged,t)}}class fh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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:rt(),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(Me.MeasureChanged,t))}}class ph{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),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.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,e))}}class mh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new b.Vector3().subVectors(e,t),s=new b.Vector3().subVectors(n,t),r=i.length(),a=s.length();if(r===0||a===0)return 0;const h=i.dot(s)/(r*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(Me.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:rt(),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 gh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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:rt(),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:rt(),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(Me.MeasureChanged,e))}}class yh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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,r=Math.sqrt(i*i+s*s);if(r===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/r*100,h=Math.atan(n/r)*(180/Math.PI);return{percentage:a,angle:h,heightDiff:n,horizontalDist:r,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(Me.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:rt(),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 vh{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 hh(e),this.distanceMeasure=new uh(e),this.clearDistanceMeasure=new dh(e),this.elevationMeasure=new fh(e),this.pointMeasure=new ph(e),this.angleMeasure=new mh(e),this.areaMeasure=new gh(e),this.slopeMeasure=new yh(e),this.tools=new ot(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),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 Zr=0,wh=1,xh=2,Yr=2,Qi=1.25,Kr=1,Le=32,_e=Le/4,qr=65535,bh=Math.pow(2,-24),es=Symbol("SKIP_GENERATION");function Mh(o){return o.index?o.index.count:o.attributes.position.count}function kt(o){return Mh(o)/3}function _h(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Sh(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=_h(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function $r(o,e){const t=kt(o),n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=Math.max(0,i),a=Math.min(t,s)-r;return[{offset:Math.floor(r),count:Math.floor(a)}]}function Hr(o,e){if(!o.groups||!o.groups.length)return $r(o,e);const t=[],n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=kt(o),a=[];for(const c of o.groups){const{start:d,count:m}=c,p=d/3,f=isFinite(m)?m:r*3-d,u=(d+f)/3;p<s&&u>i&&(a.push({pos:Math.max(i,p),isStart:!0}),a.push({pos:Math.min(s,u),isStart:!1}))}a.sort((c,d)=>c.pos!==d.pos?c.pos-d.pos:c.type==="end"?-1:1);let l=0,h=null;for(const c of a){const d=c.pos;l!==0&&d!==h&&t.push({offset:h,count:d-h}),l+=c.isStart?1:-1,h=d}return t}function ts(o,e,t,n,i){let s=1/0,r=1/0,a=1/0,l=-1/0,h=-1/0,c=-1/0,d=1/0,m=1/0,p=1/0,f=-1/0,u=-1/0,g=-1/0;const y=o.offset||0;for(let v=(e-y)*6,w=(e+t-y)*6;v<w;v+=6){const x=o[v+0],M=o[v+1],T=x-M,P=x+M;T<s&&(s=T),P>l&&(l=P),x<d&&(d=x),x>f&&(f=x);const k=o[v+2],D=o[v+3],E=k-D,O=k+D;E<r&&(r=E),O>h&&(h=O),k<m&&(m=k),k>u&&(u=k);const A=o[v+4],I=o[v+5],S=A-I,z=A+I;S<a&&(a=S),z>c&&(c=z),A<p&&(p=A),A>g&&(g=A)}n[0]=s,n[1]=r,n[2]=a,n[3]=l,n[4]=h,n[5]=c,i[0]=d,i[1]=m,i[2]=p,i[3]=f,i[4]=u,i[5]=g}function Jr(o,e,t=null,n=null,i=null){const s=o.attributes.position,r=o.index?o.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 d=["getX","getY","getZ"],m=i.offset;for(let p=e,f=e+t;p<f;p++){const g=(n?n[p]:p)*3,y=(p-m)*6;let v=g+0,w=g+1,x=g+2;r&&(v=r[v],w=r[w],x=r[x]),a||(v=v*c+h,w=w*c+h,x=x*c+h);for(let M=0;M<3;M++){let T,P,k;a?(T=s[d[M]](v),P=s[d[M]](w),k=s[d[M]](x)):(T=l[v+M],P=l[w+M],k=l[x+M]);let D=T;P<D&&(D=P),k<D&&(D=k);let E=T;P>E&&(E=P),k>E&&(E=k);const O=(E-D)/2,A=M*2;i[y+A+0]=D+O,i[y+A+1]=O+(Math.abs(D)+O)*bh}}return i}function ve(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function Qr(o){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=o[n+3]-o[n];i>t&&(t=i,e=n)}return e}function eo(o,e){e.set(o)}function to(o,e,t){let n,i;for(let s=0;s<3;s++){const r=s+3;n=o[s],i=e[s],t[s]=n<i?n:i,n=o[r],i=e[r],t[r]=n>i?n:i}}function Jn(o,e,t){for(let n=0;n<3;n++){const i=e[o+2*n],s=e[o+2*n+1],r=i-s,a=i+s;r<t[n]&&(t[n]=r),a>t[n+3]&&(t[n+3]=a)}}function dn(o){const e=o[3]-o[0],t=o[4]-o[1],n=o[5]-o[2];return 2*(e*t+t*n+n*e)}const at=32,Ch=(o,e)=>o.candidate-e.candidate,mt=new Array(at).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Qn=new Float32Array(6);function Ah(o,e,t,n,i,s){let r=-1,a=0;if(s===Zr)r=Qr(e),r!==-1&&(a=(e[r]+e[r+3])/2);else if(s===wh)r=Qr(o),r!==-1&&(a=Ph(t,n,i,r));else if(s===xh){const l=dn(o);let h=Qi*i;const c=t.offset||0,d=(n-c)*6,m=(n+i-c)*6;for(let p=0;p<3;p++){const f=e[p],y=(e[p+3]-f)/at;if(i<at/4){const v=[...mt];v.length=i;let w=0;for(let M=d;M<m;M+=6,w++){const T=v[w];T.candidate=t[M+2*p],T.count=0;const{bounds:P,leftCacheBounds:k,rightCacheBounds:D}=T;for(let E=0;E<3;E++)D[E]=1/0,D[E+3]=-1/0,k[E]=1/0,k[E+3]=-1/0,P[E]=1/0,P[E+3]=-1/0;Jn(M,t,P)}v.sort(Ch);let x=i;for(let M=0;M<x;M++){const T=v[M];for(;M+1<x&&v[M+1].candidate===T.candidate;)v.splice(M+1,1),x--}for(let M=d;M<m;M+=6){const T=t[M+2*p];for(let P=0;P<x;P++){const k=v[P];T>=k.candidate?Jn(M,t,k.rightCacheBounds):(Jn(M,t,k.leftCacheBounds),k.count++)}}for(let M=0;M<x;M++){const T=v[M],P=T.count,k=i-T.count,D=T.leftCacheBounds,E=T.rightCacheBounds;let O=0;P!==0&&(O=dn(D)/l);let A=0;k!==0&&(A=dn(E)/l);const I=Kr+Qi*(O*P+A*k);I<h&&(r=p,h=I,a=T.candidate)}}else{for(let x=0;x<at;x++){const M=mt[x];M.count=0,M.candidate=f+y+x*y;const T=M.bounds;for(let P=0;P<3;P++)T[P]=1/0,T[P+3]=-1/0}for(let x=d;x<m;x+=6){let P=~~((t[x+2*p]-f)/y);P>=at&&(P=at-1);const k=mt[P];k.count++,Jn(x,t,k.bounds)}const v=mt[at-1];eo(v.bounds,v.rightCacheBounds);for(let x=at-2;x>=0;x--){const M=mt[x],T=mt[x+1];to(M.bounds,T.rightCacheBounds,M.rightCacheBounds)}let w=0;for(let x=0;x<at-1;x++){const M=mt[x],T=M.count,P=M.bounds,D=mt[x+1].rightCacheBounds;T!==0&&(w===0?eo(P,Qn):to(P,Qn,Qn)),w+=T;let E=0,O=0;w!==0&&(E=dn(Qn)/l);const A=i-w;A!==0&&(O=dn(D)/l);const I=Kr+Qi*(E*w+O*A);I<h&&(r=p,h=I,a=M.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:r,pos:a}}function Ph(o,e,t,n){let i=0;const s=o.offset;for(let r=e,a=e+t;r<a;r++)i+=o[(r-s)*6+n*2];return i/t}class ns{constructor(){this.boundingData=new Float32Array(6)}}function Th(o,e,t,n,i,s){let r=n,a=n+i-1;const l=s.pos,h=s.axis*2,c=t.offset||0;for(;;){for(;r<=a&&t[(r-c)*6+h]<l;)r++;for(;r<=a&&t[(a-c)*6+h]>=l;)a--;if(r<a){for(let d=0;d<3;d++){let m=e[r*3+d];e[r*3+d]=e[a*3+d],e[a*3+d]=m}for(let d=0;d<6;d++){const m=r-c,p=a-c,f=t[m*6+d];t[m*6+d]=t[p*6+d],t[p*6+d]=f}r++,a--}else return r}}function Dh(o,e,t,n,i,s){let r=n,a=n+i-1;const l=s.pos,h=s.axis*2,c=t.offset||0;for(;;){for(;r<=a&&t[(r-c)*6+h]<l;)r++;for(;r<=a&&t[(a-c)*6+h]>=l;)a--;if(r<a){let d=o[r];o[r]=o[a],o[a]=d;for(let m=0;m<6;m++){const p=r-c,f=a-c,u=t[p*6+m];t[p*6+m]=t[f*6+m],t[f*6+m]=u}r++,a--}else return r}}let no,ei,is,io;const kh=Math.pow(2,32);function ss(o){return"count"in o?1:1+ss(o.left)+ss(o.right)}function Eh(o,e,t){return no=new Float32Array(t),ei=new Uint32Array(t),is=new Uint16Array(t),io=new Uint8Array(t),rs(o,e)}function rs(o,e){const t=o/4,n=o/2,i="count"in e,s=e.boundingData;for(let r=0;r<6;r++)no[t+r]=s[r];if(i)return e.buffer?(io.set(new Uint8Array(e.buffer),o),o+e.buffer.byteLength):(ei[t+6]=e.offset,is[n+14]=e.count,is[n+15]=qr,o+Le);{const{left:r,right:a,splitAxis:l}=e,h=o+Le;let c=rs(h,r);const d=o/Le,p=c/Le-d;if(p>kh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return ei[t+6]=p,ei[t+7]=l,rs(c,a)}}function Lh(o,e,t){const i=(o.index?o.index.count:o.attributes.position.count)/3>2**16,s=t.reduce((c,d)=>c+d.count,0),r=i?4:2,a=e?new SharedArrayBuffer(s*r):new ArrayBuffer(s*r),l=i?new Uint32Array(a):new Uint16Array(a);let h=0;for(let c=0;c<t.length;c++){const{offset:d,count:m}=t[c];for(let p=0;p<m;p++)l[h+p]=d+p;h+=m}return l}function Ih(o,e,t,n,i){const{maxDepth:s,verbose:r,maxLeafTris:a,strategy:l,onProgress:h,indirect:c}=i,d=o._indirectBuffer,m=o.geometry,p=m.index?m.index.array:null,f=c?Dh:Th,u=kt(m),g=new Float32Array(6);let y=!1;const v=new ns;return ts(e,t,n,v.boundingData,g),x(v,t,n,g),v;function w(M){h&&h(M/u)}function x(M,T,P,k=null,D=0){if(!y&&D>=s&&(y=!0,r&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(m))),P<=a||D>=s)return w(T+P),M.offset=T,M.count=P,M;const E=Ah(M.boundingData,k,e,T,P,l);if(E.axis===-1)return w(T+P),M.offset=T,M.count=P,M;const O=f(d,p,e,T,P,E);if(O===T||O===T+P)w(T+P),M.offset=T,M.count=P;else{M.splitAxis=E.axis;const A=new ns,I=T,S=O-T;M.left=A,ts(e,I,S,A.boundingData,g),x(A,I,S,g,D+1);const z=new ns,V=O,U=P-S;M.right=z,ts(e,V,U,z.boundingData,g),x(z,V,U,g,D+1)}return M}}function zh(o,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=o.geometry;let i,s;if(e.indirect){const r=Hr(n,e.range),a=Lh(n,e.useSharedArrayBuffer,r);o._indirectBuffer=a,i=Jr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{Sh(n,e);const r=$r(n,e.range)[0];i=Jr(n,r.offset,r.count),s=Hr(n,e.range)}o._roots=s.map(r=>{const a=Ih(o,i,r.offset,r.count,e),l=ss(a),h=new t(Le*l);return Eh(0,a,h),h})}class lt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,r=e.length;s<r;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,r=t.length;s<r;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}}lt.prototype.setFromBox=(function(){const o=new _.Vector3;return function(t,n){const i=n.min,s=n.max;let r=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++){o.x=i.x*l+s.x*(1-l),o.y=i.y*h+s.y*(1-h),o.z=i.z*c+s.z*(1-c);const d=t.dot(o);r=Math.min(d,r),a=Math.max(d,a)}this.min=r,this.max=a}})();const Bh=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Vector3;return function(i,s,r){const a=i.start,l=o,h=s.start,c=e;t.subVectors(a,h),o.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const d=t.dot(c),m=c.dot(l),p=c.dot(c),f=t.dot(l),g=l.dot(l)*p-m*m;let y,v;g!==0?y=(d*m-f*p)/g:y=0,v=(d+y*m)/p,r.x=y,r.y=v}})(),os=(function(){const o=new _.Vector2,e=new _.Vector3,t=new _.Vector3;return function(i,s,r,a){Bh(i,s,o);let l=o.x,h=o.y;if(l>=0&&l<=1&&h>=0&&h<=1){i.at(l,r),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,r);return}else if(h>=0&&h<=1){l<0?i.at(0,r):i.at(1,r),s.closestPointToPoint(r,!0,a);return}else{let c;l<0?c=i.start:c=i.end;let d;h<0?d=s.start:d=s.end;const m=e,p=t;if(i.closestPointToPoint(d,!0,e),s.closestPointToPoint(c,!0,t),m.distanceToSquared(d)<=p.distanceToSquared(c)){r.copy(m),a.copy(d);return}else{r.copy(c),a.copy(p);return}}}})(),Oh=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Plane,n=new _.Line3;return function(s,r){const{radius:a,center:l}=s,{a:h,b:c,c:d}=r;if(n.start=h,n.end=c,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(n.start=h,n.end=d,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const u=r.getPlane(t);if(Math.abs(u.distanceToPoint(l))<=a){const y=u.projectPoint(l,e);if(r.containsPoint(y))return!0}return!1}})(),Rh=["x","y","z"],ct=1e-15,so=ct*ct;function je(o){return Math.abs(o)<ct}class Ge extends _.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _.Vector3),this.satBounds=new Array(4).fill().map(()=>new lt),this.points=[this.a,this.b,this.c],this.plane=new _.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new _.Line3,this.needsUpdate=!0}intersectsSphere(e){return Oh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,r=this.satBounds,a=s[0],l=r[0];this.getNormal(a),l.setFromPoints(a,i);const h=s[1],c=r[1];h.subVectors(e,t),c.setFromPoints(h,i);const d=s[2],m=r[2];d.subVectors(t,n),m.setFromPoints(d,i);const p=s[3],f=r[3];p.subVectors(n,e),f.setFromPoints(p,i);const u=h.length(),g=d.length(),y=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,u<ct?g<ct||y<ct?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ct?y<ct?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ct&&(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 o=new _.Vector3,e=new _.Vector3,t=new _.Line3;return function(i,s=null,r=null){const{start:a,end:l}=i,h=this.points;let c,d=1/0;for(let m=0;m<3;m++){const p=(m+1)%3;t.start.copy(h[m]),t.end.copy(h[p]),os(t,i,o,e),c=o.distanceToSquared(e),c<d&&(d=c,s&&s.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),c=a.distanceToSquared(o),c<d&&(d=c,s&&s.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),c=l.distanceToSquared(o),c<d&&(d=c,s&&s.copy(o),r&&r.copy(l)),Math.sqrt(d)}})(),Ge.prototype.intersectsTriangle=(function(){const o=new Ge,e=new lt,t=new lt,n=new _.Vector3,i=new _.Vector3,s=new _.Vector3,r=new _.Vector3,a=new _.Line3,l=new _.Line3,h=new _.Vector3,c=new _.Vector2,d=new _.Vector2;function m(w,x,M,T){const P=n;!w.isDegenerateIntoPoint&&!w.isDegenerateIntoSegment?P.copy(w.plane.normal):P.copy(x.plane.normal);const k=w.satBounds,D=w.satAxes;for(let A=1;A<4;A++){const I=k[A],S=D[A];if(e.setFromPoints(S,x.points),I.isSeparated(e)||(r.copy(P).cross(S),e.setFromPoints(r,w.points),t.setFromPoints(r,x.points),e.isSeparated(t)))return!1}const E=x.satBounds,O=x.satAxes;for(let A=1;A<4;A++){const I=E[A],S=O[A];if(e.setFromPoints(S,w.points),I.isSeparated(e)||(r.crossVectors(P,S),e.setFromPoints(r,w.points),t.setFromPoints(r,x.points),e.isSeparated(t)))return!1}return M&&(T||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function p(w,x,M,T,P,k,D,E,O,A,I){let S=D/(D-E);A.x=T+(P-T)*S,I.start.subVectors(x,w).multiplyScalar(S).add(w),S=D/(D-O),A.y=T+(k-T)*S,I.end.subVectors(M,w).multiplyScalar(S).add(w)}function f(w,x,M,T,P,k,D,E,O,A,I){if(P>0)p(w.c,w.a,w.b,T,x,M,O,D,E,A,I);else if(k>0)p(w.b,w.a,w.c,M,x,T,E,D,O,A,I);else if(E*O>0||D!=0)p(w.a,w.b,w.c,x,M,T,D,E,O,A,I);else if(E!=0)p(w.b,w.a,w.c,M,x,T,E,D,O,A,I);else if(O!=0)p(w.c,w.a,w.b,T,x,M,O,D,E,A,I);else return!0;return!1}function u(w,x,M,T){const P=x.degenerateSegment,k=w.plane.distanceToPoint(P.start),D=w.plane.distanceToPoint(P.end);return je(k)?je(D)?m(w,x,M,T):(M&&(M.start.copy(P.start),M.end.copy(P.start)),w.containsPoint(P.start)):je(D)?(M&&(M.start.copy(P.end),M.end.copy(P.end)),w.containsPoint(P.end)):w.plane.intersectLine(P,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),w.containsPoint(n)):!1}function g(w,x,M){const T=x.a;return je(w.plane.distanceToPoint(T))&&w.containsPoint(T)?(M&&(M.start.copy(T),M.end.copy(T)),!0):!1}function y(w,x,M){const T=w.degenerateSegment,P=x.a;return T.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<so?(M&&(M.start.copy(P),M.end.copy(P)),!0):!1}function v(w,x,M,T){if(w.isDegenerateIntoSegment)if(x.isDegenerateIntoSegment){const P=w.degenerateSegment,k=x.degenerateSegment,D=i,E=s;P.delta(D),k.delta(E);const O=n.subVectors(k.start,P.start),A=D.x*E.y-D.y*E.x;if(je(A))return!1;const I=(O.x*E.y-O.y*E.x)/A,S=-(D.x*O.y-D.y*O.x)/A;if(I<0||I>1||S<0||S>1)return!1;const z=P.start.z+D.z*I,V=k.start.z+E.z*S;return je(z-V)?(M&&(M.start.copy(P.start).addScaledVector(D,I),M.end.copy(P.start).addScaledVector(D,I)),!0):!1}else return x.isDegenerateIntoPoint?y(w,x,M):u(x,w,M,T);else{if(w.isDegenerateIntoPoint)return x.isDegenerateIntoPoint?x.a.distanceToSquared(w.a)<so?(M&&(M.start.copy(w.a),M.end.copy(w.a)),!0):!1:x.isDegenerateIntoSegment?y(x,w,M):g(x,w,M);if(x.isDegenerateIntoPoint)return g(w,x,M);if(x.isDegenerateIntoSegment)return u(w,x,M,T)}}return function(x,M=null,T=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(o.copy(x),o.update(),x=o);const P=v(this,x,M,T);if(P!==void 0)return P;const k=this.plane,D=x.plane;let E=D.distanceToPoint(this.a),O=D.distanceToPoint(this.b),A=D.distanceToPoint(this.c);je(E)&&(E=0),je(O)&&(O=0),je(A)&&(A=0);const I=E*O,S=E*A;if(I>0&&S>0)return!1;let z=k.distanceToPoint(x.a),V=k.distanceToPoint(x.b),U=k.distanceToPoint(x.c);je(z)&&(z=0),je(V)&&(V=0),je(U)&&(U=0);const H=z*V,G=z*U;if(H>0&&G>0)return!1;i.copy(k.normal),s.copy(D.normal);const $=i.cross(s);let F=0,R=Math.abs($.x);const te=Math.abs($.y);te>R&&(R=te,F=1),Math.abs($.z)>R&&(F=2);const q=Rh[F],ce=this.a[q],fe=this.b[q],se=this.c[q],oe=x.a[q],ue=x.b[q],pe=x.c[q];if(f(this,ce,fe,se,I,S,E,O,A,c,a))return m(this,x,M,T);if(f(x,oe,ue,pe,H,G,z,V,U,d,l))return m(this,x,M,T);if(c.y<c.x){const Ce=c.y;c.y=c.x,c.x=Ce,h.copy(a.start),a.start.copy(a.end),a.end.copy(h)}if(d.y<d.x){const Ce=d.y;d.y=d.x,d.x=Ce,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return c.y<d.x||d.y<c.x?!1:(M&&(d.x>c.x?M.start.copy(l.start):M.start.copy(a.start),d.y<c.y?M.end.copy(l.end):M.end.copy(a.end)),!0)}})(),Ge.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ge.prototype.distanceToTriangle=(function(){const o=new _.Vector3,e=new _.Vector3,t=["a","b","c"],n=new _.Line3,i=new _.Line3;return function(r,a=null,l=null){const h=a||l?n:null;if(this.intersectsTriangle(r,h))return(a||l)&&(a&&h.getCenter(a),l&&h.getCenter(l)),0;let c=1/0;for(let d=0;d<3;d++){let m;const p=t[d],f=r[p];this.closestPointToPoint(f,o),m=f.distanceToSquared(o),m<c&&(c=m,a&&a.copy(o),l&&l.copy(f));const u=this[p];r.closestPointToPoint(u,o),m=u.distanceToSquared(o),m<c&&(c=m,a&&a.copy(u),l&&l.copy(o))}for(let d=0;d<3;d++){const m=t[d],p=t[(d+1)%3];n.set(this[m],this[p]);for(let f=0;f<3;f++){const u=t[f],g=t[(f+1)%3];i.set(r[u],r[g]),os(n,i,o,e);const y=o.distanceToSquared(e);y<c&&(c=y,a&&a.copy(o),l&&l.copy(e))}}return Math.sqrt(c)}})();class Ie{constructor(e,t,n){this.isOrientedBox=!0,this.min=new _.Vector3,this.max=new _.Vector3,this.matrix=new _.Matrix4,this.invMatrix=new _.Matrix4,this.points=new Array(8).fill().map(()=>new _.Vector3),this.satAxes=new Array(3).fill().map(()=>new _.Vector3),this.satBounds=new Array(3).fill().map(()=>new lt),this.alignedSatBounds=new Array(3).fill().map(()=>new lt),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}}Ie.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 d=0;d<=1;d++){const m=1*h|2*c|4*d,p=i[m];p.x=h?n.x:t.x,p.y=c?n.y:t.y,p.z=d?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,r=this.satAxes,a=i[0];for(let h=0;h<3;h++){const c=r[h],d=s[h],m=1<<h,p=i[m];c.subVectors(a,p),d.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}})(),Ie.prototype.intersectsBox=(function(){const o=new lt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=n.x,o.max=i.x,a[0].isSeparated(o)||(o.min=n.y,o.max=i.y,a[1].isSeparated(o))||(o.min=n.z,o.max=i.z,a[2].isSeparated(o)))return!1;for(let l=0;l<3;l++){const h=r[l],c=s[l];if(o.setFromBox(h,t),c.isSeparated(o))return!1}return!0}})(),Ie.prototype.intersectsTriangle=(function(){const o=new Ge,e=new Array(3),t=new lt,n=new lt,i=new _.Vector3;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let m=0;m<3;m++){const p=a[m],f=l[m];if(t.setFromPoints(f,e),p.isSeparated(t))return!1}const h=r.satBounds,c=r.satAxes,d=this.points;for(let m=0;m<3;m++){const p=h[m],f=c[m];if(t.setFromPoints(f,d),p.isSeparated(t))return!1}for(let m=0;m<3;m++){const p=l[m];for(let f=0;f<4;f++){const u=c[f];if(i.crossVectors(p,u),t.setFromPoints(i,e),n.setFromPoints(i,d),t.isSeparated(n))return!1}}return!0}})(),Ie.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}})(),Ie.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ie.prototype.distanceToBox=(function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new _.Line3),t=new Array(12).fill().map(()=>new _.Line3),n=new _.Vector3,i=new _.Vector3;return function(r,a=0,l=null,h=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||h)&&(r.getCenter(i),this.closestPointToPoint(i,n),r.closestPointToPoint(n,i),l&&l.copy(n),h&&h.copy(i)),0;const c=a*a,d=r.min,m=r.max,p=this.points;let f=1/0;for(let g=0;g<8;g++){const y=p[g];i.copy(y).clamp(d,m);const v=y.distanceToSquared(i);if(v<f&&(f=v,l&&l.copy(y),h&&h.copy(i),v<c))return Math.sqrt(v)}let u=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){const w=(g+1)%3,x=(g+2)%3,M=y<<w|v<<x,T=1<<g|y<<w|v<<x,P=p[M],k=p[T];e[u].set(P,k);const E=o[g],O=o[w],A=o[x],I=t[u],S=I.start,z=I.end;S[E]=d[E],S[O]=y?d[O]:m[O],S[A]=v?d[A]:m[O],z[E]=m[E],z[O]=y?d[O]:m[O],z[A]=v?d[A]:m[O],u++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?m.x:d.x,i.y=y?m.y:d.y,i.z=v?m.z:d.z,this.closestPointToPoint(i,n);const w=i.distanceToSquared(n);if(w<f&&(f=w,l&&l.copy(n),h&&h.copy(i),w<c))return Math.sqrt(w)}for(let g=0;g<12;g++){const y=e[g];for(let v=0;v<12;v++){const w=t[v];os(y,w,n,i);const x=n.distanceToSquared(i);if(x<f&&(f=x,l&&l.copy(n),h&&h.copy(i),x<c))return Math.sqrt(x)}}return Math.sqrt(f)}})();class as{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 Nh extends as{constructor(){super(()=>new Ge)}}const We=new Nh;function Se(o,e){return e[o+15]===qr}function Ue(o,e){return e[o+6]}function Xe(o,e){return e[o+14]}function Pe(o){return o+_e}function Te(o,e){const t=e[o+6];return o+t*_e}function ls(o,e){return e[o+7]}function qf(o){return o}class Fh{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 Fh;let gt,Kt;const qt=[],ti=new as(()=>new _.Box3);function Uh(o,e,t,n,i,s){gt=ti.getPrimitive(),Kt=ti.getPrimitive(),qt.push(gt,Kt),me.setBuffer(o._roots[e]);const r=cs(0,o.geometry,t,n,i,s);me.clearBuffer(),ti.releasePrimitive(gt),ti.releasePrimitive(Kt),qt.pop(),qt.pop();const a=qt.length;return a>0&&(Kt=qt[a-1],gt=qt[a-2]),r}function cs(o,e,t,n,i=null,s=0,r=0){const{float32Array:a,uint16Array:l,uint32Array:h}=me;let c=o*2;if(Se(c,l)){const m=Ue(o,h),p=Xe(c,l);return ve(o,a,gt),n(m,p,!1,r,s+o/_e,gt)}else{let E=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Se(z,I);)A=Pe(A),z=A*2;return Ue(A,S)},O=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Se(z,I);)A=Te(A,S),z=A*2;return Ue(A,S)+Xe(z,I)};const m=Pe(o),p=Te(o,h);let f=m,u=p,g,y,v,w;if(i&&(v=gt,w=Kt,ve(f,a,v),ve(u,a,w),g=i(v),y=i(w),y<g)){f=p,u=m;const A=g;g=y,y=A,v=w}v||(v=gt,ve(f,a,v));const x=Se(f*2,l),M=t(v,x,g,r+1,s+f/_e);let T;if(M===Yr){const A=E(f),S=O(f)-A;T=n(A,S,!0,r+1,s+f/_e,v)}else T=M&&cs(f,e,t,n,i,s,r+1);if(T)return!0;w=Kt,ve(u,a,w);const P=Se(u*2,l),k=t(w,P,y,r+1,s+u/_e);let D;if(k===Yr){const A=E(u),S=O(u)-A;D=n(A,S,!0,r+1,s+u/_e,w)}else D=k&&cs(u,e,t,n,i,s,r+1);return!!D}}const fn=new _.Vector3,hs=new _.Vector3;function Vh(o,e,t={},n=0,i=1/0){const s=n*n,r=i*i;let a=1/0,l=null;if(o.shapecast({boundsTraverseOrder:c=>(fn.copy(e).clamp(c.min,c.max),fn.distanceToSquared(e)),intersectsBounds:(c,d,m)=>m<a&&m<r,intersectsTriangle:(c,d)=>{c.closestPointToPoint(e,fn);const m=e.distanceToSquared(fn);return m<a&&(hs.copy(fn),a=m,l=d),m<s}}),a===1/0)return null;const h=Math.sqrt(a);return t.point?t.point.copy(hs):t.point=hs.clone(),t.distance=h,t.faceIndex=l,t}const ni=parseInt(_.REVISION)>=169,jh=parseInt(_.REVISION)<=161,Et=new _.Vector3,Lt=new _.Vector3,It=new _.Vector3,ii=new _.Vector2,si=new _.Vector2,ri=new _.Vector2,ro=new _.Vector3,oo=new _.Vector3,ao=new _.Vector3,pn=new _.Vector3;function Gh(o,e,t,n,i,s,r,a){let l;if(s===_.BackSide?l=o.intersectTriangle(n,t,e,!0,i):l=o.intersectTriangle(e,t,n,s!==_.DoubleSide,i),l===null)return null;const h=o.origin.distanceTo(i);return h<r||h>a?null:{distance:h,point:i.clone()}}function lo(o,e,t,n,i,s,r,a,l,h,c){Et.fromBufferAttribute(e,s),Lt.fromBufferAttribute(e,r),It.fromBufferAttribute(e,a);const d=Gh(o,Et,Lt,It,pn,l,h,c);if(d){if(n){ii.fromBufferAttribute(n,s),si.fromBufferAttribute(n,r),ri.fromBufferAttribute(n,a),d.uv=new _.Vector2;const p=_.Triangle.getInterpolation(pn,Et,Lt,It,ii,si,ri,d.uv);ni||(d.uv=p)}if(i){ii.fromBufferAttribute(i,s),si.fromBufferAttribute(i,r),ri.fromBufferAttribute(i,a),d.uv1=new _.Vector2;const p=_.Triangle.getInterpolation(pn,Et,Lt,It,ii,si,ri,d.uv1);ni||(d.uv1=p),jh&&(d.uv2=d.uv1)}if(t){ro.fromBufferAttribute(t,s),oo.fromBufferAttribute(t,r),ao.fromBufferAttribute(t,a),d.normal=new _.Vector3;const p=_.Triangle.getInterpolation(pn,Et,Lt,It,ro,oo,ao,d.normal);d.normal.dot(o.direction)>0&&d.normal.multiplyScalar(-1),ni||(d.normal=p)}const m={a:s,b:r,c:a,normal:new _.Vector3,materialIndex:0};if(_.Triangle.getNormal(Et,Lt,It,m.normal),d.face=m,d.faceIndex=s,ni){const p=new _.Vector3;_.Triangle.getBarycoord(pn,Et,Lt,It,p),d.barycoord=p}}return d}function co(o){return o&&o.isMaterial?o.side:o}function oi(o,e,t,n,i,s,r){const a=n*3;let l=a+0,h=a+1,c=a+2;const{index:d,groups:m}=o;o.index&&(l=d.getX(l),h=d.getX(h),c=d.getX(c));const{position:p,normal:f,uv:u,uv1:g}=o.attributes;if(Array.isArray(e)){const y=n*3;for(let v=0,w=m.length;v<w;v++){const{start:x,count:M,materialIndex:T}=m[v];if(y>=x&&y<x+M){const P=co(e[T]),k=lo(t,p,f,u,g,l,h,c,P,s,r);if(k)if(k.faceIndex=n,k.face.materialIndex=T,i)i.push(k);else return k}}}else{const y=co(e),v=lo(t,p,f,u,g,l,h,c,y,s,r);if(v)if(v.faceIndex=n,v.face.materialIndex=0,i)i.push(v);else return v}return null}function be(o,e,t,n){const i=o.a,s=o.b,r=o.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),r.x=n.getX(h),r.y=n.getY(h),r.z=n.getZ(h)}function Wh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:h}=o;for(let c=n,d=n+i;c<d;c++)oi(l,e,t,c,s,r,a)}function Xh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let h=1/0,c=null;for(let d=n,m=n+i;d<m;d++){let p;p=oi(a,e,t,d,null,s,r),p&&p.distance<h&&(c=p,h=p.distance)}return c}function Zh(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=o,d=e+o;c<d;c++){let m;if(m=c,be(r,m*3,l,h),r.needsUpdate=!0,n(r,m,i,s))return!0}return!1}function Yh(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,r,a,l,h=0;const c=o._roots;for(let m=0,p=c.length;m<p;m++)s=c[m],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,h),h+=s.byteLength;function d(m,p,f=!1){const u=m*2;if(Se(u,a)){const g=r[m+6],y=a[u+14];let v=1/0,w=1/0,x=1/0,M=-1/0,T=-1/0,P=-1/0;for(let k=3*g,D=3*(g+y);k<D;k++){let E=n[k];const O=i.getX(E),A=i.getY(E),I=i.getZ(E);O<v&&(v=O),O>M&&(M=O),A<w&&(w=A),A>T&&(T=A),I<x&&(x=I),I>P&&(P=I)}return l[m+0]!==v||l[m+1]!==w||l[m+2]!==x||l[m+3]!==M||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=w,l[m+2]=x,l[m+3]=M,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Pe(m),y=Te(m,r);let v=f,w=!1,x=!1;if(e){if(!v){const E=g/_e+p/Le,O=y/_e+p/Le;w=e.has(E),x=e.has(O),v=!w&&!x}}else w=!0,x=!0;const M=v||w,T=v||x;let P=!1;M&&(P=d(g,p,v));let k=!1;T&&(k=d(y,p,v));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,A=y+E,I=l[O],S=l[O+3],z=l[A],V=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>V?S:V}return D}}}function yt(o,e,t,n,i){let s,r,a,l,h,c;const d=1/t.direction.x,m=1/t.direction.y,p=1/t.direction.z,f=t.origin.x,u=t.origin.y,g=t.origin.z;let y=e[o],v=e[o+3],w=e[o+1],x=e[o+3+1],M=e[o+2],T=e[o+3+2];return d>=0?(s=(y-f)*d,r=(v-f)*d):(s=(v-f)*d,r=(y-f)*d),m>=0?(a=(w-u)*m,l=(x-u)*m):(a=(x-u)*m,l=(w-u)*m),s>l||a>r||((a>s||isNaN(s))&&(s=a),(l<r||isNaN(r))&&(r=l),p>=0?(h=(M-g)*p,c=(T-g)*p):(h=(T-g)*p,c=(M-g)*p),s>c||h>r)?!1:((h>s||s!==s)&&(s=h),(c<r||r!==r)&&(r=c),s<=i&&r>=n)}function Kh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:h}=o;for(let c=n,d=n+i;c<d;c++){let m=h?h[c]:c;oi(l,e,t,m,s,r,a)}}function qh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let h=1/0,c=null;for(let d=n,m=n+i;d<m;d++){let p;p=oi(a,e,t,l?l[d]:d,null,s,r),p&&p.distance<h&&(c=p,h=p.distance)}return c}function $h(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=o,d=e+o;c<d;c++){let m;if(m=t.resolveTriangleIndex(c),be(r,m*3,l,h),r.needsUpdate=!0,n(r,m,i,s))return!0}return!1}function Hh(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),us(0,o,t,n,i,s,r),me.clearBuffer()}function us(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=o*2;if(Se(c,l)){const m=Ue(o,h),p=Xe(c,l);Wh(e,t,n,m,p,i,s,r)}else{const m=Pe(o);yt(m,a,n,s,r)&&us(m,e,t,n,i,s,r);const p=Te(o,h);yt(p,a,n,s,r)&&us(p,e,t,n,i,s,r)}}const Jh=["x","y","z"];function Qh(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=ds(0,o,t,n,i,s);return me.clearBuffer(),r}function ds(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let h=o*2;if(Se(h,a)){const d=Ue(o,l),m=Xe(h,a);return Xh(e,t,n,d,m,i,s)}else{const d=ls(o,l),m=Jh[d],f=n.direction[m]>=0;let u,g;f?(u=Pe(o),g=Te(o,l)):(u=Te(o,l),g=Pe(o));const v=yt(u,r,n,i,s)?ds(u,e,t,n,i,s):null;if(v){const M=v.point[m];if(f?M<=r[g+d]:M>=r[g+d+3])return v}const x=yt(g,r,n,i,s)?ds(g,e,t,n,i,s):null;return v&&x?v.distance<=x.distance?v:x:v||x||null}}const ai=new _.Box3,$t=new Ge,Ht=new Ge,mn=new _.Matrix4,ho=new Ie,li=new Ie;function eu(o,e,t,n){me.setBuffer(o._roots[e]);const i=fs(0,o,t,n);return me.clearBuffer(),i}function fs(o,e,t,n,i=null){const{float32Array:s,uint16Array:r,uint32Array:a}=me;let l=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),ho.set(t.boundingBox.min,t.boundingBox.max,n),i=ho),Se(l,r)){const c=e.geometry,d=c.index,m=c.attributes.position,p=t.index,f=t.attributes.position,u=Ue(o,a),g=Xe(l,r);if(mn.copy(n).invert(),t.boundsTree)return ve(o,s,li),li.matrix.copy(mn),li.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>li.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let w=u*3,x=(g+u)*3;w<x;w+=3)if(be(Ht,w,d,m),Ht.needsUpdate=!0,v.intersectsTriangle(Ht))return!0;return!1}});{const y=kt(t);for(let v=u*3,w=(g+u)*3;v<w;v+=3){be($t,v,d,m),$t.a.applyMatrix4(mn),$t.b.applyMatrix4(mn),$t.c.applyMatrix4(mn),$t.needsUpdate=!0;for(let x=0,M=y*3;x<M;x+=3)if(be(Ht,x,p,f),Ht.needsUpdate=!0,$t.intersectsTriangle(Ht))return!0}}}else{const c=Pe(o),d=Te(o,a);return ve(c,s,ai),!!(i.intersectsBox(ai)&&fs(c,e,t,n,i)||(ve(d,s,ai),i.intersectsBox(ai)&&fs(d,e,t,n,i)))}}const ci=new _.Matrix4,ps=new Ie,gn=new Ie,tu=new _.Vector3,nu=new _.Vector3,iu=new _.Vector3,su=new _.Vector3;function ru(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ps.set(e.boundingBox.min,e.boundingBox.max,t),ps.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,d=e.index,m=We.getPrimitive(),p=We.getPrimitive();let f=tu,u=nu,g=null,y=null;i&&(g=iu,y=su);let v=1/0,w=null,x=null;return ci.copy(t).invert(),gn.matrix.copy(ci),o.shapecast({boundsTraverseOrder:M=>ps.distanceToBox(M),intersectsBounds:(M,T,P)=>P<v&&P<r?(T&&(gn.min.copy(M.min),gn.max.copy(M.max),gn.needsUpdate=!0),!0):!1,intersectsRange:(M,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>gn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<v&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){be(p,3*E,d,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let A=M,I=M+T;A<I;A++){be(m,3*A,h,l),m.needsUpdate=!0;const S=m.distanceToTriangle(p,f,g);if(S<v&&(u.copy(f),y&&y.copy(g),v=S,w=A,x=E),S<s)return!0}}}});{const P=kt(e);for(let k=0,D=P;k<D;k++){be(p,3*k,d,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=M,O=M+T;E<O;E++){be(m,3*E,h,l),m.needsUpdate=!0;const A=m.distanceToTriangle(p,f,g);if(A<v&&(u.copy(f),y&&y.copy(g),v=A,w=E,x=k),A<s)return!0}}}}}),We.releasePrimitive(m),We.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(u):n.point=u.clone(),n.distance=v,n.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ci),u.applyMatrix4(ci),i.distance=u.sub(i.point).length(),i.faceIndex=x),n)}function ou(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,r,a,l,h=0;const c=o._roots;for(let m=0,p=c.length;m<p;m++)s=c[m],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,h),h+=s.byteLength;function d(m,p,f=!1){const u=m*2;if(Se(u,a)){const g=r[m+6],y=a[u+14];let v=1/0,w=1/0,x=1/0,M=-1/0,T=-1/0,P=-1/0;for(let k=g,D=g+y;k<D;k++){const E=3*o.resolveTriangleIndex(k);for(let O=0;O<3;O++){let A=E+O;A=n?n[A]:A;const I=i.getX(A),S=i.getY(A),z=i.getZ(A);I<v&&(v=I),I>M&&(M=I),S<w&&(w=S),S>T&&(T=S),z<x&&(x=z),z>P&&(P=z)}}return l[m+0]!==v||l[m+1]!==w||l[m+2]!==x||l[m+3]!==M||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=w,l[m+2]=x,l[m+3]=M,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Pe(m),y=Te(m,r);let v=f,w=!1,x=!1;if(e){if(!v){const E=g/_e+p/Le,O=y/_e+p/Le;w=e.has(E),x=e.has(O),v=!w&&!x}}else w=!0,x=!0;const M=v||w,T=v||x;let P=!1;M&&(P=d(g,p,v));let k=!1;T&&(k=d(y,p,v));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,A=y+E,I=l[O],S=l[O+3],z=l[A],V=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>V?S:V}return D}}}function au(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),ms(0,o,t,n,i,s,r),me.clearBuffer()}function ms(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=o*2;if(Se(c,l)){const m=Ue(o,h),p=Xe(c,l);Kh(e,t,n,m,p,i,s,r)}else{const m=Pe(o);yt(m,a,n,s,r)&&ms(m,e,t,n,i,s,r);const p=Te(o,h);yt(p,a,n,s,r)&&ms(p,e,t,n,i,s,r)}}const lu=["x","y","z"];function cu(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=gs(0,o,t,n,i,s);return me.clearBuffer(),r}function gs(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let h=o*2;if(Se(h,a)){const d=Ue(o,l),m=Xe(h,a);return qh(e,t,n,d,m,i,s)}else{const d=ls(o,l),m=lu[d],f=n.direction[m]>=0;let u,g;f?(u=Pe(o),g=Te(o,l)):(u=Te(o,l),g=Pe(o));const v=yt(u,r,n,i,s)?gs(u,e,t,n,i,s):null;if(v){const M=v.point[m];if(f?M<=r[g+d]:M>=r[g+d+3])return v}const x=yt(g,r,n,i,s)?gs(g,e,t,n,i,s):null;return v&&x?v.distance<=x.distance?v:x:v||x||null}}const hi=new _.Box3,Jt=new Ge,Qt=new Ge,yn=new _.Matrix4,uo=new Ie,ui=new Ie;function hu(o,e,t,n){me.setBuffer(o._roots[e]);const i=ys(0,o,t,n);return me.clearBuffer(),i}function ys(o,e,t,n,i=null){const{float32Array:s,uint16Array:r,uint32Array:a}=me;let l=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),uo.set(t.boundingBox.min,t.boundingBox.max,n),i=uo),Se(l,r)){const c=e.geometry,d=c.index,m=c.attributes.position,p=t.index,f=t.attributes.position,u=Ue(o,a),g=Xe(l,r);if(yn.copy(n).invert(),t.boundsTree)return ve(o,s,ui),ui.matrix.copy(yn),ui.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>ui.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let w=u,x=g+u;w<x;w++)if(be(Qt,3*e.resolveTriangleIndex(w),d,m),Qt.needsUpdate=!0,v.intersectsTriangle(Qt))return!0;return!1}});{const y=kt(t);for(let v=u,w=g+u;v<w;v++){const x=e.resolveTriangleIndex(v);be(Jt,3*x,d,m),Jt.a.applyMatrix4(yn),Jt.b.applyMatrix4(yn),Jt.c.applyMatrix4(yn),Jt.needsUpdate=!0;for(let M=0,T=y*3;M<T;M+=3)if(be(Qt,M,p,f),Qt.needsUpdate=!0,Jt.intersectsTriangle(Qt))return!0}}}else{const c=Pe(o),d=Te(o,a);return ve(c,s,hi),!!(i.intersectsBox(hi)&&ys(c,e,t,n,i)||(ve(d,s,hi),i.intersectsBox(hi)&&ys(d,e,t,n,i)))}}const di=new _.Matrix4,vs=new Ie,vn=new Ie,uu=new _.Vector3,du=new _.Vector3,fu=new _.Vector3,pu=new _.Vector3;function mu(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),vs.set(e.boundingBox.min,e.boundingBox.max,t),vs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,d=e.index,m=We.getPrimitive(),p=We.getPrimitive();let f=uu,u=du,g=null,y=null;i&&(g=fu,y=pu);let v=1/0,w=null,x=null;return di.copy(t).invert(),vn.matrix.copy(di),o.shapecast({boundsTraverseOrder:M=>vs.distanceToBox(M),intersectsBounds:(M,T,P)=>P<v&&P<r?(T&&(vn.min.copy(M.min),vn.max.copy(M.max),vn.needsUpdate=!0),!0):!1,intersectsRange:(M,T)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>vn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<v&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){const A=P.resolveTriangleIndex(E);be(p,3*A,d,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let I=M,S=M+T;I<S;I++){const z=o.resolveTriangleIndex(I);be(m,3*z,h,l),m.needsUpdate=!0;const V=m.distanceToTriangle(p,f,g);if(V<v&&(u.copy(f),y&&y.copy(g),v=V,w=I,x=E),V<s)return!0}}}})}else{const P=kt(e);for(let k=0,D=P;k<D;k++){be(p,3*k,d,c),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=M,O=M+T;E<O;E++){const A=o.resolveTriangleIndex(E);be(m,3*A,h,l),m.needsUpdate=!0;const I=m.distanceToTriangle(p,f,g);if(I<v&&(u.copy(f),y&&y.copy(g),v=I,w=E,x=k),I<s)return!0}}}}}),We.releasePrimitive(m),We.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(u):n.point=u.clone(),n.distance=v,n.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(di),u.applyMatrix4(di),i.distance=u.sub(i.point).length(),i.faceIndex=x),n)}function gu(){return typeof SharedArrayBuffer<"u"}const wn=new me.constructor,fi=new me.constructor,vt=new as(()=>new _.Box3),en=new _.Box3,tn=new _.Box3,ws=new _.Box3,xs=new _.Box3;let bs=!1;function yu(o,e,t,n){if(bs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bs=!0;const i=o._roots,s=e._roots;let r,a=0,l=0;const h=new _.Matrix4().copy(t).invert();for(let c=0,d=i.length;c<d;c++){wn.setBuffer(i[c]),l=0;const m=vt.getPrimitive();ve(0,wn.float32Array,m),m.applyMatrix4(h);for(let p=0,f=s.length;p<f&&(fi.setBuffer(s[p]),r=Ke(0,0,t,h,n,a,l,0,0,m),fi.clearBuffer(),l+=s[p].byteLength/Le,!r);p++);if(vt.releasePrimitive(m),wn.clearBuffer(),a+=i[c].byteLength/Le,r)break}return bs=!1,r}function Ke(o,e,t,n,i,s=0,r=0,a=0,l=0,h=null,c=!1){let d,m;c?(d=fi,m=wn):(d=wn,m=fi);const p=d.float32Array,f=d.uint32Array,u=d.uint16Array,g=m.float32Array,y=m.uint32Array,v=m.uint16Array,w=o*2,x=e*2,M=Se(w,u),T=Se(x,v);let P=!1;if(T&&M)c?P=i(Ue(e,y),Xe(e*2,v),Ue(o,f),Xe(o*2,u),l,r+e/_e,a,s+o/_e):P=i(Ue(o,f),Xe(o*2,u),Ue(e,y),Xe(e*2,v),a,s+o/_e,l,r+e/_e);else if(T){const k=vt.getPrimitive();ve(e,g,k),k.applyMatrix4(t);const D=Pe(o),E=Te(o,f);ve(D,p,en),ve(E,p,tn);const O=k.intersectsBox(en),A=k.intersectsBox(tn);P=O&&Ke(e,D,n,t,i,r,s,l,a+1,k,!c)||A&&Ke(e,E,n,t,i,r,s,l,a+1,k,!c),vt.releasePrimitive(k)}else{const k=Pe(e),D=Te(e,y);ve(k,g,ws),ve(D,g,xs);const E=h.intersectsBox(ws),O=h.intersectsBox(xs);if(E&&O)P=Ke(o,k,t,n,i,s,r,a,l+1,h,c)||Ke(o,D,t,n,i,s,r,a,l+1,h,c);else if(E)if(M)P=Ke(o,k,t,n,i,s,r,a,l+1,h,c);else{const A=vt.getPrimitive();A.copy(ws).applyMatrix4(t);const I=Pe(o),S=Te(o,f);ve(I,p,en),ve(S,p,tn);const z=A.intersectsBox(en),V=A.intersectsBox(tn);P=z&&Ke(k,I,n,t,i,r,s,l,a+1,A,!c)||V&&Ke(k,S,n,t,i,r,s,l,a+1,A,!c),vt.releasePrimitive(A)}else if(O)if(M)P=Ke(o,D,t,n,i,s,r,a,l+1,h,c);else{const A=vt.getPrimitive();A.copy(xs).applyMatrix4(t);const I=Pe(o),S=Te(o,f);ve(I,p,en),ve(S,p,tn);const z=A.intersectsBox(en),V=A.intersectsBox(tn);P=z&&Ke(D,I,n,t,i,r,s,l,a+1,A,!c)||V&&Ke(D,S,n,t,i,r,s,l,a+1,A,!c),vt.releasePrimitive(A)}}return P}const pi=new Ie,fo=new _.Box3,vu={strategy:Zr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ms{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,r=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(l=>l.slice()),a.index=r?r.array.slice():null,a.indirectBuffer=s?s.slice():null):(a.roots=i,a.index=r?r.array:null,a.indirectBuffer=s),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:r}=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 Ms(t,{...n,[es]:!0});if(a._roots=s,a._indirectBuffer=r||null,n.setIndex){const h=t.getIndex();if(h===null){const c=new _.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 d=h[c],m=new Uint32Array(d),p=new Uint16Array(d);for(let f=0,u=d.byteLength/Le;f<u;f++){const g=_e*f,y=2*g;Se(y,p)||(m[g+6]=m[g+6]/_e-f)}}}}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({...vu,[es]:!1},t),t.useSharedArrayBuffer&&!gu())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[es]||(zh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new _.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],r=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Le;for(let h=0;h<l;h++){const c=_e*h,d=2*c;Se(d,a)&&(r[c+6]+=e)}}}}refit(e=null){return(this.indirect?ou:Yh)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);r(0);function r(a,l=0){const h=a*2,c=Se(h,s);if(c){const d=i[a+6],m=s[h+14];e(l,c,new Float32Array(n,a*4,6),d,m)}else{const d=Pe(a),m=Te(a,i),p=ls(a,i);e(l,c,new Float32Array(n,a*4,6),p)||(r(d,l+1),r(m,l+1))}}}raycast(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots,r=[],a=this.indirect?au:Hh;for(let l=0,h=s.length;l<h;l++)a(this,l,t,e,r,n,i);return r}raycastFirst(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots;let r=null;const a=this.indirect?cu:Qh;for(let l=0,h=s.length;l<h;l++){const c=a(this,l,t,e,n,i);c!=null&&(r==null||c.distance<r.distance)&&(r=c)}return r}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?hu:eu;for(let r=0,a=i.length;r<a&&(n=s(this,r,e,t),!n);r++);return n}shapecast(e){const t=We.getPrimitive(),n=this.indirect?$h:Zh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const d=r;r=(m,p,f,u,g)=>d(m,p,f,u,g)?!0:n(m,p,this,a,f,u,t)}else r||(a?r=(d,m,p,f)=>n(d,m,this,a,p,f,t):r=(d,m,p)=>p);let l=!1,h=0;const c=this._roots;for(let d=0,m=c.length;d<m;d++){const p=c[d];if(l=Uh(this,d,s,r,i,h),l)break;h+=p.byteLength/Le}return We.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const r=We.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,h=this.indirect?f=>{const u=this.resolveTriangleIndex(f);be(r,u*3,a,l)}:f=>{be(r,f*3,a,l)},c=We.getPrimitive(),d=e.geometry.index,m=e.geometry.attributes.position,p=e.indirect?f=>{const u=e.resolveTriangleIndex(f);be(c,u*3,d,m)}:f=>{be(c,f*3,d,m)};if(s){const f=(u,g,y,v,w,x,M,T)=>{for(let P=y,k=y+v;P<k;P++){p(P),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let D=u,E=u+g;D<E;D++)if(h(D),r.needsUpdate=!0,s(r,c,D,P,w,x,M,T))return!0}return!1};if(i){const u=i;i=function(g,y,v,w,x,M,T,P){return u(g,y,v,w,x,M,T,P)?!0:f(g,y,v,w,x,M,T,P)}}else i=f}return yu(this,e,t,i)}intersectsBox(e,t){return pi.set(e.min,e.max,t),pi.needsUpdate=!0,this.shapecast({intersectsBounds:n=>pi.intersectsBox(n),intersectsTriangle:n=>pi.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,r=1/0){return(this.indirect?mu:ru)(this,e,t,n,i,s,r)}closestPointToPoint(e,t={},n=0,i=1/0){return Vh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ve(0,new Float32Array(n),fo),e.union(fo)}),e}}const po=1e-6,wu=po*.5,mo=Math.pow(10,-Math.log10(po)),xu=wu*mo;function tt(o){return~~(o*mo+xu)}function bu(o){return`${tt(o.x)},${tt(o.y)}`}function go(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)}`}function Mu(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)},${tt(o.w)}`}function _u(o,e,t){t.direction.subVectors(e,o).normalize();const n=o.dot(t.direction);return t.origin.copy(o).addScaledVector(t.direction,-n),t}function yo(){return typeof SharedArrayBuffer<"u"}function Su(o){if(o.buffer instanceof SharedArrayBuffer)return o;const e=o.constructor,t=o.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function Cu(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Au(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Cu(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Pu(o){return o.index?o.index.count:o.attributes.position.count}function _s(o){return Pu(o)/3}const Tu=1e-8,Du=new _.Vector3;function ku(o){return~~(o/3)}function Eu(o){return o%3}function vo(o,e){return o.start-e.start}function wo(o,e){return Du.subVectors(e,o.origin).dot(o.direction)}function Lu(o,e,t,n=Tu){o.sort(vo),e.sort(vo);for(let a=0;a<o.length;a++){const l=o[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)||o.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 d=l.end;l.end=c.start,c.start=d}else if(l.start>=c.start&&l.end>=c.end){const d=c.end;c.end=l.start,l.start=d}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),r(c)&&(e.splice(h,1),h--),r(l)){o.splice(a,1),a--;break}}}i(o),i(e);function i(a){for(let l=0;l<a.length;l++)r(a[l])&&(a.splice(l,1),l--)}function s(a,l){return Math.abs(l-a)<n}function r(a){return Math.abs(a.end-a.start)<n}}const xo=1e-5,bo=1e-4;class Iu{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(r(c,e)&&r(c,n))continue;const d=a(c,e),m=a(c,n),p=Math.min(d,m);p<i&&(i=p,s=c)}return s;function r(l,h){const c=l.origin.distanceTo(h.origin)>xo;return l.direction.angleTo(h.direction)>bo||c}function a(l,h){const c=l.origin.distanceTo(h.origin),d=l.direction.angleTo(h.direction);return c/xo+d/bo}}}const Ss=new _.Vector3,Cs=new _.Vector3,mi=new _.Ray;function zu(o,e,t){const n=o.attributes,i=o.index,s=n.position,r=new Map,a=new Map,l=Array.from(e),h=new Iu;for(let c=0,d=l.length;c<d;c++){const m=l[c],p=ku(m),f=Eu(m);let u=3*p+f,g=3*p+(f+1)%3;i&&(u=i.getX(u),g=i.getX(g)),Ss.fromBufferAttribute(s,u),Cs.fromBufferAttribute(s,g),_u(Ss,Cs,mi);let y,v=h.findClosestRay(mi);v===null&&(v=mi.clone(),h.addRay(v)),a.has(v)||a.set(v,{forward:[],reverse:[],ray:v}),y=a.get(v);let w=wo(v,Ss),x=wo(v,Cs);w>x&&([w,x]=[x,w]),mi.direction.dot(v.direction)<0?y.reverse.push({start:w,end:x,index:m}):y.forward.push({start:w,end:x,index:m})}return a.forEach(({forward:c,reverse:d},m)=>{Lu(c,d,r,t),c.length===0&&d.length===0&&a.delete(m)}),{disjointConnectivityMap:r,fragmentMap:a}}const Bu=new _.Vector2,As=new _.Vector3,Ou=new _.Vector4,Ps=["","",""];class Ru{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,r=t?w:v,a=new Map,{attributes:l}=e,h=t?Object.keys(l):null,c=e.index,d=l.position;let m=_s(e);const p=m;let f=0;n&&(f=e.drawRange.start,e.drawRange.count!==1/0&&(m=~~(e.drawRange.count/3)));let u=this.data;(!u||u.length<3*p)&&(u=new Int32Array(3*p)),u.fill(-1);let g=0,y=new Set;for(let x=f,M=m*3+f;x<M;x+=3){const T=x;for(let P=0;P<3;P++){let k=T+P;c&&(k=c.getX(k)),Ps[P]=r(k)}for(let P=0;P<3;P++){const k=(P+1)%3,D=Ps[P],E=Ps[k],O=`${E}_${D}`;if(a.has(O)){const A=T+P,I=a.get(O);u[A]=I,u[I]=A,a.delete(O),g+=2,y.delete(I)}else{const A=`${D}_${E}`,I=T+P;a.set(A,I),y.add(I)}}}if(i){const{fragmentMap:x,disjointConnectivityMap:M}=zu(e,y,s);y.clear(),x.forEach(({forward:T,reverse:P})=>{T.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=x,this.disjointConnections=M,g=m*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=u;function v(x){return As.fromBufferAttribute(d,x),go(As)}function w(x){let M="";for(let T=0,P=h.length;T<P;T++){const k=l[h[T]];let D;switch(k.itemSize){case 1:D=tt(k.getX(x));break;case 2:D=bu(Bu.fromBufferAttribute(k,x));break;case 3:D=go(As.fromBufferAttribute(k,x));break;case 4:D=Mu(Ou.fromBufferAttribute(k,x));break}M!==""&&(M+="|"),M+=D}return M}}}class gi extends _.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new _.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=yo();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=Su(s.array)}if(e.boundsTree||(Au(e,{useSharedArrayBuffer:n}),e.boundsTree=new Ms(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Ru(e)),!e.groupIndices){const i=_s(e),s=new Uint16Array(i),r=e.groups;for(let a=0,l=r.length;a<l;a++){const{start:h,count:c}=r[a];for(let d=h/3,m=(h+c)/3;d<m;d++)s[d]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Nu=1e-14,Ts=new _.Vector3,Mo=new _.Vector3,_o=new _.Vector3;function wt(o,e=Nu){Ts.subVectors(o.b,o.a),Mo.subVectors(o.c,o.a),_o.subVectors(o.b,o.c);const t=Ts.angleTo(Mo),n=Ts.angleTo(_o),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||o.a.distanceToSquared(o.b)<e||o.a.distanceToSquared(o.c)<e||o.b.distanceToSquared(o.c)<e}const Ds=1e-10,xn=1e-10,Fu=1e-10,ht=new _.Line3,we=new _.Line3,ut=new _.Vector3,ks=new _.Vector3,So=new _.Vector3,yi=new _.Plane,Es=new Ge;class Uu{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new _.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class Vu{constructor(){this.trianglePool=new Uu,this.triangles=[],this.normal=new _.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,r=e.length;s<r;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(ut).dot(i))>Ds)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(ks).normalize(),Math.abs(1-Math.abs(ks.dot(t)))<Fu){this.coplanarTriangleUsed=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];a.coplanarCount=0}const i=[e.a,e.b,e.c];for(let s=0;s<3;s++){const r=(s+1)%3,a=i[s],l=i[r];ut.subVectors(l,a).normalize(),So.crossVectors(ks,ut),yi.setFromNormalAndCoplanarPoint(So,a),this.splitByPlane(yi,e)}}else e.getPlane(yi),this.splitByPlane(yi,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;Es.copy(t),Es.needsUpdate=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];if(!Es.intersectsTriangle(a,ht,!0))continue;const{a:l,b:h,c}=a;let d=0,m=-1,p=!1,f=[],u=[];const g=[l,h,c];for(let y=0;y<3;y++){const v=(y+1)%3;ht.start.copy(g[y]),ht.end.copy(g[v]);const w=e.distanceToPoint(ht.start),x=e.distanceToPoint(ht.end);if(Math.abs(w)<xn&&Math.abs(x)<xn){p=!0;break}if(w>0?f.push(y):u.push(y),Math.abs(w)<xn)continue;let M=!!e.intersectLine(ht,ut);!M&&Math.abs(x)<xn&&(ut.copy(ht.end),M=!0),M&&!(ut.distanceTo(ht.start)<Ds)&&(ut.distanceTo(ht.end)<Ds&&(m=y),d===0?we.start.copy(ut):we.end.copy(ut),d++)}if(!p&&d===2&&we.distance()>xn)if(m!==-1){m=(m+1)%3;let y=0;y===m&&(y=(y+1)%3);let v=y+1;v===m&&(v=(v+1)%3);const w=i.getTriangle();w.a.copy(g[v]),w.b.copy(we.end),w.c.copy(we.start),wt(w)||n.push(w),a.a.copy(g[y]),a.b.copy(we.start),a.c.copy(we.end),wt(a)&&(n.splice(s,1),s--,r--)}else{const y=f.length>=2?u[0]:f[0];if(y===0){let T=we.start;we.start=we.end,we.end=T}const v=(y+1)%3,w=(y+2)%3,x=i.getTriangle(),M=i.getTriangle();g[v].distanceToSquared(we.start)<g[w].distanceToSquared(we.end)?(x.a.copy(g[v]),x.b.copy(we.start),x.c.copy(we.end),M.a.copy(g[v]),M.b.copy(g[w]),M.c.copy(we.start)):(x.a.copy(g[w]),x.b.copy(we.start),x.c.copy(we.end),M.a.copy(g[v]),M.b.copy(g[w]),M.c.copy(we.end)),a.a.copy(g[y]),a.b.copy(we.end),a.c.copy(we.start),wt(x)||n.push(x),wt(M)||n.push(M),wt(a)&&(n.splice(s,1),s--,r--)}else d===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function ju(o){return o=~~o,o+4-o%4}class Co{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=yo()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(ju(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 Gu{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 r=n[s];i+=r[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 r=n[s],a=new Co(r.type);a.itemSize=r.itemSize,a.normalized=r.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 Co(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 Ao{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 Wu=0,Xu=1,Zu=2,Po=3,Yu=4,To=5,Do=6,Ze=new _.Ray,ko=new _.Matrix4,ze=new _.Triangle,dt=new _.Vector3,Eo=new _.Vector4,Lo=new _.Vector4,Io=new _.Vector4,Ls=new _.Vector4,vi=new _.Vector4,wi=new _.Vector4,zo=new _.Line3,Is=new _.Vector3,zs=1e-8,Ku=1e-15,zt=-1,Bt=1,xi=-2,bi=2,bn=0,Ot=1,Bs=2,qu=1e-14;let Mi=null;function Bo(o){Mi=o}function Oo(o,e){o.getMidpoint(Ze.origin),o.getNormal(Ze.direction);const t=e.raycastFirst(Ze,_.DoubleSide);return!!(t&&Ze.direction.dot(t.face.normal)>0)?zt:Bt}function $u(o,e){function t(){return Math.random()-.5}o.getNormal(Is),Ze.direction.copy(Is),o.getMidpoint(Ze.origin);const n=3;let i=0,s=1/0;for(let r=0;r<n;r++){Ze.direction.x+=t()*zs,Ze.direction.y+=t()*zs,Ze.direction.z+=t()*zs,Ze.direction.multiplyScalar(-1);const a=e.raycastFirst(Ze,_.DoubleSide);if(!!(a&&Ze.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=Ku)return a.face.normal.dot(Is)>0?bi:xi;if(i/n>.5||(r-i+1)/n>.5)break}return i/n>.5?zt:Bt}function Hu(o,e){const t=new Ao,n=new Ao;return ko.copy(o.matrixWorld).invert().multiply(e.matrixWorld),o.geometry.boundsTree.bvhcast(e.geometry.boundsTree,ko,{intersectsTriangles(i,s,r,a){if(!wt(i)&&!wt(s)){let l=i.intersectsTriangle(s,zo,!0);if(!l){const h=i.plane,c=s.plane,d=h.normal,m=c.normal;d.dot(m)===1&&Math.abs(h.constant-c.constant)<qu&&(l=!0)}if(l){let h=o.geometry.boundsTree.resolveTriangleIndex(r),c=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(h,c),n.add(c,h),Mi&&(Mi.addEdge(zo),Mi.addIntersectingTriangles(r,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function Ju(o,e,t,n,i,s,r=!1){const a=t.attributes,l=t.index,h=o*3,c=l.getX(h+0),d=l.getX(h+1),m=l.getX(h+2);for(const p in s){const f=a[p],u=s[p];if(!(p in a))throw new Error(`CSG Operations: Attribute ${p} not available on geometry.`);const g=f.itemSize;p==="position"?(ze.a.fromBufferAttribute(f,c).applyMatrix4(n),ze.b.fromBufferAttribute(f,d).applyMatrix4(n),ze.c.fromBufferAttribute(f,m).applyMatrix4(n),Os(ze.a,ze.b,ze.c,e,3,u,r)):p==="normal"?(ze.a.fromBufferAttribute(f,c).applyNormalMatrix(i),ze.b.fromBufferAttribute(f,d).applyNormalMatrix(i),ze.c.fromBufferAttribute(f,m).applyNormalMatrix(i),r&&(ze.a.multiplyScalar(-1),ze.b.multiplyScalar(-1),ze.c.multiplyScalar(-1)),Os(ze.a,ze.b,ze.c,e,3,u,r,!0)):(Eo.fromBufferAttribute(f,c),Lo.fromBufferAttribute(f,d),Io.fromBufferAttribute(f,m),Os(Eo,Lo,Io,e,g,u,r))}}function Qu(o,e,t,n,i,s,r,a=!1){Rs(o,n,i,s,r,a),Rs(a?t:e,n,i,s,r,a),Rs(a?e:t,n,i,s,r,a)}function Ro(o,e,t=!1){switch(o){case Wu:if(e===Bt||e===bi&&!t)return Ot;break;case Xu:if(t){if(e===zt)return bn}else if(e===Bt||e===xi)return Ot;break;case Zu:if(t){if(e===Bt||e===xi)return Ot}else if(e===zt)return bn;break;case Yu:if(e===zt)return bn;if(e===Bt)return Ot;break;case Po:if(e===zt||e===bi&&!t)return Ot;break;case To:if(!t&&(e===Bt||e===xi))return Ot;break;case Do:if(!t&&(e===zt||e===bi))return Ot;break;default:throw new Error(`Unrecognized CSG operation enum "${o}".`)}return Bs}function Os(o,e,t,n,i,s,r=!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)};Ls.set(0,0,0,0).addScaledVector(o,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),vi.set(0,0,0,0).addScaledVector(o,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),wi.set(0,0,0,0).addScaledVector(o,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Ls.normalize(),vi.normalize(),wi.normalize()),l(Ls),r?(l(wi),l(vi)):(l(vi),l(wi))}function Rs(o,e,t,n,i,s=!1){for(const r in i){const a=e[r],l=i[r];if(!(r in e))throw new Error(`CSG Operations: Attribute ${r} no available on geometry.`);const h=a.itemSize;r==="position"?(dt.fromBufferAttribute(a,o).applyMatrix4(t),l.push(dt.x,dt.y,dt.z)):r==="normal"?(dt.fromBufferAttribute(a,o).applyNormalMatrix(n),s&&dt.multiplyScalar(-1),l.push(dt.x,dt.y,dt.z)):(l.push(a.getX(o)),h>1&&l.push(a.getY(o)),h>2&&l.push(a.getZ(o)),h>3&&l.push(a.getW(o)))}}class ed{constructor(e){this.triangle=new _.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new _.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class No{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new ed(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=[],r=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)r(e);else for(const a in n)r(a);return s}reset(){this.data={}}}class td{constructor(){this.enabled=!1,this.triangleIntersectsA=new No,this.triangleIntersectsB=new No,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:s,triangleIntersectsB:r}=this;s.addTriangleIntersection(e,t,n,i),r.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(),Bo(this))}complete(){this.enabled&&Bo(null)}}const xt=new _.Matrix4,_i=new _.Matrix3,Rt=new _.Triangle,Si=new _.Triangle,bt=new _.Triangle,Ci=new _.Triangle,qe=[],Nt=[];function nd(o){for(const e of o)return e}function id(o,e,t,n,i,s={}){const{useGroups:r=!0}=s,{aIntersections:a,bIntersections:l}=Hu(o,e),h=[];let c=null,d;return d=r?0:-1,Fo(o,e,a,t,!1,n,i,d),Uo(o,e,a,t,!1,i,d),t.findIndex(p=>p!==Do&&p!==To)!==-1&&(d=r?o.geometry.groups.length||1:-1,Fo(e,o,l,t,!0,n,i,d),Uo(e,o,l,t,!0,i,d)),qe.length=0,Nt.length=0,{groups:h,materials:c}}function Fo(o,e,t,n,i,s,r,a=0){const l=o.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),_i.getNormalMatrix(o.matrixWorld).multiplyScalar(l?-1:1);const h=o.geometry.groupIndices,c=o.geometry.index,d=o.geometry.attributes.position,m=e.geometry.boundsTree,p=e.geometry.index,f=e.geometry.attributes.position,u=t.ids,g=t.intersectionSet;for(let y=0,v=u.length;y<v;y++){const w=u[y],x=a===-1?0:h[w]+a,M=3*w,T=c.getX(M+0),P=c.getX(M+1),k=c.getX(M+2);Rt.a.fromBufferAttribute(d,T).applyMatrix4(xt),Rt.b.fromBufferAttribute(d,P).applyMatrix4(xt),Rt.c.fromBufferAttribute(d,k).applyMatrix4(xt),s.reset(),s.initialize(Rt);const D=g[w];for(let O=0,A=D.length;O<A;O++){const I=3*D[O],S=p.getX(I+0),z=p.getX(I+1),V=p.getX(I+2);Si.a.fromBufferAttribute(f,S),Si.b.fromBufferAttribute(f,z),Si.c.fromBufferAttribute(f,V),s.splitByTriangle(Si)}const E=s.triangles;for(let O=0,A=E.length;O<A;O++){const I=E[O],S=s.coplanarTriangleUsed?$u(I,m):Oo(I,m);qe.length=0,Nt.length=0;for(let z=0,V=n.length;z<V;z++){const U=Ro(n[z],S,i);U!==Bs&&(Nt.push(U),qe.push(r[z].getGroupAttrSet(x)))}if(qe.length!==0){Rt.getBarycoord(I.a,Ci.a),Rt.getBarycoord(I.b,Ci.b),Rt.getBarycoord(I.c,Ci.c);for(let z=0,V=qe.length;z<V;z++){const U=qe[z],G=Nt[z]===bn;Ju(w,Ci,o.geometry,o.matrixWorld,_i,U,l!==G)}}}}return u.length}function Uo(o,e,t,n,i,s,r=0){const a=o.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),_i.getNormalMatrix(o.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,h=o.geometry.groupIndices,c=o.geometry.index,d=o.geometry.attributes,m=d.position,p=[],f=o.geometry.halfEdges,u=new Set,g=_s(o.geometry);for(let y=0,v=g;y<v;y++)y in t.intersectionSet||u.add(y);for(;u.size>0;){const y=nd(u);u.delete(y),p.push(y);const v=3*y,w=c.getX(v+0),x=c.getX(v+1),M=c.getX(v+2);bt.a.fromBufferAttribute(m,w).applyMatrix4(xt),bt.b.fromBufferAttribute(m,x).applyMatrix4(xt),bt.c.fromBufferAttribute(m,M).applyMatrix4(xt);const T=Oo(bt,l);Nt.length=0,qe.length=0;for(let P=0,k=n.length;P<k;P++){const D=Ro(n[P],T,i);D!==Bs&&(Nt.push(D),qe.push(s[P]))}for(;p.length>0;){const P=p.pop();for(let k=0;k<3;k++){const D=f.getSiblingTriangleIndex(P,k);D!==-1&&u.has(D)&&(p.push(D),u.delete(D))}if(qe.length!==0){const k=3*P,D=c.getX(k+0),E=c.getX(k+1),O=c.getX(k+2),A=r===-1?0:h[P]+r;if(bt.a.fromBufferAttribute(m,D),bt.b.fromBufferAttribute(m,E),bt.c.fromBufferAttribute(m,O),!wt(bt))for(let I=0,S=qe.length;I<S;I++){const z=Nt[I],V=qe[I].getGroupAttrSet(A),U=z===bn;Qu(D,E,O,d,o.matrixWorld,_i,V,U!==a)}}}}}function sd(o){for(let e=0;e<o.length-1;e++){const t=o[e],n=o[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,s=n.start+n.count;n.start=i,n.count=s-i,o.splice(e,1),e--}}}function rd(o,e,t,n){t.clear();const i=o.attributes;for(let s=0,r=n.length;s<r;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 od(o,e,t){let n=!1,i=-1;const s=o.attributes,r=e.groupAttributes[0];for(const l in r){const h=e.getTotalLength(l),c=e.getType(l),d=e.getItemSize(l),m=e.getNormalized(l);let p=s[l];(!p||p.array.length<h)&&(p=new _.BufferAttribute(new c(h),d,m),o.setAttribute(l,p),n=!0);let f=0;for(let u=0,g=Math.min(t.length,e.groupCount);u<g;u++){const y=t[u].index,{array:v,type:w,length:x}=e.groupAttributes[y][l],M=new w(v.buffer,0,x);p.array.set(M,f),f+=M.length}p.needsUpdate=!0,i=h/p.itemSize}if(o.index){const l=o.index.array;if(l.length<i)o.index=null,n=!0;else for(let h=0,c=l.length;h<c;h++)l[h]=h}let a=0;o.clearGroups();for(let l=0,h=Math.min(t.length,e.groupCount);l<h;l++){const{index:c,materialIndex:d}=t[l],m=e.getCount(c);m!==0&&(o.addGroup(a,m,d),a+=m)}o.setDrawRange(0,i),o.boundsTree=null,n&&o.dispose()}function Vo(o,e){let t=e;return Array.isArray(e)||(t=[],o.forEach(n=>{t[n.materialIndex]=e})),t}class ad{constructor(){this.triangleSplitter=new Vu,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new td}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 gi){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:r,attributeData:a,attributes:l,useGroups:h,consolidateGroups:c,debug:d}=this;for(;a.length<i.length;)a.push(new Gu);i.forEach((y,v)=>{rd(e.geometry,y.geometry,a[v],l)}),d.init(),id(e,t,n,r,a,{useGroups:h}),d.complete();const m=this.getGroupRanges(e.geometry),p=Vo(m,e.material),f=this.getGroupRanges(t.geometry),u=Vo(f,t.material);f.forEach(y=>y.materialIndex+=p.length);let g=[...m,...f].map((y,v)=>({...y,index:v}));if(h){const y=[...p,...u];c&&(g=g.map(w=>{const x=y[w.materialIndex];return w.materialIndex=y.indexOf(x),w}).sort((w,x)=>w.materialIndex-x.materialIndex));const v=[];for(let w=0,x=y.length;w<x;w++){let M=!1;for(let T=0,P=g.length;T<P;T++){const k=g[T];k.materialIndex===w&&(M=!0,k.materialIndex=v.length)}M&&v.push(y[w])}i.forEach(w=>{w.material=v})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=p[0]});return i.forEach((y,v)=>{const w=y.geometry;od(w,a[v],g),c&&sd(w.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new gi){e.updateMatrixWorld(!0);const n=(s,r)=>{const a=s.children;for(let l=0,h=a.length;l<h;l++){const c=a[l];c.isOperationGroup?n(c,r):r(c)}},i=s=>{const r=s.children;let a=!1;for(let h=0,c=r.length;h<c;h++){const d=r[h];a=i(d)||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 ld{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 ad,this.planeGroup=new b.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 b.BufferGeometry,i=new b.MeshStandardMaterial({color:new b.Color(33023),metalness:.1,roughness:.75,side:b.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((r,a)=>a!==t)}),s=new b.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((r,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),d=new gi(r.geometry);r.updateMatrixWorld(!0),d.matrix.copy(r.matrixWorld),d.updateMatrixWorld();const m=this.evaluator.evaluate(c,d,Po);m&&m.geometry.attributes.position.count>0?(s.push(m.geometry),this.geometryCache.set(l,{geometry:m.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 r=this.mergeGeometries(s);n.geometry&&n.geometry.dispose(),n.geometry=r,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(r=>r.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 b.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new b.Quaternion().setFromUnitVectors(new b.Vector3(0,-1,0),e.normal));const n=new b.Mesh(t),i=new gi(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new b.BufferGeometry,n=[],i=[],s=[];let r=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)+r);r+=l.count}),t.setAttribute("position",new b.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new b.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new b.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new b.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new b.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 b.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 cd{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 ld(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 b.Plane;n.setFromNormalAndCoplanarPoint(new b.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new b.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new b.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 b.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,r=(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),r<0&&(r=0),a<0&&(a=0),l<0&&(l=0),h<0&&(h=0),i>100&&(i=100),s>100&&(s=100),r>100&&(r=100),a>100&&(a=100),l>100&&(l=100),h>100&&(h=100);let c={x:{min:i,max:s},y:{min:r,max:a},z:{min:l,max:h}};this.engine.events.trigger(Me.SectionMove,c)}updata_face(e){let t=this,n=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.min.z)],i=[new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z)],s=[new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)],r=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z)],a=[new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z)],l=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.min.y,e.max.z)];h(n,new b.Vector3(0,0,-1),"前"),h(i,new b.Vector3(0,0,1),"后"),h(s,new b.Vector3(1,0,0),"右"),h(r,new b.Vector3(-1,0,0),"左"),h(a,new b.Vector3(0,1,0),"顶"),h(l,new b.Vector3(0,-1,0),"底");function h(c,d,m){const p=new b.BufferGeometry,f=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]),u=[0,1,2,0,2,3];p.setAttribute("position",new b.BufferAttribute(f,3)),p.setIndex(u);let g=t.engine.scene.children.find(T=>T.type=="Group"&&T.name=="ClippingBox");g==null&&(g=new b.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(T=>T.name==m);if(y==null){const T=new b.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:b.DoubleSide});T.polygonOffset=!0,T.polygonOffsetFactor=1,T.polygonOffsetUnits=4;const P=new b.Mesh(p,T);P.normal=d,P.name=m,g.add(P),t.meshs.push(P)}else y.geometry=p;const v=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 b.LineBasicMaterial({color:255}),x=new b.BufferGeometry;x.setAttribute("position",new b.BufferAttribute(v,3));let M=t.meshs.find(T=>T.name==m+"Line");M==null&&(M=new b.Line(x,w),M.name=m+"Line",g.add(M),t.meshs.push(M)),M.geometry=x,M.material=w,m=="前"||m=="左"||m=="底"?t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.min):t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.max),t.engine.scene.children.filter(T=>T.type=="Mesh"&&T.url).forEach(T=>{T.material&&Array.isArray(T.material)?T.material.forEach(P=>{P.clippingPlanes=t.engine.sectionPlane}):T.material.clippingPlanes=t.engine.sectionPlane})}}}class hd{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new b.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 b.Vector3(0,1,0).applyAxisAngle(new b.Vector3(1,0,0),e).applyAxisAngle(new b.Vector3(0,0,1),t).applyAxisAngle(new b.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(D=>D.type=="Group"&&D.name=="ClippingBox");n==null&&(n=new b.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new b.Vector3(1,0,0),s=new b.Vector3(0,1,0),r=new b.Vector3(0,0,1),a,l,h=this.normal.clone().normalize(),c=Math.abs(h.dot(i)),d=Math.abs(h.dot(s)),m=Math.abs(h.dot(r));c<=d&&c<=m?a=i:d<=c&&d<=m?a=s:a=r,a=a.clone().sub(h.clone().multiplyScalar(a.dot(h))).normalize(),l=new b.Vector3().crossVectors(h,a).normalize();let p=null;this.center==null?(p=new b.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 f=this.box.max.x-this.box.min.x,u=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*f,Math.abs(a.y)*u,Math.abs(a.z)*g),v=Math.max(Math.abs(l.x)*f,Math.abs(l.y)*u,Math.abs(l.z)*g),w=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-v/2)),x=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-v/2)),M=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(v/2)),T=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(v/2));w.add(h.clone().multiplyScalar(e)),x.add(h.clone().multiplyScalar(e)),M.add(h.clone().multiplyScalar(e)),T.add(h.clone().multiplyScalar(e)),this.current_center=p.clone().add(h.clone().multiplyScalar(e)),k([w,x,M,T],h,"face");function k(D,E,O){const A=new b.BufferGeometry,I=new Float32Array([D[0].x,D[0].y,D[0].z,D[1].x,D[1].y,D[1].z,D[2].x,D[2].y,D[2].z,D[3].x,D[3].y,D[3].z]),S=[0,1,2,0,2,3];A.setAttribute("position",new b.BufferAttribute(I,3)),A.setIndex(S);let z=t.meshs.find($=>$.name==O);if(z==null){const $=new b.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:b.DoubleSide});$.polygonOffset=!0,$.polygonOffsetFactor=1,$.polygonOffsetUnits=4;const F=new b.Mesh(A,$);F.normal=E,F.name=O,n.add(F),t.meshs.push(F)}else z.geometry=A;const V=new Float32Array([D[0].x,D[0].y,D[0].z,D[1].x,D[1].y,D[1].z,D[2].x,D[2].y,D[2].z,D[3].x,D[3].y,D[3].z,D[0].x,D[0].y,D[0].z]);let U=new b.LineBasicMaterial({color:255}),H=new b.BufferGeometry;H.setAttribute("position",new b.BufferAttribute(V,3));let G=t.meshs.find($=>$.name==O+"Line");G==null&&(G=new b.Line(H,U),G.name=O+"Line",n.add(G),t.meshs.push(G)),G.geometry=H,G.material=U,t.engine.sectionPlane.find($=>$.name==O).setFromNormalAndCoplanarPoint(E.clone().setLength(t.direction),D[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 b.Plane;n.setFromNormalAndCoplanarPoint(new b.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new b.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new b.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 b.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 ud{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 dd{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new b.Plane(new b.Vector3(0,0,1),1e5);t.name="前";let n=new b.Plane(new b.Vector3(0,0,1),1e5);n.name="左";let i=new b.Plane(new b.Vector3(0,0,1),1e5);i.name="后";let s=new b.Plane(new b.Vector3(0,0,1),1e5);s.name="右";let r=new b.Plane(new b.Vector3(0,0,1),1e5);r.name="顶";let a=new b.Plane(new b.Vector3(0,0,1),1e5);a.name="底";let l=new b.Plane(new b.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,r,a,l]}init(){this.sectionBox=new cd(this.engine),this.sectionFace=new hd(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let r=this.engine.models.find(a=>a.url===s.url);s.ids.forEach(a=>{r.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 r=new b.Vector3(1e8,1e9,1e10),a=new b.Vector3(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<r.x&&(r.x=l.min.x),l.min.y<r.y&&(r.y=l.min.y),l.min.z<r.z&&(r.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 b.Box3(r,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,r=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:r,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 ud(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)),r=new b.Vector3(n.dir.x,n.dir.y,n.dir.z),a=s.dot(r);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 fd{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 pd{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 b.Mesh){const s=i.geometry;if(s&&s.attributes){const r=s.attributes.position;if(r){const a=r.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 md{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(r=>r.url===e);i.properties==null&&Gi(e+"/property",r=>{let a=JSON.parse(r);i.properties=a,setTimeout(()=>{s(a,t,n)},100)}),s(i.properties,t,n);function s(r,a,l){let h=[],c=r.models[a.toString()||""],d=c.map(m=>m[0]);d=d.filter((m,p)=>d.indexOf(m)===p),d.forEach(m=>{let p={name:r.categorys[m],children:[]};h.push(p),c.filter(f=>f[0]===m).forEach(f=>{p.children.push({name:r.names[f[1]],value:r.values[f[2]]})})}),l?.({properties:h,materials:h})}}}class gd{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(r=>r.url==e);return n?n.info.modelMapper.find(r=>r.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{r.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 yd{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new b.LineBasicMaterial({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!1})})}loadModelEdge(){this.modelEdgeLoaded||(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(r=>{let a=i.length;for(let l=0;l<r.points.length;l++)r.points[l].length==2&&(i.push(r.points[l][0].X),i.push(r.points[l][0].Z),i.push(-r.points[l][0].Y),i.push(r.points[l][1].X),i.push(r.points[l][1].Z),i.push(-r.points[l][1].Y));s.set(Number(r.id),[a,i.length,r.points])}),this.indexes.set(e.url,s)}}),this.modelEdgeLoaded=!0)}show(){this.modelEdgeLoaded||this.loadModelEdge(),this.indexes.forEach((e,t)=>{let n=[];e.forEach((r,a)=>{r[2].forEach((l,h)=>{l.length==2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})});let i=new b.BufferGeometry;i.setAttribute("position",new b.Float32BufferAttribute(n,3));let s=new b.LineSegments(i,this.material);s.url=t,this.groupEdge.add(s)})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i.slice()}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,r,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<r;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,r,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array,c=0;for(let d=s;d<r;d+=3){const m=Math.floor(c/6),p=c%6>=3;if(a[m]&&a[m].length===2){const f=p?a[m][1]:a[m][0];h[d]=f.X,h[d+1]=f.Z,h[d+2]=-f.Y}c+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class vd{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 r=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${r.error?.message||r.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(`网络请求失败,请检查:
971
+ `;continue}if((V=z.match(E))&&(S.gamma=parseFloat(V[1])),(V=z.match(O))&&(S.exposure=parseFloat(V[1])),(V=z.match(A))&&(S.valid|=2,S.format=V[1]),(V=z.match(I))&&(S.valid|=4,S.height=parseInt(V[1],10),S.width=parseInt(V[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2||r(3,"missing format specifier"),S.valid&4||r(3,"missing image size specifier"),S},p=function(k,D,E){const O=D;if(O<8||O>32767||k[0]!==2||k[1]!==2||k[2]&128)return new Uint8Array(k);O!==(k[2]<<8|k[3])&&r(3,"wrong scanline width");const A=new Uint8Array(4*D*E);A.length||r(4,"unable to allocate buffer space");let I=0,S=0;const z=4*O,V=new Uint8Array(4),U=new Uint8Array(z);let H=E;for(;H>0&&S<k.byteLength;){S+4>k.byteLength&&r(1),V[0]=k[S++],V[1]=k[S++],V[2]=k[S++],V[3]=k[S++],(V[0]!=2||V[1]!=2||(V[2]<<8|V[3])!=O)&&r(3,"bad rgbe scanline format");let G=0,$;for(;G<z&&S<k.byteLength;){$=k[S++];const R=$>128;if(R&&($-=128),($===0||G+$>z)&&r(3,"bad scanline data"),R){const te=k[S++];for(let ee=0;ee<$;ee++)U[G++]=te}else U.set(k.subarray(S,S+$),G),G+=$,S+=$}const F=O;for(let R=0;R<F;R++){let te=0;A[I]=U[R+te],te+=O,A[I+1]=U[R+te],te+=O,A[I+2]=U[R+te],te+=O,A[I+3]=U[R+te],I+=4}H--}return A},f=function(k,D,E,O){const A=k[D+3],I=Math.pow(2,A-128)/255;E[O+0]=k[D+0]*I,E[O+1]=k[D+1]*I,E[O+2]=k[D+2]*I,E[O+3]=1},u=function(k,D,E,O){const A=k[D+3],I=Math.pow(2,A-128)/255;E[O+0]=_.DataUtils.toHalfFloat(Math.min(k[D+0]*I,65504)),E[O+1]=_.DataUtils.toHalfFloat(Math.min(k[D+1]*I,65504)),E[O+2]=_.DataUtils.toHalfFloat(Math.min(k[D+2]*I,65504)),E[O+3]=_.DataUtils.toHalfFloat(1)},g=new Uint8Array(e);g.pos=0;const y=m(g),v=y.width,w=y.height,x=p(g.subarray(g.pos),v,w);let M,T,P;switch(this.type){case _.FloatType:P=x.length/4;const k=new Float32Array(P*4);for(let E=0;E<P;E++)f(x,E*4,k,E*4);M=k,T=_.FloatType;break;case _.HalfFloatType:P=x.length/4;const D=new Uint16Array(P*4);for(let E=0;E<P;E++)u(x,E*4,D,E*4);M=D,T=_.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:v,height:w,data:M,header:y.string,gamma:y.gamma,exposure:y.exposure,type:T}}setDataType(e){return this.type=e,this}load(e,t,n,i){function s(r,a){switch(r.type){case _.FloatType:case _.HalfFloatType:r.colorSpace=_.LinearSRGBColorSpace,r.minFilter=_.LinearFilter,r.magFilter=_.LinearFilter,r.generateMipmaps=!1,r.flipY=!0;break}t&&t(r,a)}return super.load(e,s,n,i)}}function ih(){return new b.Scene}function sh(o,e){o.appendChild(e.domElement)}function rh(o,e,t){var n=new Object;n.visible=!0;let i=null,s,r,a=[];n.init=function(){s||(c(),h(),d())},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 f=new b.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(f.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(f){var u=new b.Vector3(0,0,0);f=="top"?u=new b.Vector3(0,1,1e-5):f=="down"?u=new b.Vector3(0,-1,1e-5):f=="front"?u=new b.Vector3(0,0,1):f=="left"?u=new b.Vector3(-1,0,0):f=="back"?u=new b.Vector3(0,0,-1):f=="right"?u=new b.Vector3(1,0,0):f=="top_front"?u=new b.Vector3(1,1,0):f=="top_left"?u=new b.Vector3(0,1,-1):f=="top_back"?u=new b.Vector3(-1,1,0):f=="top_right"?u=new b.Vector3(0,1,1):f=="down_front"?u=new b.Vector3(1,-1,0):f=="down_left"?u=new b.Vector3(0,-1,-1):f=="down_back"?u=new b.Vector3(-1,-1,0):f=="down_right"?u=new b.Vector3(0,-1,1):f=="front_right"?u=new b.Vector3(1,0,1):f=="right_back"?u=new b.Vector3(-1,0,1):f=="back_left"?u=new b.Vector3(-1,0,-1):f=="left_front"?u=new b.Vector3(1,0,-1):f=="top_left_front"?u=new b.Vector3(1,1,-1):f=="top_front_right"?u=new b.Vector3(1,1,1):f=="top_right_back"?u=new b.Vector3(-1,1,1):f=="top_back_left"?u=new b.Vector3(-1,1,-1):f=="button_left_front"?u=new b.Vector3(1,-1,-1):f=="button_front_right"?u=new b.Vector3(1,-1,1):f=="button_right_back"?u=new b.Vector3(-1,1,1):f=="button_back_left"&&(u=new b.Vector3(-1,-1,-1));var g=o.octreeBox.getBoundingBox(),y=g.min,v=g.max,w=y.clone().add(v.clone()).multiplyScalar(.5),x=w.clone().add(u.multiplyScalar(1*v.distanceTo(y)));l(e.camera.position,x,o.controls.target.clone(),w)},n.GetCameraPose=function(){var f=e.camera.quaternion,u=e.camera.position,g=o.controls.target,y={quaternion:f,position:u,target:g};return y},n.ReductionCameraPose=function(f,u=1e3,g){var y=new b.Quaternion(f.quaternion._x,f.quaternion._y,f.quaternion._z,f.quaternion._w),v=new b.Vector3(f.position.x,f.position.y,f.position.z),w=new b.Vector3(f.target.x,f.target.y,f.target.z);let x=!1;l(e.camera.position,v,o.controls.target.clone(),w,e.camera.quaternion,y,u,M=>{g&&(x||(g(M),x=!0))}),g&&setTimeout(()=>{x||(g(!0),x=!0)},u+10)},n.CameraGoHome=function(){var f=o.octreeBox.getBoundingBox(),u=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let g=new b.Vector3(1,1,1);var y=f.max.distanceTo(f.min),v=u.clone().add(g.multiplyScalar(y*.5));if(e.camera.isOrthographicCamera){var w=o.container.clientWidth/o.container.clientHeight,x=y*.6;e.camera.left=-x*w,e.camera.right=x*w,e.camera.top=x,e.camera.bottom=-x,e.camera.zoom=1,e.camera.updateProjectionMatrix()}o.controlModule.orbitControls.origin=u.clone(),l(e.camera.position,v,o.controls.target.clone(),u)},n.zoomToBox=function(f){if(e.camera.isOrthographicCamera){let R=function(){i=requestAnimationFrame(R),F.update()};var u=f.min.clone().add(f.max.clone()).multiplyScalar(.5),g=e.camera.position.clone().sub(o.controls.target.clone()).normalize(),y=e.camera.position.distanceTo(o.controls.target),v=u.clone().add(g.multiplyScalar(y)),w=e.camera.zoom,x=new b.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),M=new b.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new b.Vector3(f.min.x,f.min.y,f.min.z),new b.Vector3(f.max.x,f.min.y,f.min.z),new b.Vector3(f.min.x,f.max.y,f.min.z),new b.Vector3(f.max.x,f.max.y,f.min.z),new b.Vector3(f.min.x,f.min.y,f.max.z),new b.Vector3(f.max.x,f.min.y,f.max.z),new b.Vector3(f.min.x,f.max.y,f.max.z),new b.Vector3(f.max.x,f.max.y,f.max.z)],P=1/0,k=-1/0,D=1/0,E=-1/0;for(var O of T){var A=O.dot(x),I=O.dot(M);P=Math.min(P,A),k=Math.max(k,A),D=Math.min(D,I),E=Math.max(E,I)}var S=(k-P)/2,z=(E-D)/2,V=(e.camera.right-e.camera.left)/2,U=(e.camera.top-e.camera.bottom)/2;w=Math.min(V/S,U/z)*.75;var H=e.camera.position.clone(),G=o.controls.target.clone(),$=e.camera.zoom,F=new dn.Tween({x1:H.x,y1:H.y,z1:H.z,x2:G.x,y2:G.y,z2:G.z,zoom:$}).to({x1:v.x,y1:v.y,z1:v.z,x2:u.x,y2:u.y,z2:u.z,zoom:w},1e3);F.onUpdate(function(te){o.controls&&(e.camera.position.set(te.x1,te.y1,te.z1),o.controls.target.set(te.x2,te.y2,te.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=te.zoom,e.camera.updateProjectionMatrix()),o.controls.auto=!0,o.controls.update(),n.RenderScene())}),F.onComplete(function(){o.controls&&(o.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),F.easing(dn.Easing.Cubic.InOut),F.start(),R()}else{var u=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let ee=e.camera.position.clone().sub(o.controls.target.clone()).normalize();var v=u.clone().add(ee.multiplyScalar(2*f.max.distanceTo(f.min)));l(e.camera.position,v,o.controls.target.clone(),u)}};function l(f,u,g,y,v,w,x=1e3,M){var T;v&&w?(T=new dn.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z,_x:v._x,_y:v._y,_z:v._z,_w:v._w}),T.to({x1:u.x,y1:u.y,z1:u.z,x2:y.x,y2:y.y,z2:y.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w},x)):(T=new dn.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z}),T.to({x1:u.x,y1:u.y,z1:u.z,x2:y.x,y2:y.y,z2:y.z},x)),T.onUpdate(function(k){o.controls&&(v&&w?(e.camera.quaternion._x=k._x,e.camera.quaternion._y=k._y,e.camera.quaternion._z=k._z,e.camera.quaternion._w=k._w):o.controls.auto=!0,e.camera.position.x=k.x1,e.camera.position.y=k.y1,e.camera.position.z=k.z1,o.controls.target.x=k.x2,o.controls.target.y=k.y2,o.controls.target.z=k.z2,o.controls.update(),n.RenderScene())}),T.onComplete(function(k){o.controls&&(o.controls.auto=!1,n.RenderScene(),M&&M(!0),cancelAnimationFrame(i),i=null)}),T.easing(dn.Easing.Cubic.InOut);function P(k){i=requestAnimationFrame(P),T.update()}T.start(),P()}function c(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),r=document.createElement("div"),r.className="viewSettingWrapper",r.innerHTML="...",s.appendChild(r);var f=document.createElement("div");f.className="homeViewWrapper",f.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(f);const u=document.createElement("div");u.className="cameraToggleWrapper",u.title="切换正交/透视视图",u.innerHTML="⊞",u.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),v()}),s.appendChild(u);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("截图"),n.TakeScreenshot(),v()}),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(),v()}),s.appendChild(y),r.addEventListener("mousedown",function(x){x.stopPropagation(),u.classList.contains("show")?(v(),console.log("隐藏功能按钮")):(w(),console.log("显示功能按钮"))});function v(){u.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function w(){u.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function h(){n.sceneOrtho=ih();var g=t.clientWidth,y=t.clientWidth,f=g>y?g/y:y/g,u=300;n.camera=new b.OrthographicCamera(u*f/-2,u*f/2,u/2,u/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,v=new b.WebGLRenderer({alpha:!0});v.setSize(g,y),v.setClearAlpha(0),n.sceneOrtho.renderer=v;let w=new b.AmbientLight(16777215,.8);n.sceneOrtho.add(w),sh(s,v)}function d(){const f="/assets/viewcube/";let u=[{label:"右",icon:f+"cn_right.png"},{label:"左",icon:f+"cn_left.png"},{label:"顶",icon:f+"cn_top.png"},{label:"底",icon:f+"cn_bottom.png"},{label:"前",icon:f+"cn_front.png"},{label:"后",icon:f+"cn_back.png"}];var g=[];for(const v of u)g.push(new b.MeshBasicMaterial({color:16777215,map:new b.TextureLoader().load(v.icon)}));new b.MeshLambertMaterial({color:255});var y=new b.Mesh(new b.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),m(122),s.addEventListener("mousedown",v=>{var w={};w.x=v.offsetX/s.clientWidth*2-1,w.y=-(v.offsetY/s.clientHeight)*2+1;var x=new b.Raycaster;x.setFromCamera(w,n.camera);const M=x.intersectObjects(a,!1);M.length>0&&n.ToggleDirectionView(M[0].object.name)}),s.addEventListener("mousemove",v=>{var w={};w.x=v.offsetX/s.clientWidth*2-1,w.y=-(v.offsetY/s.clientHeight)*2+1;var x=new b.Raycaster;x.setFromCamera(w,n.camera);const M=x.intersectObjects(a,!1);for(var T of a)T.material.opacity=.01;M.length>0&&(M[0].object.material.opacity=.2)})}function m(f){for(var u=f*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new b.Vector3(u,0,0)},{name:"back",a:75,b:75,c:30,point:new b.Vector3(0,0,-u)},{name:"left",a:30,b:75,c:75,point:new b.Vector3(-u,0,0)},{name:"front",a:75,b:75,c:30,point:new b.Vector3(0,0,u)},{name:"top",a:75,b:30,c:75,point:new b.Vector3(0,u,0)},{name:"button",a:75,b:30,c:75,point:new b.Vector3(0,-u,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new b.Vector3(-u,u,u)},{name:"button_front_right",a:30,b:30,c:30,point:new b.Vector3(-u,-u,u)},{name:"top_front_right",a:30,b:30,c:30,point:new b.Vector3(u,u,u)},{name:"button_right_back",a:30,b:30,c:30,point:new b.Vector3(u,-u,u)},{name:"top_back_left",a:30,b:30,c:30,point:new b.Vector3(-u,u,-u)},{name:"button_back_left",a:30,b:30,c:30,point:new b.Vector3(-u,-u,-u)},{name:"top_left_front",a:30,b:30,c:30,point:new b.Vector3(u,u,-u)},{name:"button_left_front",a:30,b:30,c:30,point:new b.Vector3(u,-u,-u)}],v=[{name:"top_front",a:30,b:30,c:75,point:new b.Vector3(u,u,0)},{name:"top_right",a:75,b:30,c:30,point:new b.Vector3(0,u,u)},{name:"top_back",a:30,b:30,c:75,point:new b.Vector3(-u,u,0)},{name:"top_left",a:75,b:30,c:30,point:new b.Vector3(0,u,-u)},{name:"button_front",a:30,b:30,c:75,point:new b.Vector3(u,-u,0)},{name:"button_right",a:75,b:30,c:30,point:new b.Vector3(0,-u,u)},{name:"button_back",a:30,b:30,c:75,point:new b.Vector3(-u,-u,0)},{name:"button_left",a:75,b:30,c:30,point:new b.Vector3(0,-u,-u)},{name:"front_right",a:30,b:75,c:30,point:new b.Vector3(u,0,u)},{name:"right_back",a:30,b:75,c:30,point:new b.Vector3(-u,0,u)},{name:"back_left",a:30,b:75,c:30,point:new b.Vector3(-u,0,-u)},{name:"left_front",a:30,b:75,c:30,point:new b.Vector3(u,0,-u)}],w=0;w<g.length;w++)a.push(p(g[w]));for(var w=0;w<y.length;w++)a.push(p(y[w]));for(var w=0;w<v.length;w++)a.push(p(v[w]))}function p(f){const u=new b.BoxGeometry(f.a,f.b,f.c),g=new b.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new b.Matrix4().makeTranslation(f.point.x,f.point.y,f.point.z);let v=u.applyMatrix4(y),w=new b.Mesh(v,g);return w.name=f.name,n.sceneOrtho.add(w),w}return n.ToggleCameraType=function(){o.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!o.renderer){console.error("渲染器未初始化");return}o.renderer.render(e,e.camera);const u=o.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=u,g.click(),console.log("截图已保存")}catch(f){console.error("截图失败:",f)}},n.ToggleFullscreen=function(){const f=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(f.requestFullscreen?f.requestFullscreen():f.webkitRequestFullscreen?f.webkitRequestFullscreen():f.mozRequestFullScreen?f.mozRequestFullScreen():f.msRequestFullscreen&&f.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class oh{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=rh(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function ah(o){let e=new Object;return e.getBoundingBox=function(){let t=o.models,n=new b.Vector3(1e8,1e9,1e10),i=new b.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let m=d.boundingBox.min,p=d.boundingBox.max;m.x<n.x&&(n.x=m.x),m.y<n.y&&(n.y=m.y),m.z<n.z&&(n.z=m.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),r=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),c=Math.max(n.y,i.y),h=Math.max(n.z,i.z);return{min:new b.Vector3(s,r,a),max:new b.Vector3(l,c,h)}},e.rayInterationModel=function(t){let n=[];return o.engineStatus.models.forEach(r=>{r.info.lods.forEach(a=>{let l=a.octreeBox;s(t,l,r)})}),n=n.filter(r=>r instanceof b.Mesh),t.intersectObjects(n,!1);function s(r,a,l){if(a==null)return;let c=new b.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),h=new b.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),d=new b.Vector3(Math.min(c.x,h.X),Math.min(c.y,h.y),Math.min(c.z,h.z)),m=new b.Vector3(Math.max(h.x,c.x),Math.max(h.y,c.y),Math.max(h.z,c.z)),p=new b.Box3(d,m),f=r.ray.intersectsBox(p);if(!(f==null||f==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var u of a.elements){let g=o.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(u))continue;let y=o.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(y!=null&&y.includes(u))continue;let w=o.models.find(x=>x.url==l.url).nodesMap.get(u);w!=null&&!w.instance&&w.infos.map(M=>M.mesh).forEach(M=>{n.push(M)})}}else{if(a.elements!=null)for(var u of a.elements){let y=o.engineStatus.hideModels.find(M=>M.url==l.url)?.ids;if(y!=null&&y.includes(u))continue;let v=o.engineStatus.translucentModels.find(M=>M.url==l.url)?.ids;if(v!=null&&v.includes(u))continue;let x=o.models.find(M=>M.url==l.url).nodesMap.get(u);x!=null&&!x.instance&&x.infos.map(T=>T.mesh).forEach(T=>{n.push(T)})}for(let g of a.children)s(r,g,l)}}},e}class lh{engine;isDrawing=!1;startPoint=new b.Vector2;endPoint=new b.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 De(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),r=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:s},{x:i,y:s},{x:i,y:r},{x:n,y:r}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new b.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new b.Vector3;e.getCenter(i);const s=new b.Vector3;e.getSize(s);const r=Math.max(s.x,s.y,s.z);if(t instanceof b.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=r/(2*Math.tan(a/2))*1.2,h=new b.Vector3;t.getWorldDirection(h);const d=i.clone().sub(t.position);h.dot(d.normalize())<0&&h.negate();const p=i.clone().sub(h.multiplyScalar(c));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof b.OrthographicCamera){const l=r*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const d=new b.Vector3;t.getWorldDirection(d);const m=r*1.5,p=i.clone().sub(d.multiplyScalar(m));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class ch{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 b.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof b.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof b.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 b.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 Re);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),r=new Re(this.engine.scene,this.engine.camera,i,s);r.output=Re.OUTPUT.Default,r.blendIntensity=.5,r.updateGtaoMaterial&&r.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,r)}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,r=new b.PlaneGeometry(n,n),a=new b.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:b.DoubleSide});this.ground=new b.Mesh(r,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 rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var e=Math.random()*16|0,t=o=="x"?e:e&3|8;return t.toString(16)})}class ot{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=ki(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(f=>{p(f)}),this.engine.measure.annotationData.elevationAnnotation.forEach(f=>{m(f)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(f=>{d(f)}),this.engine.measure.annotationData.angleAnnotation.forEach(f=>{l(f)}),this.engine.measure.annotationData.areaAnnotation.forEach(f=>{c(f)}),this.engine.measure.annotationData.slopeAnnotation.forEach(f=>{h(f)});function l(f){if(f.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">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="angle-annotation",f.container.id=f.id,f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point3),v=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;u.x+=v,u.y+=w,g.x+=v,g.y+=w,y.x+=v,y.y+=w;let x=f.container;x.getElementsByTagName("circle")[0].setAttribute("cx",u.x),x.getElementsByTagName("circle")[0].setAttribute("cy",u.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",u.x+","+u.y+" "+g.x+","+g.y),x.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let M=g.x,T=g.y-30;x.getElementsByTagName("rect")[0].setAttribute("x",M-40),x.getElementsByTagName("rect")[0].setAttribute("y",T-12.5),x.getElementsByTagName("text")[0].setAttribute("x",M),x.getElementsByTagName("text")[0].setAttribute("y",T+4),x.getElementsByTagName("text")[0].innerHTML=f.text,x.style.top="0px",x.style.left="0px"}function c(f){if(f.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(f.text,2)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="area-annotation",f.container.id=f.id,f.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}if(!f.points||f.points.length<3)return;let u=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],v=0,w=0;for(let k=0;k<f.points.length;k++){let D=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.points[k]);D.x+=u,D.y+=g,y.push(D),v+=D.x,w+=D.y}v=v/y.length,w=w/y.length;let x=y.map(k=>k.x+","+k.y).join(" "),M=f.container;M.getElementsByTagName("polygon")[0].setAttribute("points",x),M.getElementsByTagName("polyline")[0].setAttribute("points",x);let T=v,P=w;M.getElementsByTagName("rect")[0].setAttribute("x",T-40),M.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),M.getElementsByTagName("text")[0].setAttribute("x",T),M.getElementsByTagName("text")[0].setAttribute("y",P+4),M.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,2),M.style.top="0px",M.style.left="0px"}function h(f){if(f.container==null){let T=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+f.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-'+f.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">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="slope-annotation",f.container.id=f.id,f.container.innerHTML=T,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;u.x+=y,u.y+=v,g.x+=y,g.y+=v;let w=f.container;w.getElementsByTagName("polyline")[0].setAttribute("points",u.x+","+u.y+" "+g.x+","+g.y);let x=(u.x+g.x)/2,M=(u.y+g.y)/2-30;w.getElementsByTagName("rect")[0].setAttribute("x",x-50),w.getElementsByTagName("rect")[0].setAttribute("y",M-12.5),w.getElementsByTagName("text")[0].setAttribute("x",x),w.getElementsByTagName("text")[0].setAttribute("y",M+4),w.getElementsByTagName("text")[0].innerHTML=f.text,w.style.top="0px",w.style.left="0px"}function d(f){if(f.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(f.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(-f.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(f.textY,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="coordinate-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container,g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=v,u.style.top="0px",u.style.left="0px";let w=u.getElementsByTagName("circle")[0];w&&(w.setAttribute("cx",g.x),w.setAttribute("cy",g.y));let x=u.getElementsByTagName("rect"),M=u.getElementsByTagName("text"),T=-55;x[0]&&(x[0].setAttribute("x",g.x+10),x[0].setAttribute("y",g.y+10+T)),M[0]&&(M[0].setAttribute("x",g.x+10+40),M[0].setAttribute("y",g.y+10+16+T)),x[1]&&(x[1].setAttribute("x",g.x+10),x[1].setAttribute("y",g.y+10+30+T)),M[1]&&(M[1].setAttribute("x",g.x+10+40),M[1].setAttribute("y",g.y+10+46+T)),x[2]&&(x[2].setAttribute("x",g.x+10),x[2].setAttribute("y",g.y+10+60+T)),M[2]&&(M[2].setAttribute("x",g.x+10+40),M[2].setAttribute("y",g.y+10+76+T)),M[0]&&(M[0].innerHTML="X: "+e.getMeasureText(f.textX,1)),M[1]&&(M[1].innerHTML="Y: "+e.getMeasureText(-f.textZ,1)),M[2]&&(M[2].innerHTML="Z: "+e.getMeasureText(f.textY,1))}function m(f){if(f.container==null){let w=['<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(f.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("");f.container=document.createElement("div"),f.container.className="elevation-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=w,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container,g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;u.style.top=g.y+v-48+"px",u.style.left=g.x+y-16+"px",u.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1)}function p(f){if(f.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(f.text,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="normal-annotation",f.container.id=f.id,f.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container;if(f.point1==null||f.point2==null){u.style.display="none";return}else u.style.display="block";let g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),y=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),v=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=v,g.y+=w,y.x+=v,y.y+=w,u.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),u.getElementsByTagName("circle")[0].setAttribute("cx",g.x),u.getElementsByTagName("circle")[0].setAttribute("cy",g.y),u.getElementsByTagName("circle")[1].setAttribute("cx",y.x),u.getElementsByTagName("circle")[1].setAttribute("cy",y.y),u.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),u.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),u.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),u.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),u.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1),u.style.top="0px",u.style.left="0px"}}}class hh{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++){const s=e[i];if(!s)continue;typeof s.updateMatrixWorld=="function"&&s.updateMatrixWorld(!0);const r=new b.Box3().setFromObject(s);!Number.isFinite(r.min.y)||!Number.isFinite(r.max.y)||(r.min.y<t&&(t=r.min.y),r.max.y>n&&(n=r.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let s=new b.Raycaster(i.add(new b.Vector3(0,.01,0)),new b.Vector3(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const r=this.engine.octreeBox.rayInterationModel(s);if(r.length===0){t.point2=null;return}t.point1=i,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}else{let i=new b.Raycaster(e.catch.point.clone().add(new b.Vector3(0,.01,0)),new b.Vector3(0,this.catchDir==0?-1:1,0));const s=this.engine.octreeBox.rayInterationModel(i);if(s.length===0){t.point2=null;return}t.point1=n.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}}}class uh{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(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();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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(Me.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:rt(),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 dh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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(r=>r.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new b.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.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(Me.MeasureChanged,t)}}class fh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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:rt(),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(Me.MeasureChanged,t))}}class ph{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),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.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,e))}}class mh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new b.Vector3().subVectors(e,t),s=new b.Vector3().subVectors(n,t),r=i.length(),a=s.length();if(r===0||a===0)return 0;const c=i.dot(s)/(r*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(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(Me.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:rt(),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 gh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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:rt(),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:rt(),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(Me.MeasureChanged,e))}}class yh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}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,r=Math.sqrt(i*i+s*s);if(r===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/r*100,c=Math.atan(n/r)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:n,horizontalDist:r,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(Me.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:rt(),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 vh{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 hh(e),this.distanceMeasure=new uh(e),this.clearDistanceMeasure=new dh(e),this.elevationMeasure=new fh(e),this.pointMeasure=new ph(e),this.angleMeasure=new mh(e),this.areaMeasure=new gh(e),this.slopeMeasure=new yh(e),this.tools=new ot(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),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 Zr=0,wh=1,xh=2,Yr=2,Qi=1.25,Kr=1,Le=32,_e=Le/4,qr=65535,bh=Math.pow(2,-24),es=Symbol("SKIP_GENERATION");function Mh(o){return o.index?o.index.count:o.attributes.position.count}function kt(o){return Mh(o)/3}function _h(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Sh(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=_h(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function $r(o,e){const t=kt(o),n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=Math.max(0,i),a=Math.min(t,s)-r;return[{offset:Math.floor(r),count:Math.floor(a)}]}function Hr(o,e){if(!o.groups||!o.groups.length)return $r(o,e);const t=[],n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=kt(o),a=[];for(const h of o.groups){const{start:d,count:m}=h,p=d/3,f=isFinite(m)?m:r*3-d,u=(d+f)/3;p<s&&u>i&&(a.push({pos:Math.max(i,p),isStart:!0}),a.push({pos:Math.min(s,u),isStart:!1}))}a.sort((h,d)=>h.pos!==d.pos?h.pos-d.pos:h.type==="end"?-1:1);let l=0,c=null;for(const h of a){const d=h.pos;l!==0&&d!==c&&t.push({offset:c,count:d-c}),l+=h.isStart?1:-1,c=d}return t}function ts(o,e,t,n,i){let s=1/0,r=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,m=1/0,p=1/0,f=-1/0,u=-1/0,g=-1/0;const y=o.offset||0;for(let v=(e-y)*6,w=(e+t-y)*6;v<w;v+=6){const x=o[v+0],M=o[v+1],T=x-M,P=x+M;T<s&&(s=T),P>l&&(l=P),x<d&&(d=x),x>f&&(f=x);const k=o[v+2],D=o[v+3],E=k-D,O=k+D;E<r&&(r=E),O>c&&(c=O),k<m&&(m=k),k>u&&(u=k);const A=o[v+4],I=o[v+5],S=A-I,z=A+I;S<a&&(a=S),z>h&&(h=z),A<p&&(p=A),A>g&&(g=A)}n[0]=s,n[1]=r,n[2]=a,n[3]=l,n[4]=c,n[5]=h,i[0]=d,i[1]=m,i[2]=p,i[3]=f,i[4]=u,i[5]=g}function Jr(o,e,t=null,n=null,i=null){const s=o.attributes.position,r=o.index?o.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,c=s.offset||0;let h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);const d=["getX","getY","getZ"],m=i.offset;for(let p=e,f=e+t;p<f;p++){const g=(n?n[p]:p)*3,y=(p-m)*6;let v=g+0,w=g+1,x=g+2;r&&(v=r[v],w=r[w],x=r[x]),a||(v=v*h+c,w=w*h+c,x=x*h+c);for(let M=0;M<3;M++){let T,P,k;a?(T=s[d[M]](v),P=s[d[M]](w),k=s[d[M]](x)):(T=l[v+M],P=l[w+M],k=l[x+M]);let D=T;P<D&&(D=P),k<D&&(D=k);let E=T;P>E&&(E=P),k>E&&(E=k);const O=(E-D)/2,A=M*2;i[y+A+0]=D+O,i[y+A+1]=O+(Math.abs(D)+O)*bh}}return i}function ve(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function Qr(o){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=o[n+3]-o[n];i>t&&(t=i,e=n)}return e}function eo(o,e){e.set(o)}function to(o,e,t){let n,i;for(let s=0;s<3;s++){const r=s+3;n=o[s],i=e[s],t[s]=n<i?n:i,n=o[r],i=e[r],t[r]=n>i?n:i}}function Qn(o,e,t){for(let n=0;n<3;n++){const i=e[o+2*n],s=e[o+2*n+1],r=i-s,a=i+s;r<t[n]&&(t[n]=r),a>t[n+3]&&(t[n+3]=a)}}function fn(o){const e=o[3]-o[0],t=o[4]-o[1],n=o[5]-o[2];return 2*(e*t+t*n+n*e)}const at=32,Ch=(o,e)=>o.candidate-e.candidate,mt=new Array(at).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ei=new Float32Array(6);function Ah(o,e,t,n,i,s){let r=-1,a=0;if(s===Zr)r=Qr(e),r!==-1&&(a=(e[r]+e[r+3])/2);else if(s===wh)r=Qr(o),r!==-1&&(a=Ph(t,n,i,r));else if(s===xh){const l=fn(o);let c=Qi*i;const h=t.offset||0,d=(n-h)*6,m=(n+i-h)*6;for(let p=0;p<3;p++){const f=e[p],y=(e[p+3]-f)/at;if(i<at/4){const v=[...mt];v.length=i;let w=0;for(let M=d;M<m;M+=6,w++){const T=v[w];T.candidate=t[M+2*p],T.count=0;const{bounds:P,leftCacheBounds:k,rightCacheBounds:D}=T;for(let E=0;E<3;E++)D[E]=1/0,D[E+3]=-1/0,k[E]=1/0,k[E+3]=-1/0,P[E]=1/0,P[E+3]=-1/0;Qn(M,t,P)}v.sort(Ch);let x=i;for(let M=0;M<x;M++){const T=v[M];for(;M+1<x&&v[M+1].candidate===T.candidate;)v.splice(M+1,1),x--}for(let M=d;M<m;M+=6){const T=t[M+2*p];for(let P=0;P<x;P++){const k=v[P];T>=k.candidate?Qn(M,t,k.rightCacheBounds):(Qn(M,t,k.leftCacheBounds),k.count++)}}for(let M=0;M<x;M++){const T=v[M],P=T.count,k=i-T.count,D=T.leftCacheBounds,E=T.rightCacheBounds;let O=0;P!==0&&(O=fn(D)/l);let A=0;k!==0&&(A=fn(E)/l);const I=Kr+Qi*(O*P+A*k);I<c&&(r=p,c=I,a=T.candidate)}}else{for(let x=0;x<at;x++){const M=mt[x];M.count=0,M.candidate=f+y+x*y;const T=M.bounds;for(let P=0;P<3;P++)T[P]=1/0,T[P+3]=-1/0}for(let x=d;x<m;x+=6){let P=~~((t[x+2*p]-f)/y);P>=at&&(P=at-1);const k=mt[P];k.count++,Qn(x,t,k.bounds)}const v=mt[at-1];eo(v.bounds,v.rightCacheBounds);for(let x=at-2;x>=0;x--){const M=mt[x],T=mt[x+1];to(M.bounds,T.rightCacheBounds,M.rightCacheBounds)}let w=0;for(let x=0;x<at-1;x++){const M=mt[x],T=M.count,P=M.bounds,D=mt[x+1].rightCacheBounds;T!==0&&(w===0?eo(P,ei):to(P,ei,ei)),w+=T;let E=0,O=0;w!==0&&(E=fn(ei)/l);const A=i-w;A!==0&&(O=fn(D)/l);const I=Kr+Qi*(E*w+O*A);I<c&&(r=p,c=I,a=M.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:r,pos:a}}function Ph(o,e,t,n){let i=0;const s=o.offset;for(let r=e,a=e+t;r<a;r++)i+=o[(r-s)*6+n*2];return i/t}class ns{constructor(){this.boundingData=new Float32Array(6)}}function Th(o,e,t,n,i,s){let r=n,a=n+i-1;const l=s.pos,c=s.axis*2,h=t.offset||0;for(;;){for(;r<=a&&t[(r-h)*6+c]<l;)r++;for(;r<=a&&t[(a-h)*6+c]>=l;)a--;if(r<a){for(let d=0;d<3;d++){let m=e[r*3+d];e[r*3+d]=e[a*3+d],e[a*3+d]=m}for(let d=0;d<6;d++){const m=r-h,p=a-h,f=t[m*6+d];t[m*6+d]=t[p*6+d],t[p*6+d]=f}r++,a--}else return r}}function Dh(o,e,t,n,i,s){let r=n,a=n+i-1;const l=s.pos,c=s.axis*2,h=t.offset||0;for(;;){for(;r<=a&&t[(r-h)*6+c]<l;)r++;for(;r<=a&&t[(a-h)*6+c]>=l;)a--;if(r<a){let d=o[r];o[r]=o[a],o[a]=d;for(let m=0;m<6;m++){const p=r-h,f=a-h,u=t[p*6+m];t[p*6+m]=t[f*6+m],t[f*6+m]=u}r++,a--}else return r}}let no,ti,is,io;const kh=Math.pow(2,32);function ss(o){return"count"in o?1:1+ss(o.left)+ss(o.right)}function Eh(o,e,t){return no=new Float32Array(t),ti=new Uint32Array(t),is=new Uint16Array(t),io=new Uint8Array(t),rs(o,e)}function rs(o,e){const t=o/4,n=o/2,i="count"in e,s=e.boundingData;for(let r=0;r<6;r++)no[t+r]=s[r];if(i)return e.buffer?(io.set(new Uint8Array(e.buffer),o),o+e.buffer.byteLength):(ti[t+6]=e.offset,is[n+14]=e.count,is[n+15]=qr,o+Le);{const{left:r,right:a,splitAxis:l}=e,c=o+Le;let h=rs(c,r);const d=o/Le,p=h/Le-d;if(p>kh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return ti[t+6]=p,ti[t+7]=l,rs(h,a)}}function Lh(o,e,t){const i=(o.index?o.index.count:o.attributes.position.count)/3>2**16,s=t.reduce((h,d)=>h+d.count,0),r=i?4:2,a=e?new SharedArrayBuffer(s*r):new ArrayBuffer(s*r),l=i?new Uint32Array(a):new Uint16Array(a);let c=0;for(let h=0;h<t.length;h++){const{offset:d,count:m}=t[h];for(let p=0;p<m;p++)l[c+p]=d+p;c+=m}return l}function Ih(o,e,t,n,i){const{maxDepth:s,verbose:r,maxLeafTris:a,strategy:l,onProgress:c,indirect:h}=i,d=o._indirectBuffer,m=o.geometry,p=m.index?m.index.array:null,f=h?Dh:Th,u=kt(m),g=new Float32Array(6);let y=!1;const v=new ns;return ts(e,t,n,v.boundingData,g),x(v,t,n,g),v;function w(M){c&&c(M/u)}function x(M,T,P,k=null,D=0){if(!y&&D>=s&&(y=!0,r&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(m))),P<=a||D>=s)return w(T+P),M.offset=T,M.count=P,M;const E=Ah(M.boundingData,k,e,T,P,l);if(E.axis===-1)return w(T+P),M.offset=T,M.count=P,M;const O=f(d,p,e,T,P,E);if(O===T||O===T+P)w(T+P),M.offset=T,M.count=P;else{M.splitAxis=E.axis;const A=new ns,I=T,S=O-T;M.left=A,ts(e,I,S,A.boundingData,g),x(A,I,S,g,D+1);const z=new ns,V=O,U=P-S;M.right=z,ts(e,V,U,z.boundingData,g),x(z,V,U,g,D+1)}return M}}function zh(o,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=o.geometry;let i,s;if(e.indirect){const r=Hr(n,e.range),a=Lh(n,e.useSharedArrayBuffer,r);o._indirectBuffer=a,i=Jr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{Sh(n,e);const r=$r(n,e.range)[0];i=Jr(n,r.offset,r.count),s=Hr(n,e.range)}o._roots=s.map(r=>{const a=Ih(o,i,r.offset,r.count,e),l=ss(a),c=new t(Le*l);return Eh(0,a,c),c})}class lt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,r=e.length;s<r;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,r=t.length;s<r;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}}lt.prototype.setFromBox=(function(){const o=new _.Vector3;return function(t,n){const i=n.min,s=n.max;let r=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){o.x=i.x*l+s.x*(1-l),o.y=i.y*c+s.y*(1-c),o.z=i.z*h+s.z*(1-h);const d=t.dot(o);r=Math.min(d,r),a=Math.max(d,a)}this.min=r,this.max=a}})();const Bh=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Vector3;return function(i,s,r){const a=i.start,l=o,c=s.start,h=e;t.subVectors(a,c),o.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const d=t.dot(h),m=h.dot(l),p=h.dot(h),f=t.dot(l),g=l.dot(l)*p-m*m;let y,v;g!==0?y=(d*m-f*p)/g:y=0,v=(d+y*m)/p,r.x=y,r.y=v}})(),os=(function(){const o=new _.Vector2,e=new _.Vector3,t=new _.Vector3;return function(i,s,r,a){Bh(i,s,o);let l=o.x,c=o.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,r),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,r);return}else if(c>=0&&c<=1){l<0?i.at(0,r):i.at(1,r),s.closestPointToPoint(r,!0,a);return}else{let h;l<0?h=i.start:h=i.end;let d;c<0?d=s.start:d=s.end;const m=e,p=t;if(i.closestPointToPoint(d,!0,e),s.closestPointToPoint(h,!0,t),m.distanceToSquared(d)<=p.distanceToSquared(h)){r.copy(m),a.copy(d);return}else{r.copy(h),a.copy(p);return}}}})(),Oh=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Plane,n=new _.Line3;return function(s,r){const{radius:a,center:l}=s,{a:c,b:h,c:d}=r;if(n.start=c,n.end=h,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(n.start=h,n.end=d,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const u=r.getPlane(t);if(Math.abs(u.distanceToPoint(l))<=a){const y=u.projectPoint(l,e);if(r.containsPoint(y))return!0}return!1}})(),Rh=["x","y","z"],ct=1e-15,so=ct*ct;function je(o){return Math.abs(o)<ct}class Ge extends _.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _.Vector3),this.satBounds=new Array(4).fill().map(()=>new lt),this.points=[this.a,this.b,this.c],this.plane=new _.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new _.Line3,this.needsUpdate=!0}intersectsSphere(e){return Oh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,r=this.satBounds,a=s[0],l=r[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],h=r[1];c.subVectors(e,t),h.setFromPoints(c,i);const d=s[2],m=r[2];d.subVectors(t,n),m.setFromPoints(d,i);const p=s[3],f=r[3];p.subVectors(n,e),f.setFromPoints(p,i);const u=c.length(),g=d.length(),y=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,u<ct?g<ct||y<ct?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ct?y<ct?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ct&&(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 o=new _.Vector3,e=new _.Vector3,t=new _.Line3;return function(i,s=null,r=null){const{start:a,end:l}=i,c=this.points;let h,d=1/0;for(let m=0;m<3;m++){const p=(m+1)%3;t.start.copy(c[m]),t.end.copy(c[p]),os(t,i,o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),h=a.distanceToSquared(o),h<d&&(d=h,s&&s.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),h=l.distanceToSquared(o),h<d&&(d=h,s&&s.copy(o),r&&r.copy(l)),Math.sqrt(d)}})(),Ge.prototype.intersectsTriangle=(function(){const o=new Ge,e=new lt,t=new lt,n=new _.Vector3,i=new _.Vector3,s=new _.Vector3,r=new _.Vector3,a=new _.Line3,l=new _.Line3,c=new _.Vector3,h=new _.Vector2,d=new _.Vector2;function m(w,x,M,T){const P=n;!w.isDegenerateIntoPoint&&!w.isDegenerateIntoSegment?P.copy(w.plane.normal):P.copy(x.plane.normal);const k=w.satBounds,D=w.satAxes;for(let A=1;A<4;A++){const I=k[A],S=D[A];if(e.setFromPoints(S,x.points),I.isSeparated(e)||(r.copy(P).cross(S),e.setFromPoints(r,w.points),t.setFromPoints(r,x.points),e.isSeparated(t)))return!1}const E=x.satBounds,O=x.satAxes;for(let A=1;A<4;A++){const I=E[A],S=O[A];if(e.setFromPoints(S,w.points),I.isSeparated(e)||(r.crossVectors(P,S),e.setFromPoints(r,w.points),t.setFromPoints(r,x.points),e.isSeparated(t)))return!1}return M&&(T||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function p(w,x,M,T,P,k,D,E,O,A,I){let S=D/(D-E);A.x=T+(P-T)*S,I.start.subVectors(x,w).multiplyScalar(S).add(w),S=D/(D-O),A.y=T+(k-T)*S,I.end.subVectors(M,w).multiplyScalar(S).add(w)}function f(w,x,M,T,P,k,D,E,O,A,I){if(P>0)p(w.c,w.a,w.b,T,x,M,O,D,E,A,I);else if(k>0)p(w.b,w.a,w.c,M,x,T,E,D,O,A,I);else if(E*O>0||D!=0)p(w.a,w.b,w.c,x,M,T,D,E,O,A,I);else if(E!=0)p(w.b,w.a,w.c,M,x,T,E,D,O,A,I);else if(O!=0)p(w.c,w.a,w.b,T,x,M,O,D,E,A,I);else return!0;return!1}function u(w,x,M,T){const P=x.degenerateSegment,k=w.plane.distanceToPoint(P.start),D=w.plane.distanceToPoint(P.end);return je(k)?je(D)?m(w,x,M,T):(M&&(M.start.copy(P.start),M.end.copy(P.start)),w.containsPoint(P.start)):je(D)?(M&&(M.start.copy(P.end),M.end.copy(P.end)),w.containsPoint(P.end)):w.plane.intersectLine(P,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),w.containsPoint(n)):!1}function g(w,x,M){const T=x.a;return je(w.plane.distanceToPoint(T))&&w.containsPoint(T)?(M&&(M.start.copy(T),M.end.copy(T)),!0):!1}function y(w,x,M){const T=w.degenerateSegment,P=x.a;return T.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<so?(M&&(M.start.copy(P),M.end.copy(P)),!0):!1}function v(w,x,M,T){if(w.isDegenerateIntoSegment)if(x.isDegenerateIntoSegment){const P=w.degenerateSegment,k=x.degenerateSegment,D=i,E=s;P.delta(D),k.delta(E);const O=n.subVectors(k.start,P.start),A=D.x*E.y-D.y*E.x;if(je(A))return!1;const I=(O.x*E.y-O.y*E.x)/A,S=-(D.x*O.y-D.y*O.x)/A;if(I<0||I>1||S<0||S>1)return!1;const z=P.start.z+D.z*I,V=k.start.z+E.z*S;return je(z-V)?(M&&(M.start.copy(P.start).addScaledVector(D,I),M.end.copy(P.start).addScaledVector(D,I)),!0):!1}else return x.isDegenerateIntoPoint?y(w,x,M):u(x,w,M,T);else{if(w.isDegenerateIntoPoint)return x.isDegenerateIntoPoint?x.a.distanceToSquared(w.a)<so?(M&&(M.start.copy(w.a),M.end.copy(w.a)),!0):!1:x.isDegenerateIntoSegment?y(x,w,M):g(x,w,M);if(x.isDegenerateIntoPoint)return g(w,x,M);if(x.isDegenerateIntoSegment)return u(w,x,M,T)}}return function(x,M=null,T=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(o.copy(x),o.update(),x=o);const P=v(this,x,M,T);if(P!==void 0)return P;const k=this.plane,D=x.plane;let E=D.distanceToPoint(this.a),O=D.distanceToPoint(this.b),A=D.distanceToPoint(this.c);je(E)&&(E=0),je(O)&&(O=0),je(A)&&(A=0);const I=E*O,S=E*A;if(I>0&&S>0)return!1;let z=k.distanceToPoint(x.a),V=k.distanceToPoint(x.b),U=k.distanceToPoint(x.c);je(z)&&(z=0),je(V)&&(V=0),je(U)&&(U=0);const H=z*V,G=z*U;if(H>0&&G>0)return!1;i.copy(k.normal),s.copy(D.normal);const $=i.cross(s);let F=0,R=Math.abs($.x);const te=Math.abs($.y);te>R&&(R=te,F=1),Math.abs($.z)>R&&(F=2);const q=Rh[F],ce=this.a[q],fe=this.b[q],se=this.c[q],oe=x.a[q],ue=x.b[q],pe=x.c[q];if(f(this,ce,fe,se,I,S,E,O,A,h,a))return m(this,x,M,T);if(f(x,oe,ue,pe,H,G,z,V,U,d,l))return m(this,x,M,T);if(h.y<h.x){const Ce=h.y;h.y=h.x,h.x=Ce,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(d.y<d.x){const Ce=d.y;d.y=d.x,d.x=Ce,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return h.y<d.x||d.y<h.x?!1:(M&&(d.x>h.x?M.start.copy(l.start):M.start.copy(a.start),d.y<h.y?M.end.copy(l.end):M.end.copy(a.end)),!0)}})(),Ge.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ge.prototype.distanceToTriangle=(function(){const o=new _.Vector3,e=new _.Vector3,t=["a","b","c"],n=new _.Line3,i=new _.Line3;return function(r,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(r,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let d=0;d<3;d++){let m;const p=t[d],f=r[p];this.closestPointToPoint(f,o),m=f.distanceToSquared(o),m<h&&(h=m,a&&a.copy(o),l&&l.copy(f));const u=this[p];r.closestPointToPoint(u,o),m=u.distanceToSquared(o),m<h&&(h=m,a&&a.copy(u),l&&l.copy(o))}for(let d=0;d<3;d++){const m=t[d],p=t[(d+1)%3];n.set(this[m],this[p]);for(let f=0;f<3;f++){const u=t[f],g=t[(f+1)%3];i.set(r[u],r[g]),os(n,i,o,e);const y=o.distanceToSquared(e);y<h&&(h=y,a&&a.copy(o),l&&l.copy(e))}}return Math.sqrt(h)}})();class Ie{constructor(e,t,n){this.isOrientedBox=!0,this.min=new _.Vector3,this.max=new _.Vector3,this.matrix=new _.Matrix4,this.invMatrix=new _.Matrix4,this.points=new Array(8).fill().map(()=>new _.Vector3),this.satAxes=new Array(3).fill().map(()=>new _.Vector3),this.satBounds=new Array(3).fill().map(()=>new lt),this.alignedSatBounds=new Array(3).fill().map(()=>new lt),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}}Ie.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){const m=1*c|2*h|4*d,p=i[m];p.x=c?n.x:t.x,p.y=h?n.y:t.y,p.z=d?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,r=this.satAxes,a=i[0];for(let c=0;c<3;c++){const h=r[c],d=s[c],m=1<<c,p=i[m];h.subVectors(a,p),d.setFromPoints(h,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}})(),Ie.prototype.intersectsBox=(function(){const o=new lt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=n.x,o.max=i.x,a[0].isSeparated(o)||(o.min=n.y,o.max=i.y,a[1].isSeparated(o))||(o.min=n.z,o.max=i.z,a[2].isSeparated(o)))return!1;for(let l=0;l<3;l++){const c=r[l],h=s[l];if(o.setFromBox(c,t),h.isSeparated(o))return!1}return!0}})(),Ie.prototype.intersectsTriangle=(function(){const o=new Ge,e=new Array(3),t=new lt,n=new lt,i=new _.Vector3;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let m=0;m<3;m++){const p=a[m],f=l[m];if(t.setFromPoints(f,e),p.isSeparated(t))return!1}const c=r.satBounds,h=r.satAxes,d=this.points;for(let m=0;m<3;m++){const p=c[m],f=h[m];if(t.setFromPoints(f,d),p.isSeparated(t))return!1}for(let m=0;m<3;m++){const p=l[m];for(let f=0;f<4;f++){const u=h[f];if(i.crossVectors(p,u),t.setFromPoints(i,e),n.setFromPoints(i,d),t.isSeparated(n))return!1}}return!0}})(),Ie.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}})(),Ie.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ie.prototype.distanceToBox=(function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new _.Line3),t=new Array(12).fill().map(()=>new _.Line3),n=new _.Vector3,i=new _.Vector3;return function(r,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||c)&&(r.getCenter(i),this.closestPointToPoint(i,n),r.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const h=a*a,d=r.min,m=r.max,p=this.points;let f=1/0;for(let g=0;g<8;g++){const y=p[g];i.copy(y).clamp(d,m);const v=y.distanceToSquared(i);if(v<f&&(f=v,l&&l.copy(y),c&&c.copy(i),v<h))return Math.sqrt(v)}let u=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){const w=(g+1)%3,x=(g+2)%3,M=y<<w|v<<x,T=1<<g|y<<w|v<<x,P=p[M],k=p[T];e[u].set(P,k);const E=o[g],O=o[w],A=o[x],I=t[u],S=I.start,z=I.end;S[E]=d[E],S[O]=y?d[O]:m[O],S[A]=v?d[A]:m[O],z[E]=m[E],z[O]=y?d[O]:m[O],z[A]=v?d[A]:m[O],u++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?m.x:d.x,i.y=y?m.y:d.y,i.z=v?m.z:d.z,this.closestPointToPoint(i,n);const w=i.distanceToSquared(n);if(w<f&&(f=w,l&&l.copy(n),c&&c.copy(i),w<h))return Math.sqrt(w)}for(let g=0;g<12;g++){const y=e[g];for(let v=0;v<12;v++){const w=t[v];os(y,w,n,i);const x=n.distanceToSquared(i);if(x<f&&(f=x,l&&l.copy(n),c&&c.copy(i),x<h))return Math.sqrt(x)}}return Math.sqrt(f)}})();class as{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 Nh extends as{constructor(){super(()=>new Ge)}}const We=new Nh;function Se(o,e){return e[o+15]===qr}function Ue(o,e){return e[o+6]}function Xe(o,e){return e[o+14]}function Pe(o){return o+_e}function Te(o,e){const t=e[o+6];return o+t*_e}function ls(o,e){return e[o+7]}function Kf(o){return o}class Fh{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 Fh;let gt,Kt;const qt=[],ni=new as(()=>new _.Box3);function Uh(o,e,t,n,i,s){gt=ni.getPrimitive(),Kt=ni.getPrimitive(),qt.push(gt,Kt),me.setBuffer(o._roots[e]);const r=cs(0,o.geometry,t,n,i,s);me.clearBuffer(),ni.releasePrimitive(gt),ni.releasePrimitive(Kt),qt.pop(),qt.pop();const a=qt.length;return a>0&&(Kt=qt[a-1],gt=qt[a-2]),r}function cs(o,e,t,n,i=null,s=0,r=0){const{float32Array:a,uint16Array:l,uint32Array:c}=me;let h=o*2;if(Se(h,l)){const m=Ue(o,c),p=Xe(h,l);return ve(o,a,gt),n(m,p,!1,r,s+o/_e,gt)}else{let E=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Se(z,I);)A=Pe(A),z=A*2;return Ue(A,S)},O=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Se(z,I);)A=Te(A,S),z=A*2;return Ue(A,S)+Xe(z,I)};const m=Pe(o),p=Te(o,c);let f=m,u=p,g,y,v,w;if(i&&(v=gt,w=Kt,ve(f,a,v),ve(u,a,w),g=i(v),y=i(w),y<g)){f=p,u=m;const A=g;g=y,y=A,v=w}v||(v=gt,ve(f,a,v));const x=Se(f*2,l),M=t(v,x,g,r+1,s+f/_e);let T;if(M===Yr){const A=E(f),S=O(f)-A;T=n(A,S,!0,r+1,s+f/_e,v)}else T=M&&cs(f,e,t,n,i,s,r+1);if(T)return!0;w=Kt,ve(u,a,w);const P=Se(u*2,l),k=t(w,P,y,r+1,s+u/_e);let D;if(k===Yr){const A=E(u),S=O(u)-A;D=n(A,S,!0,r+1,s+u/_e,w)}else D=k&&cs(u,e,t,n,i,s,r+1);return!!D}}const pn=new _.Vector3,hs=new _.Vector3;function Vh(o,e,t={},n=0,i=1/0){const s=n*n,r=i*i;let a=1/0,l=null;if(o.shapecast({boundsTraverseOrder:h=>(pn.copy(e).clamp(h.min,h.max),pn.distanceToSquared(e)),intersectsBounds:(h,d,m)=>m<a&&m<r,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,pn);const m=e.distanceToSquared(pn);return m<a&&(hs.copy(pn),a=m,l=d),m<s}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(hs):t.point=hs.clone(),t.distance=c,t.faceIndex=l,t}const ii=parseInt(_.REVISION)>=169,jh=parseInt(_.REVISION)<=161,Et=new _.Vector3,Lt=new _.Vector3,It=new _.Vector3,si=new _.Vector2,ri=new _.Vector2,oi=new _.Vector2,ro=new _.Vector3,oo=new _.Vector3,ao=new _.Vector3,mn=new _.Vector3;function Gh(o,e,t,n,i,s,r,a){let l;if(s===_.BackSide?l=o.intersectTriangle(n,t,e,!0,i):l=o.intersectTriangle(e,t,n,s!==_.DoubleSide,i),l===null)return null;const c=o.origin.distanceTo(i);return c<r||c>a?null:{distance:c,point:i.clone()}}function lo(o,e,t,n,i,s,r,a,l,c,h){Et.fromBufferAttribute(e,s),Lt.fromBufferAttribute(e,r),It.fromBufferAttribute(e,a);const d=Gh(o,Et,Lt,It,mn,l,c,h);if(d){if(n){si.fromBufferAttribute(n,s),ri.fromBufferAttribute(n,r),oi.fromBufferAttribute(n,a),d.uv=new _.Vector2;const p=_.Triangle.getInterpolation(mn,Et,Lt,It,si,ri,oi,d.uv);ii||(d.uv=p)}if(i){si.fromBufferAttribute(i,s),ri.fromBufferAttribute(i,r),oi.fromBufferAttribute(i,a),d.uv1=new _.Vector2;const p=_.Triangle.getInterpolation(mn,Et,Lt,It,si,ri,oi,d.uv1);ii||(d.uv1=p),jh&&(d.uv2=d.uv1)}if(t){ro.fromBufferAttribute(t,s),oo.fromBufferAttribute(t,r),ao.fromBufferAttribute(t,a),d.normal=new _.Vector3;const p=_.Triangle.getInterpolation(mn,Et,Lt,It,ro,oo,ao,d.normal);d.normal.dot(o.direction)>0&&d.normal.multiplyScalar(-1),ii||(d.normal=p)}const m={a:s,b:r,c:a,normal:new _.Vector3,materialIndex:0};if(_.Triangle.getNormal(Et,Lt,It,m.normal),d.face=m,d.faceIndex=s,ii){const p=new _.Vector3;_.Triangle.getBarycoord(mn,Et,Lt,It,p),d.barycoord=p}}return d}function co(o){return o&&o.isMaterial?o.side:o}function ai(o,e,t,n,i,s,r){const a=n*3;let l=a+0,c=a+1,h=a+2;const{index:d,groups:m}=o;o.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:p,normal:f,uv:u,uv1:g}=o.attributes;if(Array.isArray(e)){const y=n*3;for(let v=0,w=m.length;v<w;v++){const{start:x,count:M,materialIndex:T}=m[v];if(y>=x&&y<x+M){const P=co(e[T]),k=lo(t,p,f,u,g,l,c,h,P,s,r);if(k)if(k.faceIndex=n,k.face.materialIndex=T,i)i.push(k);else return k}}}else{const y=co(e),v=lo(t,p,f,u,g,l,c,h,y,s,r);if(v)if(v.faceIndex=n,v.face.materialIndex=0,i)i.push(v);else return v}return null}function be(o,e,t,n){const i=o.a,s=o.b,r=o.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),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),r.x=n.getX(c),r.y=n.getY(c),r.z=n.getZ(c)}function Wh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:c}=o;for(let h=n,d=n+i;h<d;h++)ai(l,e,t,h,s,r,a)}function Xh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let c=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=ai(a,e,t,d,null,s,r),p&&p.distance<c&&(h=p,c=p.distance)}return h}function Zh(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=o,d=e+o;h<d;h++){let m;if(m=h,be(r,m*3,l,c),r.needsUpdate=!0,n(r,m,i,s))return!0}return!1}function Yh(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,r,a,l,c=0;const h=o._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,c),c+=s.byteLength;function d(m,p,f=!1){const u=m*2;if(Se(u,a)){const g=r[m+6],y=a[u+14];let v=1/0,w=1/0,x=1/0,M=-1/0,T=-1/0,P=-1/0;for(let k=3*g,D=3*(g+y);k<D;k++){let E=n[k];const O=i.getX(E),A=i.getY(E),I=i.getZ(E);O<v&&(v=O),O>M&&(M=O),A<w&&(w=A),A>T&&(T=A),I<x&&(x=I),I>P&&(P=I)}return l[m+0]!==v||l[m+1]!==w||l[m+2]!==x||l[m+3]!==M||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=w,l[m+2]=x,l[m+3]=M,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Pe(m),y=Te(m,r);let v=f,w=!1,x=!1;if(e){if(!v){const E=g/_e+p/Le,O=y/_e+p/Le;w=e.has(E),x=e.has(O),v=!w&&!x}}else w=!0,x=!0;const M=v||w,T=v||x;let P=!1;M&&(P=d(g,p,v));let k=!1;T&&(k=d(y,p,v));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,A=y+E,I=l[O],S=l[O+3],z=l[A],V=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>V?S:V}return D}}}function yt(o,e,t,n,i){let s,r,a,l,c,h;const d=1/t.direction.x,m=1/t.direction.y,p=1/t.direction.z,f=t.origin.x,u=t.origin.y,g=t.origin.z;let y=e[o],v=e[o+3],w=e[o+1],x=e[o+3+1],M=e[o+2],T=e[o+3+2];return d>=0?(s=(y-f)*d,r=(v-f)*d):(s=(v-f)*d,r=(y-f)*d),m>=0?(a=(w-u)*m,l=(x-u)*m):(a=(x-u)*m,l=(w-u)*m),s>l||a>r||((a>s||isNaN(s))&&(s=a),(l<r||isNaN(r))&&(r=l),p>=0?(c=(M-g)*p,h=(T-g)*p):(c=(T-g)*p,h=(M-g)*p),s>h||c>r)?!1:((c>s||s!==s)&&(s=c),(h<r||r!==r)&&(r=h),s<=i&&r>=n)}function Kh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:c}=o;for(let h=n,d=n+i;h<d;h++){let m=c?c[h]:h;ai(l,e,t,m,s,r,a)}}function qh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let c=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=ai(a,e,t,l?l[d]:d,null,s,r),p&&p.distance<c&&(h=p,c=p.distance)}return h}function $h(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=o,d=e+o;h<d;h++){let m;if(m=t.resolveTriangleIndex(h),be(r,m*3,l,c),r.needsUpdate=!0,n(r,m,i,s))return!0}return!1}function Hh(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),us(0,o,t,n,i,s,r),me.clearBuffer()}function us(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:c}=me,h=o*2;if(Se(h,l)){const m=Ue(o,c),p=Xe(h,l);Wh(e,t,n,m,p,i,s,r)}else{const m=Pe(o);yt(m,a,n,s,r)&&us(m,e,t,n,i,s,r);const p=Te(o,c);yt(p,a,n,s,r)&&us(p,e,t,n,i,s,r)}}const Jh=["x","y","z"];function Qh(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=ds(0,o,t,n,i,s);return me.clearBuffer(),r}function ds(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let c=o*2;if(Se(c,a)){const d=Ue(o,l),m=Xe(c,a);return Xh(e,t,n,d,m,i,s)}else{const d=ls(o,l),m=Jh[d],f=n.direction[m]>=0;let u,g;f?(u=Pe(o),g=Te(o,l)):(u=Te(o,l),g=Pe(o));const v=yt(u,r,n,i,s)?ds(u,e,t,n,i,s):null;if(v){const M=v.point[m];if(f?M<=r[g+d]:M>=r[g+d+3])return v}const x=yt(g,r,n,i,s)?ds(g,e,t,n,i,s):null;return v&&x?v.distance<=x.distance?v:x:v||x||null}}const li=new _.Box3,$t=new Ge,Ht=new Ge,gn=new _.Matrix4,ho=new Ie,ci=new Ie;function eu(o,e,t,n){me.setBuffer(o._roots[e]);const i=fs(0,o,t,n);return me.clearBuffer(),i}function fs(o,e,t,n,i=null){const{float32Array:s,uint16Array:r,uint32Array:a}=me;let l=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),ho.set(t.boundingBox.min,t.boundingBox.max,n),i=ho),Se(l,r)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,f=t.attributes.position,u=Ue(o,a),g=Xe(l,r);if(gn.copy(n).invert(),t.boundsTree)return ve(o,s,ci),ci.matrix.copy(gn),ci.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>ci.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let w=u*3,x=(g+u)*3;w<x;w+=3)if(be(Ht,w,d,m),Ht.needsUpdate=!0,v.intersectsTriangle(Ht))return!0;return!1}});{const y=kt(t);for(let v=u*3,w=(g+u)*3;v<w;v+=3){be($t,v,d,m),$t.a.applyMatrix4(gn),$t.b.applyMatrix4(gn),$t.c.applyMatrix4(gn),$t.needsUpdate=!0;for(let x=0,M=y*3;x<M;x+=3)if(be(Ht,x,p,f),Ht.needsUpdate=!0,$t.intersectsTriangle(Ht))return!0}}}else{const h=Pe(o),d=Te(o,a);return ve(h,s,li),!!(i.intersectsBox(li)&&fs(h,e,t,n,i)||(ve(d,s,li),i.intersectsBox(li)&&fs(d,e,t,n,i)))}}const hi=new _.Matrix4,ps=new Ie,yn=new Ie,tu=new _.Vector3,nu=new _.Vector3,iu=new _.Vector3,su=new _.Vector3;function ru(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ps.set(e.boundingBox.min,e.boundingBox.max,t),ps.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,m=We.getPrimitive(),p=We.getPrimitive();let f=tu,u=nu,g=null,y=null;i&&(g=iu,y=su);let v=1/0,w=null,x=null;return hi.copy(t).invert(),yn.matrix.copy(hi),o.shapecast({boundsTraverseOrder:M=>ps.distanceToBox(M),intersectsBounds:(M,T,P)=>P<v&&P<r?(T&&(yn.min.copy(M.min),yn.max.copy(M.max),yn.needsUpdate=!0),!0):!1,intersectsRange:(M,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>yn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<v&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){be(p,3*E,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let A=M,I=M+T;A<I;A++){be(m,3*A,c,l),m.needsUpdate=!0;const S=m.distanceToTriangle(p,f,g);if(S<v&&(u.copy(f),y&&y.copy(g),v=S,w=A,x=E),S<s)return!0}}}});{const P=kt(e);for(let k=0,D=P;k<D;k++){be(p,3*k,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=M,O=M+T;E<O;E++){be(m,3*E,c,l),m.needsUpdate=!0;const A=m.distanceToTriangle(p,f,g);if(A<v&&(u.copy(f),y&&y.copy(g),v=A,w=E,x=k),A<s)return!0}}}}}),We.releasePrimitive(m),We.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(u):n.point=u.clone(),n.distance=v,n.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(hi),u.applyMatrix4(hi),i.distance=u.sub(i.point).length(),i.faceIndex=x),n)}function ou(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,r,a,l,c=0;const h=o._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,c),c+=s.byteLength;function d(m,p,f=!1){const u=m*2;if(Se(u,a)){const g=r[m+6],y=a[u+14];let v=1/0,w=1/0,x=1/0,M=-1/0,T=-1/0,P=-1/0;for(let k=g,D=g+y;k<D;k++){const E=3*o.resolveTriangleIndex(k);for(let O=0;O<3;O++){let A=E+O;A=n?n[A]:A;const I=i.getX(A),S=i.getY(A),z=i.getZ(A);I<v&&(v=I),I>M&&(M=I),S<w&&(w=S),S>T&&(T=S),z<x&&(x=z),z>P&&(P=z)}}return l[m+0]!==v||l[m+1]!==w||l[m+2]!==x||l[m+3]!==M||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=w,l[m+2]=x,l[m+3]=M,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Pe(m),y=Te(m,r);let v=f,w=!1,x=!1;if(e){if(!v){const E=g/_e+p/Le,O=y/_e+p/Le;w=e.has(E),x=e.has(O),v=!w&&!x}}else w=!0,x=!0;const M=v||w,T=v||x;let P=!1;M&&(P=d(g,p,v));let k=!1;T&&(k=d(y,p,v));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,A=y+E,I=l[O],S=l[O+3],z=l[A],V=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>V?S:V}return D}}}function au(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),ms(0,o,t,n,i,s,r),me.clearBuffer()}function ms(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:c}=me,h=o*2;if(Se(h,l)){const m=Ue(o,c),p=Xe(h,l);Kh(e,t,n,m,p,i,s,r)}else{const m=Pe(o);yt(m,a,n,s,r)&&ms(m,e,t,n,i,s,r);const p=Te(o,c);yt(p,a,n,s,r)&&ms(p,e,t,n,i,s,r)}}const lu=["x","y","z"];function cu(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=gs(0,o,t,n,i,s);return me.clearBuffer(),r}function gs(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let c=o*2;if(Se(c,a)){const d=Ue(o,l),m=Xe(c,a);return qh(e,t,n,d,m,i,s)}else{const d=ls(o,l),m=lu[d],f=n.direction[m]>=0;let u,g;f?(u=Pe(o),g=Te(o,l)):(u=Te(o,l),g=Pe(o));const v=yt(u,r,n,i,s)?gs(u,e,t,n,i,s):null;if(v){const M=v.point[m];if(f?M<=r[g+d]:M>=r[g+d+3])return v}const x=yt(g,r,n,i,s)?gs(g,e,t,n,i,s):null;return v&&x?v.distance<=x.distance?v:x:v||x||null}}const ui=new _.Box3,Jt=new Ge,Qt=new Ge,vn=new _.Matrix4,uo=new Ie,di=new Ie;function hu(o,e,t,n){me.setBuffer(o._roots[e]);const i=ys(0,o,t,n);return me.clearBuffer(),i}function ys(o,e,t,n,i=null){const{float32Array:s,uint16Array:r,uint32Array:a}=me;let l=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),uo.set(t.boundingBox.min,t.boundingBox.max,n),i=uo),Se(l,r)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,f=t.attributes.position,u=Ue(o,a),g=Xe(l,r);if(vn.copy(n).invert(),t.boundsTree)return ve(o,s,di),di.matrix.copy(vn),di.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>di.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let w=u,x=g+u;w<x;w++)if(be(Qt,3*e.resolveTriangleIndex(w),d,m),Qt.needsUpdate=!0,v.intersectsTriangle(Qt))return!0;return!1}});{const y=kt(t);for(let v=u,w=g+u;v<w;v++){const x=e.resolveTriangleIndex(v);be(Jt,3*x,d,m),Jt.a.applyMatrix4(vn),Jt.b.applyMatrix4(vn),Jt.c.applyMatrix4(vn),Jt.needsUpdate=!0;for(let M=0,T=y*3;M<T;M+=3)if(be(Qt,M,p,f),Qt.needsUpdate=!0,Jt.intersectsTriangle(Qt))return!0}}}else{const h=Pe(o),d=Te(o,a);return ve(h,s,ui),!!(i.intersectsBox(ui)&&ys(h,e,t,n,i)||(ve(d,s,ui),i.intersectsBox(ui)&&ys(d,e,t,n,i)))}}const fi=new _.Matrix4,vs=new Ie,wn=new Ie,uu=new _.Vector3,du=new _.Vector3,fu=new _.Vector3,pu=new _.Vector3;function mu(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),vs.set(e.boundingBox.min,e.boundingBox.max,t),vs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,m=We.getPrimitive(),p=We.getPrimitive();let f=uu,u=du,g=null,y=null;i&&(g=fu,y=pu);let v=1/0,w=null,x=null;return fi.copy(t).invert(),wn.matrix.copy(fi),o.shapecast({boundsTraverseOrder:M=>vs.distanceToBox(M),intersectsBounds:(M,T,P)=>P<v&&P<r?(T&&(wn.min.copy(M.min),wn.max.copy(M.max),wn.needsUpdate=!0),!0):!1,intersectsRange:(M,T)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>wn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<v&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){const A=P.resolveTriangleIndex(E);be(p,3*A,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let I=M,S=M+T;I<S;I++){const z=o.resolveTriangleIndex(I);be(m,3*z,c,l),m.needsUpdate=!0;const V=m.distanceToTriangle(p,f,g);if(V<v&&(u.copy(f),y&&y.copy(g),v=V,w=I,x=E),V<s)return!0}}}})}else{const P=kt(e);for(let k=0,D=P;k<D;k++){be(p,3*k,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=M,O=M+T;E<O;E++){const A=o.resolveTriangleIndex(E);be(m,3*A,c,l),m.needsUpdate=!0;const I=m.distanceToTriangle(p,f,g);if(I<v&&(u.copy(f),y&&y.copy(g),v=I,w=E,x=k),I<s)return!0}}}}}),We.releasePrimitive(m),We.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(u):n.point=u.clone(),n.distance=v,n.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(fi),u.applyMatrix4(fi),i.distance=u.sub(i.point).length(),i.faceIndex=x),n)}function gu(){return typeof SharedArrayBuffer<"u"}const xn=new me.constructor,pi=new me.constructor,vt=new as(()=>new _.Box3),en=new _.Box3,tn=new _.Box3,ws=new _.Box3,xs=new _.Box3;let bs=!1;function yu(o,e,t,n){if(bs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bs=!0;const i=o._roots,s=e._roots;let r,a=0,l=0;const c=new _.Matrix4().copy(t).invert();for(let h=0,d=i.length;h<d;h++){xn.setBuffer(i[h]),l=0;const m=vt.getPrimitive();ve(0,xn.float32Array,m),m.applyMatrix4(c);for(let p=0,f=s.length;p<f&&(pi.setBuffer(s[p]),r=Ke(0,0,t,c,n,a,l,0,0,m),pi.clearBuffer(),l+=s[p].byteLength/Le,!r);p++);if(vt.releasePrimitive(m),xn.clearBuffer(),a+=i[h].byteLength/Le,r)break}return bs=!1,r}function Ke(o,e,t,n,i,s=0,r=0,a=0,l=0,c=null,h=!1){let d,m;h?(d=pi,m=xn):(d=xn,m=pi);const p=d.float32Array,f=d.uint32Array,u=d.uint16Array,g=m.float32Array,y=m.uint32Array,v=m.uint16Array,w=o*2,x=e*2,M=Se(w,u),T=Se(x,v);let P=!1;if(T&&M)h?P=i(Ue(e,y),Xe(e*2,v),Ue(o,f),Xe(o*2,u),l,r+e/_e,a,s+o/_e):P=i(Ue(o,f),Xe(o*2,u),Ue(e,y),Xe(e*2,v),a,s+o/_e,l,r+e/_e);else if(T){const k=vt.getPrimitive();ve(e,g,k),k.applyMatrix4(t);const D=Pe(o),E=Te(o,f);ve(D,p,en),ve(E,p,tn);const O=k.intersectsBox(en),A=k.intersectsBox(tn);P=O&&Ke(e,D,n,t,i,r,s,l,a+1,k,!h)||A&&Ke(e,E,n,t,i,r,s,l,a+1,k,!h),vt.releasePrimitive(k)}else{const k=Pe(e),D=Te(e,y);ve(k,g,ws),ve(D,g,xs);const E=c.intersectsBox(ws),O=c.intersectsBox(xs);if(E&&O)P=Ke(o,k,t,n,i,s,r,a,l+1,c,h)||Ke(o,D,t,n,i,s,r,a,l+1,c,h);else if(E)if(M)P=Ke(o,k,t,n,i,s,r,a,l+1,c,h);else{const A=vt.getPrimitive();A.copy(ws).applyMatrix4(t);const I=Pe(o),S=Te(o,f);ve(I,p,en),ve(S,p,tn);const z=A.intersectsBox(en),V=A.intersectsBox(tn);P=z&&Ke(k,I,n,t,i,r,s,l,a+1,A,!h)||V&&Ke(k,S,n,t,i,r,s,l,a+1,A,!h),vt.releasePrimitive(A)}else if(O)if(M)P=Ke(o,D,t,n,i,s,r,a,l+1,c,h);else{const A=vt.getPrimitive();A.copy(xs).applyMatrix4(t);const I=Pe(o),S=Te(o,f);ve(I,p,en),ve(S,p,tn);const z=A.intersectsBox(en),V=A.intersectsBox(tn);P=z&&Ke(D,I,n,t,i,r,s,l,a+1,A,!h)||V&&Ke(D,S,n,t,i,r,s,l,a+1,A,!h),vt.releasePrimitive(A)}}return P}const mi=new Ie,fo=new _.Box3,vu={strategy:Zr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ms{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,r=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(l=>l.slice()),a.index=r?r.array.slice():null,a.indirectBuffer=s?s.slice():null):(a.roots=i,a.index=r?r.array:null,a.indirectBuffer=s),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:r}=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 Ms(t,{...n,[es]:!0});if(a._roots=s,a._indirectBuffer=r||null,n.setIndex){const c=t.getIndex();if(c===null){const h=new _.BufferAttribute(e.index,1,!1);t.setIndex(h)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return a;function l(c){for(let h=0;h<c.length;h++){const d=c[h],m=new Uint32Array(d),p=new Uint16Array(d);for(let f=0,u=d.byteLength/Le;f<u;f++){const g=_e*f,y=2*g;Se(y,p)||(m[g+6]=m[g+6]/_e-f)}}}}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({...vu,[es]:!1},t),t.useSharedArrayBuffer&&!gu())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[es]||(zh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new _.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],r=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Le;for(let c=0;c<l;c++){const h=_e*c,d=2*h;Se(d,a)&&(r[h+6]+=e)}}}}refit(e=null){return(this.indirect?ou:Yh)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);r(0);function r(a,l=0){const c=a*2,h=Se(c,s);if(h){const d=i[a+6],m=s[c+14];e(l,h,new Float32Array(n,a*4,6),d,m)}else{const d=Pe(a),m=Te(a,i),p=ls(a,i);e(l,h,new Float32Array(n,a*4,6),p)||(r(d,l+1),r(m,l+1))}}}raycast(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots,r=[],a=this.indirect?au:Hh;for(let l=0,c=s.length;l<c;l++)a(this,l,t,e,r,n,i);return r}raycastFirst(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots;let r=null;const a=this.indirect?cu:Qh;for(let l=0,c=s.length;l<c;l++){const h=a(this,l,t,e,n,i);h!=null&&(r==null||h.distance<r.distance)&&(r=h)}return r}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?hu:eu;for(let r=0,a=i.length;r<a&&(n=s(this,r,e,t),!n);r++);return n}shapecast(e){const t=We.getPrimitive(),n=this.indirect?$h:Zh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const d=r;r=(m,p,f,u,g)=>d(m,p,f,u,g)?!0:n(m,p,this,a,f,u,t)}else r||(a?r=(d,m,p,f)=>n(d,m,this,a,p,f,t):r=(d,m,p)=>p);let l=!1,c=0;const h=this._roots;for(let d=0,m=h.length;d<m;d++){const p=h[d];if(l=Uh(this,d,s,r,i,c),l)break;c+=p.byteLength/Le}return We.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const r=We.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?f=>{const u=this.resolveTriangleIndex(f);be(r,u*3,a,l)}:f=>{be(r,f*3,a,l)},h=We.getPrimitive(),d=e.geometry.index,m=e.geometry.attributes.position,p=e.indirect?f=>{const u=e.resolveTriangleIndex(f);be(h,u*3,d,m)}:f=>{be(h,f*3,d,m)};if(s){const f=(u,g,y,v,w,x,M,T)=>{for(let P=y,k=y+v;P<k;P++){p(P),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let D=u,E=u+g;D<E;D++)if(c(D),r.needsUpdate=!0,s(r,h,D,P,w,x,M,T))return!0}return!1};if(i){const u=i;i=function(g,y,v,w,x,M,T,P){return u(g,y,v,w,x,M,T,P)?!0:f(g,y,v,w,x,M,T,P)}}else i=f}return yu(this,e,t,i)}intersectsBox(e,t){return mi.set(e.min,e.max,t),mi.needsUpdate=!0,this.shapecast({intersectsBounds:n=>mi.intersectsBox(n),intersectsTriangle:n=>mi.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,r=1/0){return(this.indirect?mu:ru)(this,e,t,n,i,s,r)}closestPointToPoint(e,t={},n=0,i=1/0){return Vh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ve(0,new Float32Array(n),fo),e.union(fo)}),e}}const po=1e-6,wu=po*.5,mo=Math.pow(10,-Math.log10(po)),xu=wu*mo;function tt(o){return~~(o*mo+xu)}function bu(o){return`${tt(o.x)},${tt(o.y)}`}function go(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)}`}function Mu(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)},${tt(o.w)}`}function _u(o,e,t){t.direction.subVectors(e,o).normalize();const n=o.dot(t.direction);return t.origin.copy(o).addScaledVector(t.direction,-n),t}function yo(){return typeof SharedArrayBuffer<"u"}function Su(o){if(o.buffer instanceof SharedArrayBuffer)return o;const e=o.constructor,t=o.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function Cu(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Au(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Cu(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Pu(o){return o.index?o.index.count:o.attributes.position.count}function _s(o){return Pu(o)/3}const Tu=1e-8,Du=new _.Vector3;function ku(o){return~~(o/3)}function Eu(o){return o%3}function vo(o,e){return o.start-e.start}function wo(o,e){return Du.subVectors(e,o.origin).dot(o.direction)}function Lu(o,e,t,n=Tu){o.sort(vo),e.sort(vo);for(let a=0;a<o.length;a++){const l=o[a];for(let c=0;c<e.length;c++){const h=e[c];if(!(h.start>l.end)){if(l.end<h.start||h.end<l.start)continue;if(l.start<=h.start&&l.end>=h.end)s(h.end,l.end)||o.splice(a+1,0,{start:h.end,end:l.end,index:l.index}),l.end=h.start,h.start=0,h.end=0;else if(l.start>=h.start&&l.end<=h.end)s(l.end,h.end)||e.splice(c+1,0,{start:l.end,end:h.end,index:h.index}),h.end=l.start,l.start=0,l.end=0;else if(l.start<=h.start&&l.end<=h.end){const d=l.end;l.end=h.start,h.start=d}else if(l.start>=h.start&&l.end>=h.end){const d=h.end;h.end=l.start,l.start=d}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(h.index)||t.set(h.index,[]),t.get(l.index).push(h.index),t.get(h.index).push(l.index),r(h)&&(e.splice(c,1),c--),r(l)){o.splice(a,1),a--;break}}}i(o),i(e);function i(a){for(let l=0;l<a.length;l++)r(a[l])&&(a.splice(l,1),l--)}function s(a,l){return Math.abs(l-a)<n}function r(a){return Math.abs(a.end-a.start)<n}}const xo=1e-5,bo=1e-4;class Iu{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,c=t.length;l<c;l++){const h=t[l];if(r(h,e)&&r(h,n))continue;const d=a(h,e),m=a(h,n),p=Math.min(d,m);p<i&&(i=p,s=h)}return s;function r(l,c){const h=l.origin.distanceTo(c.origin)>xo;return l.direction.angleTo(c.direction)>bo||h}function a(l,c){const h=l.origin.distanceTo(c.origin),d=l.direction.angleTo(c.direction);return h/xo+d/bo}}}const Ss=new _.Vector3,Cs=new _.Vector3,gi=new _.Ray;function zu(o,e,t){const n=o.attributes,i=o.index,s=n.position,r=new Map,a=new Map,l=Array.from(e),c=new Iu;for(let h=0,d=l.length;h<d;h++){const m=l[h],p=ku(m),f=Eu(m);let u=3*p+f,g=3*p+(f+1)%3;i&&(u=i.getX(u),g=i.getX(g)),Ss.fromBufferAttribute(s,u),Cs.fromBufferAttribute(s,g),_u(Ss,Cs,gi);let y,v=c.findClosestRay(gi);v===null&&(v=gi.clone(),c.addRay(v)),a.has(v)||a.set(v,{forward:[],reverse:[],ray:v}),y=a.get(v);let w=wo(v,Ss),x=wo(v,Cs);w>x&&([w,x]=[x,w]),gi.direction.dot(v.direction)<0?y.reverse.push({start:w,end:x,index:m}):y.forward.push({start:w,end:x,index:m})}return a.forEach(({forward:h,reverse:d},m)=>{Lu(h,d,r,t),h.length===0&&d.length===0&&a.delete(m)}),{disjointConnectivityMap:r,fragmentMap:a}}const Bu=new _.Vector2,As=new _.Vector3,Ou=new _.Vector4,Ps=["","",""];class Ru{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,r=t?w:v,a=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,d=l.position;let m=_s(e);const p=m;let f=0;n&&(f=e.drawRange.start,e.drawRange.count!==1/0&&(m=~~(e.drawRange.count/3)));let u=this.data;(!u||u.length<3*p)&&(u=new Int32Array(3*p)),u.fill(-1);let g=0,y=new Set;for(let x=f,M=m*3+f;x<M;x+=3){const T=x;for(let P=0;P<3;P++){let k=T+P;h&&(k=h.getX(k)),Ps[P]=r(k)}for(let P=0;P<3;P++){const k=(P+1)%3,D=Ps[P],E=Ps[k],O=`${E}_${D}`;if(a.has(O)){const A=T+P,I=a.get(O);u[A]=I,u[I]=A,a.delete(O),g+=2,y.delete(I)}else{const A=`${D}_${E}`,I=T+P;a.set(A,I),y.add(I)}}}if(i){const{fragmentMap:x,disjointConnectivityMap:M}=zu(e,y,s);y.clear(),x.forEach(({forward:T,reverse:P})=>{T.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=x,this.disjointConnections=M,g=m*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=u;function v(x){return As.fromBufferAttribute(d,x),go(As)}function w(x){let M="";for(let T=0,P=c.length;T<P;T++){const k=l[c[T]];let D;switch(k.itemSize){case 1:D=tt(k.getX(x));break;case 2:D=bu(Bu.fromBufferAttribute(k,x));break;case 3:D=go(As.fromBufferAttribute(k,x));break;case 4:D=Mu(Ou.fromBufferAttribute(k,x));break}M!==""&&(M+="|"),M+=D}return M}}}class yi extends _.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new _.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=yo();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=Su(s.array)}if(e.boundsTree||(Au(e,{useSharedArrayBuffer:n}),e.boundsTree=new Ms(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Ru(e)),!e.groupIndices){const i=_s(e),s=new Uint16Array(i),r=e.groups;for(let a=0,l=r.length;a<l;a++){const{start:c,count:h}=r[a];for(let d=c/3,m=(c+h)/3;d<m;d++)s[d]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Nu=1e-14,Ts=new _.Vector3,Mo=new _.Vector3,_o=new _.Vector3;function wt(o,e=Nu){Ts.subVectors(o.b,o.a),Mo.subVectors(o.c,o.a),_o.subVectors(o.b,o.c);const t=Ts.angleTo(Mo),n=Ts.angleTo(_o),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||o.a.distanceToSquared(o.b)<e||o.a.distanceToSquared(o.c)<e||o.b.distanceToSquared(o.c)<e}const Ds=1e-10,bn=1e-10,Fu=1e-10,ht=new _.Line3,we=new _.Line3,ut=new _.Vector3,ks=new _.Vector3,So=new _.Vector3,vi=new _.Plane,Es=new Ge;class Uu{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new _.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class Vu{constructor(){this.trianglePool=new Uu,this.triangles=[],this.normal=new _.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,r=e.length;s<r;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(ut).dot(i))>Ds)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(ks).normalize(),Math.abs(1-Math.abs(ks.dot(t)))<Fu){this.coplanarTriangleUsed=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];a.coplanarCount=0}const i=[e.a,e.b,e.c];for(let s=0;s<3;s++){const r=(s+1)%3,a=i[s],l=i[r];ut.subVectors(l,a).normalize(),So.crossVectors(ks,ut),vi.setFromNormalAndCoplanarPoint(So,a),this.splitByPlane(vi,e)}}else e.getPlane(vi),this.splitByPlane(vi,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;Es.copy(t),Es.needsUpdate=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];if(!Es.intersectsTriangle(a,ht,!0))continue;const{a:l,b:c,c:h}=a;let d=0,m=-1,p=!1,f=[],u=[];const g=[l,c,h];for(let y=0;y<3;y++){const v=(y+1)%3;ht.start.copy(g[y]),ht.end.copy(g[v]);const w=e.distanceToPoint(ht.start),x=e.distanceToPoint(ht.end);if(Math.abs(w)<bn&&Math.abs(x)<bn){p=!0;break}if(w>0?f.push(y):u.push(y),Math.abs(w)<bn)continue;let M=!!e.intersectLine(ht,ut);!M&&Math.abs(x)<bn&&(ut.copy(ht.end),M=!0),M&&!(ut.distanceTo(ht.start)<Ds)&&(ut.distanceTo(ht.end)<Ds&&(m=y),d===0?we.start.copy(ut):we.end.copy(ut),d++)}if(!p&&d===2&&we.distance()>bn)if(m!==-1){m=(m+1)%3;let y=0;y===m&&(y=(y+1)%3);let v=y+1;v===m&&(v=(v+1)%3);const w=i.getTriangle();w.a.copy(g[v]),w.b.copy(we.end),w.c.copy(we.start),wt(w)||n.push(w),a.a.copy(g[y]),a.b.copy(we.start),a.c.copy(we.end),wt(a)&&(n.splice(s,1),s--,r--)}else{const y=f.length>=2?u[0]:f[0];if(y===0){let T=we.start;we.start=we.end,we.end=T}const v=(y+1)%3,w=(y+2)%3,x=i.getTriangle(),M=i.getTriangle();g[v].distanceToSquared(we.start)<g[w].distanceToSquared(we.end)?(x.a.copy(g[v]),x.b.copy(we.start),x.c.copy(we.end),M.a.copy(g[v]),M.b.copy(g[w]),M.c.copy(we.start)):(x.a.copy(g[w]),x.b.copy(we.start),x.c.copy(we.end),M.a.copy(g[v]),M.b.copy(g[w]),M.c.copy(we.end)),a.a.copy(g[y]),a.b.copy(we.end),a.c.copy(we.start),wt(x)||n.push(x),wt(M)||n.push(M),wt(a)&&(n.splice(s,1),s--,r--)}else d===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function ju(o){return o=~~o,o+4-o%4}class Co{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=yo()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(ju(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 Gu{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 r=n[s];i+=r[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 r=n[s],a=new Co(r.type);a.itemSize=r.itemSize,a.normalized=r.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,c=s.length;l<c;l++){const h=s[l][e];h.setType(t),h.itemSize=n,h.normalized=i}}else for(let l=0,c=s.length;l<c;l++){const h=new Co(t);h.itemSize=n,h.normalized=i,s[l][e]=h}}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 Ao{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 Wu=0,Xu=1,Zu=2,Po=3,Yu=4,To=5,Do=6,Ze=new _.Ray,ko=new _.Matrix4,ze=new _.Triangle,dt=new _.Vector3,Eo=new _.Vector4,Lo=new _.Vector4,Io=new _.Vector4,Ls=new _.Vector4,wi=new _.Vector4,xi=new _.Vector4,zo=new _.Line3,Is=new _.Vector3,zs=1e-8,Ku=1e-15,zt=-1,Bt=1,bi=-2,Mi=2,Mn=0,Ot=1,Bs=2,qu=1e-14;let _i=null;function Bo(o){_i=o}function Oo(o,e){o.getMidpoint(Ze.origin),o.getNormal(Ze.direction);const t=e.raycastFirst(Ze,_.DoubleSide);return!!(t&&Ze.direction.dot(t.face.normal)>0)?zt:Bt}function $u(o,e){function t(){return Math.random()-.5}o.getNormal(Is),Ze.direction.copy(Is),o.getMidpoint(Ze.origin);const n=3;let i=0,s=1/0;for(let r=0;r<n;r++){Ze.direction.x+=t()*zs,Ze.direction.y+=t()*zs,Ze.direction.z+=t()*zs,Ze.direction.multiplyScalar(-1);const a=e.raycastFirst(Ze,_.DoubleSide);if(!!(a&&Ze.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=Ku)return a.face.normal.dot(Is)>0?Mi:bi;if(i/n>.5||(r-i+1)/n>.5)break}return i/n>.5?zt:Bt}function Hu(o,e){const t=new Ao,n=new Ao;return ko.copy(o.matrixWorld).invert().multiply(e.matrixWorld),o.geometry.boundsTree.bvhcast(e.geometry.boundsTree,ko,{intersectsTriangles(i,s,r,a){if(!wt(i)&&!wt(s)){let l=i.intersectsTriangle(s,zo,!0);if(!l){const c=i.plane,h=s.plane,d=c.normal,m=h.normal;d.dot(m)===1&&Math.abs(c.constant-h.constant)<qu&&(l=!0)}if(l){let c=o.geometry.boundsTree.resolveTriangleIndex(r),h=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(c,h),n.add(h,c),_i&&(_i.addEdge(zo),_i.addIntersectingTriangles(r,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function Ju(o,e,t,n,i,s,r=!1){const a=t.attributes,l=t.index,c=o*3,h=l.getX(c+0),d=l.getX(c+1),m=l.getX(c+2);for(const p in s){const f=a[p],u=s[p];if(!(p in a))throw new Error(`CSG Operations: Attribute ${p} not available on geometry.`);const g=f.itemSize;p==="position"?(ze.a.fromBufferAttribute(f,h).applyMatrix4(n),ze.b.fromBufferAttribute(f,d).applyMatrix4(n),ze.c.fromBufferAttribute(f,m).applyMatrix4(n),Os(ze.a,ze.b,ze.c,e,3,u,r)):p==="normal"?(ze.a.fromBufferAttribute(f,h).applyNormalMatrix(i),ze.b.fromBufferAttribute(f,d).applyNormalMatrix(i),ze.c.fromBufferAttribute(f,m).applyNormalMatrix(i),r&&(ze.a.multiplyScalar(-1),ze.b.multiplyScalar(-1),ze.c.multiplyScalar(-1)),Os(ze.a,ze.b,ze.c,e,3,u,r,!0)):(Eo.fromBufferAttribute(f,h),Lo.fromBufferAttribute(f,d),Io.fromBufferAttribute(f,m),Os(Eo,Lo,Io,e,g,u,r))}}function Qu(o,e,t,n,i,s,r,a=!1){Rs(o,n,i,s,r,a),Rs(a?t:e,n,i,s,r,a),Rs(a?e:t,n,i,s,r,a)}function Ro(o,e,t=!1){switch(o){case Wu:if(e===Bt||e===Mi&&!t)return Ot;break;case Xu:if(t){if(e===zt)return Mn}else if(e===Bt||e===bi)return Ot;break;case Zu:if(t){if(e===Bt||e===bi)return Ot}else if(e===zt)return Mn;break;case Yu:if(e===zt)return Mn;if(e===Bt)return Ot;break;case Po:if(e===zt||e===Mi&&!t)return Ot;break;case To:if(!t&&(e===Bt||e===bi))return Ot;break;case Do:if(!t&&(e===zt||e===Mi))return Ot;break;default:throw new Error(`Unrecognized CSG operation enum "${o}".`)}return Bs}function Os(o,e,t,n,i,s,r=!1,a=!1){const l=c=>{s.push(c.x),i>1&&s.push(c.y),i>2&&s.push(c.z),i>3&&s.push(c.w)};Ls.set(0,0,0,0).addScaledVector(o,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),wi.set(0,0,0,0).addScaledVector(o,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),xi.set(0,0,0,0).addScaledVector(o,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Ls.normalize(),wi.normalize(),xi.normalize()),l(Ls),r?(l(xi),l(wi)):(l(wi),l(xi))}function Rs(o,e,t,n,i,s=!1){for(const r in i){const a=e[r],l=i[r];if(!(r in e))throw new Error(`CSG Operations: Attribute ${r} no available on geometry.`);const c=a.itemSize;r==="position"?(dt.fromBufferAttribute(a,o).applyMatrix4(t),l.push(dt.x,dt.y,dt.z)):r==="normal"?(dt.fromBufferAttribute(a,o).applyNormalMatrix(n),s&&dt.multiplyScalar(-1),l.push(dt.x,dt.y,dt.z)):(l.push(a.getX(o)),c>1&&l.push(a.getY(o)),c>2&&l.push(a.getZ(o)),c>3&&l.push(a.getW(o)))}}class ed{constructor(e){this.triangle=new _.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new _.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class No{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new ed(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=[],r=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 c in l)i.has(c)||(i.add(c),s.push(l[c]))}};if(e!==null)r(e);else for(const a in n)r(a);return s}reset(){this.data={}}}class td{constructor(){this.enabled=!1,this.triangleIntersectsA=new No,this.triangleIntersectsB=new No,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:s,triangleIntersectsB:r}=this;s.addTriangleIntersection(e,t,n,i),r.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(),Bo(this))}complete(){this.enabled&&Bo(null)}}const xt=new _.Matrix4,Si=new _.Matrix3,Rt=new _.Triangle,Ci=new _.Triangle,bt=new _.Triangle,Ai=new _.Triangle,qe=[],Nt=[];function nd(o){for(const e of o)return e}function id(o,e,t,n,i,s={}){const{useGroups:r=!0}=s,{aIntersections:a,bIntersections:l}=Hu(o,e),c=[];let h=null,d;return d=r?0:-1,Fo(o,e,a,t,!1,n,i,d),Uo(o,e,a,t,!1,i,d),t.findIndex(p=>p!==Do&&p!==To)!==-1&&(d=r?o.geometry.groups.length||1:-1,Fo(e,o,l,t,!0,n,i,d),Uo(e,o,l,t,!0,i,d)),qe.length=0,Nt.length=0,{groups:c,materials:h}}function Fo(o,e,t,n,i,s,r,a=0){const l=o.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),Si.getNormalMatrix(o.matrixWorld).multiplyScalar(l?-1:1);const c=o.geometry.groupIndices,h=o.geometry.index,d=o.geometry.attributes.position,m=e.geometry.boundsTree,p=e.geometry.index,f=e.geometry.attributes.position,u=t.ids,g=t.intersectionSet;for(let y=0,v=u.length;y<v;y++){const w=u[y],x=a===-1?0:c[w]+a,M=3*w,T=h.getX(M+0),P=h.getX(M+1),k=h.getX(M+2);Rt.a.fromBufferAttribute(d,T).applyMatrix4(xt),Rt.b.fromBufferAttribute(d,P).applyMatrix4(xt),Rt.c.fromBufferAttribute(d,k).applyMatrix4(xt),s.reset(),s.initialize(Rt);const D=g[w];for(let O=0,A=D.length;O<A;O++){const I=3*D[O],S=p.getX(I+0),z=p.getX(I+1),V=p.getX(I+2);Ci.a.fromBufferAttribute(f,S),Ci.b.fromBufferAttribute(f,z),Ci.c.fromBufferAttribute(f,V),s.splitByTriangle(Ci)}const E=s.triangles;for(let O=0,A=E.length;O<A;O++){const I=E[O],S=s.coplanarTriangleUsed?$u(I,m):Oo(I,m);qe.length=0,Nt.length=0;for(let z=0,V=n.length;z<V;z++){const U=Ro(n[z],S,i);U!==Bs&&(Nt.push(U),qe.push(r[z].getGroupAttrSet(x)))}if(qe.length!==0){Rt.getBarycoord(I.a,Ai.a),Rt.getBarycoord(I.b,Ai.b),Rt.getBarycoord(I.c,Ai.c);for(let z=0,V=qe.length;z<V;z++){const U=qe[z],G=Nt[z]===Mn;Ju(w,Ai,o.geometry,o.matrixWorld,Si,U,l!==G)}}}}return u.length}function Uo(o,e,t,n,i,s,r=0){const a=o.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),Si.getNormalMatrix(o.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,c=o.geometry.groupIndices,h=o.geometry.index,d=o.geometry.attributes,m=d.position,p=[],f=o.geometry.halfEdges,u=new Set,g=_s(o.geometry);for(let y=0,v=g;y<v;y++)y in t.intersectionSet||u.add(y);for(;u.size>0;){const y=nd(u);u.delete(y),p.push(y);const v=3*y,w=h.getX(v+0),x=h.getX(v+1),M=h.getX(v+2);bt.a.fromBufferAttribute(m,w).applyMatrix4(xt),bt.b.fromBufferAttribute(m,x).applyMatrix4(xt),bt.c.fromBufferAttribute(m,M).applyMatrix4(xt);const T=Oo(bt,l);Nt.length=0,qe.length=0;for(let P=0,k=n.length;P<k;P++){const D=Ro(n[P],T,i);D!==Bs&&(Nt.push(D),qe.push(s[P]))}for(;p.length>0;){const P=p.pop();for(let k=0;k<3;k++){const D=f.getSiblingTriangleIndex(P,k);D!==-1&&u.has(D)&&(p.push(D),u.delete(D))}if(qe.length!==0){const k=3*P,D=h.getX(k+0),E=h.getX(k+1),O=h.getX(k+2),A=r===-1?0:c[P]+r;if(bt.a.fromBufferAttribute(m,D),bt.b.fromBufferAttribute(m,E),bt.c.fromBufferAttribute(m,O),!wt(bt))for(let I=0,S=qe.length;I<S;I++){const z=Nt[I],V=qe[I].getGroupAttrSet(A),U=z===Mn;Qu(D,E,O,d,o.matrixWorld,Si,V,U!==a)}}}}}function sd(o){for(let e=0;e<o.length-1;e++){const t=o[e],n=o[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,s=n.start+n.count;n.start=i,n.count=s-i,o.splice(e,1),e--}}}function rd(o,e,t,n){t.clear();const i=o.attributes;for(let s=0,r=n.length;s<r;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 od(o,e,t){let n=!1,i=-1;const s=o.attributes,r=e.groupAttributes[0];for(const l in r){const c=e.getTotalLength(l),h=e.getType(l),d=e.getItemSize(l),m=e.getNormalized(l);let p=s[l];(!p||p.array.length<c)&&(p=new _.BufferAttribute(new h(c),d,m),o.setAttribute(l,p),n=!0);let f=0;for(let u=0,g=Math.min(t.length,e.groupCount);u<g;u++){const y=t[u].index,{array:v,type:w,length:x}=e.groupAttributes[y][l],M=new w(v.buffer,0,x);p.array.set(M,f),f+=M.length}p.needsUpdate=!0,i=c/p.itemSize}if(o.index){const l=o.index.array;if(l.length<i)o.index=null,n=!0;else for(let c=0,h=l.length;c<h;c++)l[c]=c}let a=0;o.clearGroups();for(let l=0,c=Math.min(t.length,e.groupCount);l<c;l++){const{index:h,materialIndex:d}=t[l],m=e.getCount(h);m!==0&&(o.addGroup(a,m,d),a+=m)}o.setDrawRange(0,i),o.boundsTree=null,n&&o.dispose()}function Vo(o,e){let t=e;return Array.isArray(e)||(t=[],o.forEach(n=>{t[n.materialIndex]=e})),t}class ad{constructor(){this.triangleSplitter=new Vu,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new td}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 yi){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:r,attributeData:a,attributes:l,useGroups:c,consolidateGroups:h,debug:d}=this;for(;a.length<i.length;)a.push(new Gu);i.forEach((y,v)=>{rd(e.geometry,y.geometry,a[v],l)}),d.init(),id(e,t,n,r,a,{useGroups:c}),d.complete();const m=this.getGroupRanges(e.geometry),p=Vo(m,e.material),f=this.getGroupRanges(t.geometry),u=Vo(f,t.material);f.forEach(y=>y.materialIndex+=p.length);let g=[...m,...f].map((y,v)=>({...y,index:v}));if(c){const y=[...p,...u];h&&(g=g.map(w=>{const x=y[w.materialIndex];return w.materialIndex=y.indexOf(x),w}).sort((w,x)=>w.materialIndex-x.materialIndex));const v=[];for(let w=0,x=y.length;w<x;w++){let M=!1;for(let T=0,P=g.length;T<P;T++){const k=g[T];k.materialIndex===w&&(M=!0,k.materialIndex=v.length)}M&&v.push(y[w])}i.forEach(w=>{w.material=v})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=p[0]});return i.forEach((y,v)=>{const w=y.geometry;od(w,a[v],g),h&&sd(w.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new yi){e.updateMatrixWorld(!0);const n=(s,r)=>{const a=s.children;for(let l=0,c=a.length;l<c;l++){const h=a[l];h.isOperationGroup?n(h,r):r(h)}},i=s=>{const r=s.children;let a=!1;for(let c=0,h=r.length;c<h;c++){const d=r[c];a=i(d)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let c;return n(s,h=>{c?c=this.evaluate(c,h,h.operation):c=this.evaluate(s,h,h.operation)}),s._cachedGeometry=c.geometry,s._cachedMaterials=c.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class ld{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 ad,this.planeGroup=new b.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 b.BufferGeometry,i=new b.MeshStandardMaterial({color:new b.Color(33023),metalness:.1,roughness:.75,side:b.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((r,a)=>a!==t)}),s=new b.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((r,a)=>{const l=this.getCacheKey(a,t),c=this.geometryCache.get(l);if(c&&c.planeHash===i)s.push(c.geometry.clone()),c.timestamp=Date.now();else try{const h=this.createPlaneBrush(e),d=new yi(r.geometry);r.updateMatrixWorld(!0),d.matrix.copy(r.matrixWorld),d.updateMatrixWorld();const m=this.evaluator.evaluate(h,d,Po);m&&m.geometry.attributes.position.count>0?(s.push(m.geometry),this.geometryCache.set(l,{geometry:m.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(h){console.warn(`CSG intersection failed for mesh ${a}:`,h)}}),s.length>0){const r=this.mergeGeometries(s);n.geometry&&n.geometry.dispose(),n.geometry=r,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(r=>r.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 b.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new b.Quaternion().setFromUnitVectors(new b.Vector3(0,-1,0),e.normal));const n=new b.Mesh(t),i=new yi(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new b.BufferGeometry,n=[],i=[],s=[];let r=0;return e.forEach(a=>{const l=a.attributes.position,c=a.attributes.normal;for(let h=0;h<l.count;h++)n.push(l.getX(h),l.getY(h),l.getZ(h));if(c)for(let h=0;h<c.count;h++)i.push(c.getX(h),c.getY(h),c.getZ(h));if(a.index)for(let h=0;h<a.index.count;h++)s.push(a.index.getX(h)+r);r+=l.count}),t.setAttribute("position",new b.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new b.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new b.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new b.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new b.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 b.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 cd{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 ld(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 b.Plane;n.setFromNormalAndCoplanarPoint(new b.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new b.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new b.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 b.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,r=(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,c=(this.box.max.z-this.maxBox.min.z)/n*100;i<0&&(i=0),s<0&&(s=0),r<0&&(r=0),a<0&&(a=0),l<0&&(l=0),c<0&&(c=0),i>100&&(i=100),s>100&&(s=100),r>100&&(r=100),a>100&&(a=100),l>100&&(l=100),c>100&&(c=100);let h={x:{min:i,max:s},y:{min:r,max:a},z:{min:l,max:c}};this.engine.events.trigger(Me.SectionMove,h)}updata_face(e){let t=this,n=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.min.z)],i=[new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z)],s=[new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)],r=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z)],a=[new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z)],l=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.min.y,e.max.z)];c(n,new b.Vector3(0,0,-1),"前"),c(i,new b.Vector3(0,0,1),"后"),c(s,new b.Vector3(1,0,0),"右"),c(r,new b.Vector3(-1,0,0),"左"),c(a,new b.Vector3(0,1,0),"顶"),c(l,new b.Vector3(0,-1,0),"底");function c(h,d,m){const p=new b.BufferGeometry,f=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z]),u=[0,1,2,0,2,3];p.setAttribute("position",new b.BufferAttribute(f,3)),p.setIndex(u);let g=t.engine.scene.children.find(T=>T.type=="Group"&&T.name=="ClippingBox");g==null&&(g=new b.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(T=>T.name==m);if(y==null){const T=new b.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:b.DoubleSide});T.polygonOffset=!0,T.polygonOffsetFactor=1,T.polygonOffsetUnits=4;const P=new b.Mesh(p,T);P.normal=d,P.name=m,g.add(P),t.meshs.push(P)}else y.geometry=p;const v=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z,h[0].x,h[0].y,h[0].z]);let w=new b.LineBasicMaterial({color:255}),x=new b.BufferGeometry;x.setAttribute("position",new b.BufferAttribute(v,3));let M=t.meshs.find(T=>T.name==m+"Line");M==null&&(M=new b.Line(x,w),M.name=m+"Line",g.add(M),t.meshs.push(M)),M.geometry=x,M.material=w,m=="前"||m=="左"||m=="底"?t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.min):t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.max),t.engine.scene.children.filter(T=>T.type=="Mesh"&&T.url).forEach(T=>{T.material&&Array.isArray(T.material)?T.material.forEach(P=>{P.clippingPlanes=t.engine.sectionPlane}):T.material.clippingPlanes=t.engine.sectionPlane})}}}class hd{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new b.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 b.Vector3(0,1,0).applyAxisAngle(new b.Vector3(1,0,0),e).applyAxisAngle(new b.Vector3(0,0,1),t).applyAxisAngle(new b.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(D=>D.type=="Group"&&D.name=="ClippingBox");n==null&&(n=new b.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new b.Vector3(1,0,0),s=new b.Vector3(0,1,0),r=new b.Vector3(0,0,1),a,l,c=this.normal.clone().normalize(),h=Math.abs(c.dot(i)),d=Math.abs(c.dot(s)),m=Math.abs(c.dot(r));h<=d&&h<=m?a=i:d<=h&&d<=m?a=s:a=r,a=a.clone().sub(c.clone().multiplyScalar(a.dot(c))).normalize(),l=new b.Vector3().crossVectors(c,a).normalize();let p=null;this.center==null?(p=new b.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 f=this.box.max.x-this.box.min.x,u=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*f,Math.abs(a.y)*u,Math.abs(a.z)*g),v=Math.max(Math.abs(l.x)*f,Math.abs(l.y)*u,Math.abs(l.z)*g),w=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-v/2)),x=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-v/2)),M=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(v/2)),T=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(v/2));w.add(c.clone().multiplyScalar(e)),x.add(c.clone().multiplyScalar(e)),M.add(c.clone().multiplyScalar(e)),T.add(c.clone().multiplyScalar(e)),this.current_center=p.clone().add(c.clone().multiplyScalar(e)),k([w,x,M,T],c,"face");function k(D,E,O){const A=new b.BufferGeometry,I=new Float32Array([D[0].x,D[0].y,D[0].z,D[1].x,D[1].y,D[1].z,D[2].x,D[2].y,D[2].z,D[3].x,D[3].y,D[3].z]),S=[0,1,2,0,2,3];A.setAttribute("position",new b.BufferAttribute(I,3)),A.setIndex(S);let z=t.meshs.find($=>$.name==O);if(z==null){const $=new b.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:b.DoubleSide});$.polygonOffset=!0,$.polygonOffsetFactor=1,$.polygonOffsetUnits=4;const F=new b.Mesh(A,$);F.normal=E,F.name=O,n.add(F),t.meshs.push(F)}else z.geometry=A;const V=new Float32Array([D[0].x,D[0].y,D[0].z,D[1].x,D[1].y,D[1].z,D[2].x,D[2].y,D[2].z,D[3].x,D[3].y,D[3].z,D[0].x,D[0].y,D[0].z]);let U=new b.LineBasicMaterial({color:255}),H=new b.BufferGeometry;H.setAttribute("position",new b.BufferAttribute(V,3));let G=t.meshs.find($=>$.name==O+"Line");G==null&&(G=new b.Line(H,U),G.name=O+"Line",n.add(G),t.meshs.push(G)),G.geometry=H,G.material=U,t.engine.sectionPlane.find($=>$.name==O).setFromNormalAndCoplanarPoint(E.clone().setLength(t.direction),D[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 b.Plane;n.setFromNormalAndCoplanarPoint(new b.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new b.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new b.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 b.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 ud{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 dd{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new b.Plane(new b.Vector3(0,0,1),1e5);t.name="前";let n=new b.Plane(new b.Vector3(0,0,1),1e5);n.name="左";let i=new b.Plane(new b.Vector3(0,0,1),1e5);i.name="后";let s=new b.Plane(new b.Vector3(0,0,1),1e5);s.name="右";let r=new b.Plane(new b.Vector3(0,0,1),1e5);r.name="顶";let a=new b.Plane(new b.Vector3(0,0,1),1e5);a.name="底";let l=new b.Plane(new b.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,r,a,l]}init(){this.sectionBox=new cd(this.engine),this.sectionFace=new hd(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let r=this.engine.models.find(a=>a.url===s.url);s.ids.forEach(a=>{r.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 r=new b.Vector3(1e8,1e9,1e10),a=new b.Vector3(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<r.x&&(r.x=l.min.x),l.min.y<r.y&&(r.y=l.min.y),l.min.z<r.z&&(r.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 b.Box3(r,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,r=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:r,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 ud(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)),r=new b.Vector3(n.dir.x,n.dir.y,n.dir.z),a=s.dot(r);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 fd{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 pd{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 b.Mesh){const s=i.geometry;if(s&&s.attributes){const r=s.attributes.position;if(r){const a=r.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 md{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(r=>r.url===e);i.properties==null&&Wi(e+"/property",r=>{let a=JSON.parse(r);i.properties=a,setTimeout(()=>{s(a,t,n)},100)}),s(i.properties,t,n);function s(r,a,l){let c=[],h=r.models[a.toString()||""],d=h.map(m=>m[0]);d=d.filter((m,p)=>d.indexOf(m)===p),d.forEach(m=>{let p={name:r.categorys[m],children:[]};c.push(p),h.filter(f=>f[0]===m).forEach(f=>{p.children.push({name:r.names[f[1]],value:r.values[f[2]]})})}),l?.({properties:c,materials:c})}}}class gd{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(r=>r.url==e);return n?n.info.modelMapper.find(r=>r.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{r.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 yd{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new b.LineBasicMaterial({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!1})})}loadModelEdge(){this.modelEdgeLoaded||(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(r=>{let a=i.length;for(let l=0;l<r.points.length;l++)r.points[l].length==2&&(i.push(r.points[l][0].X),i.push(r.points[l][0].Z),i.push(-r.points[l][0].Y),i.push(r.points[l][1].X),i.push(r.points[l][1].Z),i.push(-r.points[l][1].Y));s.set(Number(r.id),[a,i.length,r.points])}),this.indexes.set(e.url,s)}}),this.modelEdgeLoaded=!0)}show(){this.modelEdgeLoaded||this.loadModelEdge(),this.indexes.forEach((e,t)=>{let n=[];e.forEach((r,a)=>{r[2].forEach((l,c)=>{l.length==2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})});let i=new b.BufferGeometry;i.setAttribute("position",new b.Float32BufferAttribute(n,3));let s=new b.LineSegments(i,this.material);s.url=t,this.groupEdge.add(s)})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i.slice()}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,r,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array;for(let h=s;h<r;h++)c[h]=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,r,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array,h=0;for(let d=s;d<r;d+=3){const m=Math.floor(h/6),p=h%6>=3;if(a[m]&&a[m].length===2){const f=p?a[m][1]:a[m][0];c[d]=f.X,c[d+1]=f.Z,c[d+2]=-f.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class vd{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 r=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${r.error?.message||r.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(`网络请求失败,请检查:
972
972
  1. 网络连接
973
973
  2. API地址是否正确
974
- 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 r=s.body?.getReader();if(!r)throw new Error("无法读取响应流");const a=new TextDecoder;let l="";for(;;){const{done:h,value:c}=await r.read();if(h){t("",!0);break}l+=a.decode(c,{stream:!0});const d=l.split(`
975
- `);l=d.pop()||"";for(const m of d){const p=m.trim();if(!p||!p.startsWith("data: "))continue;const f=p.slice(6);if(f!=="[DONE]")try{const g=JSON.parse(f).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(u){console.warn("解析流式数据失败:",u)}}}}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 wd{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 vd(i.llmConfig);try{const s=await Promise.resolve().then(()=>Sf);this.prompts.main=s.default;const r=await Promise.resolve().then(()=>Cf);this.prompts.step=r.default;const a=await Promise.resolve().then(()=>Af);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文档
976
- ${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,r=!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):r?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} 次生成的代码:
977
- ${c}`);try{const d=await this.executeCode(c,t);if(d instanceof Object&&d.success==!1||d instanceof String&&(d.includes("undefined")||d.includes("not"))){s=d,r=!0;debugger;throw d}debugger;return d}catch(d){debugger;throw s=d,r=!0,d}}catch(l){if(r||(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 r=t[1].trim();if(r=r.replace(/^```javascript\n?/,"").replace(/^```js\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,""),r.length>0)return r}const n=[/```javascript\s*([\s\S]*?)```/i,/```js\s*([\s\S]*?)```/i,/```\s*([\s\S]*?)```/];for(const r of n){const a=e.match(r);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:`
974
+ 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 c=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${c.error?.message||c.message||s.statusText}`)}const r=s.body?.getReader();if(!r)throw new Error("无法读取响应流");const a=new TextDecoder;let l="";for(;;){const{done:c,value:h}=await r.read();if(c){t("",!0);break}l+=a.decode(h,{stream:!0});const d=l.split(`
975
+ `);l=d.pop()||"";for(const m of d){const p=m.trim();if(!p||!p.startsWith("data: "))continue;const f=p.slice(6);if(f!=="[DONE]")try{const g=JSON.parse(f).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(u){console.warn("解析流式数据失败:",u)}}}}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 wd{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 vd(i.llmConfig);try{const s=await Promise.resolve().then(()=>_f);this.prompts.main=s.default;const r=await Promise.resolve().then(()=>Sf);this.prompts.step=r.default;const a=await Promise.resolve().then(()=>Cf);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文档
976
+ ${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,r=!1;for(let a=0;a<=n;a++)try{const l=i.length>0?i[i.length-1]:"",h=await(a===0?this.generateCode(e,t):r?this.regenerateCodeAfterFailure(e,t,l,s,a):this.generateCode(e,t));i.push(h),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 第 ${a+1} 次生成的代码:
977
+ ${h}`);try{const d=await this.executeCode(h,t);if(d instanceof Object&&d.success==!1||d instanceof String&&(d.includes("undefined")||d.includes("not"))){s=d,r=!0;debugger;throw d}debugger;return d}catch(d){debugger;throw s=d,r=!0,d}}catch(l){if(r||(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 r=t[1].trim();if(r=r.replace(/^```javascript\n?/,"").replace(/^```js\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,""),r.length>0)return r}const n=[/```javascript\s*([\s\S]*?)```/i,/```js\s*([\s\S]*?)```/i,/```\s*([\s\S]*?)```/];for(const r of n){const a=e.match(r);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:`
978
978
 
979
979
  ## BIM引擎API文档
980
980
  ${this.prompts.apiDoc}`},s={role:"user",content:`请根据以下步骤描述生成可执行的JavaScript代码:
@@ -988,7 +988,7 @@ ${t?JSON.stringify(t,null,2):"null"}
988
988
  请严格按照##code##格式输出代码。`},r=[n,i,s],a=await this.llmApi.chat(r);return this.extractCodeFromResponse(a)}catch(n){throw console.error("[AI Manager] 代码生成失败:",n),n}}async regenerateCodeAfterFailure(e,t,n,i,s){try{const r={role:"system",content:`${this.prompts.step}`},a={role:"system",content:`
989
989
 
990
990
  ## BIM引擎API文档
991
- ${this.prompts.apiDoc}`},l={message:i?.message||(i instanceof Object?JSON.stringify(i):String(i)),name:i?.name,stack:i?.stack},h={role:"user",content:`上一次生成的代码在执行时失败了,请你修复后重新输出完整可执行的 JavaScript 代码(仍然要严格按 ##code## 格式输出)。
991
+ ${this.prompts.apiDoc}`},l={message:i?.message||(i instanceof Object?JSON.stringify(i):String(i)),name:i?.name,stack:i?.stack},c={role:"user",content:`上一次生成的代码在执行时失败了,请你修复后重新输出完整可执行的 JavaScript 代码(仍然要严格按 ##code## 格式输出)。
992
992
 
993
993
  当前步骤信息:
994
994
  ${JSON.stringify(e,null,2)}
@@ -1012,10 +1012,10 @@ ${JSON.stringify(l,null,2)}
1012
1012
  1) 不要输出解释文字,只输出 ##code## 段落里的代码
1013
1013
  2) 如果是语法错误/引用未定义/缺少 await/返回值不一致,请直接修复
1014
1014
  3) 尽量保持与步骤目标一致,避免引入与步骤无关的副作用
1015
- 4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},c=await this.llmApi.chat([r,a,h]);try{return this.extractCodeFromResponse(c)}catch(d){throw new Error(`无法从大模型响应中提取代码(修复重试阶段):${d.message}`)}}catch(r){throw console.error("[AI Manager] 修复后代码生成失败:",r),r}}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 r=new Function("engine","previousStepOutput",`
1015
+ 4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},h=await this.llmApi.chat([r,a,c]);try{return this.extractCodeFromResponse(h)}catch(d){throw new Error(`无法从大模型响应中提取代码(修复重试阶段):${d.message}`)}}catch(r){throw console.error("[AI Manager] 修复后代码生成失败:",r),r}}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 r=new Function("engine","previousStepOutput",`
1016
1016
  'use strict';
1017
1017
  ${i}
1018
- `)(n,t);return r&&typeof r.then=="function"?await r:r}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 xd{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],r=this.points[this.playToIndex],a=this.interpolatePose(s,r,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:b.MathUtils.lerp(e.position.x,t.position.x,i),y:b.MathUtils.lerp(e.position.y,t.position.y,i),z:b.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:b.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:b.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:b.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:b.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:b.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:b.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:b.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:b.MathUtils.lerp(e.target.x,t.target.x,i),y:b.MathUtils.lerp(e.target.y,t.target.y,i),z:b.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=b.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 bd{engine;miniMapCamera=null;miniMapRenderer=null;miniMapContainer=null;overlayCanvas=null;overlayCtx=null;isVisible=!1;mapSize=200;currentHalfSize=500;minHalfSize=5;maxHalfSize=1e4;halfSizeInitialized=!1;camY=1e3;centerX=0;centerZ=0;dragMode=null;lastMouseX=0;lastMouseY=0;constructor(e){this.engine=e,this.init()}getstate(){return this.isVisible}init(){this.miniMapContainer=document.createElement("div"),this.miniMapContainer.style.position="absolute",this.miniMapContainer.style.bottom="20px",this.miniMapContainer.style.left="20px",this.miniMapContainer.style.width=`${this.mapSize}px`,this.miniMapContainer.style.height=`${this.mapSize}px`,this.miniMapContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.miniMapContainer.style.borderRadius="4px",this.miniMapContainer.style.overflow="hidden",this.miniMapContainer.style.display="none",this.miniMapContainer.style.zIndex="200",this.miniMapContainer.style.pointerEvents="auto",this.miniMapContainer.style.cursor="crosshair",this.engine.container.appendChild(this.miniMapContainer),this.miniMapRenderer=new b.WebGLRenderer({alpha:!0,antialias:!1}),this.miniMapRenderer.setSize(this.mapSize,this.mapSize),this.miniMapRenderer.setPixelRatio(window.devicePixelRatio),this.miniMapRenderer.setClearColor(1710638,.85),this.miniMapContainer.appendChild(this.miniMapRenderer.domElement);const e=window.devicePixelRatio||1;this.overlayCanvas=document.createElement("canvas"),this.overlayCanvas.width=this.mapSize*e,this.overlayCanvas.height=this.mapSize*e,this.overlayCanvas.style.position="absolute",this.overlayCanvas.style.top="0",this.overlayCanvas.style.left="0",this.overlayCanvas.style.width=`${this.mapSize}px`,this.overlayCanvas.style.height=`${this.mapSize}px`,this.overlayCanvas.style.pointerEvents="none",this.miniMapContainer.appendChild(this.overlayCanvas),this.overlayCtx=this.overlayCanvas.getContext("2d"),this.overlayCtx&&this.overlayCtx.scale(e,e),this.miniMapCamera=new b.OrthographicCamera(-this.currentHalfSize,this.currentHalfSize,this.currentHalfSize,-this.currentHalfSize,.1,1e5),this.miniMapCamera.up.set(0,0,-1),this.setupEvents()}worldToPixel(e,t){const n=this.currentHalfSize;return{x:((e-this.centerX)/n*.5+.5)*this.mapSize,y:((t-this.centerZ)/n*.5+.5)*this.mapSize}}pixelToWorld(e,t){const n=this.currentHalfSize;return{x:(e/this.mapSize-.5)*2*n+this.centerX,z:(t/this.mapSize-.5)*2*n+this.centerZ}}setupEvents(){const e=this.miniMapContainer;e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("mousedown",this.onMouseDown),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp),e.addEventListener("mouseleave",this.onMouseUp),e.addEventListener("contextmenu",t=>t.preventDefault()),["pointerdown","pointermove","pointerup","click","dblclick"].forEach(t=>e.addEventListener(t,n=>n.stopPropagation()))}onWheel=e=>{e.preventDefault(),e.stopPropagation();const t=e.deltaY>0?1.25:.8;this.currentHalfSize=Math.max(this.minHalfSize,Math.min(this.maxHalfSize,this.currentHalfSize*t))};onMouseDown=e=>{e.stopPropagation();const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,s=this.engine.camera;if(!s)return;const{x:r,y:a}=this.worldToPixel(s.position.x,s.position.z);Math.hypot(n-r,i-a)<25?(this.dragMode="rotate",this.miniMapContainer.style.cursor="alias"):(this.dragMode=null,this.handleTeleport(n,i)),this.lastMouseX=n,this.lastMouseY=i};onMouseMove=e=>{if(e.stopPropagation(),this.dragMode!=="rotate")return;const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.handleRotate(n,i),this.lastMouseX=n,this.lastMouseY=i};onMouseUp=e=>{e.stopPropagation(),this.dragMode=null,this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair")};handleTeleport(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const{x:s,z:r}=this.pixelToWorld(e,t),a=s-n.position.x,l=r-n.position.z;n.position.x+=a,n.position.z+=l,i.target.x+=a,i.target.z+=l,i.update()}handleRotate(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const s=this.mapSize/2,r=this.mapSize/2,a=Math.atan2(this.lastMouseY-r,this.lastMouseX-s);let h=Math.atan2(t-r,e-s)-a;h>Math.PI&&(h-=2*Math.PI),h<-Math.PI&&(h+=2*Math.PI);const c=new b.Vector3().copy(i.target).sub(n.position),d=new b.Spherical().setFromVector3(c);d.theta-=h,c.setFromSpherical(d),i.target.copy(n.position).add(c),i.update()}drawOverlay(){const e=this.overlayCtx,t=this.engine.camera;if(!e||!t)return;e.clearRect(0,0,this.mapSize,this.mapSize);const n=this.mapSize/2,i=this.mapSize/2,s=new b.Vector3;t.getWorldDirection(s);const r=Math.atan2(s.x,-s.z),a=36,l=Math.PI/10;e.save(),e.translate(n,i),e.rotate(r);const h=e.createRadialGradient(0,0,2,0,0,a);h.addColorStop(0,"rgba(0, 230, 130, 0.9)"),h.addColorStop(1,"rgba(0, 230, 130, 0)");const c=-Math.sin(l)*a,d=-Math.cos(l)*a,m=Math.sin(l)*a,p=-Math.cos(l)*a;e.beginPath(),e.moveTo(0,0),e.lineTo(c,d),e.lineTo(m,p),e.closePath(),e.fillStyle=h,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}show(){this.isVisible=!0,this.miniMapContainer&&(this.miniMapContainer.style.display="block")}hide(){this.isVisible=!1,this.miniMapContainer&&(this.miniMapContainer.style.display="none")}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.miniMapCamera||!this.miniMapRenderer)return;const e=this.engine.camera;if(!(!e||!this.engine.scene)){if(this.engine.octreeBox){const t=this.engine.octreeBox.getBoundingBox();if(t?.min&&t?.max){const n=t.max.x-t.min.x,i=t.max.z-t.min.z,s=t.max.y-t.min.y;this.camY=t.max.y+Math.max(n,i,s),!this.halfSizeInitialized&&n+i>0&&(this.currentHalfSize=Math.max(n,i)*2,this.halfSizeInitialized=!0)}}this.centerX=e.position.x,this.centerZ=e.position.z,this.miniMapCamera.left=-this.currentHalfSize,this.miniMapCamera.right=this.currentHalfSize,this.miniMapCamera.top=this.currentHalfSize,this.miniMapCamera.bottom=-this.currentHalfSize,this.miniMapCamera.updateProjectionMatrix(),this.miniMapCamera.position.set(this.centerX,this.camY,this.centerZ),this.miniMapCamera.lookAt(this.centerX,this.camY-1,this.centerZ),this.miniMapRenderer.render(this.engine.scene,this.miniMapCamera),this.drawOverlay()}}dispose(){this.miniMapContainer&&(this.miniMapContainer.removeEventListener("wheel",this.onWheel),this.miniMapContainer.removeEventListener("mousedown",this.onMouseDown),this.miniMapContainer.removeEventListener("mousemove",this.onMouseMove),this.miniMapContainer.removeEventListener("mouseup",this.onMouseUp),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseUp)),this.miniMapRenderer&&(this.miniMapRenderer.dispose(),this.miniMapRenderer=null),this.miniMapContainer&&(this.miniMapContainer.remove(),this.miniMapContainer=null),this.miniMapCamera=null,this.overlayCtx=null,this.overlayCanvas=null}}const Md=[{Id:"100001",Name:"1",Points:[{X:-2,Y:-5,Z:0},{X:-2,Y:5,Z:0}]},{Id:"100002",Name:"2",Points:[{X:2,Y:-5,Z:0},{X:2,Y:5,Z:0}]},{Id:"100003",Name:"A",Points:[{X:-5,Y:-2,Z:0},{X:5,Y:-2,Z:0}]},{Id:"100004",Name:"B",Points:[{X:-5,Y:2,Z:0},{X:5,Y:2,Z:0}]}];class _d{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new b.Vector3(e.X,e.Z,-e.Y);constructor(e){this.engine=e,this._initRoot()}setData(e){this._clearAxes(),this.axes=e.map(t=>({data:t,group:null})),this.axes.forEach(t=>this._buildAxis(t))}setMockData(){this.setData(Md)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let n=.5;if(e instanceof b.OrthographicCamera){const i=e,s=(i.top-i.bottom)/i.zoom,r=t.domElement.clientHeight||1;n=30*s/r}this.rootGroup.traverse(i=>{i instanceof b.Sprite&&i.scale.set(n,n,1)})}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new b.Group,this.rootGroup.name="GridRoot",this.rootGroup.visible=!1,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const n=t;if("geometry"in n&&n.geometry&&n.geometry.dispose(),"material"in n&&n.material){const i=n.material;"map"in i&&i.map&&i.map.dispose(),i.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),n=this.coordinateMapper(e.data.Points[1]),i=e.data.Name,s=new b.Group;s.name=`GridAxis_${e.data.Id}`;const r=new b.BufferGeometry().setFromPoints([t,n]),a=new b.LineBasicMaterial({color:1609983,depthTest:!1}),l=new b.Line(r,a);l.renderOrder=998,s.add(l),s.add(this._makeCircleSprite(i,t)),s.add(this._makeCircleSprite(i,n)),this.rootGroup.add(s),e.group=s}_makeCircleSprite(e,t){const i=document.createElement("canvas");i.width=128,i.height=128;const s=i.getContext("2d"),r=128/2,a=128/2,l=128/2-4;s.beginPath(),s.arc(r,a,l,0,Math.PI*2),s.fillStyle="white",s.fill(),s.strokeStyle="#1890ff",s.lineWidth=6,s.stroke(),s.fillStyle="#1890ff",s.font=`bold ${Math.round(128*.38)}px Arial`,s.textAlign="center",s.textBaseline="middle",s.fillText(e,r,a);const h=new b.CanvasTexture(i),c=new b.SpriteMaterial({map:h,depthTest:!1,transparent:!0}),d=new b.Sprite(c);return d.position.copy(t),d.scale.set(.5,.5,1),d.renderOrder=999,d}}const Sd=[{Id:"339",Name:"站台",Elevation:-.32808398950131235},{Id:"2787",Name:"站厅",Elevation:16.896325459317584},{Id:"236633",Name:"顶板",Elevation:36.745406824146976}];class Cd{engine;isVisible=!1;levels=[];svgContainer=null;svgOverlay=null;worldToScreen=null;halfSize=500;COLOR="#1890ff";PLANE_OPACITY=.08;constructor(e){this.engine=e,this._initSvg()}_initSvg(){this.svgContainer=document.createElement("div"),this.svgContainer.style.position="absolute",this.svgContainer.style.top="0",this.svgContainer.style.left="0",this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.svgContainer.style.pointerEvents="none",this.svgContainer.style.overflow="hidden",this.svgContainer.style.display="none",this.engine.container.appendChild(this.svgContainer),this.svgOverlay=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svgOverlay.style.position="absolute",this.svgOverlay.style.top="0",this.svgOverlay.style.left="0",this.svgOverlay.style.width="1920px",this.svgOverlay.style.height="1080px",this.svgOverlay.style.overflow="visible",this.svgContainer.appendChild(this.svgOverlay)}setData(e){this._clearAll(),this.levels=e.map(t=>({data:t,group:null,svgGroup:null})),this.levels.forEach(t=>this._buildThreeObject(t))}setMockData(){this.setData(Sd)}show(){this.isVisible=!0,this.svgContainer&&(this.svgContainer.style.display="block"),this.levels.forEach(e=>{e.group&&(e.group.visible=!0)})}hide(){this.isVisible=!1,this.svgContainer&&(this.svgContainer.style.display="none"),this.levels.forEach(e=>{e.group&&(e.group.visible=!1)})}toggle(){this.isVisible?this.hide():this.show()}update(){!this.isVisible||!this.svgOverlay||!this.levels.length||!this.engine.camera||!this.engine.renderer||(this._initWorldToScreen(),this.levels.forEach(e=>this._updateSvgLabels(e)))}dispose(){this._clearAll(),this.svgContainer&&(this.svgContainer.remove(),this.svgContainer=null),this.svgOverlay=null,this.worldToScreen=null}_initWorldToScreen(){this.engine.camera&&this.engine.renderer&&this.engine.scene&&(this.worldToScreen=new De(this.engine.camera,this.engine.renderer,this.engine.scene))}_clearAll(){this.levels.forEach(e=>{e.group&&this.engine.scene&&(this.engine.scene.remove(e.group),e.group.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}),e.group=null),e.svgGroup&&this.svgOverlay&&(e.svgGroup.remove(),e.svgGroup=null)}),this.levels=[]}_buildThreeObject(e){if(!this.engine.scene)return;const t=e.data.Elevation,n=this.halfSize,i=new b.Group,s=new b.PlaneGeometry(n*2,n*2);s.rotateX(-Math.PI/2);const r=new b.MeshBasicMaterial({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:b.DoubleSide,depthWrite:!1}),a=new b.Mesh(s,r);a.position.y=t,i.add(a);const l=[new b.Vector3(-n,t,-n),new b.Vector3(n,t,-n),new b.Vector3(n,t,n),new b.Vector3(-n,t,n),new b.Vector3(-n,t,-n)],h=new b.BufferGeometry().setFromPoints(l),c=new b.LineBasicMaterial({color:this.COLOR,transparent:!0,opacity:.7});if(i.add(new b.Line(h,c)),i.visible=this.isVisible,this.engine.scene.add(i),e.group=i,this.svgOverlay){const d=document.createElementNS("http://www.w3.org/2000/svg","g");d.dataset.levelId=e.data.Id;for(let m=0;m<4;m++)d.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(d),e.svgGroup=d}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new b.Vector3(-t,n,-t),new b.Vector3(t,n,-t),new b.Vector3(t,n,t),new b.Vector3(-t,n,t)],s=Array.from(e.svgGroup.children);i.forEach((r,a)=>{const l=this.worldToScreen.worldToScreen(r);s[a].setAttribute("x",String(l.x)),s[a].setAttribute("y",String(l.y))})}_makeLabel(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.textContent=`${e} ▲${t.toFixed(3)}m`,n.setAttribute("text-anchor","middle"),n.setAttribute("dominant-baseline","central"),n.setAttribute("fill",this.COLOR),n.setAttribute("font-size","12"),n.setAttribute("font-family","Arial, sans-serif"),n.setAttribute("font-weight","bold"),n.setAttribute("stroke","white"),n.setAttribute("stroke-width","2"),n.setAttribute("paint-order","stroke"),n.style.pointerEvents="none",n}}class Ad{engine;constructor(e){}update(){}}class Pd{engine;currentHdrId="0";isVisible=!0;currentIntensity=.2;currentTexture=null;skybox=null;textureCache=new Map;hdrList=[{id:"0",name:"无"},{id:"1",name:"纯净-多云",url:"assets/hdr/纯净-多云.hdr"},{id:"2",name:"纯净-落日",url:"assets/hdr/纯净-落日.hdr"},{id:"3",name:"纯净-少云",url:"assets/hdr/纯净-少云.hdr"},{id:"4",name:"纯净-无云",url:"assets/hdr/纯净-无云.hdr"},{id:"5",name:"纯净-夜晚",url:"assets/hdr/纯净-夜晚.hdr"},{id:"6",name:"纯净-阴天",url:"assets/hdr/纯净-阴天.hdr"},{id:"7",name:"纯净-中云",url:"assets/hdr/纯净-中云.hdr"}];constructor(e){this.engine=e}getHdrList(){return this.hdrList}async setHdr(e){const t=this.hdrList.find(n=>n.id===e);if(!t){console.warn(`[Hdr] HDR id "${e}" not found`);return}if(e==="0"||!t.url){this._clearHdr(),this.currentHdrId="0";return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}try{const n=await this._loadHdr(t.url);this.textureCache.set(e,n),this._applyTexture(n),this.currentHdrId=e}catch(n){console.error(`[Hdr] Failed to load HDR "${t.url}":`,n)}}setVisible(e){this.isVisible=e,e&&this.currentTexture&&!this.skybox?this._createSkybox(this.currentTexture):this.skybox&&(this.skybox.visible=e)}getCurrentHdrId(){return this.currentHdrId}getVisible(){return this.isVisible}setIntensity(e){this.currentIntensity=e,this.engine.scene&&(this.engine.scene.environmentIntensity=e),this.skybox&&this.skybox.material.color.setScalar(e)}getIntensity(){return this.currentIntensity}addHdrItem(e){const t=this.hdrList.find(n=>n.id===e.id);t?Object.assign(t,e):this.hdrList.push(e)}dispose(){this._clearHdr(),this.textureCache.forEach(e=>e.dispose()),this.textureCache.clear()}_loadHdr(e){return new Promise((t,n)=>{new nh().load(e,i=>{i.mapping=b.EquirectangularReflectionMapping,t(i)},void 0,i=>n(i))})}_applyTexture(e){if(this.currentTexture=e,!this.engine.scene)return;const t=new b.PMREMGenerator(this.engine.renderer),n=t.fromEquirectangular(e).texture;t.dispose(),this.engine.scene.environment=n,this.engine.scene.environmentIntensity=this.currentIntensity,this.engine.scene.background=null,this._removeSkybox(),this.isVisible&&this._createSkybox(e),this.engine.setting.setAmbientLightIntensity(0)}_createSkybox(e){const t=new b.SphereGeometry(500,64,32),n=new b.MeshBasicMaterial({map:e,side:b.BackSide,depthWrite:!1,fog:!1});this.skybox=new b.Mesh(t,n),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1,this.skybox.frustumCulled=!1,n.color.setScalar(this.currentIntensity),this.engine.scene.add(this.skybox)}_removeSkybox(){this.skybox&&(this.engine.scene.remove(this.skybox),this.skybox.geometry.dispose(),this.skybox.material.dispose(),this.skybox=null)}_clearHdr(){this.currentTexture=null,this._removeSkybox(),this.engine.scene&&(this.engine.scene.background=null,this.engine.scene.environment=null,this.engine.setting.setAmbientLightIntensity(1))}}class Td{engine;currentId="0";groundGroup;groundMesh=null;waterMaterial=null;clock;groundY=0;groundList=[{id:"0",name:"无"},{id:"1",name:"草地",color:4881486,roughness:.9,metalness:0,map:"/textures/ground/grass.jpg"},{id:"2",name:"混凝土",color:9474192,roughness:.85,metalness:.1,map:"/textures/ground/concrete.jpg"},{id:"3",name:"地砖",color:13152400,roughness:.55,metalness:.1,map:"/textures/ground/tiles.jpg"},{id:"4",name:"湖面",water:!0,waterColor:28062,waveHeight:.04,waveSpeed:.8},{id:"5",name:"海面",water:!0,waterColor:15708,waveHeight:.12,waveSpeed:1.4}];constructor(e){this.engine=e,this.groundGroup=new b.Group,this.groundGroup.name="groundGroup",this.clock=new b.Clock}init(){this.engine.scene.add(this.groundGroup)}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const n=this.groundList.find(h=>h.id===e);if(!n)return;const i=t?.size??300,s=n.water?80:1,r=new b.PlaneGeometry(i,i,s,s);r.rotateX(-Math.PI/2);let a;if(n.water)a=this._createWaterMaterial(n,t),this.waterMaterial=a;else{const h=new b.MeshStandardMaterial({color:n.color,roughness:n.roughness,metalness:n.metalness}),c=t?.textureUrl??n.map;c&&new b.TextureLoader().load(c,d=>{d.wrapS=d.wrapT=b.RepeatWrapping,d.repeat.set(8,8),h.map=d,h.needsUpdate=!0},void 0,()=>{}),a=h}const l=new b.Mesh(r,a);l.name="groundMesh",l.receiveShadow=!0,l.castShadow=!1,l.position.y=-.01,this.groundMesh=l,this.groundGroup.add(l),this.groundGroup.position.y=this.groundY,this.clock.start()}setHeight(e){this.groundY=e,this.groundGroup.position.y=e}getHeight(){return this.groundY}_createWaterMaterial(e,t){const n=new b.Color(e.waterColor),i=n.clone().multiplyScalar(.35),s=t?.sunDirection?t.sunDirection.clone().normalize():new b.Vector3(.5,.8,.5).normalize();return new b.ShaderMaterial({uniforms:{uTime:{value:0},uWaterColor:{value:n},uDeepColor:{value:i},uSunColor:{value:new b.Color(16777215)},uSunDir:{value:s},uWaveHeight:{value:e.waveHeight??.05},uWaveSpeed:{value:e.waveSpeed??1},uOpacity:{value:t?.opacity??.82}},vertexShader:Dd,fragmentShader:kd,transparent:!0,side:b.DoubleSide})}update(){if(!this.waterMaterial)return;this.waterMaterial.uniforms.uTime.value=this.clock.getElapsedTime();const e=this.engine.scene?.dirLight;if(e){const t=e.position.clone().normalize();this.waterMaterial.uniforms.uSunDir.value.copy(t)}}getGroundList(){return this.groundList.map(({id:e,name:t})=>({id:e,name:t}))}getCurrentId(){return this.currentId}show(){this.groundGroup.visible=!0}hide(){this.groundGroup.visible=!1}dispose(){this._dispose(),this.engine.scene.remove(this.groundGroup)}_dispose(){if(!this.groundMesh)return;this.groundMesh.geometry.dispose();const e=this.groundMesh.material;Array.isArray(e)?e.forEach(t=>t.dispose()):e.dispose(),this.groundGroup.remove(this.groundMesh),this.groundMesh=null,this.waterMaterial=null}}const Dd=`
1018
+ `)(n,t);return r&&typeof r.then=="function"?await r:r}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 xd{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],r=this.points[this.playToIndex],a=this.interpolatePose(s,r,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:b.MathUtils.lerp(e.position.x,t.position.x,i),y:b.MathUtils.lerp(e.position.y,t.position.y,i),z:b.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:b.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:b.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:b.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:b.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:b.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:b.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:b.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:b.MathUtils.lerp(e.target.x,t.target.x,i),y:b.MathUtils.lerp(e.target.y,t.target.y,i),z:b.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=b.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 bd{engine;miniMapCamera=null;miniMapRenderer=null;miniMapContainer=null;overlayCanvas=null;overlayCtx=null;isVisible=!1;mapSize=200;currentHalfSize=500;minHalfSize=5;maxHalfSize=1e4;halfSizeInitialized=!1;camY=1e3;centerX=0;centerZ=0;dragMode=null;lastMouseX=0;lastMouseY=0;constructor(e){this.engine=e,this.init()}getstate(){return this.isVisible}init(){this.miniMapContainer=document.createElement("div"),this.miniMapContainer.style.position="absolute",this.miniMapContainer.style.bottom="20px",this.miniMapContainer.style.left="20px",this.miniMapContainer.style.width=`${this.mapSize}px`,this.miniMapContainer.style.height=`${this.mapSize}px`,this.miniMapContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.miniMapContainer.style.borderRadius="4px",this.miniMapContainer.style.overflow="hidden",this.miniMapContainer.style.display="none",this.miniMapContainer.style.zIndex="200",this.miniMapContainer.style.pointerEvents="auto",this.miniMapContainer.style.cursor="crosshair",this.engine.container.appendChild(this.miniMapContainer),this.miniMapRenderer=new b.WebGLRenderer({alpha:!0,antialias:!1}),this.miniMapRenderer.setSize(this.mapSize,this.mapSize),this.miniMapRenderer.setPixelRatio(window.devicePixelRatio),this.miniMapRenderer.setClearColor(1710638,.85),this.miniMapContainer.appendChild(this.miniMapRenderer.domElement);const e=window.devicePixelRatio||1;this.overlayCanvas=document.createElement("canvas"),this.overlayCanvas.width=this.mapSize*e,this.overlayCanvas.height=this.mapSize*e,this.overlayCanvas.style.position="absolute",this.overlayCanvas.style.top="0",this.overlayCanvas.style.left="0",this.overlayCanvas.style.width=`${this.mapSize}px`,this.overlayCanvas.style.height=`${this.mapSize}px`,this.overlayCanvas.style.pointerEvents="none",this.miniMapContainer.appendChild(this.overlayCanvas),this.overlayCtx=this.overlayCanvas.getContext("2d"),this.overlayCtx&&this.overlayCtx.scale(e,e),this.miniMapCamera=new b.OrthographicCamera(-this.currentHalfSize,this.currentHalfSize,this.currentHalfSize,-this.currentHalfSize,.1,1e5),this.miniMapCamera.up.set(0,0,-1),this.setupEvents()}worldToPixel(e,t){const n=this.currentHalfSize;return{x:((e-this.centerX)/n*.5+.5)*this.mapSize,y:((t-this.centerZ)/n*.5+.5)*this.mapSize}}pixelToWorld(e,t){const n=this.currentHalfSize;return{x:(e/this.mapSize-.5)*2*n+this.centerX,z:(t/this.mapSize-.5)*2*n+this.centerZ}}setupEvents(){const e=this.miniMapContainer;e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("mousedown",this.onMouseDown),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp),e.addEventListener("mouseleave",this.onMouseUp),e.addEventListener("contextmenu",t=>t.preventDefault()),["pointerdown","pointermove","pointerup","click","dblclick"].forEach(t=>e.addEventListener(t,n=>n.stopPropagation()))}onWheel=e=>{e.preventDefault(),e.stopPropagation();const t=e.deltaY>0?1.25:.8;this.currentHalfSize=Math.max(this.minHalfSize,Math.min(this.maxHalfSize,this.currentHalfSize*t))};onMouseDown=e=>{e.stopPropagation();const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,s=this.engine.camera;if(!s)return;const{x:r,y:a}=this.worldToPixel(s.position.x,s.position.z);Math.hypot(n-r,i-a)<25?(this.dragMode="rotate",this.miniMapContainer.style.cursor="alias"):(this.dragMode=null,this.handleTeleport(n,i)),this.lastMouseX=n,this.lastMouseY=i};onMouseMove=e=>{if(e.stopPropagation(),this.dragMode!=="rotate")return;const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.handleRotate(n,i),this.lastMouseX=n,this.lastMouseY=i};onMouseUp=e=>{e.stopPropagation(),this.dragMode=null,this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair")};handleTeleport(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const{x:s,z:r}=this.pixelToWorld(e,t),a=s-n.position.x,l=r-n.position.z;n.position.x+=a,n.position.z+=l,i.target.x+=a,i.target.z+=l,i.update()}handleRotate(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const s=this.mapSize/2,r=this.mapSize/2,a=Math.atan2(this.lastMouseY-r,this.lastMouseX-s);let c=Math.atan2(t-r,e-s)-a;c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);const h=new b.Vector3().copy(i.target).sub(n.position),d=new b.Spherical().setFromVector3(h);d.theta-=c,h.setFromSpherical(d),i.target.copy(n.position).add(h),i.update()}drawOverlay(){const e=this.overlayCtx,t=this.engine.camera;if(!e||!t)return;e.clearRect(0,0,this.mapSize,this.mapSize);const n=this.mapSize/2,i=this.mapSize/2,s=new b.Vector3;t.getWorldDirection(s);const r=Math.atan2(s.x,-s.z),a=36,l=Math.PI/10;e.save(),e.translate(n,i),e.rotate(r);const c=e.createRadialGradient(0,0,2,0,0,a);c.addColorStop(0,"rgba(0, 230, 130, 0.9)"),c.addColorStop(1,"rgba(0, 230, 130, 0)");const h=-Math.sin(l)*a,d=-Math.cos(l)*a,m=Math.sin(l)*a,p=-Math.cos(l)*a;e.beginPath(),e.moveTo(0,0),e.lineTo(h,d),e.lineTo(m,p),e.closePath(),e.fillStyle=c,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}show(){this.isVisible=!0,this.miniMapContainer&&(this.miniMapContainer.style.display="block")}hide(){this.isVisible=!1,this.miniMapContainer&&(this.miniMapContainer.style.display="none")}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.miniMapCamera||!this.miniMapRenderer)return;const e=this.engine.camera;if(!(!e||!this.engine.scene)){if(this.engine.octreeBox){const t=this.engine.octreeBox.getBoundingBox();if(t?.min&&t?.max){const n=t.max.x-t.min.x,i=t.max.z-t.min.z,s=t.max.y-t.min.y;this.camY=t.max.y+Math.max(n,i,s),!this.halfSizeInitialized&&n+i>0&&(this.currentHalfSize=Math.max(n,i)*2,this.halfSizeInitialized=!0)}}this.centerX=e.position.x,this.centerZ=e.position.z,this.miniMapCamera.left=-this.currentHalfSize,this.miniMapCamera.right=this.currentHalfSize,this.miniMapCamera.top=this.currentHalfSize,this.miniMapCamera.bottom=-this.currentHalfSize,this.miniMapCamera.updateProjectionMatrix(),this.miniMapCamera.position.set(this.centerX,this.camY,this.centerZ),this.miniMapCamera.lookAt(this.centerX,this.camY-1,this.centerZ),this.miniMapRenderer.render(this.engine.scene,this.miniMapCamera),this.drawOverlay()}}dispose(){this.miniMapContainer&&(this.miniMapContainer.removeEventListener("wheel",this.onWheel),this.miniMapContainer.removeEventListener("mousedown",this.onMouseDown),this.miniMapContainer.removeEventListener("mousemove",this.onMouseMove),this.miniMapContainer.removeEventListener("mouseup",this.onMouseUp),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseUp)),this.miniMapRenderer&&(this.miniMapRenderer.dispose(),this.miniMapRenderer=null),this.miniMapContainer&&(this.miniMapContainer.remove(),this.miniMapContainer=null),this.miniMapCamera=null,this.overlayCtx=null,this.overlayCanvas=null}}const Md=[{Id:"100001",Name:"1",Points:[{X:-2,Y:-5,Z:0},{X:-2,Y:5,Z:0}]},{Id:"100002",Name:"2",Points:[{X:2,Y:-5,Z:0},{X:2,Y:5,Z:0}]},{Id:"100003",Name:"A",Points:[{X:-5,Y:-2,Z:0},{X:5,Y:-2,Z:0}]},{Id:"100004",Name:"B",Points:[{X:-5,Y:2,Z:0},{X:5,Y:2,Z:0}]}];class _d{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new b.Vector3(e.X,e.Z,-e.Y);constructor(e){this.engine=e,this._initRoot()}setData(e){this._clearAxes(),this.axes=e.map(t=>({data:t,group:null})),this.axes.forEach(t=>this._buildAxis(t))}setMockData(){this.setData(Md)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let n=.5;if(e instanceof b.OrthographicCamera){const i=e,s=(i.top-i.bottom)/i.zoom,r=t.domElement.clientHeight||1;n=30*s/r}this.rootGroup.traverse(i=>{i instanceof b.Sprite&&i.scale.set(n,n,1)})}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new b.Group,this.rootGroup.name="GridRoot",this.rootGroup.visible=!1,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const n=t;if("geometry"in n&&n.geometry&&n.geometry.dispose(),"material"in n&&n.material){const i=n.material;"map"in i&&i.map&&i.map.dispose(),i.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),n=this.coordinateMapper(e.data.Points[1]),i=e.data.Name,s=new b.Group;s.name=`GridAxis_${e.data.Id}`;const r=new b.BufferGeometry().setFromPoints([t,n]),a=new b.LineBasicMaterial({color:1609983,depthTest:!1}),l=new b.Line(r,a);l.renderOrder=998,s.add(l),s.add(this._makeCircleSprite(i,t)),s.add(this._makeCircleSprite(i,n)),this.rootGroup.add(s),e.group=s}_makeCircleSprite(e,t){const i=document.createElement("canvas");i.width=128,i.height=128;const s=i.getContext("2d"),r=128/2,a=128/2,l=128/2-4;s.beginPath(),s.arc(r,a,l,0,Math.PI*2),s.fillStyle="white",s.fill(),s.strokeStyle="#1890ff",s.lineWidth=6,s.stroke(),s.fillStyle="#1890ff",s.font=`bold ${Math.round(128*.38)}px Arial`,s.textAlign="center",s.textBaseline="middle",s.fillText(e,r,a);const c=new b.CanvasTexture(i),h=new b.SpriteMaterial({map:c,depthTest:!1,transparent:!0}),d=new b.Sprite(h);return d.position.copy(t),d.scale.set(.5,.5,1),d.renderOrder=999,d}}const Sd=[{Id:"339",Name:"站台",Elevation:-.32808398950131235},{Id:"2787",Name:"站厅",Elevation:16.896325459317584},{Id:"236633",Name:"顶板",Elevation:36.745406824146976}];class Cd{engine;isVisible=!1;levels=[];svgContainer=null;svgOverlay=null;worldToScreen=null;halfSize=500;COLOR="#1890ff";PLANE_OPACITY=.08;constructor(e){this.engine=e,this._initSvg()}_initSvg(){this.svgContainer=document.createElement("div"),this.svgContainer.style.position="absolute",this.svgContainer.style.top="0",this.svgContainer.style.left="0",this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.svgContainer.style.pointerEvents="none",this.svgContainer.style.overflow="hidden",this.svgContainer.style.display="none",this.engine.container.appendChild(this.svgContainer),this.svgOverlay=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svgOverlay.style.position="absolute",this.svgOverlay.style.top="0",this.svgOverlay.style.left="0",this.svgOverlay.style.width="1920px",this.svgOverlay.style.height="1080px",this.svgOverlay.style.overflow="visible",this.svgContainer.appendChild(this.svgOverlay)}setData(e){this._clearAll(),this.levels=e.map(t=>({data:t,group:null,svgGroup:null})),this.levels.forEach(t=>this._buildThreeObject(t))}setMockData(){this.setData(Sd)}show(){this.isVisible=!0,this.svgContainer&&(this.svgContainer.style.display="block"),this.levels.forEach(e=>{e.group&&(e.group.visible=!0)})}hide(){this.isVisible=!1,this.svgContainer&&(this.svgContainer.style.display="none"),this.levels.forEach(e=>{e.group&&(e.group.visible=!1)})}toggle(){this.isVisible?this.hide():this.show()}update(){!this.isVisible||!this.svgOverlay||!this.levels.length||!this.engine.camera||!this.engine.renderer||(this._initWorldToScreen(),this.levels.forEach(e=>this._updateSvgLabels(e)))}dispose(){this._clearAll(),this.svgContainer&&(this.svgContainer.remove(),this.svgContainer=null),this.svgOverlay=null,this.worldToScreen=null}_initWorldToScreen(){this.engine.camera&&this.engine.renderer&&this.engine.scene&&(this.worldToScreen=new De(this.engine.camera,this.engine.renderer,this.engine.scene))}_clearAll(){this.levels.forEach(e=>{e.group&&this.engine.scene&&(this.engine.scene.remove(e.group),e.group.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}),e.group=null),e.svgGroup&&this.svgOverlay&&(e.svgGroup.remove(),e.svgGroup=null)}),this.levels=[]}_buildThreeObject(e){if(!this.engine.scene)return;const t=e.data.Elevation,n=this.halfSize,i=new b.Group,s=new b.PlaneGeometry(n*2,n*2);s.rotateX(-Math.PI/2);const r=new b.MeshBasicMaterial({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:b.DoubleSide,depthWrite:!1}),a=new b.Mesh(s,r);a.position.y=t,i.add(a);const l=[new b.Vector3(-n,t,-n),new b.Vector3(n,t,-n),new b.Vector3(n,t,n),new b.Vector3(-n,t,n),new b.Vector3(-n,t,-n)],c=new b.BufferGeometry().setFromPoints(l),h=new b.LineBasicMaterial({color:this.COLOR,transparent:!0,opacity:.7});if(i.add(new b.Line(c,h)),i.visible=this.isVisible,this.engine.scene.add(i),e.group=i,this.svgOverlay){const d=document.createElementNS("http://www.w3.org/2000/svg","g");d.dataset.levelId=e.data.Id;for(let m=0;m<4;m++)d.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(d),e.svgGroup=d}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new b.Vector3(-t,n,-t),new b.Vector3(t,n,-t),new b.Vector3(t,n,t),new b.Vector3(-t,n,t)],s=Array.from(e.svgGroup.children);i.forEach((r,a)=>{const l=this.worldToScreen.worldToScreen(r);s[a].setAttribute("x",String(l.x)),s[a].setAttribute("y",String(l.y))})}_makeLabel(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.textContent=`${e} ▲${t.toFixed(3)}m`,n.setAttribute("text-anchor","middle"),n.setAttribute("dominant-baseline","central"),n.setAttribute("fill",this.COLOR),n.setAttribute("font-size","12"),n.setAttribute("font-family","Arial, sans-serif"),n.setAttribute("font-weight","bold"),n.setAttribute("stroke","white"),n.setAttribute("stroke-width","2"),n.setAttribute("paint-order","stroke"),n.style.pointerEvents="none",n}}class Ad{engine;constructor(e){}update(){}}class Pd{engine;currentHdrId="0";isVisible=!0;currentIntensity=.2;currentTexture=null;skybox=null;textureCache=new Map;hdrList=[{id:"0",name:"无"},{id:"1",name:"纯净-多云",url:"assets/hdr/纯净-多云.hdr"},{id:"2",name:"纯净-落日",url:"assets/hdr/纯净-落日.hdr"},{id:"3",name:"纯净-少云",url:"assets/hdr/纯净-少云.hdr"},{id:"4",name:"纯净-无云",url:"assets/hdr/纯净-无云.hdr"},{id:"5",name:"纯净-夜晚",url:"assets/hdr/纯净-夜晚.hdr"},{id:"6",name:"纯净-阴天",url:"assets/hdr/纯净-阴天.hdr"},{id:"7",name:"纯净-中云",url:"assets/hdr/纯净-中云.hdr"}];constructor(e){this.engine=e}getHdrList(){return this.hdrList}async setHdr(e){const t=this.hdrList.find(n=>n.id===e);if(!t){console.warn(`[Hdr] HDR id "${e}" not found`);return}if(e==="0"||!t.url){this._clearHdr(),this.currentHdrId="0";return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}try{const n=await this._loadHdr(t.url);this.textureCache.set(e,n),this._applyTexture(n),this.currentHdrId=e}catch(n){console.error(`[Hdr] Failed to load HDR "${t.url}":`,n)}}setVisible(e){this.isVisible=e,e&&this.currentTexture&&!this.skybox?this._createSkybox(this.currentTexture):this.skybox&&(this.skybox.visible=e)}getCurrentHdrId(){return this.currentHdrId}getVisible(){return this.isVisible}setIntensity(e){this.currentIntensity=e,this.engine.scene&&(this.engine.scene.environmentIntensity=e),this.skybox&&this.skybox.material.color.setScalar(e)}getIntensity(){return this.currentIntensity}addHdrItem(e){const t=this.hdrList.find(n=>n.id===e.id);t?Object.assign(t,e):this.hdrList.push(e)}dispose(){this._clearHdr(),this.textureCache.forEach(e=>e.dispose()),this.textureCache.clear()}_loadHdr(e){return new Promise((t,n)=>{new nh().load(e,i=>{i.mapping=b.EquirectangularReflectionMapping,t(i)},void 0,i=>n(i))})}_applyTexture(e){if(this.currentTexture=e,!this.engine.scene)return;const t=new b.PMREMGenerator(this.engine.renderer),n=t.fromEquirectangular(e).texture;t.dispose(),this.engine.scene.environment=n,this.engine.scene.environmentIntensity=this.currentIntensity,this.engine.scene.background=null,this._removeSkybox(),this.isVisible&&this._createSkybox(e),this.engine.setting.setAmbientLightIntensity(0)}_createSkybox(e){const t=new b.SphereGeometry(500,64,32),n=new b.MeshBasicMaterial({map:e,side:b.BackSide,depthWrite:!1,fog:!1});this.skybox=new b.Mesh(t,n),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1,this.skybox.frustumCulled=!1,n.color.setScalar(this.currentIntensity),this.engine.scene.add(this.skybox)}_removeSkybox(){this.skybox&&(this.engine.scene.remove(this.skybox),this.skybox.geometry.dispose(),this.skybox.material.dispose(),this.skybox=null)}_clearHdr(){this.currentTexture=null,this._removeSkybox(),this.engine.scene&&(this.engine.scene.background=null,this.engine.scene.environment=null,this.engine.setting.setAmbientLightIntensity(1))}}class Td{engine;currentId="0";groundGroup;groundMesh=null;waterMaterial=null;clock;groundY=0;groundList=[{id:"0",name:"无"},{id:"1",name:"草地",color:4881486,roughness:.9,metalness:0,map:"/textures/ground/grass.jpg"},{id:"2",name:"混凝土",color:9474192,roughness:.85,metalness:.1,map:"/textures/ground/concrete.jpg"},{id:"3",name:"地砖",color:13152400,roughness:.55,metalness:.1,map:"/textures/ground/tiles.jpg"},{id:"4",name:"湖面",water:!0,waterColor:28062,waveHeight:.04,waveSpeed:.8},{id:"5",name:"海面",water:!0,waterColor:15708,waveHeight:.12,waveSpeed:1.4}];constructor(e){this.engine=e,this.groundGroup=new b.Group,this.groundGroup.name="groundGroup",this.clock=new b.Clock}init(){this.engine.scene.add(this.groundGroup)}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const n=this.groundList.find(c=>c.id===e);if(!n)return;const i=t?.size??300,s=n.water?80:1,r=new b.PlaneGeometry(i,i,s,s);r.rotateX(-Math.PI/2);let a;if(n.water)a=this._createWaterMaterial(n,t),this.waterMaterial=a;else{const c=new b.MeshStandardMaterial({color:n.color,roughness:n.roughness,metalness:n.metalness}),h=t?.textureUrl??n.map;h&&new b.TextureLoader().load(h,d=>{d.wrapS=d.wrapT=b.RepeatWrapping,d.repeat.set(8,8),c.map=d,c.needsUpdate=!0},void 0,()=>{}),a=c}const l=new b.Mesh(r,a);l.name="groundMesh",l.receiveShadow=!0,l.castShadow=!1,l.position.y=-.01,this.groundMesh=l,this.groundGroup.add(l),this.groundGroup.position.y=this.groundY,this.clock.start()}setHeight(e){this.groundY=e,this.groundGroup.position.y=e}getHeight(){return this.groundY}_createWaterMaterial(e,t){const n=new b.Color(e.waterColor),i=n.clone().multiplyScalar(.35),s=t?.sunDirection?t.sunDirection.clone().normalize():new b.Vector3(.5,.8,.5).normalize();return new b.ShaderMaterial({uniforms:{uTime:{value:0},uWaterColor:{value:n},uDeepColor:{value:i},uSunColor:{value:new b.Color(16777215)},uSunDir:{value:s},uWaveHeight:{value:e.waveHeight??.05},uWaveSpeed:{value:e.waveSpeed??1},uOpacity:{value:t?.opacity??.82}},vertexShader:Dd,fragmentShader:kd,transparent:!0,side:b.DoubleSide})}update(){if(!this.waterMaterial)return;this.waterMaterial.uniforms.uTime.value=this.clock.getElapsedTime();const e=this.engine.scene?.dirLight;if(e){const t=e.position.clone().normalize();this.waterMaterial.uniforms.uSunDir.value.copy(t)}}getGroundList(){return this.groundList.map(({id:e,name:t})=>({id:e,name:t}))}getCurrentId(){return this.currentId}show(){this.groundGroup.visible=!0}hide(){this.groundGroup.visible=!1}dispose(){this._dispose(),this.engine.scene.remove(this.groundGroup)}_dispose(){if(!this.groundMesh)return;this.groundMesh.geometry.dispose();const e=this.groundMesh.material;Array.isArray(e)?e.forEach(t=>t.dispose()):e.dispose(),this.groundGroup.remove(this.groundMesh),this.groundMesh=null,this.waterMaterial=null}}const Dd=`
1019
1019
  uniform float uTime;
1020
1020
  uniform float uWaveHeight;
1021
1021
  uniform float uWaveSpeed;
@@ -1096,7 +1096,7 @@ void main() {
1096
1096
 
1097
1097
  gl_FragColor = vec4(color, uOpacity);
1098
1098
  }
1099
- `;class Ed{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=3;_highFpsRequired=.1;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;minMap;grid;level;text;hdr;ground;models=[];reactBoundingClientRect={left:0,top:0};version="2.1.5";versionEl=null;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 qc(this),this.engineModelModule.init(),this.ai=new wd(this),this.deviceModule=new Ko(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Yo(this),this.sceneModule=new Zo(this),this.scene=this.sceneModule.scene,this.renderModule=new qo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ha(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new _a(this),this.composerModule.init(),this.events=new jc,this.engineStatus=new Vc(this),this.engineStatus.init(),this.loaderModule=new Uc(this),this.lightModule=new Gc(this),this.lightModule.init(),this.viewCube=new oh(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=ah(this),this.rangeScale=new lh(this),this.rangeScale.init(),this.clipping=new dd(this),this.clipping.init(),this.setting=new ch(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=Di(this),this.modelMapperBatch=new gd(this),this.measure=new vh(this),this.modelToolModule=new Xc(this),this.modelProperties=new md(this),this.interactionModule=new Wc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new $n(this),this.modelEdge=new yd(this),this.modelTree=new fd(this),this.engineInfo=new pd(this),this.pathRoaming=new xd(this),this.pathRoaming.init(),this.minMap=new bd(this),this.grid=new _d(this),this.level=new Cd(this),this.text=new Ad(this),this.hdr=new Pd(this),this.ground=new Td(this),this.ground.init(),this.worldToScreen=new De(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Qc,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",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(ft.EngineBusy)}),this.controls.addEventListener("end",()=>{i.events.trigger(ft.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const r=s-this._fpsLastCheck,a=this._fpsFrameCount/r*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let r=this.scene?.dirLight;r&&this.camera&&this.updateLightPosition(this.camera,r)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new b.Vector3;e.getWorldDirection(n);const i=100,s=new b.Vector3().copy(n).multiplyScalar(-i),r=new b.Vector3(0,1,0),a=new b.Vector3().crossVectors(n,r).normalize();s.addScaledVector(r,i*.5),s.addScaledVector(a,i*.3),t.position.copy(e.position).add(s);const l=new b.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}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,r=this.container.clientWidth/this.container.clientHeight;i.left=s*r/-2,i.right=s*r/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ft.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.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),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 b.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 b.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.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 b.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 b.Texture&&i.dispose()}),e.dispose()}}var Mn=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoaded="model-loaded",o.ModelLoadError="model-load-error",o.RenderStart="render-start",o.RenderEnd="render-end",o.CameraChanged="camera-changed",o.CameraReset="camera-reset",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.EntityClick="entity-click",o.LayerVisibilityChanged="layer-visibility-changed",o.LayerColorChanged="layer-color-changed",o.ViewZoomChanged="view-zoom-changed",o.ViewPanChanged="view-pan-changed",o.ToolActivated="tool-activated",o.ToolDeactivated="tool-deactivated",o.Error="error",o.Warning="warning",o))(Mn||{});class Ld{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(Mn).forEach(t=>{this.listeners.set(t,new Set),this.onceListeners.set(t,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const n=this.listeners.get(e);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const n=this.listeners.get(e);n&&n.size>0&&n.forEach(s=>{try{s(t)}catch(r){console.error(`[EventModule2d] Error in listener for ${e}:`,r)}});const i=this.onceListeners.get(e);i&&i.size>0&&(i.forEach(s=>{try{s(t)}catch(r){console.error(`[EventModule2d] Error in once listener for ${e}:`,r)}}),i.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);t&&t.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);return(t?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(Mn)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}const Id=`
1099
+ `;class Ed{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=3;_highFpsRequired=.1;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;minMap;grid;level;text;hdr;ground;models=[];reactBoundingClientRect={left:0,top:0};version="2.1.5";versionEl=null;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 qc(this),this.engineModelModule.init(),this.ai=new wd(this),this.deviceModule=new Ko(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Yo(this),this.sceneModule=new Zo(this),this.scene=this.sceneModule.scene,this.renderModule=new qo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ha(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new _a(this),this.composerModule.init(),this.events=new jc,this.engineStatus=new Vc(this),this.engineStatus.init(),this.loaderModule=new Uc(this),this.lightModule=new Gc(this),this.lightModule.init(),this.viewCube=new oh(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=ah(this),this.rangeScale=new lh(this),this.rangeScale.init(),this.clipping=new dd(this),this.clipping.init(),this.setting=new ch(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=ki(this),this.modelMapperBatch=new gd(this),this.measure=new vh(this),this.modelToolModule=new Xc(this),this.modelProperties=new md(this),this.interactionModule=new Wc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Hn(this),this.modelEdge=new yd(this),this.modelTree=new fd(this),this.engineInfo=new pd(this),this.pathRoaming=new xd(this),this.pathRoaming.init(),this.minMap=new bd(this),this.grid=new _d(this),this.level=new Cd(this),this.text=new Ad(this),this.hdr=new Pd(this),this.ground=new Td(this),this.ground.init(),this.worldToScreen=new De(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Qc,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",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(ft.EngineBusy)}),this.controls.addEventListener("end",()=>{i.events.trigger(ft.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const r=s-this._fpsLastCheck,a=this._fpsFrameCount/r*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let r=this.scene?.dirLight;r&&this.camera&&this.updateLightPosition(this.camera,r)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new b.Vector3;e.getWorldDirection(n);const i=100,s=new b.Vector3().copy(n).multiplyScalar(-i),r=new b.Vector3(0,1,0),a=new b.Vector3().crossVectors(n,r).normalize();s.addScaledVector(r,i*.5),s.addScaledVector(a,i*.3),t.position.copy(e.position).add(s);const l=new b.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}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,r=this.container.clientWidth/this.container.clientHeight;i.left=s*r/-2,i.right=s*r/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ft.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.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),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 b.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 b.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.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 b.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 b.Texture&&i.dispose()}),e.dispose()}}var _n=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoaded="model-loaded",o.ModelLoadError="model-load-error",o.RenderStart="render-start",o.RenderEnd="render-end",o.CameraChanged="camera-changed",o.CameraReset="camera-reset",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.EntityClick="entity-click",o.LayerVisibilityChanged="layer-visibility-changed",o.LayerColorChanged="layer-color-changed",o.ViewZoomChanged="view-zoom-changed",o.ViewPanChanged="view-pan-changed",o.ToolActivated="tool-activated",o.ToolDeactivated="tool-deactivated",o.Error="error",o.Warning="warning",o))(_n||{});class Ld{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(_n).forEach(t=>{this.listeners.set(t,new Set),this.onceListeners.set(t,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const n=this.listeners.get(e);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const n=this.listeners.get(e);n&&n.size>0&&n.forEach(s=>{try{s(t)}catch(r){console.error(`[EventModule2d] Error in listener for ${e}:`,r)}});const i=this.onceListeners.get(e);i&&i.size>0&&(i.forEach(s=>{try{s(t)}catch(r){console.error(`[EventModule2d] Error in once listener for ${e}:`,r)}}),i.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);t&&t.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);return(t?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(_n)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}const Id=`
1100
1100
  varying vec2 vWorldPos;
1101
1101
 
1102
1102
  void main() {
@@ -1159,8 +1159,8 @@ void main() {
1159
1159
 
1160
1160
  gl_FragColor = vec4(color, alpha);
1161
1161
  }
1162
- `;class Bd{scene;camera;container;gridGroup;gridGeometry;gridMaterial;gridMesh;animationFrameId=null;resizeObserver;windowResizeHandler;lastState={zoom:-1,centerX:Number.NaN,centerY:Number.NaN,viewWidth:0,viewHeight:0,containerWidth:0,containerHeight:0,minorSpacing:0};largeGridColor=6052956;smallGridColor=3815994;desiredMinorPixelSize=28;coverageMultiplier=1.6;minSpacing=1e-4;minorThicknessPx=.4;majorThicknessPx=.6;minorLineOpacity=.05;majorLineOpacity=.2;baseRenderOrder=-20;gridZOffset=-.001;majorStep=5;gridUniforms={minorSpacing:{value:100},majorStep:{value:this.majorStep},worldPerPixel:{value:new b.Vector2(1,1)},minorThicknessPx:{value:this.minorThicknessPx},majorThicknessPx:{value:this.majorThicknessPx},minorColor:{value:new b.Color(this.smallGridColor)},majorColor:{value:new b.Color(this.largeGridColor)},minorOpacity:{value:this.minorLineOpacity},majorOpacity:{value:this.majorLineOpacity}};constructor(e,t,n){this.scene=e,this.camera=t,this.container=n,this.gridGroup=new b.Group,this.gridGroup.name="AdaptiveGridGroup",this.gridGroup.renderOrder=this.baseRenderOrder,this.gridGroup.visible=!0,this.gridGroup.position.set(0,0,this.gridZOffset),this.scene.add(this.gridGroup),this.createGridMesh(),this.updateGrid(!0),this.startMonitoring(),this.setupResizeObserver()}createGridMesh(){this.gridGeometry=new b.PlaneGeometry(1,1,1,1),this.gridMaterial=new b.ShaderMaterial({uniforms:this.gridUniforms,vertexShader:Id,fragmentShader:zd,transparent:!0,depthWrite:!1,depthTest:!1,side:b.DoubleSide,toneMapped:!1}),this.gridMesh=new b.Mesh(this.gridGeometry,this.gridMaterial),this.gridMesh.frustumCulled=!1,this.gridMesh.renderOrder=this.baseRenderOrder,this.gridGroup.add(this.gridMesh)}startMonitoring(){const e=()=>{this.updateGrid(),this.animationFrameId=requestAnimationFrame(e)};e()}stopMonitoring(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}setupResizeObserver(){typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.updateGrid(!0)),this.resizeObserver.observe(this.container)):(this.windowResizeHandler=()=>this.updateGrid(!0),window.addEventListener("resize",this.windowResizeHandler))}teardownResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=void 0)}normalizeSpacing(e){const t=Math.max(e,this.minSpacing),n=Math.floor(Math.log10(t)),i=Math.pow(10,n),s=[1,2,5,10];for(const r of s){const a=r*i;if(t<=a)return a}return 10*i}updateGrid(e=!1){if(!this.gridMesh)return;const t=Math.max(1,this.container.clientWidth),n=Math.max(1,this.container.clientHeight),i=this.camera.zoom,s=this.camera.right-this.camera.left,r=this.camera.top-this.camera.bottom,a=Math.max(this.minSpacing,s/i),l=Math.max(this.minSpacing,r/i),h=this.camera.position.x,c=this.camera.position.y,d=a/t,m=l/n,p=d*this.desiredMinorPixelSize,f=this.normalizeSpacing(p),u=this.lastState;if(!e){const v=Math.abs(i-u.zoom)/Math.max(1e-4,u.zoom||1)>.02,w=Math.abs(f-u.minorSpacing)>u.minorSpacing*.05,x=Math.abs(h-u.centerX)>Math.max(f*.5,.01),M=Math.abs(c-u.centerY)>Math.max(f*.5,.01),T=Math.abs(a-u.viewWidth)>u.viewWidth*.01,P=Math.abs(l-u.viewHeight)>u.viewHeight*.01,k=t!==u.containerWidth||n!==u.containerHeight;if(!(v||w||x||M||T||P||k))return}const g=a*this.coverageMultiplier,y=l*this.coverageMultiplier;this.gridMesh.scale.set(g,y,1),this.gridMesh.position.set(h,c,0),this.gridUniforms.minorSpacing.value=f,this.gridUniforms.worldPerPixel.value.set(d,m),this.lastState={zoom:i,centerX:h,centerY:c,viewWidth:a,viewHeight:l,containerWidth:t,containerHeight:n,minorSpacing:f}}setVisible(e){this.gridGroup.visible=e}setColors(e,t){this.largeGridColor=e,this.smallGridColor=t,this.gridUniforms.majorColor.value.setHex(e),this.gridUniforms.minorColor.value.setHex(t)}setOpacity(e,t){this.minorLineOpacity=Math.max(0,Math.min(1,e)),this.majorLineOpacity=Math.max(0,Math.min(1,t)),this.gridUniforms.minorOpacity.value=this.minorLineOpacity,this.gridUniforms.majorOpacity.value=this.majorLineOpacity}dispose(){this.stopMonitoring(),this.teardownResizeObserver(),this.gridMesh&&this.gridGroup.remove(this.gridMesh),this.gridGeometry&&(this.gridGeometry.dispose(),this.gridGeometry=void 0),this.gridMaterial&&(this.gridMaterial.dispose(),this.gridMaterial=void 0),this.gridMesh=void 0}}class Od{engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new b.Scene,t=this.options.backgroundColor??1710618;return e.background=new b.Color(t),e.is2D=!0,e}initHelpers(){this.options.axesEnabled&&this.createAxes()}initGrid(){this.options.gridEnabled&&this.createGrid()}createGrid(e=1e3,t=50){this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.adaptiveGrid=new Bd(this.scene,this.engine.cameraModule2d.orthographicCamera,this.engine.renderModule2d.container);const n=this.options.backgroundColor??1710618;this.updateGridColorsByBackground(n)}createAxes(e=100){this.axesHelper&&this.scene.remove(this.axesHelper),this.axesHelper=new b.AxesHelper(e),this.axesHelper.rotation.z=0,this.scene.add(this.axesHelper),this.scene.remove(this.axesHelper),this.scene.add(this.axesHelper),this.axesHelper.renderOrder=999}setBackgroundColor(e){this.scene.background=new b.Color(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new b.Color(e);.299*t.r+.587*t.g+.114*t.b<.5?(this.adaptiveGrid.setColors(16777215,16777215),this.adaptiveGrid.setOpacity(.2,.3)):(this.adaptiveGrid.setColors(0,0),this.adaptiveGrid.setOpacity(.05,.2))}addObject(e){this.scene.add(e)}removeObject(e){this.scene.remove(e),e instanceof b.Mesh&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}clearScene(){for(let e=this.scene.children.length-1;e>=0;e--){const t=this.scene.children[e];t!==this.axesHelper&&(this.adaptiveGrid||this.removeObject(t))}this.engine.events&&this.engine.events.trigger("scene-cleared")}getObjects(e=!1){const t=[];return this.scene.children.forEach(n=>{(e||n!==this.axesHelper)&&t.push(n)}),t}getSceneStats(){let e=0,t=0,n=0;return this.scene.children.forEach(i=>{i instanceof b.Mesh?e++:i instanceof b.Line?t++:i instanceof b.Group&&n++}),{objectCount:this.scene.children.length,meshCount:e,lineCount:t,groupCount:n}}setGridVisible(e){this.adaptiveGrid&&this.adaptiveGrid.setVisible(e)}setAxesVisible(e){this.axesHelper&&(this.axesHelper.visible=e)}dispose(){this.clearScene(),this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper=void 0),this.scene.clear()}}class Rd{engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new b.Vector3(0,0,1e3);constructor(e,t){this.engine=e,this.container=t,this.orthographicCamera=this.createOrthographicCamera()}createOrthographicCamera(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e,i=new b.OrthographicCamera(-n,n,t,-t,this.near,this.far);return i.position.copy(this.defaultPosition),i.lookAt(0,0,0),i.zoom=this.initialZoom,i.updateProjectionMatrix(),i}fitToExtents(e,t=1.2){const n=new b.Vector3(...e.min),i=new b.Vector3(...e.max);if(!(n.distanceTo(i)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const r=new b.Vector3;r.addVectors(n,i).multiplyScalar(.5);const a=new b.Vector3;a.subVectors(i,n);const h=Math.max(a.x,a.y)*t,c=this.container.clientWidth/this.container.clientHeight,d=h/2,m=d*c;this.orthographicCamera.left=-m,this.orthographicCamera.right=m,this.orthographicCamera.top=d,this.orthographicCamera.bottom=-d,this.orthographicCamera.position.set(r.x,r.y,this.defaultPosition.z),this.orthographicCamera.zoom=1,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:r,size:a})}setZoom(e){this.orthographicCamera.zoom=e,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("view-zoom-changed",{zoom:e})}getZoom(){return this.orthographicCamera.zoom}setPosition(e,t){this.orthographicCamera.position.set(e,t,this.defaultPosition.z),this.engine.events&&this.engine.events.trigger("view-pan-changed",{x:e,y:t})}getPosition(){return this.orthographicCamera.position.clone()}resetView(){this.orthographicCamera.position.copy(this.defaultPosition),this.orthographicCamera.zoom=this.initialZoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-reset")}getViewBounds(){const e=this.orthographicCamera,t=e.zoom,n=e.left/t,i=e.right/t,s=e.top/t,r=e.bottom/t,a=e.position.x,l=e.position.y;return{minX:a+n,maxX:a+i,minY:l+r,maxY:l+s,width:i-n,height:s-r}}screenToWorld(e,t){const n=new b.Vector3(e/this.container.clientWidth*2-1,-(t/this.container.clientHeight)*2+1,.5);return n.unproject(this.orthographicCamera),n}worldToScreen(e,t){const n=new b.Vector3(e,t,0);return n.project(this.orthographicCamera),{x:(n.x+1)/2*this.container.clientWidth,y:-(n.y-1)/2*this.container.clientHeight}}updateAspectRatio(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e;this.orthographicCamera.left=-n,this.orthographicCamera.right=n,this.orthographicCamera.top=t,this.orthographicCamera.bottom=-t,this.orthographicCamera.updateProjectionMatrix()}setFrustumSize(e){this.frustumSize=e,this.updateAspectRatio()}getFrustumSize(){return this.frustumSize}dispose(){this.orthographicCamera=null}}class Nd{engine;renderer;container;options;antialias=!0;alpha=!1;precision="highp";constructor(e,t,n){this.engine=e,this.container=t,this.options=n,this.renderer=this.createRenderer(),this.handleResize()}createRenderer(){const e=new b.WebGLRenderer({antialias:this.antialias,alpha:this.alpha,precision:this.precision}),t=this.container.clientWidth,n=this.container.clientHeight;return e.setSize(t,n),e.setPixelRatio(window.devicePixelRatio),e.autoClear=!0,e.sortObjects=!0,e.setClearColor(this.options.backgroundColor??1710618),this.container.appendChild(e.domElement),e}render(e,t){const n=performance.now();this.engine.events&&this.engine.events.trigger("render-start"),this.renderer.render(e,t);const i=performance.now()-n;this.engine.events&&this.engine.events.trigger("render-end",{renderTime:i})}handleResize(){window.addEventListener("resize",()=>{this.onWindowResize()})}onWindowResize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio(),this.engine.scene&&this.engine.camera&&this.render(this.engine.scene,this.engine.camera)}setSize(e,t){this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio()}getSize(){const e=this.renderer.getSize(new b.Vector2);return{width:e.x,height:e.y}}setBackgroundColor(e){this.renderer.setClearColor(new b.Color(e))}setPixelRatio(e){this.renderer.setPixelRatio(e)}getPixelRatio(){return this.renderer.getPixelRatio()}setAntialias(e){console.warn("Antialias cannot be changed after renderer creation")}clear(e=!0,t=!0,n=!1){this.renderer.clear(e,t,n)}getInfo(){const e=this.renderer.getContext();return{renderer:this.renderer.capabilities.isWebGL2?"WebGL 2.0":"WebGL 1.0",version:this.renderer.capabilities.getVersion(),vendor:this.renderer.capabilities.vendor,capabilities:{maxTextureSize:this.renderer.capabilities.maxTextureSize,maxRenderbufferSize:this.renderer.capabilities.maxRenderbufferSize,maxVertexAttribs:this.renderer.capabilities.maxVertexAttribs,maxVaryingVectors:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)}}}dispose(){window.removeEventListener("resize",this.onWindowResize.bind(this)),this.renderer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer=null}}class Fd extends b.EventDispatcher{object;domElement;enabled=!0;enableZoom=!0;enablePan=!0;enableDamping=!1;dampingFactor=.05;zoomSpeed=1;minZoom=0;maxZoom=1/0;isDragging=!1;mouseButton=-1;previousMousePosition=new b.Vector2;targetPosition=new b.Vector3;targetZoom=1;lastClickTime=0;doubleClickDelay=300;constructor(e,t){super(),this.object=e,this.domElement=t||document,this.targetPosition.copy(e.position),this.targetZoom=e.zoom,this.bindEvents()}bindEvents(){this.domElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.addEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.addEventListener("wheel",this.onWheel.bind(this),{passive:!1}),this.domElement.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.addEventListener("click",this.onClick.bind(this)),this.domElement.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),this.domElement.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),this.domElement.addEventListener("touchend",this.onTouchEnd.bind(this)),this.domElement.addEventListener("contextmenu",e=>{e.preventDefault()})}onMouseDown(e){this.enabled&&this.enablePan&&(e.button===0||e.button===1)&&(this.isDragging=!0,this.mouseButton=e.button,this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"start"}))}onMouseMove(e){if(!this.enabled||!this.isDragging)return;const t=e.clientX-this.previousMousePosition.x,n=e.clientY-this.previousMousePosition.y,s=1/this.object.zoom,r=this.object.top-this.object.bottom,a=this.object.right-this.object.left,l=t/this.domElement.clientWidth*a*s,h=n/this.domElement.clientHeight*r*s;this.targetPosition.x-=l,this.targetPosition.y+=h,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"change"})}onMouseUp(e){this.isDragging&&(this.isDragging=!1,this.mouseButton=-1,this.dispatchEvent({type:"end"}))}onWheel(e){if(!this.enabled||!this.enableZoom)return;e.preventDefault();const t=Math.pow(1.1,-Math.sign(e.deltaY)*this.zoomSpeed),n=this.targetZoom;this.targetZoom*=t,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const i=this.targetZoom,s=(this.object.right-this.object.left)/2,r=(this.object.top-this.object.bottom)/2,a=this.domElement.getBoundingClientRect(),l=(e.clientX-a.left)/a.width*2-1,h=-((e.clientY-a.top)/a.height)*2+1;this.targetPosition.x+=l*s*(1/n-1/i),this.targetPosition.y+=h*r*(1/n-1/i),this.enableDamping||(this.object.zoom=i,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}onDoubleClick(e){this.enabled&&this.dispatchEvent({type:"doubleClick",event:e})}onClick(e){const t=performance.now();t-this.lastClickTime<this.doubleClickDelay||(this.lastClickTime=t)}onTouchStart(e){if(!this.enabled||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0];this.isDragging=!0,this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"start"})}onTouchMove(e){if(!this.enabled||!this.isDragging)return;e.preventDefault();const t=e.touches[0],n=t.clientX-this.previousMousePosition.x,i=t.clientY-this.previousMousePosition.y,r=1/this.object.zoom,a=this.object.top-this.object.bottom,l=this.object.right-this.object.left,h=n/this.domElement.clientWidth*l*r,c=i/this.domElement.clientHeight*a*r;this.targetPosition.x-=h,this.targetPosition.y+=c,this.enableDamping||this.object.position.copy(this.targetPosition),this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"change"})}onTouchEnd(e){this.isDragging&&(this.isDragging=!1,this.dispatchEvent({type:"end"}))}update(){if(this.enabled&&this.enableDamping){const e=1-this.dampingFactor;this.object.position.x+=(this.targetPosition.x-this.object.position.x)*e,this.object.position.y+=(this.targetPosition.y-this.object.position.y)*e,this.object.zoom+=(this.targetZoom-this.object.zoom)*e,this.object.updateProjectionMatrix()}}reset(){this.targetPosition.set(0,0,this.object.position.z),this.targetZoom=1,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"reset"})}setPosition(e,t){this.targetPosition.set(e,t,this.object.position.z),this.enableDamping||this.object.position.copy(this.targetPosition),this.dispatchEvent({type:"change"})}setZoom(e){this.targetZoom=e,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom)),this.enableDamping||(this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}dispose(){this.enabled=!1,this.domElement.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.removeEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.removeEventListener("wheel",this.onWheel.bind(this)),this.domElement.removeEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.removeEventListener("click",this.onClick.bind(this)),this.domElement.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.domElement.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.domElement.removeEventListener("touchend",this.onTouchEnd.bind(this))}}class Ud{engine;panControls;isActive=!0;constructor(e){this.engine=e,this.panControls=this.createPanControls(),this.init()}init(){this.panControls.addEventListener("doubleClick",this.onDoubleClick.bind(this)),this.panControls.addEventListener("change",this.onChange.bind(this))}createPanControls(){const e=new Fd(this.engine.camera,this.engine.renderer.domElement);return e.enableZoom=!0,e.enablePan=!0,e.enableDamping=!0,e.dampingFactor=.05,e.zoomSpeed=1,e.minZoom=0,e.maxZoom=1/0,e}onDoubleClick(e){this.engine.cameraModule2d&&this.engine.cameraModule2d.resetView()}onChange(){this.engine.events&&this.engine.events.trigger("camera-changed",{type:"user-interaction"})}active(){this.isActive=!0,this.panControls.enabled=!0}disActive(){this.isActive=!1,this.panControls.enabled=!1}update(){this.isActive&&this.panControls.update()}reset(){this.panControls.reset()}setPosition(e,t){this.panControls.setPosition(e,t)}setZoom(e){this.panControls.setZoom(e)}getZoom(){return this.panControls.object.zoom}setEnableZoom(e){this.panControls.enableZoom=e}setEnablePan(e){this.panControls.enablePan=e}setEnableDamping(e){this.panControls.enableDamping=e}setDampingFactor(e){this.panControls.dampingFactor=Math.max(0,Math.min(e,1))}setZoomSpeed(e){this.panControls.zoomSpeed=Math.max(.1,e)}setZoomLimits(e,t){this.panControls.minZoom=e,this.panControls.maxZoom=t}dispose(){this.panControls.dispose(),this.panControls=null}}class Vd extends _.Loader{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new _.FileLoader(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(a){const l=s.parse(JSON.parse(a));t&&t(l)},n,i)}parse(e){return new jd(e)}}class jd{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="ltr"){const i=[],s=Gd(e,t,this.data,n);for(let r=0,a=s.length;r<a;r++)i.push(...s[r].toShapes());return i}}function Gd(o,e,t,n){const i=Array.from(o),s=e/t.resolution,r=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,a=[];let l=0,h=0;(n=="rtl"||n=="tb")&&i.reverse();for(let c=0;c<i.length;c++){const d=i[c];if(d===`
1163
- `)l=0,h-=r;else{const m=Wd(d,s,l,h,t);n=="tb"?(l=0,h+=t.ascender*s):l+=m.offsetX,a.push(m.path)}}return a}function Wd(o,e,t,n,i){const s=i.glyphs[o]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+o+'" does not exists in font family '+i.familyName+".");return}const r=new _.ShapePath;let a,l,h,c,d,m,p,f;if(s.o){const u=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,y=u.length;g<y;)switch(u[g++]){case"m":a=u[g++]*e+t,l=u[g++]*e+n,r.moveTo(a,l);break;case"l":a=u[g++]*e+t,l=u[g++]*e+n,r.lineTo(a,l);break;case"q":h=u[g++]*e+t,c=u[g++]*e+n,d=u[g++]*e+t,m=u[g++]*e+n,r.quadraticCurveTo(d,m,h,c);break;case"b":h=u[g++]*e+t,c=u[g++]*e+n,d=u[g++]*e+t,m=u[g++]*e+n,p=u[g++]*e+t,f=u[g++]*e+n,r.bezierCurveTo(d,m,p,f,h,c);break}}return{offsetX:s.ha*e,path:r}}class Xd extends _.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const i=n.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}class Zd{engine;data=null;enableValidation=!0;constructor(e){this.engine=e}async loadModel(e,t={}){if(!e.includes(".json"))Gi(e+"/info",n=>{const i=JSON.parse(n);this.data=i,this.buildScene(i)});else{this.engine.events&&this.engine.events.trigger(Mn.ModelLoadStart,{url:e});const n=await this.fetchJson(e),i=this.parseData(n);if(!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i)}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;loadFont(){return new Promise((e,t)=>{new Vd().load("https://threejs.org/examples/fonts/helvetiker_regular.typeface.json",e,void 0,t)})}async buildScene(e){this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.textMap=new Map,console.log(this.model.layers),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this.loadBlock({entities:e.entities},"",!1),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(r=>{i.push(...r)}),i.length!=0){const r=new b.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var s=this.model.layers.find(c=>c.name==n.split("||")[0]);a=s.color}const l=new b.LineBasicMaterial({color:a}),h=new b.LineSegments(r,l);h.name=n,this.engine.scene.add(h)}}),this.model.textMap.forEach((t,n)=>{let i=Xi(t.map(h=>h.geometry),!1),s=parseInt(n.split("||")[1]);if(s==0){var r=this.model.layers.find(h=>h.name==n.split("||")[0]);s=r.color}const a=new b.LineBasicMaterial({color:s});let l=new b.Mesh(i,a);l.name=n,this.engine.scene.add(l)})}loadBlock(e,t,n,i=0){e.entities.forEach(s=>{const r=s.layer+"||"+s.color;let a=new Map;n?(a=this.totalBlock.get(t),a==null&&(a=new Map,this.totalBlock.set(t,a))):(a=this.model.modelMap.get(r),a==null&&(a=new Map,this.model.modelMap.set(r,a)));let l=[];switch(s.type){case"LINE":l=this.getPoint_line(s);break;case"CIRCLE":l=this.getPoint_arc(s);break;case"POLYLINE":l=this.getPoint_polyline(s);break;case"MTEXT":this.create_text(s);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(s.blockId);h?.forEach(d=>{l.push(...d.map(m=>m.clone()))});const c=this.getMatrix(s.position,s.scale,s.rotation);l.forEach(d=>{d.applyMatrix4(c)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${s.type}`),null}a.has(s.linkId)?a.get(s.linkId).push(...l):a.set(s.linkId,l)})}getPoint_polyline(e){let t=[];for(let n=0;n<e.points.length-1;n++)t.push(new b.Vector3(e.points[n].x,e.points[n].y,0)),t.push(new b.Vector3(e.points[n+1].x,e.points[n+1].y,0));return e.closed&&(t.push(new b.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),t.push(new b.Vector3(e.points[0].x,e.points[0].y,0))),t}create_text(e){if(!this.font||!e.text)return;const t=new Xd(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}])}getPoint_line(e){const t=new b.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),n=new b.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);return[t,n]}getPoint_arc(e){const t=e.center[0],n=e.center[1],i=e.radius,r=new b.EllipseCurve(t,n,i,i,e.startAngle,e.endAngle,!1,0).getPoints(30).map(l=>new b.Vector3(l.x,l.y,0));let a=[];for(let l=0;l<r.length-1;l++)a.push(r[l].clone()),a.push(r[l+1].clone());return a}getMatrix(e,t,n){const i=new b.Vector3(e[0],e[1],e[2]),s=new b.Euler(0,0,n),r=new b.Vector3(t[0],t[1],t[2]),a=new b.Quaternion;a.setFromEuler(s);const l=new b.Matrix4;return l.compose(i,a,r),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class Yd{panel=null;listEl=null;isVisible=!1;delegate;constructor(e,t){this.delegate=t,this._buildPanel(e)}show(){this.panel&&(this.panel.style.display="flex",this.isVisible=!0)}hide(){this.panel&&(this.panel.style.display="none",this.isVisible=!1)}toggle(){this.isVisible?this.hide():this.show()}refresh(){this._renderList()}_buildPanel(e){const t=document.createElement("div");t.style.cssText=`
1162
+ `;class Bd{scene;camera;container;gridGroup;gridGeometry;gridMaterial;gridMesh;animationFrameId=null;resizeObserver;windowResizeHandler;lastState={zoom:-1,centerX:Number.NaN,centerY:Number.NaN,viewWidth:0,viewHeight:0,containerWidth:0,containerHeight:0,minorSpacing:0};largeGridColor=6052956;smallGridColor=3815994;desiredMinorPixelSize=28;coverageMultiplier=1.6;minSpacing=1e-4;minorThicknessPx=.4;majorThicknessPx=.6;minorLineOpacity=.05;majorLineOpacity=.2;baseRenderOrder=-20;gridZOffset=-.001;majorStep=5;gridUniforms={minorSpacing:{value:100},majorStep:{value:this.majorStep},worldPerPixel:{value:new b.Vector2(1,1)},minorThicknessPx:{value:this.minorThicknessPx},majorThicknessPx:{value:this.majorThicknessPx},minorColor:{value:new b.Color(this.smallGridColor)},majorColor:{value:new b.Color(this.largeGridColor)},minorOpacity:{value:this.minorLineOpacity},majorOpacity:{value:this.majorLineOpacity}};constructor(e,t,n){this.scene=e,this.camera=t,this.container=n,this.gridGroup=new b.Group,this.gridGroup.name="AdaptiveGridGroup",this.gridGroup.renderOrder=this.baseRenderOrder,this.gridGroup.visible=!0,this.gridGroup.position.set(0,0,this.gridZOffset),this.scene.add(this.gridGroup),this.createGridMesh(),this.updateGrid(!0),this.startMonitoring(),this.setupResizeObserver()}createGridMesh(){this.gridGeometry=new b.PlaneGeometry(1,1,1,1),this.gridMaterial=new b.ShaderMaterial({uniforms:this.gridUniforms,vertexShader:Id,fragmentShader:zd,transparent:!0,depthWrite:!1,depthTest:!1,side:b.DoubleSide,toneMapped:!1}),this.gridMesh=new b.Mesh(this.gridGeometry,this.gridMaterial),this.gridMesh.frustumCulled=!1,this.gridMesh.renderOrder=this.baseRenderOrder,this.gridGroup.add(this.gridMesh)}startMonitoring(){const e=()=>{this.updateGrid(),this.animationFrameId=requestAnimationFrame(e)};e()}stopMonitoring(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}setupResizeObserver(){typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.updateGrid(!0)),this.resizeObserver.observe(this.container)):(this.windowResizeHandler=()=>this.updateGrid(!0),window.addEventListener("resize",this.windowResizeHandler))}teardownResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=void 0)}normalizeSpacing(e){const t=Math.max(e,this.minSpacing),n=Math.floor(Math.log10(t)),i=Math.pow(10,n),s=[1,2,5,10];for(const r of s){const a=r*i;if(t<=a)return a}return 10*i}updateGrid(e=!1){if(!this.gridMesh)return;const t=Math.max(1,this.container.clientWidth),n=Math.max(1,this.container.clientHeight),i=this.camera.zoom,s=this.camera.right-this.camera.left,r=this.camera.top-this.camera.bottom,a=Math.max(this.minSpacing,s/i),l=Math.max(this.minSpacing,r/i),c=this.camera.position.x,h=this.camera.position.y,d=a/t,m=l/n,p=d*this.desiredMinorPixelSize,f=this.normalizeSpacing(p),u=this.lastState;if(!e){const v=Math.abs(i-u.zoom)/Math.max(1e-4,u.zoom||1)>.02,w=Math.abs(f-u.minorSpacing)>u.minorSpacing*.05,x=Math.abs(c-u.centerX)>Math.max(f*.5,.01),M=Math.abs(h-u.centerY)>Math.max(f*.5,.01),T=Math.abs(a-u.viewWidth)>u.viewWidth*.01,P=Math.abs(l-u.viewHeight)>u.viewHeight*.01,k=t!==u.containerWidth||n!==u.containerHeight;if(!(v||w||x||M||T||P||k))return}const g=a*this.coverageMultiplier,y=l*this.coverageMultiplier;this.gridMesh.scale.set(g,y,1),this.gridMesh.position.set(c,h,0),this.gridUniforms.minorSpacing.value=f,this.gridUniforms.worldPerPixel.value.set(d,m),this.lastState={zoom:i,centerX:c,centerY:h,viewWidth:a,viewHeight:l,containerWidth:t,containerHeight:n,minorSpacing:f}}setVisible(e){this.gridGroup.visible=e}setColors(e,t){this.largeGridColor=e,this.smallGridColor=t,this.gridUniforms.majorColor.value.setHex(e),this.gridUniforms.minorColor.value.setHex(t)}setOpacity(e,t){this.minorLineOpacity=Math.max(0,Math.min(1,e)),this.majorLineOpacity=Math.max(0,Math.min(1,t)),this.gridUniforms.minorOpacity.value=this.minorLineOpacity,this.gridUniforms.majorOpacity.value=this.majorLineOpacity}dispose(){this.stopMonitoring(),this.teardownResizeObserver(),this.gridMesh&&this.gridGroup.remove(this.gridMesh),this.gridGeometry&&(this.gridGeometry.dispose(),this.gridGeometry=void 0),this.gridMaterial&&(this.gridMaterial.dispose(),this.gridMaterial=void 0),this.gridMesh=void 0}}class Od{engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new b.Scene,t=this.options.backgroundColor??1710618;return e.background=new b.Color(t),e.is2D=!0,e}initHelpers(){this.options.axesEnabled&&this.createAxes()}initGrid(){this.options.gridEnabled&&this.createGrid()}createGrid(e=1e3,t=50){this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.adaptiveGrid=new Bd(this.scene,this.engine.cameraModule2d.orthographicCamera,this.engine.renderModule2d.container);const n=this.options.backgroundColor??1710618;this.updateGridColorsByBackground(n)}createAxes(e=100){this.axesHelper&&this.scene.remove(this.axesHelper),this.axesHelper=new b.AxesHelper(e),this.axesHelper.rotation.z=0,this.scene.add(this.axesHelper),this.scene.remove(this.axesHelper),this.scene.add(this.axesHelper),this.axesHelper.renderOrder=999}setBackgroundColor(e){this.scene.background=new b.Color(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new b.Color(e);.299*t.r+.587*t.g+.114*t.b<.5?(this.adaptiveGrid.setColors(16777215,16777215),this.adaptiveGrid.setOpacity(.2,.3)):(this.adaptiveGrid.setColors(0,0),this.adaptiveGrid.setOpacity(.05,.2))}addObject(e){this.scene.add(e)}removeObject(e){this.scene.remove(e),e instanceof b.Mesh&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}clearScene(){for(let e=this.scene.children.length-1;e>=0;e--){const t=this.scene.children[e];t!==this.axesHelper&&(this.adaptiveGrid||this.removeObject(t))}this.engine.events&&this.engine.events.trigger("scene-cleared")}getObjects(e=!1){const t=[];return this.scene.children.forEach(n=>{(e||n!==this.axesHelper)&&t.push(n)}),t}getSceneStats(){let e=0,t=0,n=0;return this.scene.children.forEach(i=>{i instanceof b.Mesh?e++:i instanceof b.Line?t++:i instanceof b.Group&&n++}),{objectCount:this.scene.children.length,meshCount:e,lineCount:t,groupCount:n}}setGridVisible(e){this.adaptiveGrid&&this.adaptiveGrid.setVisible(e)}setAxesVisible(e){this.axesHelper&&(this.axesHelper.visible=e)}dispose(){this.clearScene(),this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper=void 0),this.scene.clear()}}class Rd{engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new b.Vector3(0,0,1e3);constructor(e,t){this.engine=e,this.container=t,this.orthographicCamera=this.createOrthographicCamera()}createOrthographicCamera(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e,i=new b.OrthographicCamera(-n,n,t,-t,this.near,this.far);return i.position.copy(this.defaultPosition),i.lookAt(0,0,0),i.zoom=this.initialZoom,i.updateProjectionMatrix(),i}fitToExtents(e,t=1.2){const n=new b.Vector3(e.min[0],e.min[1]),i=new b.Vector3(e.max[0],e.max[1]);if(!(n.distanceTo(i)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const r=new b.Vector3;r.addVectors(n,i).multiplyScalar(.5);const a=new b.Vector3;a.subVectors(i,n);const c=Math.max(a.x,a.y)*t,h=this.container.clientWidth/this.container.clientHeight,d=c/2,m=d*h;this.orthographicCamera.left=-m,this.orthographicCamera.right=m,this.orthographicCamera.top=d,this.orthographicCamera.bottom=-d,this.orthographicCamera.position.set(r.x,r.y,this.defaultPosition.z),this.orthographicCamera.zoom=1,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:r,size:a})}setZoom(e){this.orthographicCamera.zoom=e,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("view-zoom-changed",{zoom:e})}getZoom(){return this.orthographicCamera.zoom}setPosition(e,t){this.orthographicCamera.position.set(e,t,this.defaultPosition.z),this.engine.events&&this.engine.events.trigger("view-pan-changed",{x:e,y:t})}getPosition(){return this.orthographicCamera.position.clone()}resetView(){this.orthographicCamera.position.copy(this.defaultPosition),this.orthographicCamera.zoom=this.initialZoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-reset")}getViewBounds(){const e=this.orthographicCamera,t=e.zoom,n=e.left/t,i=e.right/t,s=e.top/t,r=e.bottom/t,a=e.position.x,l=e.position.y;return{minX:a+n,maxX:a+i,minY:l+r,maxY:l+s,width:i-n,height:s-r}}screenToWorld(e,t){const n=new b.Vector3(e/this.container.clientWidth*2-1,-(t/this.container.clientHeight)*2+1,.5);return n.unproject(this.orthographicCamera),n}worldToScreen(e,t){const n=new b.Vector3(e,t,0);return n.project(this.orthographicCamera),{x:(n.x+1)/2*this.container.clientWidth,y:-(n.y-1)/2*this.container.clientHeight}}updateAspectRatio(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e;this.orthographicCamera.left=-n,this.orthographicCamera.right=n,this.orthographicCamera.top=t,this.orthographicCamera.bottom=-t,this.orthographicCamera.updateProjectionMatrix()}setFrustumSize(e){this.frustumSize=e,this.updateAspectRatio()}getFrustumSize(){return this.frustumSize}dispose(){this.orthographicCamera=null}}class Nd{engine;renderer;container;options;antialias=!0;alpha=!1;precision="highp";constructor(e,t,n){this.engine=e,this.container=t,this.options=n,this.renderer=this.createRenderer(),this.handleResize()}createRenderer(){const e=new b.WebGLRenderer({antialias:this.antialias,alpha:this.alpha,precision:this.precision}),t=this.container.clientWidth,n=this.container.clientHeight;return e.setSize(t,n),e.setPixelRatio(window.devicePixelRatio),e.autoClear=!0,e.sortObjects=!0,e.setClearColor(this.options.backgroundColor??1710618),this.container.appendChild(e.domElement),e}render(e,t){const n=performance.now();this.engine.events&&this.engine.events.trigger("render-start"),this.renderer.render(e,t);const i=performance.now()-n;this.engine.events&&this.engine.events.trigger("render-end",{renderTime:i})}handleResize(){window.addEventListener("resize",()=>{this.onWindowResize()})}onWindowResize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio(),this.engine.scene&&this.engine.camera&&this.render(this.engine.scene,this.engine.camera)}setSize(e,t){this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio()}getSize(){const e=this.renderer.getSize(new b.Vector2);return{width:e.x,height:e.y}}setBackgroundColor(e){this.renderer.setClearColor(new b.Color(e))}setPixelRatio(e){this.renderer.setPixelRatio(e)}getPixelRatio(){return this.renderer.getPixelRatio()}setAntialias(e){console.warn("Antialias cannot be changed after renderer creation")}clear(e=!0,t=!0,n=!1){this.renderer.clear(e,t,n)}getInfo(){const e=this.renderer.getContext();return{renderer:this.renderer.capabilities.isWebGL2?"WebGL 2.0":"WebGL 1.0",version:this.renderer.capabilities.getVersion(),vendor:this.renderer.capabilities.vendor,capabilities:{maxTextureSize:this.renderer.capabilities.maxTextureSize,maxRenderbufferSize:this.renderer.capabilities.maxRenderbufferSize,maxVertexAttribs:this.renderer.capabilities.maxVertexAttribs,maxVaryingVectors:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)}}}dispose(){window.removeEventListener("resize",this.onWindowResize.bind(this)),this.renderer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer=null}}class Fd extends b.EventDispatcher{object;domElement;enabled=!0;enableZoom=!0;enablePan=!0;enableDamping=!1;dampingFactor=.05;zoomSpeed=1;minZoom=0;maxZoom=1/0;isDragging=!1;mouseButton=-1;previousMousePosition=new b.Vector2;targetPosition=new b.Vector3;targetZoom=1;lastClickTime=0;doubleClickDelay=300;constructor(e,t){super(),this.object=e,this.domElement=t||document,this.targetPosition.copy(e.position),this.targetZoom=e.zoom,this.bindEvents()}bindEvents(){this.domElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.addEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.addEventListener("wheel",this.onWheel.bind(this),{passive:!1}),this.domElement.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.addEventListener("click",this.onClick.bind(this)),this.domElement.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),this.domElement.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),this.domElement.addEventListener("touchend",this.onTouchEnd.bind(this)),this.domElement.addEventListener("contextmenu",e=>{e.preventDefault()})}onMouseDown(e){this.enabled&&this.enablePan&&(e.button===0||e.button===1)&&(this.isDragging=!0,this.mouseButton=e.button,this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"start"}))}onMouseMove(e){if(!this.enabled||!this.isDragging)return;const t=e.clientX-this.previousMousePosition.x,n=e.clientY-this.previousMousePosition.y,s=1/this.object.zoom,r=this.object.top-this.object.bottom,a=this.object.right-this.object.left,l=t/this.domElement.clientWidth*a*s,c=n/this.domElement.clientHeight*r*s;this.targetPosition.x-=l,this.targetPosition.y+=c,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"change"})}onMouseUp(e){this.isDragging&&(this.isDragging=!1,this.mouseButton=-1,this.dispatchEvent({type:"end"}))}onWheel(e){if(!this.enabled||!this.enableZoom)return;e.preventDefault();const t=Math.pow(1.1,-Math.sign(e.deltaY)*this.zoomSpeed),n=this.targetZoom;this.targetZoom*=t,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const i=this.targetZoom,s=(this.object.right-this.object.left)/2,r=(this.object.top-this.object.bottom)/2,a=this.domElement.getBoundingClientRect(),l=(e.clientX-a.left)/a.width*2-1,c=-((e.clientY-a.top)/a.height)*2+1;this.targetPosition.x+=l*s*(1/n-1/i),this.targetPosition.y+=c*r*(1/n-1/i),this.enableDamping||(this.object.zoom=i,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}onDoubleClick(e){this.enabled&&this.dispatchEvent({type:"doubleClick",event:e})}onClick(e){const t=performance.now();t-this.lastClickTime<this.doubleClickDelay||(this.lastClickTime=t)}onTouchStart(e){if(!this.enabled||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0];this.isDragging=!0,this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"start"})}onTouchMove(e){if(!this.enabled||!this.isDragging)return;e.preventDefault();const t=e.touches[0],n=t.clientX-this.previousMousePosition.x,i=t.clientY-this.previousMousePosition.y,r=1/this.object.zoom,a=this.object.top-this.object.bottom,l=this.object.right-this.object.left,c=n/this.domElement.clientWidth*l*r,h=i/this.domElement.clientHeight*a*r;this.targetPosition.x-=c,this.targetPosition.y+=h,this.enableDamping||this.object.position.copy(this.targetPosition),this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"change"})}onTouchEnd(e){this.isDragging&&(this.isDragging=!1,this.dispatchEvent({type:"end"}))}update(){if(this.enabled&&this.enableDamping){const e=1-this.dampingFactor;this.object.position.x+=(this.targetPosition.x-this.object.position.x)*e,this.object.position.y+=(this.targetPosition.y-this.object.position.y)*e,this.object.zoom+=(this.targetZoom-this.object.zoom)*e,this.object.updateProjectionMatrix()}}reset(){this.targetPosition.set(0,0,this.object.position.z),this.targetZoom=1,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"reset"})}setPosition(e,t){this.targetPosition.set(e,t,this.object.position.z),this.enableDamping||this.object.position.copy(this.targetPosition),this.dispatchEvent({type:"change"})}setZoom(e){this.targetZoom=e,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom)),this.enableDamping||(this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}dispose(){this.enabled=!1,this.domElement.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.removeEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.removeEventListener("wheel",this.onWheel.bind(this)),this.domElement.removeEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.removeEventListener("click",this.onClick.bind(this)),this.domElement.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.domElement.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.domElement.removeEventListener("touchend",this.onTouchEnd.bind(this))}}class Ud{engine;panControls;isActive=!0;constructor(e){this.engine=e,this.panControls=this.createPanControls(),this.init()}init(){this.panControls.addEventListener("doubleClick",this.onDoubleClick.bind(this)),this.panControls.addEventListener("change",this.onChange.bind(this))}createPanControls(){const e=new Fd(this.engine.camera,this.engine.renderer.domElement);return e.enableZoom=!0,e.enablePan=!0,e.enableDamping=!0,e.dampingFactor=.05,e.zoomSpeed=1,e.minZoom=0,e.maxZoom=1/0,e}onDoubleClick(e){this.engine.cameraModule2d&&this.engine.cameraModule2d.resetView()}onChange(){this.engine.events&&this.engine.events.trigger("camera-changed",{type:"user-interaction"})}active(){this.isActive=!0,this.panControls.enabled=!0}disActive(){this.isActive=!1,this.panControls.enabled=!1}update(){this.isActive&&this.panControls.update()}reset(){this.panControls.reset()}setPosition(e,t){this.panControls.setPosition(e,t)}setZoom(e){this.panControls.setZoom(e)}getZoom(){return this.panControls.object.zoom}setEnableZoom(e){this.panControls.enableZoom=e}setEnablePan(e){this.panControls.enablePan=e}setEnableDamping(e){this.panControls.enableDamping=e}setDampingFactor(e){this.panControls.dampingFactor=Math.max(0,Math.min(e,1))}setZoomSpeed(e){this.panControls.zoomSpeed=Math.max(.1,e)}setZoomLimits(e,t){this.panControls.minZoom=e,this.panControls.maxZoom=t}dispose(){this.panControls.dispose(),this.panControls=null}}class Vd extends _.Loader{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new _.FileLoader(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(a){const l=s.parse(JSON.parse(a));t&&t(l)},n,i)}parse(e){return new jd(e)}}class jd{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="ltr"){const i=[],s=Gd(e,t,this.data,n);for(let r=0,a=s.length;r<a;r++)i.push(...s[r].toShapes());return i}}function Gd(o,e,t,n){const i=Array.from(o),s=e/t.resolution,r=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,a=[];let l=0,c=0;(n=="rtl"||n=="tb")&&i.reverse();for(let h=0;h<i.length;h++){const d=i[h];if(d===`
1163
+ `)l=0,c-=r;else{const m=Wd(d,s,l,c,t);n=="tb"?(l=0,c+=t.ascender*s):l+=m.offsetX,a.push(m.path)}}return a}function Wd(o,e,t,n,i){const s=i.glyphs[o]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+o+'" does not exists in font family '+i.familyName+".");return}const r=new _.ShapePath;let a,l,c,h,d,m,p,f;if(s.o){const u=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,y=u.length;g<y;)switch(u[g++]){case"m":a=u[g++]*e+t,l=u[g++]*e+n,r.moveTo(a,l);break;case"l":a=u[g++]*e+t,l=u[g++]*e+n,r.lineTo(a,l);break;case"q":c=u[g++]*e+t,h=u[g++]*e+n,d=u[g++]*e+t,m=u[g++]*e+n,r.quadraticCurveTo(d,m,c,h);break;case"b":c=u[g++]*e+t,h=u[g++]*e+n,d=u[g++]*e+t,m=u[g++]*e+n,p=u[g++]*e+t,f=u[g++]*e+n,r.bezierCurveTo(d,m,p,f,c,h);break}}return{offsetX:s.ha*e,path:r}}class Xd extends _.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const i=n.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}class Zd{engine;data=null;enableValidation=!0;constructor(e){this.engine=e}async loadModel(e,t={}){if(!e.includes(".json"))Wi(e+"/info",n=>{const i=JSON.parse(n);this.engine.dwgData=i,this.data=i,this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers()});else{this.engine.events&&this.engine.events.trigger(_n.ModelLoadStart,{url:e});const n=await this.fetchJson(e),i=this.parseData(n);if(this.engine.dwgData=i,!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers()}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;loadFont(){return new Promise((e,t)=>{new Vd().load("https://threejs.org/examples/fonts/helvetiker_regular.typeface.json",e,void 0,t)})}async buildScene(e){this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,console.log(this.model.layers),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this.loadBlock({entities:e.entities},"",!1),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(r=>{i.push(...r)}),i.length!=0){const r=new b.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var s=this.model.layers.find(h=>h.name==n.split("||")[0]);a=s.color}const l=new b.LineBasicMaterial({color:a}),c=new b.LineSegments(r,l);c.name=n,this.engine.scene.add(c)}}),this.model.textMap.forEach((t,n)=>{let i=cn(t.map(c=>c.geometry),!1),s=parseInt(n.split("||")[1]);if(s==0){var r=this.model.layers.find(c=>c.name==n.split("||")[0]);s=r.color}const a=new b.LineBasicMaterial({color:s});let l=new b.Mesh(i,a);l.name=n,this.engine.scene.add(l)}),this.model.hatchMap.forEach((t,n)=>{let i=cn(t.map(c=>c.geometry),!1),s=parseInt(n.split("||")[1]);if(s==0){var r=this.model.layers.find(c=>c.name==n.split("||")[0]);s=r.color}const a=new b.MeshBasicMaterial({color:s,side:b.DoubleSide,transparent:!0,opacity:.5});let l=new b.Mesh(i,a);l.name=n,this.engine.scene.add(l)})}loadBlock(e,t,n,i=0){let s=[0,0,0];n&&(s=e.origin),e.entities.forEach(r=>{const a=r.layer+"||"+r.color;let l=new Map;n?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(a),l==null&&(l=new Map,this.model.modelMap.set(a,l)));let c=[];switch(r.type){case"LINE":c=this.getPoint_line(r,s);break;case"CIRCLE":c=this.getPoint_arc(r,s);break;case"POLYLINE":c=this.getPoint_polyline(r,s);break;case"MTEXT":this.create_text(r);break;case"HATCH":this.create_hatch(r);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(r.blockId);h?.forEach(m=>{c.push(...m.map(p=>p.clone()))});const d=this.getMatrix(r.position,r.scale,r.rotation);c.forEach(m=>{m.applyMatrix4(d)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${r.type}`),null}l.has(r.linkId)?l.get(r.linkId).push(...c):l.set(r.linkId,c)})}getPoint_polyline(e,t){let n=[];for(let i=0;i<e.points.length-1;i++)n.push(new b.Vector3(e.points[i].x,e.points[i].y,0)),n.push(new b.Vector3(e.points[i+1].x,e.points[i+1].y,0));return e.closed&&(n.push(new b.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),n.push(new b.Vector3(e.points[0].x,e.points[0].y,0))),n.forEach(i=>{i[0]=i[0]-t[0],i[1]=i[1]-t[1]}),n}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(a=>a.type===!0),n=e.loops.filter(a=>a.type===!1),i=[];for(const a of t){if(!a.points||a.points.length<3)continue;const l=new b.Shape;l.moveTo(a.points[0][0],a.points[0][1]);for(let c=1;c<a.points.length;c++)l.lineTo(a.points[c][0],a.points[c][1]);l.closePath();for(const c of n){if(!c.points||c.points.length<3)continue;const h=new b.Path;h.moveTo(c.points[0][0],c.points[0][1]);for(let d=1;d<c.points.length;d++)h.lineTo(c.points[d][0],c.points[d][1]);h.closePath(),l.holes.push(h)}i.push(new b.ShapeGeometry(l))}if(i.length===0)return;const s=i.length===1?i[0]:cn(i,!1),r=e.layer+"||"+e.color;this.model.hatchMap.has(r)?this.model.hatchMap.get(r).push({geometry:s,info:e}):this.model.hatchMap.set(r,[{geometry:s,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new Xd(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}])}getPoint_line(e,t){const n=new b.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),i=new b.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let s=[n,i];return s.forEach(r=>{r[0]=r[0]-t[0],r[1]=r[1]-t[1]}),s}getPoint_arc(e,t){const n=e.center[0],i=e.center[1],s=e.radius,a=new b.EllipseCurve(n,i,s,s,e.startAngle,e.endAngle,!1,0).getPoints(30).map(c=>new b.Vector3(c.x,c.y,0));let l=[];for(let c=0;c<a.length-1;c++)l.push(a[c].clone()),l.push(a[c+1].clone());return l.forEach(c=>{c[0]=c[0]-t[0],c[1]=c[1]-t[1]}),l}getMatrix(e,t,n){const i=new b.Vector3(e[0],e[1],e[2]),s=new b.Euler(0,0,n),r=new b.Vector3(t[0],t[1],t[2]),a=new b.Quaternion;a.setFromEuler(s);const l=new b.Matrix4;return l.compose(i,a,r),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class Yd{panel=null;listEl=null;isVisible=!1;delegate;constructor(e,t){this.delegate=t,this._buildPanel(e)}show(){this.panel&&(this.panel.style.display="flex",this.isVisible=!0)}hide(){this.panel&&(this.panel.style.display="none",this.isVisible=!1)}toggle(){this.isVisible?this.hide():this.show()}refresh(){this._renderList()}_buildPanel(e){const t=document.createElement("div");t.style.cssText=`
1164
1164
  position:absolute; top:10px; right:10px;
1165
1165
  width:220px; max-height:480px;
1166
1166
  background:var(--e2d-bg,#1e1f22);
@@ -1182,11 +1182,11 @@ void main() {
1182
1182
  color:var(--e2d-close,#aaa);
1183
1183
  font-size:18px; line-height:1; cursor:pointer; padding:0 2px;
1184
1184
  transition:color 0.15s;
1185
- `,s.onmouseenter=()=>{s.style.color="var(--e2d-close-hover,#fff)"},s.onmouseleave=()=>{s.style.color="var(--e2d-close,#aaa)"},s.onclick=()=>this.hide(),n.appendChild(i),n.appendChild(s),this._makeDraggable(t,n);const r=this._createRow(),a=this._createEye(!0),l=document.createElement("span");l.textContent="全部图层",l.style.cssText="flex:1; font-weight:500; color:var(--e2d-text,#e0e0e0);",r.appendChild(a),r.appendChild(l),r.onclick=()=>{const m=!this.delegate.isAllVisible();this.delegate.setAllLayersVisible(m),this._renderList(),this._updateEye(a,m)};const h=document.createElement("div");h.style.cssText="height:1px; background:var(--e2d-border2,#333); margin:0 8px; flex-shrink:0;";const c=document.createElement("div");c.style.cssText=`
1185
+ `,s.onmouseenter=()=>{s.style.color="var(--e2d-close-hover,#fff)"},s.onmouseleave=()=>{s.style.color="var(--e2d-close,#aaa)"},s.onclick=()=>this.hide(),n.appendChild(i),n.appendChild(s),this._makeDraggable(t,n);const r=this._createRow(),a=this._createEye(!0),l=document.createElement("span");l.textContent="全部图层",l.style.cssText="flex:1; font-weight:500; color:var(--e2d-text,#e0e0e0);",r.appendChild(a),r.appendChild(l),r.onclick=()=>{const m=!this.delegate.isAllVisible();this.delegate.setAllLayersVisible(m),this._renderList(),this._updateEye(a,m)};const c=document.createElement("div");c.style.cssText="height:1px; background:var(--e2d-border2,#333); margin:0 8px; flex-shrink:0;";const h=document.createElement("div");h.style.cssText=`
1186
1186
  overflow-y:auto; flex:1;
1187
1187
  scrollbar-width:thin;
1188
1188
  scrollbar-color:var(--e2d-scrollbar,#444) transparent;
1189
- `,this.listEl=c,t.appendChild(n),t.appendChild(r),t.appendChild(h),t.appendChild(c);const d=this._renderList.bind(this);this._renderList=()=>{d(),this._updateEye(a,this.delegate.isAllVisible())},this._renderList(),e.style.position="relative",e.appendChild(t)}_renderList(){const e=this.listEl;if(e){e.innerHTML="";for(const t of this.delegate.getLayers()){const n=this._createRow(),i=this._createEye(t.visible),s=document.createElement("span");s.style.cssText=`
1189
+ `,this.listEl=h,t.appendChild(n),t.appendChild(r),t.appendChild(c),t.appendChild(h);const d=this._renderList.bind(this);this._renderList=()=>{d(),this._updateEye(a,this.delegate.isAllVisible())},this._renderList(),e.style.position="relative",e.appendChild(t)}_renderList(){const e=this.listEl;if(e){e.innerHTML="";for(const t of this.delegate.getLayers()){const n=this._createRow(),i=this._createEye(t.visible),s=document.createElement("span");s.style.cssText=`
1190
1190
  width:14px; height:14px; border-radius:2px; flex-shrink:0;
1191
1191
  border:1px solid var(--e2d-swatch-border,#444);
1192
1192
  background:${this._colorToHex(t.color)};
@@ -1207,16 +1207,16 @@ void main() {
1207
1207
  <path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
1208
1208
  <path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
1209
1209
  <path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
1210
- </svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-s.left+"px",e.style.top=i.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const r=n.clientX-i.left,a=n.clientY-i.top,l=c=>{e.style.left=c.clientX-r-s.left+"px",e.style.top=c.clientY-a-s.top+"px"},h=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",h)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",h)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}const Kd=[];class qd{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e,this._loadLayers(Kd);const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new Yd(t,this))}_loadLayers(e){this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t})}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(s=>{s.name?.startsWith(i)&&(s.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}function $d(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",h),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),o.renderer.domElement.addEventListener("touchend",p,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",a),o.renderer.domElement.removeEventListener("mouseup",h),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",d),o.renderer.domElement.removeEventListener("touchend",p),o.renderer.domElement.removeEventListener("touchmove",m),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 g=new b.Vector2,y=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return g.x=u.offsetX/y*2-1,g.y=-(u.offsetY/v)*2+1,g}function s(u){const g=new b.Raycaster,y=i(u);return g.setFromCamera(y,o.camera),g}function r(u,g=!1){const y=s(u);if(u.raycaster=y,g){const v=void 0;u.catch=v}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new b.Vector3(u.offsetX,u.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,r(u,!0),u.catch!=null&&o.controlModule.orbitControls.origin.set(u.catch.point.x,u.catch.point.y,u.catch.point.z),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(u)}function h(u){if(u.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new b.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const w=v.distanceTo(e.mouseDownPosition);if((y<100||w==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const x=g-e.lastClickTime;console.log(x),x<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function c(u){const g=u.touches[0]||u.changedTouches[0];if(!g)return null;const v=o.renderer.domElement.getBoundingClientRect(),w=g.clientX-v.left,x=g.clientY-v.top;return{offsetX:w,offsetY:x,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>u.preventDefault(),stopPropagation:()=>u.stopPropagation(),originalEvent:u}}function d(u){if(u.preventDefault(),u.touches.length!==1)return;const g=c(u);g&&a(g)}function m(u){if(u.preventDefault(),u.touches.length!==1)return;const g=c(u);g&&l(g)}function p(u){u.preventDefault();const g=c(u);g&&h(g)}function f(u,g){}return e}class Hd{el;xEl;yEl;constructor(e){this.el=document.createElement("div"),this.el.className="engine-2d-mouse-coord";const t=document.createElement("span");t.className="engine-2d-mouse-coord__label",t.textContent="坐标",this.xEl=document.createElement("span"),this.xEl.className="engine-2d-mouse-coord__value",this.xEl.textContent="X: --",this.yEl=document.createElement("span"),this.yEl.className="engine-2d-mouse-coord__value",this.yEl.textContent="Y: --",this.el.appendChild(t),this.el.appendChild(this.xEl),this.el.appendChild(this.yEl),e.appendChild(this.el)}update(e,t){this.xEl.textContent=`X: ${e.toFixed(0)} mm`,this.yEl.textContent=`Y: ${t.toFixed(0)} mm`}reset(){this.xEl.textContent="X: --",this.yEl.textContent="Y: --"}dispose(){this.el.parentElement?.removeChild(this.el)}}class Jd{engine;behavior;mouseCoordUI=null;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved2d,this.behavior.init(this);const e=this.engine.container;e&&(this.mouseCoordUI=new Hd(e))}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handleMouseMove(e){if(!this.mouseCoordUI||!this.engine.cameraModule2d)return;const t=this.engine.cameraModule2d.screenToWorld(e.offsetX,e.offsetY);this.mouseCoordUI.update(t.x*1e3,t.y*1e3)}handleMouseClick(e){}dispose(){this.mouseCoordUI?.dispose(),this.mouseCoordUI=null}}class Qd{overlay;hLine;vLine;box;canvas;constructor(e,t){this.canvas=t,t.style.cursor="none",this.overlay=document.createElement("div"),this.overlay.className="engine-2d-cad-cursor",this.hLine=document.createElement("div"),this.hLine.className="engine-2d-cad-cursor__h",this.vLine=document.createElement("div"),this.vLine.className="engine-2d-cad-cursor__v",this.box=document.createElement("div"),this.box.className="engine-2d-cad-cursor__box",this.overlay.appendChild(this.hLine),this.overlay.appendChild(this.vLine),this.overlay.appendChild(this.box),e.appendChild(this.overlay),this.hide(),this.bindEvents()}bindEvents(){this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseenter",this.onMouseEnter),this.canvas.addEventListener("mouseleave",this.onMouseLeave)}onMouseMove=e=>{const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.hLine.style.top=`${i}px`,this.vLine.style.left=`${n}px`,this.box.style.left=`${n}px`,this.box.style.top=`${i}px`};onMouseEnter=()=>{this.show()};onMouseLeave=()=>{this.hide()};show(){this.overlay.style.visibility="visible"}hide(){this.overlay.style.visibility="hidden"}dispose(){this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseenter",this.onMouseEnter),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.style.cursor="",this.overlay.parentElement?.removeChild(this.overlay)}}const ef=[{action:"search",label:"搜索"},{action:"hideElement",label:"隐藏元素",dividerBefore:!0},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层",dividerBefore:!0},{action:"showAllLayers",label:"显示所有图层"}];class tf{menu;container;canvas;onAction;constructor(e,t,n){this.container=e,this.canvas=t,this.onAction=n,this.menu=this.createMenu(),e.appendChild(this.menu),this.bindEvents()}createMenu(){const e=document.createElement("div");return e.className="engine-2d-context-menu",ef.forEach(t=>{if(t.dividerBefore){const i=document.createElement("div");i.className="engine-2d-context-menu__divider",e.appendChild(i)}const n=document.createElement("div");n.className="engine-2d-context-menu__item",n.textContent=t.label,n.dataset.action=t.action,n.addEventListener("click",()=>{this.hide(),this.onAction(t.action)}),e.appendChild(n)}),e}bindEvents(){this.canvas.addEventListener("contextmenu",this.onContextMenu),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onContextMenu=e=>{e.preventDefault();const t=this.container.getBoundingClientRect();let n=e.clientX-t.left,i=e.clientY-t.top;this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`,this.menu.classList.add("engine-2d-context-menu--visible");const s=this.menu.offsetWidth,r=this.menu.offsetHeight,a=this.container.clientWidth,l=this.container.clientHeight;n+s>a&&(n=a-s-4),i+r>l&&(i=l-r-4),this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`};onDocMouseDown=e=>{this.menu.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};hide(){this.menu.classList.remove("engine-2d-context-menu--visible")}dispose(){this.canvas.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.menu.parentElement?.removeChild(this.menu)}}const nf=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
1210
+ </svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-s.left+"px",e.style.top=i.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const r=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-r-s.left+"px",e.style.top=h.clientY-a-s.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class Kd{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new Yd(t,this))}_loadLayers(){let e=this.engine.dwgData.layers;this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t}),this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(s=>{s.name?.startsWith(i)&&(s.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}function qd(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",c),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),o.renderer.domElement.addEventListener("touchend",p,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",a),o.renderer.domElement.removeEventListener("mouseup",c),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",d),o.renderer.domElement.removeEventListener("touchend",p),o.renderer.domElement.removeEventListener("touchmove",m),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 g=new b.Vector2,y=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return g.x=u.offsetX/y*2-1,g.y=-(u.offsetY/v)*2+1,g}function s(u){const g=new b.Raycaster,y=i(u);return g.setFromCamera(y,o.camera),g}function r(u,g=!1){const y=s(u);if(u.raycaster=y,g){const v=void 0;u.catch=v}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new b.Vector3(u.offsetX,u.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,r(u,!0),u.catch!=null&&o.controlModule.orbitControls.origin.set(u.catch.point.x,u.catch.point.y,u.catch.point.z),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(u)}function c(u){if(u.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new b.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const w=v.distanceTo(e.mouseDownPosition);if((y<100||w==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const x=g-e.lastClickTime;console.log(x),x<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function h(u){const g=u.touches[0]||u.changedTouches[0];if(!g)return null;const v=o.renderer.domElement.getBoundingClientRect(),w=g.clientX-v.left,x=g.clientY-v.top;return{offsetX:w,offsetY:x,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>u.preventDefault(),stopPropagation:()=>u.stopPropagation(),originalEvent:u}}function d(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&a(g)}function m(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&l(g)}function p(u){u.preventDefault();const g=h(u);g&&c(g)}function f(u,g){}return e}class $d{el;xEl;yEl;constructor(e){this.el=document.createElement("div"),this.el.className="engine-2d-mouse-coord";const t=document.createElement("span");t.className="engine-2d-mouse-coord__label",t.textContent="",this.xEl=document.createElement("span"),this.xEl.className="engine-2d-mouse-coord__value",this.xEl.textContent="X: --",this.yEl=document.createElement("span"),this.yEl.className="engine-2d-mouse-coord__value",this.yEl.textContent="Y: --",this.el.appendChild(t),this.el.appendChild(this.xEl),this.el.appendChild(this.yEl),e.appendChild(this.el)}update(e,t){this.xEl.textContent=`X: ${e.toFixed(0)} mm`,this.yEl.textContent=`Y: ${t.toFixed(0)} mm`}reset(){this.xEl.textContent="X: --",this.yEl.textContent="Y: --"}dispose(){this.el.parentElement?.removeChild(this.el)}}class Hd{engine;behavior;mouseCoordUI=null;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved2d,this.behavior.init(this);const e=this.engine.container;e&&(this.mouseCoordUI=new $d(e))}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handleMouseMove(e){if(!this.mouseCoordUI||!this.engine.cameraModule2d)return;const t=this.engine.cameraModule2d.screenToWorld(e.offsetX,e.offsetY);this.mouseCoordUI.update(t.x*1e3,t.y*1e3)}handleMouseClick(e){}dispose(){this.mouseCoordUI?.dispose(),this.mouseCoordUI=null}}class Jd{overlay;hLine;vLine;box;canvas;constructor(e,t){this.canvas=t,t.style.cursor="none",this.overlay=document.createElement("div"),this.overlay.className="engine-2d-cad-cursor",this.hLine=document.createElement("div"),this.hLine.className="engine-2d-cad-cursor__h",this.vLine=document.createElement("div"),this.vLine.className="engine-2d-cad-cursor__v",this.box=document.createElement("div"),this.box.className="engine-2d-cad-cursor__box",this.overlay.appendChild(this.hLine),this.overlay.appendChild(this.vLine),this.overlay.appendChild(this.box),e.appendChild(this.overlay),this.hide(),this.bindEvents()}bindEvents(){this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseenter",this.onMouseEnter),this.canvas.addEventListener("mouseleave",this.onMouseLeave)}onMouseMove=e=>{const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.hLine.style.top=`${i}px`,this.vLine.style.left=`${n}px`,this.box.style.left=`${n}px`,this.box.style.top=`${i}px`};onMouseEnter=()=>{this.show()};onMouseLeave=()=>{this.hide()};show(){this.overlay.style.visibility="visible"}hide(){this.overlay.style.visibility="hidden"}dispose(){this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseenter",this.onMouseEnter),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.style.cursor="",this.overlay.parentElement?.removeChild(this.overlay)}}const Qd=[{action:"search",label:"搜索"},{action:"hideElement",label:"隐藏元素",dividerBefore:!0},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层",dividerBefore:!0},{action:"showAllLayers",label:"显示所有图层"}];class ef{menu;container;canvas;onAction;constructor(e,t,n){this.container=e,this.canvas=t,this.onAction=n,this.menu=this.createMenu(),e.appendChild(this.menu),this.bindEvents()}createMenu(){const e=document.createElement("div");return e.className="engine-2d-context-menu",Qd.forEach(t=>{if(t.dividerBefore){const i=document.createElement("div");i.className="engine-2d-context-menu__divider",e.appendChild(i)}const n=document.createElement("div");n.className="engine-2d-context-menu__item",n.textContent=t.label,n.dataset.action=t.action,n.addEventListener("click",()=>{this.hide(),this.onAction(t.action)}),e.appendChild(n)}),e}bindEvents(){this.canvas.addEventListener("contextmenu",this.onContextMenu),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onContextMenu=e=>{e.preventDefault();const t=this.container.getBoundingClientRect();let n=e.clientX-t.left,i=e.clientY-t.top;this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`,this.menu.classList.add("engine-2d-context-menu--visible");const s=this.menu.offsetWidth,r=this.menu.offsetHeight,a=this.container.clientWidth,l=this.container.clientHeight;n+s>a&&(n=a-s-4),i+r>l&&(i=l-r-4),this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`};onDocMouseDown=e=>{this.menu.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};hide(){this.menu.classList.remove("engine-2d-context-menu--visible")}dispose(){this.canvas.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.menu.parentElement?.removeChild(this.menu)}}const tf=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
1211
1211
  <circle cx="6.5" cy="6.5" r="4.5" stroke="currentColor" stroke-width="1.5"/>
1212
1212
  <line x1="10" y1="10" x2="14" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1213
- </svg>`,sf=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1213
+ </svg>`,nf=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
1214
1214
  <line x1="1" y1="1" x2="11" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1215
1215
  <line x1="11" y1="1" x2="1" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
1216
- </svg>`,rf={房间:"#4fc3f7",门:"#81c784",窗:"#aed581",柱:"#ff8a65",梁:"#ffb74d",楼梯:"#ce93d8",电梯:"#80deea",设备间:"#f48fb1",轴线:"#90a4ae",墙体:"#bcaaa4",室外:"#a5d6a7"};class of{container;manager;wrapper;input;clearBtn;resultList;statusEl;activeIndex=-1;currentResults=[];debounceTimer=null;constructor(e,t){this.container=e,this.manager=t,this.wrapper=this._buildWrapper(),this.input=this.wrapper.querySelector(".engine-2d-search__input"),this.clearBtn=this.wrapper.querySelector(".engine-2d-search__clear"),this.resultList=this.wrapper.querySelector(".engine-2d-search__list"),this.statusEl=this.wrapper.querySelector(".engine-2d-search__status"),e.appendChild(this.wrapper),this._bindEvents()}_buildWrapper(){const e=document.createElement("div");return e.className="engine-2d-search",e.innerHTML=`
1216
+ </svg>`,sf={房间:"#4fc3f7",门:"#81c784",窗:"#aed581",柱:"#ff8a65",梁:"#ffb74d",楼梯:"#ce93d8",电梯:"#80deea",设备间:"#f48fb1",轴线:"#90a4ae",墙体:"#bcaaa4",室外:"#a5d6a7"};class rf{container;manager;wrapper;input;clearBtn;resultList;statusEl;activeIndex=-1;currentResults=[];debounceTimer=null;constructor(e,t){this.container=e,this.manager=t,this.wrapper=this._buildWrapper(),this.input=this.wrapper.querySelector(".engine-2d-search__input"),this.clearBtn=this.wrapper.querySelector(".engine-2d-search__clear"),this.resultList=this.wrapper.querySelector(".engine-2d-search__list"),this.statusEl=this.wrapper.querySelector(".engine-2d-search__status"),e.appendChild(this.wrapper),this._bindEvents()}_buildWrapper(){const e=document.createElement("div");return e.className="engine-2d-search",e.innerHTML=`
1217
1217
  <div class="engine-2d-search__box">
1218
1218
  <div class="engine-2d-search__input-row">
1219
- <span class="engine-2d-search__icon">${nf}</span>
1219
+ <span class="engine-2d-search__icon">${tf}</span>
1220
1220
  <input
1221
1221
  class="engine-2d-search__input"
1222
1222
  type="text"
@@ -1224,18 +1224,18 @@ void main() {
1224
1224
  autocomplete="off"
1225
1225
  spellcheck="false"
1226
1226
  />
1227
- <button class="engine-2d-search__clear" title="清除">${sf}</button>
1227
+ <button class="engine-2d-search__clear" title="清除">${nf}</button>
1228
1228
  </div>
1229
1229
  <div class="engine-2d-search__divider"></div>
1230
1230
  <div class="engine-2d-search__status"></div>
1231
1231
  <ul class="engine-2d-search__list" role="listbox"></ul>
1232
1232
  </div>
1233
- `,e}_bindEvents(){this.input.addEventListener("input",this._onInput),this.input.addEventListener("keydown",this._onKeyDown),this.clearBtn.addEventListener("click",this._onClear),document.addEventListener("mousedown",this._onDocMouseDown),document.addEventListener("keydown",this._onEscape)}_onInput=()=>{this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this._doSearch(),150);const e=this.input.value.length>0;this.clearBtn.style.opacity=e?"1":"0",this.clearBtn.style.pointerEvents=e?"auto":"none"};_onKeyDown=e=>{const t=this.resultList.querySelectorAll(".engine-2d-search__item");t.length&&(e.key==="ArrowDown"?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,t.length-1),this._highlightItem(t)):e.key==="ArrowUp"?(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this._highlightItem(t)):e.key==="Enter"&&this.activeIndex>=0&&this.currentResults[this.activeIndex]&&this._selectResult(this.currentResults[this.activeIndex]))};_onClear=()=>{this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none",this._clearResults(),this.input.focus()};_onDocMouseDown=e=>{this.wrapper.contains(e.target)||this.hide()};_onEscape=e=>{e.key==="Escape"&&this.hide()};_doSearch(){const e=this.input.value;if(!e.trim()){this._clearResults();return}this.currentResults=this.manager.search(e),this.activeIndex=-1,this._renderResults(this.currentResults,e)}_renderResults(e,t){this.resultList.innerHTML="";const n=this.wrapper.querySelector(".engine-2d-search__divider");if(e.length===0){this.statusEl.textContent=`未找到与 "${t}" 相关的结果`,this.statusEl.style.display="block",n.style.display="none",this.resultList.style.display="none";return}this.statusEl.textContent=`找到 ${e.length} 个结果`,this.statusEl.style.display="block",n.style.display="block",this.resultList.style.display="block",e.forEach((i,s)=>{const r=document.createElement("li");r.className="engine-2d-search__item",r.setAttribute("role","option"),r.dataset.index=String(s);const a=rf[i.type]??"#90a4ae",l=this._highlight(i.name,t);r.innerHTML=`
1233
+ `,e}_bindEvents(){this.input.addEventListener("input",this._onInput),this.input.addEventListener("keydown",this._onKeyDown),this.clearBtn.addEventListener("click",this._onClear),document.addEventListener("mousedown",this._onDocMouseDown),document.addEventListener("keydown",this._onEscape)}_onInput=()=>{this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this._doSearch(),150);const e=this.input.value.length>0;this.clearBtn.style.opacity=e?"1":"0",this.clearBtn.style.pointerEvents=e?"auto":"none"};_onKeyDown=e=>{const t=this.resultList.querySelectorAll(".engine-2d-search__item");t.length&&(e.key==="ArrowDown"?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,t.length-1),this._highlightItem(t)):e.key==="ArrowUp"?(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this._highlightItem(t)):e.key==="Enter"&&this.activeIndex>=0&&this.currentResults[this.activeIndex]&&this._selectResult(this.currentResults[this.activeIndex]))};_onClear=()=>{this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none",this._clearResults(),this.input.focus()};_onDocMouseDown=e=>{this.wrapper.contains(e.target)||this.hide()};_onEscape=e=>{e.key==="Escape"&&this.hide()};_doSearch(){const e=this.input.value;if(!e.trim()){this._clearResults();return}this.currentResults=this.manager.search(e),this.activeIndex=-1,this._renderResults(this.currentResults,e)}_renderResults(e,t){this.resultList.innerHTML="";const n=this.wrapper.querySelector(".engine-2d-search__divider");if(e.length===0){this.statusEl.textContent=`未找到与 "${t}" 相关的结果`,this.statusEl.style.display="block",n.style.display="none",this.resultList.style.display="none";return}this.statusEl.textContent=`找到 ${e.length} 个结果`,this.statusEl.style.display="block",n.style.display="block",this.resultList.style.display="block",e.forEach((i,s)=>{const r=document.createElement("li");r.className="engine-2d-search__item",r.setAttribute("role","option"),r.dataset.index=String(s);const a=sf[i.type]??"#90a4ae",l=this._highlight(i.name,t);r.innerHTML=`
1234
1234
  <span class="engine-2d-search__item-badge" style="background:${a}20;color:${a};">${i.type}</span>
1235
1235
  <span class="engine-2d-search__item-name">${l}</span>
1236
1236
  ${i.layer?`<span class="engine-2d-search__item-layer">${i.layer}</span>`:""}
1237
1237
  ${i.description?`<span class="engine-2d-search__item-desc">${i.description}</span>`:""}
1238
- `,r.addEventListener("click",()=>this._selectResult(i)),r.addEventListener("mouseenter",()=>{this.activeIndex=s;const h=this.resultList.querySelectorAll(".engine-2d-search__item");this._highlightItem(h)}),this.resultList.appendChild(r)})}_highlight(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`(${n})`,"gi"),'<mark class="engine-2d-search__mark">$1</mark>')}_highlightItem(e){e.forEach((t,n)=>{t.classList.toggle("engine-2d-search__item--active",n===this.activeIndex)}),this.activeIndex>=0&&e[this.activeIndex]?.scrollIntoView({block:"nearest"})}_selectResult(e){this.manager.onResultSelect(e),this.hide()}_clearResults(){this.resultList.innerHTML="",this.resultList.style.display="none",this.statusEl.style.display="none";const e=this.wrapper.querySelector(".engine-2d-search__divider");e.style.display="none",this.currentResults=[],this.activeIndex=-1}show(){this.wrapper.classList.add("engine-2d-search--visible"),requestAnimationFrame(()=>this.input.focus())}hide(){this.wrapper.classList.remove("engine-2d-search--visible"),this._clearResults(),this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none"}toggle(){this.wrapper.classList.contains("engine-2d-search--visible")?this.hide():this.show()}dispose(){this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("keydown",this._onKeyDown),this.clearBtn.removeEventListener("click",this._onClear),document.removeEventListener("mousedown",this._onDocMouseDown),document.removeEventListener("keydown",this._onEscape),this.wrapper.parentElement?.removeChild(this.wrapper),this.debounceTimer!==null&&clearTimeout(this.debounceTimer)}}const af=[{id:"1",name:"会议室 A",type:"房间",layer:"建筑-房间",description:"3F 东侧,面积 48㎡"},{id:"2",name:"会议室 B",type:"房间",layer:"建筑-房间",description:"3F 西侧,面积 32㎡"},{id:"3",name:"卫生间-男",type:"房间",layer:"建筑-房间",description:"2F,面积 18㎡"},{id:"4",name:"卫生间-女",type:"房间",layer:"建筑-房间",description:"2F,面积 16㎡"},{id:"5",name:"大厅",type:"房间",layer:"建筑-房间",description:"1F,面积 260㎡"},{id:"6",name:"主入口门",type:"门",layer:"建筑-门窗",description:"宽 2400mm,双开"},{id:"7",name:"次入口门",type:"门",layer:"建筑-门窗",description:"宽 1200mm,单开"},{id:"8",name:"防火门 FD-01",type:"门",layer:"建筑-门窗",description:"甲级防火,宽 900mm"},{id:"9",name:"落地窗 W-101",type:"窗",layer:"建筑-门窗",description:"高 3000mm,南向"},{id:"10",name:"普通窗 W-201",type:"窗",layer:"建筑-门窗",description:"高 1800mm,东向"},{id:"11",name:"承重柱 Z-A1",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"12",name:"承重柱 Z-A2",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"13",name:"钢柱 GZ-01",type:"柱",layer:"结构-柱",description:"H 型钢,H300×150"},{id:"14",name:"主梁 L-1",type:"梁",layer:"结构-梁",description:"400×800,跨度 8m"},{id:"15",name:"次梁 L-2",type:"梁",layer:"结构-梁",description:"250×500,跨度 4m"},{id:"16",name:"楼梯间 ST-1",type:"楼梯",layer:"建筑-楼梯",description:"双跑楼梯,净宽 1200mm"},{id:"17",name:"消防楼梯 ST-2",type:"楼梯",layer:"建筑-楼梯",description:"疏散楼梯,净宽 1100mm"},{id:"18",name:"电梯井 EV-1",type:"电梯",layer:"建筑-电梯",description:"客梯,井道 2000×2200"},{id:"19",name:"消防电梯 EV-2",type:"电梯",layer:"建筑-电梯",description:"消防兼客梯"},{id:"20",name:"强电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 4㎡"},{id:"21",name:"弱电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 2㎡"},{id:"22",name:"空调机房",type:"设备间",layer:"机电-暖通",description:"BF,面积 80㎡"},{id:"23",name:"消防控制室",type:"设备间",layer:"机电-消防",description:"1F,面积 24㎡"},{id:"24",name:"配电室",type:"设备间",layer:"机电-电气",description:"BF,面积 36㎡"},{id:"25",name:"轴线 A",type:"轴线",layer:"轴网",description:"X 向,间距 8400mm"},{id:"26",name:"轴线 1",type:"轴线",layer:"轴网",description:"Y 向,间距 7200mm"},{id:"27",name:"内墙 Q-001",type:"墙体",layer:"建筑-墙",description:"200mm 砌块"},{id:"28",name:"外墙 Q-101",type:"墙体",layer:"建筑-墙",description:"300mm 保温外墙"},{id:"29",name:"散水 SS-1",type:"室外",layer:"建筑-室外",description:"宽 900mm,坡度 3%"},{id:"30",name:"台阶 TJ-1",type:"室外",layer:"建筑-室外",description:"3 级,踏步 300×150"}];class lf{engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new of(t,this))}search(e){const t=e.trim().toLowerCase();return t?af.filter(n=>n.name.toLowerCase().includes(t)||n.type.toLowerCase().includes(t)||(n.layer?.toLowerCase().includes(t)??!1)||(n.description?.toLowerCase().includes(t)??!1)):[]}onResultSelect(e){console.log("[SearchManager] 选中结果:",e)}show(){this.searchUI?.show()}hide(){this.searchUI?.hide()}toggle(){this.searchUI?.toggle()}dispose(){this.searchUI?.dispose(),this.searchUI=null}}const jo={dark:{"--e2d-bg":"#1e1f22","--e2d-bg2":"#252526","--e2d-bg3":"#222222","--e2d-bg-hover":"rgba(79,195,247,0.08)","--e2d-bg-accent":"#094771","--e2d-icon-bg":"rgba(255,255,255,0.08)","--e2d-icon-bg-hover":"rgba(255,255,255,0.16)","--e2d-border":"rgba(255,255,255,0.12)","--e2d-border2":"#333333","--e2d-text":"#e0e0e0","--e2d-text2":"#cccccc","--e2d-text3":"rgba(255,255,255,0.35)","--e2d-text4":"#666666","--e2d-text-accent":"#ffffff","--e2d-accent":"#4fc3f7","--e2d-shadow":"rgba(0,0,0,0.50)","--e2d-shadow-lg":"rgba(0,0,0,0.65)","--e2d-cursor":"rgba(255,255,255,0.85)","--e2d-scrollbar":"rgba(255,255,255,0.15)","--e2d-float-bg":"rgba(0,0,0,0.65)","--e2d-float-border":"rgba(255,255,255,0.08)","--e2d-swatch-border":"#444444","--e2d-close":"#aaaaaa","--e2d-close-hover":"#ffffff","--e2d-icon":"rgba(255,255,255,0.4)","--e2d-coord-value":"#76c8ff","--e2d-coord-label":"rgba(255,255,255,0.45)"},light:{"--e2d-bg":"#ffffff","--e2d-bg2":"#f5f5f5","--e2d-bg3":"#eeeeee","--e2d-bg-hover":"rgba(25,118,210,0.06)","--e2d-bg-accent":"#e3f2fd","--e2d-icon-bg":"rgba(0,0,0,0.06)","--e2d-icon-bg-hover":"rgba(0,0,0,0.12)","--e2d-border":"rgba(0,0,0,0.12)","--e2d-border2":"#e0e0e0","--e2d-text":"#1a1a1a","--e2d-text2":"#444444","--e2d-text3":"rgba(0,0,0,0.40)","--e2d-text4":"#aaaaaa","--e2d-text-accent":"#1565c0","--e2d-accent":"#1976d2","--e2d-shadow":"rgba(0,0,0,0.15)","--e2d-shadow-lg":"rgba(0,0,0,0.22)","--e2d-cursor":"rgba(30,30,30,0.70)","--e2d-scrollbar":"rgba(0,0,0,0.18)","--e2d-float-bg":"rgba(245,245,245,0.92)","--e2d-float-border":"rgba(0,0,0,0.10)","--e2d-swatch-border":"#cccccc","--e2d-close":"#777777","--e2d-close-hover":"#1a1a1a","--e2d-icon":"rgba(0,0,0,0.45)","--e2d-coord-value":"#1976d2","--e2d-coord-label":"rgba(0,0,0,0.50)"}};class cf{container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=jo[e];for(const[n,i]of Object.entries(t))this.container.style.setProperty(n,i);this.container.setAttribute("data-e2d-theme",e)}setTheme(e){this.current=e,this._apply(e)}getTheme(){return this.current}toggle(){this.setTheme(this.current==="dark"?"light":"dark")}dispose(){for(const e of Object.keys(jo[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}class hf{options;container=null;animationId=null;isRendering=!1;fpsFrameCount=0;fpsLastCheck=0;currentFps=0;enablePerformanceMonitoring=!1;events;handelBehaved2d;interactionModule2d;sceneModule2d;cameraModule2d;renderModule2d;controlModule2d;loaderModule2d;layerManager;searchManager;themeManager;cadCursorUI;contextMenuUI;scene=null;camera=null;renderer=null;dwgData=null;version="1.0.0";constructor(e){if(this.options=e,this.enablePerformanceMonitoring=e.enablePerformanceMonitoring??!1,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.initialize(),this.handelBehaved2d=$d(this),this.interactionModule2d=new Jd(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new Ld(!1),this.sceneModule2d=new Od(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new Rd(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new Nd(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new Ud(this),this.loaderModule2d=new Zd(this),this.themeManager=new cf(this.container),this.layerManager=new qd(this),this.searchManager=new lf(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new Qd(this.container,this.renderer.domElement),this.contextMenuUI=new tf(this.container,this.renderer.domElement,e=>{e==="search"&&this.searchManager.show()}),this.startRendering(),console.log(`[EngineKernel2d] 2D Engine initialized (v${this.version})`)}startRendering(){this.isRendering||(this.isRendering=!0,this.fpsLastCheck=performance.now(),this.animate(),console.log("[EngineKernel2d] Rendering started"))}stopRendering(){this.isRendering=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),console.log("[EngineKernel2d] Rendering stopped")}animate=()=>{this.isRendering&&(this.animationId=requestAnimationFrame(this.animate),this.controlModule2d.update(),this.scene&&this.camera&&this.renderer&&this.renderer.render(this.scene,this.camera),this.enablePerformanceMonitoring&&this.updatePerformanceStats())};updatePerformanceStats(){this.fpsFrameCount++;const e=performance.now();e-this.fpsLastCheck>=1e3&&(this.currentFps=this.fpsFrameCount,this.fpsFrameCount=0,this.fpsLastCheck=e,this.events.trigger(Mn.RenderEnd,{fps:this.currentFps}))}async loadModel(e,t){return await this.loaderModule2d.loadModel(e,t),{}}getLayers(){return this.loaderModule2d.getLayers()}getEntitiesByLayer(e){return this.loaderModule2d.getEntitiesByLayer(e)}setLayerVisible(e,t){console.log(`[EngineKernel2d] Set layer ${e} visible: ${t}`)}setTheme(e){this.themeManager.setTheme(e)}resetView(){this.cameraModule2d&&this.cameraModule2d.resetView()}fitToView(){this.dwgData?.metadata.extents&&this.cameraModule2d.fitToExtents(this.dwgData.metadata.extents)}setZoom(e){this.cameraModule2d&&this.cameraModule2d.setZoom(e)}getZoom(){return this.cameraModule2d?this.cameraModule2d.getZoom():1}getPerformanceStats(){const e=this.sceneModule2d.getSceneStats();return{fps:this.currentFps,renderTime:0,entityCount:e.objectCount,visibleEntityCount:e.objectCount}}setBackgroundColor(e){this.sceneModule2d&&this.sceneModule2d.setBackgroundColor(e)}clearScene(){this.sceneModule2d&&this.sceneModule2d.clearScene()}resize(){if(this.renderModule2d){const e=this.container?.clientWidth??0,t=this.container?.clientHeight??0;this.renderModule2d.setSize(e,t)}}dispose(){console.log("[EngineKernel2d] Disposing engine..."),this.stopRendering(),this.cadCursorUI?.dispose(),this.contextMenuUI?.dispose(),this.searchManager?.dispose(),this.themeManager?.dispose(),this.loaderModule2d?.dispose(),this.controlModule2d?.dispose(),this.renderModule2d?.dispose(),this.cameraModule2d?.dispose(),this.sceneModule2d?.dispose(),this.events?.dispose(),this.scene=null,this.camera=null,this.renderer=null,this.dwgData=null,console.log("[EngineKernel2d] Engine disposed")}}class uf{scene;panoramaSphere=null;sphereRadius;constructor(e=500){this.sphereRadius=e,this.scene=new b.Scene,this.init()}init(){this.panoramaSphere=this.createPanoramaSphere(this.sphereRadius),this.scene.add(this.panoramaSphere)}createPanoramaSphere(e=500,t=64){const n=new b.SphereGeometry(e,t,t/2);n.scale(-1,1,1);const i=new b.MeshBasicMaterial({map:null,side:b.FrontSide,transparent:!0}),s=new b.Mesh(n,i);return s.name="panorama-sphere",s}updatePanoramaTexture(e){if(!this.panoramaSphere){console.warn("SceneModule720: Panorama sphere not initialized");return}const t=this.panoramaSphere.material;t.map&&t.map.dispose(),t.map=e,t.needsUpdate=!0}clearPanoramaTexture(){if(!this.panoramaSphere)return;const e=this.panoramaSphere.material;e.map&&(e.map.dispose(),e.map=null,e.needsUpdate=!0)}getScene(){return this.scene}getPanoramaSphere(){return this.panoramaSphere}setSphereRadius(e){if(this.sphereRadius!==e){if(this.sphereRadius=e,this.panoramaSphere){const t=this.panoramaSphere.material,n=t.map;this.scene.remove(this.panoramaSphere),this.panoramaSphere.geometry.dispose(),t.dispose(),n&&n.dispose()}this.panoramaSphere=this.createPanoramaSphere(e),this.scene.add(this.panoramaSphere)}}getSphereRadius(){return this.sphereRadius}dispose(){if(this.panoramaSphere){const e=this.panoramaSphere.material;e.map&&e.map.dispose(),e.dispose(),this.panoramaSphere.geometry.dispose(),this.scene.remove(this.panoramaSphere),this.panoramaSphere=null}this.scene.clear()}}class df{camera;minFov;maxFov;container;currentPose;constructor(e,t=75,n=30,i=90){this.container=e,this.minFov=n,this.maxFov=i,this.currentPose={theta:0,phi:0},this.camera=this.createCamera(t),this.init()}createCamera(e){const t=this.container.clientWidth/this.container.clientHeight,n=new b.PerspectiveCamera(e,t,.1,2e3);return n.position.set(0,0,0),n}init(){this.updateCameraRotation()}updateCameraRotation(){const{theta:e,phi:t}=this.currentPose,n=new b.Euler(t,e,0,"YXZ"),i=new b.Quaternion;i.setFromEuler(n),this.camera.quaternion.copy(i)}setFov(e){const t=Math.max(this.minFov,Math.min(this.maxFov,e));this.camera.fov=t,this.camera.updateProjectionMatrix()}getFov(){return this.camera.fov}getCameraPose(){return{...this.currentPose}}setCameraPose(e,t){this.currentPose.theta=e,this.currentPose.phi=t,this.updateCameraRotation()}updatePose(e,t){this.currentPose.theta+=e,this.currentPose.phi+=t,this.currentPose.theta<0?this.currentPose.theta+=2*Math.PI:this.currentPose.theta>=2*Math.PI&&(this.currentPose.theta-=2*Math.PI),this.currentPose.phi=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,this.currentPose.phi)),this.updateCameraRotation()}getCamera(){return this.camera}updateAspectRatio(e,t){const n=e/t;this.camera.aspect=n,this.camera.updateProjectionMatrix()}dispose(){this.camera=null}}class ff{renderer;container;animationId=null;isRenderingPaused=!1;fpsFrameCount=0;fpsLastTime=performance.now();currentFps=60;onBeforeRenderCallback;onAfterRenderCallback;constructor(e,t=!0){this.container=e,this.renderer=this.createRenderer(t),this.init()}createRenderer(e){const t=new b.WebGLRenderer({antialias:e,alpha:!0,preserveDrawingBuffer:!1}),n=this.container.clientWidth,i=this.container.clientHeight;return t.setSize(n,i),t.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(t.domElement),t}init(){}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}render(e,t){this.onBeforeRenderCallback&&this.onBeforeRenderCallback(),this.renderer.render(e,t),this.onAfterRenderCallback&&this.onAfterRenderCallback(),this.updateFps()}startRenderLoop(e,t){if(this.animationId!==null){console.warn("RenderModule720: Render loop already running");return}this.isRenderingPaused=!1,this.animate(e,t)}animate(e,t){this.isRenderingPaused||(this.animationId=requestAnimationFrame(()=>{this.animate(e,t)}),this.render(e,t))}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(e,t){this.isRenderingPaused&&(this.isRenderingPaused=!1,this.startRenderLoop(e,t))}isRenderingPausedState(){return this.isRenderingPaused}updateFps(){this.fpsFrameCount++;const e=performance.now();e>=this.fpsLastTime+1e3&&(this.currentFps=Math.round(this.fpsFrameCount*1e3/(e-this.fpsLastTime)),this.fpsFrameCount=0,this.fpsLastTime=e,this.currentFps<30&&console.warn("RenderModule720: Low FPS detected:",this.currentFps))}getCurrentFps(){return this.currentFps}resize(e,t){this.renderer.setSize(e,t),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getDomElement(){return this.renderer.domElement}getRenderer(){return this.renderer}dispose(){this.pauseRendering(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.onBeforeRenderCallback=void 0,this.onAfterRenderCallback=void 0}}class pf{camera;domElement;cameraModule;enableZoom=!0;enableRotate=!0;minFov=30;maxFov=90;rotateSpeed=.5;zoomSpeed=1;enableDamping=!0;dampingFactor=.05;isDragging=!1;startX=0;startY=0;thetaDelta=0;phiDelta=0;isPinching=!1;pinchStartDistance=null;pinchStartFov=75;_onMouseDown;_onMouseMove;_onMouseUp;_onWheel;_onTouchStart;_onTouchMove;_onTouchEnd;onViewAngleChange;constructor(e,t){this.cameraModule=e,this.camera=e.getCamera(),this.pinchStartFov=this.camera.fov,this.domElement=t,this._onMouseDown=this.onMouseDown.bind(this),this._onMouseMove=this.onMouseMove.bind(this),this._onMouseUp=this.onMouseUp.bind(this),this._onWheel=this.onWheel.bind(this),this._onTouchStart=this.onTouchStart.bind(this),this._onTouchMove=this.onTouchMove.bind(this),this._onTouchEnd=this.onTouchEnd.bind(this),this.init()}init(){this.domElement.addEventListener("mousedown",this._onMouseDown),this.domElement.addEventListener("mousemove",this._onMouseMove),this.domElement.addEventListener("mouseup",this._onMouseUp),this.domElement.addEventListener("mouseleave",this._onMouseUp),this.domElement.addEventListener("wheel",this._onWheel,{passive:!1}),this.domElement.addEventListener("touchstart",this._onTouchStart,{passive:!1}),this.domElement.addEventListener("touchmove",this._onTouchMove,{passive:!1}),this.domElement.addEventListener("touchend",this._onTouchEnd)}onMouseDown(e){e.button===0&&(this.isDragging=!0,this.startX=e.clientX,this.startY=e.clientY)}onMouseMove(e){if(!this.isDragging||!this.enableRotate)return;const t=e.clientX-this.startX,n=e.clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta+=t*i*this.rotateSpeed*.06,this.phiDelta+=n*s*this.rotateSpeed*.06,this.startX=e.clientX,this.startY=e.clientY,this.applyRotation()}onMouseUp(){this.isDragging=!1}onWheel(e){if(!this.enableZoom)return;e.preventDefault();const n=(e.deltaY>0?1:-1)*this.zoomSpeed*2;this.applyZoom(n)}onTouchStart(e){e.touches.length===1?(this.isDragging=!0,this.isPinching=!1,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):e.touches.length===2&&(e.preventDefault(),this.isDragging=!1,this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov())}onTouchMove(e){if(e.touches.length===1&&this.isDragging&&this.enableRotate){const t=e.touches[0].clientX-this.startX,n=e.touches[0].clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta-=t*i*this.rotateSpeed,this.phiDelta-=n*s*this.rotateSpeed,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY,this.applyRotation()}else if(e.touches.length===2&&this.enableZoom){e.preventDefault(),this.isPinching||(this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov());const t=this.getTouchDistance(e.touches);if(this.pinchStartDistance&&t>0){const n=this.pinchStartDistance/t,i=b.MathUtils.clamp(this.pinchStartFov*n,this.minFov,this.maxFov);this.cameraModule.setFov(i)}}}onTouchEnd(e){e.touches&&e.touches.length>0?this.isDragging=e.touches.length===1:this.isDragging=!1,e.touches.length<2&&(this.isPinching=!1,this.pinchStartDistance=null)}applyRotation(){if(this.cameraModule.updatePose(this.thetaDelta,this.phiDelta),this.enableDamping?(this.thetaDelta*=1-this.dampingFactor,this.phiDelta*=1-this.dampingFactor):(this.thetaDelta=0,this.phiDelta=0),this.onViewAngleChange){const e=this.cameraModule.getCameraPose();this.onViewAngleChange(e.theta,e.phi)}}getRotationFactors(){const e=Math.max(1,this.domElement.clientWidth),t=Math.max(1,this.domElement.clientHeight);return{horizontal:Math.PI*2/e,vertical:Math.PI/t}}applyZoom(e){const t=this.cameraModule.getFov(),n=b.MathUtils.clamp(t+e,this.minFov,this.maxFov);this.cameraModule.setFov(n)}getTouchDistance(e){if(e.length<2)return 0;const t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)}update(){this.enableDamping&&(Math.abs(this.thetaDelta)>1e-4||Math.abs(this.phiDelta)>1e-4)&&this.applyRotation()}lookAt(e,t){this.thetaDelta=e,this.phiDelta=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,t)),this.cameraModule.setCameraPose(e,t),this.thetaDelta=0,this.phiDelta=0}getViewAngle(){return this.cameraModule.getCameraPose()}setOnViewAngleChange(e){this.onViewAngleChange=e}reset(){this.thetaDelta=0,this.phiDelta=0,this.lookAt(0,0)}setRotateSpeed(e){this.rotateSpeed=Math.max(.05,e)}setZoomSpeed(e){this.zoomSpeed=Math.max(.1,e)}setEnableDamping(e){this.enableDamping=e}setDampingFactor(e){this.dampingFactor=Math.max(0,Math.min(1,e))}setZoomLimits(e,t){this.minFov=e,this.maxFov=t}dispose(){this.domElement.removeEventListener("mousedown",this._onMouseDown),this.domElement.removeEventListener("mousemove",this._onMouseMove),this.domElement.removeEventListener("mouseup",this._onMouseUp),this.domElement.removeEventListener("mouseleave",this._onMouseUp),this.domElement.removeEventListener("wheel",this._onWheel),this.domElement.removeEventListener("touchstart",this._onTouchStart),this.domElement.removeEventListener("touchmove",this._onTouchMove),this.domElement.removeEventListener("touchend",this._onTouchEnd),this.onViewAngleChange=void 0}}class mf{controls;domElement;cameraModule;constructor(e,t){this.cameraModule=e,this.domElement=t,this.controls=new pf(e,t)}init(){}active(){}disActive(){this.controls.enableRotate=!1,this.controls.enableZoom=!1}enable(){this.controls.enableRotate=!0,this.controls.enableZoom=!0}update(){this.controls.update()}lookAt(e,t){this.controls.lookAt(e,t)}getViewAngle(){return this.controls.getViewAngle()}setOnViewAngleChange(e){this.controls.setOnViewAngleChange(e)}reset(){this.controls.reset()}getControls(){return this.controls}updateInteractionOptions(e){if(e.rotateSpeed!==void 0&&this.controls.setRotateSpeed(e.rotateSpeed),e.zoomSpeed!==void 0&&this.controls.setZoomSpeed(e.zoomSpeed),e.enableDamping!==void 0&&this.controls.setEnableDamping(e.enableDamping),e.dampingFactor!==void 0&&this.controls.setDampingFactor(e.dampingFactor),e.enableRotate!==void 0&&(this.controls.enableRotate=e.enableRotate),e.enableZoom!==void 0&&(this.controls.enableZoom=e.enableZoom),e.minFov!==void 0||e.maxFov!==void 0){const t=e.minFov??this.controls.minFov,n=e.maxFov??this.controls.maxFov;this.controls.setZoomLimits(t,n)}}dispose(){this.controls.dispose()}}class gf{cache=new Map;loadingPromises=new Map;loadTexture(e){if(this.cache.has(e))return Promise.resolve(this.cache.get(e));if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const t=new Promise((n,i)=>{new b.TextureLoader().load(e,r=>{r.colorSpace=b.SRGBColorSpace,r.minFilter=b.LinearFilter,r.magFilter=b.LinearFilter,this.cache.set(e,r),this.loadingPromises.delete(e),n(r)},void 0,r=>{this.loadingPromises.delete(e),i(r)})});return this.loadingPromises.set(e,t),t}async preloadTextures(e){const t=e.map(n=>this.loadTexture(n));return Promise.all(t)}has(e){return this.cache.has(e)}get(e){return this.cache.get(e)}remove(e){const t=this.cache.get(e);t&&(t.dispose(),this.cache.delete(e))}clear(){this.cache.forEach(e=>e.dispose()),this.cache.clear(),this.loadingPromises.clear()}size(){return this.cache.size}dispose(){this.clear()}}class yf{textureCache;currentUrl=null;loadProgress=0;onProgressCallback;constructor(){this.textureCache=new gf}async loadTexture(e){this.currentUrl=e,this.loadProgress=0,this.onProgressCallback&&this.onProgressCallback(0);try{const t=await this.loadTextureInternal(e);return this.loadProgress=100,this.onProgressCallback&&this.onProgressCallback(100),t}catch(t){throw console.error("PanoramaLoader: Failed to load texture:",t),t}}loadTextureInternal(e){return new Promise((t,n)=>{if(this.textureCache.has(e)){const s=this.textureCache.get(e);if(s){t(s);return}}new b.TextureLoader().load(e,s=>{s.colorSpace=b.SRGBColorSpace,s.minFilter=b.LinearFilter,s.magFilter=b.LinearFilter,this.textureCache.cache.set(e,s),t(s)},s=>{s.total>0&&(this.loadProgress=s.loaded/s.total*100,this.onProgressCallback&&this.onProgressCallback(this.loadProgress))},s=>{n(s)})})}async preloadPanoramas(e){try{await this.textureCache.preloadTextures(e)}catch(t){throw console.error("PanoramaLoader: Failed to preload panoramas:",t),t}}getLoadProgress(){return this.loadProgress}setOnProgress(e){this.onProgressCallback=e}getCurrentUrl(){return this.currentUrl}isCached(e){return this.textureCache.has(e)}getCachedTexture(e){return this.textureCache.get(e)}clearCache(){this.textureCache.clear()}removeCachedTexture(e){this.textureCache.remove(e)}dispose(){this.textureCache.dispose(),this.onProgressCallback=void 0,this.currentUrl=null}}class Go{static sphericalToCartesian(e){const t=e.radius||500,{theta:n,phi:i}=e,s=t*Math.cos(i)*Math.cos(n),r=t*Math.sin(i),a=t*Math.cos(i)*Math.sin(n);return{x:s,y:r,z:a}}static cartesianToSpherical(e,t,n){const i=Math.sqrt(e*e+t*t+n*n),s=Math.asin(t/i);let r=Math.atan2(n,e);return r<0&&(r+=2*Math.PI),{theta:r,phi:s,radius:i}}static normalizeAngle(e,t=-Math.PI,n=Math.PI){const i=n-t;let s=e;for(;s<t;)s+=i;for(;s>n;)s-=i;return s}static clampPhi(e,t=-Math.PI/2+.01,n=Math.PI/2-.01){return Math.max(t,Math.min(n,e))}static sphericalDistance(e,t){const n=Math.sin(e.phi)*Math.sin(t.phi)+Math.cos(e.phi)*Math.cos(t.phi)*Math.cos(e.theta-t.theta);return Math.acos(Math.max(-1,Math.min(1,n)))}static lerpSpherical(e,t,n){let i=t.theta-e.theta;i>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI);const s=e.theta+i*n,r=e.phi+(t.phi-e.phi)*n,a=e.radius||500,l=t.radius||500,h=a+(l-a)*n;return{theta:s,phi:r,radius:h}}}var _n=(o=>(o.ICON="icon",o.TEXT="text",o.LINK="link",o))(_n||{});class vf{annotations=new Map;container;annotationContainer;worldToScreen;sphereRadius;camera;renderer;onClickAnnotation;onHoverAnnotation;constructor(e,t,n,i){this.container=e,this.camera=t,this.renderer=n,this.sphereRadius=i,this.worldToScreen=new De(t,n),this.createAnnotationContainer()}createAnnotationContainer(){this.annotationContainer=document.createElement("div"),this.annotationContainer.className="panorama-annotation-container",this.annotationContainer.style.cssText=`
1238
+ `,r.addEventListener("click",()=>this._selectResult(i)),r.addEventListener("mouseenter",()=>{this.activeIndex=s;const c=this.resultList.querySelectorAll(".engine-2d-search__item");this._highlightItem(c)}),this.resultList.appendChild(r)})}_highlight(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`(${n})`,"gi"),'<mark class="engine-2d-search__mark">$1</mark>')}_highlightItem(e){e.forEach((t,n)=>{t.classList.toggle("engine-2d-search__item--active",n===this.activeIndex)}),this.activeIndex>=0&&e[this.activeIndex]?.scrollIntoView({block:"nearest"})}_selectResult(e){this.manager.onResultSelect(e),this.hide()}_clearResults(){this.resultList.innerHTML="",this.resultList.style.display="none",this.statusEl.style.display="none";const e=this.wrapper.querySelector(".engine-2d-search__divider");e.style.display="none",this.currentResults=[],this.activeIndex=-1}show(){this.wrapper.classList.add("engine-2d-search--visible"),requestAnimationFrame(()=>this.input.focus())}hide(){this.wrapper.classList.remove("engine-2d-search--visible"),this._clearResults(),this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none"}toggle(){this.wrapper.classList.contains("engine-2d-search--visible")?this.hide():this.show()}dispose(){this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("keydown",this._onKeyDown),this.clearBtn.removeEventListener("click",this._onClear),document.removeEventListener("mousedown",this._onDocMouseDown),document.removeEventListener("keydown",this._onEscape),this.wrapper.parentElement?.removeChild(this.wrapper),this.debounceTimer!==null&&clearTimeout(this.debounceTimer)}}const of=[{id:"1",name:"会议室 A",type:"房间",layer:"建筑-房间",description:"3F 东侧,面积 48㎡"},{id:"2",name:"会议室 B",type:"房间",layer:"建筑-房间",description:"3F 西侧,面积 32㎡"},{id:"3",name:"卫生间-男",type:"房间",layer:"建筑-房间",description:"2F,面积 18㎡"},{id:"4",name:"卫生间-女",type:"房间",layer:"建筑-房间",description:"2F,面积 16㎡"},{id:"5",name:"大厅",type:"房间",layer:"建筑-房间",description:"1F,面积 260㎡"},{id:"6",name:"主入口门",type:"门",layer:"建筑-门窗",description:"宽 2400mm,双开"},{id:"7",name:"次入口门",type:"门",layer:"建筑-门窗",description:"宽 1200mm,单开"},{id:"8",name:"防火门 FD-01",type:"门",layer:"建筑-门窗",description:"甲级防火,宽 900mm"},{id:"9",name:"落地窗 W-101",type:"窗",layer:"建筑-门窗",description:"高 3000mm,南向"},{id:"10",name:"普通窗 W-201",type:"窗",layer:"建筑-门窗",description:"高 1800mm,东向"},{id:"11",name:"承重柱 Z-A1",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"12",name:"承重柱 Z-A2",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"13",name:"钢柱 GZ-01",type:"柱",layer:"结构-柱",description:"H 型钢,H300×150"},{id:"14",name:"主梁 L-1",type:"梁",layer:"结构-梁",description:"400×800,跨度 8m"},{id:"15",name:"次梁 L-2",type:"梁",layer:"结构-梁",description:"250×500,跨度 4m"},{id:"16",name:"楼梯间 ST-1",type:"楼梯",layer:"建筑-楼梯",description:"双跑楼梯,净宽 1200mm"},{id:"17",name:"消防楼梯 ST-2",type:"楼梯",layer:"建筑-楼梯",description:"疏散楼梯,净宽 1100mm"},{id:"18",name:"电梯井 EV-1",type:"电梯",layer:"建筑-电梯",description:"客梯,井道 2000×2200"},{id:"19",name:"消防电梯 EV-2",type:"电梯",layer:"建筑-电梯",description:"消防兼客梯"},{id:"20",name:"强电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 4㎡"},{id:"21",name:"弱电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 2㎡"},{id:"22",name:"空调机房",type:"设备间",layer:"机电-暖通",description:"BF,面积 80㎡"},{id:"23",name:"消防控制室",type:"设备间",layer:"机电-消防",description:"1F,面积 24㎡"},{id:"24",name:"配电室",type:"设备间",layer:"机电-电气",description:"BF,面积 36㎡"},{id:"25",name:"轴线 A",type:"轴线",layer:"轴网",description:"X 向,间距 8400mm"},{id:"26",name:"轴线 1",type:"轴线",layer:"轴网",description:"Y 向,间距 7200mm"},{id:"27",name:"内墙 Q-001",type:"墙体",layer:"建筑-墙",description:"200mm 砌块"},{id:"28",name:"外墙 Q-101",type:"墙体",layer:"建筑-墙",description:"300mm 保温外墙"},{id:"29",name:"散水 SS-1",type:"室外",layer:"建筑-室外",description:"宽 900mm,坡度 3%"},{id:"30",name:"台阶 TJ-1",type:"室外",layer:"建筑-室外",description:"3 级,踏步 300×150"}];class af{engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new rf(t,this))}search(e){const t=e.trim().toLowerCase();return t?of.filter(n=>n.name.toLowerCase().includes(t)||n.type.toLowerCase().includes(t)||(n.layer?.toLowerCase().includes(t)??!1)||(n.description?.toLowerCase().includes(t)??!1)):[]}onResultSelect(e){console.log("[SearchManager] 选中结果:",e)}show(){this.searchUI?.show()}hide(){this.searchUI?.hide()}toggle(){this.searchUI?.toggle()}dispose(){this.searchUI?.dispose(),this.searchUI=null}}const jo={dark:{"--e2d-bg":"#1e1f22","--e2d-bg2":"#252526","--e2d-bg3":"#222222","--e2d-bg-hover":"rgba(79,195,247,0.08)","--e2d-bg-accent":"#094771","--e2d-icon-bg":"rgba(255,255,255,0.08)","--e2d-icon-bg-hover":"rgba(255,255,255,0.16)","--e2d-border":"rgba(255,255,255,0.12)","--e2d-border2":"#333333","--e2d-text":"#e0e0e0","--e2d-text2":"#cccccc","--e2d-text3":"rgba(255,255,255,0.35)","--e2d-text4":"#666666","--e2d-text-accent":"#ffffff","--e2d-accent":"#4fc3f7","--e2d-shadow":"rgba(0,0,0,0.50)","--e2d-shadow-lg":"rgba(0,0,0,0.65)","--e2d-cursor":"rgba(255,255,255,0.85)","--e2d-scrollbar":"rgba(255,255,255,0.15)","--e2d-float-bg":"rgba(0,0,0,0.65)","--e2d-float-border":"rgba(255,255,255,0.08)","--e2d-swatch-border":"#444444","--e2d-close":"#aaaaaa","--e2d-close-hover":"#ffffff","--e2d-icon":"rgba(255,255,255,0.4)","--e2d-coord-value":"#76c8ff","--e2d-coord-label":"rgba(255,255,255,0.45)"},light:{"--e2d-bg":"#ffffff","--e2d-bg2":"#f5f5f5","--e2d-bg3":"#eeeeee","--e2d-bg-hover":"rgba(25,118,210,0.06)","--e2d-bg-accent":"#e3f2fd","--e2d-icon-bg":"rgba(0,0,0,0.06)","--e2d-icon-bg-hover":"rgba(0,0,0,0.12)","--e2d-border":"rgba(0,0,0,0.12)","--e2d-border2":"#e0e0e0","--e2d-text":"#1a1a1a","--e2d-text2":"#444444","--e2d-text3":"rgba(0,0,0,0.40)","--e2d-text4":"#aaaaaa","--e2d-text-accent":"#1565c0","--e2d-accent":"#1976d2","--e2d-shadow":"rgba(0,0,0,0.15)","--e2d-shadow-lg":"rgba(0,0,0,0.22)","--e2d-cursor":"rgba(30,30,30,0.70)","--e2d-scrollbar":"rgba(0,0,0,0.18)","--e2d-float-bg":"rgba(245,245,245,0.92)","--e2d-float-border":"rgba(0,0,0,0.10)","--e2d-swatch-border":"#cccccc","--e2d-close":"#777777","--e2d-close-hover":"#1a1a1a","--e2d-icon":"rgba(0,0,0,0.45)","--e2d-coord-value":"#1976d2","--e2d-coord-label":"rgba(0,0,0,0.50)"}};class lf{container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=jo[e];for(const[n,i]of Object.entries(t))this.container.style.setProperty(n,i);this.container.setAttribute("data-e2d-theme",e)}setTheme(e){this.current=e,this._apply(e)}getTheme(){return this.current}toggle(){this.setTheme(this.current==="dark"?"light":"dark")}dispose(){for(const e of Object.keys(jo[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}class cf{options;container=null;animationId=null;isRendering=!1;fpsFrameCount=0;fpsLastCheck=0;currentFps=0;enablePerformanceMonitoring=!1;events;handelBehaved2d;interactionModule2d;sceneModule2d;cameraModule2d;renderModule2d;controlModule2d;loaderModule2d;layerManager;searchManager;themeManager;cadCursorUI;contextMenuUI;scene=null;camera=null;renderer=null;dwgData=null;version="1.0.0";constructor(e){if(this.options=e,this.enablePerformanceMonitoring=e.enablePerformanceMonitoring??!1,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.initialize(),this.handelBehaved2d=qd(this),this.interactionModule2d=new Hd(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new Ld(!1),this.sceneModule2d=new Od(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new Rd(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new Nd(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new Ud(this),this.loaderModule2d=new Zd(this),this.themeManager=new lf(this.container),this.layerManager=new Kd(this),this.searchManager=new af(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new Jd(this.container,this.renderer.domElement),this.contextMenuUI=new ef(this.container,this.renderer.domElement,e=>{e==="search"&&this.searchManager.show()}),this.startRendering(),console.log(`[EngineKernel2d] 2D Engine initialized (v${this.version})`)}startRendering(){this.isRendering||(this.isRendering=!0,this.fpsLastCheck=performance.now(),this.animate(),console.log("[EngineKernel2d] Rendering started"))}stopRendering(){this.isRendering=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),console.log("[EngineKernel2d] Rendering stopped")}animate=()=>{this.isRendering&&(this.animationId=requestAnimationFrame(this.animate),this.controlModule2d.update(),this.scene&&this.camera&&this.renderer&&this.renderer.render(this.scene,this.camera),this.enablePerformanceMonitoring&&this.updatePerformanceStats())};updatePerformanceStats(){this.fpsFrameCount++;const e=performance.now();e-this.fpsLastCheck>=1e3&&(this.currentFps=this.fpsFrameCount,this.fpsFrameCount=0,this.fpsLastCheck=e,this.events.trigger(_n.RenderEnd,{fps:this.currentFps}))}async loadModel(e,t){return await this.loaderModule2d.loadModel(e,t),{}}getLayers(){return this.loaderModule2d.getLayers()}getEntitiesByLayer(e){return this.loaderModule2d.getEntitiesByLayer(e)}setLayerVisible(e,t){console.log(`[EngineKernel2d] Set layer ${e} visible: ${t}`)}setTheme(e){this.themeManager.setTheme(e)}resetView(){this.cameraModule2d&&this.cameraModule2d.resetView()}fitToView(){this.dwgData?.metadata.extents&&this.cameraModule2d.fitToExtents(this.dwgData.metadata.extents)}setZoom(e){this.cameraModule2d&&this.cameraModule2d.setZoom(e)}getZoom(){return this.cameraModule2d?this.cameraModule2d.getZoom():1}getPerformanceStats(){const e=this.sceneModule2d.getSceneStats();return{fps:this.currentFps,renderTime:0,entityCount:e.objectCount,visibleEntityCount:e.objectCount}}setBackgroundColor(e){this.sceneModule2d&&this.sceneModule2d.setBackgroundColor(e)}clearScene(){this.sceneModule2d&&this.sceneModule2d.clearScene()}resize(){if(this.renderModule2d){const e=this.container?.clientWidth??0,t=this.container?.clientHeight??0;this.renderModule2d.setSize(e,t)}}dispose(){console.log("[EngineKernel2d] Disposing engine..."),this.stopRendering(),this.cadCursorUI?.dispose(),this.contextMenuUI?.dispose(),this.searchManager?.dispose(),this.themeManager?.dispose(),this.loaderModule2d?.dispose(),this.controlModule2d?.dispose(),this.renderModule2d?.dispose(),this.cameraModule2d?.dispose(),this.sceneModule2d?.dispose(),this.events?.dispose(),this.scene=null,this.camera=null,this.renderer=null,this.dwgData=null,console.log("[EngineKernel2d] Engine disposed")}}class hf{scene;panoramaSphere=null;sphereRadius;constructor(e=500){this.sphereRadius=e,this.scene=new b.Scene,this.init()}init(){this.panoramaSphere=this.createPanoramaSphere(this.sphereRadius),this.scene.add(this.panoramaSphere)}createPanoramaSphere(e=500,t=64){const n=new b.SphereGeometry(e,t,t/2);n.scale(-1,1,1);const i=new b.MeshBasicMaterial({map:null,side:b.FrontSide,transparent:!0}),s=new b.Mesh(n,i);return s.name="panorama-sphere",s}updatePanoramaTexture(e){if(!this.panoramaSphere){console.warn("SceneModule720: Panorama sphere not initialized");return}const t=this.panoramaSphere.material;t.map&&t.map.dispose(),t.map=e,t.needsUpdate=!0}clearPanoramaTexture(){if(!this.panoramaSphere)return;const e=this.panoramaSphere.material;e.map&&(e.map.dispose(),e.map=null,e.needsUpdate=!0)}getScene(){return this.scene}getPanoramaSphere(){return this.panoramaSphere}setSphereRadius(e){if(this.sphereRadius!==e){if(this.sphereRadius=e,this.panoramaSphere){const t=this.panoramaSphere.material,n=t.map;this.scene.remove(this.panoramaSphere),this.panoramaSphere.geometry.dispose(),t.dispose(),n&&n.dispose()}this.panoramaSphere=this.createPanoramaSphere(e),this.scene.add(this.panoramaSphere)}}getSphereRadius(){return this.sphereRadius}dispose(){if(this.panoramaSphere){const e=this.panoramaSphere.material;e.map&&e.map.dispose(),e.dispose(),this.panoramaSphere.geometry.dispose(),this.scene.remove(this.panoramaSphere),this.panoramaSphere=null}this.scene.clear()}}class uf{camera;minFov;maxFov;container;currentPose;constructor(e,t=75,n=30,i=90){this.container=e,this.minFov=n,this.maxFov=i,this.currentPose={theta:0,phi:0},this.camera=this.createCamera(t),this.init()}createCamera(e){const t=this.container.clientWidth/this.container.clientHeight,n=new b.PerspectiveCamera(e,t,.1,2e3);return n.position.set(0,0,0),n}init(){this.updateCameraRotation()}updateCameraRotation(){const{theta:e,phi:t}=this.currentPose,n=new b.Euler(t,e,0,"YXZ"),i=new b.Quaternion;i.setFromEuler(n),this.camera.quaternion.copy(i)}setFov(e){const t=Math.max(this.minFov,Math.min(this.maxFov,e));this.camera.fov=t,this.camera.updateProjectionMatrix()}getFov(){return this.camera.fov}getCameraPose(){return{...this.currentPose}}setCameraPose(e,t){this.currentPose.theta=e,this.currentPose.phi=t,this.updateCameraRotation()}updatePose(e,t){this.currentPose.theta+=e,this.currentPose.phi+=t,this.currentPose.theta<0?this.currentPose.theta+=2*Math.PI:this.currentPose.theta>=2*Math.PI&&(this.currentPose.theta-=2*Math.PI),this.currentPose.phi=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,this.currentPose.phi)),this.updateCameraRotation()}getCamera(){return this.camera}updateAspectRatio(e,t){const n=e/t;this.camera.aspect=n,this.camera.updateProjectionMatrix()}dispose(){this.camera=null}}class df{renderer;container;animationId=null;isRenderingPaused=!1;fpsFrameCount=0;fpsLastTime=performance.now();currentFps=60;onBeforeRenderCallback;onAfterRenderCallback;constructor(e,t=!0){this.container=e,this.renderer=this.createRenderer(t),this.init()}createRenderer(e){const t=new b.WebGLRenderer({antialias:e,alpha:!0,preserveDrawingBuffer:!1}),n=this.container.clientWidth,i=this.container.clientHeight;return t.setSize(n,i),t.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(t.domElement),t}init(){}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}render(e,t){this.onBeforeRenderCallback&&this.onBeforeRenderCallback(),this.renderer.render(e,t),this.onAfterRenderCallback&&this.onAfterRenderCallback(),this.updateFps()}startRenderLoop(e,t){if(this.animationId!==null){console.warn("RenderModule720: Render loop already running");return}this.isRenderingPaused=!1,this.animate(e,t)}animate(e,t){this.isRenderingPaused||(this.animationId=requestAnimationFrame(()=>{this.animate(e,t)}),this.render(e,t))}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(e,t){this.isRenderingPaused&&(this.isRenderingPaused=!1,this.startRenderLoop(e,t))}isRenderingPausedState(){return this.isRenderingPaused}updateFps(){this.fpsFrameCount++;const e=performance.now();e>=this.fpsLastTime+1e3&&(this.currentFps=Math.round(this.fpsFrameCount*1e3/(e-this.fpsLastTime)),this.fpsFrameCount=0,this.fpsLastTime=e,this.currentFps<30&&console.warn("RenderModule720: Low FPS detected:",this.currentFps))}getCurrentFps(){return this.currentFps}resize(e,t){this.renderer.setSize(e,t),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getDomElement(){return this.renderer.domElement}getRenderer(){return this.renderer}dispose(){this.pauseRendering(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.onBeforeRenderCallback=void 0,this.onAfterRenderCallback=void 0}}class ff{camera;domElement;cameraModule;enableZoom=!0;enableRotate=!0;minFov=30;maxFov=90;rotateSpeed=.5;zoomSpeed=1;enableDamping=!0;dampingFactor=.05;isDragging=!1;startX=0;startY=0;thetaDelta=0;phiDelta=0;isPinching=!1;pinchStartDistance=null;pinchStartFov=75;_onMouseDown;_onMouseMove;_onMouseUp;_onWheel;_onTouchStart;_onTouchMove;_onTouchEnd;onViewAngleChange;constructor(e,t){this.cameraModule=e,this.camera=e.getCamera(),this.pinchStartFov=this.camera.fov,this.domElement=t,this._onMouseDown=this.onMouseDown.bind(this),this._onMouseMove=this.onMouseMove.bind(this),this._onMouseUp=this.onMouseUp.bind(this),this._onWheel=this.onWheel.bind(this),this._onTouchStart=this.onTouchStart.bind(this),this._onTouchMove=this.onTouchMove.bind(this),this._onTouchEnd=this.onTouchEnd.bind(this),this.init()}init(){this.domElement.addEventListener("mousedown",this._onMouseDown),this.domElement.addEventListener("mousemove",this._onMouseMove),this.domElement.addEventListener("mouseup",this._onMouseUp),this.domElement.addEventListener("mouseleave",this._onMouseUp),this.domElement.addEventListener("wheel",this._onWheel,{passive:!1}),this.domElement.addEventListener("touchstart",this._onTouchStart,{passive:!1}),this.domElement.addEventListener("touchmove",this._onTouchMove,{passive:!1}),this.domElement.addEventListener("touchend",this._onTouchEnd)}onMouseDown(e){e.button===0&&(this.isDragging=!0,this.startX=e.clientX,this.startY=e.clientY)}onMouseMove(e){if(!this.isDragging||!this.enableRotate)return;const t=e.clientX-this.startX,n=e.clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta+=t*i*this.rotateSpeed*.06,this.phiDelta+=n*s*this.rotateSpeed*.06,this.startX=e.clientX,this.startY=e.clientY,this.applyRotation()}onMouseUp(){this.isDragging=!1}onWheel(e){if(!this.enableZoom)return;e.preventDefault();const n=(e.deltaY>0?1:-1)*this.zoomSpeed*2;this.applyZoom(n)}onTouchStart(e){e.touches.length===1?(this.isDragging=!0,this.isPinching=!1,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):e.touches.length===2&&(e.preventDefault(),this.isDragging=!1,this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov())}onTouchMove(e){if(e.touches.length===1&&this.isDragging&&this.enableRotate){const t=e.touches[0].clientX-this.startX,n=e.touches[0].clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta-=t*i*this.rotateSpeed,this.phiDelta-=n*s*this.rotateSpeed,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY,this.applyRotation()}else if(e.touches.length===2&&this.enableZoom){e.preventDefault(),this.isPinching||(this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov());const t=this.getTouchDistance(e.touches);if(this.pinchStartDistance&&t>0){const n=this.pinchStartDistance/t,i=b.MathUtils.clamp(this.pinchStartFov*n,this.minFov,this.maxFov);this.cameraModule.setFov(i)}}}onTouchEnd(e){e.touches&&e.touches.length>0?this.isDragging=e.touches.length===1:this.isDragging=!1,e.touches.length<2&&(this.isPinching=!1,this.pinchStartDistance=null)}applyRotation(){if(this.cameraModule.updatePose(this.thetaDelta,this.phiDelta),this.enableDamping?(this.thetaDelta*=1-this.dampingFactor,this.phiDelta*=1-this.dampingFactor):(this.thetaDelta=0,this.phiDelta=0),this.onViewAngleChange){const e=this.cameraModule.getCameraPose();this.onViewAngleChange(e.theta,e.phi)}}getRotationFactors(){const e=Math.max(1,this.domElement.clientWidth),t=Math.max(1,this.domElement.clientHeight);return{horizontal:Math.PI*2/e,vertical:Math.PI/t}}applyZoom(e){const t=this.cameraModule.getFov(),n=b.MathUtils.clamp(t+e,this.minFov,this.maxFov);this.cameraModule.setFov(n)}getTouchDistance(e){if(e.length<2)return 0;const t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)}update(){this.enableDamping&&(Math.abs(this.thetaDelta)>1e-4||Math.abs(this.phiDelta)>1e-4)&&this.applyRotation()}lookAt(e,t){this.thetaDelta=e,this.phiDelta=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,t)),this.cameraModule.setCameraPose(e,t),this.thetaDelta=0,this.phiDelta=0}getViewAngle(){return this.cameraModule.getCameraPose()}setOnViewAngleChange(e){this.onViewAngleChange=e}reset(){this.thetaDelta=0,this.phiDelta=0,this.lookAt(0,0)}setRotateSpeed(e){this.rotateSpeed=Math.max(.05,e)}setZoomSpeed(e){this.zoomSpeed=Math.max(.1,e)}setEnableDamping(e){this.enableDamping=e}setDampingFactor(e){this.dampingFactor=Math.max(0,Math.min(1,e))}setZoomLimits(e,t){this.minFov=e,this.maxFov=t}dispose(){this.domElement.removeEventListener("mousedown",this._onMouseDown),this.domElement.removeEventListener("mousemove",this._onMouseMove),this.domElement.removeEventListener("mouseup",this._onMouseUp),this.domElement.removeEventListener("mouseleave",this._onMouseUp),this.domElement.removeEventListener("wheel",this._onWheel),this.domElement.removeEventListener("touchstart",this._onTouchStart),this.domElement.removeEventListener("touchmove",this._onTouchMove),this.domElement.removeEventListener("touchend",this._onTouchEnd),this.onViewAngleChange=void 0}}class pf{controls;domElement;cameraModule;constructor(e,t){this.cameraModule=e,this.domElement=t,this.controls=new ff(e,t)}init(){}active(){}disActive(){this.controls.enableRotate=!1,this.controls.enableZoom=!1}enable(){this.controls.enableRotate=!0,this.controls.enableZoom=!0}update(){this.controls.update()}lookAt(e,t){this.controls.lookAt(e,t)}getViewAngle(){return this.controls.getViewAngle()}setOnViewAngleChange(e){this.controls.setOnViewAngleChange(e)}reset(){this.controls.reset()}getControls(){return this.controls}updateInteractionOptions(e){if(e.rotateSpeed!==void 0&&this.controls.setRotateSpeed(e.rotateSpeed),e.zoomSpeed!==void 0&&this.controls.setZoomSpeed(e.zoomSpeed),e.enableDamping!==void 0&&this.controls.setEnableDamping(e.enableDamping),e.dampingFactor!==void 0&&this.controls.setDampingFactor(e.dampingFactor),e.enableRotate!==void 0&&(this.controls.enableRotate=e.enableRotate),e.enableZoom!==void 0&&(this.controls.enableZoom=e.enableZoom),e.minFov!==void 0||e.maxFov!==void 0){const t=e.minFov??this.controls.minFov,n=e.maxFov??this.controls.maxFov;this.controls.setZoomLimits(t,n)}}dispose(){this.controls.dispose()}}class mf{cache=new Map;loadingPromises=new Map;loadTexture(e){if(this.cache.has(e))return Promise.resolve(this.cache.get(e));if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const t=new Promise((n,i)=>{new b.TextureLoader().load(e,r=>{r.colorSpace=b.SRGBColorSpace,r.minFilter=b.LinearFilter,r.magFilter=b.LinearFilter,this.cache.set(e,r),this.loadingPromises.delete(e),n(r)},void 0,r=>{this.loadingPromises.delete(e),i(r)})});return this.loadingPromises.set(e,t),t}async preloadTextures(e){const t=e.map(n=>this.loadTexture(n));return Promise.all(t)}has(e){return this.cache.has(e)}get(e){return this.cache.get(e)}remove(e){const t=this.cache.get(e);t&&(t.dispose(),this.cache.delete(e))}clear(){this.cache.forEach(e=>e.dispose()),this.cache.clear(),this.loadingPromises.clear()}size(){return this.cache.size}dispose(){this.clear()}}class gf{textureCache;currentUrl=null;loadProgress=0;onProgressCallback;constructor(){this.textureCache=new mf}async loadTexture(e){this.currentUrl=e,this.loadProgress=0,this.onProgressCallback&&this.onProgressCallback(0);try{const t=await this.loadTextureInternal(e);return this.loadProgress=100,this.onProgressCallback&&this.onProgressCallback(100),t}catch(t){throw console.error("PanoramaLoader: Failed to load texture:",t),t}}loadTextureInternal(e){return new Promise((t,n)=>{if(this.textureCache.has(e)){const s=this.textureCache.get(e);if(s){t(s);return}}new b.TextureLoader().load(e,s=>{s.colorSpace=b.SRGBColorSpace,s.minFilter=b.LinearFilter,s.magFilter=b.LinearFilter,this.textureCache.cache.set(e,s),t(s)},s=>{s.total>0&&(this.loadProgress=s.loaded/s.total*100,this.onProgressCallback&&this.onProgressCallback(this.loadProgress))},s=>{n(s)})})}async preloadPanoramas(e){try{await this.textureCache.preloadTextures(e)}catch(t){throw console.error("PanoramaLoader: Failed to preload panoramas:",t),t}}getLoadProgress(){return this.loadProgress}setOnProgress(e){this.onProgressCallback=e}getCurrentUrl(){return this.currentUrl}isCached(e){return this.textureCache.has(e)}getCachedTexture(e){return this.textureCache.get(e)}clearCache(){this.textureCache.clear()}removeCachedTexture(e){this.textureCache.remove(e)}dispose(){this.textureCache.dispose(),this.onProgressCallback=void 0,this.currentUrl=null}}class Go{static sphericalToCartesian(e){const t=e.radius||500,{theta:n,phi:i}=e,s=t*Math.cos(i)*Math.cos(n),r=t*Math.sin(i),a=t*Math.cos(i)*Math.sin(n);return{x:s,y:r,z:a}}static cartesianToSpherical(e,t,n){const i=Math.sqrt(e*e+t*t+n*n),s=Math.asin(t/i);let r=Math.atan2(n,e);return r<0&&(r+=2*Math.PI),{theta:r,phi:s,radius:i}}static normalizeAngle(e,t=-Math.PI,n=Math.PI){const i=n-t;let s=e;for(;s<t;)s+=i;for(;s>n;)s-=i;return s}static clampPhi(e,t=-Math.PI/2+.01,n=Math.PI/2-.01){return Math.max(t,Math.min(n,e))}static sphericalDistance(e,t){const n=Math.sin(e.phi)*Math.sin(t.phi)+Math.cos(e.phi)*Math.cos(t.phi)*Math.cos(e.theta-t.theta);return Math.acos(Math.max(-1,Math.min(1,n)))}static lerpSpherical(e,t,n){let i=t.theta-e.theta;i>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI);const s=e.theta+i*n,r=e.phi+(t.phi-e.phi)*n,a=e.radius||500,l=t.radius||500,c=a+(l-a)*n;return{theta:s,phi:r,radius:c}}}var Sn=(o=>(o.ICON="icon",o.TEXT="text",o.LINK="link",o))(Sn||{});class yf{annotations=new Map;container;annotationContainer;worldToScreen;sphereRadius;camera;renderer;onClickAnnotation;onHoverAnnotation;constructor(e,t,n,i){this.container=e,this.camera=t,this.renderer=n,this.sphereRadius=i,this.worldToScreen=new De(t,n),this.createAnnotationContainer()}createAnnotationContainer(){this.annotationContainer=document.createElement("div"),this.annotationContainer.className="panorama-annotation-container",this.annotationContainer.style.cssText=`
1239
1239
  position: absolute;
1240
1240
  top: 0;
1241
1241
  left: 0;
@@ -1250,7 +1250,7 @@ void main() {
1250
1250
  cursor: pointer;
1251
1251
  transform: translate(-50%, -50%);
1252
1252
  transition: opacity 0.2s ease;
1253
- `,e.type){case _n.ICON:this.createIconAnnotation(n,e);break;case _n.TEXT:this.createTextAnnotation(n,e);break;case _n.LINK:this.createLinkAnnotation(n,e);break}return this.attachAnnotationEvents(n,t),n}createIconAnnotation(e,t){const n=t.size||{width:40,height:40};e.style.width=`${n.width}px`,e.style.height=`${n.height}px`;const i=document.createElement("img");i.src=t.iconUrl,i.style.cssText=`
1253
+ `,e.type){case Sn.ICON:this.createIconAnnotation(n,e);break;case Sn.TEXT:this.createTextAnnotation(n,e);break;case Sn.LINK:this.createLinkAnnotation(n,e);break}return this.attachAnnotationEvents(n,t),n}createIconAnnotation(e,t){const n=t.size||{width:40,height:40};e.style.width=`${n.width}px`,e.style.height=`${n.height}px`;const i=document.createElement("img");i.src=t.iconUrl,i.style.cssText=`
1254
1254
  width: 100%;
1255
1255
  height: 100%;
1256
1256
  object-fit: contain;
@@ -1279,7 +1279,7 @@ void main() {
1279
1279
  width: 16px;
1280
1280
  height: 16px;
1281
1281
  display: block;
1282
- `,e.appendChild(s)}const i=document.createElement("span");i.textContent=t.text||t.url,e.appendChild(i),t.tooltip&&(e.title=t.tooltip)}attachAnnotationEvents(e,t){e.addEventListener("click",n=>{n.stopPropagation();const i=this.annotations.get(t);i&&this.handleClickAnnotation(i)}),e.addEventListener("mouseenter",()=>{const n=this.annotations.get(t);n&&this.handleHoverAnnotation(n)}),e.addEventListener("mouseleave",()=>{this.onHoverAnnotation&&this.onHoverAnnotation(null)})}sphericalToCartesian(e){const t=e.radius??this.sphereRadius;return Go.sphericalToCartesian({...e,radius:t})}updateAnnotationPosition(e){const t=new b.Vector3(e.worldPosition.x,e.worldPosition.y,e.worldPosition.z),n=this.worldToScreen.worldToScreen(t);e.screenPosition={x:n.x,y:n.y};const i=this.isPositionInFront(t),s=this.isPositionInView(n);e.visible=i&&s,e.visible?(e.element.style.display="block",e.element.style.left=`${n.x}px`,e.element.style.top=`${n.y}px`):e.element.style.display="none"}isPositionInFront(e){const t=new b.Vector3;return this.camera.getWorldDirection(t),e.clone().normalize().dot(t)>0}isPositionInView(e){const t=this.renderer.domElement.clientWidth,n=this.renderer.domElement.clientHeight;return e.x>=0&&e.x<=t&&e.y>=0&&e.y<=n}update(){this.annotations.forEach(e=>{this.updateAnnotationPosition(e)})}handleClickAnnotation(e){if(e.config.type===_n.LINK){const t=e.config;window.open(t.url,"_blank")}this.onClickAnnotation&&this.onClickAnnotation(e)}handleHoverAnnotation(e){this.onHoverAnnotation&&this.onHoverAnnotation(e)}setOnClickAnnotation(e){this.onClickAnnotation=e}setOnHoverAnnotation(e){this.onHoverAnnotation=e}removeAnnotation(e){const t=this.annotations.get(e);t&&(t.element.remove(),this.annotations.delete(e))}clearAll(){this.annotations.forEach(e=>{e.element.remove()}),this.annotations.clear()}getAnnotations(){return Array.from(this.annotations.values())}getAnnotation(e){return this.annotations.get(e)}updateCamera(e){this.camera=e,this.worldToScreen.updateCamera(e)}dispose(){this.clearAll(),this.annotationContainer.remove(),this.onClickAnnotation=void 0,this.onHoverAnnotation=void 0}generateId(){return`annotation-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}class wf{listeners=new Map;on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t)}off(e,t){const n=String(e),i=this.listeners.get(n);if(i){const s=i.indexOf(t);s!==-1&&i.splice(s,1),i.length===0&&this.listeners.delete(n)}}trigger(e,t){const n=String(e),i=this.listeners.get(n);if(i&&i.length>0){const s=[...i];for(const r of s)try{r(t)}catch(a){console.error(`EventModule: Error in event handler for "${n}":`,a)}}}removeAllListeners(e){const t=String(e);this.listeners.delete(t)}clear(){this.listeners.clear()}listenerCount(e){const t=String(e),n=this.listeners.get(t);return n?n.length:0}dispose(){this.clear()}}var nt=(o=>(o.PanoramaLoadStart="panorama-load-start",o.PanoramaLoadProgress="panorama-load-progress",o.PanoramaLoaded="panorama-loaded",o.PanoramaLoadError="panorama-load-error",o.AnnotationClick="annotation-click",o.AnnotationHover="annotation-hover",o.AnnotationAdd="annotation-add",o.AnnotationRemove="annotation-remove",o.ViewAngleChanged="view-angle-changed",o))(nt||{});class xf{sceneModule;cameraModule;renderModule;controlModule;eventModule;panoramaLoader;annotationManager;worldToScreen;isInitialized=!1;version="1.0.0";constructor(e){this.initialize(e)}initialize(e){const t={fov:75,enableZoom:!0,enableRotate:!0,minFov:30,maxFov:90,sphereRadius:500,rotateSpeed:.35,zoomSpeed:.8,enableDamping:!0,dampingFactor:.08,...e},n=document.getElementById(t.containerId);if(!n)throw new Error(`Container with id "${t.containerId}" not found`);try{this.eventModule=new wf,this.sceneModule=new uf(t.sphereRadius),this.cameraModule=new df(n,t.fov,t.minFov,t.maxFov),this.renderModule=new ff(n,!0),this.controlModule=new mf(this.cameraModule,this.renderModule.getDomElement());const i=this.controlModule.getControls();i.enableZoom=t.enableZoom,i.enableRotate=t.enableRotate,i.setRotateSpeed(t.rotateSpeed),i.setZoomSpeed(t.zoomSpeed),i.setEnableDamping(t.enableDamping),i.setDampingFactor(t.dampingFactor),i.setZoomLimits(t.minFov,t.maxFov),i.setOnViewAngleChange((s,r)=>{this.eventModule.trigger(nt.ViewAngleChanged,{theta:s,phi:r})}),this.panoramaLoader=new yf,this.worldToScreen=new De(this.cameraModule.getCamera(),this.renderModule.getRenderer(),this.sceneModule.getScene()),this.annotationManager=new vf(n,this.cameraModule.getCamera(),this.renderModule.getRenderer(),t.sphereRadius),this.annotationManager.setOnClickAnnotation(s=>{this.eventModule.trigger(nt.AnnotationClick,{id:s.id,config:s.config,metadata:s.config.metadata})}),this.annotationManager.setOnHoverAnnotation(s=>{this.eventModule.trigger(nt.AnnotationHover,{annotation:s?{id:s.id,config:s.config,metadata:s.config.metadata}:null})}),this.setupRenderLoop(),this.isInitialized=!0,console.log("EngineKernel720: Initialized successfully")}catch(i){throw console.error("EngineKernel720: Initialization failed",i),i}}setupRenderLoop(){this.renderModule.setOnBeforeRender(()=>{this.controlModule.update(),this.annotationManager.update()}),this.renderModule.startRenderLoop(this.sceneModule.getScene(),this.cameraModule.getCamera())}async loadPanorama(e){this.checkInitialized(),this.eventModule.trigger(nt.PanoramaLoadStart,{url:e});try{this.panoramaLoader.setOnProgress(n=>{this.eventModule.trigger(nt.PanoramaLoadProgress,{url:e,progress:n})});const t=await this.panoramaLoader.loadTexture(e);this.sceneModule.updatePanoramaTexture(t),this.eventModule.trigger(nt.PanoramaLoaded,{url:e,progress:100}),console.log("EngineKernel720: Panorama loaded successfully")}catch(t){throw console.error("EngineKernel720: Failed to load panorama",t),this.eventModule.trigger(nt.PanoramaLoadError,{url:e,error:t}),t}}async preloadPanoramas(e){this.checkInitialized();try{await this.panoramaLoader.preloadPanoramas(e),console.log(`EngineKernel720: Preloaded ${e.length} panoramas`)}catch(t){throw console.error("EngineKernel720: Failed to preload panoramas",t),t}}addAnnotation(e){this.checkInitialized();const t=this.annotationManager.addAnnotation(e);return this.eventModule.trigger(nt.AnnotationAdd,{id:t,config:e}),t}addAnnotations(e){return this.checkInitialized(),e.map(t=>this.addAnnotation(t))}removeAnnotation(e){this.checkInitialized(),this.annotationManager.removeAnnotation(e),this.eventModule.trigger(nt.AnnotationRemove,{id:e})}clearAnnotations(){this.checkInitialized(),this.annotationManager.clearAll()}getAnnotations(){return this.checkInitialized(),this.annotationManager.getAnnotations()}updateInteractionOptions(e){this.checkInitialized(),this.controlModule.updateInteractionOptions(e)}pickPanoramaPoint(e,t){this.checkInitialized();const i=this.renderModule.getRenderer().domElement,s=i.clientWidth,r=i.clientHeight;if(s===0||r===0)return null;const a=new b.Vector2(e/s*2-1,-(t/r*2-1)),l=this.cameraModule.getCamera(),h=new b.Vector3(a.x,a.y,.5);h.unproject(l),h.sub(l.position).normalize();const c=this.sceneModule.getSphereRadius(),d=l.position.clone().add(h.multiplyScalar(c)),m=Go.cartesianToSpherical(d.x,d.y,d.z);return{theta:m.theta,phi:m.phi,radius:c}}lookAt(e,t,n){this.checkInitialized(),n&&console.warn("EngineKernel720: Animated lookAt not implemented yet"),this.controlModule.lookAt(e,t)}getViewAngle(){return this.checkInitialized(),this.controlModule.getViewAngle()}setFov(e){this.checkInitialized(),this.cameraModule.setFov(e)}getFov(){return this.checkInitialized(),this.cameraModule.getFov()}on(e,t){this.checkInitialized(),this.eventModule.on(e,t)}off(e,t){this.checkInitialized(),this.eventModule.off(e,t)}resize(e,t){this.checkInitialized();const n=e??this.renderModule.getRenderer().domElement.clientWidth,i=t??this.renderModule.getRenderer().domElement.clientHeight;this.renderModule.resize(n,i),this.cameraModule.updateAspectRatio(n,i),console.log("EngineKernel720: Resized to",n,"x",i)}pauseRendering(){this.checkInitialized(),this.renderModule.pauseRendering()}resumeRendering(){this.checkInitialized(),this.renderModule.resumeRendering(this.sceneModule.getScene(),this.cameraModule.getCamera())}isRenderingPausedState(){return this.isInitialized?this.renderModule.isRenderingPausedState():!0}getVersion(){return this.version}dispose(){if(this.isInitialized)try{this.renderModule.pauseRendering(),this.annotationManager.dispose(),this.panoramaLoader.dispose(),this.controlModule.dispose(),this.cameraModule.dispose(),this.renderModule.dispose(),this.sceneModule.dispose(),this.eventModule.dispose(),this.isInitialized=!1,console.log("EngineKernel720: Disposed successfully")}catch(e){console.error("EngineKernel720: Error during dispose",e)}}checkInitialized(){if(!this.isInitialized)throw new Error("EngineKernel720: Not initialized")}}function bf(o){return new Ed(o)}function Mf(o){return new hf(o)}function _f(o){return new xf(o)}const Sf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
1282
+ `,e.appendChild(s)}const i=document.createElement("span");i.textContent=t.text||t.url,e.appendChild(i),t.tooltip&&(e.title=t.tooltip)}attachAnnotationEvents(e,t){e.addEventListener("click",n=>{n.stopPropagation();const i=this.annotations.get(t);i&&this.handleClickAnnotation(i)}),e.addEventListener("mouseenter",()=>{const n=this.annotations.get(t);n&&this.handleHoverAnnotation(n)}),e.addEventListener("mouseleave",()=>{this.onHoverAnnotation&&this.onHoverAnnotation(null)})}sphericalToCartesian(e){const t=e.radius??this.sphereRadius;return Go.sphericalToCartesian({...e,radius:t})}updateAnnotationPosition(e){const t=new b.Vector3(e.worldPosition.x,e.worldPosition.y,e.worldPosition.z),n=this.worldToScreen.worldToScreen(t);e.screenPosition={x:n.x,y:n.y};const i=this.isPositionInFront(t),s=this.isPositionInView(n);e.visible=i&&s,e.visible?(e.element.style.display="block",e.element.style.left=`${n.x}px`,e.element.style.top=`${n.y}px`):e.element.style.display="none"}isPositionInFront(e){const t=new b.Vector3;return this.camera.getWorldDirection(t),e.clone().normalize().dot(t)>0}isPositionInView(e){const t=this.renderer.domElement.clientWidth,n=this.renderer.domElement.clientHeight;return e.x>=0&&e.x<=t&&e.y>=0&&e.y<=n}update(){this.annotations.forEach(e=>{this.updateAnnotationPosition(e)})}handleClickAnnotation(e){if(e.config.type===Sn.LINK){const t=e.config;window.open(t.url,"_blank")}this.onClickAnnotation&&this.onClickAnnotation(e)}handleHoverAnnotation(e){this.onHoverAnnotation&&this.onHoverAnnotation(e)}setOnClickAnnotation(e){this.onClickAnnotation=e}setOnHoverAnnotation(e){this.onHoverAnnotation=e}removeAnnotation(e){const t=this.annotations.get(e);t&&(t.element.remove(),this.annotations.delete(e))}clearAll(){this.annotations.forEach(e=>{e.element.remove()}),this.annotations.clear()}getAnnotations(){return Array.from(this.annotations.values())}getAnnotation(e){return this.annotations.get(e)}updateCamera(e){this.camera=e,this.worldToScreen.updateCamera(e)}dispose(){this.clearAll(),this.annotationContainer.remove(),this.onClickAnnotation=void 0,this.onHoverAnnotation=void 0}generateId(){return`annotation-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}class vf{listeners=new Map;on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t)}off(e,t){const n=String(e),i=this.listeners.get(n);if(i){const s=i.indexOf(t);s!==-1&&i.splice(s,1),i.length===0&&this.listeners.delete(n)}}trigger(e,t){const n=String(e),i=this.listeners.get(n);if(i&&i.length>0){const s=[...i];for(const r of s)try{r(t)}catch(a){console.error(`EventModule: Error in event handler for "${n}":`,a)}}}removeAllListeners(e){const t=String(e);this.listeners.delete(t)}clear(){this.listeners.clear()}listenerCount(e){const t=String(e),n=this.listeners.get(t);return n?n.length:0}dispose(){this.clear()}}var nt=(o=>(o.PanoramaLoadStart="panorama-load-start",o.PanoramaLoadProgress="panorama-load-progress",o.PanoramaLoaded="panorama-loaded",o.PanoramaLoadError="panorama-load-error",o.AnnotationClick="annotation-click",o.AnnotationHover="annotation-hover",o.AnnotationAdd="annotation-add",o.AnnotationRemove="annotation-remove",o.ViewAngleChanged="view-angle-changed",o))(nt||{});class wf{sceneModule;cameraModule;renderModule;controlModule;eventModule;panoramaLoader;annotationManager;worldToScreen;isInitialized=!1;version="1.0.0";constructor(e){this.initialize(e)}initialize(e){const t={fov:75,enableZoom:!0,enableRotate:!0,minFov:30,maxFov:90,sphereRadius:500,rotateSpeed:.35,zoomSpeed:.8,enableDamping:!0,dampingFactor:.08,...e},n=document.getElementById(t.containerId);if(!n)throw new Error(`Container with id "${t.containerId}" not found`);try{this.eventModule=new vf,this.sceneModule=new hf(t.sphereRadius),this.cameraModule=new uf(n,t.fov,t.minFov,t.maxFov),this.renderModule=new df(n,!0),this.controlModule=new pf(this.cameraModule,this.renderModule.getDomElement());const i=this.controlModule.getControls();i.enableZoom=t.enableZoom,i.enableRotate=t.enableRotate,i.setRotateSpeed(t.rotateSpeed),i.setZoomSpeed(t.zoomSpeed),i.setEnableDamping(t.enableDamping),i.setDampingFactor(t.dampingFactor),i.setZoomLimits(t.minFov,t.maxFov),i.setOnViewAngleChange((s,r)=>{this.eventModule.trigger(nt.ViewAngleChanged,{theta:s,phi:r})}),this.panoramaLoader=new gf,this.worldToScreen=new De(this.cameraModule.getCamera(),this.renderModule.getRenderer(),this.sceneModule.getScene()),this.annotationManager=new yf(n,this.cameraModule.getCamera(),this.renderModule.getRenderer(),t.sphereRadius),this.annotationManager.setOnClickAnnotation(s=>{this.eventModule.trigger(nt.AnnotationClick,{id:s.id,config:s.config,metadata:s.config.metadata})}),this.annotationManager.setOnHoverAnnotation(s=>{this.eventModule.trigger(nt.AnnotationHover,{annotation:s?{id:s.id,config:s.config,metadata:s.config.metadata}:null})}),this.setupRenderLoop(),this.isInitialized=!0,console.log("EngineKernel720: Initialized successfully")}catch(i){throw console.error("EngineKernel720: Initialization failed",i),i}}setupRenderLoop(){this.renderModule.setOnBeforeRender(()=>{this.controlModule.update(),this.annotationManager.update()}),this.renderModule.startRenderLoop(this.sceneModule.getScene(),this.cameraModule.getCamera())}async loadPanorama(e){this.checkInitialized(),this.eventModule.trigger(nt.PanoramaLoadStart,{url:e});try{this.panoramaLoader.setOnProgress(n=>{this.eventModule.trigger(nt.PanoramaLoadProgress,{url:e,progress:n})});const t=await this.panoramaLoader.loadTexture(e);this.sceneModule.updatePanoramaTexture(t),this.eventModule.trigger(nt.PanoramaLoaded,{url:e,progress:100}),console.log("EngineKernel720: Panorama loaded successfully")}catch(t){throw console.error("EngineKernel720: Failed to load panorama",t),this.eventModule.trigger(nt.PanoramaLoadError,{url:e,error:t}),t}}async preloadPanoramas(e){this.checkInitialized();try{await this.panoramaLoader.preloadPanoramas(e),console.log(`EngineKernel720: Preloaded ${e.length} panoramas`)}catch(t){throw console.error("EngineKernel720: Failed to preload panoramas",t),t}}addAnnotation(e){this.checkInitialized();const t=this.annotationManager.addAnnotation(e);return this.eventModule.trigger(nt.AnnotationAdd,{id:t,config:e}),t}addAnnotations(e){return this.checkInitialized(),e.map(t=>this.addAnnotation(t))}removeAnnotation(e){this.checkInitialized(),this.annotationManager.removeAnnotation(e),this.eventModule.trigger(nt.AnnotationRemove,{id:e})}clearAnnotations(){this.checkInitialized(),this.annotationManager.clearAll()}getAnnotations(){return this.checkInitialized(),this.annotationManager.getAnnotations()}updateInteractionOptions(e){this.checkInitialized(),this.controlModule.updateInteractionOptions(e)}pickPanoramaPoint(e,t){this.checkInitialized();const i=this.renderModule.getRenderer().domElement,s=i.clientWidth,r=i.clientHeight;if(s===0||r===0)return null;const a=new b.Vector2(e/s*2-1,-(t/r*2-1)),l=this.cameraModule.getCamera(),c=new b.Vector3(a.x,a.y,.5);c.unproject(l),c.sub(l.position).normalize();const h=this.sceneModule.getSphereRadius(),d=l.position.clone().add(c.multiplyScalar(h)),m=Go.cartesianToSpherical(d.x,d.y,d.z);return{theta:m.theta,phi:m.phi,radius:h}}lookAt(e,t,n){this.checkInitialized(),n&&console.warn("EngineKernel720: Animated lookAt not implemented yet"),this.controlModule.lookAt(e,t)}getViewAngle(){return this.checkInitialized(),this.controlModule.getViewAngle()}setFov(e){this.checkInitialized(),this.cameraModule.setFov(e)}getFov(){return this.checkInitialized(),this.cameraModule.getFov()}on(e,t){this.checkInitialized(),this.eventModule.on(e,t)}off(e,t){this.checkInitialized(),this.eventModule.off(e,t)}resize(e,t){this.checkInitialized();const n=e??this.renderModule.getRenderer().domElement.clientWidth,i=t??this.renderModule.getRenderer().domElement.clientHeight;this.renderModule.resize(n,i),this.cameraModule.updateAspectRatio(n,i),console.log("EngineKernel720: Resized to",n,"x",i)}pauseRendering(){this.checkInitialized(),this.renderModule.pauseRendering()}resumeRendering(){this.checkInitialized(),this.renderModule.resumeRendering(this.sceneModule.getScene(),this.cameraModule.getCamera())}isRenderingPausedState(){return this.isInitialized?this.renderModule.isRenderingPausedState():!0}getVersion(){return this.version}dispose(){if(this.isInitialized)try{this.renderModule.pauseRendering(),this.annotationManager.dispose(),this.panoramaLoader.dispose(),this.controlModule.dispose(),this.cameraModule.dispose(),this.renderModule.dispose(),this.sceneModule.dispose(),this.eventModule.dispose(),this.isInitialized=!1,console.log("EngineKernel720: Disposed successfully")}catch(e){console.error("EngineKernel720: Error during dispose",e)}}checkInitialized(){if(!this.isInitialized)throw new Error("EngineKernel720: Not initialized")}}function xf(o){return new Ed(o)}function bf(o){return new cf(o)}function Mf(o){return new wf(o)}const _f=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
1283
1283
  \r
1284
1284
  ## 角色定位\r
1285
1285
  \r
@@ -1449,7 +1449,7 @@ json内容\r
1449
1449
  5. **用户友好**:步骤描述要清晰易懂,便于用户理解整个执行流程\r
1450
1450
  \r
1451
1451
  \r
1452
- ''`},Symbol.toStringTag,{value:"Module"})),Cf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家\r
1452
+ ''`},Symbol.toStringTag,{value:"Module"})),Sf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家\r
1453
1453
  \r
1454
1454
  ## 角色定位\r
1455
1455
  \r
@@ -1695,7 +1695,7 @@ try {\r
1695
1695
  5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"写法\r
1696
1696
  6. **注释清晰**:关键逻辑要有注释,但不要过度注释\r
1697
1697
  7. **性能考虑**:对于大量数据的处理,考虑性能优化\r
1698
- 8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),Af=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
1698
+ 8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),Cf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
1699
1699
 
1700
1700
  本文档为 BIM Engine SDK 的完整 API 参考,适合大模型阅读和理解引擎的功能结构。
1701
1701
 
@@ -3199,5 +3199,5 @@ BIM Engine SDK 提供了完整的 3D BIM 模型渲染和交互能力,主要特
3199
3199
  - 施工模拟
3200
3200
  - 运维管理
3201
3201
  - AI 辅助设计
3202
- `},Symbol.toStringTag,{value:"Module"}));it.createEngine=bf,it.createEngine2d=Mf,it.createEngine720=_f,Object.defineProperty(it,Symbol.toStringTag,{value:"Module"})}));
3202
+ `},Symbol.toStringTag,{value:"Module"}));it.createEngine=xf,it.createEngine2d=bf,it.createEngine720=Mf,Object.defineProperty(it,Symbol.toStringTag,{value:"Module"})}));
3203
3203
  //# sourceMappingURL=bim-engine-sdk.umd.js.map