iflow-engine-base 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bim-engine-sdk.es.js +3011 -2511
- package/dist/bim-engine-sdk.es.js.map +1 -1
- package/dist/bim-engine-sdk.umd.js +229 -21
- package/dist/bim-engine-sdk.umd.js.map +1 -1
- package/dist/iflow-engine-base.css +1 -1
- package/dist/index.d.ts +53 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(_t,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],S):(_t=typeof globalThis<"u"?globalThis:_t||self,S(_t.BimEngineSDK={},_t.THREE))})(this,(function(_t,S){"use strict";function Oo(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 A=Oo(S);class zo{engine;scene;constructor(e){this.engine=e,this.scene=new A.Scene;let t=new A.Group;t.name="groupEdge",this.scene.add(t)}}class No{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new A.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 A.OrthographicCamera(t*n/-2,t*n/2,t/2,t/-2,.1,1e3)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}updateComposerCamera(){if(!this.engine.composerModule?.composer)return;const e=this.engine.camera,t=this.engine.composerModule.composer;if(t.passes)for(const n of t.passes)n.camera!==void 0&&(n.camera=e)}switchToPerspectiveCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.perspectiveCamera,this.engine.scene.camera=this.perspectiveCamera,this.perspectiveCamera.position.copy(e),this.perspectiveCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.perspectiveCamera,this.engine.controlModule.firstPersonControls.camera=this.perspectiveCamera,this.updateComposerCamera(),this.perspectiveCamera.updateProjectionMatrix(),this.perspectiveCamera.updateMatrixWorld()}switchToOrthographicCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.orthographicCamera,this.engine.scene.camera=this.orthographicCamera,this.orthographicCamera.position.copy(e),this.orthographicCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.orthographicCamera,this.engine.controlModule.firstPersonControls.camera=this.orthographicCamera,this.updateComposerCamera(),this.orthographicCamera.updateProjectionMatrix(),this.orthographicCamera.updateMatrixWorld()}getCameraType(){return this.engine.camera===this.perspectiveCamera?"perspective":this.engine.camera===this.orthographicCamera?"orthographic":"perspective"}getCameraPose(){const e=this.engine.camera,t=this.getCameraType(),n={type:t,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w}};return this.engine.controls&&this.engine.controls.target&&(n.target={x:this.engine.controls.target.x,y:this.engine.controls.target.y,z:this.engine.controls.target.z}),t==="orthographic"&&(n.zoom=e.zoom),n}restoreCameraPose(e){this.getCameraType()!==e.type&&(e.type==="perspective"?this.switchToPerspectiveCamera():this.switchToOrthographicCamera());const n=this.engine.camera;n.position.set(e.position.x,e.position.y,e.position.z),e.quaternion?n.quaternion.set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w):e.rotation&&n.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.target&&this.engine.controls&&this.engine.controls.target&&this.engine.controls.target.set(e.target.x,e.target.y,e.target.z),e.type==="orthographic"&&e.zoom!==void 0&&(n.zoom=e.zoom,n.updateProjectionMatrix()),n.updateMatrix(),n.updateMatrixWorld(!0),this.engine.controls&&this.engine.controls.update&&this.engine.controls.update()}}class Ro{engine;deviceType;constructor(e){this.engine=e,this.deviceType="PC"}getDeviceType(){return this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class Fo{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new A.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=A.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=A.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Ds={type:"change"},xi={type:"start"},ks={type:"end"},_n=new S.Ray,Is=new S.Plane,Uo=Math.cos(70*S.MathUtils.DEG2RAD),be=new S.Vector3,Oe=2*Math.PI,ue={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},bi=1e-6;class Vo extends S.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=ue.NONE,this.target=new S.Vector3,this.cursor=new S.Vector3,this.origin=new S.Vector3(0,0,0),this.showOriginIcon=!0,this.originPosition={x:0,y:0},this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:S.MOUSE.ROTATE,MIDDLE:S.MOUSE.DOLLY,RIGHT:S.MOUSE.PAN},this.touches={ONE:S.TOUCH.ROTATE,TWO:S.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new S.Vector3,this._lastQuaternion=new S.Quaternion,this._lastTargetPosition=new S.Vector3,this._quat=new S.Quaternion().setFromUnitVectors(t.up,new S.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new S.Spherical,this._sphericalDelta=new S.Spherical,this._scale=1,this._panOffset=new S.Vector3,this._rotateStart=new S.Vector2,this._rotateEnd=new S.Vector2,this._rotateDelta=new S.Vector2,this._panStart=new S.Vector2,this._panEnd=new S.Vector2,this._panDelta=new S.Vector2,this._dollyStart=new S.Vector2,this._dollyEnd=new S.Vector2,this._dollyDelta=new S.Vector2,this._dollyDirection=new S.Vector3,this._mouse=new S.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Go.bind(this),this._onPointerDown=jo.bind(this),this._onPointerUp=Xo.bind(this),this._onContextMenu=Ho.bind(this),this._onMouseWheel=Zo.bind(this),this._onKeyDown=Ko.bind(this),this._onTouchStart=Yo.bind(this),this._onTouchMove=$o.bind(this),this._onMouseDown=Wo.bind(this),this._onMouseMove=qo.bind(this),this._interceptControlDown=Jo.bind(this),this._interceptControlUp=Qo.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ds),this.update(),this.state=ue.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;be.copy(t).sub(this.target),be.applyQuaternion(this._quat),this._spherical.setFromVector3(be),this.autoRotate&&this.state===ue.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Oe:n>Math.PI&&(n-=Oe),i<-Math.PI?i+=Oe:i>Math.PI&&(i-=Oe),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=r!=this._spherical.radius}if(be.setFromSpherical(this._spherical),be.applyQuaternion(this._quatInverse),this.engine&&this.engine.DeviceType==="PC"){const r=new S.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 S.Vector3(0,1,0),c=new S.Vector3;this.object.getWorldDirection(c);const u=c.clone().cross(h).normalize(),p=new S.Vector3().copy(this.object.position).sub(this.origin);p.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(u,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(p);const f=new S.Vector3().copy(this.target).sub(this.origin);f.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),f.applyAxisAngle(u,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(f)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const l=new S.Vector3;this.object.getWorldDirection(l);const h=this._spherical.radius*.05*(this._scale-1);t.add(l.multiplyScalar(h))}}else t.copy(this.target).add(be);this.object.lookAt(this.target)}else t.copy(this.target).add(be),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=be.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 S.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const h=new S.Vector3(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(a),this.object.updateMatrixWorld(),r=be.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):(_n.origin.copy(this.object.position),_n.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_n.direction))<Uo?this.object.lookAt(this.target):(Is.setFromNormalAndCoplanarPoint(this.object.up,this.target),_n.intersectPlane(Is,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)>bi||8*(1-this._lastQuaternion.dot(this.object.quaternion))>bi||this._lastTargetPosition.distanceToSquared(this.target)>bi?(this.dispatchEvent(Ds),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Oe/60*this.autoRotateSpeed*e:Oe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){be.setFromMatrixColumn(t,0),be.multiplyScalar(-e),this._panOffset.add(be)}_panUp(e,t){this.screenSpacePanning===!0?be.setFromMatrixColumn(t,1):(be.setFromMatrixColumn(t,0),be.crossVectors(this.object.up,be)),be.multiplyScalar(e),this._panOffset.add(be)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;be.copy(i).sub(this.target);let s=be.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 S.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function jo(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 Go(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function Xo(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(ks),this.state=ue.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Wo(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 S.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=ue.DOLLY;break;case S.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=ue.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=ue.ROTATE}break;case S.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=ue.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=ue.PAN}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(xi)}function qo(o){switch(this.state){case ue.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case ue.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case ue.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function Zo(o){this.enabled===!1||this.enableZoom===!1||this.state!==ue.NONE||(o.preventDefault(),this.dispatchEvent(xi),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(ks))}function Ko(o){this.enabled!==!1&&this._handleKeyDown(o)}function Yo(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case S.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=ue.TOUCH_ROTATE;break;case S.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=ue.TOUCH_PAN;break;default:this.state=ue.NONE}break;case 2:switch(this.touches.TWO){case S.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=ue.TOUCH_DOLLY_PAN;break;case S.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=ue.TOUCH_DOLLY_ROTATE;break;default:this.state=ue.NONE}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(xi)}function $o(o){switch(this._trackPointer(o),this.state){case ue.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case ue.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case ue.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case ue.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=ue.NONE}}function Ho(o){this.enabled!==!1&&o.preventDefault()}function Jo(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Qo(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Es{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new A.Vector3(0,-1,0),this._camerLocalDirection=new A.Vector3,this._tmpVector=new A.Vector3,this._rayCaster=new A.Raycaster,this._fallingTime=0,this._euler=new A.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 A.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 A.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var n=this.GetEngine().scene.ground;return n&&n.material.type,null}}function _i(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,p){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,p==null&&(p={showCatch:!1}),e.options=p},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",h),o.renderer.domElement.addEventListener("mousemove",l),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),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(u){(u.keyCode===8||u.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),u.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),u.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),u.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(u){u.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),u.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),u.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),u.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(u){const p=new A.Vector2,f=o.renderer.domElement.clientWidth,d=o.renderer.domElement.clientHeight;return p.x=u.offsetX/f*2-1,p.y=-(u.offsetY/d)*2+1,p}function s(u){const p=new A.Raycaster,f=i(u);return p.setFromCamera(f,o.camera),p}function r(u,p=!1){const f=s(u);if(u.raycaster=f,p){const d=c(f,u);u.catch=d}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new A.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 p=Date.now(),f=p-e.mouseDownTime,d=new A.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const m=d.distanceTo(e.mouseDownPosition);if((f<100||m==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const g=p-e.lastClickTime;console.log(g),g<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function c(u,p){if(!o.engineStatus.isFree){o.hoverHighLight.clearHighlight();return}o.catchSvg.innerHTML="";const f=o.octreeBox.rayInterationModel(u);let d=u.intersectObjects(o.scene.children.filter(O=>O instanceof A.InstancedMesh),!0);if(d.length>0&&(f.length==0||d[0].distance<f[0].distance)){let O=d[0].object,C=O.ids[d[0].instanceId],I={object:{url:O.url,id:C,name:C,isInstance:!0},face:d[0].face,distance:d[0].distance,point:d[0].point,instanceId:d[0].instanceId,matrix:O.matrixs[d[0].instanceId]};f.splice(0,0,I)}if(f.length===0)return;let m=f[0].object.url,g=f[0].object.name,y=o.modelEdge.getModelEdge(m,g);y||(y=[0,0,[]]);let w=[];y[2].forEach(O=>{O[0]!=null&&O[1]!=null&&w.push({X:O[0].X*.5+O[1].X*.5,Y:O[0].Y*.5+O[1].Y*.5,Z:O[0].Z*.5+O[1].Z*.5})});let x=[...y[2].map(O=>O[0]),...w],b="face",_=[],T=[],P=10;if(x.forEach(O=>{if(O!=null){let C=new A.Vector3(O.X,O.Z,-O.Y),I=o.worldToScreen.worldToScreen(C),v=Math.sqrt(Math.pow(I.x-p.offsetX,2)+Math.pow(I.y-p.offsetY,2));v<P&&(P=v,_.push({point:C,distance:v,pointxy:I}))}}),_.length>0?(_.sort((O,C)=>O.distance-C.distance),b="point"):(y[2].forEach(O=>{if(O[0]!=null&&O[1]!=null){let C=new A.Vector3(O[0].X,O[0].Z,-O[0].Y),I=new A.Vector3(O[1].X,O[1].Z,-O[1].Y),v=o.worldToScreen.worldToScreen(C),z=o.worldToScreen.worldToScreen(I),q=k(new A.Vector2(p.offsetX,p.offsetY),v,z);if(q<P){let G=D(new A.Vector2(p.offsetX,p.offsetY),v,z),ee=B(G,C,I);T.push({distance:q,point:ee,pointxy:o.worldToScreen.worldToScreen(ee),start:v,end:z})}}}),T.length>0&&(T.sort((O,C)=>O.distance-C.distance),b="line")),b=="point"&&e.options.showCatch){const O=o.worldToScreen.worldToScreen(_[0].point);o.catchSvg.innerHTML="";const C=O.x+o.reactBoundingClientRect.left,I=O.y+o.reactBoundingClientRect.top,v=document.createElementNS("http://www.w3.org/2000/svg","polygon");v.setAttribute("class","catchPoint"),v.setAttribute("points",`${C},${I-8} ${C-7},${I+4} ${C+7},${I+4}`),o.catchSvg.appendChild(v),f[0].point=_[0].point}else if(b=="line"&&e.options.showCatch){o.worldToScreen.worldToScreen(T[0].point);const O=T[0].start,C=T[0].end;o.catchSvg.innerHTML="";const I=document.createElementNS("http://www.w3.org/2000/svg","line");I.setAttribute("class","catchLine"),I.setAttribute("x1",(O.x+o.reactBoundingClientRect.left).toString()),I.setAttribute("y1",(O.y+o.reactBoundingClientRect.top).toString()),I.setAttribute("x2",(C.x+o.reactBoundingClientRect.left).toString()),I.setAttribute("y2",(C.y+o.reactBoundingClientRect.top).toString()),I.setAttribute("stroke","rgb(8, 223, 215)"),I.setAttribute("stroke-width","2"),o.catchSvg.appendChild(I),f[0].point=T[0].point}else if(b=="face"&&e.options.showCatch){let O=f[0].point.clone(),C=f[0].normal||(f[0].face?f[0].face.normal:null);const I=(C?C.clone():new A.Vector3(0,0,1)).normalize(),v=Math.abs(I.y)<.9?new A.Vector3(0,1,0):new A.Vector3(1,0,0),z=new A.Vector3().crossVectors(I,v).normalize(),q=new A.Vector3().crossVectors(I,z).normalize(),G=.05,Q=[new A.Vector3().copy(z).add(q).multiplyScalar(G),new A.Vector3().copy(z).sub(q).multiplyScalar(G),new A.Vector3().copy(z).multiplyScalar(-1).sub(q).multiplyScalar(G),new A.Vector3().copy(z).multiplyScalar(-1).add(q).multiplyScalar(G)].map(F=>new A.Vector3().copy(O).add(F)).map(F=>o.worldToScreen.worldToScreen(F));o.catchSvg.innerHTML="";const R=document.createElementNS("http://www.w3.org/2000/svg","polygon");R.setAttribute("class","catchFace"),R.setAttribute("points",Q.map(F=>`${F.x+o.reactBoundingClientRect.left},${F.y+o.reactBoundingClientRect.top}`).join(" ")),R.setAttribute("fill","rgba(1, 238, 255, 0.2)"),R.setAttribute("stroke","rgb(0, 255, 247)"),R.setAttribute("stroke-width","1"),o.catchSvg.appendChild(R)}return f[0];function k(O,C,I){const v=new A.Vector2().subVectors(I,C),z=v.lengthSq();if(z<1e-10)return O.distanceTo(C);const q=new A.Vector2().subVectors(O,C),G=A.MathUtils.clamp(q.dot(v)/z,0,1),ee=new A.Vector2().copy(v).multiplyScalar(G).add(C);return O.distanceTo(ee)}function D(O,C,I){const v=new A.Vector2().subVectors(I,C),z=v.lengthSq();if(z<1e-10)return 0;const q=new A.Vector2().subVectors(O,C);return A.MathUtils.clamp(q.dot(v)/z,0,1)}function B(O,C,I){const v=A.MathUtils.clamp(O,0,1);return new A.Vector3().lerpVectors(C,I,v)}}return e}class ea{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=_i(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Vo(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Es(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e}getMoveSpeed(){return this.firstPersonControls.moveSpeed}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new Es(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1,this.engine.cameraModule.switchToOrthographicCamera()),this.orbitControls.enabled=!0}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,n=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=n.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=n.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const vn={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
1
|
+
(function(_t,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],_):(_t=typeof globalThis<"u"?globalThis:_t||self,_(_t.BimEngineSDK={},_t.THREE))})(this,(function(_t,_){"use strict";function Uo(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 A=Uo(_);class Vo{engine;scene;constructor(e){this.engine=e,this.scene=new A.Scene;let t=new A.Group;t.name="groupEdge",this.scene.add(t)}}class jo{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new A.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 A.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 Go{engine;deviceType;constructor(e){this.engine=e,this.deviceType="PC"}getDeviceType(){return this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class Wo{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new A.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=A.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=A.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Es={type:"change"},Si={type:"start"},Bs={type:"end"},Mn=new _.Ray,Os=new _.Plane,Xo=Math.cos(70*_.MathUtils.DEG2RAD),ve=new _.Vector3,Oe=2*Math.PI,ue={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ai=1e-6;class Zo extends _.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=ue.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=Ko.bind(this),this._onPointerDown=qo.bind(this),this._onPointerUp=Yo.bind(this),this._onContextMenu=na.bind(this),this._onMouseWheel=Qo.bind(this),this._onKeyDown=Ho.bind(this),this._onTouchStart=ea.bind(this),this._onTouchMove=ta.bind(this),this._onMouseDown=$o.bind(this),this._onMouseMove=Jo.bind(this),this._interceptControlDown=ia.bind(this),this._interceptControlUp=sa.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(Es),this.update(),this.state=ue.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;ve.copy(t).sub(this.target),ve.applyQuaternion(this._quat),this._spherical.setFromVector3(ve),this.autoRotate&&this.state===ue.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Oe:n>Math.PI&&(n-=Oe),i<-Math.PI?i+=Oe:i>Math.PI&&(i-=Oe),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=r!=this._spherical.radius}if(ve.setFromSpherical(this._spherical),ve.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 u=c.clone().cross(h).normalize(),p=new _.Vector3().copy(this.object.position).sub(this.origin);p.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(u,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(p);const f=new _.Vector3().copy(this.target).sub(this.origin);f.applyAxisAngle(h,Math.PI*this._sphericalDelta.theta*l),f.applyAxisAngle(u,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(f)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const l=new _.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(ve);this.object.lookAt(this.target)}else t.copy(this.target).add(ve),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=ve.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=ve.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):(Mn.origin.copy(this.object.position),Mn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Mn.direction))<Xo?this.object.lookAt(this.target):(Os.setFromNormalAndCoplanarPoint(this.object.up,this.target),Mn.intersectPlane(Os,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)>Ai||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ai||this._lastTargetPosition.distanceToSquared(this.target)>Ai?(this.dispatchEvent(Es),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){ve.setFromMatrixColumn(t,0),ve.multiplyScalar(-e),this._panOffset.add(ve)}_panUp(e,t){this.screenSpacePanning===!0?ve.setFromMatrixColumn(t,1):(ve.setFromMatrixColumn(t,0),ve.crossVectors(this.object.up,ve)),ve.multiplyScalar(e),this._panOffset.add(ve)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ve.copy(i).sub(this.target);let s=ve.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 qo(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 Ko(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function Yo(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(Bs),this.state=ue.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function $o(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=ue.DOLLY;break;case _.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=ue.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=ue.ROTATE}break;case _.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=ue.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=ue.PAN}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(Si)}function Jo(o){switch(this.state){case ue.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case ue.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case ue.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function Qo(o){this.enabled===!1||this.enableZoom===!1||this.state!==ue.NONE||(o.preventDefault(),this.dispatchEvent(Si),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(Bs))}function Ho(o){this.enabled!==!1&&this._handleKeyDown(o)}function ea(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=ue.TOUCH_ROTATE;break;case _.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=ue.TOUCH_PAN;break;default:this.state=ue.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=ue.TOUCH_DOLLY_PAN;break;case _.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=ue.TOUCH_DOLLY_ROTATE;break;default:this.state=ue.NONE}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(Si)}function ta(o){switch(this._trackPointer(o),this.state){case ue.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case ue.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case ue.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case ue.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=ue.NONE}}function na(o){this.enabled!==!1&&o.preventDefault()}function ia(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function sa(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class zs{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new A.Vector3(0,-1,0),this._camerLocalDirection=new A.Vector3,this._tmpVector=new A.Vector3,this._rayCaster=new A.Raycaster,this._fallingTime=0,this._euler=new A.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 A.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 A.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var n=this.GetEngine().scene.ground;return n&&n.material.type,null}}function Ci(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,p){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,p==null&&(p={showCatch:!1}),e.options=p},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",h),o.renderer.domElement.addEventListener("mousemove",l),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),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(u){(u.keyCode===8||u.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),u.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),u.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),u.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(u){u.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),u.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),u.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),u.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(u){const p=new A.Vector2,f=o.renderer.domElement.clientWidth,d=o.renderer.domElement.clientHeight;return p.x=u.offsetX/f*2-1,p.y=-(u.offsetY/d)*2+1,p}function s(u){const p=new A.Raycaster,f=i(u);return p.setFromCamera(f,o.camera),p}function r(u,p=!1){const f=s(u);if(u.raycaster=f,p){const d=c(f,u);u.catch=d}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new A.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 p=Date.now(),f=p-e.mouseDownTime,d=new A.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const m=d.distanceTo(e.mouseDownPosition);if((f<100||m==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const g=p-e.lastClickTime;console.log(g),g<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function c(u,p){if(!o.engineStatus.isFree){o.hoverHighLight.clearHighlight();return}o.catchSvg.innerHTML="";const f=o.octreeBox.rayInterationModel(u);let d=u.intersectObjects(o.scene.children.filter(O=>O instanceof A.InstancedMesh),!0);if(d.length>0&&(f.length==0||d[0].distance<f[0].distance)){let O=d[0].object,C=O.ids[d[0].instanceId],I={object:{url:O.url,id:C,name:C,isInstance:!0},face:d[0].face,distance:d[0].distance,point:d[0].point,instanceId:d[0].instanceId,matrix:O.matrixs[d[0].instanceId]};f.splice(0,0,I)}if(f.length===0)return;let m=f[0].object.url,g=f[0].object.name,y=o.modelEdge.getModelEdge(m,g);y||(y=[0,0,[]]);let w=[];y[2].forEach(O=>{O[0]!=null&&O[1]!=null&&w.push({X:O[0].X*.5+O[1].X*.5,Y:O[0].Y*.5+O[1].Y*.5,Z:O[0].Z*.5+O[1].Z*.5})});let x=[...y[2].map(O=>O[0]),...w],v="face",b=[],T=[],P=10;if(x.forEach(O=>{if(O!=null){let C=new A.Vector3(O.X,O.Z,-O.Y),I=o.worldToScreen.worldToScreen(C),M=Math.sqrt(Math.pow(I.x-p.offsetX,2)+Math.pow(I.y-p.offsetY,2));M<P&&(P=M,b.push({point:C,distance:M,pointxy:I}))}}),b.length>0?(b.sort((O,C)=>O.distance-C.distance),v="point"):(y[2].forEach(O=>{if(O[0]!=null&&O[1]!=null){let C=new A.Vector3(O[0].X,O[0].Z,-O[0].Y),I=new A.Vector3(O[1].X,O[1].Z,-O[1].Y),M=o.worldToScreen.worldToScreen(C),z=o.worldToScreen.worldToScreen(I),Z=k(new A.Vector2(p.offsetX,p.offsetY),M,z);if(Z<P){let G=D(new A.Vector2(p.offsetX,p.offsetY),M,z),ee=E(G,C,I);T.push({distance:Z,point:ee,pointxy:o.worldToScreen.worldToScreen(ee),start:M,end:z})}}}),T.length>0&&(T.sort((O,C)=>O.distance-C.distance),v="line")),v=="point"&&e.options.showCatch){const O=o.worldToScreen.worldToScreen(b[0].point);o.catchSvg.innerHTML="";const C=O.x+o.reactBoundingClientRect.left,I=O.y+o.reactBoundingClientRect.top,M=document.createElementNS("http://www.w3.org/2000/svg","polygon");M.setAttribute("class","catchPoint"),M.setAttribute("points",`${C},${I-8} ${C-7},${I+4} ${C+7},${I+4}`),o.catchSvg.appendChild(M),f[0].point=b[0].point}else if(v=="line"&&e.options.showCatch){o.worldToScreen.worldToScreen(T[0].point);const O=T[0].start,C=T[0].end;o.catchSvg.innerHTML="";const I=document.createElementNS("http://www.w3.org/2000/svg","line");I.setAttribute("class","catchLine"),I.setAttribute("x1",(O.x+o.reactBoundingClientRect.left).toString()),I.setAttribute("y1",(O.y+o.reactBoundingClientRect.top).toString()),I.setAttribute("x2",(C.x+o.reactBoundingClientRect.left).toString()),I.setAttribute("y2",(C.y+o.reactBoundingClientRect.top).toString()),I.setAttribute("stroke","rgb(8, 223, 215)"),I.setAttribute("stroke-width","2"),o.catchSvg.appendChild(I),f[0].point=T[0].point}else if(v=="face"&&e.options.showCatch){let O=f[0].point.clone(),C=f[0].normal||(f[0].face?f[0].face.normal:null);const I=(C?C.clone():new A.Vector3(0,0,1)).normalize(),M=Math.abs(I.y)<.9?new A.Vector3(0,1,0):new A.Vector3(1,0,0),z=new A.Vector3().crossVectors(I,M).normalize(),Z=new A.Vector3().crossVectors(I,z).normalize(),G=.05,H=[new A.Vector3().copy(z).add(Z).multiplyScalar(G),new A.Vector3().copy(z).sub(Z).multiplyScalar(G),new A.Vector3().copy(z).multiplyScalar(-1).sub(Z).multiplyScalar(G),new A.Vector3().copy(z).multiplyScalar(-1).add(Z).multiplyScalar(G)].map(F=>new A.Vector3().copy(O).add(F)).map(F=>o.worldToScreen.worldToScreen(F));o.catchSvg.innerHTML="";const R=document.createElementNS("http://www.w3.org/2000/svg","polygon");R.setAttribute("class","catchFace"),R.setAttribute("points",H.map(F=>`${F.x+o.reactBoundingClientRect.left},${F.y+o.reactBoundingClientRect.top}`).join(" ")),R.setAttribute("fill","rgba(1, 238, 255, 0.2)"),R.setAttribute("stroke","rgb(0, 255, 247)"),R.setAttribute("stroke-width","1"),o.catchSvg.appendChild(R)}return f[0];function k(O,C,I){const M=new A.Vector2().subVectors(I,C),z=M.lengthSq();if(z<1e-10)return O.distanceTo(C);const Z=new A.Vector2().subVectors(O,C),G=A.MathUtils.clamp(Z.dot(M)/z,0,1),ee=new A.Vector2().copy(M).multiplyScalar(G).add(C);return O.distanceTo(ee)}function D(O,C,I){const M=new A.Vector2().subVectors(I,C),z=M.lengthSq();if(z<1e-10)return 0;const Z=new A.Vector2().subVectors(O,C);return A.MathUtils.clamp(Z.dot(M)/z,0,1)}function E(O,C,I){const M=A.MathUtils.clamp(O,0,1);return new A.Vector3().lerpVectors(C,I,M)}}return e}class ra{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=Ci(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Zo(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new zs(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e}getMoveSpeed(){return this.firstPersonControls.moveSpeed}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new zs(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1,this.engine.cameraModule.switchToOrthographicCamera()),this.orbitControls.enabled=!0}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,n=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=n.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=n.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const Mt={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
|
|
24
|
+
}`};class St{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 oa=new _.OrthographicCamera(-1,1,1,-1,0,1);class aa 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 la=new aa;class Sn{constructor(e){this._mesh=new _.Mesh(la,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,oa)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class An extends St{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 Sn(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 Ns extends St{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 ca extends St{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ha{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 An(Mt),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()}Ns!==void 0&&(r instanceof Ns?n=!0:r instanceof ca&&(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 ua extends St{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 Cn={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
|
-
}`},
|
|
207
|
+
}`},Tn={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
|
-
}`},
|
|
235
|
+
}`},Ti={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
|
|
249
|
+
}`};function da(o=5){const e=Math.floor(o)%2===0?Math.floor(o)+1:Math.floor(o),t=fa(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 fa(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 Pn={defines:{SAMPLES:16,SAMPLE_VECTORS:Rs(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,215 @@
|
|
|
391
391
|
denoised /= totalWeight;
|
|
392
392
|
}
|
|
393
393
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
394
|
-
}`};function Ls(o,e,t){const n=ca(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 ca(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 S.Vector3(Math.cos(s),Math.sin(s),r))}return n}class ha{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,i,s;const 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,u=(l+h)*c,p=l-u,f=h-u,d=e-p,m=t-f;let g,y;d>m?(g=1,y=0):(g=0,y=1);const w=d-g+c,x=m-y+c,b=d-1+2*c,_=m-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,B=this.perm[T+1+this.perm[P+1]]%12;let O=.5-d*d-m*m;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],d,m));let C=.5-w*w-x*x;C<0?i=0:(C*=C,i=C*C*this._dot(this.grad3[D],w,x));let I=.5-b*b-_*_;return I<0?s=0:(I*=I,s=I*I*this._dot(this.grad3[B],b,_)),70*(n+i+s)}noise3d(e,t,n){let i,s,r,a;const h=(e+t+n)*.3333333333333333,c=Math.floor(e+h),u=Math.floor(t+h),p=Math.floor(n+h),f=1/6,d=(c+u+p)*f,m=c-d,g=u-d,y=p-d,w=e-m,x=t-g,b=n-y;let _,T,P,k,D,B;w>=x?x>=b?(_=1,T=0,P=0,k=1,D=1,B=0):w>=b?(_=1,T=0,P=0,k=1,D=0,B=1):(_=0,T=0,P=1,k=1,D=0,B=1):x<b?(_=0,T=0,P=1,k=0,D=1,B=1):w<b?(_=0,T=1,P=0,k=0,D=1,B=1):(_=0,T=1,P=0,k=1,D=1,B=0);const O=w-_+f,C=x-T+f,I=b-P+f,v=w-k+2*f,z=x-D+2*f,q=b-B+2*f,G=w-1+3*f,ee=x-1+3*f,X=b-1+3*f,Q=c&255,R=u&255,F=p&255,te=this.perm[Q+this.perm[R+this.perm[F]]]%12,J=this.perm[Q+_+this.perm[R+T+this.perm[F+P]]]%12,Y=this.perm[Q+k+this.perm[R+D+this.perm[F+B]]]%12,de=this.perm[Q+1+this.perm[R+1+this.perm[F+1]]]%12;let fe=.6-w*w-x*x-b*b;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[te],w,x,b));let se=.6-O*O-C*C-I*I;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[J],O,C,I));let oe=.6-v*v-z*z-q*q;oe<0?r=0:(oe*=oe,r=oe*oe*this._dot3(this.grad3[Y],v,z,q));let he=.6-G*G-ee*ee-X*X;return he<0?a=0:(he*=he,a=he*he*this._dot3(this.grad3[de],G,ee,X)),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,u,p,f,d;const m=(e+t+n+i)*l,g=Math.floor(e+m),y=Math.floor(t+m),w=Math.floor(n+m),x=Math.floor(i+m),b=(g+y+w+x)*h,_=g-b,T=y-b,P=w-b,k=x-b,D=e-_,B=t-T,O=n-P,C=i-k,I=D>B?32:0,v=D>O?16:0,z=B>O?8:0,q=D>C?4:0,G=B>C?2:0,ee=O>C?1:0,X=I+v+z+q+G+ee,Q=r[X][0]>=3?1:0,R=r[X][1]>=3?1:0,F=r[X][2]>=3?1:0,te=r[X][3]>=3?1:0,J=r[X][0]>=2?1:0,Y=r[X][1]>=2?1:0,de=r[X][2]>=2?1:0,fe=r[X][3]>=2?1:0,se=r[X][0]>=1?1:0,oe=r[X][1]>=1?1:0,he=r[X][2]>=1?1:0,pe=r[X][3]>=1?1:0,Ae=D-Q+h,Le=B-R+h,M=O-F+h,W=C-te+h,j=D-J+2*h,L=B-Y+2*h,E=O-de+2*h,N=C-fe+2*h,Z=D-se+3*h,K=B-oe+3*h,U=O-he+3*h,$=C-pe+3*h,ne=D-1+4*h,H=B-1+4*h,ie=O-1+4*h,ce=C-1+4*h,ae=g&255,Ce=y&255,$e=w&255,ke=x&255,Ot=a[ae+a[Ce+a[$e+a[ke]]]]%32,ge=a[ae+Q+a[Ce+R+a[$e+F+a[ke+te]]]]%32,Qt=a[ae+J+a[Ce+Y+a[$e+de+a[ke+fe]]]]%32,xn=a[ae+se+a[Ce+oe+a[$e+he+a[ke+pe]]]]%32,He=a[ae+1+a[Ce+1+a[$e+1+a[ke+1]]]]%32;let xt=.6-D*D-B*B-O*O-C*C;xt<0?c=0:(xt*=xt,c=xt*xt*this._dot4(s[Ot],D,B,O,C));let zt=.6-Ae*Ae-Le*Le-M*M-W*W;zt<0?u=0:(zt*=zt,u=zt*zt*this._dot4(s[ge],Ae,Le,M,W));let Nt=.6-j*j-L*L-E*E-N*N;Nt<0?p=0:(Nt*=Nt,p=Nt*Nt*this._dot4(s[Qt],j,L,E,N));let Rt=.6-Z*Z-K*K-U*U-$*$;Rt<0?f=0:(Rt*=Rt,f=Rt*Rt*this._dot4(s[xn],Z,K,U,$));let bt=.6-ne*ne-H*H-ie*ie-ce*ce;return bt<0?d=0:(bt*=bt,d=bt*bt*this._dot4(s[He],ne,H,ie,ce)),27*(c+u+p+f+d)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,s){return e[0]*t+e[1]*n+e[2]*i+e[3]*s}}class ze extends Ft{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=aa(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{type:S.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new S.ShaderMaterial({defines:Object.assign({},Sn.defines),uniforms:S.UniformsUtils.clone(Sn.uniforms),vertexShader:Sn.vertexShader,fragmentShader:Sn.fragmentShader,blending:S.NoBlending,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new S.MeshNormalMaterial,this.normalMaterial.blending=S.NoBlending,this.pdMaterial=new S.ShaderMaterial({defines:Object.assign({},Cn.defines),uniforms:S.UniformsUtils.clone(Cn.uniforms),vertexShader:Cn.vertexShader,fragmentShader:Cn.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new S.ShaderMaterial({defines:Object.assign({},An.defines),uniforms:S.UniformsUtils.clone(An.uniforms),vertexShader:An.vertexShader,fragmentShader:An.fragmentShader,blending:S.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(vn.uniforms),vertexShader:vn.vertexShader,fragmentShader:vn.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this.blendMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(Mi.uniforms),vertexShader:Mi.vertexShader,fragmentShader:Mi.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:S.CustomBlending,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this._fsQuad=new vi(null),this._originalClearColor=new S.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 S.DepthTexture,this.depthTexture.format=S.DepthStencilFormat,this.depthTexture.type=S.UnsignedInt248Type,this.normalRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{minFilter:S.NearestFilter,magFilter:S.NearestFilter,type:S.HalfFloatType,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,i=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=i,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=i,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Ls(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ze.OUTPUT.Off:break;case ze.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const 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 ha,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 S.DataTexture(i,e,e,S.RGBAFormat,S.UnsignedByteType);return s.wrapS=S.RepeatWrapping,s.wrapT=S.RepeatWrapping,s.needsUpdate=!0,s}}ze.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Tn={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
394
|
+
}`};function Rs(o,e,t){const n=pa(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 pa(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 Fs{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,u=(l+h)*c,p=l-u,f=h-u,d=e-p,m=t-f;let g,y;d>m?(g=1,y=0):(g=0,y=1);const w=d-g+c,x=m-y+c,v=d-1+2*c,b=m-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-d*d-m*m;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],d,m));let C=.5-w*w-x*x;C<0?i=0:(C*=C,i=C*C*this._dot(this.grad3[D],w,x));let I=.5-v*v-b*b;return I<0?s=0:(I*=I,s=I*I*this._dot(this.grad3[E],v,b)),70*(n+i+s)}noise3d(e,t,n){let i,s,r,a;const h=(e+t+n)*.3333333333333333,c=Math.floor(e+h),u=Math.floor(t+h),p=Math.floor(n+h),f=1/6,d=(c+u+p)*f,m=c-d,g=u-d,y=p-d,w=e-m,x=t-g,v=n-y;let b,T,P,k,D,E;w>=x?x>=v?(b=1,T=0,P=0,k=1,D=1,E=0):w>=v?(b=1,T=0,P=0,k=1,D=0,E=1):(b=0,T=0,P=1,k=1,D=0,E=1):x<v?(b=0,T=0,P=1,k=0,D=1,E=1):w<v?(b=0,T=1,P=0,k=0,D=1,E=1):(b=0,T=1,P=0,k=1,D=1,E=0);const O=w-b+f,C=x-T+f,I=v-P+f,M=w-k+2*f,z=x-D+2*f,Z=v-E+2*f,G=w-1+3*f,ee=x-1+3*f,W=v-1+3*f,H=c&255,R=u&255,F=p&255,te=this.perm[H+this.perm[R+this.perm[F]]]%12,Q=this.perm[H+b+this.perm[R+T+this.perm[F+P]]]%12,Y=this.perm[H+k+this.perm[R+D+this.perm[F+E]]]%12,de=this.perm[H+1+this.perm[R+1+this.perm[F+1]]]%12;let fe=.6-w*w-x*x-v*v;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[te],w,x,v));let se=.6-O*O-C*C-I*I;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[Q],O,C,I));let oe=.6-M*M-z*z-Z*Z;oe<0?r=0:(oe*=oe,r=oe*oe*this._dot3(this.grad3[Y],M,z,Z));let he=.6-G*G-ee*ee-W*W;return he<0?a=0:(he*=he,a=he*he*this._dot3(this.grad3[de],G,ee,W)),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,u,p,f,d;const m=(e+t+n+i)*l,g=Math.floor(e+m),y=Math.floor(t+m),w=Math.floor(n+m),x=Math.floor(i+m),v=(g+y+w+x)*h,b=g-v,T=y-v,P=w-v,k=x-v,D=e-b,E=t-T,O=n-P,C=i-k,I=D>E?32:0,M=D>O?16:0,z=E>O?8:0,Z=D>C?4:0,G=E>C?2:0,ee=O>C?1:0,W=I+M+z+Z+G+ee,H=r[W][0]>=3?1:0,R=r[W][1]>=3?1:0,F=r[W][2]>=3?1:0,te=r[W][3]>=3?1:0,Q=r[W][0]>=2?1:0,Y=r[W][1]>=2?1:0,de=r[W][2]>=2?1:0,fe=r[W][3]>=2?1:0,se=r[W][0]>=1?1:0,oe=r[W][1]>=1?1:0,he=r[W][2]>=1?1:0,pe=r[W][3]>=1?1:0,Ae=D-H+h,Be=E-R+h,S=O-F+h,X=C-te+h,j=D-Q+2*h,B=E-Y+2*h,L=O-de+2*h,N=C-fe+2*h,q=D-se+3*h,K=E-oe+3*h,U=O-he+3*h,$=C-pe+3*h,ne=D-1+4*h,J=E-1+4*h,ie=O-1+4*h,ce=C-1+4*h,ae=g&255,Ce=y&255,$e=w&255,ke=x&255,Rt=a[ae+a[Ce+a[$e+a[ke]]]]%32,ge=a[ae+H+a[Ce+R+a[$e+F+a[ke+te]]]]%32,tn=a[ae+Q+a[Ce+Y+a[$e+de+a[ke+fe]]]]%32,bn=a[ae+se+a[Ce+oe+a[$e+he+a[ke+pe]]]]%32,Je=a[ae+1+a[Ce+1+a[$e+1+a[ke+1]]]]%32;let vt=.6-D*D-E*E-O*O-C*C;vt<0?c=0:(vt*=vt,c=vt*vt*this._dot4(s[Rt],D,E,O,C));let Ft=.6-Ae*Ae-Be*Be-S*S-X*X;Ft<0?u=0:(Ft*=Ft,u=Ft*Ft*this._dot4(s[ge],Ae,Be,S,X));let Ut=.6-j*j-B*B-L*L-N*N;Ut<0?p=0:(Ut*=Ut,p=Ut*Ut*this._dot4(s[tn],j,B,L,N));let Vt=.6-q*q-K*K-U*U-$*$;Vt<0?f=0:(Vt*=Vt,f=Vt*Vt*this._dot4(s[bn],q,K,U,$));let bt=.6-ne*ne-J*J-ie*ie-ce*ce;return bt<0?d=0:(bt*=bt,d=bt*bt*this._dot4(s[Je],ne,J,ie,ce)),27*(c+u+p+f+d)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,s){return e[0]*t+e[1]*n+e[2]*i+e[3]*s}}class ze extends St{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=da(),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({},Cn.defines),uniforms:_.UniformsUtils.clone(Cn.uniforms),vertexShader:Cn.vertexShader,fragmentShader:Cn.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({},Pn.defines),uniforms:_.UniformsUtils.clone(Pn.uniforms),vertexShader:Pn.vertexShader,fragmentShader:Pn.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({},Tn.defines),uniforms:_.UniformsUtils.clone(Tn.uniforms),vertexShader:Tn.vertexShader,fragmentShader:Tn.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(Mt.uniforms),vertexShader:Mt.vertexShader,fragmentShader:Mt.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(Ti.uniforms),vertexShader:Ti.vertexShader,fragmentShader:Ti.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:_.CustomBlending,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Sn(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=Rs(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ze.OUTPUT.Off:break;case ze.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case ze.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.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 Fs,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}}ze.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Dn={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
|
+
|
|
396
|
+
varying vec2 vUv;
|
|
397
|
+
|
|
398
|
+
void main() {
|
|
399
|
+
|
|
400
|
+
vUv = uv;
|
|
401
|
+
|
|
402
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
403
|
+
|
|
404
|
+
}`,fragmentShader:`
|
|
405
|
+
uniform highp sampler2D tNormal;
|
|
406
|
+
uniform highp sampler2D tDepth;
|
|
407
|
+
uniform sampler2D tNoise;
|
|
408
|
+
|
|
409
|
+
uniform vec3 kernel[ KERNEL_SIZE ];
|
|
410
|
+
|
|
411
|
+
uniform vec2 resolution;
|
|
412
|
+
|
|
413
|
+
uniform float cameraNear;
|
|
414
|
+
uniform float cameraFar;
|
|
415
|
+
uniform mat4 cameraProjectionMatrix;
|
|
416
|
+
uniform mat4 cameraInverseProjectionMatrix;
|
|
417
|
+
|
|
418
|
+
uniform float kernelRadius;
|
|
419
|
+
uniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference
|
|
420
|
+
uniform float maxDistance; // avoid the influence of fragments which are too far away
|
|
421
|
+
|
|
422
|
+
varying vec2 vUv;
|
|
423
|
+
|
|
424
|
+
#include <packing>
|
|
425
|
+
|
|
426
|
+
float getDepth( const in vec2 screenPosition ) {
|
|
427
|
+
|
|
428
|
+
return texture2D( tDepth, screenPosition ).x;
|
|
429
|
+
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
float getLinearDepth( const in vec2 screenPosition ) {
|
|
433
|
+
|
|
434
|
+
#if PERSPECTIVE_CAMERA == 1
|
|
435
|
+
|
|
436
|
+
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
|
437
|
+
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
|
438
|
+
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
439
|
+
|
|
440
|
+
#else
|
|
441
|
+
|
|
442
|
+
return texture2D( tDepth, screenPosition ).x;
|
|
443
|
+
|
|
444
|
+
#endif
|
|
445
|
+
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
float getViewZ( const in float depth ) {
|
|
449
|
+
|
|
450
|
+
#if PERSPECTIVE_CAMERA == 1
|
|
451
|
+
|
|
452
|
+
return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );
|
|
453
|
+
|
|
454
|
+
#else
|
|
455
|
+
|
|
456
|
+
return orthographicDepthToViewZ( depth, cameraNear, cameraFar );
|
|
457
|
+
|
|
458
|
+
#endif
|
|
459
|
+
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {
|
|
463
|
+
|
|
464
|
+
float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];
|
|
465
|
+
|
|
466
|
+
vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );
|
|
467
|
+
|
|
468
|
+
clipPosition *= clipW; // unprojection.
|
|
469
|
+
|
|
470
|
+
return ( cameraInverseProjectionMatrix * clipPosition ).xyz;
|
|
471
|
+
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
vec3 getViewNormal( const in vec2 screenPosition ) {
|
|
475
|
+
|
|
476
|
+
return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );
|
|
477
|
+
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
void main() {
|
|
481
|
+
|
|
482
|
+
float depth = getDepth( vUv );
|
|
483
|
+
|
|
484
|
+
if ( depth == 1.0 ) {
|
|
485
|
+
|
|
486
|
+
gl_FragColor = vec4( 1.0 ); // don't influence background
|
|
487
|
+
|
|
488
|
+
} else {
|
|
489
|
+
|
|
490
|
+
float viewZ = getViewZ( depth );
|
|
491
|
+
|
|
492
|
+
vec3 viewPosition = getViewPosition( vUv, depth, viewZ );
|
|
493
|
+
vec3 viewNormal = getViewNormal( vUv );
|
|
494
|
+
|
|
495
|
+
vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );
|
|
496
|
+
vec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );
|
|
497
|
+
|
|
498
|
+
// compute matrix used to reorient a kernel vector
|
|
499
|
+
|
|
500
|
+
vec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );
|
|
501
|
+
vec3 bitangent = cross( viewNormal, tangent );
|
|
502
|
+
mat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );
|
|
503
|
+
|
|
504
|
+
float occlusion = 0.0;
|
|
505
|
+
|
|
506
|
+
for ( int i = 0; i < KERNEL_SIZE; i ++ ) {
|
|
507
|
+
|
|
508
|
+
vec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space
|
|
509
|
+
vec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point
|
|
510
|
+
|
|
511
|
+
vec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC
|
|
512
|
+
samplePointNDC /= samplePointNDC.w;
|
|
513
|
+
|
|
514
|
+
vec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates
|
|
515
|
+
|
|
516
|
+
float realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture
|
|
517
|
+
float sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value
|
|
518
|
+
float delta = sampleDepth - realDepth;
|
|
519
|
+
|
|
520
|
+
if ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion
|
|
521
|
+
|
|
522
|
+
occlusion += 1.0;
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
occlusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );
|
|
529
|
+
|
|
530
|
+
gl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );
|
|
531
|
+
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
}`},kn={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`varying vec2 vUv;
|
|
535
|
+
|
|
536
|
+
void main() {
|
|
537
|
+
|
|
538
|
+
vUv = uv;
|
|
539
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
540
|
+
|
|
541
|
+
}`,fragmentShader:`uniform sampler2D tDepth;
|
|
542
|
+
|
|
543
|
+
uniform float cameraNear;
|
|
544
|
+
uniform float cameraFar;
|
|
545
|
+
|
|
546
|
+
varying vec2 vUv;
|
|
547
|
+
|
|
548
|
+
#include <packing>
|
|
549
|
+
|
|
550
|
+
float getLinearDepth( const in vec2 screenPosition ) {
|
|
551
|
+
|
|
552
|
+
#if PERSPECTIVE_CAMERA == 1
|
|
553
|
+
|
|
554
|
+
float fragCoordZ = texture2D( tDepth, screenPosition ).x;
|
|
555
|
+
float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
|
|
556
|
+
return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
557
|
+
|
|
558
|
+
#else
|
|
559
|
+
|
|
560
|
+
return texture2D( tDepth, screenPosition ).x;
|
|
561
|
+
|
|
562
|
+
#endif
|
|
563
|
+
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
void main() {
|
|
567
|
+
|
|
568
|
+
float depth = getLinearDepth( vUv );
|
|
569
|
+
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
|
570
|
+
|
|
571
|
+
}`},In={uniforms:{tDiffuse:{value:null},resolution:{value:new _.Vector2}},vertexShader:`varying vec2 vUv;
|
|
572
|
+
|
|
573
|
+
void main() {
|
|
574
|
+
|
|
575
|
+
vUv = uv;
|
|
576
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
577
|
+
|
|
578
|
+
}`,fragmentShader:`uniform sampler2D tDiffuse;
|
|
579
|
+
|
|
580
|
+
uniform vec2 resolution;
|
|
581
|
+
|
|
582
|
+
varying vec2 vUv;
|
|
583
|
+
|
|
584
|
+
void main() {
|
|
585
|
+
|
|
586
|
+
vec2 texelSize = ( 1.0 / resolution );
|
|
587
|
+
float result = 0.0;
|
|
588
|
+
|
|
589
|
+
for ( int i = - 2; i <= 2; i ++ ) {
|
|
590
|
+
|
|
591
|
+
for ( int j = - 2; j <= 2; j ++ ) {
|
|
592
|
+
|
|
593
|
+
vec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;
|
|
594
|
+
result += texture2D( tDiffuse, vUv + offset ).r;
|
|
595
|
+
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );
|
|
601
|
+
|
|
602
|
+
}`};class nt extends St{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({},Dn.defines),uniforms:_.UniformsUtils.clone(Dn.uniforms),vertexShader:Dn.vertexShader,fragmentShader:Dn.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({},In.defines),uniforms:_.UniformsUtils.clone(In.uniforms),vertexShader:In.vertexShader,fragmentShader:In.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({},kn.defines),uniforms:_.UniformsUtils.clone(kn.uniforms),vertexShader:kn.vertexShader,fragmentShader:kn.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(Mt.uniforms),vertexShader:Mt.vertexShader,fragmentShader:Mt.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Sn(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 nt.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 nt.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 nt.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:n);break;case nt.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 nt.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 Fs,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}}nt.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const Ln={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
395
603
|
precision highp float;
|
|
396
604
|
|
|
397
605
|
uniform mat4 modelViewMatrix;
|
|
@@ -462,7 +670,7 @@
|
|
|
462
670
|
|
|
463
671
|
#endif
|
|
464
672
|
|
|
465
|
-
}`};class
|
|
673
|
+
}`};class ma extends St{constructor(){super(),this.uniforms=_.UniformsUtils.clone(Ln.uniforms),this.material=new _.RawShaderMaterial({name:Ln.name,uniforms:this.uniforms,vertexShader:Ln.vertexShader,fragmentShader:Ln.fragmentShader}),this._fsQuad=new Sn(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 ga={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new _.Vector2(1/1024,1/512)}},vertexShader:`
|
|
466
674
|
|
|
467
675
|
varying vec2 vUv;
|
|
468
676
|
|
|
@@ -723,7 +931,7 @@
|
|
|
723
931
|
|
|
724
932
|
gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
|
|
725
933
|
|
|
726
|
-
}`},
|
|
934
|
+
}`},ya={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
|
|
727
935
|
varying vec2 vUv;
|
|
728
936
|
void main() {
|
|
729
937
|
vUv = uv;
|
|
@@ -749,18 +957,18 @@
|
|
|
749
957
|
|
|
750
958
|
gl_FragColor = color;
|
|
751
959
|
}
|
|
752
|
-
`};class
|
|
753
|
-
\0`,J+=s(R,2),J+=T.magic,J+=s(x,2),J+=s(b,2),J+=s(Q.crc32,4),J+=s(Q.compressedSize,4),J+=s(Q.uncompressedSize,4),J+=s(k.length,2),J+=s(z.length,2),{fileRecord:u.LOCAL_FILE_HEADER+J+k+z,dirRecord:u.CENTRAL_FILE_HEADER+s(te,2)+J+s(O.length,2)+"\0\0\0\0"+s(F,4)+s(g,4)+k+z+O}}var a=t("../utils"),l=t("../stream/GenericWorker"),h=t("../utf8"),c=t("../crc32"),u=t("../signature");function p(f,d,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=d,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(f){var d=f.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,l.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:m?(d+100*(m-g-1))/m:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var d=this.streamFiles&&!f.file.dir;if(d){var m=r(f,d,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var d=this.streamFiles&&!f.file.dir,m=r(f,d,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),d)this.push({data:(function(g){return u.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(f),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,d=0;d<this.dirRecords.length;d++)this.push({data:this.dirRecords[d],meta:{percent:100}});var m=this.bytesWritten-f,g=(function(y,w,x,b,_){var T=a.transformTo("string",_(b));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(w,4)+s(x,4)+s(T.length,2)+T})(this.dirRecords.length,m,f,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(f){this._sources.push(f);var d=this;return f.on("data",function(m){d.processChunk(m)}),f.on("end",function(){d.closedSource(d.previous.streamInfo),d._sources.length?d.prepareNextSource():d.end()}),f.on("error",function(m){d.error(m)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(f){var d=this._sources;if(!l.prototype.error.call(this,f))return!1;for(var m=0;m<d.length;m++)try{d[m].error(f)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var f=this._sources,d=0;d<f.length;d++)f[d].lock()},n.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),r=t("./ZipFileWorker");i.generateWorker=function(a,l,h){var c=new r(l.streamFiles,h,l.platform,l.encodeFileName),u=0;try{a.forEach(function(p,f){u++;var d=(function(w,x){var b=w||x,_=s[b];if(!_)throw new Error(b+" is not a valid compression method !");return _})(f.options.compression,l.compression),m=f.options.compressionOptions||l.compressionOptions||{},g=f.dir,y=f.date;f._compressWorker(d,m).withStreamInfo("file",{name:p,dir:g,date:y,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(c)}),c.entriesCount=u}catch(p){c.error(p)}return c}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var 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 u(p){return new r.Promise(function(f,d){var m=p.decompressed.getContentWorker().pipe(new h);m.on("error",function(g){d(g)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?d(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}n.exports=function(p,f){var d=this;return f=s.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(p)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,f.optimizedBinaryString,f.base64).then(function(m){var g=new l(f);return g.load(m),g}).then(function(m){var g=[r.Promise.resolve(m)],y=m.files;if(f.checkCRC32)for(var w=0;w<y.length;w++)g.push(u(y[w]));return r.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,w=0;w<y.length;w++){var x=y[w],b=x.fileNameStr,_=s.resolve(x.fileNameStr);d.file(_,x.decompressed,{binary:!0,optimizedBinaryString:!0,date:x.date,dir:x.dir,comment:x.fileCommentStr.length?x.fileCommentStr:null,unixPermissions:x.unixPermissions,dosPermissions:x.dosPermissions,createFolders:f.createFolders}),x.dir||(d.file(_).unsafeOriginalName=b)}return g.zipComment.length&&(d.comment=g.zipComment),d})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),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(u,p){c.push(u)||c._helper.pause(),h&&h(p)}).on("error",function(u){c.emit("error",u)}).on("end",function(){c.push(null)})}t("../utils").inherits(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(_,T,P){var k,D=a.getTypeOf(T),B=a.extend(P||{},c);B.date=B.date||new Date,B.compression!==null&&(B.compression=B.compression.toUpperCase()),typeof B.unixPermissions=="string"&&(B.unixPermissions=parseInt(B.unixPermissions,8)),B.unixPermissions&&16384&B.unixPermissions&&(B.dir=!0),B.dosPermissions&&16&B.dosPermissions&&(B.dir=!0),B.dir&&(_=y(_)),B.createFolders&&(k=g(_))&&w.call(this,k,!0);var O=D==="string"&&B.binary===!1&&B.base64===!1;P&&P.binary!==void 0||(B.binary=!O),(T instanceof u&&T.uncompressedSize===0||B.dir||!T||T.length===0)&&(B.base64=!1,B.binary=!0,T="",B.compression="STORE",D="string");var C=null;C=T instanceof u||T instanceof l?T:d.isNode&&d.isStream(T)?new m(_,T):a.prepareContent(_,T,B.binary,B.optimizedBinaryString,B.base64);var I=new p(_,C,B);this.files[_]=I}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),h=t("./stream/StreamHelper"),c=t("./defaults"),u=t("./compressedObject"),p=t("./zipObject"),f=t("./generate"),d=t("./nodejsUtils"),m=t("./nodejs/NodejsStreamInputAdapter"),g=function(_){_.slice(-1)==="/"&&(_=_.substring(0,_.length-1));var T=_.lastIndexOf("/");return 0<T?_.substring(0,T):""},y=function(_){return _.slice(-1)!=="/"&&(_+="/"),_},w=function(_,T){return T=T!==void 0?T:c.createFolders,_=y(_),this.files[_]||s.call(this,_,null,{dir:!0,createFolders:T}),this.files[_]};function x(_){return Object.prototype.toString.call(_)==="[object RegExp]"}var b={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(_){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&&_(P,k)},filter:function(_){var T=[];return this.forEach(function(P,k){_(P,k)&&T.push(k)}),T},file:function(_,T,P){if(arguments.length!==1)return _=this.root+_,s.call(this,_,T,P),this;if(x(_)){var k=_;return this.filter(function(B,O){return!O.dir&&k.test(B)})}var D=this.files[this.root+_];return D&&!D.dir?D:null},folder:function(_){if(!_)return this;if(x(_))return this.filter(function(D,B){return B.dir&&_.test(D)});var T=this.root+_,P=w.call(this,T),k=this.clone();return k.root=P.name,k},remove:function(_){_=this.root+_;var T=this.files[_];if(T||(_.slice(-1)!=="/"&&(_+="/"),T=this.files[_]),T&&!T.dir)delete this.files[_];else for(var P=this.filter(function(D,B){return B.name.slice(0,_.length)===_}),k=0;k<P.length;k++)delete this.files[P[k].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(_){var T,P={};try{if((P=a.extend(_||{},{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=f.generateWorker(this,P,k)}catch(D){(T=new l("error")).error(D)}return new h(T,P.type||"string",P.mimeType)},generateAsync:function(_,T){return this.generateInternalStream(_).accumulate(T)},generateNodeStream:function(_,T){return(_=_||{}).type||(_.type="nodebuffer"),this.generateInternalStream(_).toNodejsStream(T)}};n.exports=b},{"./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),u=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===h&&this.data[p+2]===c&&this.data[p+3]===u)return p-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),u=a.charCodeAt(3),p=this.readData(4);return l===p[0]&&h===p[1]&&c===p[2]&&u===p[3]},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(u){var p=s.getTypeOf(u);return s.checkSupport(p),p!=="string"||r.uint8array?p==="nodebuffer"?new h(u):r.uint8array?new c(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),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"),u=null;if(h.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(d,m){return new c.Promise(function(g,y){var w=[],x=d._internalType,b=d._outputType,_=d._mimeType;d.on("data",function(T,P){w.push(T),m&&m(P)}).on("error",function(T){w=[],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)}})(b,(function(P,k){var D,B=0,O=null,C=0;for(D=0;D<k.length;D++)C+=k[D].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(C),D=0;D<k.length;D++)O.set(k[D],B),B+=k[D].length;return O;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+P+"'")}})(x,w),_);g(T)}catch(P){y(P)}w=[]}).resume()})}function f(d,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,s.checkSupport(y),this._worker=d.pipe(new r(y)),d.lock()}catch(w){this._worker=new a("error"),this._worker.error(w)}}f.prototype={accumulate:function(d){return p(this,d)},on:function(d,m){var g=this;return d==="data"?this._worker.on(d,function(y){m.call(g,y.data,y.meta)}):this._worker.on(d,function(){s.delay(m,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(d){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},d)}},n.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var 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 u(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}i.utf8encode=function(f){return r.nodebuffer?a.newBufferFrom(f,"utf-8"):(function(d){var m,g,y,w,x,b=d.length,_=0;for(w=0;w<b;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<b&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),_+=g<128?1:g<2048?2:g<65536?3:4;for(m=r.uint8array?new Uint8Array(_):new Array(_),w=x=0;x<_;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<b&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),g<128?m[x++]=g:(g<2048?m[x++]=192|g>>>6:(g<65536?m[x++]=224|g>>>12:(m[x++]=240|g>>>18,m[x++]=128|g>>>12&63),m[x++]=128|g>>>6&63),m[x++]=128|63&g);return m})(f)},i.utf8decode=function(f){return r.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):(function(d){var m,g,y,w,x=d.length,b=new Array(2*x);for(m=g=0;m<x;)if((y=d[m++])<128)b[g++]=y;else if(4<(w=h[y]))b[g++]=65533,m+=w-1;else{for(y&=w===2?31:w===3?15:7;1<w&&m<x;)y=y<<6|63&d[m++],w--;1<w?b[g++]=65533:y<65536?b[g++]=y:(y-=65536,b[g++]=55296|y>>10&1023,b[g++]=56320|1023&y)}return b.length!==g&&(b.subarray?b=b.subarray(0,g):b.length=g),s.applyFromCharCode(b)})(f=s.transformTo(r.uint8array?"uint8array":"array",f))},s.inherits(u,l),u.prototype.processChunk=function(f){var d=s.transformTo(r.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var m=d;(d=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),d.set(m,this.leftOver.length)}else d=this.leftOver.concat(d);this.leftOver=null}var g=(function(w,x){var b;for((x=x||w.length)>w.length&&(x=w.length),b=x-1;0<=b&&(192&w[b])==128;)b--;return b<0||b===0?x:b+h[w[b]]>x?b:x})(d),y=d;g!==d.length&&(r.uint8array?(y=d.subarray(0,g),this.leftOver=d.subarray(g,d.length)):(y=d.slice(0,g),this.leftOver=d.slice(g,d.length))),this.push({data:i.utf8decode(y),meta:f.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=u,s.inherits(p,l),p.prototype.processChunk=function(f){this.push({data:i.utf8encode(f.data),meta:f.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function h(m){return m}function c(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,g,y){var w=[],x=0,b=m.length;if(b<=y)return String.fromCharCode.apply(null,m);for(;x<b;)g==="array"||g==="nodebuffer"?w.push(String.fromCharCode.apply(null,m.slice(x,Math.min(x+y,b)))):w.push(String.fromCharCode.apply(null,m.subarray(x,Math.min(x+y,b)))),x+=y;return w.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var g=65536,y=i.getTypeOf(m),w=!0;if(y==="uint8array"?w=u.applyCanBeUsed.uint8array:y==="nodebuffer"&&(w=u.applyCanBeUsed.nodebuffer),w)for(;1<g;)try{return u.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return u.stringifyByChar(m)}function f(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=p;var d={};d.string={string:h,array:function(m){return c(m,new Array(m.length))},arraybuffer:function(m){return d.string.uint8array(m).buffer},uint8array:function(m){return c(m,new Uint8Array(m.length))},nodebuffer:function(m){return c(m,a.allocBuffer(m.length))}},d.array={string:p,array:h,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},d.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return f(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:h,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},d.uint8array={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:h,nodebuffer:function(m){return a.newBufferFrom(m)}},d.nodebuffer={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return d.nodebuffer.uint8array(m).buffer},uint8array:function(m){return f(m,new Uint8Array(m.length))},nodebuffer:h},i.transformTo=function(m,g){if(g=g||"",!m)return g;i.checkSupport(m);var y=i.getTypeOf(g);return d[y][m](g)},i.resolve=function(m){for(var g=m.split("/"),y=[],w=0;w<g.length;w++){var x=g[w];x==="."||x===""&&w!==0&&w!==g.length-1||(x===".."?y.pop():y.push(x))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,w="";for(y=0;y<(m||"").length;y++)w+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return w},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,w,x){return l.Promise.resolve(g).then(function(b){return s.blob&&(b instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(b))!==-1)&&typeof FileReader<"u"?new l.Promise(function(_,T){var P=new FileReader;P.onload=function(k){_(k.target.result)},P.onerror=function(k){T(k.target.error)},P.readAsArrayBuffer(b)}):b}).then(function(b){var _=i.getTypeOf(b);return _?(_==="arraybuffer"?b=i.transformTo("uint8array",b):_==="string"&&(x?b=r.decode(b):y&&w!==!0&&(b=(function(T){return c(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(b))),b):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),h=t("./support");function c(u){this.files=[],this.loadOptions=u}c.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(p)+", expected "+r.pretty(u)+")")}},isSignature:function(u,p){var f=this.reader.index;this.reader.setIndex(u);var d=this.reader.readString(4)===p;return this.reader.setIndex(f),d},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),p=h.uint8array?"uint8array":"array",f=r.transformTo(p,u);this.zipComment=this.loadOptions.decodeFileName(f)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,p,f,d=this.zip64EndOfCentralSize-44;0<d;)u=this.reader.readInt(2),p=this.reader.readInt(4),f=this.reader.readData(p),this.zip64ExtensibleData[u]={id:u,length:p,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,p;for(u=0;u<this.files.length;u++)p=this.files[u],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var p=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===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,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var d=p-f;if(0<d)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=d);else if(d<0)throw new Error("Corrupted zip: missing "+Math.abs(d)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),h=t("./utf8"),c=t("./compressions"),u=t("./support");function p(f,d){this.options=f,this.loadOptions=d}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var d,m;if(f.skip(22),this.fileNameLength=f.readInt(2),m=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((d=(function(g){for(var y in c)if(Object.prototype.hasOwnProperty.call(c,y)&&c[y].magic===g)return c[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,d,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var d=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(d),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var d,m,g,y=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<y;)d=f.readInt(2),m=f.readInt(2),g=f.readData(m),this.extraFields[d]={id:d,length:m,value:g};f.setIndex(y)},handleUTF8:function(){var f=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=h.utf8decode(this.fileName),this.fileCommentStr=h.utf8decode(this.fileComment);else{var d=this.findExtraFieldUnicodePath();if(d!==null)this.fileNameStr=d;else{var m=r.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=r.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var d=s(f.value);return d.readInt(1)!==1||l(this.fileName)!==d.readInt(4)?null:h.utf8decode(d.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var d=s(f.value);return d.readInt(1)!==1||l(this.fileComment)!==d.readInt(4)?null:h.utf8decode(d.readData(f.length-5))}return null}},n.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(d,m,g){this.name=d,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),h=t("./compressedObject"),c=t("./stream/GenericWorker");s.prototype={internalStream:function(d){var m=null,g="string";try{if(!d)throw new Error("No output type specified.");var y=(g=d.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var w=!this._dataBinary;w&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!w&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(x){(m=new c("error")).error(x)}return new r(m,g,"")},async:function(d,m){return this.internalStream(d).accumulate(m)},nodeStream:function(d,m){return this.internalStream(d||"nodebuffer").toNodejsStream(m)},_compressWorker:function(d,m){if(this._data instanceof h&&this._data.compression.magic===d.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),h.createWorkerFrom(g,d,m)},_decompressWorker:function(){return this._data instanceof h?this._data.getContentWorker():this._data instanceof c?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)s.prototype[u[f]]=p;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var r,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var h=0,c=new l(d),u=s.document.createTextNode("");c.observe(u,{characterData:!0}),r=function(){u.data=h=++h%2}}else if(s.setImmediate||s.MessageChannel===void 0)r="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){d(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(d,0)};else{var p=new s.MessageChannel;p.port1.onmessage=d,r=function(){p.port2.postMessage(0)}}var f=[];function d(){var m,g;a=!0;for(var y=f.length;y;){for(g=f,f=[],m=-1;++m<y;)g[m]();y=f.length}a=!1}n.exports=function(m){f.push(m)!==1||a||r()}}).call(this,typeof Pn<"u"?Pn: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 u(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,y!==r&&m(this,y)}function p(y,w,x){this.promise=y,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}function f(y,w,x){s(function(){var b;try{b=w(x)}catch(_){return a.reject(y,_)}b===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,b)})}function d(y){var w=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof w=="function")return function(){w.apply(y,arguments)}}function m(y,w){var x=!1;function b(P){x||(x=!0,a.reject(y,P))}function _(P){x||(x=!0,a.resolve(y,P))}var T=g(function(){w(_,b)});T.status==="error"&&b(T.value)}function g(y,w){var x={};try{x.value=y(w),x.status="success"}catch(b){x.status="error",x.value=b}return x}(n.exports=u).prototype.finally=function(y){if(typeof y!="function")return this;var w=this.constructor;return this.then(function(x){return w.resolve(y()).then(function(){return x})},function(x){return w.resolve(y()).then(function(){throw x})})},u.prototype.catch=function(y){return this.then(null,y)},u.prototype.then=function(y,w){if(typeof y!="function"&&this.state===h||typeof w!="function"&&this.state===l)return this;var x=new this.constructor(r);return this.state!==c?f(x,this.state===h?y:w,this.outcome):this.queue.push(new p(x,y,w)),x},p.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){f(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){a.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){f(this.promise,this.onRejected,y)},a.resolve=function(y,w){var x=g(d,w);if(x.status==="error")return a.reject(y,x.value);var b=x.value;if(b)m(y,b);else{y.state=h,y.outcome=w;for(var _=-1,T=y.queue.length;++_<T;)y.queue[_].callFulfilled(w)}return y},a.reject=function(y,w){y.state=l,y.outcome=w;for(var x=-1,b=y.queue.length;++x<b;)y.queue[x].callRejected(w);return y},u.resolve=function(y){return y instanceof this?y:a.resolve(new this(r),y)},u.reject=function(y){var w=new this(r);return a.reject(w,y)},u.all=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=y.length,b=!1;if(!x)return this.resolve([]);for(var _=new Array(x),T=0,P=-1,k=new this(r);++P<x;)D(y[P],P);return k;function D(B,O){w.resolve(B).then(function(C){_[O]=C,++T!==x||b||(b=!0,a.resolve(k,_))},function(C){b||(b=!0,a.reject(k,C))})}},u.race=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=y.length,b=!1;if(!x)return this.resolve([]);for(var _=-1,T=new this(r);++_<x;)P=y[_],w.resolve(P).then(function(k){b||(b=!0,a.resolve(T,k))},function(k){b||(b=!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,u=0,p=-1,f=0,d=8;function m(y){if(!(this instanceof m))return new m(y);this.options=r.assign({level:p,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},y||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var x=s.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(x!==u)throw new Error(l[x]);if(w.header&&s.deflateSetHeader(this.strm,w.header),w.dictionary){var b;if(b=typeof w.dictionary=="string"?a.string2buf(w.dictionary):c.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(x=s.deflateSetDictionary(this.strm,b))!==u)throw new Error(l[x]);this._dict_set=!0}}function g(y,w){var x=new m(w);if(x.push(y,!0),x.err)throw x.msg||l[x.err];return x.result}m.prototype.push=function(y,w){var x,b,_=this.strm,T=this.options.chunkSize;if(this.ended)return!1;b=w===~~w?w:w===!0?4:0,typeof y=="string"?_.input=a.string2buf(y):c.call(y)==="[object ArrayBuffer]"?_.input=new Uint8Array(y):_.input=y,_.next_in=0,_.avail_in=_.input.length;do{if(_.avail_out===0&&(_.output=new r.Buf8(T),_.next_out=0,_.avail_out=T),(x=s.deflate(_,b))!==1&&x!==u)return this.onEnd(x),!(this.ended=!0);_.avail_out!==0&&(_.avail_in!==0||b!==4&&b!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(r.shrinkBuf(_.output,_.next_out))):this.onData(r.shrinkBuf(_.output,_.next_out)))}while((0<_.avail_in||_.avail_out===0)&&x!==1);return b===4?(x=s.deflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===u):b!==2||(this.onEnd(u),!(_.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,w){return(w=w||{}).raw=!0,g(y,w)},i.gzip=function(y,w){return(w=w||{}).gzip=!0,g(y,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var s=t("./zlib/inflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),c=t("./zlib/zstream"),u=t("./zlib/gzheader"),p=Object.prototype.toString;function f(m){if(!(this instanceof f))return new f(m);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(h[y]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function d(m,g){var y=new f(g);if(y.push(m,!0),y.err)throw y.msg||h[y.err];return y.result}f.prototype.push=function(m,g){var y,w,x,b,_,T,P=this.strm,k=this.options.chunkSize,D=this.options.dictionary,B=!1;if(this.ended)return!1;w=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?P.input=a.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?P.input=new Uint8Array(m):P.input=m,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new 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):p.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,y=s.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&B===!0&&(y=l.Z_OK,B=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(x=a.utf8border(P.output,P.next_out),b=P.next_out-x,_=a.buf2string(P.output,x),P.next_out=b,P.avail_out=k-b,b&&r.arraySet(P.output,P.output,x,b,0),this.onData(_)):this.onData(r.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(B=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(w=l.Z_FINISH),w===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=f,i.inflate=d,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,d(m,g)},i.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var h=Array.prototype.slice.call(arguments,1);h.length;){var c=h.shift();if(c){if(typeof c!="object")throw new TypeError(c+"must be non-object");for(var u in c)c.hasOwnProperty(u)&&(l[u]=c[u])}}return l},i.shrinkBuf=function(l,h){return l.length===h?l:l.subarray?l.subarray(0,h):(l.length=h,l)};var r={arraySet:function(l,h,c,u,p){if(h.subarray&&l.subarray)l.set(h.subarray(c,c+u),p);else for(var f=0;f<u;f++)l[p+f]=h[c+f]},flattenChunks:function(l){var h,c,u,p,f,d;for(h=u=0,c=l.length;h<c;h++)u+=l[h].length;for(d=new Uint8Array(u),h=p=0,c=l.length;h<c;h++)f=l[h],d.set(f,p),p+=f.length;return d}},a={arraySet:function(l,h,c,u,p){for(var f=0;f<u;f++)l[p+f]=h[c+f]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,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(u,p){if(p<65537&&(u.subarray&&a||!u.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(u,p));for(var f="",d=0;d<p;d++)f+=String.fromCharCode(u[d]);return f}l[254]=l[254]=1,i.string2buf=function(u){var p,f,d,m,g,y=u.length,w=0;for(m=0;m<y;m++)(64512&(f=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(d-56320),m++),w+=f<128?1:f<2048?2:f<65536?3:4;for(p=new s.Buf8(w),m=g=0;g<w;m++)(64512&(f=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(d-56320),m++),f<128?p[g++]=f:(f<2048?p[g++]=192|f>>>6:(f<65536?p[g++]=224|f>>>12:(p[g++]=240|f>>>18,p[g++]=128|f>>>12&63),p[g++]=128|f>>>6&63),p[g++]=128|63&f);return p},i.buf2binstring=function(u){return c(u,u.length)},i.binstring2buf=function(u){for(var p=new s.Buf8(u.length),f=0,d=p.length;f<d;f++)p[f]=u.charCodeAt(f);return p},i.buf2string=function(u,p){var f,d,m,g,y=p||u.length,w=new Array(2*y);for(f=d=0;f<y;)if((m=u[f++])<128)w[d++]=m;else if(4<(g=l[m]))w[d++]=65533,f+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&f<y;)m=m<<6|63&u[f++],g--;1<g?w[d++]=65533:m<65536?w[d++]=m:(m-=65536,w[d++]=55296|m>>10&1023,w[d++]=56320|1023&m)}return c(w,d)},i.utf8border=function(u,p){var f;for((p=p||u.length)>u.length&&(p=u.length),f=p-1;0<=f&&(192&u[f])==128;)f--;return f<0||f===0?p:f+l[u[f]]>p?f:p}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,r,a,l){for(var h=65535&s|0,c=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;c=c+(h=h+r[l++]|0)|0,--u;);h%=65521,c%=65521}return h|c<<16|0}},{}],44:[function(t,n,i){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,n,i){var s=(function(){for(var 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,u=h+l;r^=-1;for(var p=h;p<u;p++)r=r>>>8^c[255&(r^a[p])];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"),u=0,p=4,f=0,d=-2,m=-1,g=4,y=2,w=8,x=9,b=286,_=30,T=19,P=2*b+1,k=15,D=3,B=258,O=B+D+1,C=42,I=113,v=1,z=2,q=3,G=4;function ee(M,W){return M.msg=c[W],W}function X(M){return(M<<1)-(4<M?9:0)}function Q(M){for(var W=M.length;0<=--W;)M[W]=0}function R(M){var W=M.state,j=W.pending;j>M.avail_out&&(j=M.avail_out),j!==0&&(r.arraySet(M.output,W.pending_buf,W.pending_out,j,M.next_out),M.next_out+=j,W.pending_out+=j,M.total_out+=j,M.avail_out-=j,W.pending-=j,W.pending===0&&(W.pending_out=0))}function F(M,W){a._tr_flush_block(M,0<=M.block_start?M.block_start:-1,M.strstart-M.block_start,W),M.block_start=M.strstart,R(M.strm)}function te(M,W){M.pending_buf[M.pending++]=W}function J(M,W){M.pending_buf[M.pending++]=W>>>8&255,M.pending_buf[M.pending++]=255&W}function Y(M,W){var j,L,E=M.max_chain_length,N=M.strstart,Z=M.prev_length,K=M.nice_match,U=M.strstart>M.w_size-O?M.strstart-(M.w_size-O):0,$=M.window,ne=M.w_mask,H=M.prev,ie=M.strstart+B,ce=$[N+Z-1],ae=$[N+Z];M.prev_length>=M.good_match&&(E>>=2),K>M.lookahead&&(K=M.lookahead);do if($[(j=W)+Z]===ae&&$[j+Z-1]===ce&&$[j]===$[N]&&$[++j]===$[N+1]){N+=2,j++;do;while($[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&N<ie);if(L=B-(ie-N),N=ie-B,Z<L){if(M.match_start=W,K<=(Z=L))break;ce=$[N+Z-1],ae=$[N+Z]}}while((W=H[W&ne])>U&&--E!=0);return Z<=M.lookahead?Z:M.lookahead}function de(M){var W,j,L,E,N,Z,K,U,$,ne,H=M.w_size;do{if(E=M.window_size-M.lookahead-M.strstart,M.strstart>=H+(H-O)){for(r.arraySet(M.window,M.window,H,H,0),M.match_start-=H,M.strstart-=H,M.block_start-=H,W=j=M.hash_size;L=M.head[--W],M.head[W]=H<=L?L-H:0,--j;);for(W=j=H;L=M.prev[--W],M.prev[W]=H<=L?L-H:0,--j;);E+=H}if(M.strm.avail_in===0)break;if(Z=M.strm,K=M.window,U=M.strstart+M.lookahead,$=E,ne=void 0,ne=Z.avail_in,$<ne&&(ne=$),j=ne===0?0:(Z.avail_in-=ne,r.arraySet(K,Z.input,Z.next_in,ne,U),Z.state.wrap===1?Z.adler=l(Z.adler,K,ne,U):Z.state.wrap===2&&(Z.adler=h(Z.adler,K,ne,U)),Z.next_in+=ne,Z.total_in+=ne,ne),M.lookahead+=j,M.lookahead+M.insert>=D)for(N=M.strstart-M.insert,M.ins_h=M.window[N],M.ins_h=(M.ins_h<<M.hash_shift^M.window[N+1])&M.hash_mask;M.insert&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[N+D-1])&M.hash_mask,M.prev[N&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=N,N++,M.insert--,!(M.lookahead+M.insert<D)););}while(M.lookahead<O&&M.strm.avail_in!==0)}function fe(M,W){for(var j,L;;){if(M.lookahead<O){if(de(M),M.lookahead<O&&W===u)return v;if(M.lookahead===0)break}if(j=0,M.lookahead>=D&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+D-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),j!==0&&M.strstart-j<=M.w_size-O&&(M.match_length=Y(M,j)),M.match_length>=D)if(L=a._tr_tally(M,M.strstart-M.match_start,M.match_length-D),M.lookahead-=M.match_length,M.match_length<=M.max_lazy_match&&M.lookahead>=D){for(M.match_length--;M.strstart++,M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+D-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart,--M.match_length!=0;);M.strstart++}else M.strstart+=M.match_length,M.match_length=0,M.ins_h=M.window[M.strstart],M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+1])&M.hash_mask;else L=a._tr_tally(M,0,M.window[M.strstart]),M.lookahead--,M.strstart++;if(L&&(F(M,!1),M.strm.avail_out===0))return v}return M.insert=M.strstart<D-1?M.strstart:D-1,W===p?(F(M,!0),M.strm.avail_out===0?q:G):M.last_lit&&(F(M,!1),M.strm.avail_out===0)?v:z}function se(M,W){for(var j,L,E;;){if(M.lookahead<O){if(de(M),M.lookahead<O&&W===u)return v;if(M.lookahead===0)break}if(j=0,M.lookahead>=D&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+D-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),M.prev_length=M.match_length,M.prev_match=M.match_start,M.match_length=D-1,j!==0&&M.prev_length<M.max_lazy_match&&M.strstart-j<=M.w_size-O&&(M.match_length=Y(M,j),M.match_length<=5&&(M.strategy===1||M.match_length===D&&4096<M.strstart-M.match_start)&&(M.match_length=D-1)),M.prev_length>=D&&M.match_length<=M.prev_length){for(E=M.strstart+M.lookahead-D,L=a._tr_tally(M,M.strstart-1-M.prev_match,M.prev_length-D),M.lookahead-=M.prev_length-1,M.prev_length-=2;++M.strstart<=E&&(M.ins_h=(M.ins_h<<M.hash_shift^M.window[M.strstart+D-1])&M.hash_mask,j=M.prev[M.strstart&M.w_mask]=M.head[M.ins_h],M.head[M.ins_h]=M.strstart),--M.prev_length!=0;);if(M.match_available=0,M.match_length=D-1,M.strstart++,L&&(F(M,!1),M.strm.avail_out===0))return v}else if(M.match_available){if((L=a._tr_tally(M,0,M.window[M.strstart-1]))&&F(M,!1),M.strstart++,M.lookahead--,M.strm.avail_out===0)return v}else M.match_available=1,M.strstart++,M.lookahead--}return M.match_available&&(L=a._tr_tally(M,0,M.window[M.strstart-1]),M.match_available=0),M.insert=M.strstart<D-1?M.strstart:D-1,W===p?(F(M,!0),M.strm.avail_out===0?q:G):M.last_lit&&(F(M,!1),M.strm.avail_out===0)?v:z}function oe(M,W,j,L,E){this.good_length=M,this.max_lazy=W,this.nice_length=j,this.max_chain=L,this.func=E}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(2*P),this.dyn_dtree=new r.Buf16(2*(2*_+1)),this.bl_tree=new r.Buf16(2*(2*T+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(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*b+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*b+1),Q(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pe(M){var W;return M&&M.state?(M.total_in=M.total_out=0,M.data_type=y,(W=M.state).pending=0,W.pending_out=0,W.wrap<0&&(W.wrap=-W.wrap),W.status=W.wrap?C:I,M.adler=W.wrap===2?0:1,W.last_flush=u,a._tr_init(W),f):ee(M,d)}function Ae(M){var W=pe(M);return W===f&&(function(j){j.window_size=2*j.w_size,Q(j.head),j.max_lazy_match=s[j.level].max_lazy,j.good_match=s[j.level].good_length,j.nice_match=s[j.level].nice_length,j.max_chain_length=s[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=D-1,j.match_available=0,j.ins_h=0})(M.state),W}function Le(M,W,j,L,E,N){if(!M)return d;var Z=1;if(W===m&&(W=6),L<0?(Z=0,L=-L):15<L&&(Z=2,L-=16),E<1||x<E||j!==w||L<8||15<L||W<0||9<W||N<0||g<N)return ee(M,d);L===8&&(L=9);var K=new he;return(M.state=K).strm=M,K.wrap=Z,K.gzhead=null,K.w_bits=L,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=E+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+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<<E+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=W,K.strategy=N,K.method=j,Ae(M)}s=[new oe(0,0,0,0,function(M,W){var j=65535;for(j>M.pending_buf_size-5&&(j=M.pending_buf_size-5);;){if(M.lookahead<=1){if(de(M),M.lookahead===0&&W===u)return v;if(M.lookahead===0)break}M.strstart+=M.lookahead,M.lookahead=0;var L=M.block_start+j;if((M.strstart===0||M.strstart>=L)&&(M.lookahead=M.strstart-L,M.strstart=L,F(M,!1),M.strm.avail_out===0)||M.strstart-M.block_start>=M.w_size-O&&(F(M,!1),M.strm.avail_out===0))return v}return M.insert=0,W===p?(F(M,!0),M.strm.avail_out===0?q:G):(M.strstart>M.block_start&&(F(M,!1),M.strm.avail_out),v)}),new oe(4,4,8,4,fe),new oe(4,5,16,8,fe),new oe(4,6,32,32,fe),new oe(4,4,16,16,se),new oe(8,16,32,32,se),new oe(8,16,128,128,se),new oe(8,32,128,256,se),new oe(32,128,258,1024,se),new oe(32,258,258,4096,se)],i.deflateInit=function(M,W){return Le(M,W,w,15,8,0)},i.deflateInit2=Le,i.deflateReset=Ae,i.deflateResetKeep=pe,i.deflateSetHeader=function(M,W){return M&&M.state?M.state.wrap!==2?d:(M.state.gzhead=W,f):d},i.deflate=function(M,W){var j,L,E,N;if(!M||!M.state||5<W||W<0)return M?ee(M,d):d;if(L=M.state,!M.output||!M.input&&M.avail_in!==0||L.status===666&&W!==p)return ee(M,M.avail_out===0?-5:d);if(L.strm=M,j=L.last_flush,L.last_flush=W,L.status===C)if(L.wrap===2)M.adler=0,te(L,31),te(L,139),te(L,8),L.gzhead?(te(L,(L.gzhead.text?1:0)+(L.gzhead.hcrc?2:0)+(L.gzhead.extra?4:0)+(L.gzhead.name?8:0)+(L.gzhead.comment?16:0)),te(L,255&L.gzhead.time),te(L,L.gzhead.time>>8&255),te(L,L.gzhead.time>>16&255),te(L,L.gzhead.time>>24&255),te(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),te(L,255&L.gzhead.os),L.gzhead.extra&&L.gzhead.extra.length&&(te(L,255&L.gzhead.extra.length),te(L,L.gzhead.extra.length>>8&255)),L.gzhead.hcrc&&(M.adler=h(M.adler,L.pending_buf,L.pending,0)),L.gzindex=0,L.status=69):(te(L,0),te(L,0),te(L,0),te(L,0),te(L,0),te(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),te(L,3),L.status=I);else{var Z=w+(L.w_bits-8<<4)<<8;Z|=(2<=L.strategy||L.level<2?0:L.level<6?1:L.level===6?2:3)<<6,L.strstart!==0&&(Z|=32),Z+=31-Z%31,L.status=I,J(L,Z),L.strstart!==0&&(J(L,M.adler>>>16),J(L,65535&M.adler)),M.adler=1}if(L.status===69)if(L.gzhead.extra){for(E=L.pending;L.gzindex<(65535&L.gzhead.extra.length)&&(L.pending!==L.pending_buf_size||(L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),R(M),E=L.pending,L.pending!==L.pending_buf_size));)te(L,255&L.gzhead.extra[L.gzindex]),L.gzindex++;L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),L.gzindex===L.gzhead.extra.length&&(L.gzindex=0,L.status=73)}else L.status=73;if(L.status===73)if(L.gzhead.name){E=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),R(M),E=L.pending,L.pending===L.pending_buf_size)){N=1;break}N=L.gzindex<L.gzhead.name.length?255&L.gzhead.name.charCodeAt(L.gzindex++):0,te(L,N)}while(N!==0);L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),N===0&&(L.gzindex=0,L.status=91)}else L.status=91;if(L.status===91)if(L.gzhead.comment){E=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),R(M),E=L.pending,L.pending===L.pending_buf_size)){N=1;break}N=L.gzindex<L.gzhead.comment.length?255&L.gzhead.comment.charCodeAt(L.gzindex++):0,te(L,N)}while(N!==0);L.gzhead.hcrc&&L.pending>E&&(M.adler=h(M.adler,L.pending_buf,L.pending-E,E)),N===0&&(L.status=103)}else L.status=103;if(L.status===103&&(L.gzhead.hcrc?(L.pending+2>L.pending_buf_size&&R(M),L.pending+2<=L.pending_buf_size&&(te(L,255&M.adler),te(L,M.adler>>8&255),M.adler=0,L.status=I)):L.status=I),L.pending!==0){if(R(M),M.avail_out===0)return L.last_flush=-1,f}else if(M.avail_in===0&&X(W)<=X(j)&&W!==p)return ee(M,-5);if(L.status===666&&M.avail_in!==0)return ee(M,-5);if(M.avail_in!==0||L.lookahead!==0||W!==u&&L.status!==666){var K=L.strategy===2?(function(U,$){for(var ne;;){if(U.lookahead===0&&(de(U),U.lookahead===0)){if($===u)return v;break}if(U.match_length=0,ne=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,ne&&(F(U,!1),U.strm.avail_out===0))return v}return U.insert=0,$===p?(F(U,!0),U.strm.avail_out===0?q:G):U.last_lit&&(F(U,!1),U.strm.avail_out===0)?v:z})(L,W):L.strategy===3?(function(U,$){for(var ne,H,ie,ce,ae=U.window;;){if(U.lookahead<=B){if(de(U),U.lookahead<=B&&$===u)return v;if(U.lookahead===0)break}if(U.match_length=0,U.lookahead>=D&&0<U.strstart&&(H=ae[ie=U.strstart-1])===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]){ce=U.strstart+B;do;while(H===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]&&H===ae[++ie]&&ie<ce);U.match_length=B-(ce-ie),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=D?(ne=a._tr_tally(U,1,U.match_length-D),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(ne=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),ne&&(F(U,!1),U.strm.avail_out===0))return v}return U.insert=0,$===p?(F(U,!0),U.strm.avail_out===0?q:G):U.last_lit&&(F(U,!1),U.strm.avail_out===0)?v:z})(L,W):s[L.level].func(L,W);if(K!==q&&K!==G||(L.status=666),K===v||K===q)return M.avail_out===0&&(L.last_flush=-1),f;if(K===z&&(W===1?a._tr_align(L):W!==5&&(a._tr_stored_block(L,0,0,!1),W===3&&(Q(L.head),L.lookahead===0&&(L.strstart=0,L.block_start=0,L.insert=0))),R(M),M.avail_out===0))return L.last_flush=-1,f}return W!==p?f:L.wrap<=0?1:(L.wrap===2?(te(L,255&M.adler),te(L,M.adler>>8&255),te(L,M.adler>>16&255),te(L,M.adler>>24&255),te(L,255&M.total_in),te(L,M.total_in>>8&255),te(L,M.total_in>>16&255),te(L,M.total_in>>24&255)):(J(L,M.adler>>>16),J(L,65535&M.adler)),R(M),0<L.wrap&&(L.wrap=-L.wrap),L.pending!==0?f:1)},i.deflateEnd=function(M){var W;return M&&M.state?(W=M.state.status)!==C&&W!==69&&W!==73&&W!==91&&W!==103&&W!==I&&W!==666?ee(M,d):(M.state=null,W===I?ee(M,-3):f):d},i.deflateSetDictionary=function(M,W){var j,L,E,N,Z,K,U,$,ne=W.length;if(!M||!M.state||(N=(j=M.state).wrap)===2||N===1&&j.status!==C||j.lookahead)return d;for(N===1&&(M.adler=l(M.adler,W,ne,0)),j.wrap=0,ne>=j.w_size&&(N===0&&(Q(j.head),j.strstart=0,j.block_start=0,j.insert=0),$=new r.Buf8(j.w_size),r.arraySet($,W,ne-j.w_size,j.w_size,0),W=$,ne=j.w_size),Z=M.avail_in,K=M.next_in,U=M.input,M.avail_in=ne,M.next_in=0,M.input=W,de(j);j.lookahead>=D;){for(L=j.strstart,E=j.lookahead-(D-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[L+D-1])&j.hash_mask,j.prev[L&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=L,L++,--E;);j.strstart=L,j.lookahead=D-1,de(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=D-1,j.match_available=0,M.next_in=K,M.input=U,M.avail_in=Z,j.wrap=N,f},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,n,i){n.exports=function(s,r){var a,l,h,c,u,p,f,d,m,g,y,w,x,b,_,T,P,k,D,B,O,C,I,v,z;a=s.state,l=s.next_in,v=s.input,h=l+(s.avail_in-5),c=s.next_out,z=s.output,u=c-(r-s.avail_out),p=c+(s.avail_out-257),f=a.dmax,d=a.wsize,m=a.whave,g=a.wnext,y=a.window,w=a.hold,x=a.bits,b=a.lencode,_=a.distcode,T=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{x<15&&(w+=v[l++]<<x,x+=8,w+=v[l++]<<x,x+=8),k=b[w&T];t:for(;;){if(w>>>=D=k>>>24,x-=D,(D=k>>>16&255)===0)z[c++]=65535&k;else{if(!(16&D)){if((64&D)==0){k=b[(65535&k)+(w&(1<<D)-1)];continue t}if(32&D){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}B=65535&k,(D&=15)&&(x<D&&(w+=v[l++]<<x,x+=8),B+=w&(1<<D)-1,w>>>=D,x-=D),x<15&&(w+=v[l++]<<x,x+=8,w+=v[l++]<<x,x+=8),k=_[w&P];n:for(;;){if(w>>>=D=k>>>24,x-=D,!(16&(D=k>>>16&255))){if((64&D)==0){k=_[(65535&k)+(w&(1<<D)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,x<(D&=15)&&(w+=v[l++]<<x,(x+=8)<D&&(w+=v[l++]<<x,x+=8)),f<(O+=w&(1<<D)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(w>>>=D,x-=D,(D=c-u)<O){if(m<(D=O-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=y,(C=0)===g){if(C+=d-D,D<B){for(B-=D;z[c++]=y[C++],--D;);C=c-O,I=z}}else if(g<D){if(C+=d+g-D,(D-=g)<B){for(B-=D;z[c++]=y[C++],--D;);if(C=0,g<B){for(B-=D=g;z[c++]=y[C++],--D;);C=c-O,I=z}}}else if(C+=g-D,D<B){for(B-=D;z[c++]=y[C++],--D;);C=c-O,I=z}for(;2<B;)z[c++]=I[C++],z[c++]=I[C++],z[c++]=I[C++],B-=3;B&&(z[c++]=I[C++],1<B&&(z[c++]=I[C++]))}else{for(C=c-O;z[c++]=z[C++],z[c++]=z[C++],z[c++]=z[C++],2<(B-=3););B&&(z[c++]=z[C++],1<B&&(z[c++]=z[C++]))}break}}break}}while(l<h&&c<p);l-=B=x>>3,w&=(1<<(x-=B<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l<h?h-l+5:5-(l-h),s.avail_out=c<p?p-c+257:257-(c-p),a.hold=w,a.bits=x}},{}],49:[function(t,n,i){var s=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),h=t("./inftrees"),c=1,u=2,p=0,f=-2,d=1,m=852,g=592;function y(C){return(C>>>24&255)+(C>>>8&65280)+((65280&C)<<8)+((255&C)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x(C){var I;return C&&C.state?(I=C.state,C.total_in=C.total_out=I.total=0,C.msg="",I.wrap&&(C.adler=1&I.wrap),I.mode=d,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(m),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,p):f}function b(C){var I;return C&&C.state?((I=C.state).wsize=0,I.whave=0,I.wnext=0,x(C)):f}function _(C,I){var v,z;return C&&C.state?(z=C.state,I<0?(v=0,I=-I):(v=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?f:(z.window!==null&&z.wbits!==I&&(z.window=null),z.wrap=v,z.wbits=I,b(C))):f}function T(C,I){var v,z;return C?(z=new w,(C.state=z).window=null,(v=_(C,I))!==p&&(C.state=null),v):f}var P,k,D=!0;function B(C){if(D){var I;for(P=new s.Buf32(512),k=new s.Buf32(32),I=0;I<144;)C.lens[I++]=8;for(;I<256;)C.lens[I++]=9;for(;I<280;)C.lens[I++]=7;for(;I<288;)C.lens[I++]=8;for(h(c,C.lens,0,288,P,0,C.work,{bits:9}),I=0;I<32;)C.lens[I++]=5;h(u,C.lens,0,32,k,0,C.work,{bits:5}),D=!1}C.lencode=P,C.lenbits=9,C.distcode=k,C.distbits=5}function O(C,I,v,z){var q,G=C.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new s.Buf8(G.wsize)),z>=G.wsize?(s.arraySet(G.window,I,v-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(z<(q=G.wsize-G.wnext)&&(q=z),s.arraySet(G.window,I,v-z,q,G.wnext),(z-=q)?(s.arraySet(G.window,I,v-z,z,0),G.wnext=z,G.whave=G.wsize):(G.wnext+=q,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=q))),0}i.inflateReset=b,i.inflateReset2=_,i.inflateResetKeep=x,i.inflateInit=function(C){return T(C,15)},i.inflateInit2=T,i.inflate=function(C,I){var v,z,q,G,ee,X,Q,R,F,te,J,Y,de,fe,se,oe,he,pe,Ae,Le,M,W,j,L,E=0,N=new s.Buf8(4),Z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!C||!C.state||!C.output||!C.input&&C.avail_in!==0)return f;(v=C.state).mode===12&&(v.mode=13),ee=C.next_out,q=C.output,Q=C.avail_out,G=C.next_in,z=C.input,X=C.avail_in,R=v.hold,F=v.bits,te=X,J=Q,W=p;e:for(;;)switch(v.mode){case d:if(v.wrap===0){v.mode=13;break}for(;F<16;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(2&v.wrap&&R===35615){N[v.check=0]=255&R,N[1]=R>>>8&255,v.check=a(v.check,N,2,0),F=R=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&R)<<8)+(R>>8))%31){C.msg="incorrect header check",v.mode=30;break}if((15&R)!=8){C.msg="unknown compression method",v.mode=30;break}if(F-=4,M=8+(15&(R>>>=4)),v.wbits===0)v.wbits=M;else if(M>v.wbits){C.msg="invalid window size",v.mode=30;break}v.dmax=1<<M,C.adler=v.check=1,v.mode=512&R?10:12,F=R=0;break;case 2:for(;F<16;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(v.flags=R,(255&v.flags)!=8){C.msg="unknown compression method",v.mode=30;break}if(57344&v.flags){C.msg="unknown header flags set",v.mode=30;break}v.head&&(v.head.text=R>>8&1),512&v.flags&&(N[0]=255&R,N[1]=R>>>8&255,v.check=a(v.check,N,2,0)),F=R=0,v.mode=3;case 3:for(;F<32;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}v.head&&(v.head.time=R),512&v.flags&&(N[0]=255&R,N[1]=R>>>8&255,N[2]=R>>>16&255,N[3]=R>>>24&255,v.check=a(v.check,N,4,0)),F=R=0,v.mode=4;case 4:for(;F<16;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}v.head&&(v.head.xflags=255&R,v.head.os=R>>8),512&v.flags&&(N[0]=255&R,N[1]=R>>>8&255,v.check=a(v.check,N,2,0)),F=R=0,v.mode=5;case 5:if(1024&v.flags){for(;F<16;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}v.length=R,v.head&&(v.head.extra_len=R),512&v.flags&&(N[0]=255&R,N[1]=R>>>8&255,v.check=a(v.check,N,2,0)),F=R=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(X<(Y=v.length)&&(Y=X),Y&&(v.head&&(M=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,z,G,Y,M)),512&v.flags&&(v.check=a(v.check,z,Y,G)),X-=Y,G+=Y,v.length-=Y),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(X===0)break e;for(Y=0;M=z[G+Y++],v.head&&M&&v.length<65536&&(v.head.name+=String.fromCharCode(M)),M&&Y<X;);if(512&v.flags&&(v.check=a(v.check,z,Y,G)),X-=Y,G+=Y,M)break e}else v.head&&(v.head.name=null);v.length=0,v.mode=8;case 8:if(4096&v.flags){if(X===0)break e;for(Y=0;M=z[G+Y++],v.head&&M&&v.length<65536&&(v.head.comment+=String.fromCharCode(M)),M&&Y<X;);if(512&v.flags&&(v.check=a(v.check,z,Y,G)),X-=Y,G+=Y,M)break e}else v.head&&(v.head.comment=null);v.mode=9;case 9:if(512&v.flags){for(;F<16;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(R!==(65535&v.check)){C.msg="header crc mismatch",v.mode=30;break}F=R=0}v.head&&(v.head.hcrc=v.flags>>9&1,v.head.done=!0),C.adler=v.check=0,v.mode=12;break;case 10:for(;F<32;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}C.adler=v.check=y(R),F=R=0,v.mode=11;case 11:if(v.havedict===0)return C.next_out=ee,C.avail_out=Q,C.next_in=G,C.avail_in=X,v.hold=R,v.bits=F,2;C.adler=v.check=1,v.mode=12;case 12:if(I===5||I===6)break e;case 13:if(v.last){R>>>=7&F,F-=7&F,v.mode=27;break}for(;F<3;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}switch(v.last=1&R,F-=1,3&(R>>>=1)){case 0:v.mode=14;break;case 1:if(B(v),v.mode=20,I!==6)break;R>>>=2,F-=2;break e;case 2:v.mode=17;break;case 3:C.msg="invalid block type",v.mode=30}R>>>=2,F-=2;break;case 14:for(R>>>=7&F,F-=7&F;F<32;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if((65535&R)!=(R>>>16^65535)){C.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&R,F=R=0,v.mode=15,I===6)break e;case 15:v.mode=16;case 16:if(Y=v.length){if(X<Y&&(Y=X),Q<Y&&(Y=Q),Y===0)break e;s.arraySet(q,z,G,Y,ee),X-=Y,G+=Y,Q-=Y,ee+=Y,v.length-=Y;break}v.mode=12;break;case 17:for(;F<14;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(v.nlen=257+(31&R),R>>>=5,F-=5,v.ndist=1+(31&R),R>>>=5,F-=5,v.ncode=4+(15&R),R>>>=4,F-=4,286<v.nlen||30<v.ndist){C.msg="too many length or distance symbols",v.mode=30;break}v.have=0,v.mode=18;case 18:for(;v.have<v.ncode;){for(;F<3;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}v.lens[Z[v.have++]]=7&R,R>>>=3,F-=3}for(;v.have<19;)v.lens[Z[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,j={bits:v.lenbits},W=h(0,v.lens,0,19,v.lencode,0,v.work,j),v.lenbits=j.bits,W){C.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have<v.nlen+v.ndist;){for(;oe=(E=v.lencode[R&(1<<v.lenbits)-1])>>>16&255,he=65535&E,!((se=E>>>24)<=F);){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(he<16)R>>>=se,F-=se,v.lens[v.have++]=he;else{if(he===16){for(L=se+2;F<L;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(R>>>=se,F-=se,v.have===0){C.msg="invalid bit length repeat",v.mode=30;break}M=v.lens[v.have-1],Y=3+(3&R),R>>>=2,F-=2}else if(he===17){for(L=se+3;F<L;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}F-=se,M=0,Y=3+(7&(R>>>=se)),R>>>=3,F-=3}else{for(L=se+7;F<L;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}F-=se,M=0,Y=11+(127&(R>>>=se)),R>>>=7,F-=7}if(v.have+Y>v.nlen+v.ndist){C.msg="invalid bit length repeat",v.mode=30;break}for(;Y--;)v.lens[v.have++]=M}}if(v.mode===30)break;if(v.lens[256]===0){C.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,j={bits:v.lenbits},W=h(c,v.lens,0,v.nlen,v.lencode,0,v.work,j),v.lenbits=j.bits,W){C.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,j={bits:v.distbits},W=h(u,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,j),v.distbits=j.bits,W){C.msg="invalid distances set",v.mode=30;break}if(v.mode=20,I===6)break e;case 20:v.mode=21;case 21:if(6<=X&&258<=Q){C.next_out=ee,C.avail_out=Q,C.next_in=G,C.avail_in=X,v.hold=R,v.bits=F,l(C,J),ee=C.next_out,q=C.output,Q=C.avail_out,G=C.next_in,z=C.input,X=C.avail_in,R=v.hold,F=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;oe=(E=v.lencode[R&(1<<v.lenbits)-1])>>>16&255,he=65535&E,!((se=E>>>24)<=F);){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(oe&&(240&oe)==0){for(pe=se,Ae=oe,Le=he;oe=(E=v.lencode[Le+((R&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&E,!(pe+(se=E>>>24)<=F);){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}R>>>=pe,F-=pe,v.back+=pe}if(R>>>=se,F-=se,v.back+=se,v.length=he,oe===0){v.mode=26;break}if(32&oe){v.back=-1,v.mode=12;break}if(64&oe){C.msg="invalid literal/length code",v.mode=30;break}v.extra=15&oe,v.mode=22;case 22:if(v.extra){for(L=v.extra;F<L;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}v.length+=R&(1<<v.extra)-1,R>>>=v.extra,F-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;oe=(E=v.distcode[R&(1<<v.distbits)-1])>>>16&255,he=65535&E,!((se=E>>>24)<=F);){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if((240&oe)==0){for(pe=se,Ae=oe,Le=he;oe=(E=v.distcode[Le+((R&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&E,!(pe+(se=E>>>24)<=F);){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}R>>>=pe,F-=pe,v.back+=pe}if(R>>>=se,F-=se,v.back+=se,64&oe){C.msg="invalid distance code",v.mode=30;break}v.offset=he,v.extra=15&oe,v.mode=24;case 24:if(v.extra){for(L=v.extra;F<L;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}v.offset+=R&(1<<v.extra)-1,R>>>=v.extra,F-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){C.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(Q===0)break e;if(Y=J-Q,v.offset>Y){if((Y=v.offset-Y)>v.whave&&v.sane){C.msg="invalid distance too far back",v.mode=30;break}de=Y>v.wnext?(Y-=v.wnext,v.wsize-Y):v.wnext-Y,Y>v.length&&(Y=v.length),fe=v.window}else fe=q,de=ee-v.offset,Y=v.length;for(Q<Y&&(Y=Q),Q-=Y,v.length-=Y;q[ee++]=fe[de++],--Y;);v.length===0&&(v.mode=21);break;case 26:if(Q===0)break e;q[ee++]=v.length,Q--,v.mode=21;break;case 27:if(v.wrap){for(;F<32;){if(X===0)break e;X--,R|=z[G++]<<F,F+=8}if(J-=Q,C.total_out+=J,v.total+=J,J&&(C.adler=v.check=v.flags?a(v.check,q,J,ee-J):r(v.check,q,J,ee-J)),J=Q,(v.flags?R:y(R))!==v.check){C.msg="incorrect data check",v.mode=30;break}F=R=0}v.mode=28;case 28:if(v.wrap&&v.flags){for(;F<32;){if(X===0)break e;X--,R+=z[G++]<<F,F+=8}if(R!==(4294967295&v.total)){C.msg="incorrect length check",v.mode=30;break}F=R=0}v.mode=29;case 29:W=1;break e;case 30:W=-3;break e;case 31:return-4;case 32:default:return f}return C.next_out=ee,C.avail_out=Q,C.next_in=G,C.avail_in=X,v.hold=R,v.bits=F,(v.wsize||J!==C.avail_out&&v.mode<30&&(v.mode<27||I!==4))&&O(C,C.output,C.next_out,J-C.avail_out)?(v.mode=31,-4):(te-=C.avail_in,J-=C.avail_out,C.total_in+=te,C.total_out+=J,v.total+=J,v.wrap&&J&&(C.adler=v.check=v.flags?a(v.check,q,J,C.next_out-J):r(v.check,q,J,C.next_out-J)),C.data_type=v.bits+(v.last?64:0)+(v.mode===12?128:0)+(v.mode===20||v.mode===15?256:0),(te==0&&J===0||I===4)&&W===p&&(W=-5),W)},i.inflateEnd=function(C){if(!C||!C.state)return f;var I=C.state;return I.window&&(I.window=null),C.state=null,p},i.inflateGetHeader=function(C,I){var v;return C&&C.state?(2&(v=C.state).wrap)==0?f:((v.head=I).done=!1,p):f},i.inflateSetDictionary=function(C,I){var v,z=I.length;return C&&C.state?(v=C.state).wrap!==0&&v.mode!==11?f:v.mode===11&&r(1,I,z,0)!==v.check?-3:O(C,I,z,z)?(v.mode=31,-4):(v.havedict=1,p):f},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var s=t("../utils/common"),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,u,p,f,d,m,g,y){var w,x,b,_,T,P,k,D,B,O=y.bits,C=0,I=0,v=0,z=0,q=0,G=0,ee=0,X=0,Q=0,R=0,F=null,te=0,J=new s.Buf16(16),Y=new s.Buf16(16),de=null,fe=0;for(C=0;C<=15;C++)J[C]=0;for(I=0;I<f;I++)J[u[p+I]]++;for(q=O,z=15;1<=z&&J[z]===0;z--);if(z<q&&(q=z),z===0)return d[m++]=20971520,d[m++]=20971520,y.bits=1,0;for(v=1;v<z&&J[v]===0;v++);for(q<v&&(q=v),C=X=1;C<=15;C++)if(X<<=1,(X-=J[C])<0)return-1;if(0<X&&(c===0||z!==1))return-1;for(Y[1]=0,C=1;C<15;C++)Y[C+1]=Y[C]+J[C];for(I=0;I<f;I++)u[p+I]!==0&&(g[Y[u[p+I]]++]=I);if(P=c===0?(F=de=g,19):c===1?(F=r,te-=257,de=a,fe-=257,256):(F=l,de=h,-1),C=v,T=m,ee=I=R=0,b=-1,_=(Q=1<<(G=q))-1,c===1&&852<Q||c===2&&592<Q)return 1;for(;;){for(k=C-ee,B=g[I]<P?(D=0,g[I]):g[I]>P?(D=de[fe+g[I]],F[te+g[I]]):(D=96,0),w=1<<C-ee,v=x=1<<G;d[T+(R>>ee)+(x-=w)]=k<<24|D<<16|B|0,x!==0;);for(w=1<<C-1;R&w;)w>>=1;if(w!==0?(R&=w-1,R+=w):R=0,I++,--J[C]==0){if(C===z)break;C=u[p+g[I]]}if(q<C&&(R&_)!==b){for(ee===0&&(ee=q),T+=v,X=1<<(G=C-ee);G+ee<z&&!((X-=J[G+ee])<=0);)G++,X<<=1;if(Q+=1<<G,c===1&&852<Q||c===2&&592<Q)return 1;d[b=R&_]=q<<24|G<<16|T-m|0}}return R!==0&&(d[T+R]=C-ee<<24|64<<16|0),y.bits=q,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(E){for(var N=E.length;0<=--N;)E[N]=0}var h=0,c=29,u=256,p=u+1+c,f=30,d=19,m=2*p+1,g=15,y=16,w=7,x=256,b=16,_=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],B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(p+2));l(O);var C=new Array(2*f);l(C);var I=new Array(512);l(I);var v=new Array(256);l(v);var z=new Array(c);l(z);var q,G,ee,X=new Array(f);function Q(E,N,Z,K,U){this.static_tree=E,this.extra_bits=N,this.extra_base=Z,this.elems=K,this.max_length=U,this.has_stree=E&&E.length}function R(E,N){this.dyn_tree=E,this.max_code=0,this.stat_desc=N}function F(E){return E<256?I[E]:I[256+(E>>>7)]}function te(E,N){E.pending_buf[E.pending++]=255&N,E.pending_buf[E.pending++]=N>>>8&255}function J(E,N,Z){E.bi_valid>y-Z?(E.bi_buf|=N<<E.bi_valid&65535,te(E,E.bi_buf),E.bi_buf=N>>y-E.bi_valid,E.bi_valid+=Z-y):(E.bi_buf|=N<<E.bi_valid&65535,E.bi_valid+=Z)}function Y(E,N,Z){J(E,Z[2*N],Z[2*N+1])}function de(E,N){for(var Z=0;Z|=1&E,E>>>=1,Z<<=1,0<--N;);return Z>>>1}function fe(E,N,Z){var K,U,$=new Array(g+1),ne=0;for(K=1;K<=g;K++)$[K]=ne=ne+Z[K-1]<<1;for(U=0;U<=N;U++){var H=E[2*U+1];H!==0&&(E[2*U]=de($[H]++,H))}}function se(E){var N;for(N=0;N<p;N++)E.dyn_ltree[2*N]=0;for(N=0;N<f;N++)E.dyn_dtree[2*N]=0;for(N=0;N<d;N++)E.bl_tree[2*N]=0;E.dyn_ltree[2*x]=1,E.opt_len=E.static_len=0,E.last_lit=E.matches=0}function oe(E){8<E.bi_valid?te(E,E.bi_buf):0<E.bi_valid&&(E.pending_buf[E.pending++]=E.bi_buf),E.bi_buf=0,E.bi_valid=0}function he(E,N,Z,K){var U=2*N,$=2*Z;return E[U]<E[$]||E[U]===E[$]&&K[N]<=K[Z]}function pe(E,N,Z){for(var K=E.heap[Z],U=Z<<1;U<=E.heap_len&&(U<E.heap_len&&he(N,E.heap[U+1],E.heap[U],E.depth)&&U++,!he(N,K,E.heap[U],E.depth));)E.heap[Z]=E.heap[U],Z=U,U<<=1;E.heap[Z]=K}function Ae(E,N,Z){var K,U,$,ne,H=0;if(E.last_lit!==0)for(;K=E.pending_buf[E.d_buf+2*H]<<8|E.pending_buf[E.d_buf+2*H+1],U=E.pending_buf[E.l_buf+H],H++,K===0?Y(E,U,N):(Y(E,($=v[U])+u+1,N),(ne=P[$])!==0&&J(E,U-=z[$],ne),Y(E,$=F(--K),Z),(ne=k[$])!==0&&J(E,K-=X[$],ne)),H<E.last_lit;);Y(E,x,N)}function Le(E,N){var Z,K,U,$=N.dyn_tree,ne=N.stat_desc.static_tree,H=N.stat_desc.has_stree,ie=N.stat_desc.elems,ce=-1;for(E.heap_len=0,E.heap_max=m,Z=0;Z<ie;Z++)$[2*Z]!==0?(E.heap[++E.heap_len]=ce=Z,E.depth[Z]=0):$[2*Z+1]=0;for(;E.heap_len<2;)$[2*(U=E.heap[++E.heap_len]=ce<2?++ce:0)]=1,E.depth[U]=0,E.opt_len--,H&&(E.static_len-=ne[2*U+1]);for(N.max_code=ce,Z=E.heap_len>>1;1<=Z;Z--)pe(E,$,Z);for(U=ie;Z=E.heap[1],E.heap[1]=E.heap[E.heap_len--],pe(E,$,1),K=E.heap[1],E.heap[--E.heap_max]=Z,E.heap[--E.heap_max]=K,$[2*U]=$[2*Z]+$[2*K],E.depth[U]=(E.depth[Z]>=E.depth[K]?E.depth[Z]:E.depth[K])+1,$[2*Z+1]=$[2*K+1]=U,E.heap[1]=U++,pe(E,$,1),2<=E.heap_len;);E.heap[--E.heap_max]=E.heap[1],(function(ae,Ce){var $e,ke,Ot,ge,Qt,xn,He=Ce.dyn_tree,xt=Ce.max_code,zt=Ce.stat_desc.static_tree,Nt=Ce.stat_desc.has_stree,Rt=Ce.stat_desc.extra_bits,bt=Ce.stat_desc.extra_base,bn=Ce.stat_desc.max_length,wi=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<m;$e++)bn<(ge=He[2*He[2*(ke=ae.heap[$e])+1]+1]+1)&&(ge=bn,wi++),He[2*ke+1]=ge,xt<ke||(ae.bl_count[ge]++,Qt=0,bt<=ke&&(Qt=Rt[ke-bt]),xn=He[2*ke],ae.opt_len+=xn*(ge+Qt),Nt&&(ae.static_len+=xn*(zt[2*ke+1]+Qt)));if(wi!==0){do{for(ge=bn-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[bn]--,wi-=2}while(0<wi);for(ge=bn;ge!==0;ge--)for(ke=ae.bl_count[ge];ke!==0;)xt<(Ot=ae.heap[--$e])||(He[2*Ot+1]!==ge&&(ae.opt_len+=(ge-He[2*Ot+1])*He[2*Ot],He[2*Ot+1]=ge),ke--)}})(E,N),fe($,ce,E.bl_count)}function M(E,N,Z){var K,U,$=-1,ne=N[1],H=0,ie=7,ce=4;for(ne===0&&(ie=138,ce=3),N[2*(Z+1)+1]=65535,K=0;K<=Z;K++)U=ne,ne=N[2*(K+1)+1],++H<ie&&U===ne||(H<ce?E.bl_tree[2*U]+=H:U!==0?(U!==$&&E.bl_tree[2*U]++,E.bl_tree[2*b]++):H<=10?E.bl_tree[2*_]++:E.bl_tree[2*T]++,$=U,ce=(H=0)===ne?(ie=138,3):U===ne?(ie=6,3):(ie=7,4))}function W(E,N,Z){var K,U,$=-1,ne=N[1],H=0,ie=7,ce=4;for(ne===0&&(ie=138,ce=3),K=0;K<=Z;K++)if(U=ne,ne=N[2*(K+1)+1],!(++H<ie&&U===ne)){if(H<ce)for(;Y(E,U,E.bl_tree),--H!=0;);else U!==0?(U!==$&&(Y(E,U,E.bl_tree),H--),Y(E,b,E.bl_tree),J(E,H-3,2)):H<=10?(Y(E,_,E.bl_tree),J(E,H-3,3)):(Y(E,T,E.bl_tree),J(E,H-11,7));$=U,ce=(H=0)===ne?(ie=138,3):U===ne?(ie=6,3):(ie=7,4)}}l(X);var j=!1;function L(E,N,Z,K){J(E,(h<<1)+(K?1:0),3),(function(U,$,ne,H){oe(U),te(U,ne),te(U,~ne),s.arraySet(U.pending_buf,U.window,$,ne,U.pending),U.pending+=ne})(E,N,Z)}i._tr_init=function(E){j||((function(){var N,Z,K,U,$,ne=new Array(g+1);for(U=K=0;U<c-1;U++)for(z[U]=K,N=0;N<1<<P[U];N++)v[K++]=U;for(v[K-1]=U,U=$=0;U<16;U++)for(X[U]=$,N=0;N<1<<k[U];N++)I[$++]=U;for($>>=7;U<f;U++)for(X[U]=$<<7,N=0;N<1<<k[U]-7;N++)I[256+$++]=U;for(Z=0;Z<=g;Z++)ne[Z]=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,p+1,ne),N=0;N<f;N++)C[2*N+1]=5,C[2*N]=de(N,5);q=new Q(O,P,u+1,p,g),G=new Q(C,k,0,f,g),ee=new Q(new Array(0),D,0,d,w)})(),j=!0),E.l_desc=new R(E.dyn_ltree,q),E.d_desc=new R(E.dyn_dtree,G),E.bl_desc=new R(E.bl_tree,ee),E.bi_buf=0,E.bi_valid=0,se(E)},i._tr_stored_block=L,i._tr_flush_block=function(E,N,Z,K){var U,$,ne=0;0<E.level?(E.strm.data_type===2&&(E.strm.data_type=(function(H){var ie,ce=4093624447;for(ie=0;ie<=31;ie++,ce>>>=1)if(1&ce&&H.dyn_ltree[2*ie]!==0)return r;if(H.dyn_ltree[18]!==0||H.dyn_ltree[20]!==0||H.dyn_ltree[26]!==0)return a;for(ie=32;ie<u;ie++)if(H.dyn_ltree[2*ie]!==0)return a;return r})(E)),Le(E,E.l_desc),Le(E,E.d_desc),ne=(function(H){var ie;for(M(H,H.dyn_ltree,H.l_desc.max_code),M(H,H.dyn_dtree,H.d_desc.max_code),Le(H,H.bl_desc),ie=d-1;3<=ie&&H.bl_tree[2*B[ie]+1]===0;ie--);return H.opt_len+=3*(ie+1)+5+5+4,ie})(E),U=E.opt_len+3+7>>>3,($=E.static_len+3+7>>>3)<=U&&(U=$)):U=$=Z+5,Z+4<=U&&N!==-1?L(E,N,Z,K):E.strategy===4||$===U?(J(E,2+(K?1:0),3),Ae(E,O,C)):(J(E,4+(K?1:0),3),(function(H,ie,ce,ae){var Ce;for(J(H,ie-257,5),J(H,ce-1,5),J(H,ae-4,4),Ce=0;Ce<ae;Ce++)J(H,H.bl_tree[2*B[Ce]+1],3);W(H,H.dyn_ltree,ie-1),W(H,H.dyn_dtree,ce-1)})(E,E.l_desc.max_code+1,E.d_desc.max_code+1,ne+1),Ae(E,E.dyn_ltree,E.dyn_dtree)),se(E),K&&oe(E)},i._tr_tally=function(E,N,Z){return E.pending_buf[E.d_buf+2*E.last_lit]=N>>>8&255,E.pending_buf[E.d_buf+2*E.last_lit+1]=255&N,E.pending_buf[E.l_buf+E.last_lit]=255&Z,E.last_lit++,N===0?E.dyn_ltree[2*Z]++:(E.matches++,N--,E.dyn_ltree[2*(v[Z]+u+1)]++,E.dyn_dtree[2*F(N)]++),E.last_lit===E.lit_bufsize-1},i._tr_align=function(E){J(E,2,3),Y(E,x,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)})(E)}},{"../utils/common":41}],53:[function(t,n,i){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,n,i){(function(s){(function(r,a){if(!r.setImmediate){var l,h,c,u,p=1,f={},d=!1,m=r.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(r);g=g&&g.setTimeout?g:r,l={}.toString.call(r.process)==="[object process]"?function(b){process.nextTick(function(){w(b)})}:(function(){if(r.postMessage&&!r.importScripts){var b=!0,_=r.onmessage;return r.onmessage=function(){b=!1},r.postMessage("","*"),r.onmessage=_,b}})()?(u="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",x,!1):r.attachEvent("onmessage",x),function(b){r.postMessage(u+b,"*")}):r.MessageChannel?((c=new MessageChannel).port1.onmessage=function(b){w(b.data)},function(b){c.port2.postMessage(b)}):m&&"onreadystatechange"in m.createElement("script")?(h=m.documentElement,function(b){var _=m.createElement("script");_.onreadystatechange=function(){w(b),_.onreadystatechange=null,h.removeChild(_),_=null},h.appendChild(_)}):function(b){setTimeout(w,0,b)},g.setImmediate=function(b){typeof b!="function"&&(b=new Function(""+b));for(var _=new Array(arguments.length-1),T=0;T<_.length;T++)_[T]=arguments[T+1];var P={callback:b,args:_};return f[p]=P,l(p),p++},g.clearImmediate=y}function y(b){delete f[b]}function w(b){if(d)setTimeout(w,0,b);else{var _=f[b];if(_){d=!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)}})(_)}finally{y(b),d=!1}}}}function x(b){b.source===r&&typeof b.data=="string"&&b.data.indexOf(u)===0&&w(+b.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Pn<"u"?Pn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Si)),Si.exports}var ga=ma();const Ns=Os(ga);function Rs(o,e){return function(){return o.apply(e,arguments)}}const{toString:ya}=Object.prototype,{getPrototypeOf:Ai}=Object,{iterator:kn,toStringTag:Fs}=Symbol,In=(o=>e=>{const t=ya.call(e);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ze=o=>(o=o.toLowerCase(),e=>In(e)===o),En=o=>e=>typeof e===o,{isArray:Ut}=Array,Vt=En("undefined");function en(o){return o!==null&&!Vt(o)&&o.constructor!==null&&!Vt(o.constructor)&&Ne(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const Us=Ze("ArrayBuffer");function wa(o){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&Us(o.buffer),e}const xa=En("string"),Ne=En("function"),Vs=En("number"),tn=o=>o!==null&&typeof o=="object",ba=o=>o===!0||o===!1,Bn=o=>{if(In(o)!=="object")return!1;const e=Ai(o);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Fs in o)&&!(kn in o)},_a=o=>{if(!tn(o)||en(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},va=Ze("Date"),Ma=Ze("File"),Sa=Ze("Blob"),Aa=Ze("FileList"),Ca=o=>tn(o)&&Ne(o.pipe),Ta=o=>{let e;return o&&(typeof FormData=="function"&&o instanceof FormData||Ne(o.append)&&((e=In(o))==="formdata"||e==="object"&&Ne(o.toString)&&o.toString()==="[object FormData]"))},Pa=Ze("URLSearchParams"),[Da,ka,Ia,Ea]=["ReadableStream","Request","Response","Headers"].map(Ze),Ba=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nn(o,e,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let n,i;if(typeof o!="object"&&(o=[o]),Ut(o))for(n=0,i=o.length;n<i;n++)e.call(null,o[n],n,o);else{if(en(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(en(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 vt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Gs=o=>!Vt(o)&&o!==vt;function Ci(){const{caseless:o,skipUndefined:e}=Gs(this)&&this||{},t={},n=(i,s)=>{const r=o&&js(t,s)||s;Bn(t[r])&&Bn(i)?t[r]=Ci(t[r],i):Bn(i)?t[r]=Ci({},i):Ut(i)?t[r]=i.slice():(!e||!Vt(i))&&(t[r]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&nn(arguments[i],n);return t}const La=(o,e,t,{allOwnKeys:n}={})=>(nn(e,(i,s)=>{t&&Ne(i)?o[s]=Rs(i,t):o[s]=i},{allOwnKeys:n}),o),Oa=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),za=(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)},Na=(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&&Ai(o)}while(o&&(!t||t(o,e))&&o!==Object.prototype);return e},Ra=(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},Fa=o=>{if(!o)return null;if(Ut(o))return o;let e=o.length;if(!Vs(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=o[e];return t},Ua=(o=>e=>o&&e instanceof o)(typeof Uint8Array<"u"&&Ai(Uint8Array)),Va=(o,e)=>{const n=(o&&o[kn]).call(o);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(o,s[0],s[1])}},ja=(o,e)=>{let t;const n=[];for(;(t=o.exec(e))!==null;)n.push(t);return n},Ga=Ze("HTMLFormElement"),Xa=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Xs=(({hasOwnProperty:o})=>(e,t)=>o.call(e,t))(Object.prototype),Wa=Ze("RegExp"),Ws=(o,e)=>{const t=Object.getOwnPropertyDescriptors(o),n={};nn(t,(i,s)=>{let r;(r=e(i,s,o))!==!1&&(n[s]=r||i)}),Object.defineProperties(o,n)},qa=o=>{Ws(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+"'")})}})},Za=(o,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return Ut(o)?n(o):n(String(o).split(e)),t},Ka=()=>{},Ya=(o,e)=>o!=null&&Number.isFinite(o=+o)?o:e;function $a(o){return!!(o&&Ne(o.append)&&o[Fs]==="FormData"&&o[kn])}const Ha=o=>{const e=new Array(10),t=(n,i)=>{if(tn(n)){if(e.indexOf(n)>=0)return;if(en(n))return n;if(!("toJSON"in n)){e[i]=n;const s=Ut(n)?[]:{};return nn(n,(r,a)=>{const l=t(r,i+1);!Vt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(o,0)},Ja=Ze("AsyncFunction"),Qa=o=>o&&(tn(o)||Ne(o))&&Ne(o.then)&&Ne(o.catch),qs=((o,e)=>o?setImmediate:e?((t,n)=>(vt.addEventListener("message",({source:i,data:s})=>{i===vt&&s===t&&n.length&&n.shift()()},!1),i=>{n.push(i),vt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ne(vt.postMessage)),el=typeof queueMicrotask<"u"?queueMicrotask.bind(vt):typeof process<"u"&&process.nextTick||qs,V={isArray:Ut,isArrayBuffer:Us,isBuffer:en,isFormData:Ta,isArrayBufferView:wa,isString:xa,isNumber:Vs,isBoolean:ba,isObject:tn,isPlainObject:Bn,isEmptyObject:_a,isReadableStream:Da,isRequest:ka,isResponse:Ia,isHeaders:Ea,isUndefined:Vt,isDate:va,isFile:Ma,isBlob:Sa,isRegExp:Wa,isFunction:Ne,isStream:Ca,isURLSearchParams:Pa,isTypedArray:Ua,isFileList:Aa,forEach:nn,merge:Ci,extend:La,trim:Ba,stripBOM:Oa,inherits:za,toFlatObject:Na,kindOf:In,kindOfTest:Ze,endsWith:Ra,toArray:Fa,forEachEntry:Va,matchAll:ja,isHTMLForm:Ga,hasOwnProperty:Xs,hasOwnProp:Xs,reduceDescriptors:Ws,freezeMethods:qa,toObjectSet:Za,toCamelCase:Xa,noop:Ka,toFiniteNumber:Ya,findKey:js,global:vt,isContextDefined:Gs,isSpecCompliantForm:$a,toJSONObject:Ha,isAsyncFn:Ja,isThenable:Qa,setImmediate:qs,asap:el,isIterable:o=>o!=null&&Ne(o[kn])};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)}V.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const Zs=re.prototype,Ks={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(o=>{Ks[o]={value:o}}),Object.defineProperties(re,Ks),Object.defineProperty(Zs,"isAxiosError",{value:!0}),re.from=(o,e,t,n,i,s)=>{const r=Object.create(Zs);V.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 tl=null;function Ti(o){return V.isPlainObject(o)||V.isArray(o)}function Ys(o){return V.endsWith(o,"[]")?o.slice(0,-2):o}function $s(o,e,t){return o?o.concat(e).map(function(i,s){return i=Ys(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function nl(o){return V.isArray(o)&&!o.some(Ti)}const il=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)});function Ln(o,e,t){if(!V.isObject(o))throw new TypeError("target must be an object");e=e||new FormData,t=V.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!V.isUndefined(g[m])});const n=t.metaTokens,i=t.visitor||c,s=t.dots,r=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(e);if(!V.isFunction(i))throw new TypeError("visitor must be a function");function h(d){if(d===null)return"";if(V.isDate(d))return d.toISOString();if(V.isBoolean(d))return d.toString();if(!l&&V.isBlob(d))throw new re("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(d)||V.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,m,g){let y=d;if(d&&!g&&typeof d=="object"){if(V.endsWith(m,"{}"))m=n?m:m.slice(0,-2),d=JSON.stringify(d);else if(V.isArray(d)&&nl(d)||(V.isFileList(d)||V.endsWith(m,"[]"))&&(y=V.toArray(d)))return m=Ys(m),y.forEach(function(x,b){!(V.isUndefined(x)||x===null)&&e.append(r===!0?$s([m],b,s):r===null?m:m+"[]",h(x))}),!1}return Ti(d)?!0:(e.append($s(g,m,s),h(d)),!1)}const u=[],p=Object.assign(il,{defaultVisitor:c,convertValue:h,isVisitable:Ti});function f(d,m){if(!V.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+m.join("."));u.push(d),V.forEach(d,function(y,w){(!(V.isUndefined(y)||y===null)&&i.call(e,y,V.isString(w)?w.trim():w,m,p))===!0&&f(y,m?m.concat(w):[w])}),u.pop()}}if(!V.isObject(o))throw new TypeError("data must be an object");return f(o),e}function Hs(o){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Pi(o,e){this._pairs=[],o&&Ln(o,this,e)}const Js=Pi.prototype;Js.append=function(e,t){this._pairs.push([e,t])},Js.toString=function(e){const t=e?function(n){return e.call(this,n,Hs)}:Hs;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function sl(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Qs(o,e,t){if(!e)return o;const n=t&&t.encode||sl;V.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=V.isURLSearchParams(e)?e.toString():new Pi(e,t).toString(n),s){const r=o.indexOf("#");r!==-1&&(o=o.slice(0,r)),o+=(o.indexOf("?")===-1?"?":"&")+s}return o}class er{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(n){n!==null&&e(n)})}}const tr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},rl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Pi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Di=typeof window<"u"&&typeof document<"u",ki=typeof navigator=="object"&&navigator||void 0,ol=Di&&(!ki||["ReactNative","NativeScript","NS"].indexOf(ki.product)<0),al=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ll=Di&&window.location.href||"http://localhost",De={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Di,hasStandardBrowserEnv:ol,hasStandardBrowserWebWorkerEnv:al,navigator:ki,origin:ll},Symbol.toStringTag,{value:"Module"})),...rl};function cl(o,e){return Ln(o,new De.classes.URLSearchParams,{visitor:function(t,n,i,s){return De.isNode&&V.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function hl(o){return V.matchAll(/\w+|\[(\w*)]/g,o).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ul(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 nr(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&&V.isArray(i)?i.length:r,l?(V.hasOwnProp(i,r)?i[r]=[i[r],n]:i[r]=n,!a):((!i[r]||!V.isObject(i[r]))&&(i[r]=[]),e(t,n,i[r],s)&&V.isArray(i[r])&&(i[r]=ul(i[r])),!a)}if(V.isFormData(o)&&V.isFunction(o.entries)){const t={};return V.forEachEntry(o,(n,i)=>{e(hl(n),i,t,0)}),t}return null}function dl(o,e,t){if(V.isString(o))try{return(e||JSON.parse)(o),V.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(o)}const sn={transitional:tr,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=V.isObject(e);if(s&&V.isHTMLForm(e)&&(e=new FormData(e)),V.isFormData(e))return i?JSON.stringify(nr(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return cl(e,this.formSerializer).toString();if((a=V.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Ln(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),dl(e)):e}],transformResponse:[function(e){const t=this.transitional||sn.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(n&&!this.responseType||i)){const 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:De.classes.FormData,Blob:De.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],o=>{sn.headers[o]={}});const fl=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),pl=o=>{const e={};let t,n,i;return o&&o.split(`
|
|
754
|
-
`).forEach(function(r){i=r.indexOf(":"),t=r.substring(0,i).trim().toLowerCase(),n=r.substring(i+1).trim(),!(!t||e[t]&&
|
|
755
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[ir]=this[ir]={accessors:{}}).accessors,i=this.prototype;function s(r){const a=rn(r);n[a]||(wl(i,r),n[a]=!0)}return V.isArray(e)?e.forEach(s):s(e),this}};Re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Re.prototype,({value:o},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>o,set(n){this[t]=n}}}),V.freezeMethods(Re);function Ei(o,e){const t=this||sn,n=e||t,i=Re.from(n.headers);let s=n.data;return V.forEach(o,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function sr(o){return!!(o&&o.__CANCEL__)}function jt(o,e,t){re.call(this,o??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}V.inherits(jt,re,{__CANCEL__:!0});function rr(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 xl(o){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return e&&e[1]||""}function bl(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 u=s,p=0;for(;u!==i;)p+=t[u++],u=u%o;if(i=(i+1)%o,i===s&&(s=(s+1)%o),h-r<e)return;const f=c&&h-c;return f?Math.round(p*1e3/f):void 0}}function _l(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(),u=c-t;u>=n?r(h,c):(i=h,s||(s=setTimeout(()=>{s=null,r(i)},n-u)))},()=>i&&r(i)]}const zn=(o,e,t=3)=>{let n=0;const i=bl(50,250);return _l(s=>{const r=s.loaded,a=s.lengthComputable?s.total:void 0,l=r-n,h=i(l),c=r<=a;n=r;const u={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(u)},t)},or=(o,e)=>{const t=o!=null;return[n=>e[0]({lengthComputable:t,total:o,loaded:n}),e[1]]},ar=o=>(...e)=>V.asap(()=>o(...e)),vl=De.hasStandardBrowserEnv?((o,e)=>t=>(t=new URL(t,De.origin),o.protocol===t.protocol&&o.host===t.host&&(e||o.port===t.port)))(new URL(De.origin),De.navigator&&/(msie|trident)/i.test(De.navigator.userAgent)):()=>!0,Ml=De.hasStandardBrowserEnv?{write(o,e,t,n,i,s,r){if(typeof document>"u")return;const a=[`${o}=${encodeURIComponent(e)}`];V.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),V.isString(n)&&a.push(`path=${n}`),V.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),V.isString(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 Sl(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function Al(o,e){return e?o.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):o}function lr(o,e,t){let n=!Sl(e);return o&&(n||t==!1)?Al(o,e):e}const cr=o=>o instanceof Re?{...o}:o;function Mt(o,e){e=e||{};const t={};function n(h,c,u,p){return V.isPlainObject(h)&&V.isPlainObject(c)?V.merge.call({caseless:p},h,c):V.isPlainObject(c)?V.merge({},c):V.isArray(c)?c.slice():c}function i(h,c,u,p){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h,u,p)}else return n(h,c,u,p)}function s(h,c){if(!V.isUndefined(c))return n(void 0,c)}function r(h,c){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h)}else return n(void 0,c)}function a(h,c,u){if(u in e)return n(h,c);if(u in 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,u)=>i(cr(h),cr(c),u,!0)};return V.forEach(Object.keys({...o,...e}),function(c){const u=l[c]||i,p=u(o[c],e[c],c);V.isUndefined(p)&&u!==a||(t[c]=p)}),t}const hr=o=>{const e=Mt({},o);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Re.from(r),e.url=Qs(lr(e.baseURL,e.url,e.allowAbsoluteUrls),o.params,o.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(t)){if(De.hasStandardBrowserEnv||De.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(V.isFunction(t.getHeaders)){const l=t.getHeaders(),h=["content-type","content-length"];Object.entries(l).forEach(([c,u])=>{h.includes(c.toLowerCase())&&r.set(c,u)})}}if(De.hasStandardBrowserEnv&&(n&&V.isFunction(n)&&(n=n(e)),n||n!==!1&&vl(e.url))){const l=i&&s&&Ml.read(s);l&&r.set(i,l)}return e},Cl=typeof XMLHttpRequest<"u"&&function(o){return new Promise(function(t,n){const i=hr(o);let s=i.data;const r=Re.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:h}=i,c,u,p,f,d;function m(){f&&f(),d&&d(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const x=Re.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),_={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:x,config:o,request:g};rr(function(P){t(P),m()},function(P){n(P),m()},_),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(n(new re("Request aborted",re.ECONNABORTED,o,g)),g=null)},g.onerror=function(b){const _=b&&b.message?b.message:"Network Error",T=new re(_,re.ERR_NETWORK,o,g);T.event=b||null,n(T),g=null},g.ontimeout=function(){let b=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const _=i.transitional||tr;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new re(b,_.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,o,g)),g=null},s===void 0&&r.setContentType(null),"setRequestHeader"in g&&V.forEach(r.toJSON(),function(b,_){g.setRequestHeader(_,b)}),V.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),h&&([p,d]=zn(h,!0),g.addEventListener("progress",p)),l&&g.upload&&([u,f]=zn(l),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",f)),(i.cancelToken||i.signal)&&(c=x=>{g&&(n(!x||x.type?new jt(null,o,g):x),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const w=xl(i.url);if(w&&De.protocols.indexOf(w)===-1){n(new re("Unsupported protocol "+w+":",re.ERR_BAD_REQUEST,o));return}g.send(s||null)})},Tl=(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 jt(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=()=>V.asap(a),l}},Pl=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},Dl=async function*(o,e){for await(const t of kl(o))yield*Pl(t,e)},kl=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()}},ur=(o,e,t,n)=>{const i=Dl(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 u=c.byteLength;if(t){let p=s+=u;t(p)}l.enqueue(new Uint8Array(c))}catch(h){throw a(h),h}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},dr=64*1024,{isFunction:Nn}=V,Il=(({Request:o,Response:e})=>({Request:o,Response:e}))(V.global),{ReadableStream:fr,TextEncoder:pr}=V.global,mr=(o,...e)=>{try{return!!o(...e)}catch{return!1}},El=o=>{o=V.merge.call({skipUndefined:!0},Il,o);const{fetch:e,Request:t,Response:n}=o,i=e?Nn(e):typeof fetch=="function",s=Nn(t),r=Nn(n);if(!i)return!1;const a=i&&Nn(fr),l=i&&(typeof pr=="function"?(d=>m=>d.encode(m))(new pr):async d=>new Uint8Array(await new t(d).arrayBuffer())),h=s&&a&&mr(()=>{let d=!1;const m=new t(De.origin,{body:new fr,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!m}),c=r&&a&&mr(()=>V.isReadableStream(new n("").body)),u={stream:c&&(d=>d.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(m,g)=>{let y=m&&m[d];if(y)return y.call(m);throw new re(`Response type '${d}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const p=async d=>{if(d==null)return 0;if(V.isBlob(d))return d.size;if(V.isSpecCompliantForm(d))return(await new t(De.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(V.isArrayBufferView(d)||V.isArrayBuffer(d))return d.byteLength;if(V.isURLSearchParams(d)&&(d=d+""),V.isString(d))return(await l(d)).byteLength},f=async(d,m)=>{const g=V.toFiniteNumber(d.getContentLength());return g??p(m)};return async d=>{let{url:m,method:g,data:y,signal:w,cancelToken:x,timeout:b,onDownloadProgress:_,onUploadProgress:T,responseType:P,headers:k,withCredentials:D="same-origin",fetchOptions:B}=hr(d),O=e||fetch;P=P?(P+"").toLowerCase():"text";let C=Tl([w,x&&x.toAbortSignal()],b),I=null;const v=C&&C.unsubscribe&&(()=>{C.unsubscribe()});let z;try{if(T&&h&&g!=="get"&&g!=="head"&&(z=await f(k,y))!==0){let R=new t(m,{method:"POST",body:y,duplex:"half"}),F;if(V.isFormData(y)&&(F=R.headers.get("content-type"))&&k.setContentType(F),R.body){const[te,J]=or(z,zn(ar(T)));y=ur(R.body,dr,te,J)}}V.isString(D)||(D=D?"include":"omit");const q=s&&"credentials"in t.prototype,G={...B,signal:C,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:q?D:void 0};I=s&&new t(m,G);let ee=await(s?O(I,B):O(m,G));const X=c&&(P==="stream"||P==="response");if(c&&(_||X&&v)){const R={};["status","statusText","headers"].forEach(Y=>{R[Y]=ee[Y]});const F=V.toFiniteNumber(ee.headers.get("content-length")),[te,J]=_&&or(F,zn(ar(_),!0))||[];ee=new n(ur(ee.body,dr,te,()=>{J&&J(),v&&v()}),R)}P=P||"text";let Q=await u[V.findKey(u,P)||"text"](ee,d);return!X&&v&&v(),await new Promise((R,F)=>{rr(R,F,{data:Q,headers:Re.from(ee.headers),status:ee.status,statusText:ee.statusText,config:d,request:I})})}catch(q){throw v&&v(),q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,d,I),{cause:q.cause||q}):re.from(q,q&&q.code,d,I)}}},Bl=new Map,gr=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=Bl;for(;a--;)l=s[a],h=c.get(l),h===void 0&&c.set(l,h=a?new Map:El(e)),c=h;return h};gr();const Bi={http:tl,xhr:Cl,fetch:{get:gr}};V.forEach(Bi,(o,e)=>{if(o){try{Object.defineProperty(o,"name",{value:e})}catch{}Object.defineProperty(o,"adapterName",{value:e})}});const yr=o=>`- ${o}`,Ll=o=>V.isFunction(o)||o===null||o===!1;function Ol(o,e){o=V.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,!Ll(n)&&(i=Bi[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(V.isFunction(i)||(i=i.get(e))))break;s[a||"#"+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 :
|
|
756
|
-
`+r.map(
|
|
757
|
-
`):" "+
|
|
758
|
-
`+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Mt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Fn.assertOptions(n,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},!1),i!=null&&(V.isFunction(i)?t.paramsSerializer={serialize:i}:Fn.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),Fn.assertOptions(t,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=s&&V.merge(s.common,s[t.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],d=>{delete s[d]}),t.headers=Re.concat(r,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let c,u=0,p;if(!l){const d=[xr.bind(this),void 0];for(d.unshift(...a),d.push(...h),p=d.length,c=Promise.resolve(t);u<p;)c=c.then(d[u++],d[u++]);return c}p=a.length;let f=t;for(;u<p;){const d=a[u++],m=a[u++];try{f=d(f)}catch(g){m.call(this,g);break}}try{c=xr.call(this,f)}catch(d){return Promise.reject(d)}for(u=0,p=h.length;u<p;)c=c.then(h[u++],h[u++]);return c}getUri(e){e=Mt(this.defaults,e);const t=lr(e.baseURL,e.url,e.allowAbsoluteUrls);return Qs(t,e.params,e.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(e){St.prototype[e]=function(t,n){return this.request(Mt(n||{},{method:e,url:t,data:(n||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(n){return function(s,r,a){return this.request(Mt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}St.prototype[e]=t(),St.prototype[e+"Form"]=t(!0)});let Nl=class Lo{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const 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 jt(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 Lo(function(i){e=i}),cancel:e}}};function Rl(o){return function(t){return o.apply(null,t)}}function Fl(o){return V.isObject(o)&&o.isAxiosError===!0}const Oi={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(Oi).forEach(([o,e])=>{Oi[e]=o});function vr(o){const e=new St(o),t=Rs(St.prototype.request,e);return V.extend(t,St.prototype,e,{allOwnKeys:!0}),V.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return vr(Mt(o,i))},t}const ye=vr(sn);ye.Axios=St,ye.CanceledError=jt,ye.CancelToken=Nl,ye.isCancel=sr,ye.VERSION=br,ye.toFormData=Ln,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=Rl,ye.isAxiosError=Fl,ye.mergeConfig=Mt,ye.AxiosHeaders=Re,ye.formToJSON=o=>nr(V.isHTMLForm(o)?new FormData(o):o),ye.getAdapter=wr.getAdapter,ye.HttpStatusCode=Oi,ye.default=ye;const{Axios:Pd,AxiosError:Dd,CanceledError:kd,isCancel:Id,CancelToken:Ed,VERSION:Bd,all:Ld,Cancel:Od,isAxiosError:zd,spread:Nd,toFormData:Rd,AxiosHeaders:Fd,HttpStatusCode:Ud,formToJSON:Vd,getAdapter:jd,mergeConfig:Gd}=ye;function Mr(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 Ul(o,e){ye({method:"get",responseType:"blob",url:o}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});Ns.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 u=URL.createObjectURL(c);s.set("/"+i.files[a].name.replace("\\","/"),u)});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 Sr(o,e){ye({method:"get",responseType:"blob",url:o}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});Ns.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 zi=new WeakMap;class Vl extends S.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new S.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,S.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=S.LinearSRGBColorSpace,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(zi.has(e)){const l=zi.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)}),zi.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new S.BufferGeometry;e.index&&t.setIndex(new S.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:r,stride:a,vertexColorSpace:l}=e.attributes[n];let h;if(r===a)h=new S.BufferAttribute(s,r);else{const c=new S.InterleavedBuffer(s,a);h=new S.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!==S.SRGBColorSpace)return;const n=new S.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),S.ColorManagement.colorSpaceToWorking(n,S.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new S.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=jl.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
759
|
-
`);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 jl(){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(u){c({draco:u})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const u=c.draco,p=new u.Decoder;try{const f=t(u,p,new Int8Array(l),h),d=f.attributes.map(m=>m.array.buffer);f.index&&d.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},d)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{u.destroy(p)}});break}};function t(r,a,l,h){const c=h.attributeIDs,u=h.attributeTypes;let p,f;const d=a.GetEncodedGeometryType(l);if(d===r.TRIANGULAR_MESH)p=new r.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,p);else if(d===r.POINT_CLOUD)p=new r.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const m={index:null,attributes:[]};for(const g in c){const y=self[u[g]];let w,x;if(h.useUniqueIDs)x=c[g],w=a.GetAttributeByUniqueId(p,x);else{if(x=a.GetAttributeId(p,r[c[g]]),x===-1)continue;w=a.GetAttribute(p,x)}const b=i(r,a,p,g,y,w);g==="color"&&(b.vertexColorSpace=h.vertexColorSpace),m.attributes.push(b)}return d===r.TRIANGULAR_MESH&&(m.index=n(r,a,p)),r.destroy(p),m}function n(r,a,l){const c=l.num_faces()*3,u=c*4,p=r._malloc(u);a.GetTrianglesUInt32Array(l,u,p);const f=new Uint32Array(r.HEAPF32.buffer,p,c).slice();return r._free(p),{array:f,itemSize:1}}function i(r,a,l,h,c,u){const p=l.num_points(),f=u.num_components(),d=s(r,c),m=f*c.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,y=g/c.BYTES_PER_ELEMENT,w=p*m,x=p*g,b=r._malloc(w);a.GetAttributeDataArrayForAllPoints(l,u,d,w,b);const _=new c(r.HEAPF32.buffer,b,w/c.BYTES_PER_ELEMENT);let T;if(m===g)T=_.slice();else{T=new c(x/c.BYTES_PER_ELEMENT);let P=0;for(let k=0,D=_.length;k<D;k++){for(let B=0;B<f;B++)T[P+B]=_[k*f+B];P+=y}}return r._free(b),{name:h,count:p,itemSize:f,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 ht=(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))(ht||{});function Gl(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(f=>f.url==t),l=e.circularMeps,h=e.rectMeps.filter(f=>f.type==="风管"),c=e.rectMeps.filter(f=>f.type==="桥架"),u=e.ellipseMeps,p=o.scene;if(new A.MeshBasicMaterial,new A.BufferGeometry,l&&l.length){let f=[],d=0;for(let m of l)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Un("Circle",p,f,t)}if(h&&h.length){let f=[],d=0;for(let m of h)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Un("Rect",p,f,t)}if(u&&u.length){let f=[],d=0;for(let m of u)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Un("Ellipse",p,f,t)}if(c&&c.length){let f=[],d=0;for(let m of c)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Un("Bridge",p,f,t)}}function Un(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new A.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=Vn("Rect",a);break;case"Bridge":r=Vn("Bridge",a);break;case"Circle":r=Vn("Circle",a);break;case"Ellipse":r=Vn("Ellipse",a);break}r&&(s=new A.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[];for(var h=0;h<t.length;h++){let p=t[h],f=new A.Vector3(p.startPoint.X,0,-p.startPoint.Y),d=new A.Vector3(p.endPoint.X,0,-p.endPoint.Y),m=new A.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),g=new A.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),y=0,w=0,x=0;if(Math.abs(d.clone().sub(f.clone()).z)<.01&&Math.abs(d.clone().sub(f.clone()).x)<.01){if(y=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var c=new A.Vector3(p.base_x.X,0,-p.base_x.Y);w=(c.clone().cross(new A.Vector3(0,0,1)).y<=0?1:-1)*c.angleTo(new A.Vector3(0,0,1))+Math.PI*.5}}else w=(d.clone().sub(f.clone()).cross(new A.Vector3(0,0,1)).y>0?-1:1)*d.clone().sub(f.clone()).angleTo(new A.Vector3(0,0,1)),y=(p.startPoint.Z>p.endPoint.Z?1:-1)*d.clone().sub(f.clone()).angleTo(g.clone().sub(m.clone()));let b=new A.Matrix4;const _=new A.Euler(y,w,x,"YXZ");let T=b.clone().makeRotationFromEuler(_),P,k;o==="Circle"?(P=p.diameter,k=p.diameter):(P=p.width,k=p.height);let D=b.clone().makeScale(P,k,p.length);b.multiplyMatrices(T,D),b.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(h,b.clone()),s.setColorAt(h,p.color),s.geometry.computeBoundingBox();let B=s.geometry.boundingBox.min.clone().applyMatrix4(b.clone()),O=s.geometry.boundingBox.max.clone().applyMatrix4(b.clone()),C=new A.Vector3(Math.min(B.x,O.x),Math.min(B.y,O.y),Math.min(B.z,O.z)),I=new A.Vector3(Math.max(B.x,O.x),Math.max(B.y,O.y),Math.max(B.z,O.z)),v=C.clone().add(I.clone()).multiplyScalar(.5),z={name:p.name,min:C,max:I,center:v,dbid:h,materialName:r.material.name},q=null,G=null;o==="Circle"&&(q={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},G={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},z.minC=q,z.maxC=G),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(b.clone()),s.ids.push(Number(p.id)),l.push(z)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone();let u=[];u={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=u,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Vn(o,e,t){let n=new A.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 u=new A.ExtrudeGeometry(r,a),p=new A.MeshStandardMaterial({color:l,side:A.DoubleSide}),f=new A.Mesh(u,p);return f.position.set(h.x,h.y,h.z),f.rotation._order="YXZ",f.rotation.set(c.x,c.y,c.z),f}}function Ar(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 S.BufferGeometry;let h=0;for(let c=0;c<o.length;++c){const u=o[c];let p=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(u.attributes[f]),p++}if(p!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;r[f]===void 0&&(r[f]=[]),r[f].push(u.morphAttributes[f])}if(e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,f,c),h+=f}}if(t){let c=0;const u=[];for(let p=0;p<o.length;++p){const f=o[p].index;for(let d=0;d<f.count;++d)u.push(f.getX(d)+c);c+=o[p].attributes.position.count}l.setIndex(u)}for(const c in s){const u=Cr(s[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(const c in r){const u=r[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let p=0;p<u;++p){const f=[];for(let m=0;m<r[c].length;++m)f.push(r[c][m][p]);const d=Cr(f);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(d)}}return l}function Cr(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 S.BufferAttribute(r,t,n);let l=0;for(let h=0;h<o.length;++h){const c=o[h];if(c.isInterleavedBufferAttribute){const u=l/t;for(let p=0,f=c.count;p<f;p++)for(let d=0;d<t;d++){const m=c.getComponent(p,d);a.setComponent(p+u,d,m)}}else r.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Tr(o,e){if(e===S.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===S.TriangleFanDrawMode||e===S.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===S.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 Xl extends S.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Yl(t)}),this.register(function(t){return new $l(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new Jl(t)}),this.register(function(t){return new Ql(t)}),this.register(function(t){return new ec(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new Kl(t)}),this.register(function(t){return new nc(t)}),this.register(function(t){return new Hl(t)}),this.register(function(t){return new sc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new ql(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new cc(t)})}load(e,t,n,i){const s=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=S.LoaderUtils.extractUrlBase(e);r=S.LoaderUtils.resolveURL(h,this.path)}else r=S.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){i?i(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},l=new S.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{s.parse(h,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))===Pr){try{r[le.KHR_BINARY_GLTF]=new hc(e)}catch(u){i&&i(u);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 Mc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const u=this.pluginCallbacks[c](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const u=s.extensionsUsed[c],p=s.extensionsRequired||[];switch(u){case le.KHR_MATERIALS_UNLIT:r[u]=new Zl;break;case le.KHR_DRACO_MESH_COMPRESSION:r[u]=new uc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[u]=new dc;break;case le.KHR_MESH_QUANTIZATION:r[u]=new fc;break;default:p.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}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 Wl(){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 ql{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const c=new S.Color(16777215);l.color!==void 0&&c.setRGB(l.color[0],l.color[1],l.color[2],S.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new S.DirectionalLight(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new S.PointLight(c),h.distance=u;break;case"spot":h=new S.SpotLight(c),h.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Qe(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Zl{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return S.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new S.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const r=s.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],S.LinearSRGBColorSpace),e.opacity=r[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,S.SRGBColorSpace))}return Promise.all(i)}}class Kl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Yl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 S.Vector2(a,a)}return Promise.all(s)}}class $l{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class Hl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 Jl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new S.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,S.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class Ql{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 ec{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),Promise.all(s)}}class tc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class nc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,S.SRGBColorSpace)),Promise.all(s)}}class ic{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 sc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],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 rc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],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 oc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const 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 ac{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const 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 lc{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),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,u=i.byteStride,p=new Uint8Array(a,l,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,u,p,i.mode,i.filter).then(function(f){return f.buffer}):r.ready.then(function(){const f=new ArrayBuffer(c*u);return r.decodeGltfBuffer(new Uint8Array(f),c,u,p,i.mode,i.filter),f})})}else return null}}class cc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==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(),u=c.isGroup?c.children:[c],p=h[0].count,f=[];for(const d of u){const m=new S.Matrix4,g=new S.Vector3,y=new S.Quaternion,w=new S.Vector3(1,1,1),x=new S.InstancedMesh(d.geometry,d.material,p);for(let b=0;b<p;b++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,b),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,b),l.SCALE&&w.fromBufferAttribute(l.SCALE,b),x.setMatrixAt(b,m.compose(g,y,w));for(const b in l)if(b==="_COLOR_0"){const _=l[b];x.instanceColor=new S.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&d.geometry.setAttribute(b,l[b]);S.Object3D.prototype.copy.call(x,d),this.parser.assignFinalMaterial(x),f.push(x)}return c.isGroup?(c.clear(),c.add(...f),c):f[0]}))}}const Pr="glTF",on=12,Dr={JSON:1313821514,BIN:5130562};class hc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,on),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Pr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-on,s=new DataView(e,on);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Dr.JSON){const h=new Uint8Array(e,on+r,a);this.content=n.decode(h)}else if(l===Dr.BIN){const h=on+r;this.body=e.slice(h,h+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class uc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},l={},h={};for(const c in r){const u=Ri[c]||c.toLowerCase();a[u]=r[c]}for(const c in e.attributes){const u=Ri[c]||c.toLowerCase();if(r[c]!==void 0){const p=n.accessors[e.attributes[c]],f=Gt[p.componentType];h[u]=f.name,l[u]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(u,p){i.decodeDracoFile(c,function(f){for(const d in f.attributes){const m=f.attributes[d],g=l[d];g!==void 0&&(m.normalized=g)}u(f)},a,h,S.LinearSRGBColorSpace,p)})})}}class dc{constructor(){this.name=le.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class fc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class kr extends S.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let 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,u=(n-t)/c,p=u*u,f=p*u,d=e*h,m=d-h,g=-2*f+3*p,y=f-p,w=1-g,x=y-p+u;for(let b=0;b!==a;b++){const _=r[m+b+a],T=r[m+b+l]*c,P=r[d+b+a],k=r[d+b]*c;s[b]=w*_+x*T+g*P+y*k}return s}}const pc=new S.Quaternion;class mc extends kr{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return pc.fromArray(s).normalize().toArray(s),s}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Gt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ir={9728:S.NearestFilter,9729:S.LinearFilter,9984:S.NearestMipmapNearestFilter,9985:S.LinearMipmapNearestFilter,9986:S.NearestMipmapLinearFilter,9987:S.LinearMipmapLinearFilter},Er={33071:S.ClampToEdgeWrapping,33648:S.MirroredRepeatWrapping,10497:S.RepeatWrapping},Ni={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ri={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ut={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},gc={CUBICSPLINE:void 0,LINEAR:S.InterpolateLinear,STEP:S.InterpolateDiscrete},Fi={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function yc(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new S.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:S.FrontSide})),o.DefaultMaterial}function At(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 wc(o,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const u=e[h];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const u=e[h];if(n){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):o.attributes.position;r.push(p)}if(i){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):o.attributes.normal;a.push(p)}if(s){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):o.attributes.color;l.push(p)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],u=h[1],p=h[2];return n&&(o.morphAttributes.position=c),i&&(o.morphAttributes.normal=u),s&&(o.morphAttributes.color=p),o.morphTargetsRelative=!0,o})}function xc(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 bc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ui(t.attributes):e=o.indices+":"+Ui(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+Ui(o.targets[n]);return e}function Ui(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 Vi(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 _c(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 vc=new S.Matrix4;class Mc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Wl,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,s=!1,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 S.TextureLoader(this.options.manager):this.textureLoader=new S.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new S.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(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 At(s,a,i),Qe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const 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(S.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=Ni[i.type],a=Gt[i.componentType],l=i.normalized===!0,h=new a(i.count*r);return Promise.resolve(new S.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=Ni[i.type],h=Gt[i.componentType],c=h.BYTES_PER_ELEMENT,u=c*l,p=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0;let m,g;if(f&&f!==u){const y=Math.floor(p/f),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let x=t.cache.get(w);x||(m=new h(a,y*f,i.count*f/c),x=new S.InterleavedBuffer(m,f/c),t.cache.add(w,x)),g=new S.InterleavedBufferAttribute(x,l,p%f/c,d)}else a===null?m=new h(i.count*l):m=new h(a,p,i.count*l),g=new S.BufferAttribute(m,l,d);if(i.sparse!==void 0){const y=Ni.SCALAR,w=Gt[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,b=i.sparse.values.byteOffset||0,_=new w(r[1],x,i.sparse.count*y),T=new h(r[2],b,i.sparse.count*l);a!==null&&(g=new S.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=_.length;P<k;P++){const D=_[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=d}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 p=(s.samplers||{})[r.sampler]||{};return c.magFilter=Ir[p.magFilter]||S.LinearFilter,c.minFilter=Ir[p.minFilter]||S.LinearMipmapLinearFilter,c.wrapS=Er[p.wrapS]||S.RepeatWrapping,c.wrapT=Er[p.wrapT]||S.RepeatWrapping,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==S.NearestFilter&&c.minFilter!==S.LinearFilter,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const 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(u){h=!0;const p=new Blob([u],{type:r.mimeType});return l=a.createObjectURL(p),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(u){return new Promise(function(p,f){let d=p;t.isImageBitmapLoader===!0&&(d=function(m){const g=new S.Texture(m);g.needsUpdate=!0,p(g)}),t.load(S.LoaderUtils.resolveURL(u,s.path),d,void 0,f)})}).then(function(u){return h===!0&&a.revokeObjectURL(l),Qe(u,r),u.userData.mimeType=r.mimeType||_c(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(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 S.PointsMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.LineBasicMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||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 S.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 u=i[le.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),h.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new S.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],S.LinearSRGBColorSpace),a.opacity=p[3]}u.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",u.baseColorTexture,S.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=S.DoubleSide);const c=s.alphaMode||Fi.OPAQUE;if(c===Fi.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Fi.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new S.Vector2(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&r!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==S.MeshBasicMaterial){const u=s.emissiveFactor;a.emissive=new S.Color().setRGB(u[0],u[1],u[2],S.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==S.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,S.SRGBColorSpace)),Promise.all(h).then(function(){const u=new r(a);return s.name&&(u.name=s.name),Qe(u,s),t.associations.set(u,{materials:e}),s.extensions&&At(i,u,s),u})}createUniqueName(e){const t=S.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Br(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=bc(h),u=i[c];if(u)r.push(u.promise);else{let p;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?p=s(h):p=Br(new S.BufferGeometry,h,t),i[c]={primitive:h,promise:p},r.push(p)}}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?yc(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],u=[];for(let f=0,d=c.length;f<d;f++){const m=c[f],g=r[f];let y;const w=h[f];if(g.mode===Ve.TRIANGLES||g.mode===Ve.TRIANGLE_STRIP||g.mode===Ve.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new S.SkinnedMesh(m,w):new S.Mesh(m,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Tr(y.geometry,S.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Tr(y.geometry,S.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new S.LineSegments(m,w);else if(g.mode===Ve.LINE_STRIP)y=new S.Line(m,w);else if(g.mode===Ve.LINE_LOOP)y=new S.LineLoop(m,w);else if(g.mode===Ve.POINTS)y=new S.Points(m,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&xc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&At(i,y,g),t.assignFinalMaterial(y),u.push(y)}for(let f=0,d=u.length;f<d;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return s.extensions&&At(i,u[0],s),u[0];const p=new S.Group;s.extensions&&At(i,p,s),t.associations.set(p,{meshes:e});for(let f=0,d=u.length;f<d;f++)p.add(u[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new S.PerspectiveCamera(S.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new S.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Qe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),r=i,a=[],l=[];for(let h=0,c=r.length;h<c;h++){const u=r[h];if(u){a.push(u);const p=new S.Matrix4;s!==null&&p.fromArray(s.array,h*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new S.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,r=[],a=[],l=[],h=[],c=[];for(let u=0,p=i.channels.length;u<p;u++){const f=i.channels[u],d=i.samplers[f.sampler],m=f.target,g=m.node,y=i.parameters!==void 0?i.parameters[d.input]:d.input,w=i.parameters!==void 0?i.parameters[d.output]:d.output;m.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(d),c.push(m))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(u){const p=u[0],f=u[1],d=u[2],m=u[3],g=u[4],y=[];for(let x=0,b=p.length;x<b;x++){const _=p[x],T=f[x],P=d[x],k=m[x],D=g[x];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const B=n._createAnimationTracks(_,T,P,k,D);if(B)for(let O=0;O<B.length;O++)y.push(B[O])}const w=new S.AnimationClip(s,void 0,y);return Qe(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const 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],u=h[1],p=h[2];p!==null&&c.traverse(function(f){f.isSkinnedMesh&&f.bind(p,vc)});for(let f=0,d=u.length;f<d;f++)c.add(u[f]);return c})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],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 S.Bone:h.length>1?c=new S.Group:h.length===1?c=h[0]:c=new S.Object3D,c!==h[0])for(let u=0,p=h.length;u<p;u++)c.add(h[u]);if(s.name&&(c.userData.name=s.name,c.name=r),Qe(c,s),s.extensions&&At(n,c,s),s.matrix!==void 0){const u=new S.Matrix4;u.fromArray(s.matrix),c.applyMatrix4(u)}else s.translation!==void 0&&c.position.fromArray(s.translation),s.rotation!==void 0&&c.quaternion.fromArray(s.rotation),s.scale!==void 0&&c.scale.fromArray(s.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(c);i.associations.set(c,{...u})}return i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new S.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&At(t,s,n);const 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,u=l.length;c<u;c++)s.add(l[c]);const h=c=>{const u=new Map;for(const[p,f]of i.associations)(p instanceof S.Material||p instanceof S.Texture)&&u.set(p,f);return c.traverse(p=>{const f=i.associations.get(p);f!=null&&u.set(p,f)}),u};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];ut[s.path]===ut.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let h;switch(ut[s.path]){case ut.weights:h=S.NumberKeyframeTrack;break;case ut.rotation:h=S.QuaternionKeyframeTrack;break;case ut.translation:case ut.scale:h=S.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=S.NumberKeyframeTrack;break;case 2:case 3:default:h=S.VectorKeyframeTrack;break}break}const c=i.interpolation!==void 0?gc[i.interpolation]:S.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let p=0,f=l.length;p<f;p++){const d=new h(l[p]+"."+ut[s.path],t.array,u,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(d),r.push(d)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Vi(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 S.QuaternionKeyframeTrack?mc:kr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Sc(o,e,t){const n=e.attributes,i=new S.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(i.set(new S.Vector3(l[0],l[1],l[2]),new S.Vector3(h[0],h[1],h[2])),a.normalized){const c=Vi(Gt[a.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new S.Vector3,l=new S.Vector3;for(let h=0,c=s.length;h<c;h++){const u=s[h];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,d=p.max;if(f!==void 0&&d!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(d[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(d[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(d[2]))),p.normalized){const m=Vi(Gt[p.componentType]);l.multiplyScalar(m)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new S.Sphere;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Br(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=Ri[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 S.ColorManagement.workingColorSpace!==S.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${S.ColorManagement.workingColorSpace}" not supported.`),Qe(o,e),Sc(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?wc(o,e.targets,t):o})}function Ac(o,e,t){let n=new A.Group;n.name=e,o.scene.add(n),Sr(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 A.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new A.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ht.EngineFree,e)})}function Cc(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,Gl(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Tc(o,t))})}function Tc(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={},Ul(e.url+i.path,s=>{Mr(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(f=>{f.glb=c,l.has(f.id)==!1?l.set(f.id,{infos:[f]}):l.get(f.id).infos.push(f)});let u=new Xl;const p=new Vl;p.setDecoderPath("/draco/"),p.preload(),u.setDRACOLoader(p),u.load(s.get(c+".glb"),f=>{i.glbs[c]=f.scene.children,h++,h==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ht.EngineFree,e.url),o.viewCube.CameraGoHome())})}Mr(s.get("/instances.json"),c=>{let u=JSON.parse(c);o.models.find(p=>p.url==e.url).instanceNodes=u})})});else{console.log("加载模型.............");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 u=i.glbs[c.glb][c.mesh];if(u!=null&&u.geometry!=null&&u.material!=null){let p=new A.Matrix4;p.elements=c.matrix;let f=new A.Mesh(u.geometry.clone().applyMatrix4(p),u.material),d=new A.Box3().setFromObject(f);c.box=d,c.mesh=f,f.name=h,f.glb=c.glb,f.url=e.url,u.geometry.attributes.position!=null&&r.push(f)}})}),console.log("加载模型数量",r.length),Pc(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 u=i.glbs[h][c.mesh];Dc(e.url,c.mesh,o,u,c.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new A.Vector3(r.min.X,r.min.Z,-r.min.Y),h=new A.Vector3(r.max.X,r.max.Z,-r.max.Y);h.distanceTo(l);let c=o.camera.position,u=new A.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(u),r.elements.forEach(p=>{a.push(p)}),r.children.forEach(p=>{a.push(...n(i,s,p))}),r.children.findIndex(p=>p.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Pc(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.set(Number(i.name),[s.currentIndex-i.geometry.index.count,s.currentIndex])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof A.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new A.BufferGeometry,a=kc(i.meshes[0].material);r=Ar(i.meshes.map(c=>c.geometry),!1);let l=new A.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(u=>{h.nodesMap.get(Number(i.meshes[c].name)).indexes==null&&(h.nodesMap.get(Number(i.meshes[c].name)).indexes=[]),h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index,c++,u[0],u[1]])})}}})}function Dc(o,e,t,n,i){if(n==null)return;let s=new A.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let a=0;a<i.length;a++)r[a*3]=1,r[a*3+1]=1,r[a*3+2]=1;s.instanceColor=new A.InstancedBufferAttribute(r,3);for(let a=0;a<i.length;a++){let l=i[a],h=new A.Matrix4;h.elements=l.matrix,s.setMatrixAt(a,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),t.models.find(c=>c.url==o).nodesMap.has(l.id)?(t.models.find(c=>c.url==o).nodesMap.get(l.id).indexes==null&&(t.models.find(c=>c.url==o).nodesMap.get(l.id).indexes=[]),t.models.find(c=>c.url==o).nodesMap.get(l.id).indexes.push([t.scene.children.length-1,a,0,0])):t.models.find(c=>c.url==o).nodesMap.set(l.id,{instance:!0,info:l,indexes:[[t.scene.children.length-1,a,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(a=>a.id)}function kc(o){return o.map!=null&&(o.map.colorSpace=A.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=A.FrontSide,o.side=o.side,o}class Ic{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&Ac(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class Ec{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ht.EngineFree,e=>{this.updateFree(!0),console.log("引擎空闲"),Cc(this.engine,e)}),this.engine.events.on(ht.EngineBusy,()=>{this.updateFree(!1),console.log("引擎繁忙")})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Bc{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,r)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${r}:`,a)}})}}class Lc{engine;constructor(e){this.engine=e}init(){const e=new A.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 A.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new A.AmbientLight(16777215,1);this.engine.scene.add(i)}}var ve=(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))(ve||{});class Oc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new A.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;handleMouseMove(e){if(!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let t=e.catch.object,n=e.catch.object.id,i=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n),s=new Map;i?.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof A.InstancedMesh&&(s.has(a[0])?s.get(a[0])?.push(a[1]):s.set(a[0],[a[1]]))});let r=[];return s.forEach((a,l)=>{let h=this.engine.scene.children[l];a.forEach(c=>{let u=h.geometry.clone();u.applyMatrix4(h.matrixs[c]),r.push(new A.Mesh(u,h.material))})}),this.hoverOldId==n?[]:(this.hoverOldId=n,this.engine.hoverHighLight.clearHighlight(),r)}else{const t=e.catch;t.object;let n=t.object,i=n.name,a=this.engine.models.find(l=>l.url===n.url).nodesMap.get(i).infos.map(l=>l.mesh);return this.hoverOldId==i?[]:(this.hoverOldId=i,this.engine.hoverHighLight.clearHighlight(),a)}}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(ve.Click,!0)}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object,this.engine.events.trigger(ve.Click,n);let i=n.object,a=this.engine.models.find(h=>h.url===i.url).nodesMap.get(i.name).infos.map(h=>h.box),l=t(a);this.engine.viewCube.zoomToModel(l)}function t(n){let i=new A.Vector3(1e8,1e9,1e10),s=new A.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 A.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof A.InstancedMesh),!0)}}class zc{engine;highlightMaterial;hideMaterial;translucentMaterial;cloneModels=new Map;clonetranslucentModels=new Map;constructor(e){this.engine=e,this.highlightMaterial=new A.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:A.DoubleSide}),this.hideMaterial=new A.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:A.DoubleSide}),this.translucentMaterial=new A.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:A.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 A.InstancedMesh)return;let t=e.materialClone.clone(),n=Ar(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s?.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof A.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(console.log(this.engine.scene.children[r[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[r[0]]),this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=1)})}),Nc(n,this.engine,this.cloneModels),this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s?.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof A.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})}),Lr(n,this.engine,this.cloneModels)})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof A.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Fc(n,this.engine,this.cloneModels);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof A.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Or(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const 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.unhighlightAllModels(),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightModel(e),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof A.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=2)})}),Rc(n,this.engine,this.clonetranslucentModels);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof A.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&&Or(n,this.engine),Lr(n,this.engine,this.clonetranslucentModels)}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Nc(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof A.InstancedMesh))return;const r=s.geometry,a=new A.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:A.DoubleSide}),l=new A.InstancedMesh(r,a,n.length);l.name="highlightModel";const h=new Map,c=new A.Matrix4,u=new A.Matrix4;u.makeScale(0,0,0),n.forEach((p,f)=>{s.getMatrixAt(p,c),h.set(p,c.clone()),s.setMatrixAt(p,u),l.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Lr(o,e,t){o.forEach((n,i)=>{const s=t.get(i);if(!s)return;const r=e.scene.children[i];r instanceof A.InstancedMesh&&(n.forEach(a=>{const l=s.originalMatrices.get(a);l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0,s.cloneModel.parent&&s.cloneModel.parent.remove(s.cloneModel),s.cloneModel.geometry,s.cloneModel.material&&(Array.isArray(s.cloneModel.material)?s.cloneModel.material.forEach(a=>a.dispose()):s.cloneModel.material.dispose()),t.delete(i))})}function Rc(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof A.InstancedMesh))return;const r=s.geometry,a=new A.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:A.DoubleSide}),l=new A.InstancedMesh(r,a,n.length);l.name="translucentModel";const h=new Map,c=new A.Matrix4,u=new A.Matrix4;u.makeScale(0,0,0),n.forEach((p,f)=>{s.getMatrixAt(p,c),h.set(p,c.clone()),s.setMatrixAt(p,u),l.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Fc(o,e,t){e.scene.children.forEach(n=>{n.name=="highlightModel"&&n.parent.remove(n)}),o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof A.InstancedMesh))return;const r=new Map,a=new A.Matrix4,l=new A.Matrix4;l.makeScale(0,0,0),n.forEach((h,c)=>{s.getMatrixAt(h,a),r.set(h,a.clone()),s.setMatrixAt(h,l)}),s.instanceMatrix.needsUpdate=!0,t.set(i,{cloneModel:null,originalMatrices:r})})}function Or(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof A.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class Fe{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new A.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new A.Vector2(t.x,t.y)}worldToScreen(e){const t=this.worldToScreenNormalized(e),n=this.renderer.domElement.width,i=this.renderer.domElement.height,s=(t.x+1)*n/2,r=(1-t.y)*i/2;return new A.Vector2(s,r)}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 A.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 A.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}class Uc{engine;currentMode="balance";gtaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.setMode("balance")}setMode(e){console.log("setMode",e),this.currentMode=e,this.switchModel(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){if(!this.engine.composerModule?.composer)return;const e=this.engine.composerModule.composer.passes;for(const t of e)t.constructor.name==="_GTAOPass"?this.gtaoPass=t:t.constructor.name==="ShaderPass"?t.material.uniforms.saturation?this.saturationPass=t:t.material.uniforms.resolution&&(this.fxaaPass=t):t.constructor.name==="OutputPass"&&(this.outputPass=t);this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass)}switchModel(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof A.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&(e?this.gtaoPass.enabled=!0:this.gtaoPass&&(this.gtaoPass.enabled=!1))}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof A.DirectionalLight),i={low:1024,medium:2048,high:4096}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class jn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;constructor(e){this.engine=e,this.init()}init(){this.overlayMaterial=new A.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:A.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 A.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/jn.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/jn.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 Gn={exports:{}},Vc=Gn.exports,zr;function jc(){return zr||(zr=1,(function(o,e){(function(t,n){o.exports=n()})(Vc,function(){var t=function(){function n(f){return r.appendChild(f.dom),f}function i(f){for(var d=0;d<r.children.length;d++)r.children[d].style.display=d===f?"block":"none";s=f}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(f){f.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var f=(performance||Date).now();if(u.update(f-a,200),f>l+1e3&&(c.update(1e3*h/(f-l),100),l=f,h=0,p)){var d=performance.memory;p.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return f},update:function(){a=this.end()},domElement: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,u=48*h,p=3*h,f=2*h,d=3*h,m=15*h,g=74*h,y=30*h,w=document.createElement("canvas");w.width=c,w.height=u,w.style.cssText="width:80px;height:48px";var x=w.getContext("2d");return x.font="bold "+9*h+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,c,u),x.fillStyle=i,x.fillText(n,p,f),x.fillRect(d,m,g,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(d,m,g,y),{dom:w,update:function(b,_){r=Math.min(r,b),a=Math.max(a,b),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,c,m),x.fillStyle=i,x.fillText(l(b)+" "+n+" ("+l(r)+"-"+l(a)+")",p,f),x.drawImage(w,d+h,m,g-h,y,d,m,g-h,y),x.fillRect(d+g-h,m,h,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(d+g-h,m,h,l((1-b/_)*y))}}},t})})(Gn)),Gn.exports}var Gc=jc();const Xc=Os(Gc);var Xt=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-Xt.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?Xt.Bounce.In(o*2)*.5:Xt.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}}}}),an=function(){return performance.now()},Wc=(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=an()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],r=!t;s&&s.update(e,r)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o})(),ji={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=ji.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}}},Nr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),Gi=new Wc,qc=(function(){function o(e,t){t===void 0&&(t=Gi),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=Xt.Linear.None,this._interpolationFunction=ji.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Nr.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=an()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},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 u=n[r];if(u.length===0)continue;for(var p=[a],f=0,d=u.length;f<d;f+=1){var m=this._handleRelativeValue(a,u[f]);if(isNaN(m)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(m)}c&&(n[r]=p)}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 u=n[r];if(!this._isDynamic){var w={};for(var y in u)w[y]=u[y];n[r]=u=w}this._setupProperties(g,t[r],u,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=an()),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=an()),!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=Gi),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=Xt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=ji.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=an()),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,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},u=c(),p=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,m=this._chainedTweens.length;d<m;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},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})();Nr.nextId;var et=Gi;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var ln={Easing:Xt,Tween:qc};function Zc(){return new A.Scene}function Kc(o,e){o.appendChild(e.domElement)}function Yc(o,e,t){var n=new Object;n.visible=!0;let i=null,s,r,a=[];n.init=function(){s||(h(),c(),u())},n.Hide=function(){s.style.display="none",n.visible=!1},n.Show=function(){s.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);const d=new A.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(d.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(d){var m=new A.Vector3(0,0,0);d=="top"?m=new A.Vector3(0,1,1e-5):d=="down"?m=new A.Vector3(0,-1,1e-5):d=="front"?m=new A.Vector3(0,0,1):d=="left"?m=new A.Vector3(-1,0,0):d=="back"?m=new A.Vector3(0,0,-1):d=="right"?m=new A.Vector3(1,0,0):d=="top_front"?m=new A.Vector3(1,1,0):d=="top_left"?m=new A.Vector3(0,1,-1):d=="top_back"?m=new A.Vector3(-1,1,0):d=="top_right"?m=new A.Vector3(0,1,1):d=="down_front"?m=new A.Vector3(1,-1,0):d=="down_left"?m=new A.Vector3(0,-1,-1):d=="down_back"?m=new A.Vector3(-1,-1,0):d=="down_right"?m=new A.Vector3(0,-1,1):d=="front_right"?m=new A.Vector3(1,0,1):d=="right_back"?m=new A.Vector3(-1,0,1):d=="back_left"?m=new A.Vector3(-1,0,-1):d=="left_front"?m=new A.Vector3(1,0,-1):d=="top_left_front"?m=new A.Vector3(1,1,-1):d=="top_front_right"?m=new A.Vector3(1,1,1):d=="top_right_back"?m=new A.Vector3(-1,1,1):d=="top_back_left"?m=new A.Vector3(-1,1,-1):d=="button_left_front"?m=new A.Vector3(1,-1,-1):d=="button_front_right"?m=new A.Vector3(1,-1,1):d=="button_right_back"?m=new A.Vector3(-1,1,1):d=="button_back_left"&&(m=new A.Vector3(-1,-1,-1));var g=o.octreeBox.getBoundingBox(),y=g.min,w=g.max,x=y.clone().add(w.clone()).multiplyScalar(.5),b=x.clone().add(m.multiplyScalar(1*w.distanceTo(y)));l(e.camera.position,b,o.controls.target.clone(),x)},n.GetCameraPose=function(){var d=e.camera.quaternion,m=e.camera.position,g=o.controls.target,y={quaternion:d,position:m,target:g};return y},n.ReductionCameraPose=function(d,m=1e3,g){var y=new A.Quaternion(d.quaternion._x,d.quaternion._y,d.quaternion._z,d.quaternion._w),w=new A.Vector3(d.position.x,d.position.y,d.position.z),x=new A.Vector3(d.target.x,d.target.y,d.target.z);let b=!1;l(e.camera.position,w,o.controls.target.clone(),x,e.camera.quaternion,y,m,_=>{g&&(b||(g(_),b=!0))}),g&&setTimeout(()=>{b||(g(!0),b=!0)},m+10)},n.CameraGoHome=function(){var d=o.octreeBox.getBoundingBox(),m=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let g=new A.Vector3(1,1,1);var y=d.max.distanceTo(d.min),w=m.clone().add(g.multiplyScalar(y));if(e.camera.isOrthographicCamera){var x=o.container.clientWidth/o.container.clientHeight,b=y*.6;e.camera.left=-b*x,e.camera.right=b*x,e.camera.top=b,e.camera.bottom=-b,e.camera.zoom=1,e.camera.updateProjectionMatrix()}l(e.camera.position,w,o.controls.target.clone(),m)},n.zoomToBox=function(d){var m=d.min.clone().add(d.max.clone()).multiplyScalar(.5),g=e.camera.position.clone().sub(o.controls.target.clone()).normalize(),y=e.camera.position.distanceTo(o.controls.target),w=m.clone().add(g.multiplyScalar(y)),x=e.camera.zoom;if(e.camera.isOrthographicCamera){var b=new A.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),_=new A.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new A.Vector3(d.min.x,d.min.y,d.min.z),new A.Vector3(d.max.x,d.min.y,d.min.z),new A.Vector3(d.min.x,d.max.y,d.min.z),new A.Vector3(d.max.x,d.max.y,d.min.z),new A.Vector3(d.min.x,d.min.y,d.max.z),new A.Vector3(d.max.x,d.min.y,d.max.z),new A.Vector3(d.min.x,d.max.y,d.max.z),new A.Vector3(d.max.x,d.max.y,d.max.z)],P=1/0,k=-1/0,D=1/0,B=-1/0;for(var O of T){var C=O.dot(b),I=O.dot(_);P=Math.min(P,C),k=Math.max(k,C),D=Math.min(D,I),B=Math.max(B,I)}var v=(k-P)/2,z=(B-D)/2,q=(e.camera.right-e.camera.left)/2,G=(e.camera.top-e.camera.bottom)/2;x=Math.min(q/v,G/z)*.75}var ee=e.camera.position.clone(),X=o.controls.target.clone(),Q=e.camera.zoom,R=new ln.Tween({x1:ee.x,y1:ee.y,z1:ee.z,x2:X.x,y2:X.y,z2:X.z,zoom:Q}).to({x1:w.x,y1:w.y,z1:w.z,x2:m.x,y2:m.y,z2:m.z,zoom:x},1e3);R.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())}),R.onComplete(function(){o.controls&&(o.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),R.easing(ln.Easing.Cubic.InOut),R.start();function F(){i=requestAnimationFrame(F),R.update()}F()};function l(d,m,g,y,w,x,b=1e3,_){var T;w&&x?(T=new ln.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w}),T.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z,_x:x._x,_y:x._y,_z:x._z,_w:x._w},b)):(T=new ln.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z}),T.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z},b)),T.onUpdate(function(k){o.controls&&(w&&x?(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(),_&&_(!0),cancelAnimationFrame(i),i=null)}),T.easing(ln.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 d=document.createElement("div");d.className="homeViewWrapper",d.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(d);const m=document.createElement("div");m.className="cameraToggleWrapper",m.title="切换正交/透视视图",m.innerHTML="⊞",m.addEventListener("mousedown",function(b){b.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),w()}),s.appendChild(m);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(b){b.stopPropagation(),console.log("截图"),n.TakeScreenshot(),w()}),s.appendChild(g);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(b){b.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),w()}),s.appendChild(y),r.addEventListener("mousedown",function(b){b.stopPropagation(),m.classList.contains("show")?(w(),console.log("隐藏功能按钮")):(x(),console.log("显示功能按钮"))});function w(){m.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function x(){m.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function c(){n.sceneOrtho=Zc();var g=t.clientWidth,y=t.clientWidth,d=g>y?g/y:y/g,m=300;n.camera=new A.OrthographicCamera(m*d/-2,m*d/2,m/2,m/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,w=new A.WebGLRenderer({alpha:!0});w.setSize(g,y),w.setClearAlpha(0),n.sceneOrtho.renderer=w;let x=new A.AmbientLight(16777215,.8);n.sceneOrtho.add(x),Kc(s,w)}function u(){const d="/assets/viewcube/";let m=[{label:"右",icon:d+"cn_right.png"},{label:"左",icon:d+"cn_left.png"},{label:"顶",icon:d+"cn_top.png"},{label:"底",icon:d+"cn_bottom.png"},{label:"前",icon:d+"cn_front.png"},{label:"后",icon:d+"cn_back.png"}];var g=[];for(const w of m)g.push(new A.MeshBasicMaterial({color:16777215,map:new A.TextureLoader().load(w.icon)}));new A.MeshLambertMaterial({color:255});var y=new A.Mesh(new A.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),p(122),s.addEventListener("mousedown",w=>{var x={};x.x=w.offsetX/s.clientWidth*2-1,x.y=-(w.offsetY/s.clientHeight)*2+1;var b=new A.Raycaster;b.setFromCamera(x,n.camera);const _=b.intersectObjects(a,!1);_.length>0&&n.ToggleDirectionView(_[0].object.name)}),s.addEventListener("mousemove",w=>{var x={};x.x=w.offsetX/s.clientWidth*2-1,x.y=-(w.offsetY/s.clientHeight)*2+1;var b=new A.Raycaster;b.setFromCamera(x,n.camera);const _=b.intersectObjects(a,!1);for(var T of a)T.material.opacity=.01;_.length>0&&(_[0].object.material.opacity=.2)})}function p(d){for(var m=d*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new A.Vector3(m,0,0)},{name:"back",a:75,b:75,c:30,point:new A.Vector3(0,0,-m)},{name:"left",a:30,b:75,c:75,point:new A.Vector3(-m,0,0)},{name:"front",a:75,b:75,c:30,point:new A.Vector3(0,0,m)},{name:"top",a:75,b:30,c:75,point:new A.Vector3(0,m,0)},{name:"button",a:75,b:30,c:75,point:new A.Vector3(0,-m,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new A.Vector3(-m,m,m)},{name:"button_front_right",a:30,b:30,c:30,point:new A.Vector3(-m,-m,m)},{name:"top_front_right",a:30,b:30,c:30,point:new A.Vector3(m,m,m)},{name:"button_right_back",a:30,b:30,c:30,point:new A.Vector3(m,-m,m)},{name:"top_back_left",a:30,b:30,c:30,point:new A.Vector3(-m,m,-m)},{name:"button_back_left",a:30,b:30,c:30,point:new A.Vector3(-m,-m,-m)},{name:"top_left_front",a:30,b:30,c:30,point:new A.Vector3(m,m,-m)},{name:"button_left_front",a:30,b:30,c:30,point:new A.Vector3(m,-m,-m)}],w=[{name:"top_front",a:30,b:30,c:75,point:new A.Vector3(m,m,0)},{name:"top_right",a:75,b:30,c:30,point:new A.Vector3(0,m,m)},{name:"top_back",a:30,b:30,c:75,point:new A.Vector3(-m,m,0)},{name:"top_left",a:75,b:30,c:30,point:new A.Vector3(0,m,-m)},{name:"button_front",a:30,b:30,c:75,point:new A.Vector3(m,-m,0)},{name:"button_right",a:75,b:30,c:30,point:new A.Vector3(0,-m,m)},{name:"button_back",a:30,b:30,c:75,point:new A.Vector3(-m,-m,0)},{name:"button_left",a:75,b:30,c:30,point:new A.Vector3(0,-m,-m)},{name:"front_right",a:30,b:75,c:30,point:new A.Vector3(m,0,m)},{name:"right_back",a:30,b:75,c:30,point:new A.Vector3(-m,0,m)},{name:"back_left",a:30,b:75,c:30,point:new A.Vector3(-m,0,-m)},{name:"left_front",a:30,b:75,c:30,point:new A.Vector3(m,0,-m)}],x=0;x<g.length;x++)a.push(f(g[x]));for(var x=0;x<y.length;x++)a.push(f(y[x]));for(var x=0;x<w.length;x++)a.push(f(w[x]))}function f(d){const m=new A.BoxGeometry(d.a,d.b,d.c),g=new A.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new A.Matrix4().makeTranslation(d.point.x,d.point.y,d.point.z);let w=m.applyMatrix4(y),x=new A.Mesh(w,g);return x.name=d.name,n.sceneOrtho.add(x),x}return n.ToggleCameraType=function(){o.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!o.renderer){console.error("渲染器未初始化");return}o.renderer.render(e,e.camera);const m=o.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=m,g.click(),console.log("截图已保存")}catch(d){console.error("截图失败:",d)}},n.ToggleFullscreen=function(){const d=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(d.requestFullscreen?d.requestFullscreen():d.webkitRequestFullscreen?d.webkitRequestFullscreen():d.mozRequestFullScreen?d.mozRequestFullScreen():d.msRequestFullscreen&&d.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class $c{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Yc(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function Hc(o){let e=new Object;return e.getBoundingBox=function(){let t=o.models,n=new A.Vector3(1e8,1e9,1e10),i=new A.Vector3(-1e8,-1e9,-1e10);t.forEach(u=>{let p=u.boundingBox.min,f=u.boundingBox.max;p.x<n.x&&(n.x=p.x),p.y<n.y&&(n.y=p.y),p.z<n.z&&(n.z=p.z),f.x>i.x&&(i.x=f.x),f.y>i.y&&(i.y=f.y),f.z>i.z&&(i.z=f.z)});let s=Math.min(n.x,i.x),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 A.Vector3(s,r,a),max:new A.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)})}),t.intersectObjects(n,!1);function s(r,a,l){if(a==null)return;let h=new A.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),c=new A.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),u=new A.Vector3(Math.min(h.x,c.X),Math.min(h.y,c.y),Math.min(h.z,c.z)),p=new A.Vector3(Math.max(c.x,h.x),Math.max(c.y,h.y),Math.max(c.z,h.z)),f=new A.Box3(u,p),d=r.ray.intersectsBox(f);if(!(d==null||d==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var m of a.elements){let g=o.engineStatus.hideModels.find(b=>b.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let y=o.engineStatus.translucentModels.find(b=>b.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let x=o.models.find(b=>b.url==l.url).nodesMap.get(m);x!=null&&!x.instance&&x.infos.map(_=>_.mesh).forEach(_=>{n.push(_)})}}else{if(a.elements!=null)for(var m of a.elements){let y=o.engineStatus.hideModels.find(_=>_.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let w=o.engineStatus.translucentModels.find(_=>_.url==l.url)?.ids;if(w!=null&&w.includes(m))continue;let b=o.models.find(_=>_.url==l.url).nodesMap.get(m);b!=null&&!b.instance&&b.infos.map(T=>T.mesh).forEach(T=>{n.push(T)})}for(let g of a.children)s(r,g,l)}}},e}class Jc{engine;isDrawing=!1;startPoint=new A.Vector2;endPoint=new A.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 Fe(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 u=this.worldToScreen.screenToWorld(c.x,c.y);u&&a.push(u)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const h=new A.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 A.Vector3;e.getCenter(i);const s=new A.Vector3;e.getSize(s);const r=Math.max(s.x,s.y,s.z);if(t instanceof A.PerspectiveCamera){const a=t.fov*(Math.PI/180),h=r/(2*Math.tan(a/2))*1.2,c=new A.Vector3;t.getWorldDirection(c);const u=i.clone().sub(t.position);c.dot(u.normalize())<0&&c.negate();const f=i.clone().sub(c.multiplyScalar(h));t.position.copy(f),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof A.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 u=new A.Vector3;t.getWorldDirection(u);const p=r*1.5,f=i.clone().sub(u.multiplyScalar(p));t.position.copy(f),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class Qc{engine;ground=null;constructor(e){this.engine=e}init(){}setStatsVisible(e){this.engine.stats?.dom&&(this.engine.stats.dom.style.display=e?"block":"none")}setAmbientLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof A.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof A.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof A.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof A.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof A.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 A.DirectionalLight);t&&(t.castShadow=e),this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e)}setGTAOEnabled(e){if(!this.engine.composerModule?.composer){console.warn("Composer not initialized");return}const t=this.engine.composerModule.composer,n=t.passes.find(i=>i instanceof ze);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),r=new ze(this.engine.scene,this.engine.camera,i,s);r.output=ze.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 A.PlaneGeometry(n,n),a=new A.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:A.DoubleSide});this.ground=new A.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 nt(){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 it{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=_i(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(d=>{f(d)}),this.engine.measure.annotationData.elevationAnnotation.forEach(d=>{p(d)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(d=>{u(d)}),this.engine.measure.annotationData.angleAnnotation.forEach(d=>{l(d)}),this.engine.measure.annotationData.areaAnnotation.forEach(d=>{h(d)}),this.engine.measure.annotationData.slopeAnnotation.forEach(d=>{c(d)});function l(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="angle-annotation",d.container.id=d.id,d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point3),w=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;m.x+=w,m.y+=x,g.x+=w,g.y+=x,y.x+=w,y.y+=x;let b=d.container;b.getElementsByTagName("circle")[0].setAttribute("cx",m.x),b.getElementsByTagName("circle")[0].setAttribute("cy",m.y),b.getElementsByTagName("circle")[1].setAttribute("cx",g.x),b.getElementsByTagName("circle")[1].setAttribute("cy",g.y),b.getElementsByTagName("circle")[2].setAttribute("cx",y.x),b.getElementsByTagName("circle")[2].setAttribute("cy",y.y),b.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y),b.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let _=g.x,T=g.y-30;b.getElementsByTagName("rect")[0].setAttribute("x",_-40),b.getElementsByTagName("rect")[0].setAttribute("y",T-12.5),b.getElementsByTagName("text")[0].setAttribute("x",_),b.getElementsByTagName("text")[0].setAttribute("y",T+4),b.getElementsByTagName("text")[0].innerHTML=d.text,b.style.top="0px",b.style.left="0px"}function h(d){if(d.container==null){let k=['<svg class="measureSvg">','<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,2)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="area-annotation",d.container.id=d.id,d.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}if(!d.points||d.points.length<3)return;let m=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],w=0,x=0;for(let k=0;k<d.points.length;k++){let D=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.points[k]);D.x+=m,D.y+=g,y.push(D),w+=D.x,x+=D.y}w=w/y.length,x=x/y.length;let b=y.map(k=>k.x+","+k.y).join(" "),_=d.container;_.getElementsByTagName("polygon")[0].setAttribute("points",b),_.getElementsByTagName("polyline")[0].setAttribute("points",b);let T=w,P=x;_.getElementsByTagName("rect")[0].setAttribute("x",T-40),_.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),_.getElementsByTagName("text")[0].setAttribute("x",T),_.getElementsByTagName("text")[0].setAttribute("y",P+4),_.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,2),_.style.top="0px",_.style.left="0px"}function c(d){if(d.container==null){let T=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+d.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+d.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="slope-annotation",d.container.id=d.id,d.container.innerHTML=T,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.x+=y,m.y+=w,g.x+=y,g.y+=w;let x=d.container;x.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y);let b=(m.x+g.x)/2,_=(m.y+g.y)/2-30;x.getElementsByTagName("rect")[0].setAttribute("x",b-50),x.getElementsByTagName("rect")[0].setAttribute("y",_-12.5),x.getElementsByTagName("text")[0].setAttribute("x",b),x.getElementsByTagName("text")[0].setAttribute("y",_+4),x.getElementsByTagName("text")[0].innerHTML=d.text,x.style.top="0px",x.style.left="0px"}function u(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(d.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-d.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(d.textY,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="coordinate-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container,g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=w,m.style.top="0px",m.style.left="0px";let x=m.getElementsByTagName("circle")[0];x&&(x.setAttribute("cx",g.x),x.setAttribute("cy",g.y));let b=m.getElementsByTagName("rect"),_=m.getElementsByTagName("text"),T=-55;b[0]&&(b[0].setAttribute("x",g.x+10),b[0].setAttribute("y",g.y+10+T)),_[0]&&(_[0].setAttribute("x",g.x+10+40),_[0].setAttribute("y",g.y+10+16+T)),b[1]&&(b[1].setAttribute("x",g.x+10),b[1].setAttribute("y",g.y+10+30+T)),_[1]&&(_[1].setAttribute("x",g.x+10+40),_[1].setAttribute("y",g.y+10+46+T)),b[2]&&(b[2].setAttribute("x",g.x+10),b[2].setAttribute("y",g.y+10+60+T)),_[2]&&(_[2].setAttribute("x",g.x+10+40),_[2].setAttribute("y",g.y+10+76+T)),_[0]&&(_[0].innerHTML="X: "+e.getMeasureText(d.textX,1)),_[1]&&(_[1].innerHTML="Y: "+e.getMeasureText(-d.textZ,1)),_[2]&&(_[2].innerHTML="Z: "+e.getMeasureText(d.textY,1))}function p(d){if(d.container==null){let x=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");d.container=document.createElement("div"),d.container.className="elevation-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container,g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.style.top=g.y+w-48+"px",m.style.left=g.x+y-16+"px",m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1)}function f(d){if(d.container==null){let b=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="normal-annotation",d.container.id=d.id,d.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(ve.MeasureClick,d)})}let m=d.container;if(d.point1==null||d.point2==null){m.style.display="none";return}else m.style.display="block";let g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),y=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),w=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;g.x+=w,g.y+=x,y.x+=w,y.y+=x,m.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),m.getElementsByTagName("circle")[0].setAttribute("cx",g.x),m.getElementsByTagName("circle")[0].setAttribute("cy",g.y),m.getElementsByTagName("circle")[1].setAttribute("cx",y.x),m.getElementsByTagName("circle")[1].setAttribute("cy",y.y),m.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),m.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),m.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1),m.style.top="0px",m.style.left="0px"}}}class eh{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();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 A.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:nt(),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 A.Raycaster(i.add(new A.Vector3(0,.01,0)),new A.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(ve.MeasureChanged,t)}else{let i=new A.Raycaster(e.catch.point.clone().add(new A.Vector3(0,.01,0)),new A.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(ve.MeasureChanged,t)}}}class th{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();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(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:nt(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class nh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();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:nt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new A.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(ve.MeasureChanged,t)}}class ih{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;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:nt(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(ve.MeasureChanged,t))}}class sh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;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.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,this.engine.events.trigger(ve.MeasureChanged,t))}}class rh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();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 A.Vector3().subVectors(e,t),s=new A.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(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:nt(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class oh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();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:nt(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:nt(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(ve.MeasureChanged,e))}}class ah{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new it(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();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(ve.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);n==null&&(n={id:nt(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class lh{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new eh(e),this.distanceMeasure=new th(e),this.clearDistanceMeasure=new nh(e),this.elevationMeasure=new ih(e),this.pointMeasure=new sh(e),this.angleMeasure=new rh(e),this.areaMeasure=new oh(e),this.slopeMeasure=new ah(e),this.tools=new it(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.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 Rr=0,ch=1,hh=2,Fr=2,Xi=1.25,Ur=1,Ie=32,Me=Ie/4,Vr=65535,uh=Math.pow(2,-24),Wi=Symbol("SKIP_GENERATION");function dh(o){return o.index?o.index.count:o.attributes.position.count}function Ct(o){return dh(o)/3}function fh(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function ph(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=fh(t,n);o.setIndex(new S.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function jr(o,e){const t=Ct(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 Gr(o,e){if(!o.groups||!o.groups.length)return jr(o,e);const t=[],n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=Ct(o),a=[];for(const c of o.groups){const{start:u,count:p}=c,f=u/3,d=isFinite(p)?p:r*3-u,m=(u+d)/3;f<s&&m>i&&(a.push({pos:Math.max(i,f),isStart:!0}),a.push({pos:Math.min(s,m),isStart:!1}))}a.sort((c,u)=>c.pos!==u.pos?c.pos-u.pos:c.type==="end"?-1:1);let l=0,h=null;for(const c of a){const u=c.pos;l!==0&&u!==h&&t.push({offset:h,count:u-h}),l+=c.isStart?1:-1,h=u}return t}function qi(o,e,t,n,i){let s=1/0,r=1/0,a=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,p=1/0,f=1/0,d=-1/0,m=-1/0,g=-1/0;const y=o.offset||0;for(let w=(e-y)*6,x=(e+t-y)*6;w<x;w+=6){const b=o[w+0],_=o[w+1],T=b-_,P=b+_;T<s&&(s=T),P>l&&(l=P),b<u&&(u=b),b>d&&(d=b);const k=o[w+2],D=o[w+3],B=k-D,O=k+D;B<r&&(r=B),O>h&&(h=O),k<p&&(p=k),k>m&&(m=k);const C=o[w+4],I=o[w+5],v=C-I,z=C+I;v<a&&(a=v),z>c&&(c=z),C<f&&(f=C),C>g&&(g=C)}n[0]=s,n[1]=r,n[2]=a,n[3]=l,n[4]=h,n[5]=c,i[0]=u,i[1]=p,i[2]=f,i[3]=d,i[4]=m,i[5]=g}function Xr(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 u=["getX","getY","getZ"],p=i.offset;for(let f=e,d=e+t;f<d;f++){const g=(n?n[f]:f)*3,y=(f-p)*6;let w=g+0,x=g+1,b=g+2;r&&(w=r[w],x=r[x],b=r[b]),a||(w=w*c+h,x=x*c+h,b=b*c+h);for(let _=0;_<3;_++){let T,P,k;a?(T=s[u[_]](w),P=s[u[_]](x),k=s[u[_]](b)):(T=l[w+_],P=l[x+_],k=l[b+_]);let D=T;P<D&&(D=P),k<D&&(D=k);let B=T;P>B&&(B=P),k>B&&(B=k);const O=(B-D)/2,C=_*2;i[y+C+0]=D+O,i[y+C+1]=O+(Math.abs(D)+O)*uh}}return i}function we(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 Wr(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 qr(o,e){e.set(o)}function Zr(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 Xn(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 cn(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 st=32,mh=(o,e)=>o.candidate-e.candidate,dt=new Array(st).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Wn=new Float32Array(6);function gh(o,e,t,n,i,s){let r=-1,a=0;if(s===Rr)r=Wr(e),r!==-1&&(a=(e[r]+e[r+3])/2);else if(s===ch)r=Wr(o),r!==-1&&(a=yh(t,n,i,r));else if(s===hh){const l=cn(o);let h=Xi*i;const c=t.offset||0,u=(n-c)*6,p=(n+i-c)*6;for(let f=0;f<3;f++){const d=e[f],y=(e[f+3]-d)/st;if(i<st/4){const w=[...dt];w.length=i;let x=0;for(let _=u;_<p;_+=6,x++){const T=w[x];T.candidate=t[_+2*f],T.count=0;const{bounds:P,leftCacheBounds:k,rightCacheBounds:D}=T;for(let B=0;B<3;B++)D[B]=1/0,D[B+3]=-1/0,k[B]=1/0,k[B+3]=-1/0,P[B]=1/0,P[B+3]=-1/0;Xn(_,t,P)}w.sort(mh);let b=i;for(let _=0;_<b;_++){const T=w[_];for(;_+1<b&&w[_+1].candidate===T.candidate;)w.splice(_+1,1),b--}for(let _=u;_<p;_+=6){const T=t[_+2*f];for(let P=0;P<b;P++){const k=w[P];T>=k.candidate?Xn(_,t,k.rightCacheBounds):(Xn(_,t,k.leftCacheBounds),k.count++)}}for(let _=0;_<b;_++){const T=w[_],P=T.count,k=i-T.count,D=T.leftCacheBounds,B=T.rightCacheBounds;let O=0;P!==0&&(O=cn(D)/l);let C=0;k!==0&&(C=cn(B)/l);const I=Ur+Xi*(O*P+C*k);I<h&&(r=f,h=I,a=T.candidate)}}else{for(let b=0;b<st;b++){const _=dt[b];_.count=0,_.candidate=d+y+b*y;const T=_.bounds;for(let P=0;P<3;P++)T[P]=1/0,T[P+3]=-1/0}for(let b=u;b<p;b+=6){let P=~~((t[b+2*f]-d)/y);P>=st&&(P=st-1);const k=dt[P];k.count++,Xn(b,t,k.bounds)}const w=dt[st-1];qr(w.bounds,w.rightCacheBounds);for(let b=st-2;b>=0;b--){const _=dt[b],T=dt[b+1];Zr(_.bounds,T.rightCacheBounds,_.rightCacheBounds)}let x=0;for(let b=0;b<st-1;b++){const _=dt[b],T=_.count,P=_.bounds,D=dt[b+1].rightCacheBounds;T!==0&&(x===0?qr(P,Wn):Zr(P,Wn,Wn)),x+=T;let B=0,O=0;x!==0&&(B=cn(Wn)/l);const C=i-x;C!==0&&(O=cn(D)/l);const I=Ur+Xi*(B*x+O*C);I<h&&(r=f,h=I,a=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:r,pos:a}}function yh(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 Zi{constructor(){this.boundingData=new Float32Array(6)}}function wh(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 u=0;u<3;u++){let p=e[r*3+u];e[r*3+u]=e[a*3+u],e[a*3+u]=p}for(let u=0;u<6;u++){const p=r-c,f=a-c,d=t[p*6+u];t[p*6+u]=t[f*6+u],t[f*6+u]=d}r++,a--}else return r}}function xh(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 u=o[r];o[r]=o[a],o[a]=u;for(let p=0;p<6;p++){const f=r-c,d=a-c,m=t[f*6+p];t[f*6+p]=t[d*6+p],t[d*6+p]=m}r++,a--}else return r}}let Kr,qn,Ki,Yr;const bh=Math.pow(2,32);function Yi(o){return"count"in o?1:1+Yi(o.left)+Yi(o.right)}function _h(o,e,t){return Kr=new Float32Array(t),qn=new Uint32Array(t),Ki=new Uint16Array(t),Yr=new Uint8Array(t),$i(o,e)}function $i(o,e){const t=o/4,n=o/2,i="count"in e,s=e.boundingData;for(let r=0;r<6;r++)Kr[t+r]=s[r];if(i)return e.buffer?(Yr.set(new Uint8Array(e.buffer),o),o+e.buffer.byteLength):(qn[t+6]=e.offset,Ki[n+14]=e.count,Ki[n+15]=Vr,o+Ie);{const{left:r,right:a,splitAxis:l}=e,h=o+Ie;let c=$i(h,r);const u=o/Ie,f=c/Ie-u;if(f>bh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return qn[t+6]=f,qn[t+7]=l,$i(c,a)}}function vh(o,e,t){const i=(o.index?o.index.count:o.attributes.position.count)/3>2**16,s=t.reduce((c,u)=>c+u.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:u,count:p}=t[c];for(let f=0;f<p;f++)l[h+f]=u+f;h+=p}return l}function Mh(o,e,t,n,i){const{maxDepth:s,verbose:r,maxLeafTris:a,strategy:l,onProgress:h,indirect:c}=i,u=o._indirectBuffer,p=o.geometry,f=p.index?p.index.array:null,d=c?xh:wh,m=Ct(p),g=new Float32Array(6);let y=!1;const w=new Zi;return qi(e,t,n,w.boundingData,g),b(w,t,n,g),w;function x(_){h&&h(_/m)}function b(_,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(p))),P<=a||D>=s)return x(T+P),_.offset=T,_.count=P,_;const B=gh(_.boundingData,k,e,T,P,l);if(B.axis===-1)return x(T+P),_.offset=T,_.count=P,_;const O=d(u,f,e,T,P,B);if(O===T||O===T+P)x(T+P),_.offset=T,_.count=P;else{_.splitAxis=B.axis;const C=new Zi,I=T,v=O-T;_.left=C,qi(e,I,v,C.boundingData,g),b(C,I,v,g,D+1);const z=new Zi,q=O,G=P-v;_.right=z,qi(e,q,G,z.boundingData,g),b(z,q,G,g,D+1)}return _}}function Sh(o,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=o.geometry;let i,s;if(e.indirect){const r=Gr(n,e.range),a=vh(n,e.useSharedArrayBuffer,r);o._indirectBuffer=a,i=Xr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{ph(n,e);const r=jr(n,e.range)[0];i=Xr(n,r.offset,r.count),s=Gr(n,e.range)}o._roots=s.map(r=>{const a=Mh(o,i,r.offset,r.count,e),l=Yi(a),h=new t(Ie*l);return _h(0,a,h),h})}class rt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,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}}rt.prototype.setFromBox=(function(){const o=new S.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 u=t.dot(o);r=Math.min(u,r),a=Math.max(u,a)}this.min=r,this.max=a}})();const Ah=(function(){const o=new S.Vector3,e=new S.Vector3,t=new S.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 u=t.dot(c),p=c.dot(l),f=c.dot(c),d=t.dot(l),g=l.dot(l)*f-p*p;let y,w;g!==0?y=(u*p-d*f)/g:y=0,w=(u+y*p)/f,r.x=y,r.y=w}})(),Hi=(function(){const o=new S.Vector2,e=new S.Vector3,t=new S.Vector3;return function(i,s,r,a){Ah(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 u;h<0?u=s.start:u=s.end;const p=e,f=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(c,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(c)){r.copy(p),a.copy(u);return}else{r.copy(c),a.copy(f);return}}}})(),Ch=(function(){const o=new S.Vector3,e=new S.Vector3,t=new S.Plane,n=new S.Line3;return function(s,r){const{radius:a,center:l}=s,{a:h,b:c,c:u}=r;if(n.start=h,n.end=c,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(n.start=h,n.end=u,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(n.start=c,n.end=u,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const m=r.getPlane(t);if(Math.abs(m.distanceToPoint(l))<=a){const y=m.projectPoint(l,e);if(r.containsPoint(y))return!0}return!1}})(),Th=["x","y","z"],ot=1e-15,$r=ot*ot;function je(o){return Math.abs(o)<ot}class Ge extends S.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new S.Vector3),this.satBounds=new Array(4).fill().map(()=>new rt),this.points=[this.a,this.b,this.c],this.plane=new S.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new S.Line3,this.needsUpdate=!0}intersectsSphere(e){return Ch(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 u=s[2],p=r[2];u.subVectors(t,n),p.setFromPoints(u,i);const f=s[3],d=r[3];f.subVectors(n,e),d.setFromPoints(f,i);const m=h.length(),g=u.length(),y=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<ot?g<ot||y<ot?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ot?y<ot?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ot&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Ge.prototype.closestPointToSegment=(function(){const o=new S.Vector3,e=new S.Vector3,t=new S.Line3;return function(i,s=null,r=null){const{start:a,end:l}=i,h=this.points;let c,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(h[p]),t.end.copy(h[f]),Hi(t,i,o,e),c=o.distanceToSquared(e),c<u&&(u=c,s&&s.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),c=a.distanceToSquared(o),c<u&&(u=c,s&&s.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),c=l.distanceToSquared(o),c<u&&(u=c,s&&s.copy(o),r&&r.copy(l)),Math.sqrt(u)}})(),Ge.prototype.intersectsTriangle=(function(){const o=new Ge,e=new rt,t=new rt,n=new S.Vector3,i=new S.Vector3,s=new S.Vector3,r=new S.Vector3,a=new S.Line3,l=new S.Line3,h=new S.Vector3,c=new S.Vector2,u=new S.Vector2;function p(x,b,_,T){const P=n;!x.isDegenerateIntoPoint&&!x.isDegenerateIntoSegment?P.copy(x.plane.normal):P.copy(b.plane.normal);const k=x.satBounds,D=x.satAxes;for(let C=1;C<4;C++){const I=k[C],v=D[C];if(e.setFromPoints(v,b.points),I.isSeparated(e)||(r.copy(P).cross(v),e.setFromPoints(r,x.points),t.setFromPoints(r,b.points),e.isSeparated(t)))return!1}const B=b.satBounds,O=b.satAxes;for(let C=1;C<4;C++){const I=B[C],v=O[C];if(e.setFromPoints(v,x.points),I.isSeparated(e)||(r.crossVectors(P,v),e.setFromPoints(r,x.points),t.setFromPoints(r,b.points),e.isSeparated(t)))return!1}return _&&(T||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}function f(x,b,_,T,P,k,D,B,O,C,I){let v=D/(D-B);C.x=T+(P-T)*v,I.start.subVectors(b,x).multiplyScalar(v).add(x),v=D/(D-O),C.y=T+(k-T)*v,I.end.subVectors(_,x).multiplyScalar(v).add(x)}function d(x,b,_,T,P,k,D,B,O,C,I){if(P>0)f(x.c,x.a,x.b,T,b,_,O,D,B,C,I);else if(k>0)f(x.b,x.a,x.c,_,b,T,B,D,O,C,I);else if(B*O>0||D!=0)f(x.a,x.b,x.c,b,_,T,D,B,O,C,I);else if(B!=0)f(x.b,x.a,x.c,_,b,T,B,D,O,C,I);else if(O!=0)f(x.c,x.a,x.b,T,b,_,O,D,B,C,I);else return!0;return!1}function m(x,b,_,T){const P=b.degenerateSegment,k=x.plane.distanceToPoint(P.start),D=x.plane.distanceToPoint(P.end);return je(k)?je(D)?p(x,b,_,T):(_&&(_.start.copy(P.start),_.end.copy(P.start)),x.containsPoint(P.start)):je(D)?(_&&(_.start.copy(P.end),_.end.copy(P.end)),x.containsPoint(P.end)):x.plane.intersectLine(P,n)!=null?(_&&(_.start.copy(n),_.end.copy(n)),x.containsPoint(n)):!1}function g(x,b,_){const T=b.a;return je(x.plane.distanceToPoint(T))&&x.containsPoint(T)?(_&&(_.start.copy(T),_.end.copy(T)),!0):!1}function y(x,b,_){const T=x.degenerateSegment,P=b.a;return T.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<$r?(_&&(_.start.copy(P),_.end.copy(P)),!0):!1}function w(x,b,_,T){if(x.isDegenerateIntoSegment)if(b.isDegenerateIntoSegment){const P=x.degenerateSegment,k=b.degenerateSegment,D=i,B=s;P.delta(D),k.delta(B);const O=n.subVectors(k.start,P.start),C=D.x*B.y-D.y*B.x;if(je(C))return!1;const I=(O.x*B.y-O.y*B.x)/C,v=-(D.x*O.y-D.y*O.x)/C;if(I<0||I>1||v<0||v>1)return!1;const z=P.start.z+D.z*I,q=k.start.z+B.z*v;return je(z-q)?(_&&(_.start.copy(P.start).addScaledVector(D,I),_.end.copy(P.start).addScaledVector(D,I)),!0):!1}else return b.isDegenerateIntoPoint?y(x,b,_):m(b,x,_,T);else{if(x.isDegenerateIntoPoint)return b.isDegenerateIntoPoint?b.a.distanceToSquared(x.a)<$r?(_&&(_.start.copy(x.a),_.end.copy(x.a)),!0):!1:b.isDegenerateIntoSegment?y(b,x,_):g(b,x,_);if(b.isDegenerateIntoPoint)return g(x,b,_);if(b.isDegenerateIntoSegment)return m(x,b,_,T)}}return function(b,_=null,T=!1){this.needsUpdate&&this.update(),b.isExtendedTriangle?b.needsUpdate&&b.update():(o.copy(b),o.update(),b=o);const P=w(this,b,_,T);if(P!==void 0)return P;const k=this.plane,D=b.plane;let B=D.distanceToPoint(this.a),O=D.distanceToPoint(this.b),C=D.distanceToPoint(this.c);je(B)&&(B=0),je(O)&&(O=0),je(C)&&(C=0);const I=B*O,v=B*C;if(I>0&&v>0)return!1;let z=k.distanceToPoint(b.a),q=k.distanceToPoint(b.b),G=k.distanceToPoint(b.c);je(z)&&(z=0),je(q)&&(q=0),je(G)&&(G=0);const ee=z*q,X=z*G;if(ee>0&&X>0)return!1;i.copy(k.normal),s.copy(D.normal);const Q=i.cross(s);let R=0,F=Math.abs(Q.x);const te=Math.abs(Q.y);te>F&&(F=te,R=1),Math.abs(Q.z)>F&&(R=2);const Y=Th[R],de=this.a[Y],fe=this.b[Y],se=this.c[Y],oe=b.a[Y],he=b.b[Y],pe=b.c[Y];if(d(this,de,fe,se,I,v,B,O,C,c,a))return p(this,b,_,T);if(d(b,oe,he,pe,ee,X,z,q,G,u,l))return p(this,b,_,T);if(c.y<c.x){const Ae=c.y;c.y=c.x,c.x=Ae,h.copy(a.start),a.start.copy(a.end),a.end.copy(h)}if(u.y<u.x){const Ae=u.y;u.y=u.x,u.x=Ae,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return c.y<u.x||u.y<c.x?!1:(_&&(u.x>c.x?_.start.copy(l.start):_.start.copy(a.start),u.y<c.y?_.end.copy(l.end):_.end.copy(a.end)),!0)}})(),Ge.prototype.distanceToPoint=(function(){const o=new S.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ge.prototype.distanceToTriangle=(function(){const o=new S.Vector3,e=new S.Vector3,t=["a","b","c"],n=new S.Line3,i=new S.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 u=0;u<3;u++){let p;const f=t[u],d=r[f];this.closestPointToPoint(d,o),p=d.distanceToSquared(o),p<c&&(c=p,a&&a.copy(o),l&&l.copy(d));const m=this[f];r.closestPointToPoint(m,o),p=m.distanceToSquared(o),p<c&&(c=p,a&&a.copy(m),l&&l.copy(o))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let d=0;d<3;d++){const m=t[d],g=t[(d+1)%3];i.set(r[m],r[g]),Hi(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 Ee{constructor(e,t,n){this.isOrientedBox=!0,this.min=new S.Vector3,this.max=new S.Vector3,this.matrix=new S.Matrix4,this.invMatrix=new S.Matrix4,this.points=new Array(8).fill().map(()=>new S.Vector3),this.satAxes=new Array(3).fill().map(()=>new S.Vector3),this.satBounds=new Array(3).fill().map(()=>new rt),this.alignedSatBounds=new Array(3).fill().map(()=>new rt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ee.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let h=0;h<=1;h++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){const p=1*h|2*c|4*u,f=i[p];f.x=h?n.x:t.x,f.y=c?n.y:t.y,f.z=u?n.z:t.z,f.applyMatrix4(e)}const s=this.satBounds,r=this.satAxes,a=i[0];for(let h=0;h<3;h++){const c=r[h],u=s[h],p=1<<h,f=i[p];c.subVectors(a,f),u.setFromPoints(c,i)}const l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Ee.prototype.intersectsBox=(function(){const o=new rt;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}})(),Ee.prototype.intersectsTriangle=(function(){const o=new Ge,e=new Array(3),t=new rt,n=new rt,i=new S.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 p=0;p<3;p++){const f=a[p],d=l[p];if(t.setFromPoints(d,e),f.isSeparated(t))return!1}const h=r.satBounds,c=r.satAxes,u=this.points;for(let p=0;p<3;p++){const f=h[p],d=c[p];if(t.setFromPoints(d,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=l[p];for(let d=0;d<4;d++){const m=c[d];if(i.crossVectors(f,m),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}})(),Ee.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),Ee.prototype.distanceToPoint=(function(){const o=new S.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ee.prototype.distanceToBox=(function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new S.Line3),t=new Array(12).fill().map(()=>new S.Line3),n=new S.Vector3,i=new S.Vector3;return function(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,u=r.min,p=r.max,f=this.points;let d=1/0;for(let g=0;g<8;g++){const y=f[g];i.copy(y).clamp(u,p);const w=y.distanceToSquared(i);if(w<d&&(d=w,l&&l.copy(y),h&&h.copy(i),w<c))return Math.sqrt(w)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){const x=(g+1)%3,b=(g+2)%3,_=y<<x|w<<b,T=1<<g|y<<x|w<<b,P=f[_],k=f[T];e[m].set(P,k);const B=o[g],O=o[x],C=o[b],I=t[m],v=I.start,z=I.end;v[B]=u[B],v[O]=y?u[O]:p[O],v[C]=w?u[C]:p[O],z[B]=p[B],z[O]=y?u[O]:p[O],z[C]=w?u[C]:p[O],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){i.x=g?p.x:u.x,i.y=y?p.y:u.y,i.z=w?p.z:u.z,this.closestPointToPoint(i,n);const x=i.distanceToSquared(n);if(x<d&&(d=x,l&&l.copy(n),h&&h.copy(i),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){const y=e[g];for(let w=0;w<12;w++){const x=t[w];Hi(y,x,n,i);const b=n.distanceToSquared(i);if(b<d&&(d=b,l&&l.copy(n),h&&h.copy(i),b<c))return Math.sqrt(b)}}return Math.sqrt(d)}})();class Ji{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Ph extends Ji{constructor(){super(()=>new Ge)}}const Xe=new Ph;function Se(o,e){return e[o+15]===Vr}function Ue(o,e){return e[o+6]}function We(o,e){return e[o+14]}function Te(o){return o+Me}function Pe(o,e){const t=e[o+6];return o+t*Me}function Qi(o,e){return e[o+7]}function Xd(o){return o}class Dh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const me=new Dh;let ft,Wt;const qt=[],Zn=new Ji(()=>new S.Box3);function kh(o,e,t,n,i,s){ft=Zn.getPrimitive(),Wt=Zn.getPrimitive(),qt.push(ft,Wt),me.setBuffer(o._roots[e]);const r=es(0,o.geometry,t,n,i,s);me.clearBuffer(),Zn.releasePrimitive(ft),Zn.releasePrimitive(Wt),qt.pop(),qt.pop();const a=qt.length;return a>0&&(Wt=qt[a-1],ft=qt[a-2]),r}function es(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 p=Ue(o,h),f=We(c,l);return we(o,a,ft),n(p,f,!1,r,s+o/Me,ft)}else{let B=function(C){const{uint16Array:I,uint32Array:v}=me;let z=C*2;for(;!Se(z,I);)C=Te(C),z=C*2;return Ue(C,v)},O=function(C){const{uint16Array:I,uint32Array:v}=me;let z=C*2;for(;!Se(z,I);)C=Pe(C,v),z=C*2;return Ue(C,v)+We(z,I)};const p=Te(o),f=Pe(o,h);let d=p,m=f,g,y,w,x;if(i&&(w=ft,x=Wt,we(d,a,w),we(m,a,x),g=i(w),y=i(x),y<g)){d=f,m=p;const C=g;g=y,y=C,w=x}w||(w=ft,we(d,a,w));const b=Se(d*2,l),_=t(w,b,g,r+1,s+d/Me);let T;if(_===Fr){const C=B(d),v=O(d)-C;T=n(C,v,!0,r+1,s+d/Me,w)}else T=_&&es(d,e,t,n,i,s,r+1);if(T)return!0;x=Wt,we(m,a,x);const P=Se(m*2,l),k=t(x,P,y,r+1,s+m/Me);let D;if(k===Fr){const C=B(m),v=O(m)-C;D=n(C,v,!0,r+1,s+m/Me,x)}else D=k&&es(m,e,t,n,i,s,r+1);return!!D}}const hn=new S.Vector3,ts=new S.Vector3;function Ih(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=>(hn.copy(e).clamp(c.min,c.max),hn.distanceToSquared(e)),intersectsBounds:(c,u,p)=>p<a&&p<r,intersectsTriangle:(c,u)=>{c.closestPointToPoint(e,hn);const p=e.distanceToSquared(hn);return p<a&&(ts.copy(hn),a=p,l=u),p<s}}),a===1/0)return null;const h=Math.sqrt(a);return t.point?t.point.copy(ts):t.point=ts.clone(),t.distance=h,t.faceIndex=l,t}const Kn=parseInt(S.REVISION)>=169,Eh=parseInt(S.REVISION)<=161,Tt=new S.Vector3,Pt=new S.Vector3,Dt=new S.Vector3,Yn=new S.Vector2,$n=new S.Vector2,Hn=new S.Vector2,Hr=new S.Vector3,Jr=new S.Vector3,Qr=new S.Vector3,un=new S.Vector3;function Bh(o,e,t,n,i,s,r,a){let l;if(s===S.BackSide?l=o.intersectTriangle(n,t,e,!0,i):l=o.intersectTriangle(e,t,n,s!==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 eo(o,e,t,n,i,s,r,a,l,h,c){Tt.fromBufferAttribute(e,s),Pt.fromBufferAttribute(e,r),Dt.fromBufferAttribute(e,a);const u=Bh(o,Tt,Pt,Dt,un,l,h,c);if(u){if(n){Yn.fromBufferAttribute(n,s),$n.fromBufferAttribute(n,r),Hn.fromBufferAttribute(n,a),u.uv=new S.Vector2;const f=S.Triangle.getInterpolation(un,Tt,Pt,Dt,Yn,$n,Hn,u.uv);Kn||(u.uv=f)}if(i){Yn.fromBufferAttribute(i,s),$n.fromBufferAttribute(i,r),Hn.fromBufferAttribute(i,a),u.uv1=new S.Vector2;const f=S.Triangle.getInterpolation(un,Tt,Pt,Dt,Yn,$n,Hn,u.uv1);Kn||(u.uv1=f),Eh&&(u.uv2=u.uv1)}if(t){Hr.fromBufferAttribute(t,s),Jr.fromBufferAttribute(t,r),Qr.fromBufferAttribute(t,a),u.normal=new S.Vector3;const f=S.Triangle.getInterpolation(un,Tt,Pt,Dt,Hr,Jr,Qr,u.normal);u.normal.dot(o.direction)>0&&u.normal.multiplyScalar(-1),Kn||(u.normal=f)}const p={a:s,b:r,c:a,normal:new S.Vector3,materialIndex:0};if(S.Triangle.getNormal(Tt,Pt,Dt,p.normal),u.face=p,u.faceIndex=s,Kn){const f=new S.Vector3;S.Triangle.getBarycoord(un,Tt,Pt,Dt,f),u.barycoord=f}}return u}function to(o){return o&&o.isMaterial?o.side:o}function Jn(o,e,t,n,i,s,r){const a=n*3;let l=a+0,h=a+1,c=a+2;const{index:u,groups:p}=o;o.index&&(l=u.getX(l),h=u.getX(h),c=u.getX(c));const{position:f,normal:d,uv:m,uv1:g}=o.attributes;if(Array.isArray(e)){const y=n*3;for(let w=0,x=p.length;w<x;w++){const{start:b,count:_,materialIndex:T}=p[w];if(y>=b&&y<b+_){const P=to(e[T]),k=eo(t,f,d,m,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=to(e),w=eo(t,f,d,m,g,l,h,c,y,s,r);if(w)if(w.faceIndex=n,w.face.materialIndex=0,i)i.push(w);else return w}return null}function _e(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 Lh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:h}=o;for(let c=n,u=n+i;c<u;c++)Jn(l,e,t,c,s,r,a)}function Oh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let h=1/0,c=null;for(let u=n,p=n+i;u<p;u++){let f;f=Jn(a,e,t,u,null,s,r),f&&f.distance<h&&(c=f,h=f.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,u=e+o;c<u;c++){let p;if(p=c,_e(r,p*3,l,h),r.needsUpdate=!0,n(r,p,i,s))return!0}return!1}function Nh(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 p=0,f=c.length;p<f;p++)s=c[p],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(p,f,d=!1){const m=p*2;if(Se(m,a)){const g=r[p+6],y=a[m+14];let w=1/0,x=1/0,b=1/0,_=-1/0,T=-1/0,P=-1/0;for(let k=3*g,D=3*(g+y);k<D;k++){let B=n[k];const O=i.getX(B),C=i.getY(B),I=i.getZ(B);O<w&&(w=O),O>_&&(_=O),C<x&&(x=C),C>T&&(T=C),I<b&&(b=I),I>P&&(P=I)}return l[p+0]!==w||l[p+1]!==x||l[p+2]!==b||l[p+3]!==_||l[p+4]!==T||l[p+5]!==P?(l[p+0]=w,l[p+1]=x,l[p+2]=b,l[p+3]=_,l[p+4]=T,l[p+5]=P,!0):!1}else{const g=Te(p),y=Pe(p,r);let w=d,x=!1,b=!1;if(e){if(!w){const B=g/Me+f/Ie,O=y/Me+f/Ie;x=e.has(B),b=e.has(O),w=!x&&!b}}else x=!0,b=!0;const _=w||x,T=w||b;let P=!1;_&&(P=u(g,f,w));let k=!1;T&&(k=u(y,f,w));const D=P||k;if(D)for(let B=0;B<3;B++){const O=g+B,C=y+B,I=l[O],v=l[O+3],z=l[C],q=l[C+3];l[p+B]=I<z?I:z,l[p+B+3]=v>q?v:q}return D}}}function pt(o,e,t,n,i){let s,r,a,l,h,c;const u=1/t.direction.x,p=1/t.direction.y,f=1/t.direction.z,d=t.origin.x,m=t.origin.y,g=t.origin.z;let y=e[o],w=e[o+3],x=e[o+1],b=e[o+3+1],_=e[o+2],T=e[o+3+2];return u>=0?(s=(y-d)*u,r=(w-d)*u):(s=(w-d)*u,r=(y-d)*u),p>=0?(a=(x-m)*p,l=(b-m)*p):(a=(b-m)*p,l=(x-m)*p),s>l||a>r||((a>s||isNaN(s))&&(s=a),(l<r||isNaN(r))&&(r=l),f>=0?(h=(_-g)*f,c=(T-g)*f):(h=(T-g)*f,c=(_-g)*f),s>c||h>r)?!1:((h>s||s!==s)&&(s=h),(c<r||r!==r)&&(r=c),s<=i&&r>=n)}function Rh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:h}=o;for(let c=n,u=n+i;c<u;c++){let p=h?h[c]:c;Jn(l,e,t,p,s,r,a)}}function Fh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let h=1/0,c=null;for(let u=n,p=n+i;u<p;u++){let f;f=Jn(a,e,t,l?l[u]:u,null,s,r),f&&f.distance<h&&(c=f,h=f.distance)}return c}function Uh(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=o,u=e+o;c<u;c++){let p;if(p=t.resolveTriangleIndex(c),_e(r,p*3,l,h),r.needsUpdate=!0,n(r,p,i,s))return!0}return!1}function Vh(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),ns(0,o,t,n,i,s,r),me.clearBuffer()}function ns(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=o*2;if(Se(c,l)){const p=Ue(o,h),f=We(c,l);Lh(e,t,n,p,f,i,s,r)}else{const p=Te(o);pt(p,a,n,s,r)&&ns(p,e,t,n,i,s,r);const f=Pe(o,h);pt(f,a,n,s,r)&&ns(f,e,t,n,i,s,r)}}const jh=["x","y","z"];function Gh(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=is(0,o,t,n,i,s);return me.clearBuffer(),r}function is(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let h=o*2;if(Se(h,a)){const u=Ue(o,l),p=We(h,a);return Oh(e,t,n,u,p,i,s)}else{const u=Qi(o,l),p=jh[u],d=n.direction[p]>=0;let m,g;d?(m=Te(o),g=Pe(o,l)):(m=Pe(o,l),g=Te(o));const w=pt(m,r,n,i,s)?is(m,e,t,n,i,s):null;if(w){const _=w.point[p];if(d?_<=r[g+u]:_>=r[g+u+3])return w}const b=pt(g,r,n,i,s)?is(g,e,t,n,i,s):null;return w&&b?w.distance<=b.distance?w:b:w||b||null}}const Qn=new S.Box3,Zt=new Ge,Kt=new Ge,dn=new S.Matrix4,no=new Ee,ei=new Ee;function Xh(o,e,t,n){me.setBuffer(o._roots[e]);const i=ss(0,o,t,n);return me.clearBuffer(),i}function ss(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(),no.set(t.boundingBox.min,t.boundingBox.max,n),i=no),Se(l,r)){const c=e.geometry,u=c.index,p=c.attributes.position,f=t.index,d=t.attributes.position,m=Ue(o,a),g=We(l,r);if(dn.copy(n).invert(),t.boundsTree)return we(o,s,ei),ei.matrix.copy(dn),ei.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>ei.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let x=m*3,b=(g+m)*3;x<b;x+=3)if(_e(Kt,x,u,p),Kt.needsUpdate=!0,w.intersectsTriangle(Kt))return!0;return!1}});{const y=Ct(t);for(let w=m*3,x=(g+m)*3;w<x;w+=3){_e(Zt,w,u,p),Zt.a.applyMatrix4(dn),Zt.b.applyMatrix4(dn),Zt.c.applyMatrix4(dn),Zt.needsUpdate=!0;for(let b=0,_=y*3;b<_;b+=3)if(_e(Kt,b,f,d),Kt.needsUpdate=!0,Zt.intersectsTriangle(Kt))return!0}}}else{const c=Te(o),u=Pe(o,a);return we(c,s,Qn),!!(i.intersectsBox(Qn)&&ss(c,e,t,n,i)||(we(u,s,Qn),i.intersectsBox(Qn)&&ss(u,e,t,n,i)))}}const ti=new S.Matrix4,rs=new Ee,fn=new Ee,Wh=new S.Vector3,qh=new S.Vector3,Zh=new S.Vector3,Kh=new S.Vector3;function Yh(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),rs.set(e.boundingBox.min,e.boundingBox.max,t),rs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,p=Xe.getPrimitive(),f=Xe.getPrimitive();let d=Wh,m=qh,g=null,y=null;i&&(g=Zh,y=Kh);let w=1/0,x=null,b=null;return ti.copy(t).invert(),fn.matrix.copy(ti),o.shapecast({boundsTraverseOrder:_=>rs.distanceToBox(_),intersectsBounds:(_,T,P)=>P<w&&P<r?(T&&(fn.min.copy(_.min),fn.max.copy(_.max),fn.needsUpdate=!0),!0):!1,intersectsRange:(_,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>fn.distanceToBox(k),intersectsBounds:(k,D,B)=>B<w&&B<r,intersectsRange:(k,D)=>{for(let B=k,O=k+D;B<O;B++){_e(f,3*B,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let C=_,I=_+T;C<I;C++){_e(p,3*C,h,l),p.needsUpdate=!0;const v=p.distanceToTriangle(f,d,g);if(v<w&&(m.copy(d),y&&y.copy(g),w=v,x=C,b=B),v<s)return!0}}}});{const P=Ct(e);for(let k=0,D=P;k<D;k++){_e(f,3*k,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let B=_,O=_+T;B<O;B++){_e(p,3*B,h,l),p.needsUpdate=!0;const C=p.distanceToTriangle(f,d,g);if(C<w&&(m.copy(d),y&&y.copy(g),w=C,x=B,b=k),C<s)return!0}}}}}),Xe.releasePrimitive(p),Xe.releasePrimitive(f),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ti),m.applyMatrix4(ti),i.distance=m.sub(i.point).length(),i.faceIndex=b),n)}function $h(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 p=0,f=c.length;p<f;p++)s=c[p],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(p,f,d=!1){const m=p*2;if(Se(m,a)){const g=r[p+6],y=a[m+14];let w=1/0,x=1/0,b=1/0,_=-1/0,T=-1/0,P=-1/0;for(let k=g,D=g+y;k<D;k++){const B=3*o.resolveTriangleIndex(k);for(let O=0;O<3;O++){let C=B+O;C=n?n[C]:C;const I=i.getX(C),v=i.getY(C),z=i.getZ(C);I<w&&(w=I),I>_&&(_=I),v<x&&(x=v),v>T&&(T=v),z<b&&(b=z),z>P&&(P=z)}}return l[p+0]!==w||l[p+1]!==x||l[p+2]!==b||l[p+3]!==_||l[p+4]!==T||l[p+5]!==P?(l[p+0]=w,l[p+1]=x,l[p+2]=b,l[p+3]=_,l[p+4]=T,l[p+5]=P,!0):!1}else{const g=Te(p),y=Pe(p,r);let w=d,x=!1,b=!1;if(e){if(!w){const B=g/Me+f/Ie,O=y/Me+f/Ie;x=e.has(B),b=e.has(O),w=!x&&!b}}else x=!0,b=!0;const _=w||x,T=w||b;let P=!1;_&&(P=u(g,f,w));let k=!1;T&&(k=u(y,f,w));const D=P||k;if(D)for(let B=0;B<3;B++){const O=g+B,C=y+B,I=l[O],v=l[O+3],z=l[C],q=l[C+3];l[p+B]=I<z?I:z,l[p+B+3]=v>q?v:q}return D}}}function Hh(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),os(0,o,t,n,i,s,r),me.clearBuffer()}function os(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=o*2;if(Se(c,l)){const p=Ue(o,h),f=We(c,l);Rh(e,t,n,p,f,i,s,r)}else{const p=Te(o);pt(p,a,n,s,r)&&os(p,e,t,n,i,s,r);const f=Pe(o,h);pt(f,a,n,s,r)&&os(f,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=as(0,o,t,n,i,s);return me.clearBuffer(),r}function as(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let h=o*2;if(Se(h,a)){const u=Ue(o,l),p=We(h,a);return Fh(e,t,n,u,p,i,s)}else{const u=Qi(o,l),p=Jh[u],d=n.direction[p]>=0;let m,g;d?(m=Te(o),g=Pe(o,l)):(m=Pe(o,l),g=Te(o));const w=pt(m,r,n,i,s)?as(m,e,t,n,i,s):null;if(w){const _=w.point[p];if(d?_<=r[g+u]:_>=r[g+u+3])return w}const b=pt(g,r,n,i,s)?as(g,e,t,n,i,s):null;return w&&b?w.distance<=b.distance?w:b:w||b||null}}const ni=new S.Box3,Yt=new Ge,$t=new Ge,pn=new S.Matrix4,io=new Ee,ii=new Ee;function eu(o,e,t,n){me.setBuffer(o._roots[e]);const i=ls(0,o,t,n);return me.clearBuffer(),i}function ls(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(),io.set(t.boundingBox.min,t.boundingBox.max,n),i=io),Se(l,r)){const c=e.geometry,u=c.index,p=c.attributes.position,f=t.index,d=t.attributes.position,m=Ue(o,a),g=We(l,r);if(pn.copy(n).invert(),t.boundsTree)return we(o,s,ii),ii.matrix.copy(pn),ii.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>ii.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let x=m,b=g+m;x<b;x++)if(_e($t,3*e.resolveTriangleIndex(x),u,p),$t.needsUpdate=!0,w.intersectsTriangle($t))return!0;return!1}});{const y=Ct(t);for(let w=m,x=g+m;w<x;w++){const b=e.resolveTriangleIndex(w);_e(Yt,3*b,u,p),Yt.a.applyMatrix4(pn),Yt.b.applyMatrix4(pn),Yt.c.applyMatrix4(pn),Yt.needsUpdate=!0;for(let _=0,T=y*3;_<T;_+=3)if(_e($t,_,f,d),$t.needsUpdate=!0,Yt.intersectsTriangle($t))return!0}}}else{const c=Te(o),u=Pe(o,a);return we(c,s,ni),!!(i.intersectsBox(ni)&&ls(c,e,t,n,i)||(we(u,s,ni),i.intersectsBox(ni)&&ls(u,e,t,n,i)))}}const si=new S.Matrix4,cs=new Ee,mn=new Ee,tu=new S.Vector3,nu=new S.Vector3,iu=new S.Vector3,su=new S.Vector3;function ru(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),cs.set(e.boundingBox.min,e.boundingBox.max,t),cs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,p=Xe.getPrimitive(),f=Xe.getPrimitive();let d=tu,m=nu,g=null,y=null;i&&(g=iu,y=su);let w=1/0,x=null,b=null;return si.copy(t).invert(),mn.matrix.copy(si),o.shapecast({boundsTraverseOrder:_=>cs.distanceToBox(_),intersectsBounds:(_,T,P)=>P<w&&P<r?(T&&(mn.min.copy(_.min),mn.max.copy(_.max),mn.needsUpdate=!0),!0):!1,intersectsRange:(_,T)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>mn.distanceToBox(k),intersectsBounds:(k,D,B)=>B<w&&B<r,intersectsRange:(k,D)=>{for(let B=k,O=k+D;B<O;B++){const C=P.resolveTriangleIndex(B);_e(f,3*C,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=_,v=_+T;I<v;I++){const z=o.resolveTriangleIndex(I);_e(p,3*z,h,l),p.needsUpdate=!0;const q=p.distanceToTriangle(f,d,g);if(q<w&&(m.copy(d),y&&y.copy(g),w=q,x=I,b=B),q<s)return!0}}}})}else{const P=Ct(e);for(let k=0,D=P;k<D;k++){_e(f,3*k,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let B=_,O=_+T;B<O;B++){const C=o.resolveTriangleIndex(B);_e(p,3*C,h,l),p.needsUpdate=!0;const I=p.distanceToTriangle(f,d,g);if(I<w&&(m.copy(d),y&&y.copy(g),w=I,x=B,b=k),I<s)return!0}}}}}),Xe.releasePrimitive(p),Xe.releasePrimitive(f),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(si),m.applyMatrix4(si),i.distance=m.sub(i.point).length(),i.faceIndex=b),n)}function ou(){return typeof SharedArrayBuffer<"u"}const gn=new me.constructor,ri=new me.constructor,mt=new Ji(()=>new S.Box3),Ht=new S.Box3,Jt=new S.Box3,hs=new S.Box3,us=new S.Box3;let ds=!1;function au(o,e,t,n){if(ds)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");ds=!0;const i=o._roots,s=e._roots;let r,a=0,l=0;const h=new S.Matrix4().copy(t).invert();for(let c=0,u=i.length;c<u;c++){gn.setBuffer(i[c]),l=0;const p=mt.getPrimitive();we(0,gn.float32Array,p),p.applyMatrix4(h);for(let f=0,d=s.length;f<d&&(ri.setBuffer(s[f]),r=Ke(0,0,t,h,n,a,l,0,0,p),ri.clearBuffer(),l+=s[f].byteLength/Ie,!r);f++);if(mt.releasePrimitive(p),gn.clearBuffer(),a+=i[c].byteLength/Ie,r)break}return ds=!1,r}function Ke(o,e,t,n,i,s=0,r=0,a=0,l=0,h=null,c=!1){let u,p;c?(u=ri,p=gn):(u=gn,p=ri);const f=u.float32Array,d=u.uint32Array,m=u.uint16Array,g=p.float32Array,y=p.uint32Array,w=p.uint16Array,x=o*2,b=e*2,_=Se(x,m),T=Se(b,w);let P=!1;if(T&&_)c?P=i(Ue(e,y),We(e*2,w),Ue(o,d),We(o*2,m),l,r+e/Me,a,s+o/Me):P=i(Ue(o,d),We(o*2,m),Ue(e,y),We(e*2,w),a,s+o/Me,l,r+e/Me);else if(T){const k=mt.getPrimitive();we(e,g,k),k.applyMatrix4(t);const D=Te(o),B=Pe(o,d);we(D,f,Ht),we(B,f,Jt);const O=k.intersectsBox(Ht),C=k.intersectsBox(Jt);P=O&&Ke(e,D,n,t,i,r,s,l,a+1,k,!c)||C&&Ke(e,B,n,t,i,r,s,l,a+1,k,!c),mt.releasePrimitive(k)}else{const k=Te(e),D=Pe(e,y);we(k,g,hs),we(D,g,us);const B=h.intersectsBox(hs),O=h.intersectsBox(us);if(B&&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(B)if(_)P=Ke(o,k,t,n,i,s,r,a,l+1,h,c);else{const C=mt.getPrimitive();C.copy(hs).applyMatrix4(t);const I=Te(o),v=Pe(o,d);we(I,f,Ht),we(v,f,Jt);const z=C.intersectsBox(Ht),q=C.intersectsBox(Jt);P=z&&Ke(k,I,n,t,i,r,s,l,a+1,C,!c)||q&&Ke(k,v,n,t,i,r,s,l,a+1,C,!c),mt.releasePrimitive(C)}else if(O)if(_)P=Ke(o,D,t,n,i,s,r,a,l+1,h,c);else{const C=mt.getPrimitive();C.copy(us).applyMatrix4(t);const I=Te(o),v=Pe(o,d);we(I,f,Ht),we(v,f,Jt);const z=C.intersectsBox(Ht),q=C.intersectsBox(Jt);P=z&&Ke(D,I,n,t,i,r,s,l,a+1,C,!c)||q&&Ke(D,v,n,t,i,r,s,l,a+1,C,!c),mt.releasePrimitive(C)}}return P}const oi=new Ee,so=new S.Box3,lu={strategy:Rr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class fs{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,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 fs(t,{...n,[Wi]:!0});if(a._roots=s,a._indirectBuffer=r||null,n.setIndex){const h=t.getIndex();if(h===null){const c=new S.BufferAttribute(e.index,1,!1);t.setIndex(c)}else h.array!==i&&(h.array.set(i),h.needsUpdate=!0)}return a;function l(h){for(let c=0;c<h.length;c++){const u=h[c],p=new Uint32Array(u),f=new Uint16Array(u);for(let d=0,m=u.byteLength/Ie;d<m;d++){const g=Me*d,y=2*g;Se(y,f)||(p[g+6]=p[g+6]/Me-d)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...lu,[Wi]:!1},t),t.useSharedArrayBuffer&&!ou())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Wi]||(Sh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new S.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],r=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Ie;for(let h=0;h<l;h++){const c=Me*h,u=2*c;Se(u,a)&&(r[c+6]+=e)}}}}refit(e=null){return(this.indirect?$h:Nh)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);r(0);function r(a,l=0){const h=a*2,c=Se(h,s);if(c){const u=i[a+6],p=s[h+14];e(l,c,new Float32Array(n,a*4,6),u,p)}else{const u=Te(a),p=Pe(a,i),f=Qi(a,i);e(l,c,new Float32Array(n,a*4,6),f)||(r(u,l+1),r(p,l+1))}}}raycast(e,t=S.FrontSide,n=0,i=1/0){const s=this._roots,r=[],a=this.indirect?Hh:Vh;for(let l=0,h=s.length;l<h;l++)a(this,l,t,e,r,n,i);return r}raycastFirst(e,t=S.FrontSide,n=0,i=1/0){const s=this._roots;let r=null;const a=this.indirect?Qh:Gh;for(let l=0,h=s.length;l<h;l++){const c=a(this,l,t,e,n,i);c!=null&&(r==null||c.distance<r.distance)&&(r=c)}return r}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?eu:Xh;for(let r=0,a=i.length;r<a&&(n=s(this,r,e,t),!n);r++);return n}shapecast(e){const t=Xe.getPrimitive(),n=this.indirect?Uh:zh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const u=r;r=(p,f,d,m,g)=>u(p,f,d,m,g)?!0:n(p,f,this,a,d,m,t)}else r||(a?r=(u,p,f,d)=>n(u,p,this,a,f,d,t):r=(u,p,f)=>f);let l=!1,h=0;const c=this._roots;for(let u=0,p=c.length;u<p;u++){const f=c[u];if(l=kh(this,u,s,r,i,h),l)break;h+=f.byteLength/Ie}return Xe.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const r=Xe.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,h=this.indirect?d=>{const m=this.resolveTriangleIndex(d);_e(r,m*3,a,l)}:d=>{_e(r,d*3,a,l)},c=Xe.getPrimitive(),u=e.geometry.index,p=e.geometry.attributes.position,f=e.indirect?d=>{const m=e.resolveTriangleIndex(d);_e(c,m*3,u,p)}:d=>{_e(c,d*3,u,p)};if(s){const d=(m,g,y,w,x,b,_,T)=>{for(let P=y,k=y+w;P<k;P++){f(P),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let D=m,B=m+g;D<B;D++)if(h(D),r.needsUpdate=!0,s(r,c,D,P,x,b,_,T))return!0}return!1};if(i){const m=i;i=function(g,y,w,x,b,_,T,P){return m(g,y,w,x,b,_,T,P)?!0:d(g,y,w,x,b,_,T,P)}}else i=d}return au(this,e,t,i)}intersectsBox(e,t){return oi.set(e.min,e.max,t),oi.needsUpdate=!0,this.shapecast({intersectsBounds:n=>oi.intersectsBox(n),intersectsTriangle:n=>oi.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?ru:Yh)(this,e,t,n,i,s,r)}closestPointToPoint(e,t={},n=0,i=1/0){return Ih(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{we(0,new Float32Array(n),so),e.union(so)}),e}}const ro=1e-6,cu=ro*.5,oo=Math.pow(10,-Math.log10(ro)),hu=cu*oo;function tt(o){return~~(o*oo+hu)}function uu(o){return`${tt(o.x)},${tt(o.y)}`}function ao(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)}`}function du(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)},${tt(o.w)}`}function fu(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 lo(){return typeof SharedArrayBuffer<"u"}function pu(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 mu(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function gu(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=mu(t,n);o.setIndex(new S.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function yu(o){return o.index?o.index.count:o.attributes.position.count}function ps(o){return yu(o)/3}const wu=1e-8,xu=new S.Vector3;function bu(o){return~~(o/3)}function _u(o){return o%3}function co(o,e){return o.start-e.start}function ho(o,e){return xu.subVectors(e,o.origin).dot(o.direction)}function vu(o,e,t,n=wu){o.sort(co),e.sort(co);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 u=l.end;l.end=c.start,c.start=u}else if(l.start>=c.start&&l.end>=c.end){const u=c.end;c.end=l.start,l.start=u}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(c.index)||t.set(c.index,[]),t.get(l.index).push(c.index),t.get(c.index).push(l.index),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 uo=1e-5,fo=1e-4;class Mu{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,s=null;for(let l=0,h=t.length;l<h;l++){const c=t[l];if(r(c,e)&&r(c,n))continue;const u=a(c,e),p=a(c,n),f=Math.min(u,p);f<i&&(i=f,s=c)}return s;function r(l,h){const c=l.origin.distanceTo(h.origin)>uo;return l.direction.angleTo(h.direction)>fo||c}function a(l,h){const c=l.origin.distanceTo(h.origin),u=l.direction.angleTo(h.direction);return c/uo+u/fo}}}const ms=new S.Vector3,gs=new S.Vector3,ai=new S.Ray;function Su(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 Mu;for(let c=0,u=l.length;c<u;c++){const p=l[c],f=bu(p),d=_u(p);let m=3*f+d,g=3*f+(d+1)%3;i&&(m=i.getX(m),g=i.getX(g)),ms.fromBufferAttribute(s,m),gs.fromBufferAttribute(s,g),fu(ms,gs,ai);let y,w=h.findClosestRay(ai);w===null&&(w=ai.clone(),h.addRay(w)),a.has(w)||a.set(w,{forward:[],reverse:[],ray:w}),y=a.get(w);let x=ho(w,ms),b=ho(w,gs);x>b&&([x,b]=[b,x]),ai.direction.dot(w.direction)<0?y.reverse.push({start:x,end:b,index:p}):y.forward.push({start:x,end:b,index:p})}return a.forEach(({forward:c,reverse:u},p)=>{vu(c,u,r,t),c.length===0&&u.length===0&&a.delete(p)}),{disjointConnectivityMap:r,fragmentMap:a}}const Au=new S.Vector2,ys=new S.Vector3,Cu=new S.Vector4,ws=["","",""];class Tu{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?x:w,a=new Map,{attributes:l}=e,h=t?Object.keys(l):null,c=e.index,u=l.position;let p=ps(e);const f=p;let d=0;n&&(d=e.drawRange.start,e.drawRange.count!==1/0&&(p=~~(e.drawRange.count/3)));let m=this.data;(!m||m.length<3*f)&&(m=new Int32Array(3*f)),m.fill(-1);let g=0,y=new Set;for(let b=d,_=p*3+d;b<_;b+=3){const T=b;for(let P=0;P<3;P++){let k=T+P;c&&(k=c.getX(k)),ws[P]=r(k)}for(let P=0;P<3;P++){const k=(P+1)%3,D=ws[P],B=ws[k],O=`${B}_${D}`;if(a.has(O)){const C=T+P,I=a.get(O);m[C]=I,m[I]=C,a.delete(O),g+=2,y.delete(I)}else{const C=`${D}_${B}`,I=T+P;a.set(C,I),y.add(I)}}}if(i){const{fragmentMap:b,disjointConnectivityMap:_}=Su(e,y,s);y.clear(),b.forEach(({forward:T,reverse:P})=>{T.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=b,this.disjointConnections=_,g=p*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=m;function w(b){return ys.fromBufferAttribute(u,b),ao(ys)}function x(b){let _="";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(b));break;case 2:D=uu(Au.fromBufferAttribute(k,b));break;case 3:D=ao(ys.fromBufferAttribute(k,b));break;case 4:D=du(Cu.fromBufferAttribute(k,b));break}_!==""&&(_+="|"),_+=D}return _}}}class li extends S.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new S.Matrix4,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let s=0;s<16;s++)if(n[s]!==i[s])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=lo();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=pu(s.array)}if(e.boundsTree||(gu(e,{useSharedArrayBuffer:n}),e.boundsTree=new fs(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Tu(e)),!e.groupIndices){const i=ps(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 u=h/3,p=(h+c)/3;u<p;u++)s[u]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Pu=1e-14,xs=new S.Vector3,po=new S.Vector3,mo=new S.Vector3;function gt(o,e=Pu){xs.subVectors(o.b,o.a),po.subVectors(o.c,o.a),mo.subVectors(o.b,o.c);const t=xs.angleTo(po),n=xs.angleTo(mo),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 bs=1e-10,yn=1e-10,Du=1e-10,at=new S.Line3,xe=new S.Line3,lt=new S.Vector3,_s=new S.Vector3,go=new S.Vector3,ci=new S.Plane,vs=new Ge;class ku{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new S.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class Iu{constructor(){this.trianglePool=new ku,this.triangles=[],this.normal=new S.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,r=e.length;s<r;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(lt).dot(i))>bs)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=n.getTriangle();l.copy(a),t.push(l)}else{e.getNormal(i);const s=n.getTriangle();s.copy(e),t.push(s)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(_s).normalize(),Math.abs(1-Math.abs(_s.dot(t)))<Du){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];lt.subVectors(l,a).normalize(),go.crossVectors(_s,lt),ci.setFromNormalAndCoplanarPoint(go,a),this.splitByPlane(ci,e)}}else e.getPlane(ci),this.splitByPlane(ci,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;vs.copy(t),vs.needsUpdate=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];if(!vs.intersectsTriangle(a,at,!0))continue;const{a:l,b:h,c}=a;let u=0,p=-1,f=!1,d=[],m=[];const g=[l,h,c];for(let y=0;y<3;y++){const w=(y+1)%3;at.start.copy(g[y]),at.end.copy(g[w]);const x=e.distanceToPoint(at.start),b=e.distanceToPoint(at.end);if(Math.abs(x)<yn&&Math.abs(b)<yn){f=!0;break}if(x>0?d.push(y):m.push(y),Math.abs(x)<yn)continue;let _=!!e.intersectLine(at,lt);!_&&Math.abs(b)<yn&&(lt.copy(at.end),_=!0),_&&!(lt.distanceTo(at.start)<bs)&&(lt.distanceTo(at.end)<bs&&(p=y),u===0?xe.start.copy(lt):xe.end.copy(lt),u++)}if(!f&&u===2&&xe.distance()>yn)if(p!==-1){p=(p+1)%3;let y=0;y===p&&(y=(y+1)%3);let w=y+1;w===p&&(w=(w+1)%3);const x=i.getTriangle();x.a.copy(g[w]),x.b.copy(xe.end),x.c.copy(xe.start),gt(x)||n.push(x),a.a.copy(g[y]),a.b.copy(xe.start),a.c.copy(xe.end),gt(a)&&(n.splice(s,1),s--,r--)}else{const y=d.length>=2?m[0]:d[0];if(y===0){let T=xe.start;xe.start=xe.end,xe.end=T}const w=(y+1)%3,x=(y+2)%3,b=i.getTriangle(),_=i.getTriangle();g[w].distanceToSquared(xe.start)<g[x].distanceToSquared(xe.end)?(b.a.copy(g[w]),b.b.copy(xe.start),b.c.copy(xe.end),_.a.copy(g[w]),_.b.copy(g[x]),_.c.copy(xe.start)):(b.a.copy(g[x]),b.b.copy(xe.start),b.c.copy(xe.end),_.a.copy(g[w]),_.b.copy(g[x]),_.c.copy(xe.end)),a.a.copy(g[y]),a.b.copy(xe.end),a.c.copy(xe.start),gt(b)||n.push(b),gt(_)||n.push(_),gt(a)&&(n.splice(s,1),s--,r--)}else u===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function Eu(o){return o=~~o,o+4-o%4}class yo{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,n=lo()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(Eu(e*t.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,s=e.length;i<s;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class Bu{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let s=0;s<t;s++){const 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 yo(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 yo(t);c.itemSize=n,c.normalized=i,s[l][e]=c}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const n in t)t[n].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class wo{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const Lu=0,Ou=1,zu=2,xo=3,Nu=4,bo=5,_o=6,qe=new S.Ray,vo=new S.Matrix4,Be=new S.Triangle,ct=new S.Vector3,Mo=new S.Vector4,So=new S.Vector4,Ao=new S.Vector4,Ms=new S.Vector4,hi=new S.Vector4,ui=new S.Vector4,Co=new S.Line3,Ss=new S.Vector3,As=1e-8,Ru=1e-15,kt=-1,It=1,di=-2,fi=2,wn=0,Et=1,Cs=2,Fu=1e-14;let pi=null;function To(o){pi=o}function Po(o,e){o.getMidpoint(qe.origin),o.getNormal(qe.direction);const t=e.raycastFirst(qe,S.DoubleSide);return!!(t&&qe.direction.dot(t.face.normal)>0)?kt:It}function Uu(o,e){function t(){return Math.random()-.5}o.getNormal(Ss),qe.direction.copy(Ss),o.getMidpoint(qe.origin);const n=3;let i=0,s=1/0;for(let r=0;r<n;r++){qe.direction.x+=t()*As,qe.direction.y+=t()*As,qe.direction.z+=t()*As,qe.direction.multiplyScalar(-1);const a=e.raycastFirst(qe,S.DoubleSide);if(!!(a&&qe.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=Ru)return a.face.normal.dot(Ss)>0?fi:di;if(i/n>.5||(r-i+1)/n>.5)break}return i/n>.5?kt:It}function Vu(o,e){const t=new wo,n=new wo;return vo.copy(o.matrixWorld).invert().multiply(e.matrixWorld),o.geometry.boundsTree.bvhcast(e.geometry.boundsTree,vo,{intersectsTriangles(i,s,r,a){if(!gt(i)&&!gt(s)){let l=i.intersectsTriangle(s,Co,!0);if(!l){const h=i.plane,c=s.plane,u=h.normal,p=c.normal;u.dot(p)===1&&Math.abs(h.constant-c.constant)<Fu&&(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),pi&&(pi.addEdge(Co),pi.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),u=l.getX(h+1),p=l.getX(h+2);for(const f in s){const d=a[f],m=s[f];if(!(f in a))throw new Error(`CSG Operations: Attribute ${f} not available on geometry.`);const g=d.itemSize;f==="position"?(Be.a.fromBufferAttribute(d,c).applyMatrix4(n),Be.b.fromBufferAttribute(d,u).applyMatrix4(n),Be.c.fromBufferAttribute(d,p).applyMatrix4(n),Ts(Be.a,Be.b,Be.c,e,3,m,r)):f==="normal"?(Be.a.fromBufferAttribute(d,c).applyNormalMatrix(i),Be.b.fromBufferAttribute(d,u).applyNormalMatrix(i),Be.c.fromBufferAttribute(d,p).applyNormalMatrix(i),r&&(Be.a.multiplyScalar(-1),Be.b.multiplyScalar(-1),Be.c.multiplyScalar(-1)),Ts(Be.a,Be.b,Be.c,e,3,m,r,!0)):(Mo.fromBufferAttribute(d,c),So.fromBufferAttribute(d,u),Ao.fromBufferAttribute(d,p),Ts(Mo,So,Ao,e,g,m,r))}}function Gu(o,e,t,n,i,s,r,a=!1){Ps(o,n,i,s,r,a),Ps(a?t:e,n,i,s,r,a),Ps(a?e:t,n,i,s,r,a)}function Do(o,e,t=!1){switch(o){case Lu:if(e===It||e===fi&&!t)return Et;break;case Ou:if(t){if(e===kt)return wn}else if(e===It||e===di)return Et;break;case zu:if(t){if(e===It||e===di)return Et}else if(e===kt)return wn;break;case Nu:if(e===kt)return wn;if(e===It)return Et;break;case xo:if(e===kt||e===fi&&!t)return Et;break;case bo:if(!t&&(e===It||e===di))return Et;break;case _o:if(!t&&(e===kt||e===fi))return Et;break;default:throw new Error(`Unrecognized CSG operation enum "${o}".`)}return Cs}function Ts(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)};Ms.set(0,0,0,0).addScaledVector(o,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),hi.set(0,0,0,0).addScaledVector(o,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),ui.set(0,0,0,0).addScaledVector(o,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Ms.normalize(),hi.normalize(),ui.normalize()),l(Ms),r?(l(ui),l(hi)):(l(hi),l(ui))}function Ps(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"?(ct.fromBufferAttribute(a,o).applyMatrix4(t),l.push(ct.x,ct.y,ct.z)):r==="normal"?(ct.fromBufferAttribute(a,o).applyNormalMatrix(n),s&&ct.multiplyScalar(-1),l.push(ct.x,ct.y,ct.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 Xu{constructor(e){this.triangle=new S.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new S.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class ko{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new Xu(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 Wu{constructor(){this.enabled=!1,this.triangleIntersectsA=new ko,this.triangleIntersectsB=new ko,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(),To(this))}complete(){this.enabled&&To(null)}}const yt=new S.Matrix4,mi=new S.Matrix3,Bt=new S.Triangle,gi=new S.Triangle,wt=new S.Triangle,yi=new S.Triangle,Ye=[],Lt=[];function qu(o){for(const e of o)return e}function Zu(o,e,t,n,i,s={}){const{useGroups:r=!0}=s,{aIntersections:a,bIntersections:l}=Vu(o,e),h=[];let c=null,u;return u=r?0:-1,Io(o,e,a,t,!1,n,i,u),Eo(o,e,a,t,!1,i,u),t.findIndex(f=>f!==_o&&f!==bo)!==-1&&(u=r?o.geometry.groups.length||1:-1,Io(e,o,l,t,!0,n,i,u),Eo(e,o,l,t,!0,i,u)),Ye.length=0,Lt.length=0,{groups:h,materials:c}}function Io(o,e,t,n,i,s,r,a=0){const l=o.matrixWorld.determinant()<0;yt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),mi.getNormalMatrix(o.matrixWorld).multiplyScalar(l?-1:1);const h=o.geometry.groupIndices,c=o.geometry.index,u=o.geometry.attributes.position,p=e.geometry.boundsTree,f=e.geometry.index,d=e.geometry.attributes.position,m=t.ids,g=t.intersectionSet;for(let y=0,w=m.length;y<w;y++){const x=m[y],b=a===-1?0:h[x]+a,_=3*x,T=c.getX(_+0),P=c.getX(_+1),k=c.getX(_+2);Bt.a.fromBufferAttribute(u,T).applyMatrix4(yt),Bt.b.fromBufferAttribute(u,P).applyMatrix4(yt),Bt.c.fromBufferAttribute(u,k).applyMatrix4(yt),s.reset(),s.initialize(Bt);const D=g[x];for(let O=0,C=D.length;O<C;O++){const I=3*D[O],v=f.getX(I+0),z=f.getX(I+1),q=f.getX(I+2);gi.a.fromBufferAttribute(d,v),gi.b.fromBufferAttribute(d,z),gi.c.fromBufferAttribute(d,q),s.splitByTriangle(gi)}const B=s.triangles;for(let O=0,C=B.length;O<C;O++){const I=B[O],v=s.coplanarTriangleUsed?Uu(I,p):Po(I,p);Ye.length=0,Lt.length=0;for(let z=0,q=n.length;z<q;z++){const G=Do(n[z],v,i);G!==Cs&&(Lt.push(G),Ye.push(r[z].getGroupAttrSet(b)))}if(Ye.length!==0){Bt.getBarycoord(I.a,yi.a),Bt.getBarycoord(I.b,yi.b),Bt.getBarycoord(I.c,yi.c);for(let z=0,q=Ye.length;z<q;z++){const G=Ye[z],X=Lt[z]===wn;ju(x,yi,o.geometry,o.matrixWorld,mi,G,l!==X)}}}}return m.length}function Eo(o,e,t,n,i,s,r=0){const a=o.matrixWorld.determinant()<0;yt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),mi.getNormalMatrix(o.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,h=o.geometry.groupIndices,c=o.geometry.index,u=o.geometry.attributes,p=u.position,f=[],d=o.geometry.halfEdges,m=new Set,g=ps(o.geometry);for(let y=0,w=g;y<w;y++)y in t.intersectionSet||m.add(y);for(;m.size>0;){const y=qu(m);m.delete(y),f.push(y);const w=3*y,x=c.getX(w+0),b=c.getX(w+1),_=c.getX(w+2);wt.a.fromBufferAttribute(p,x).applyMatrix4(yt),wt.b.fromBufferAttribute(p,b).applyMatrix4(yt),wt.c.fromBufferAttribute(p,_).applyMatrix4(yt);const T=Po(wt,l);Lt.length=0,Ye.length=0;for(let P=0,k=n.length;P<k;P++){const D=Do(n[P],T,i);D!==Cs&&(Lt.push(D),Ye.push(s[P]))}for(;f.length>0;){const P=f.pop();for(let k=0;k<3;k++){const D=d.getSiblingTriangleIndex(P,k);D!==-1&&m.has(D)&&(f.push(D),m.delete(D))}if(Ye.length!==0){const k=3*P,D=c.getX(k+0),B=c.getX(k+1),O=c.getX(k+2),C=r===-1?0:h[P]+r;if(wt.a.fromBufferAttribute(p,D),wt.b.fromBufferAttribute(p,B),wt.c.fromBufferAttribute(p,O),!gt(wt))for(let I=0,v=Ye.length;I<v;I++){const z=Lt[I],q=Ye[I].getGroupAttrSet(C),G=z===wn;Gu(D,B,O,u,o.matrixWorld,mi,q,G!==a)}}}}}function Ku(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 Yu(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 $u(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),u=e.getItemSize(l),p=e.getNormalized(l);let f=s[l];(!f||f.array.length<h)&&(f=new S.BufferAttribute(new c(h),u,p),o.setAttribute(l,f),n=!0);let d=0;for(let m=0,g=Math.min(t.length,e.groupCount);m<g;m++){const y=t[m].index,{array:w,type:x,length:b}=e.groupAttributes[y][l],_=new x(w.buffer,0,b);f.array.set(_,d),d+=_.length}f.needsUpdate=!0,i=h/f.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:u}=t[l],p=e.getCount(c);p!==0&&(o.addGroup(a,p,u),a+=p)}o.setDrawRange(0,i),o.boundsTree=null,n&&o.dispose()}function Bo(o,e){let t=e;return Array.isArray(e)||(t=[],o.forEach(n=>{t[n.materialIndex]=e})),t}class Hu{constructor(){this.triangleSplitter=new Iu,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new Wu}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 li){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:u}=this;for(;a.length<i.length;)a.push(new Bu);i.forEach((y,w)=>{Yu(e.geometry,y.geometry,a[w],l)}),u.init(),Zu(e,t,n,r,a,{useGroups:h}),u.complete();const p=this.getGroupRanges(e.geometry),f=Bo(p,e.material),d=this.getGroupRanges(t.geometry),m=Bo(d,t.material);d.forEach(y=>y.materialIndex+=f.length);let g=[...p,...d].map((y,w)=>({...y,index:w}));if(h){const y=[...f,...m];c&&(g=g.map(x=>{const b=y[x.materialIndex];return x.materialIndex=y.indexOf(b),x}).sort((x,b)=>x.materialIndex-b.materialIndex));const w=[];for(let x=0,b=y.length;x<b;x++){let _=!1;for(let T=0,P=g.length;T<P;T++){const k=g[T];k.materialIndex===x&&(_=!0,k.materialIndex=w.length)}_&&w.push(y[x])}i.forEach(x=>{x.material=w})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=f[0]});return i.forEach((y,w)=>{const x=y.geometry;$u(x,a[w],g),c&&Ku(x.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new li){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 u=r[h];a=i(u)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let h;return n(s,c=>{h?h=this.evaluate(h,c,c.operation):h=this.evaluate(s,c,c.operation)}),s._cachedGeometry=h.geometry,s._cachedMaterials=h.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class Ju{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 Hu,this.planeGroup=new A.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 A.BufferGeometry,i=new A.MeshStandardMaterial({color:new A.Color(33023),metalness:.1,roughness:.75,side:A.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((r,a)=>a!==t)}),s=new A.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),u=new li(r.geometry);r.updateMatrixWorld(!0),u.matrix.copy(r.matrixWorld),u.updateMatrixWorld();const p=this.evaluator.evaluate(c,u,xo);p&&p.geometry.attributes.position.count>0?(s.push(p.geometry),this.geometryCache.set(l,{geometry:p.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(c){console.warn(`CSG intersection failed for mesh ${a}:`,c)}}),s.length>0){const 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 A.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new A.Quaternion().setFromUnitVectors(new A.Vector3(0,-1,0),e.normal));const n=new A.Mesh(t),i=new li(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new A.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 A.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new A.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new A.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new A.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new A.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 A.MeshStandardMaterial&&t.material.color.set(e)})}getCacheStats(){return{cacheSize:this.geometryCache.size,sourceMeshCount:this.sourceMeshes.size,sectionMeshCount:this.sectionMeshes.size}}setPlaneThickness(e){if(e<=0){console.warn("Plane thickness must be positive");return}this.planeThickness=e,this.clearAllCache(),this.isActive&&this.requestUpdate()}getPlaneThickness(){return this.planeThickness}showSections(){this.sectionMeshes.forEach(e=>{e.geometry?.attributes.position?.count&&e.geometry.attributes.position.count>0&&(e.visible=!0)})}hideSections(){this.sectionMeshes.forEach(e=>{e.visible=!1})}showSection(){this.planeGroup.visible=!0}hideSection(){this.planeGroup.visible=!1}toggleSectionsVisibility(){let e=!1;return this.sectionMeshes.forEach(t=>{t.visible&&(e=!0)}),e?(this.hideSections(),!1):(this.showSections(),!0)}toggleSectionVisibility(e){const t=this.sectionMeshes.get(`plane_${e}`);return t?(t.visible=!t.visible,t.visible):!1}}class Qu{engine;isActive=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;csgClipping=null;useCsgClipping=!1;constructor(e,t){this.engine=e,this.meshs=[],t?.useCsgClipping!==void 0&&(this.useCsgClipping=t.useCsgClipping),this.useCsgClipping&&this.initCsgClipping()}initCsgClipping(){this.csgClipping=new Ju(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 A.Plane;n.setFromNormalAndCoplanarPoint(new A.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new A.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new A.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 A.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(ve.SectionMove,c)}updata_face(e){let t=this,n=[new A.Vector3(e.min.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.min.z),new A.Vector3(e.min.x,e.max.y,e.min.z)],i=[new A.Vector3(e.min.x,e.min.y,e.max.z),new A.Vector3(e.max.x,e.min.y,e.max.z),new A.Vector3(e.max.x,e.max.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.max.z)],s=[new A.Vector3(e.max.x,e.min.y,e.max.z),new A.Vector3(e.max.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.max.z)],r=[new A.Vector3(e.min.x,e.min.y,e.min.z),new A.Vector3(e.min.x,e.min.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.min.z)],a=[new A.Vector3(e.min.x,e.max.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.max.z)],l=[new A.Vector3(e.min.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.min.y,e.max.z),new A.Vector3(e.min.x,e.min.y,e.max.z)];h(n,new A.Vector3(0,0,-1),"前"),h(i,new A.Vector3(0,0,1),"后"),h(s,new A.Vector3(1,0,0),"右"),h(r,new A.Vector3(-1,0,0),"左"),h(a,new A.Vector3(0,1,0),"顶"),h(l,new A.Vector3(0,-1,0),"底");function h(c,u,p){const f=new A.BufferGeometry,d=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z]),m=[0,1,2,0,2,3];f.setAttribute("position",new A.BufferAttribute(d,3)),f.setIndex(m);let g=t.engine.scene.children.find(T=>T.type=="Group"&&T.name=="ClippingBox");g==null&&(g=new A.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(T=>T.name==p);if(y==null){const T=new A.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:A.DoubleSide});T.polygonOffset=!0,T.polygonOffsetFactor=1,T.polygonOffsetUnits=4;const P=new A.Mesh(f,T);P.normal=u,P.name=p,g.add(P),t.meshs.push(P)}else y.geometry=f;const w=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z,c[0].x,c[0].y,c[0].z]);let x=new A.LineBasicMaterial({color:255}),b=new A.BufferGeometry;b.setAttribute("position",new A.BufferAttribute(w,3));let _=t.meshs.find(T=>T.name==p+"Line");_==null&&(_=new A.Line(b,x),_.name=p+"Line",g.add(_),t.meshs.push(_)),_.geometry=b,_.material=x,p=="前"||p=="左"||p=="底"?t.engine.sectionPlane.find(T=>T.name==p).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.min):t.engine.sectionPlane.find(T=>T.name==p).setFromNormalAndCoplanarPoint(u.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 ed{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new A.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 A.Vector3(0,1,0).applyAxisAngle(new A.Vector3(1,0,0),e).applyAxisAngle(new A.Vector3(0,0,1),t).applyAxisAngle(new A.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 A.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new A.Vector3(1,0,0),s=new A.Vector3(0,1,0),r=new A.Vector3(0,0,1),a,l,h=this.normal.clone().normalize(),c=Math.abs(h.dot(i)),u=Math.abs(h.dot(s)),p=Math.abs(h.dot(r));c<=u&&c<=p?a=i:u<=c&&u<=p?a=s:a=r,a=a.clone().sub(h.clone().multiplyScalar(a.dot(h))).normalize(),l=new A.Vector3().crossVectors(h,a).normalize();let f=null;this.center==null?(f=new A.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),this.center=f.clone()):f=this.center.clone();let d=this.box.max.x-this.box.min.x,m=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*d,Math.abs(a.y)*m,Math.abs(a.z)*g),w=Math.max(Math.abs(l.x)*d,Math.abs(l.y)*m,Math.abs(l.z)*g),x=f.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-w/2)),b=f.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-w/2)),_=f.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(w/2)),T=f.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(w/2));x.add(h.clone().multiplyScalar(e)),b.add(h.clone().multiplyScalar(e)),_.add(h.clone().multiplyScalar(e)),T.add(h.clone().multiplyScalar(e)),this.current_center=f.clone().add(h.clone().multiplyScalar(e)),k([x,b,_,T],h,"face");function k(D,B,O){const C=new A.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]),v=[0,1,2,0,2,3];C.setAttribute("position",new A.BufferAttribute(I,3)),C.setIndex(v);let z=t.meshs.find(Q=>Q.name==O);if(z==null){const Q=new A.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:A.DoubleSide});Q.polygonOffset=!0,Q.polygonOffsetFactor=1,Q.polygonOffsetUnits=4;const R=new A.Mesh(C,Q);R.normal=B,R.name=O,n.add(R),t.meshs.push(R)}else z.geometry=C;const q=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 G=new A.LineBasicMaterial({color:255}),ee=new A.BufferGeometry;ee.setAttribute("position",new A.BufferAttribute(q,3));let X=t.meshs.find(Q=>Q.name==O+"Line");X==null&&(X=new A.Line(ee,G),X.name=O+"Line",n.add(X),t.meshs.push(X)),X.geometry=ee,X.material=G,t.engine.sectionPlane.find(Q=>Q.name==O).setFromNormalAndCoplanarPoint(B.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 A.Plane;n.setFromNormalAndCoplanarPoint(new A.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new A.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new A.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 A.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.distance=i,this.updata_face(this.distance)}}}}class td{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){let t=e.catch.normal;this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class nd{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new A.Plane(new A.Vector3(0,0,1),1e5);t.name="前";let n=new A.Plane(new A.Vector3(0,0,1),1e5);n.name="左";let i=new A.Plane(new A.Vector3(0,0,1),1e5);i.name="后";let s=new A.Plane(new A.Vector3(0,0,1),1e5);s.name="右";let r=new A.Plane(new A.Vector3(0,0,1),1e5);r.name="顶";let a=new A.Plane(new A.Vector3(0,0,1),1e5);a.name="底";let l=new A.Plane(new A.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,r,a,l]}init(){this.sectionBox=new Qu(this.engine),this.sectionFace=new ed(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let 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 A.Vector3(1e8,1e9,1e10),a=new A.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 A.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 td(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),s=n.position.clone().sub(i.min.clone().add(i.max.clone()).setLength(.5)),r=new A.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 id{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class sd{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof A.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 rd{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&&Sr(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()||""],u=c.map(p=>p[0]);u=u.filter((p,f)=>u.indexOf(p)===f),u.forEach(p=>{let f={name:r.categorys[p],children:[]};h.push(f),c.filter(d=>d[0]===p).forEach(d=>{f.children.push({name:r.names[d[1]],value:r.values[d[2]]})})}),l?.({properties:h,materials:h})}}}class od{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(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 ad{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 A.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 A.BufferGeometry;i.setAttribute("position",new A.Float32BufferAttribute(n,3));let s=new A.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 u=s;u<r;u+=3){const p=Math.floor(c/6),f=c%6>=3;if(a[p]&&a[p].length===2){const d=f?a[p][1]:a[p][0];h[u]=d.X,h[u+1]=d.Z,h[u+2]=-d.Y}c+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class ld{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const 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(`网络请求失败,请检查:
|
|
960
|
+
`};class wa{engine;composer;saturationPass;ssaoPass;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 An&&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 A.WebGLRenderTarget(e,t,{minFilter:A.LinearFilter,magFilter:A.LinearFilter,format:A.RGBAFormat,samples:4});this.composer=new ha(s,a),this.composer.setPixelRatio(r),this.composer.setSize(e,t);const l=new ua(n,i);this.composer.addPass(l);const h=new ze(n,i,e,t);h.output=ze.OUTPUT.Default,h.blendIntensity=.3,h.enabled=!1,h.updateGtaoMaterial&&h.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.composer.addPass(h),this.ssaoPass=new nt(n,i,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=nt.OUTPUT.Default,this.ssaoPass.enabled=!1,this.composer.addPass(this.ssaoPass),this.saturationPass=new An(ya),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass);const c=new ma;c.enabled=!1,this.composer.addPass(c);const u=new An(ga);u.material.uniforms.resolution.value.x=1/(e*r),u.material.uniforms.resolution.value.y=1/(t*r),u.enabled=!1,this.composer.addPass(u)}}var En=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Us(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Bn(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 Pi={exports:{}};var Vs;function xa(){return Vs||(Vs=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 u=typeof Bn=="function"&&Bn;if(!c&&u)return u(h,!0);if(a)return a(h,!0);var p=new Error("Cannot find module '"+h+"'");throw p.code="MODULE_NOT_FOUND",p}var f=i[h]={exports:{}};n[h][0].call(f.exports,function(d){var m=n[h][1][d];return r(m||d)},f,f.exports,t,n,i,s)}return i[h].exports}for(var a=typeof Bn=="function"&&Bn,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,u,p,f,d,m,g=[],y=0,w=l.length,x=w,v=s.getTypeOf(l)!=="string";y<l.length;)x=w-y,u=v?(h=l[y++],c=y<w?l[y++]:0,y<w?l[y++]:0):(h=l.charCodeAt(y++),c=y<w?l.charCodeAt(y++):0,y<w?l.charCodeAt(y++):0),p=h>>2,f=(3&h)<<4|c>>4,d=1<x?(15&c)<<2|u>>6:64,m=2<x?63&u:64,g.push(a.charAt(p)+a.charAt(f)+a.charAt(d)+a.charAt(m));return g.join("")},i.decode=function(l){var h,c,u,p,f,d,m=0,g=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var w,x=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&x--,l.charAt(l.length-2)===a.charAt(64)&&x--,x%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=r.uint8array?new Uint8Array(0|x):new Array(0|x);m<l.length;)h=a.indexOf(l.charAt(m++))<<2|(p=a.indexOf(l.charAt(m++)))>>4,c=(15&p)<<4|(f=a.indexOf(l.charAt(m++)))>>2,u=(3&f)<<6|(d=a.indexOf(l.charAt(m++))),w[g++]=h,f!==64&&(w[g++]=c),d!==64&&(w[g++]=u);return w}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function h(c,u,p,f,d){this.compressedSize=c,this.uncompressedSize=u,this.crc32=p,this.compression=f,this.compressedContent=d}h.prototype={getContentWorker:function(){var c=new r(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return c.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new 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,u,p){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},n.exports=h},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var s=t("./utils"),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,u,p){var f=r,d=p+u;h^=-1;for(var m=p;m<d;m++)h=h>>>8^f[255&(h^c[m])];return-1^h})(0|l,a,a.length,0):(function(h,c,u,p){var f=r,d=p+u;h^=-1;for(var m=p;m<d;m++)h=h>>>8^f[255&(h^c.charCodeAt(m))];return-1^h})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var s=null;s=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:s}},{lie:37}],7:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),h=s?"uint8array":"array";function c(u,p){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=p,this.meta={}}i.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(h,u.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(p){u.push({data:p,meta:u.meta})}},i.compressWorker=function(u){return new c("Deflate",u)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(f,d){var m,g="";for(m=0;m<d;m++)g+=String.fromCharCode(255&f),f>>>=8;return g}function r(f,d,m,g,y,w){var x,v,b=f.file,T=f.compression,P=w!==h.utf8encode,k=a.transformTo("string",w(b.name)),D=a.transformTo("string",h.utf8encode(b.name)),E=b.comment,O=a.transformTo("string",w(E)),C=a.transformTo("string",h.utf8encode(E)),I=D.length!==b.name.length,M=C.length!==E.length,z="",Z="",G="",ee=b.dir,W=b.date,H={crc32:0,compressedSize:0,uncompressedSize:0};d&&!m||(H.crc32=f.crc32,H.compressedSize=f.compressedSize,H.uncompressedSize=f.uncompressedSize);var R=0;d&&(R|=8),P||!I&&!M||(R|=2048);var F=0,te=0;ee&&(F|=16),y==="UNIX"?(te=798,F|=(function(Y,de){var fe=Y;return Y||(fe=de?16893:33204),(65535&fe)<<16})(b.unixPermissions,ee)):(te=20,F|=(function(Y){return 63&(Y||0)})(b.dosPermissions)),x=W.getUTCHours(),x<<=6,x|=W.getUTCMinutes(),x<<=5,x|=W.getUTCSeconds()/2,v=W.getUTCFullYear()-1980,v<<=4,v|=W.getUTCMonth()+1,v<<=5,v|=W.getUTCDate(),I&&(Z=s(1,1)+s(c(k),4)+D,z+="up"+s(Z.length,2)+Z),M&&(G=s(1,1)+s(c(O),4)+C,z+="uc"+s(G.length,2)+G);var Q="";return Q+=`
|
|
961
|
+
\0`,Q+=s(R,2),Q+=T.magic,Q+=s(x,2),Q+=s(v,2),Q+=s(H.crc32,4),Q+=s(H.compressedSize,4),Q+=s(H.uncompressedSize,4),Q+=s(k.length,2),Q+=s(z.length,2),{fileRecord:u.LOCAL_FILE_HEADER+Q+k+z,dirRecord:u.CENTRAL_FILE_HEADER+s(te,2)+Q+s(O.length,2)+"\0\0\0\0"+s(F,4)+s(g,4)+k+z+O}}var a=t("../utils"),l=t("../stream/GenericWorker"),h=t("../utf8"),c=t("../crc32"),u=t("../signature");function p(f,d,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=d,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=f,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(f){var d=f.meta.percent||0,m=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(f):(this.bytesWritten+=f.data.length,l.prototype.push.call(this,{data:f.data,meta:{currentFile:this.currentFile,percent:m?(d+100*(m-g-1))/m:100}}))},p.prototype.openedSource=function(f){this.currentSourceOffset=this.bytesWritten,this.currentFile=f.file.name;var d=this.streamFiles&&!f.file.dir;if(d){var m=r(f,d,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(f){this.accumulate=!1;var d=this.streamFiles&&!f.file.dir,m=r(f,d,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),d)this.push({data:(function(g){return u.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(f),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var f=this.bytesWritten,d=0;d<this.dirRecords.length;d++)this.push({data:this.dirRecords[d],meta:{percent:100}});var m=this.bytesWritten-f,g=(function(y,w,x,v,b){var T=a.transformTo("string",b(v));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(w,4)+s(x,4)+s(T.length,2)+T})(this.dirRecords.length,m,f,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(f){this._sources.push(f);var d=this;return f.on("data",function(m){d.processChunk(m)}),f.on("end",function(){d.closedSource(d.previous.streamInfo),d._sources.length?d.prepareNextSource():d.end()}),f.on("error",function(m){d.error(m)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(f){var d=this._sources;if(!l.prototype.error.call(this,f))return!1;for(var m=0;m<d.length;m++)try{d[m].error(f)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var f=this._sources,d=0;d<f.length;d++)f[d].lock()},n.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),r=t("./ZipFileWorker");i.generateWorker=function(a,l,h){var c=new r(l.streamFiles,h,l.platform,l.encodeFileName),u=0;try{a.forEach(function(p,f){u++;var d=(function(w,x){var v=w||x,b=s[v];if(!b)throw new Error(v+" is not a valid compression method !");return b})(f.options.compression,l.compression),m=f.options.compressionOptions||l.compressionOptions||{},g=f.dir,y=f.date;f._compressWorker(d,m).withStreamInfo("file",{name:p,dir:g,date:y,comment:f.comment||"",unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions}).pipe(c)}),c.entriesCount=u}catch(p){c.error(p)}return c}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var 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 u(p){return new r.Promise(function(f,d){var m=p.decompressed.getContentWorker().pipe(new h);m.on("error",function(g){d(g)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?d(new Error("Corrupted zip : CRC32 mismatch")):f()}).resume()})}n.exports=function(p,f){var d=this;return f=s.extend(f||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(p)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,f.optimizedBinaryString,f.base64).then(function(m){var g=new l(f);return g.load(m),g}).then(function(m){var g=[r.Promise.resolve(m)],y=m.files;if(f.checkCRC32)for(var w=0;w<y.length;w++)g.push(u(y[w]));return r.Promise.all(g)}).then(function(m){for(var g=m.shift(),y=g.files,w=0;w<y.length;w++){var x=y[w],v=x.fileNameStr,b=s.resolve(x.fileNameStr);d.file(b,x.decompressed,{binary:!0,optimizedBinaryString:!0,date:x.date,dir:x.dir,comment:x.fileCommentStr.length?x.fileCommentStr:null,unixPermissions:x.unixPermissions,dosPermissions:x.dosPermissions,createFolders:f.createFolders}),x.dir||(d.file(b).unsafeOriginalName=v)}return g.zipComment.length&&(d.comment=g.zipComment),d})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),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(u,p){c.push(u)||c._helper.pause(),h&&h(p)}).on("error",function(u){c.emit("error",u)}).on("end",function(){c.push(null)})}t("../utils").inherits(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(b,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&&(b=y(b)),E.createFolders&&(k=g(b))&&w.call(this,k,!0);var O=D==="string"&&E.binary===!1&&E.base64===!1;P&&P.binary!==void 0||(E.binary=!O),(T instanceof u&&T.uncompressedSize===0||E.dir||!T||T.length===0)&&(E.base64=!1,E.binary=!0,T="",E.compression="STORE",D="string");var C=null;C=T instanceof u||T instanceof l?T:d.isNode&&d.isStream(T)?new m(b,T):a.prepareContent(b,T,E.binary,E.optimizedBinaryString,E.base64);var I=new p(b,C,E);this.files[b]=I}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),h=t("./stream/StreamHelper"),c=t("./defaults"),u=t("./compressedObject"),p=t("./zipObject"),f=t("./generate"),d=t("./nodejsUtils"),m=t("./nodejs/NodejsStreamInputAdapter"),g=function(b){b.slice(-1)==="/"&&(b=b.substring(0,b.length-1));var T=b.lastIndexOf("/");return 0<T?b.substring(0,T):""},y=function(b){return b.slice(-1)!=="/"&&(b+="/"),b},w=function(b,T){return T=T!==void 0?T:c.createFolders,b=y(b),this.files[b]||s.call(this,b,null,{dir:!0,createFolders:T}),this.files[b]};function x(b){return Object.prototype.toString.call(b)==="[object RegExp]"}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(b){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&&b(P,k)},filter:function(b){var T=[];return this.forEach(function(P,k){b(P,k)&&T.push(k)}),T},file:function(b,T,P){if(arguments.length!==1)return b=this.root+b,s.call(this,b,T,P),this;if(x(b)){var k=b;return this.filter(function(E,O){return!O.dir&&k.test(E)})}var D=this.files[this.root+b];return D&&!D.dir?D:null},folder:function(b){if(!b)return this;if(x(b))return this.filter(function(D,E){return E.dir&&b.test(D)});var T=this.root+b,P=w.call(this,T),k=this.clone();return k.root=P.name,k},remove:function(b){b=this.root+b;var T=this.files[b];if(T||(b.slice(-1)!=="/"&&(b+="/"),T=this.files[b]),T&&!T.dir)delete this.files[b];else for(var P=this.filter(function(D,E){return E.name.slice(0,b.length)===b}),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(b){var T,P={};try{if((P=a.extend(b||{},{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=f.generateWorker(this,P,k)}catch(D){(T=new l("error")).error(D)}return new h(T,P.type||"string",P.mimeType)},generateAsync:function(b,T){return this.generateInternalStream(b).accumulate(T)},generateNodeStream:function(b,T){return(b=b||{}).type||(b.type="nodebuffer"),this.generateInternalStream(b).toNodejsStream(T)}};n.exports=v},{"./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),u=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===h&&this.data[p+2]===c&&this.data[p+3]===u)return p-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),h=a.charCodeAt(1),c=a.charCodeAt(2),u=a.charCodeAt(3),p=this.readData(4);return l===p[0]&&h===p[1]&&c===p[2]&&u===p[3]},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(u){var p=s.getTypeOf(u);return s.checkSupport(p),p!=="string"||r.uint8array?p==="nodebuffer"?new h(u):r.uint8array?new c(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),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"),u=null;if(h.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(d,m){return new c.Promise(function(g,y){var w=[],x=d._internalType,v=d._outputType,b=d._mimeType;d.on("data",function(T,P){w.push(T),m&&m(P)}).on("error",function(T){w=[],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)}})(v,(function(P,k){var D,E=0,O=null,C=0;for(D=0;D<k.length;D++)C+=k[D].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(C),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+"'")}})(x,w),b);g(T)}catch(P){y(P)}w=[]}).resume()})}function f(d,m,g){var y=m;switch(m){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=m,this._mimeType=g,s.checkSupport(y),this._worker=d.pipe(new r(y)),d.lock()}catch(w){this._worker=new a("error"),this._worker.error(w)}}f.prototype={accumulate:function(d){return p(this,d)},on:function(d,m){var g=this;return d==="data"?this._worker.on(d,function(y){m.call(g,y.data,y.meta)}):this._worker.on(d,function(){s.delay(m,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(d){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},d)}},n.exports=f},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var 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 u(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}i.utf8encode=function(f){return r.nodebuffer?a.newBufferFrom(f,"utf-8"):(function(d){var m,g,y,w,x,v=d.length,b=0;for(w=0;w<v;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<v&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),b+=g<128?1:g<2048?2:g<65536?3:4;for(m=r.uint8array?new Uint8Array(b):new Array(b),w=x=0;x<b;w++)(64512&(g=d.charCodeAt(w)))==55296&&w+1<v&&(64512&(y=d.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),w++),g<128?m[x++]=g:(g<2048?m[x++]=192|g>>>6:(g<65536?m[x++]=224|g>>>12:(m[x++]=240|g>>>18,m[x++]=128|g>>>12&63),m[x++]=128|g>>>6&63),m[x++]=128|63&g);return m})(f)},i.utf8decode=function(f){return r.nodebuffer?s.transformTo("nodebuffer",f).toString("utf-8"):(function(d){var m,g,y,w,x=d.length,v=new Array(2*x);for(m=g=0;m<x;)if((y=d[m++])<128)v[g++]=y;else if(4<(w=h[y]))v[g++]=65533,m+=w-1;else{for(y&=w===2?31:w===3?15:7;1<w&&m<x;)y=y<<6|63&d[m++],w--;1<w?v[g++]=65533:y<65536?v[g++]=y:(y-=65536,v[g++]=55296|y>>10&1023,v[g++]=56320|1023&y)}return v.length!==g&&(v.subarray?v=v.subarray(0,g):v.length=g),s.applyFromCharCode(v)})(f=s.transformTo(r.uint8array?"uint8array":"array",f))},s.inherits(u,l),u.prototype.processChunk=function(f){var d=s.transformTo(r.uint8array?"uint8array":"array",f.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var m=d;(d=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),d.set(m,this.leftOver.length)}else d=this.leftOver.concat(d);this.leftOver=null}var g=(function(w,x){var v;for((x=x||w.length)>w.length&&(x=w.length),v=x-1;0<=v&&(192&w[v])==128;)v--;return v<0||v===0?x:v+h[w[v]]>x?v:x})(d),y=d;g!==d.length&&(r.uint8array?(y=d.subarray(0,g),this.leftOver=d.subarray(g,d.length)):(y=d.slice(0,g),this.leftOver=d.slice(g,d.length))),this.push({data:i.utf8decode(y),meta:f.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=u,s.inherits(p,l),p.prototype.processChunk=function(f){this.push({data:i.utf8encode(f.data),meta:f.meta})},i.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function h(m){return m}function c(m,g){for(var y=0;y<m.length;++y)g[y]=255&m.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(m,g){i.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(m),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,g,y){var w=[],x=0,v=m.length;if(v<=y)return String.fromCharCode.apply(null,m);for(;x<v;)g==="array"||g==="nodebuffer"?w.push(String.fromCharCode.apply(null,m.slice(x,Math.min(x+y,v)))):w.push(String.fromCharCode.apply(null,m.subarray(x,Math.min(x+y,v)))),x+=y;return w.join("")},stringifyByChar:function(m){for(var g="",y=0;y<m.length;y++)g+=String.fromCharCode(m[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var g=65536,y=i.getTypeOf(m),w=!0;if(y==="uint8array"?w=u.applyCanBeUsed.uint8array:y==="nodebuffer"&&(w=u.applyCanBeUsed.nodebuffer),w)for(;1<g;)try{return u.stringifyByChunk(m,y,g)}catch{g=Math.floor(g/2)}return u.stringifyByChar(m)}function f(m,g){for(var y=0;y<m.length;y++)g[y]=m[y];return g}i.applyFromCharCode=p;var d={};d.string={string:h,array:function(m){return c(m,new Array(m.length))},arraybuffer:function(m){return d.string.uint8array(m).buffer},uint8array:function(m){return c(m,new Uint8Array(m.length))},nodebuffer:function(m){return c(m,a.allocBuffer(m.length))}},d.array={string:p,array:h,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},d.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return f(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:h,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},d.uint8array={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:h,nodebuffer:function(m){return a.newBufferFrom(m)}},d.nodebuffer={string:p,array:function(m){return f(m,new Array(m.length))},arraybuffer:function(m){return d.nodebuffer.uint8array(m).buffer},uint8array:function(m){return f(m,new Uint8Array(m.length))},nodebuffer:h},i.transformTo=function(m,g){if(g=g||"",!m)return g;i.checkSupport(m);var y=i.getTypeOf(g);return d[y][m](g)},i.resolve=function(m){for(var g=m.split("/"),y=[],w=0;w<g.length;w++){var x=g[w];x==="."||x===""&&w!==0&&w!==g.length-1||(x===".."?y.pop():y.push(x))}return y.join("/")},i.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(m){var g,y,w="";for(y=0;y<(m||"").length;y++)w+="\\x"+((g=m.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return w},i.delay=function(m,g,y){setImmediate(function(){m.apply(y||null,g||[])})},i.inherits=function(m,g){function y(){}y.prototype=g.prototype,m.prototype=new y},i.extend=function(){var m,g,y={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&y[g]===void 0&&(y[g]=arguments[m][g]);return y},i.prepareContent=function(m,g,y,w,x){return l.Promise.resolve(g).then(function(v){return s.blob&&(v instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(v))!==-1)&&typeof FileReader<"u"?new l.Promise(function(b,T){var P=new FileReader;P.onload=function(k){b(k.target.result)},P.onerror=function(k){T(k.target.error)},P.readAsArrayBuffer(v)}):v}).then(function(v){var b=i.getTypeOf(v);return b?(b==="arraybuffer"?v=i.transformTo("uint8array",v):b==="string"&&(x?v=r.decode(v):y&&w!==!0&&(v=(function(T){return c(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(v))),v):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),h=t("./support");function c(u){this.files=[],this.loadOptions=u}c.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(p)+", expected "+r.pretty(u)+")")}},isSignature:function(u,p){var f=this.reader.index;this.reader.setIndex(u);var d=this.reader.readString(4)===p;return this.reader.setIndex(f),d},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),p=h.uint8array?"uint8array":"array",f=r.transformTo(p,u);this.zipComment=this.loadOptions.decodeFileName(f)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,p,f,d=this.zip64EndOfCentralSize-44;0<d;)u=this.reader.readInt(2),p=this.reader.readInt(4),f=this.reader.readData(p),this.zip64ExtensibleData[u]={id:u,length:p,value:f}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,p;for(u=0;u<this.files.length;u++)p=this.files[u],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var p=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===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,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var f=this.centralDirOffset+this.centralDirSize;this.zip64&&(f+=20,f+=12+this.zip64EndOfCentralSize);var d=p-f;if(0<d)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=d);else if(d<0)throw new Error("Corrupted zip: missing "+Math.abs(d)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),h=t("./utf8"),c=t("./compressions"),u=t("./support");function p(f,d){this.options=f,this.loadOptions=d}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(f){var d,m;if(f.skip(22),this.fileNameLength=f.readInt(2),m=f.readInt(2),this.fileName=f.readData(this.fileNameLength),f.skip(m),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((d=(function(g){for(var y in c)if(Object.prototype.hasOwnProperty.call(c,y)&&c[y].magic===g)return c[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,d,f.readData(this.compressedSize))},readCentralPart:function(f){this.versionMadeBy=f.readInt(2),f.skip(2),this.bitFlag=f.readInt(2),this.compressionMethod=f.readString(2),this.date=f.readDate(),this.crc32=f.readInt(4),this.compressedSize=f.readInt(4),this.uncompressedSize=f.readInt(4);var d=f.readInt(2);if(this.extraFieldsLength=f.readInt(2),this.fileCommentLength=f.readInt(2),this.diskNumberStart=f.readInt(2),this.internalFileAttributes=f.readInt(2),this.externalFileAttributes=f.readInt(4),this.localHeaderOffset=f.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");f.skip(d),this.readExtraFields(f),this.parseZIP64ExtraField(f),this.fileComment=f.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var f=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),f==0&&(this.dosPermissions=63&this.externalFileAttributes),f==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var f=s(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=f.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=f.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=f.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=f.readInt(4))}},readExtraFields:function(f){var d,m,g,y=f.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});f.index+4<y;)d=f.readInt(2),m=f.readInt(2),g=f.readData(m),this.extraFields[d]={id:d,length:m,value:g};f.setIndex(y)},handleUTF8:function(){var f=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=h.utf8decode(this.fileName),this.fileCommentStr=h.utf8decode(this.fileComment);else{var d=this.findExtraFieldUnicodePath();if(d!==null)this.fileNameStr=d;else{var m=r.transformTo(f,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=r.transformTo(f,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var f=this.extraFields[28789];if(f){var d=s(f.value);return d.readInt(1)!==1||l(this.fileName)!==d.readInt(4)?null:h.utf8decode(d.readData(f.length-5))}return null},findExtraFieldUnicodeComment:function(){var f=this.extraFields[25461];if(f){var d=s(f.value);return d.readInt(1)!==1||l(this.fileComment)!==d.readInt(4)?null:h.utf8decode(d.readData(f.length-5))}return null}},n.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(d,m,g){this.name=d,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),h=t("./compressedObject"),c=t("./stream/GenericWorker");s.prototype={internalStream:function(d){var m=null,g="string";try{if(!d)throw new Error("No output type specified.");var y=(g=d.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var w=!this._dataBinary;w&&!y&&(m=m.pipe(new l.Utf8EncodeWorker)),!w&&y&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(x){(m=new c("error")).error(x)}return new r(m,g,"")},async:function(d,m){return this.internalStream(d).accumulate(m)},nodeStream:function(d,m){return this.internalStream(d||"nodebuffer").toNodejsStream(m)},_compressWorker:function(d,m){if(this._data instanceof h&&this._data.compression.magic===d.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),h.createWorkerFrom(g,d,m)},_decompressWorker:function(){return this._data instanceof h?this._data.getContentWorker():this._data instanceof c?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},f=0;f<u.length;f++)s.prototype[u[f]]=p;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var r,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var h=0,c=new l(d),u=s.document.createTextNode("");c.observe(u,{characterData:!0}),r=function(){u.data=h=++h%2}}else if(s.setImmediate||s.MessageChannel===void 0)r="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){d(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(d,0)};else{var p=new s.MessageChannel;p.port1.onmessage=d,r=function(){p.port2.postMessage(0)}}var f=[];function d(){var m,g;a=!0;for(var y=f.length;y;){for(g=f,f=[],m=-1;++m<y;)g[m]();y=f.length}a=!1}n.exports=function(m){f.push(m)!==1||a||r()}}).call(this,typeof En<"u"?En: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 u(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,y!==r&&m(this,y)}function p(y,w,x){this.promise=y,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}function f(y,w,x){s(function(){var v;try{v=w(x)}catch(b){return a.reject(y,b)}v===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,v)})}function d(y){var w=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof w=="function")return function(){w.apply(y,arguments)}}function m(y,w){var x=!1;function v(P){x||(x=!0,a.reject(y,P))}function b(P){x||(x=!0,a.resolve(y,P))}var T=g(function(){w(b,v)});T.status==="error"&&v(T.value)}function g(y,w){var x={};try{x.value=y(w),x.status="success"}catch(v){x.status="error",x.value=v}return x}(n.exports=u).prototype.finally=function(y){if(typeof y!="function")return this;var w=this.constructor;return this.then(function(x){return w.resolve(y()).then(function(){return x})},function(x){return w.resolve(y()).then(function(){throw x})})},u.prototype.catch=function(y){return this.then(null,y)},u.prototype.then=function(y,w){if(typeof y!="function"&&this.state===h||typeof w!="function"&&this.state===l)return this;var x=new this.constructor(r);return this.state!==c?f(x,this.state===h?y:w,this.outcome):this.queue.push(new p(x,y,w)),x},p.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){f(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){a.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){f(this.promise,this.onRejected,y)},a.resolve=function(y,w){var x=g(d,w);if(x.status==="error")return a.reject(y,x.value);var v=x.value;if(v)m(y,v);else{y.state=h,y.outcome=w;for(var b=-1,T=y.queue.length;++b<T;)y.queue[b].callFulfilled(w)}return y},a.reject=function(y,w){y.state=l,y.outcome=w;for(var x=-1,v=y.queue.length;++x<v;)y.queue[x].callRejected(w);return y},u.resolve=function(y){return y instanceof this?y:a.resolve(new this(r),y)},u.reject=function(y){var w=new this(r);return a.reject(w,y)},u.all=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=y.length,v=!1;if(!x)return this.resolve([]);for(var b=new Array(x),T=0,P=-1,k=new this(r);++P<x;)D(y[P],P);return k;function D(E,O){w.resolve(E).then(function(C){b[O]=C,++T!==x||v||(v=!0,a.resolve(k,b))},function(C){v||(v=!0,a.reject(k,C))})}},u.race=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=y.length,v=!1;if(!x)return this.resolve([]);for(var b=-1,T=new this(r);++b<x;)P=y[b],w.resolve(P).then(function(k){v||(v=!0,a.resolve(T,k))},function(k){v||(v=!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,u=0,p=-1,f=0,d=8;function m(y){if(!(this instanceof m))return new m(y);this.options=r.assign({level:p,method:d,chunkSize:16384,windowBits:15,memLevel:8,strategy:f,to:""},y||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var x=s.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(x!==u)throw new Error(l[x]);if(w.header&&s.deflateSetHeader(this.strm,w.header),w.dictionary){var v;if(v=typeof w.dictionary=="string"?a.string2buf(w.dictionary):c.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(x=s.deflateSetDictionary(this.strm,v))!==u)throw new Error(l[x]);this._dict_set=!0}}function g(y,w){var x=new m(w);if(x.push(y,!0),x.err)throw x.msg||l[x.err];return x.result}m.prototype.push=function(y,w){var x,v,b=this.strm,T=this.options.chunkSize;if(this.ended)return!1;v=w===~~w?w:w===!0?4:0,typeof y=="string"?b.input=a.string2buf(y):c.call(y)==="[object ArrayBuffer]"?b.input=new Uint8Array(y):b.input=y,b.next_in=0,b.avail_in=b.input.length;do{if(b.avail_out===0&&(b.output=new r.Buf8(T),b.next_out=0,b.avail_out=T),(x=s.deflate(b,v))!==1&&x!==u)return this.onEnd(x),!(this.ended=!0);b.avail_out!==0&&(b.avail_in!==0||v!==4&&v!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(r.shrinkBuf(b.output,b.next_out))):this.onData(r.shrinkBuf(b.output,b.next_out)))}while((0<b.avail_in||b.avail_out===0)&&x!==1);return v===4?(x=s.deflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===u):v!==2||(this.onEnd(u),!(b.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=m,i.deflate=g,i.deflateRaw=function(y,w){return(w=w||{}).raw=!0,g(y,w)},i.gzip=function(y,w){return(w=w||{}).gzip=!0,g(y,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var s=t("./zlib/inflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),c=t("./zlib/zstream"),u=t("./zlib/gzheader"),p=Object.prototype.toString;function f(m){if(!(this instanceof f))return new f(m);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(h[y]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function d(m,g){var y=new f(g);if(y.push(m,!0),y.err)throw y.msg||h[y.err];return y.result}f.prototype.push=function(m,g){var y,w,x,v,b,T,P=this.strm,k=this.options.chunkSize,D=this.options.dictionary,E=!1;if(this.ended)return!1;w=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?P.input=a.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?P.input=new Uint8Array(m):P.input=m,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new 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):p.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||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(x=a.utf8border(P.output,P.next_out),v=P.next_out-x,b=a.buf2string(P.output,x),P.next_out=v,P.avail_out=k-v,v&&r.arraySet(P.output,P.output,x,v,0),this.onData(b)):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&&(w=l.Z_FINISH),w===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},f.prototype.onData=function(m){this.chunks.push(m)},f.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},i.Inflate=f,i.inflate=d,i.inflateRaw=function(m,g){return(g=g||{}).raw=!0,d(m,g)},i.ungzip=d},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var h=Array.prototype.slice.call(arguments,1);h.length;){var c=h.shift();if(c){if(typeof c!="object")throw new TypeError(c+"must be non-object");for(var u in c)c.hasOwnProperty(u)&&(l[u]=c[u])}}return l},i.shrinkBuf=function(l,h){return l.length===h?l:l.subarray?l.subarray(0,h):(l.length=h,l)};var r={arraySet:function(l,h,c,u,p){if(h.subarray&&l.subarray)l.set(h.subarray(c,c+u),p);else for(var f=0;f<u;f++)l[p+f]=h[c+f]},flattenChunks:function(l){var h,c,u,p,f,d;for(h=u=0,c=l.length;h<c;h++)u+=l[h].length;for(d=new Uint8Array(u),h=p=0,c=l.length;h<c;h++)f=l[h],d.set(f,p),p+=f.length;return d}},a={arraySet:function(l,h,c,u,p){for(var f=0;f<u;f++)l[p+f]=h[c+f]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,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(u,p){if(p<65537&&(u.subarray&&a||!u.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(u,p));for(var f="",d=0;d<p;d++)f+=String.fromCharCode(u[d]);return f}l[254]=l[254]=1,i.string2buf=function(u){var p,f,d,m,g,y=u.length,w=0;for(m=0;m<y;m++)(64512&(f=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(d-56320),m++),w+=f<128?1:f<2048?2:f<65536?3:4;for(p=new s.Buf8(w),m=g=0;g<w;m++)(64512&(f=u.charCodeAt(m)))==55296&&m+1<y&&(64512&(d=u.charCodeAt(m+1)))==56320&&(f=65536+(f-55296<<10)+(d-56320),m++),f<128?p[g++]=f:(f<2048?p[g++]=192|f>>>6:(f<65536?p[g++]=224|f>>>12:(p[g++]=240|f>>>18,p[g++]=128|f>>>12&63),p[g++]=128|f>>>6&63),p[g++]=128|63&f);return p},i.buf2binstring=function(u){return c(u,u.length)},i.binstring2buf=function(u){for(var p=new s.Buf8(u.length),f=0,d=p.length;f<d;f++)p[f]=u.charCodeAt(f);return p},i.buf2string=function(u,p){var f,d,m,g,y=p||u.length,w=new Array(2*y);for(f=d=0;f<y;)if((m=u[f++])<128)w[d++]=m;else if(4<(g=l[m]))w[d++]=65533,f+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&f<y;)m=m<<6|63&u[f++],g--;1<g?w[d++]=65533:m<65536?w[d++]=m:(m-=65536,w[d++]=55296|m>>10&1023,w[d++]=56320|1023&m)}return c(w,d)},i.utf8border=function(u,p){var f;for((p=p||u.length)>u.length&&(p=u.length),f=p-1;0<=f&&(192&u[f])==128;)f--;return f<0||f===0?p:f+l[u[f]]>p?f:p}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,r,a,l){for(var h=65535&s|0,c=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;c=c+(h=h+r[l++]|0)|0,--u;);h%=65521,c%=65521}return h|c<<16|0}},{}],44:[function(t,n,i){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,n,i){var s=(function(){for(var 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,u=h+l;r^=-1;for(var p=h;p<u;p++)r=r>>>8^c[255&(r^a[p])];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"),u=0,p=4,f=0,d=-2,m=-1,g=4,y=2,w=8,x=9,v=286,b=30,T=19,P=2*v+1,k=15,D=3,E=258,O=E+D+1,C=42,I=113,M=1,z=2,Z=3,G=4;function ee(S,X){return S.msg=c[X],X}function W(S){return(S<<1)-(4<S?9:0)}function H(S){for(var X=S.length;0<=--X;)S[X]=0}function R(S){var X=S.state,j=X.pending;j>S.avail_out&&(j=S.avail_out),j!==0&&(r.arraySet(S.output,X.pending_buf,X.pending_out,j,S.next_out),S.next_out+=j,X.pending_out+=j,S.total_out+=j,S.avail_out-=j,X.pending-=j,X.pending===0&&(X.pending_out=0))}function F(S,X){a._tr_flush_block(S,0<=S.block_start?S.block_start:-1,S.strstart-S.block_start,X),S.block_start=S.strstart,R(S.strm)}function te(S,X){S.pending_buf[S.pending++]=X}function Q(S,X){S.pending_buf[S.pending++]=X>>>8&255,S.pending_buf[S.pending++]=255&X}function Y(S,X){var j,B,L=S.max_chain_length,N=S.strstart,q=S.prev_length,K=S.nice_match,U=S.strstart>S.w_size-O?S.strstart-(S.w_size-O):0,$=S.window,ne=S.w_mask,J=S.prev,ie=S.strstart+E,ce=$[N+q-1],ae=$[N+q];S.prev_length>=S.good_match&&(L>>=2),K>S.lookahead&&(K=S.lookahead);do if($[(j=X)+q]===ae&&$[j+q-1]===ce&&$[j]===$[N]&&$[++j]===$[N+1]){N+=2,j++;do;while($[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&$[++N]===$[++j]&&N<ie);if(B=E-(ie-N),N=ie-E,q<B){if(S.match_start=X,K<=(q=B))break;ce=$[N+q-1],ae=$[N+q]}}while((X=J[X&ne])>U&&--L!=0);return q<=S.lookahead?q:S.lookahead}function de(S){var X,j,B,L,N,q,K,U,$,ne,J=S.w_size;do{if(L=S.window_size-S.lookahead-S.strstart,S.strstart>=J+(J-O)){for(r.arraySet(S.window,S.window,J,J,0),S.match_start-=J,S.strstart-=J,S.block_start-=J,X=j=S.hash_size;B=S.head[--X],S.head[X]=J<=B?B-J:0,--j;);for(X=j=J;B=S.prev[--X],S.prev[X]=J<=B?B-J:0,--j;);L+=J}if(S.strm.avail_in===0)break;if(q=S.strm,K=S.window,U=S.strstart+S.lookahead,$=L,ne=void 0,ne=q.avail_in,$<ne&&(ne=$),j=ne===0?0:(q.avail_in-=ne,r.arraySet(K,q.input,q.next_in,ne,U),q.state.wrap===1?q.adler=l(q.adler,K,ne,U):q.state.wrap===2&&(q.adler=h(q.adler,K,ne,U)),q.next_in+=ne,q.total_in+=ne,ne),S.lookahead+=j,S.lookahead+S.insert>=D)for(N=S.strstart-S.insert,S.ins_h=S.window[N],S.ins_h=(S.ins_h<<S.hash_shift^S.window[N+1])&S.hash_mask;S.insert&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[N+D-1])&S.hash_mask,S.prev[N&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=N,N++,S.insert--,!(S.lookahead+S.insert<D)););}while(S.lookahead<O&&S.strm.avail_in!==0)}function fe(S,X){for(var j,B;;){if(S.lookahead<O){if(de(S),S.lookahead<O&&X===u)return M;if(S.lookahead===0)break}if(j=0,S.lookahead>=D&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+D-1])&S.hash_mask,j=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),j!==0&&S.strstart-j<=S.w_size-O&&(S.match_length=Y(S,j)),S.match_length>=D)if(B=a._tr_tally(S,S.strstart-S.match_start,S.match_length-D),S.lookahead-=S.match_length,S.match_length<=S.max_lazy_match&&S.lookahead>=D){for(S.match_length--;S.strstart++,S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+D-1])&S.hash_mask,j=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart,--S.match_length!=0;);S.strstart++}else S.strstart+=S.match_length,S.match_length=0,S.ins_h=S.window[S.strstart],S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+1])&S.hash_mask;else B=a._tr_tally(S,0,S.window[S.strstart]),S.lookahead--,S.strstart++;if(B&&(F(S,!1),S.strm.avail_out===0))return M}return S.insert=S.strstart<D-1?S.strstart:D-1,X===p?(F(S,!0),S.strm.avail_out===0?Z:G):S.last_lit&&(F(S,!1),S.strm.avail_out===0)?M:z}function se(S,X){for(var j,B,L;;){if(S.lookahead<O){if(de(S),S.lookahead<O&&X===u)return M;if(S.lookahead===0)break}if(j=0,S.lookahead>=D&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+D-1])&S.hash_mask,j=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),S.prev_length=S.match_length,S.prev_match=S.match_start,S.match_length=D-1,j!==0&&S.prev_length<S.max_lazy_match&&S.strstart-j<=S.w_size-O&&(S.match_length=Y(S,j),S.match_length<=5&&(S.strategy===1||S.match_length===D&&4096<S.strstart-S.match_start)&&(S.match_length=D-1)),S.prev_length>=D&&S.match_length<=S.prev_length){for(L=S.strstart+S.lookahead-D,B=a._tr_tally(S,S.strstart-1-S.prev_match,S.prev_length-D),S.lookahead-=S.prev_length-1,S.prev_length-=2;++S.strstart<=L&&(S.ins_h=(S.ins_h<<S.hash_shift^S.window[S.strstart+D-1])&S.hash_mask,j=S.prev[S.strstart&S.w_mask]=S.head[S.ins_h],S.head[S.ins_h]=S.strstart),--S.prev_length!=0;);if(S.match_available=0,S.match_length=D-1,S.strstart++,B&&(F(S,!1),S.strm.avail_out===0))return M}else if(S.match_available){if((B=a._tr_tally(S,0,S.window[S.strstart-1]))&&F(S,!1),S.strstart++,S.lookahead--,S.strm.avail_out===0)return M}else S.match_available=1,S.strstart++,S.lookahead--}return S.match_available&&(B=a._tr_tally(S,0,S.window[S.strstart-1]),S.match_available=0),S.insert=S.strstart<D-1?S.strstart:D-1,X===p?(F(S,!0),S.strm.avail_out===0?Z:G):S.last_lit&&(F(S,!1),S.strm.avail_out===0)?M:z}function oe(S,X,j,B,L){this.good_length=S,this.max_lazy=X,this.nice_length=j,this.max_chain=B,this.func=L}function he(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(2*P),this.dyn_dtree=new r.Buf16(2*(2*b+1)),this.bl_tree=new r.Buf16(2*(2*T+1)),H(this.dyn_ltree),H(this.dyn_dtree),H(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*v+1),H(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*v+1),H(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(S){var X;return S&&S.state?(S.total_in=S.total_out=0,S.data_type=y,(X=S.state).pending=0,X.pending_out=0,X.wrap<0&&(X.wrap=-X.wrap),X.status=X.wrap?C:I,S.adler=X.wrap===2?0:1,X.last_flush=u,a._tr_init(X),f):ee(S,d)}function Ae(S){var X=pe(S);return X===f&&(function(j){j.window_size=2*j.w_size,H(j.head),j.max_lazy_match=s[j.level].max_lazy,j.good_match=s[j.level].good_length,j.nice_match=s[j.level].nice_length,j.max_chain_length=s[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=D-1,j.match_available=0,j.ins_h=0})(S.state),X}function Be(S,X,j,B,L,N){if(!S)return d;var q=1;if(X===m&&(X=6),B<0?(q=0,B=-B):15<B&&(q=2,B-=16),L<1||x<L||j!==w||B<8||15<B||X<0||9<X||N<0||g<N)return ee(S,d);B===8&&(B=9);var K=new he;return(S.state=K).strm=S,K.wrap=q,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=X,K.strategy=N,K.method=j,Ae(S)}s=[new oe(0,0,0,0,function(S,X){var j=65535;for(j>S.pending_buf_size-5&&(j=S.pending_buf_size-5);;){if(S.lookahead<=1){if(de(S),S.lookahead===0&&X===u)return M;if(S.lookahead===0)break}S.strstart+=S.lookahead,S.lookahead=0;var B=S.block_start+j;if((S.strstart===0||S.strstart>=B)&&(S.lookahead=S.strstart-B,S.strstart=B,F(S,!1),S.strm.avail_out===0)||S.strstart-S.block_start>=S.w_size-O&&(F(S,!1),S.strm.avail_out===0))return M}return S.insert=0,X===p?(F(S,!0),S.strm.avail_out===0?Z:G):(S.strstart>S.block_start&&(F(S,!1),S.strm.avail_out),M)}),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(S,X){return Be(S,X,w,15,8,0)},i.deflateInit2=Be,i.deflateReset=Ae,i.deflateResetKeep=pe,i.deflateSetHeader=function(S,X){return S&&S.state?S.state.wrap!==2?d:(S.state.gzhead=X,f):d},i.deflate=function(S,X){var j,B,L,N;if(!S||!S.state||5<X||X<0)return S?ee(S,d):d;if(B=S.state,!S.output||!S.input&&S.avail_in!==0||B.status===666&&X!==p)return ee(S,S.avail_out===0?-5:d);if(B.strm=S,j=B.last_flush,B.last_flush=X,B.status===C)if(B.wrap===2)S.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&&(S.adler=h(S.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 q=w+(B.w_bits-8<<4)<<8;q|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(q|=32),q+=31-q%31,B.status=I,Q(B,q),B.strstart!==0&&(Q(B,S.adler>>>16),Q(B,65535&S.adler)),S.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&&(S.adler=h(S.adler,B.pending_buf,B.pending-L,L)),R(S),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&&(S.adler=h(S.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&&(S.adler=h(S.adler,B.pending_buf,B.pending-L,L)),R(S),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&&(S.adler=h(S.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&&(S.adler=h(S.adler,B.pending_buf,B.pending-L,L)),R(S),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&&(S.adler=h(S.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&&R(S),B.pending+2<=B.pending_buf_size&&(te(B,255&S.adler),te(B,S.adler>>8&255),S.adler=0,B.status=I)):B.status=I),B.pending!==0){if(R(S),S.avail_out===0)return B.last_flush=-1,f}else if(S.avail_in===0&&W(X)<=W(j)&&X!==p)return ee(S,-5);if(B.status===666&&S.avail_in!==0)return ee(S,-5);if(S.avail_in!==0||B.lookahead!==0||X!==u&&B.status!==666){var K=B.strategy===2?(function(U,$){for(var ne;;){if(U.lookahead===0&&(de(U),U.lookahead===0)){if($===u)return M;break}if(U.match_length=0,ne=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,ne&&(F(U,!1),U.strm.avail_out===0))return M}return U.insert=0,$===p?(F(U,!0),U.strm.avail_out===0?Z:G):U.last_lit&&(F(U,!1),U.strm.avail_out===0)?M:z})(B,X):B.strategy===3?(function(U,$){for(var ne,J,ie,ce,ae=U.window;;){if(U.lookahead<=E){if(de(U),U.lookahead<=E&&$===u)return M;if(U.lookahead===0)break}if(U.match_length=0,U.lookahead>=D&&0<U.strstart&&(J=ae[ie=U.strstart-1])===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]){ce=U.strstart+E;do;while(J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&J===ae[++ie]&&ie<ce);U.match_length=E-(ce-ie),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=D?(ne=a._tr_tally(U,1,U.match_length-D),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(ne=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),ne&&(F(U,!1),U.strm.avail_out===0))return M}return U.insert=0,$===p?(F(U,!0),U.strm.avail_out===0?Z:G):U.last_lit&&(F(U,!1),U.strm.avail_out===0)?M:z})(B,X):s[B.level].func(B,X);if(K!==Z&&K!==G||(B.status=666),K===M||K===Z)return S.avail_out===0&&(B.last_flush=-1),f;if(K===z&&(X===1?a._tr_align(B):X!==5&&(a._tr_stored_block(B,0,0,!1),X===3&&(H(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),R(S),S.avail_out===0))return B.last_flush=-1,f}return X!==p?f:B.wrap<=0?1:(B.wrap===2?(te(B,255&S.adler),te(B,S.adler>>8&255),te(B,S.adler>>16&255),te(B,S.adler>>24&255),te(B,255&S.total_in),te(B,S.total_in>>8&255),te(B,S.total_in>>16&255),te(B,S.total_in>>24&255)):(Q(B,S.adler>>>16),Q(B,65535&S.adler)),R(S),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?f:1)},i.deflateEnd=function(S){var X;return S&&S.state?(X=S.state.status)!==C&&X!==69&&X!==73&&X!==91&&X!==103&&X!==I&&X!==666?ee(S,d):(S.state=null,X===I?ee(S,-3):f):d},i.deflateSetDictionary=function(S,X){var j,B,L,N,q,K,U,$,ne=X.length;if(!S||!S.state||(N=(j=S.state).wrap)===2||N===1&&j.status!==C||j.lookahead)return d;for(N===1&&(S.adler=l(S.adler,X,ne,0)),j.wrap=0,ne>=j.w_size&&(N===0&&(H(j.head),j.strstart=0,j.block_start=0,j.insert=0),$=new r.Buf8(j.w_size),r.arraySet($,X,ne-j.w_size,j.w_size,0),X=$,ne=j.w_size),q=S.avail_in,K=S.next_in,U=S.input,S.avail_in=ne,S.next_in=0,S.input=X,de(j);j.lookahead>=D;){for(B=j.strstart,L=j.lookahead-(D-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[B+D-1])&j.hash_mask,j.prev[B&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=B,B++,--L;);j.strstart=B,j.lookahead=D-1,de(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=D-1,j.match_available=0,S.next_in=K,S.input=U,S.avail_in=q,j.wrap=N,f},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,n,i){n.exports=function(s,r){var a,l,h,c,u,p,f,d,m,g,y,w,x,v,b,T,P,k,D,E,O,C,I,M,z;a=s.state,l=s.next_in,M=s.input,h=l+(s.avail_in-5),c=s.next_out,z=s.output,u=c-(r-s.avail_out),p=c+(s.avail_out-257),f=a.dmax,d=a.wsize,m=a.whave,g=a.wnext,y=a.window,w=a.hold,x=a.bits,v=a.lencode,b=a.distcode,T=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{x<15&&(w+=M[l++]<<x,x+=8,w+=M[l++]<<x,x+=8),k=v[w&T];t:for(;;){if(w>>>=D=k>>>24,x-=D,(D=k>>>16&255)===0)z[c++]=65535&k;else{if(!(16&D)){if((64&D)==0){k=v[(65535&k)+(w&(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)&&(x<D&&(w+=M[l++]<<x,x+=8),E+=w&(1<<D)-1,w>>>=D,x-=D),x<15&&(w+=M[l++]<<x,x+=8,w+=M[l++]<<x,x+=8),k=b[w&P];n:for(;;){if(w>>>=D=k>>>24,x-=D,!(16&(D=k>>>16&255))){if((64&D)==0){k=b[(65535&k)+(w&(1<<D)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,x<(D&=15)&&(w+=M[l++]<<x,(x+=8)<D&&(w+=M[l++]<<x,x+=8)),f<(O+=w&(1<<D)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(w>>>=D,x-=D,(D=c-u)<O){if(m<(D=O-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=y,(C=0)===g){if(C+=d-D,D<E){for(E-=D;z[c++]=y[C++],--D;);C=c-O,I=z}}else if(g<D){if(C+=d+g-D,(D-=g)<E){for(E-=D;z[c++]=y[C++],--D;);if(C=0,g<E){for(E-=D=g;z[c++]=y[C++],--D;);C=c-O,I=z}}}else if(C+=g-D,D<E){for(E-=D;z[c++]=y[C++],--D;);C=c-O,I=z}for(;2<E;)z[c++]=I[C++],z[c++]=I[C++],z[c++]=I[C++],E-=3;E&&(z[c++]=I[C++],1<E&&(z[c++]=I[C++]))}else{for(C=c-O;z[c++]=z[C++],z[c++]=z[C++],z[c++]=z[C++],2<(E-=3););E&&(z[c++]=z[C++],1<E&&(z[c++]=z[C++]))}break}}break}}while(l<h&&c<p);l-=E=x>>3,w&=(1<<(x-=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<p?p-c+257:257-(c-p),a.hold=w,a.bits=x}},{}],49:[function(t,n,i){var s=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),h=t("./inftrees"),c=1,u=2,p=0,f=-2,d=1,m=852,g=592;function y(C){return(C>>>24&255)+(C>>>8&65280)+((65280&C)<<8)+((255&C)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x(C){var I;return C&&C.state?(I=C.state,C.total_in=C.total_out=I.total=0,C.msg="",I.wrap&&(C.adler=1&I.wrap),I.mode=d,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(m),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,p):f}function v(C){var I;return C&&C.state?((I=C.state).wsize=0,I.whave=0,I.wnext=0,x(C)):f}function b(C,I){var M,z;return C&&C.state?(z=C.state,I<0?(M=0,I=-I):(M=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?f:(z.window!==null&&z.wbits!==I&&(z.window=null),z.wrap=M,z.wbits=I,v(C))):f}function T(C,I){var M,z;return C?(z=new w,(C.state=z).window=null,(M=b(C,I))!==p&&(C.state=null),M):f}var P,k,D=!0;function E(C){if(D){var I;for(P=new s.Buf32(512),k=new s.Buf32(32),I=0;I<144;)C.lens[I++]=8;for(;I<256;)C.lens[I++]=9;for(;I<280;)C.lens[I++]=7;for(;I<288;)C.lens[I++]=8;for(h(c,C.lens,0,288,P,0,C.work,{bits:9}),I=0;I<32;)C.lens[I++]=5;h(u,C.lens,0,32,k,0,C.work,{bits:5}),D=!1}C.lencode=P,C.lenbits=9,C.distcode=k,C.distbits=5}function O(C,I,M,z){var Z,G=C.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new s.Buf8(G.wsize)),z>=G.wsize?(s.arraySet(G.window,I,M-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(z<(Z=G.wsize-G.wnext)&&(Z=z),s.arraySet(G.window,I,M-z,Z,G.wnext),(z-=Z)?(s.arraySet(G.window,I,M-z,z,0),G.wnext=z,G.whave=G.wsize):(G.wnext+=Z,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=Z))),0}i.inflateReset=v,i.inflateReset2=b,i.inflateResetKeep=x,i.inflateInit=function(C){return T(C,15)},i.inflateInit2=T,i.inflate=function(C,I){var M,z,Z,G,ee,W,H,R,F,te,Q,Y,de,fe,se,oe,he,pe,Ae,Be,S,X,j,B,L=0,N=new s.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!C||!C.state||!C.output||!C.input&&C.avail_in!==0)return f;(M=C.state).mode===12&&(M.mode=13),ee=C.next_out,Z=C.output,H=C.avail_out,G=C.next_in,z=C.input,W=C.avail_in,R=M.hold,F=M.bits,te=W,Q=H,X=p;e:for(;;)switch(M.mode){case d:if(M.wrap===0){M.mode=13;break}for(;F<16;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(2&M.wrap&&R===35615){N[M.check=0]=255&R,N[1]=R>>>8&255,M.check=a(M.check,N,2,0),F=R=0,M.mode=2;break}if(M.flags=0,M.head&&(M.head.done=!1),!(1&M.wrap)||(((255&R)<<8)+(R>>8))%31){C.msg="incorrect header check",M.mode=30;break}if((15&R)!=8){C.msg="unknown compression method",M.mode=30;break}if(F-=4,S=8+(15&(R>>>=4)),M.wbits===0)M.wbits=S;else if(S>M.wbits){C.msg="invalid window size",M.mode=30;break}M.dmax=1<<S,C.adler=M.check=1,M.mode=512&R?10:12,F=R=0;break;case 2:for(;F<16;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(M.flags=R,(255&M.flags)!=8){C.msg="unknown compression method",M.mode=30;break}if(57344&M.flags){C.msg="unknown header flags set",M.mode=30;break}M.head&&(M.head.text=R>>8&1),512&M.flags&&(N[0]=255&R,N[1]=R>>>8&255,M.check=a(M.check,N,2,0)),F=R=0,M.mode=3;case 3:for(;F<32;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}M.head&&(M.head.time=R),512&M.flags&&(N[0]=255&R,N[1]=R>>>8&255,N[2]=R>>>16&255,N[3]=R>>>24&255,M.check=a(M.check,N,4,0)),F=R=0,M.mode=4;case 4:for(;F<16;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}M.head&&(M.head.xflags=255&R,M.head.os=R>>8),512&M.flags&&(N[0]=255&R,N[1]=R>>>8&255,M.check=a(M.check,N,2,0)),F=R=0,M.mode=5;case 5:if(1024&M.flags){for(;F<16;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}M.length=R,M.head&&(M.head.extra_len=R),512&M.flags&&(N[0]=255&R,N[1]=R>>>8&255,M.check=a(M.check,N,2,0)),F=R=0}else M.head&&(M.head.extra=null);M.mode=6;case 6:if(1024&M.flags&&(W<(Y=M.length)&&(Y=W),Y&&(M.head&&(S=M.head.extra_len-M.length,M.head.extra||(M.head.extra=new Array(M.head.extra_len)),s.arraySet(M.head.extra,z,G,Y,S)),512&M.flags&&(M.check=a(M.check,z,Y,G)),W-=Y,G+=Y,M.length-=Y),M.length))break e;M.length=0,M.mode=7;case 7:if(2048&M.flags){if(W===0)break e;for(Y=0;S=z[G+Y++],M.head&&S&&M.length<65536&&(M.head.name+=String.fromCharCode(S)),S&&Y<W;);if(512&M.flags&&(M.check=a(M.check,z,Y,G)),W-=Y,G+=Y,S)break e}else M.head&&(M.head.name=null);M.length=0,M.mode=8;case 8:if(4096&M.flags){if(W===0)break e;for(Y=0;S=z[G+Y++],M.head&&S&&M.length<65536&&(M.head.comment+=String.fromCharCode(S)),S&&Y<W;);if(512&M.flags&&(M.check=a(M.check,z,Y,G)),W-=Y,G+=Y,S)break e}else M.head&&(M.head.comment=null);M.mode=9;case 9:if(512&M.flags){for(;F<16;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(R!==(65535&M.check)){C.msg="header crc mismatch",M.mode=30;break}F=R=0}M.head&&(M.head.hcrc=M.flags>>9&1,M.head.done=!0),C.adler=M.check=0,M.mode=12;break;case 10:for(;F<32;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}C.adler=M.check=y(R),F=R=0,M.mode=11;case 11:if(M.havedict===0)return C.next_out=ee,C.avail_out=H,C.next_in=G,C.avail_in=W,M.hold=R,M.bits=F,2;C.adler=M.check=1,M.mode=12;case 12:if(I===5||I===6)break e;case 13:if(M.last){R>>>=7&F,F-=7&F,M.mode=27;break}for(;F<3;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}switch(M.last=1&R,F-=1,3&(R>>>=1)){case 0:M.mode=14;break;case 1:if(E(M),M.mode=20,I!==6)break;R>>>=2,F-=2;break e;case 2:M.mode=17;break;case 3:C.msg="invalid block type",M.mode=30}R>>>=2,F-=2;break;case 14:for(R>>>=7&F,F-=7&F;F<32;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if((65535&R)!=(R>>>16^65535)){C.msg="invalid stored block lengths",M.mode=30;break}if(M.length=65535&R,F=R=0,M.mode=15,I===6)break e;case 15:M.mode=16;case 16:if(Y=M.length){if(W<Y&&(Y=W),H<Y&&(Y=H),Y===0)break e;s.arraySet(Z,z,G,Y,ee),W-=Y,G+=Y,H-=Y,ee+=Y,M.length-=Y;break}M.mode=12;break;case 17:for(;F<14;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(M.nlen=257+(31&R),R>>>=5,F-=5,M.ndist=1+(31&R),R>>>=5,F-=5,M.ncode=4+(15&R),R>>>=4,F-=4,286<M.nlen||30<M.ndist){C.msg="too many length or distance symbols",M.mode=30;break}M.have=0,M.mode=18;case 18:for(;M.have<M.ncode;){for(;F<3;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}M.lens[q[M.have++]]=7&R,R>>>=3,F-=3}for(;M.have<19;)M.lens[q[M.have++]]=0;if(M.lencode=M.lendyn,M.lenbits=7,j={bits:M.lenbits},X=h(0,M.lens,0,19,M.lencode,0,M.work,j),M.lenbits=j.bits,X){C.msg="invalid code lengths set",M.mode=30;break}M.have=0,M.mode=19;case 19:for(;M.have<M.nlen+M.ndist;){for(;oe=(L=M.lencode[R&(1<<M.lenbits)-1])>>>16&255,he=65535&L,!((se=L>>>24)<=F);){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(he<16)R>>>=se,F-=se,M.lens[M.have++]=he;else{if(he===16){for(B=se+2;F<B;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(R>>>=se,F-=se,M.have===0){C.msg="invalid bit length repeat",M.mode=30;break}S=M.lens[M.have-1],Y=3+(3&R),R>>>=2,F-=2}else if(he===17){for(B=se+3;F<B;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}F-=se,S=0,Y=3+(7&(R>>>=se)),R>>>=3,F-=3}else{for(B=se+7;F<B;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}F-=se,S=0,Y=11+(127&(R>>>=se)),R>>>=7,F-=7}if(M.have+Y>M.nlen+M.ndist){C.msg="invalid bit length repeat",M.mode=30;break}for(;Y--;)M.lens[M.have++]=S}}if(M.mode===30)break;if(M.lens[256]===0){C.msg="invalid code -- missing end-of-block",M.mode=30;break}if(M.lenbits=9,j={bits:M.lenbits},X=h(c,M.lens,0,M.nlen,M.lencode,0,M.work,j),M.lenbits=j.bits,X){C.msg="invalid literal/lengths set",M.mode=30;break}if(M.distbits=6,M.distcode=M.distdyn,j={bits:M.distbits},X=h(u,M.lens,M.nlen,M.ndist,M.distcode,0,M.work,j),M.distbits=j.bits,X){C.msg="invalid distances set",M.mode=30;break}if(M.mode=20,I===6)break e;case 20:M.mode=21;case 21:if(6<=W&&258<=H){C.next_out=ee,C.avail_out=H,C.next_in=G,C.avail_in=W,M.hold=R,M.bits=F,l(C,Q),ee=C.next_out,Z=C.output,H=C.avail_out,G=C.next_in,z=C.input,W=C.avail_in,R=M.hold,F=M.bits,M.mode===12&&(M.back=-1);break}for(M.back=0;oe=(L=M.lencode[R&(1<<M.lenbits)-1])>>>16&255,he=65535&L,!((se=L>>>24)<=F);){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(oe&&(240&oe)==0){for(pe=se,Ae=oe,Be=he;oe=(L=M.lencode[Be+((R&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&L,!(pe+(se=L>>>24)<=F);){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}R>>>=pe,F-=pe,M.back+=pe}if(R>>>=se,F-=se,M.back+=se,M.length=he,oe===0){M.mode=26;break}if(32&oe){M.back=-1,M.mode=12;break}if(64&oe){C.msg="invalid literal/length code",M.mode=30;break}M.extra=15&oe,M.mode=22;case 22:if(M.extra){for(B=M.extra;F<B;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}M.length+=R&(1<<M.extra)-1,R>>>=M.extra,F-=M.extra,M.back+=M.extra}M.was=M.length,M.mode=23;case 23:for(;oe=(L=M.distcode[R&(1<<M.distbits)-1])>>>16&255,he=65535&L,!((se=L>>>24)<=F);){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if((240&oe)==0){for(pe=se,Ae=oe,Be=he;oe=(L=M.distcode[Be+((R&(1<<pe+Ae)-1)>>pe)])>>>16&255,he=65535&L,!(pe+(se=L>>>24)<=F);){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}R>>>=pe,F-=pe,M.back+=pe}if(R>>>=se,F-=se,M.back+=se,64&oe){C.msg="invalid distance code",M.mode=30;break}M.offset=he,M.extra=15&oe,M.mode=24;case 24:if(M.extra){for(B=M.extra;F<B;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}M.offset+=R&(1<<M.extra)-1,R>>>=M.extra,F-=M.extra,M.back+=M.extra}if(M.offset>M.dmax){C.msg="invalid distance too far back",M.mode=30;break}M.mode=25;case 25:if(H===0)break e;if(Y=Q-H,M.offset>Y){if((Y=M.offset-Y)>M.whave&&M.sane){C.msg="invalid distance too far back",M.mode=30;break}de=Y>M.wnext?(Y-=M.wnext,M.wsize-Y):M.wnext-Y,Y>M.length&&(Y=M.length),fe=M.window}else fe=Z,de=ee-M.offset,Y=M.length;for(H<Y&&(Y=H),H-=Y,M.length-=Y;Z[ee++]=fe[de++],--Y;);M.length===0&&(M.mode=21);break;case 26:if(H===0)break e;Z[ee++]=M.length,H--,M.mode=21;break;case 27:if(M.wrap){for(;F<32;){if(W===0)break e;W--,R|=z[G++]<<F,F+=8}if(Q-=H,C.total_out+=Q,M.total+=Q,Q&&(C.adler=M.check=M.flags?a(M.check,Z,Q,ee-Q):r(M.check,Z,Q,ee-Q)),Q=H,(M.flags?R:y(R))!==M.check){C.msg="incorrect data check",M.mode=30;break}F=R=0}M.mode=28;case 28:if(M.wrap&&M.flags){for(;F<32;){if(W===0)break e;W--,R+=z[G++]<<F,F+=8}if(R!==(4294967295&M.total)){C.msg="incorrect length check",M.mode=30;break}F=R=0}M.mode=29;case 29:X=1;break e;case 30:X=-3;break e;case 31:return-4;case 32:default:return f}return C.next_out=ee,C.avail_out=H,C.next_in=G,C.avail_in=W,M.hold=R,M.bits=F,(M.wsize||Q!==C.avail_out&&M.mode<30&&(M.mode<27||I!==4))&&O(C,C.output,C.next_out,Q-C.avail_out)?(M.mode=31,-4):(te-=C.avail_in,Q-=C.avail_out,C.total_in+=te,C.total_out+=Q,M.total+=Q,M.wrap&&Q&&(C.adler=M.check=M.flags?a(M.check,Z,Q,C.next_out-Q):r(M.check,Z,Q,C.next_out-Q)),C.data_type=M.bits+(M.last?64:0)+(M.mode===12?128:0)+(M.mode===20||M.mode===15?256:0),(te==0&&Q===0||I===4)&&X===p&&(X=-5),X)},i.inflateEnd=function(C){if(!C||!C.state)return f;var I=C.state;return I.window&&(I.window=null),C.state=null,p},i.inflateGetHeader=function(C,I){var M;return C&&C.state?(2&(M=C.state).wrap)==0?f:((M.head=I).done=!1,p):f},i.inflateSetDictionary=function(C,I){var M,z=I.length;return C&&C.state?(M=C.state).wrap!==0&&M.mode!==11?f:M.mode===11&&r(1,I,z,0)!==M.check?-3:O(C,I,z,z)?(M.mode=31,-4):(M.havedict=1,p):f},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var s=t("../utils/common"),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,u,p,f,d,m,g,y){var w,x,v,b,T,P,k,D,E,O=y.bits,C=0,I=0,M=0,z=0,Z=0,G=0,ee=0,W=0,H=0,R=0,F=null,te=0,Q=new s.Buf16(16),Y=new s.Buf16(16),de=null,fe=0;for(C=0;C<=15;C++)Q[C]=0;for(I=0;I<f;I++)Q[u[p+I]]++;for(Z=O,z=15;1<=z&&Q[z]===0;z--);if(z<Z&&(Z=z),z===0)return d[m++]=20971520,d[m++]=20971520,y.bits=1,0;for(M=1;M<z&&Q[M]===0;M++);for(Z<M&&(Z=M),C=W=1;C<=15;C++)if(W<<=1,(W-=Q[C])<0)return-1;if(0<W&&(c===0||z!==1))return-1;for(Y[1]=0,C=1;C<15;C++)Y[C+1]=Y[C]+Q[C];for(I=0;I<f;I++)u[p+I]!==0&&(g[Y[u[p+I]]++]=I);if(P=c===0?(F=de=g,19):c===1?(F=r,te-=257,de=a,fe-=257,256):(F=l,de=h,-1),C=M,T=m,ee=I=R=0,v=-1,b=(H=1<<(G=Z))-1,c===1&&852<H||c===2&&592<H)return 1;for(;;){for(k=C-ee,E=g[I]<P?(D=0,g[I]):g[I]>P?(D=de[fe+g[I]],F[te+g[I]]):(D=96,0),w=1<<C-ee,M=x=1<<G;d[T+(R>>ee)+(x-=w)]=k<<24|D<<16|E|0,x!==0;);for(w=1<<C-1;R&w;)w>>=1;if(w!==0?(R&=w-1,R+=w):R=0,I++,--Q[C]==0){if(C===z)break;C=u[p+g[I]]}if(Z<C&&(R&b)!==v){for(ee===0&&(ee=Z),T+=M,W=1<<(G=C-ee);G+ee<z&&!((W-=Q[G+ee])<=0);)G++,W<<=1;if(H+=1<<G,c===1&&852<H||c===2&&592<H)return 1;d[v=R&b]=Z<<24|G<<16|T-m|0}}return R!==0&&(d[T+R]=C-ee<<24|64<<16|0),y.bits=Z,0}},{"../utils/common":41}],51:[function(t,n,i){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,n,i){var s=t("../utils/common"),r=0,a=1;function l(L){for(var N=L.length;0<=--N;)L[N]=0}var h=0,c=29,u=256,p=u+1+c,f=30,d=19,m=2*p+1,g=15,y=16,w=7,x=256,v=16,b=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*(p+2));l(O);var C=new Array(2*f);l(C);var I=new Array(512);l(I);var M=new Array(256);l(M);var z=new Array(c);l(z);var Z,G,ee,W=new Array(f);function H(L,N,q,K,U){this.static_tree=L,this.extra_bits=N,this.extra_base=q,this.elems=K,this.max_length=U,this.has_stree=L&&L.length}function R(L,N){this.dyn_tree=L,this.max_code=0,this.stat_desc=N}function F(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 Q(L,N,q){L.bi_valid>y-q?(L.bi_buf|=N<<L.bi_valid&65535,te(L,L.bi_buf),L.bi_buf=N>>y-L.bi_valid,L.bi_valid+=q-y):(L.bi_buf|=N<<L.bi_valid&65535,L.bi_valid+=q)}function Y(L,N,q){Q(L,q[2*N],q[2*N+1])}function de(L,N){for(var q=0;q|=1&L,L>>>=1,q<<=1,0<--N;);return q>>>1}function fe(L,N,q){var K,U,$=new Array(g+1),ne=0;for(K=1;K<=g;K++)$[K]=ne=ne+q[K-1]<<1;for(U=0;U<=N;U++){var J=L[2*U+1];J!==0&&(L[2*U]=de($[J]++,J))}}function se(L){var N;for(N=0;N<p;N++)L.dyn_ltree[2*N]=0;for(N=0;N<f;N++)L.dyn_dtree[2*N]=0;for(N=0;N<d;N++)L.bl_tree[2*N]=0;L.dyn_ltree[2*x]=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 he(L,N,q,K){var U=2*N,$=2*q;return L[U]<L[$]||L[U]===L[$]&&K[N]<=K[q]}function pe(L,N,q){for(var K=L.heap[q],U=q<<1;U<=L.heap_len&&(U<L.heap_len&&he(N,L.heap[U+1],L.heap[U],L.depth)&&U++,!he(N,K,L.heap[U],L.depth));)L.heap[q]=L.heap[U],q=U,U<<=1;L.heap[q]=K}function Ae(L,N,q){var K,U,$,ne,J=0;if(L.last_lit!==0)for(;K=L.pending_buf[L.d_buf+2*J]<<8|L.pending_buf[L.d_buf+2*J+1],U=L.pending_buf[L.l_buf+J],J++,K===0?Y(L,U,N):(Y(L,($=M[U])+u+1,N),(ne=P[$])!==0&&Q(L,U-=z[$],ne),Y(L,$=F(--K),q),(ne=k[$])!==0&&Q(L,K-=W[$],ne)),J<L.last_lit;);Y(L,x,N)}function Be(L,N){var q,K,U,$=N.dyn_tree,ne=N.stat_desc.static_tree,J=N.stat_desc.has_stree,ie=N.stat_desc.elems,ce=-1;for(L.heap_len=0,L.heap_max=m,q=0;q<ie;q++)$[2*q]!==0?(L.heap[++L.heap_len]=ce=q,L.depth[q]=0):$[2*q+1]=0;for(;L.heap_len<2;)$[2*(U=L.heap[++L.heap_len]=ce<2?++ce:0)]=1,L.depth[U]=0,L.opt_len--,J&&(L.static_len-=ne[2*U+1]);for(N.max_code=ce,q=L.heap_len>>1;1<=q;q--)pe(L,$,q);for(U=ie;q=L.heap[1],L.heap[1]=L.heap[L.heap_len--],pe(L,$,1),K=L.heap[1],L.heap[--L.heap_max]=q,L.heap[--L.heap_max]=K,$[2*U]=$[2*q]+$[2*K],L.depth[U]=(L.depth[q]>=L.depth[K]?L.depth[q]:L.depth[K])+1,$[2*q+1]=$[2*K+1]=U,L.heap[1]=U++,pe(L,$,1),2<=L.heap_len;);L.heap[--L.heap_max]=L.heap[1],(function(ae,Ce){var $e,ke,Rt,ge,tn,bn,Je=Ce.dyn_tree,vt=Ce.max_code,Ft=Ce.stat_desc.static_tree,Ut=Ce.stat_desc.has_stree,Vt=Ce.stat_desc.extra_bits,bt=Ce.stat_desc.extra_base,_n=Ce.stat_desc.max_length,Mi=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(Je[2*ae.heap[ae.heap_max]+1]=0,$e=ae.heap_max+1;$e<m;$e++)_n<(ge=Je[2*Je[2*(ke=ae.heap[$e])+1]+1]+1)&&(ge=_n,Mi++),Je[2*ke+1]=ge,vt<ke||(ae.bl_count[ge]++,tn=0,bt<=ke&&(tn=Vt[ke-bt]),bn=Je[2*ke],ae.opt_len+=bn*(ge+tn),Ut&&(ae.static_len+=bn*(Ft[2*ke+1]+tn)));if(Mi!==0){do{for(ge=_n-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[_n]--,Mi-=2}while(0<Mi);for(ge=_n;ge!==0;ge--)for(ke=ae.bl_count[ge];ke!==0;)vt<(Rt=ae.heap[--$e])||(Je[2*Rt+1]!==ge&&(ae.opt_len+=(ge-Je[2*Rt+1])*Je[2*Rt],Je[2*Rt+1]=ge),ke--)}})(L,N),fe($,ce,L.bl_count)}function S(L,N,q){var K,U,$=-1,ne=N[1],J=0,ie=7,ce=4;for(ne===0&&(ie=138,ce=3),N[2*(q+1)+1]=65535,K=0;K<=q;K++)U=ne,ne=N[2*(K+1)+1],++J<ie&&U===ne||(J<ce?L.bl_tree[2*U]+=J:U!==0?(U!==$&&L.bl_tree[2*U]++,L.bl_tree[2*v]++):J<=10?L.bl_tree[2*b]++:L.bl_tree[2*T]++,$=U,ce=(J=0)===ne?(ie=138,3):U===ne?(ie=6,3):(ie=7,4))}function X(L,N,q){var K,U,$=-1,ne=N[1],J=0,ie=7,ce=4;for(ne===0&&(ie=138,ce=3),K=0;K<=q;K++)if(U=ne,ne=N[2*(K+1)+1],!(++J<ie&&U===ne)){if(J<ce)for(;Y(L,U,L.bl_tree),--J!=0;);else U!==0?(U!==$&&(Y(L,U,L.bl_tree),J--),Y(L,v,L.bl_tree),Q(L,J-3,2)):J<=10?(Y(L,b,L.bl_tree),Q(L,J-3,3)):(Y(L,T,L.bl_tree),Q(L,J-11,7));$=U,ce=(J=0)===ne?(ie=138,3):U===ne?(ie=6,3):(ie=7,4)}}l(W);var j=!1;function B(L,N,q,K){Q(L,(h<<1)+(K?1:0),3),(function(U,$,ne,J){oe(U),te(U,ne),te(U,~ne),s.arraySet(U.pending_buf,U.window,$,ne,U.pending),U.pending+=ne})(L,N,q)}i._tr_init=function(L){j||((function(){var N,q,K,U,$,ne=new Array(g+1);for(U=K=0;U<c-1;U++)for(z[U]=K,N=0;N<1<<P[U];N++)M[K++]=U;for(M[K-1]=U,U=$=0;U<16;U++)for(W[U]=$,N=0;N<1<<k[U];N++)I[$++]=U;for($>>=7;U<f;U++)for(W[U]=$<<7,N=0;N<1<<k[U]-7;N++)I[256+$++]=U;for(q=0;q<=g;q++)ne[q]=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,p+1,ne),N=0;N<f;N++)C[2*N+1]=5,C[2*N]=de(N,5);Z=new H(O,P,u+1,p,g),G=new H(C,k,0,f,g),ee=new H(new Array(0),D,0,d,w)})(),j=!0),L.l_desc=new R(L.dyn_ltree,Z),L.d_desc=new R(L.dyn_dtree,G),L.bl_desc=new R(L.bl_tree,ee),L.bi_buf=0,L.bi_valid=0,se(L)},i._tr_stored_block=B,i._tr_flush_block=function(L,N,q,K){var U,$,ne=0;0<L.level?(L.strm.data_type===2&&(L.strm.data_type=(function(J){var ie,ce=4093624447;for(ie=0;ie<=31;ie++,ce>>>=1)if(1&ce&&J.dyn_ltree[2*ie]!==0)return r;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return a;for(ie=32;ie<u;ie++)if(J.dyn_ltree[2*ie]!==0)return a;return r})(L)),Be(L,L.l_desc),Be(L,L.d_desc),ne=(function(J){var ie;for(S(J,J.dyn_ltree,J.l_desc.max_code),S(J,J.dyn_dtree,J.d_desc.max_code),Be(J,J.bl_desc),ie=d-1;3<=ie&&J.bl_tree[2*E[ie]+1]===0;ie--);return J.opt_len+=3*(ie+1)+5+5+4,ie})(L),U=L.opt_len+3+7>>>3,($=L.static_len+3+7>>>3)<=U&&(U=$)):U=$=q+5,q+4<=U&&N!==-1?B(L,N,q,K):L.strategy===4||$===U?(Q(L,2+(K?1:0),3),Ae(L,O,C)):(Q(L,4+(K?1:0),3),(function(J,ie,ce,ae){var Ce;for(Q(J,ie-257,5),Q(J,ce-1,5),Q(J,ae-4,4),Ce=0;Ce<ae;Ce++)Q(J,J.bl_tree[2*E[Ce]+1],3);X(J,J.dyn_ltree,ie-1),X(J,J.dyn_dtree,ce-1)})(L,L.l_desc.max_code+1,L.d_desc.max_code+1,ne+1),Ae(L,L.dyn_ltree,L.dyn_dtree)),se(L),K&&oe(L)},i._tr_tally=function(L,N,q){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&q,L.last_lit++,N===0?L.dyn_ltree[2*q]++:(L.matches++,N--,L.dyn_ltree[2*(M[q]+u+1)]++,L.dyn_dtree[2*F(N)]++),L.last_lit===L.lit_bufsize-1},i._tr_align=function(L){Q(L,2,3),Y(L,x,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,u,p=1,f={},d=!1,m=r.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(r);g=g&&g.setTimeout?g:r,l={}.toString.call(r.process)==="[object process]"?function(v){process.nextTick(function(){w(v)})}:(function(){if(r.postMessage&&!r.importScripts){var v=!0,b=r.onmessage;return r.onmessage=function(){v=!1},r.postMessage("","*"),r.onmessage=b,v}})()?(u="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",x,!1):r.attachEvent("onmessage",x),function(v){r.postMessage(u+v,"*")}):r.MessageChannel?((c=new MessageChannel).port1.onmessage=function(v){w(v.data)},function(v){c.port2.postMessage(v)}):m&&"onreadystatechange"in m.createElement("script")?(h=m.documentElement,function(v){var b=m.createElement("script");b.onreadystatechange=function(){w(v),b.onreadystatechange=null,h.removeChild(b),b=null},h.appendChild(b)}):function(v){setTimeout(w,0,v)},g.setImmediate=function(v){typeof v!="function"&&(v=new Function(""+v));for(var b=new Array(arguments.length-1),T=0;T<b.length;T++)b[T]=arguments[T+1];var P={callback:v,args:b};return f[p]=P,l(p),p++},g.clearImmediate=y}function y(v){delete f[v]}function w(v){if(d)setTimeout(w,0,v);else{var b=f[v];if(b){d=!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)}})(b)}finally{y(v),d=!1}}}}function x(v){v.source===r&&typeof v.data=="string"&&v.data.indexOf(u)===0&&w(+v.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof En<"u"?En:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Pi)),Pi.exports}var va=xa();const js=Us(va);function Gs(o,e){return function(){return o.apply(e,arguments)}}const{toString:ba}=Object.prototype,{getPrototypeOf:Di}=Object,{iterator:On,toStringTag:Ws}=Symbol,zn=(o=>e=>{const t=ba.call(e);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),qe=o=>(o=o.toLowerCase(),e=>zn(e)===o),Nn=o=>e=>typeof e===o,{isArray:jt}=Array,Gt=Nn("undefined");function nn(o){return o!==null&&!Gt(o)&&o.constructor!==null&&!Gt(o.constructor)&&Ne(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const Xs=qe("ArrayBuffer");function _a(o){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&Xs(o.buffer),e}const Ma=Nn("string"),Ne=Nn("function"),Zs=Nn("number"),sn=o=>o!==null&&typeof o=="object",Sa=o=>o===!0||o===!1,Rn=o=>{if(zn(o)!=="object")return!1;const e=Di(o);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Ws in o)&&!(On in o)},Aa=o=>{if(!sn(o)||nn(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},Ca=qe("Date"),Ta=qe("File"),Pa=qe("Blob"),Da=qe("FileList"),ka=o=>sn(o)&&Ne(o.pipe),Ia=o=>{let e;return o&&(typeof FormData=="function"&&o instanceof FormData||Ne(o.append)&&((e=zn(o))==="formdata"||e==="object"&&Ne(o.toString)&&o.toString()==="[object FormData]"))},La=qe("URLSearchParams"),[Ea,Ba,Oa,za]=["ReadableStream","Request","Response","Headers"].map(qe),Na=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function rn(o,e,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let n,i;if(typeof o!="object"&&(o=[o]),jt(o))for(n=0,i=o.length;n<i;n++)e.call(null,o[n],n,o);else{if(nn(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 qs(o,e){if(nn(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,Ks=o=>!Gt(o)&&o!==At;function ki(){const{caseless:o,skipUndefined:e}=Ks(this)&&this||{},t={},n=(i,s)=>{const r=o&&qs(t,s)||s;Rn(t[r])&&Rn(i)?t[r]=ki(t[r],i):Rn(i)?t[r]=ki({},i):jt(i)?t[r]=i.slice():(!e||!Gt(i))&&(t[r]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&rn(arguments[i],n);return t}const Ra=(o,e,t,{allOwnKeys:n}={})=>(rn(e,(i,s)=>{t&&Ne(i)?o[s]=Gs(i,t):o[s]=i},{allOwnKeys:n}),o),Fa=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),Ua=(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)},Va=(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&&Di(o)}while(o&&(!t||t(o,e))&&o!==Object.prototype);return e},ja=(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},Ga=o=>{if(!o)return null;if(jt(o))return o;let e=o.length;if(!Zs(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=o[e];return t},Wa=(o=>e=>o&&e instanceof o)(typeof Uint8Array<"u"&&Di(Uint8Array)),Xa=(o,e)=>{const n=(o&&o[On]).call(o);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(o,s[0],s[1])}},Za=(o,e)=>{let t;const n=[];for(;(t=o.exec(e))!==null;)n.push(t);return n},qa=qe("HTMLFormElement"),Ka=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Ys=(({hasOwnProperty:o})=>(e,t)=>o.call(e,t))(Object.prototype),Ya=qe("RegExp"),$s=(o,e)=>{const t=Object.getOwnPropertyDescriptors(o),n={};rn(t,(i,s)=>{let r;(r=e(i,s,o))!==!1&&(n[s]=r||i)}),Object.defineProperties(o,n)},$a=o=>{$s(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+"'")})}})},Ja=(o,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return jt(o)?n(o):n(String(o).split(e)),t},Qa=()=>{},Ha=(o,e)=>o!=null&&Number.isFinite(o=+o)?o:e;function el(o){return!!(o&&Ne(o.append)&&o[Ws]==="FormData"&&o[On])}const tl=o=>{const e=new Array(10),t=(n,i)=>{if(sn(n)){if(e.indexOf(n)>=0)return;if(nn(n))return n;if(!("toJSON"in n)){e[i]=n;const s=jt(n)?[]:{};return rn(n,(r,a)=>{const l=t(r,i+1);!Gt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(o,0)},nl=qe("AsyncFunction"),il=o=>o&&(sn(o)||Ne(o))&&Ne(o.then)&&Ne(o.catch),Js=((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)),sl=typeof queueMicrotask<"u"?queueMicrotask.bind(At):typeof process<"u"&&process.nextTick||Js,V={isArray:jt,isArrayBuffer:Xs,isBuffer:nn,isFormData:Ia,isArrayBufferView:_a,isString:Ma,isNumber:Zs,isBoolean:Sa,isObject:sn,isPlainObject:Rn,isEmptyObject:Aa,isReadableStream:Ea,isRequest:Ba,isResponse:Oa,isHeaders:za,isUndefined:Gt,isDate:Ca,isFile:Ta,isBlob:Pa,isRegExp:Ya,isFunction:Ne,isStream:ka,isURLSearchParams:La,isTypedArray:Wa,isFileList:Da,forEach:rn,merge:ki,extend:Ra,trim:Na,stripBOM:Fa,inherits:Ua,toFlatObject:Va,kindOf:zn,kindOfTest:qe,endsWith:ja,toArray:Ga,forEachEntry:Xa,matchAll:Za,isHTMLForm:qa,hasOwnProperty:Ys,hasOwnProp:Ys,reduceDescriptors:$s,freezeMethods:$a,toObjectSet:Ja,toCamelCase:Ka,noop:Qa,toFiniteNumber:Ha,findKey:qs,global:At,isContextDefined:Ks,isSpecCompliantForm:el,toJSONObject:tl,isAsyncFn:nl,isThenable:il,setImmediate:Js,asap:sl,isIterable:o=>o!=null&&Ne(o[On])};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)}V.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:V.toJSONObject(this.config),code:this.code,status:this.status}}});const Qs=re.prototype,Hs={};["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=>{Hs[o]={value:o}}),Object.defineProperties(re,Hs),Object.defineProperty(Qs,"isAxiosError",{value:!0}),re.from=(o,e,t,n,i,s)=>{const r=Object.create(Qs);V.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 rl=null;function Ii(o){return V.isPlainObject(o)||V.isArray(o)}function er(o){return V.endsWith(o,"[]")?o.slice(0,-2):o}function tr(o,e,t){return o?o.concat(e).map(function(i,s){return i=er(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function ol(o){return V.isArray(o)&&!o.some(Ii)}const al=V.toFlatObject(V,{},null,function(e){return/^is[A-Z]/.test(e)});function Fn(o,e,t){if(!V.isObject(o))throw new TypeError("target must be an object");e=e||new FormData,t=V.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!V.isUndefined(g[m])});const n=t.metaTokens,i=t.visitor||c,s=t.dots,r=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&V.isSpecCompliantForm(e);if(!V.isFunction(i))throw new TypeError("visitor must be a function");function h(d){if(d===null)return"";if(V.isDate(d))return d.toISOString();if(V.isBoolean(d))return d.toString();if(!l&&V.isBlob(d))throw new re("Blob is not supported. Use a Buffer instead.");return V.isArrayBuffer(d)||V.isTypedArray(d)?l&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function c(d,m,g){let y=d;if(d&&!g&&typeof d=="object"){if(V.endsWith(m,"{}"))m=n?m:m.slice(0,-2),d=JSON.stringify(d);else if(V.isArray(d)&&ol(d)||(V.isFileList(d)||V.endsWith(m,"[]"))&&(y=V.toArray(d)))return m=er(m),y.forEach(function(x,v){!(V.isUndefined(x)||x===null)&&e.append(r===!0?tr([m],v,s):r===null?m:m+"[]",h(x))}),!1}return Ii(d)?!0:(e.append(tr(g,m,s),h(d)),!1)}const u=[],p=Object.assign(al,{defaultVisitor:c,convertValue:h,isVisitable:Ii});function f(d,m){if(!V.isUndefined(d)){if(u.indexOf(d)!==-1)throw Error("Circular reference detected in "+m.join("."));u.push(d),V.forEach(d,function(y,w){(!(V.isUndefined(y)||y===null)&&i.call(e,y,V.isString(w)?w.trim():w,m,p))===!0&&f(y,m?m.concat(w):[w])}),u.pop()}}if(!V.isObject(o))throw new TypeError("data must be an object");return f(o),e}function nr(o){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Li(o,e){this._pairs=[],o&&Fn(o,this,e)}const ir=Li.prototype;ir.append=function(e,t){this._pairs.push([e,t])},ir.toString=function(e){const t=e?function(n){return e.call(this,n,nr)}:nr;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function ll(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function sr(o,e,t){if(!e)return o;const n=t&&t.encode||ll;V.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=V.isURLSearchParams(e)?e.toString():new Li(e,t).toString(n),s){const r=o.indexOf("#");r!==-1&&(o=o.slice(0,r)),o+=(o.indexOf("?")===-1?"?":"&")+s}return o}class rr{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){V.forEach(this.handlers,function(n){n!==null&&e(n)})}}const or={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Li,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ei=typeof window<"u"&&typeof document<"u",Bi=typeof navigator=="object"&&navigator||void 0,hl=Ei&&(!Bi||["ReactNative","NativeScript","NS"].indexOf(Bi.product)<0),ul=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",dl=Ei&&window.location.href||"http://localhost",De={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ei,hasStandardBrowserEnv:hl,hasStandardBrowserWebWorkerEnv:ul,navigator:Bi,origin:dl},Symbol.toStringTag,{value:"Module"})),...cl};function fl(o,e){return Fn(o,new De.classes.URLSearchParams,{visitor:function(t,n,i,s){return De.isNode&&V.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function pl(o){return V.matchAll(/\w+|\[(\w*)]/g,o).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ml(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 ar(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&&V.isArray(i)?i.length:r,l?(V.hasOwnProp(i,r)?i[r]=[i[r],n]:i[r]=n,!a):((!i[r]||!V.isObject(i[r]))&&(i[r]=[]),e(t,n,i[r],s)&&V.isArray(i[r])&&(i[r]=ml(i[r])),!a)}if(V.isFormData(o)&&V.isFunction(o.entries)){const t={};return V.forEachEntry(o,(n,i)=>{e(pl(n),i,t,0)}),t}return null}function gl(o,e,t){if(V.isString(o))try{return(e||JSON.parse)(o),V.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(o)}const on={transitional:or,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=V.isObject(e);if(s&&V.isHTMLForm(e)&&(e=new FormData(e)),V.isFormData(e))return i?JSON.stringify(ar(e)):e;if(V.isArrayBuffer(e)||V.isBuffer(e)||V.isStream(e)||V.isFile(e)||V.isBlob(e)||V.isReadableStream(e))return e;if(V.isArrayBufferView(e))return e.buffer;if(V.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return fl(e,this.formSerializer).toString();if((a=V.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fn(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),gl(e)):e}],transformResponse:[function(e){const t=this.transitional||on.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(V.isResponse(e)||V.isReadableStream(e))return e;if(e&&V.isString(e)&&(n&&!this.responseType||i)){const 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:De.classes.FormData,Blob:De.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};V.forEach(["delete","get","head","post","put","patch"],o=>{on.headers[o]={}});const yl=V.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),wl=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]&&yl[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},lr=Symbol("internals");function an(o){return o&&String(o).trim().toLowerCase()}function Un(o){return o===!1||o==null?o:V.isArray(o)?o.map(Un):String(o)}function xl(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 vl=o=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());function Oi(o,e,t,n,i){if(V.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!V.isString(e)){if(V.isString(n))return e.indexOf(n)!==-1;if(V.isRegExp(n))return n.test(e)}}function bl(o){return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function _l(o,e){const t=V.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 Re=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(a,l,h){const c=an(l);if(!c)throw new Error("header name must be a non-empty string");const u=V.findKey(i,c);(!u||i[u]===void 0||h===!0||h===void 0&&i[u]!==!1)&&(i[u||l]=Un(a))}const r=(a,l)=>V.forEach(a,(h,c)=>s(h,c,l));if(V.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(V.isString(e)&&(e=e.trim())&&!vl(e))r(wl(e),t);else if(V.isObject(e)&&V.isIterable(e)){let a={},l,h;for(const c of e){if(!V.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[h=c[0]]=(l=a[h])?V.isArray(l)?[...l,c[1]]:[l,c[1]]:c[1]}r(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=an(e),e){const n=V.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return xl(i);if(V.isFunction(t))return t.call(this,i,n);if(V.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=an(e),e){const n=V.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Oi(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function s(r){if(r=an(r),r){const a=V.findKey(n,r);a&&(!t||Oi(n,n[a],a,t))&&(delete n[a],i=!0)}}return V.isArray(e)?e.forEach(s):s(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const s=t[n];(!e||Oi(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return V.forEach(this,(i,s)=>{const r=V.findKey(n,s);if(r){t[r]=Un(i),delete t[s];return}const a=e?bl(s):String(s).trim();a!==s&&delete t[s],t[a]=Un(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return V.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&V.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
|
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[lr]=this[lr]={accessors:{}}).accessors,i=this.prototype;function s(r){const a=an(r);n[a]||(_l(i,r),n[a]=!0)}return V.isArray(e)?e.forEach(s):s(e),this}};Re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),V.reduceDescriptors(Re.prototype,({value:o},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>o,set(n){this[t]=n}}}),V.freezeMethods(Re);function zi(o,e){const t=this||on,n=e||t,i=Re.from(n.headers);let s=n.data;return V.forEach(o,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function cr(o){return!!(o&&o.__CANCEL__)}function Wt(o,e,t){re.call(this,o??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}V.inherits(Wt,re,{__CANCEL__:!0});function hr(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 Ml(o){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return e&&e[1]||""}function Sl(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 u=s,p=0;for(;u!==i;)p+=t[u++],u=u%o;if(i=(i+1)%o,i===s&&(s=(s+1)%o),h-r<e)return;const f=c&&h-c;return f?Math.round(p*1e3/f):void 0}}function Al(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(),u=c-t;u>=n?r(h,c):(i=h,s||(s=setTimeout(()=>{s=null,r(i)},n-u)))},()=>i&&r(i)]}const Vn=(o,e,t=3)=>{let n=0;const i=Sl(50,250);return Al(s=>{const r=s.loaded,a=s.lengthComputable?s.total:void 0,l=r-n,h=i(l),c=r<=a;n=r;const u={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(u)},t)},ur=(o,e)=>{const t=o!=null;return[n=>e[0]({lengthComputable:t,total:o,loaded:n}),e[1]]},dr=o=>(...e)=>V.asap(()=>o(...e)),Cl=De.hasStandardBrowserEnv?((o,e)=>t=>(t=new URL(t,De.origin),o.protocol===t.protocol&&o.host===t.host&&(e||o.port===t.port)))(new URL(De.origin),De.navigator&&/(msie|trident)/i.test(De.navigator.userAgent)):()=>!0,Tl=De.hasStandardBrowserEnv?{write(o,e,t,n,i,s,r){if(typeof document>"u")return;const a=[`${o}=${encodeURIComponent(e)}`];V.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),V.isString(n)&&a.push(`path=${n}`),V.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),V.isString(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 Pl(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function Dl(o,e){return e?o.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):o}function fr(o,e,t){let n=!Pl(e);return o&&(n||t==!1)?Dl(o,e):e}const pr=o=>o instanceof Re?{...o}:o;function Ct(o,e){e=e||{};const t={};function n(h,c,u,p){return V.isPlainObject(h)&&V.isPlainObject(c)?V.merge.call({caseless:p},h,c):V.isPlainObject(c)?V.merge({},c):V.isArray(c)?c.slice():c}function i(h,c,u,p){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h,u,p)}else return n(h,c,u,p)}function s(h,c){if(!V.isUndefined(c))return n(void 0,c)}function r(h,c){if(V.isUndefined(c)){if(!V.isUndefined(h))return n(void 0,h)}else return n(void 0,c)}function a(h,c,u){if(u in e)return n(h,c);if(u in 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,u)=>i(pr(h),pr(c),u,!0)};return V.forEach(Object.keys({...o,...e}),function(c){const u=l[c]||i,p=u(o[c],e[c],c);V.isUndefined(p)&&u!==a||(t[c]=p)}),t}const mr=o=>{const e=Ct({},o);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Re.from(r),e.url=sr(fr(e.baseURL,e.url,e.allowAbsoluteUrls),o.params,o.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),V.isFormData(t)){if(De.hasStandardBrowserEnv||De.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(V.isFunction(t.getHeaders)){const l=t.getHeaders(),h=["content-type","content-length"];Object.entries(l).forEach(([c,u])=>{h.includes(c.toLowerCase())&&r.set(c,u)})}}if(De.hasStandardBrowserEnv&&(n&&V.isFunction(n)&&(n=n(e)),n||n!==!1&&Cl(e.url))){const l=i&&s&&Tl.read(s);l&&r.set(i,l)}return e},kl=typeof XMLHttpRequest<"u"&&function(o){return new Promise(function(t,n){const i=mr(o);let s=i.data;const r=Re.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:h}=i,c,u,p,f,d;function m(){f&&f(),d&&d(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const x=Re.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),b={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:x,config:o,request:g};hr(function(P){t(P),m()},function(P){n(P),m()},b),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(v){const b=v&&v.message?v.message:"Network Error",T=new re(b,re.ERR_NETWORK,o,g);T.event=v||null,n(T),g=null},g.ontimeout=function(){let v=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const b=i.transitional||or;i.timeoutErrorMessage&&(v=i.timeoutErrorMessage),n(new re(v,b.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,o,g)),g=null},s===void 0&&r.setContentType(null),"setRequestHeader"in g&&V.forEach(r.toJSON(),function(v,b){g.setRequestHeader(b,v)}),V.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),h&&([p,d]=Vn(h,!0),g.addEventListener("progress",p)),l&&g.upload&&([u,f]=Vn(l),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",f)),(i.cancelToken||i.signal)&&(c=x=>{g&&(n(!x||x.type?new Wt(null,o,g):x),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const w=Ml(i.url);if(w&&De.protocols.indexOf(w)===-1){n(new re("Unsupported protocol "+w+":",re.ERR_BAD_REQUEST,o));return}g.send(s||null)})},Il=(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 Wt(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=()=>V.asap(a),l}},Ll=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},El=async function*(o,e){for await(const t of Bl(o))yield*Ll(t,e)},Bl=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()}},gr=(o,e,t,n)=>{const i=El(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 u=c.byteLength;if(t){let p=s+=u;t(p)}l.enqueue(new Uint8Array(c))}catch(h){throw a(h),h}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},yr=64*1024,{isFunction:jn}=V,Ol=(({Request:o,Response:e})=>({Request:o,Response:e}))(V.global),{ReadableStream:wr,TextEncoder:xr}=V.global,vr=(o,...e)=>{try{return!!o(...e)}catch{return!1}},zl=o=>{o=V.merge.call({skipUndefined:!0},Ol,o);const{fetch:e,Request:t,Response:n}=o,i=e?jn(e):typeof fetch=="function",s=jn(t),r=jn(n);if(!i)return!1;const a=i&&jn(wr),l=i&&(typeof xr=="function"?(d=>m=>d.encode(m))(new xr):async d=>new Uint8Array(await new t(d).arrayBuffer())),h=s&&a&&vr(()=>{let d=!1;const m=new t(De.origin,{body:new wr,method:"POST",get duplex(){return d=!0,"half"}}).headers.has("Content-Type");return d&&!m}),c=r&&a&&vr(()=>V.isReadableStream(new n("").body)),u={stream:c&&(d=>d.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(d=>{!u[d]&&(u[d]=(m,g)=>{let y=m&&m[d];if(y)return y.call(m);throw new re(`Response type '${d}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const p=async d=>{if(d==null)return 0;if(V.isBlob(d))return d.size;if(V.isSpecCompliantForm(d))return(await new t(De.origin,{method:"POST",body:d}).arrayBuffer()).byteLength;if(V.isArrayBufferView(d)||V.isArrayBuffer(d))return d.byteLength;if(V.isURLSearchParams(d)&&(d=d+""),V.isString(d))return(await l(d)).byteLength},f=async(d,m)=>{const g=V.toFiniteNumber(d.getContentLength());return g??p(m)};return async d=>{let{url:m,method:g,data:y,signal:w,cancelToken:x,timeout:v,onDownloadProgress:b,onUploadProgress:T,responseType:P,headers:k,withCredentials:D="same-origin",fetchOptions:E}=mr(d),O=e||fetch;P=P?(P+"").toLowerCase():"text";let C=Il([w,x&&x.toAbortSignal()],v),I=null;const M=C&&C.unsubscribe&&(()=>{C.unsubscribe()});let z;try{if(T&&h&&g!=="get"&&g!=="head"&&(z=await f(k,y))!==0){let R=new t(m,{method:"POST",body:y,duplex:"half"}),F;if(V.isFormData(y)&&(F=R.headers.get("content-type"))&&k.setContentType(F),R.body){const[te,Q]=ur(z,Vn(dr(T)));y=gr(R.body,yr,te,Q)}}V.isString(D)||(D=D?"include":"omit");const Z=s&&"credentials"in t.prototype,G={...E,signal:C,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:Z?D:void 0};I=s&&new t(m,G);let ee=await(s?O(I,E):O(m,G));const W=c&&(P==="stream"||P==="response");if(c&&(b||W&&M)){const R={};["status","statusText","headers"].forEach(Y=>{R[Y]=ee[Y]});const F=V.toFiniteNumber(ee.headers.get("content-length")),[te,Q]=b&&ur(F,Vn(dr(b),!0))||[];ee=new n(gr(ee.body,yr,te,()=>{Q&&Q(),M&&M()}),R)}P=P||"text";let H=await u[V.findKey(u,P)||"text"](ee,d);return!W&&M&&M(),await new Promise((R,F)=>{hr(R,F,{data:H,headers:Re.from(ee.headers),status:ee.status,statusText:ee.statusText,config:d,request:I})})}catch(Z){throw M&&M(),Z&&Z.name==="TypeError"&&/Load failed|fetch/i.test(Z.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,d,I),{cause:Z.cause||Z}):re.from(Z,Z&&Z.code,d,I)}}},Nl=new Map,br=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=Nl;for(;a--;)l=s[a],h=c.get(l),h===void 0&&c.set(l,h=a?new Map:zl(e)),c=h;return h};br();const Ni={http:rl,xhr:kl,fetch:{get:br}};V.forEach(Ni,(o,e)=>{if(o){try{Object.defineProperty(o,"name",{value:e})}catch{}Object.defineProperty(o,"adapterName",{value:e})}});const _r=o=>`- ${o}`,Rl=o=>V.isFunction(o)||o===null||o===!1;function Fl(o,e){o=V.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,!Rl(n)&&(i=Ni[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(V.isFunction(i)||(i=i.get(e))))break;s[a||"#"+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 :
|
|
964
|
+
`+r.map(_r).join(`
|
|
965
|
+
`):" "+_r(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 Mr={getAdapter:Fl,adapters:Ni};function Ri(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Wt(null,o)}function Sr(o){return Ri(o),o.headers=Re.from(o.headers),o.data=zi.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Mr.getAdapter(o.adapter||on.adapter,o)(o).then(function(n){return Ri(o),n.data=zi.call(o,o.transformResponse,n),n.headers=Re.from(n.headers),n},function(n){return cr(n)||(Ri(o),n&&n.response&&(n.response.data=zi.call(o,o.transformResponse,n.response),n.response.headers=Re.from(n.response.headers))),Promise.reject(n)})}const Ar="1.13.2",Gn={};["object","boolean","number","function","string","symbol"].forEach((o,e)=>{Gn[o]=function(n){return typeof n===o||"a"+(e<1?"n ":" ")+o}});const Cr={};Gn.transitional=function(e,t,n){function i(s,r){return"[Axios v"+Ar+"] 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&&!Cr[r]&&(Cr[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}},Gn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Ul(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 Wn={assertOptions:Ul,validators:Gn},Qe=Wn.validators;let Tt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new rr,response:new rr}}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=Ct(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Wn.assertOptions(n,{silentJSONParsing:Qe.transitional(Qe.boolean),forcedJSONParsing:Qe.transitional(Qe.boolean),clarifyTimeoutError:Qe.transitional(Qe.boolean)},!1),i!=null&&(V.isFunction(i)?t.paramsSerializer={serialize:i}:Wn.assertOptions(i,{encode:Qe.function,serialize:Qe.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Wn.assertOptions(t,{baseUrl:Qe.spelling("baseURL"),withXsrfToken:Qe.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=s&&V.merge(s.common,s[t.method]);s&&V.forEach(["delete","get","head","post","put","patch","common"],d=>{delete s[d]}),t.headers=Re.concat(r,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let c,u=0,p;if(!l){const d=[Sr.bind(this),void 0];for(d.unshift(...a),d.push(...h),p=d.length,c=Promise.resolve(t);u<p;)c=c.then(d[u++],d[u++]);return c}p=a.length;let f=t;for(;u<p;){const d=a[u++],m=a[u++];try{f=d(f)}catch(g){m.call(this,g);break}}try{c=Sr.call(this,f)}catch(d){return Promise.reject(d)}for(u=0,p=h.length;u<p;)c=c.then(h[u++],h[u++]);return c}getUri(e){e=Ct(this.defaults,e);const t=fr(e.baseURL,e.url,e.allowAbsoluteUrls);return sr(t,e.params,e.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(e){Tt.prototype[e]=function(t,n){return this.request(Ct(n||{},{method:e,url:t,data:(n||{}).data}))}}),V.forEach(["post","put","patch"],function(e){function t(n){return function(s,r,a){return this.request(Ct(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 Vl=class Fo{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 Wt(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 Fo(function(i){e=i}),cancel:e}}};function jl(o){return function(t){return o.apply(null,t)}}function Gl(o){return V.isObject(o)&&o.isAxiosError===!0}const Fi={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(Fi).forEach(([o,e])=>{Fi[e]=o});function Tr(o){const e=new Tt(o),t=Gs(Tt.prototype.request,e);return V.extend(t,Tt.prototype,e,{allOwnKeys:!0}),V.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Tr(Ct(o,i))},t}const ye=Tr(on);ye.Axios=Tt,ye.CanceledError=Wt,ye.CancelToken=Vl,ye.isCancel=cr,ye.VERSION=Ar,ye.toFormData=Fn,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=jl,ye.isAxiosError=Gl,ye.mergeConfig=Ct,ye.AxiosHeaders=Re,ye.formToJSON=o=>ar(V.isHTMLForm(o)?new FormData(o):o),ye.getAdapter=Mr.getAdapter,ye.HttpStatusCode=Fi,ye.default=ye;const{Axios:Ld,AxiosError:Ed,CanceledError:Bd,isCancel:Od,CancelToken:zd,VERSION:Nd,all:Rd,Cancel:Fd,isAxiosError:Ud,spread:Vd,toFormData:jd,AxiosHeaders:Gd,HttpStatusCode:Wd,formToJSON:Xd,getAdapter:Zd,mergeConfig:qd}=ye;function Pr(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 Wl(o,e){ye({method:"get",responseType:"blob",url:o}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});js.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 u=URL.createObjectURL(c);s.set("/"+i.files[a].name.replace("\\","/"),u)});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 Dr(o,e){ye({method:"get",responseType:"blob",url:o}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});js.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 Ui=new WeakMap;class Xl 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(Ui.has(e)){const l=Ui.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)}),Ui.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=Zl.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 Zl(){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(u){c({draco:u})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const u=c.draco,p=new u.Decoder;try{const f=t(u,p,new Int8Array(l),h),d=f.attributes.map(m=>m.array.buffer);f.index&&d.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},d)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{u.destroy(p)}});break}};function t(r,a,l,h){const c=h.attributeIDs,u=h.attributeTypes;let p,f;const d=a.GetEncodedGeometryType(l);if(d===r.TRIANGULAR_MESH)p=new r.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,p);else if(d===r.POINT_CLOUD)p=new r.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const m={index:null,attributes:[]};for(const g in c){const y=self[u[g]];let w,x;if(h.useUniqueIDs)x=c[g],w=a.GetAttributeByUniqueId(p,x);else{if(x=a.GetAttributeId(p,r[c[g]]),x===-1)continue;w=a.GetAttribute(p,x)}const v=i(r,a,p,g,y,w);g==="color"&&(v.vertexColorSpace=h.vertexColorSpace),m.attributes.push(v)}return d===r.TRIANGULAR_MESH&&(m.index=n(r,a,p)),r.destroy(p),m}function n(r,a,l){const c=l.num_faces()*3,u=c*4,p=r._malloc(u);a.GetTrianglesUInt32Array(l,u,p);const f=new Uint32Array(r.HEAPF32.buffer,p,c).slice();return r._free(p),{array:f,itemSize:1}}function i(r,a,l,h,c,u){const p=l.num_points(),f=u.num_components(),d=s(r,c),m=f*c.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,y=g/c.BYTES_PER_ELEMENT,w=p*m,x=p*g,v=r._malloc(w);a.GetAttributeDataArrayForAllPoints(l,u,d,w,v);const b=new c(r.HEAPF32.buffer,v,w/c.BYTES_PER_ELEMENT);let T;if(m===g)T=b.slice();else{T=new c(x/c.BYTES_PER_ELEMENT);let P=0;for(let k=0,D=b.length;k<D;k++){for(let E=0;E<f;E++)T[P+E]=b[k*f+E];P+=y}}return r._free(v),{name:h,count:p,itemSize:f,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 ut=(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))(ut||{});function ql(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(f=>f.url==t),l=e.circularMeps,h=e.rectMeps.filter(f=>f.type==="风管"),c=e.rectMeps.filter(f=>f.type==="桥架"),u=e.ellipseMeps,p=o.scene;if(new A.MeshBasicMaterial,new A.BufferGeometry,l&&l.length){let f=[],d=0;for(let m of l)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Xn("Circle",p,f,t)}if(h&&h.length){let f=[],d=0;for(let m of h)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Xn("Rect",p,f,t)}if(u&&u.length){let f=[],d=0;for(let m of u)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Xn("Ellipse",p,f,t)}if(c&&c.length){let f=[],d=0;for(let m of c)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new A.Color(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+i,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+r},m.rotation={x:0,y:0,z:0},m.indexes=[[o.scene.children.length,d++,0,0]],a.nodesMap.set(Number(m.id),m),f.push(m);Xn("Bridge",p,f,t)}}function Xn(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new A.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=Zn("Rect",a);break;case"Bridge":r=Zn("Bridge",a);break;case"Circle":r=Zn("Circle",a);break;case"Ellipse":r=Zn("Ellipse",a);break}r&&(s=new A.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[];for(var h=0;h<t.length;h++){let p=t[h],f=new A.Vector3(p.startPoint.X,0,-p.startPoint.Y),d=new A.Vector3(p.endPoint.X,0,-p.endPoint.Y),m=new A.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),g=new A.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),y=0,w=0,x=0;if(Math.abs(d.clone().sub(f.clone()).z)<.01&&Math.abs(d.clone().sub(f.clone()).x)<.01){if(y=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var c=new A.Vector3(p.base_x.X,0,-p.base_x.Y);w=(c.clone().cross(new A.Vector3(0,0,1)).y<=0?1:-1)*c.angleTo(new A.Vector3(0,0,1))+Math.PI*.5}}else w=(d.clone().sub(f.clone()).cross(new A.Vector3(0,0,1)).y>0?-1:1)*d.clone().sub(f.clone()).angleTo(new A.Vector3(0,0,1)),y=(p.startPoint.Z>p.endPoint.Z?1:-1)*d.clone().sub(f.clone()).angleTo(g.clone().sub(m.clone()));let v=new A.Matrix4;const b=new A.Euler(y,w,x,"YXZ");let T=v.clone().makeRotationFromEuler(b),P,k;o==="Circle"?(P=p.diameter,k=p.diameter):(P=p.width,k=p.height);let D=v.clone().makeScale(P,k,p.length);v.multiplyMatrices(T,D),v.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(h,v.clone()),s.setColorAt(h,p.color),s.geometry.computeBoundingBox();let E=s.geometry.boundingBox.min.clone().applyMatrix4(v.clone()),O=s.geometry.boundingBox.max.clone().applyMatrix4(v.clone()),C=new A.Vector3(Math.min(E.x,O.x),Math.min(E.y,O.y),Math.min(E.z,O.z)),I=new A.Vector3(Math.max(E.x,O.x),Math.max(E.y,O.y),Math.max(E.z,O.z)),M=C.clone().add(I.clone()).multiplyScalar(.5),z={name:p.name,min:C,max:I,center:M,dbid:h,materialName:r.material.name},Z=null,G=null;o==="Circle"&&(Z={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},G={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},z.minC=Z,z.maxC=G),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(v.clone()),s.ids.push(Number(p.id)),l.push(z)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone();let u=[];u={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=u,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Zn(o,e,t){let n=new A.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 u=new A.ExtrudeGeometry(r,a),p=new A.MeshStandardMaterial({color:l,side:A.DoubleSide}),f=new A.Mesh(u,p);return f.position.set(h.x,h.y,h.z),f.rotation._order="YXZ",f.rotation.set(c.x,c.y,c.z),f}}function kr(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 u=o[c];let p=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;s[f]===void 0&&(s[f]=[]),s[f].push(u.attributes[f]),p++}if(p!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;r[f]===void 0&&(r[f]=[]),r[f].push(u.morphAttributes[f])}if(e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,f,c),h+=f}}if(t){let c=0;const u=[];for(let p=0;p<o.length;++p){const f=o[p].index;for(let d=0;d<f.count;++d)u.push(f.getX(d)+c);c+=o[p].attributes.position.count}l.setIndex(u)}for(const c in s){const u=Ir(s[c]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,u)}for(const c in r){const u=r[c][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let p=0;p<u;++p){const f=[];for(let m=0;m<r[c].length;++m)f.push(r[c][m][p]);const d=Ir(f);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(d)}}return l}function Ir(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 u=l/t;for(let p=0,f=c.count;p<f;p++)for(let d=0;d<t;d++){const m=c.getComponent(p,d);a.setComponent(p+u,d,m)}}else r.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Lr(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 Kl extends _.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Hl(t)}),this.register(function(t){return new ec(t)}),this.register(function(t){return new cc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new nc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new Ql(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new $l(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new fc(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))===Er){try{r[le.KHR_BINARY_GLTF]=new pc(e)}catch(u){i&&i(u);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 Tc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const u=this.pluginCallbacks[c](h);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const u=s.extensionsUsed[c],p=s.extensionsRequired||[];switch(u){case le.KHR_MATERIALS_UNLIT:r[u]=new Jl;break;case le.KHR_DRACO_MESH_COMPRESSION:r[u]=new mc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[u]=new gc;break;case le.KHR_MESH_QUANTIZATION:r[u]=new yc;break;default:p.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}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 Yl(){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 $l{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 u=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=u;break;case"spot":h=new _.SpotLight(c),h.distance=u,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),He(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 Jl{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 Ql{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 Hl{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 ec{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 tc{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 nc{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 ic{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 sc{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 rc{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 oc{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 ac{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 lc{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 cc{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 hc{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 uc{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 dc{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,u=i.byteStride,p=new Uint8Array(a,l,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,u,p,i.mode,i.filter).then(function(f){return f.buffer}):r.ready.then(function(){const f=new ArrayBuffer(c*u);return r.decodeGltfBuffer(new Uint8Array(f),c,u,p,i.mode,i.filter),f})})}else return null}}class fc{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(),u=c.isGroup?c.children:[c],p=h[0].count,f=[];for(const d of u){const m=new _.Matrix4,g=new _.Vector3,y=new _.Quaternion,w=new _.Vector3(1,1,1),x=new _.InstancedMesh(d.geometry,d.material,p);for(let v=0;v<p;v++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,v),l.SCALE&&w.fromBufferAttribute(l.SCALE,v),x.setMatrixAt(v,m.compose(g,y,w));for(const v in l)if(v==="_COLOR_0"){const b=l[v];x.instanceColor=new _.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&d.geometry.setAttribute(v,l[v]);_.Object3D.prototype.copy.call(x,d),this.parser.assignFinalMaterial(x),f.push(x)}return c.isGroup?(c.clear(),c.add(...f),c):f[0]}))}}const Er="glTF",ln=12,Br={JSON:1313821514,BIN:5130562};class pc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ln),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!==Er)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-ln,s=new DataView(e,ln);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Br.JSON){const h=new Uint8Array(e,ln+r,a);this.content=n.decode(h)}else if(l===Br.BIN){const h=ln+r;this.body=e.slice(h,h+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class mc{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 u=ji[c]||c.toLowerCase();a[u]=r[c]}for(const c in e.attributes){const u=ji[c]||c.toLowerCase();if(r[c]!==void 0){const p=n.accessors[e.attributes[c]],f=Xt[p.componentType];h[u]=f.name,l[u]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(u,p){i.decodeDracoFile(c,function(f){for(const d in f.attributes){const m=f.attributes[d],g=l[d];g!==void 0&&(m.normalized=g)}u(f)},a,h,_.LinearSRGBColorSpace,p)})})}}class gc{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 yc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Or 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,u=(n-t)/c,p=u*u,f=p*u,d=e*h,m=d-h,g=-2*f+3*p,y=f-p,w=1-g,x=y-p+u;for(let v=0;v!==a;v++){const b=r[m+v+a],T=r[m+v+l]*c,P=r[d+v+a],k=r[d+v]*c;s[v]=w*b+x*T+g*P+y*k}return s}}const wc=new _.Quaternion;class xc extends Or{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return wc.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},Xt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},zr={9728:_.NearestFilter,9729:_.LinearFilter,9984:_.NearestMipmapNearestFilter,9985:_.LinearMipmapNearestFilter,9986:_.NearestMipmapLinearFilter,9987:_.LinearMipmapLinearFilter},Nr={33071:_.ClampToEdgeWrapping,33648:_.MirroredRepeatWrapping,10497:_.RepeatWrapping},Vi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ji={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"},dt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},vc={CUBICSPLINE:void 0,LINEAR:_.InterpolateLinear,STEP:_.InterpolateDiscrete},Gi={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function bc(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 Pt(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 He(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 _c(o,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const u=e[h];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const u=e[h];if(n){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):o.attributes.position;r.push(p)}if(i){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):o.attributes.normal;a.push(p)}if(s){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):o.attributes.color;l.push(p)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],u=h[1],p=h[2];return n&&(o.morphAttributes.position=c),i&&(o.morphAttributes.normal=u),s&&(o.morphAttributes.color=p),o.morphTargetsRelative=!0,o})}function Mc(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 Sc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Wi(t.attributes):e=o.indices+":"+Wi(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+Wi(o.targets[n]);return e}function Wi(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 Xi(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 Ac(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 Cc=new _.Matrix4;class Tc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Yl,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 Pt(s,a,i),He(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=Vi[i.type],a=Xt[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=Vi[i.type],h=Xt[i.componentType],c=h.BYTES_PER_ELEMENT,u=c*l,p=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,d=i.normalized===!0;let m,g;if(f&&f!==u){const y=Math.floor(p/f),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let x=t.cache.get(w);x||(m=new h(a,y*f,i.count*f/c),x=new _.InterleavedBuffer(m,f/c),t.cache.add(w,x)),g=new _.InterleavedBufferAttribute(x,l,p%f/c,d)}else a===null?m=new h(i.count*l):m=new h(a,p,i.count*l),g=new _.BufferAttribute(m,l,d);if(i.sparse!==void 0){const y=Vi.SCALAR,w=Xt[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,v=i.sparse.values.byteOffset||0,b=new w(r[1],x,i.sparse.count*y),T=new h(r[2],v,i.sparse.count*l);a!==null&&(g=new _.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=b.length;P<k;P++){const D=b[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=d}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 p=(s.samplers||{})[r.sampler]||{};return c.magFilter=zr[p.magFilter]||_.LinearFilter,c.minFilter=zr[p.minFilter]||_.LinearMipmapLinearFilter,c.wrapS=Nr[p.wrapS]||_.RepeatWrapping,c.wrapT=Nr[p.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(u=>u.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(u){h=!0;const p=new Blob([u],{type:r.mimeType});return l=a.createObjectURL(p),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(u){return new Promise(function(p,f){let d=p;t.isImageBitmapLoader===!0&&(d=function(m){const g=new _.Texture(m);g.needsUpdate=!0,p(g)}),t.load(_.LoaderUtils.resolveURL(u,s.path),d,void 0,f)})}).then(function(u){return h===!0&&a.revokeObjectURL(l),He(u,r),u.userData.mimeType=r.mimeType||Ac(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(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 u=i[le.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),h.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new _.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],_.LinearSRGBColorSpace),a.opacity=p[3]}u.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",u.baseColorTexture,_.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=_.DoubleSide);const c=s.alphaMode||Gi.OPAQUE;if(c===Gi.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Gi.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 u=s.normalTexture.scale;a.normalScale.set(u,u)}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 u=s.emissiveFactor;a.emissive=new _.Color().setRGB(u[0],u[1],u[2],_.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==_.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,_.SRGBColorSpace)),Promise.all(h).then(function(){const u=new r(a);return s.name&&(u.name=s.name),He(u,s),t.associations.set(u,{materials:e}),s.extensions&&Pt(i,u,s),u})}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 Rr(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=Sc(h),u=i[c];if(u)r.push(u.promise);else{let p;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?p=s(h):p=Rr(new _.BufferGeometry,h,t),i[c]={primitive:h,promise:p},r.push(p)}}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?bc(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],u=[];for(let f=0,d=c.length;f<d;f++){const m=c[f],g=r[f];let y;const w=h[f];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(m,w):new _.Mesh(m,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Lr(y.geometry,_.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Lr(y.geometry,_.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new _.LineSegments(m,w);else if(g.mode===Ve.LINE_STRIP)y=new _.Line(m,w);else if(g.mode===Ve.LINE_LOOP)y=new _.LineLoop(m,w);else if(g.mode===Ve.POINTS)y=new _.Points(m,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Mc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),He(y,s),g.extensions&&Pt(i,y,g),t.assignFinalMaterial(y),u.push(y)}for(let f=0,d=u.length;f<d;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return s.extensions&&Pt(i,u[0],s),u[0];const p=new _.Group;s.extensions&&Pt(i,p,s),t.associations.set(p,{meshes:e});for(let f=0,d=u.length;f<d;f++)p.add(u[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new _.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)),He(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 u=r[h];if(u){a.push(u);const p=new _.Matrix4;s!==null&&p.fromArray(s.array,h*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new _.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 u=0,p=i.channels.length;u<p;u++){const f=i.channels[u],d=i.samplers[f.sampler],m=f.target,g=m.node,y=i.parameters!==void 0?i.parameters[d.input]:d.input,w=i.parameters!==void 0?i.parameters[d.output]:d.output;m.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(d),c.push(m))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(u){const p=u[0],f=u[1],d=u[2],m=u[3],g=u[4],y=[];for(let x=0,v=p.length;x<v;x++){const b=p[x],T=f[x],P=d[x],k=m[x],D=g[x];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const E=n._createAnimationTracks(b,T,P,k,D);if(E)for(let O=0;O<E.length;O++)y.push(E[O])}const w=new _.AnimationClip(s,void 0,y);return He(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const 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],u=h[1],p=h[2];p!==null&&c.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Cc)});for(let f=0,d=u.length;f<d;f++)c.add(u[f]);return c})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],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 u=0,p=h.length;u<p;u++)c.add(h[u]);if(s.name&&(c.userData.name=s.name,c.name=r),He(c,s),s.extensions&&Pt(n,c,s),s.matrix!==void 0){const u=new _.Matrix4;u.fromArray(s.matrix),c.applyMatrix4(u)}else s.translation!==void 0&&c.position.fromArray(s.translation),s.rotation!==void 0&&c.quaternion.fromArray(s.rotation),s.scale!==void 0&&c.scale.fromArray(s.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(c);i.associations.set(c,{...u})}return i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new _.Group;n.name&&(s.name=i.createUniqueName(n.name)),He(s,n),n.extensions&&Pt(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,u=l.length;c<u;c++)s.add(l[c]);const h=c=>{const u=new Map;for(const[p,f]of i.associations)(p instanceof _.Material||p instanceof _.Texture)&&u.set(p,f);return c.traverse(p=>{const f=i.associations.get(p);f!=null&&u.set(p,f)}),u};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];dt[s.path]===dt.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let h;switch(dt[s.path]){case dt.weights:h=_.NumberKeyframeTrack;break;case dt.rotation:h=_.QuaternionKeyframeTrack;break;case dt.translation:case dt.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?vc[i.interpolation]:_.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let p=0,f=l.length;p<f;p++){const d=new h(l[p]+"."+dt[s.path],t.array,u,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(d),r.push(d)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Xi(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?xc:Or;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Pc(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=Xi(Xt[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 u=s[h];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,d=p.max;if(f!==void 0&&d!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(d[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(d[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(d[2]))),p.normalized){const m=Xi(Xt[p.componentType]);l.multiplyScalar(m)}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 Rr(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=ji[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.`),He(o,e),Pc(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?_c(o,e.targets,t):o})}function Dc(o,e,t){let n=new A.Group;n.name=e,o.scene.add(n),Dr(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 A.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new A.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ut.EngineFree,e)})}function kc(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,ql(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Ic(o,t))})}function Ic(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={},Wl(e.url+i.path,s=>{Pr(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(f=>{f.glb=c,l.has(f.id)==!1?l.set(f.id,{infos:[f]}):l.get(f.id).infos.push(f)});let u=new Kl;const p=new Xl;p.setDecoderPath("/draco/"),p.preload(),u.setDRACOLoader(p),u.load(s.get(c+".glb"),f=>{i.glbs[c]=f.scene.children,i.glbs[c].forEach(d=>{d.geometry.computeVertexNormals()}),h++,h==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ut.EngineFree,e.url),o.viewCube.CameraGoHome())})}Pr(s.get("/instances.json"),c=>{let u=JSON.parse(c);o.models.find(p=>p.url==e.url).instanceNodes=u})})});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 u=i.glbs[c.glb][c.mesh];if(u!=null&&u.geometry!=null&&u.material!=null){let p=new A.Matrix4;p.elements=c.matrix;let f=new A.Mesh(u.geometry.clone().applyMatrix4(p),u.material),d=new A.Box3().setFromObject(f);c.box=d,c.mesh=f,f.name=h,f.glb=c.glb,f.url=e.url,u.geometry.attributes.position!=null&&r.push(f)}})}),Lc(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 u=i.glbs[h][c.mesh];Ec(e.url,c.mesh,o,u,c.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new A.Vector3(r.min.X,r.min.Z,-r.min.Y),h=new A.Vector3(r.max.X,r.max.Z,-r.max.Y);h.distanceTo(l);let c=o.camera.position,u=new A.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(u),r.elements.forEach(p=>{a.push(p)}),r.children.forEach(p=>{a.push(...n(i,s,p))}),r.children.findIndex(p=>p.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Lc(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.set(Number(i.name),[s.currentIndex-i.geometry.index.count,s.currentIndex])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof A.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new A.BufferGeometry,a=Bc(i.meshes[0].material);r=kr(i.meshes.map(c=>c.geometry),!1);let l=new A.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(u=>{h.nodesMap.get(Number(i.meshes[c].name)).indexes==null&&(h.nodesMap.get(Number(i.meshes[c].name)).indexes=[]),h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index,c++,u[0],u[1]])})}}})}function Ec(o,e,t,n,i){if(n==null)return;let s=new A.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let a=0;a<i.length;a++)r[a*3]=1,r[a*3+1]=1,r[a*3+2]=1;s.instanceColor=new A.InstancedBufferAttribute(r,3);for(let a=0;a<i.length;a++){let l=i[a],h=new A.Matrix4;h.elements=l.matrix,s.setMatrixAt(a,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),t.models.find(c=>c.url==o).nodesMap.has(l.id)?(t.models.find(c=>c.url==o).nodesMap.get(l.id).indexes==null&&(t.models.find(c=>c.url==o).nodesMap.get(l.id).indexes=[]),t.models.find(c=>c.url==o).nodesMap.get(l.id).indexes.push([t.scene.children.length-1,a,0,0])):t.models.find(c=>c.url==o).nodesMap.set(l.id,{instance:!0,info:l,indexes:[[t.scene.children.length-1,a,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(a=>a.id)}function Bc(o){return o.map!=null&&(o.map.colorSpace=A.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=A.FrontSide,o.side=o.side,o}class Oc{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&Dc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class zc{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(ut.EngineFree,e=>{this.updateFree(!0),kc(this.engine,e)}),this.engine.events.on(ut.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Nc{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 Rc{engine;constructor(e){this.engine=e}init(){const e=new A.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 A.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new A.AmbientLight(16777215,1);this.engine.scene.add(i)}}var _e=(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))(_e||{});class Fc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new A.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;handleMouseMove(e){if(!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let t=e.catch.object,n=e.catch.object.id,i=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n),s=new Map;i?.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof A.InstancedMesh&&(s.has(a[0])?s.get(a[0])?.push(a[1]):s.set(a[0],[a[1]]))});let r=[];return s.forEach((a,l)=>{let h=this.engine.scene.children[l];a.forEach(c=>{let u=h.geometry.clone();u.applyMatrix4(h.matrixs[c]),r.push(new A.Mesh(u,h.material))})}),this.hoverOldId==n?[]:(this.hoverOldId=n,this.engine.hoverHighLight.clearHighlight(),r)}else{const t=e.catch;t.object;let n=t.object,i=n.name,a=this.engine.models.find(l=>l.url===n.url).nodesMap.get(i).infos.map(l=>l.mesh);return this.hoverOldId==i?[]:(this.hoverOldId=i,this.engine.hoverHighLight.clearHighlight(),a)}}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(_e.Click,!0)}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object,this.engine.events.trigger(_e.Click,n);let i=n.object,a=this.engine.models.find(h=>h.url===i.url).nodesMap.get(i.name).infos.map(h=>h.box),l=t(a);this.engine.viewCube.zoomToModel(l)}function t(n){let i=new A.Vector3(1e8,1e9,1e10),s=new A.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 A.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof A.InstancedMesh),!0)}}class Uc{engine;highlightMaterial;hideMaterial;translucentMaterial;cloneModels=new Map;clonetranslucentModels=new Map;constructor(e){this.engine=e,this.highlightMaterial=new A.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:A.DoubleSide}),this.hideMaterial=new A.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:A.DoubleSide}),this.translucentMaterial=new A.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:A.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 A.InstancedMesh)return;let t=e.materialClone.clone(),n=kr(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s?.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof A.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(console.log(this.engine.scene.children[r[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[r[0]]),this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=1)})}),Vc(n,this.engine,this.cloneModels),this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s?.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof A.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})}),Fr(n,this.engine,this.cloneModels)})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof A.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&&Gc(n,this.engine,this.cloneModels);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof A.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&&Ur(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.unhighlightAllModels(),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightModel(e),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof A.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)})}),jc(n,this.engine,this.clonetranslucentModels);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof A.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&&Ur(n,this.engine),Fr(n,this.engine,this.clonetranslucentModels)}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Vc(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof A.InstancedMesh))return;const r=s.geometry,a=new A.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:A.DoubleSide}),l=new A.InstancedMesh(r,a,n.length);l.name="highlightModel";const h=new Map,c=new A.Matrix4,u=new A.Matrix4;u.makeScale(0,0,0),n.forEach((p,f)=>{s.getMatrixAt(p,c),h.set(p,c.clone()),s.setMatrixAt(p,u),l.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Fr(o,e,t){o.forEach((n,i)=>{const s=t.get(i);if(!s)return;const r=e.scene.children[i];r instanceof A.InstancedMesh&&(n.forEach(a=>{const l=s.originalMatrices.get(a);l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0,s.cloneModel.parent&&s.cloneModel.parent.remove(s.cloneModel),s.cloneModel.geometry,s.cloneModel.material&&(Array.isArray(s.cloneModel.material)?s.cloneModel.material.forEach(a=>a.dispose()):s.cloneModel.material.dispose()),t.delete(i))})}function jc(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof A.InstancedMesh))return;const r=s.geometry,a=new A.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:A.DoubleSide}),l=new A.InstancedMesh(r,a,n.length);l.name="translucentModel";const h=new Map,c=new A.Matrix4,u=new A.Matrix4;u.makeScale(0,0,0),n.forEach((p,f)=>{s.getMatrixAt(p,c),h.set(p,c.clone()),s.setMatrixAt(p,u),l.setMatrixAt(f,c)}),s.instanceMatrix.needsUpdate=!0,l.instanceMatrix.needsUpdate=!0,e.scene.add(l),t.set(i,{cloneModel:l,originalMatrices:h})})}function Gc(o,e,t){e.scene.children.forEach(n=>{n.name=="highlightModel"&&n.parent.remove(n)}),o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof A.InstancedMesh))return;const r=new Map,a=new A.Matrix4,l=new A.Matrix4;l.makeScale(0,0,0),n.forEach((h,c)=>{s.getMatrixAt(h,a),r.set(h,a.clone()),s.setMatrixAt(h,l)}),s.instanceMatrix.needsUpdate=!0,t.set(i,{cloneModel:null,originalMatrices:r})})}function Ur(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof A.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class Fe{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new A.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new A.Vector2(t.x,t.y)}worldToScreen(e){const t=this.worldToScreenNormalized(e),n=this.renderer.domElement.width,i=this.renderer.domElement.height,s=(t.x+1)*n/2,r=(1-t.y)*i/2;return new A.Vector2(s,r)}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 A.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 A.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}class Wc{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.setMode("simple")}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.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){if(!this.engine.composerModule?.composer)return;const e=this.engine.composerModule.composer.passes;for(const t of e)t.constructor.name==="_GTAOPass"?this.gtaoPass=t:t.constructor.name==="ShaderPass"?t.material.uniforms.saturation?this.saturationPass=t:t.material.uniforms.resolution&&(this.fxaaPass=t):t.constructor.name==="OutputPass"&&(this.outputPass=t);this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass)}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 A.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&(e?this.gtaoPass.enabled=!0:this.gtaoPass&&(this.gtaoPass.enabled=!1))}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 A.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 qn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;constructor(e){this.engine=e,this.init()}init(){this.overlayMaterial=new A.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:A.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 A.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/qn.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/qn.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 Kn={exports:{}},Xc=Kn.exports,Vr;function Zc(){return Vr||(Vr=1,(function(o,e){(function(t,n){o.exports=n()})(Xc,function(){var t=function(){function n(f){return r.appendChild(f.dom),f}function i(f){for(var d=0;d<r.children.length;d++)r.children[d].style.display=d===f?"block":"none";s=f}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(f){f.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var f=(performance||Date).now();if(u.update(f-a,200),f>l+1e3&&(c.update(1e3*h/(f-l),100),l=f,h=0,p)){var d=performance.memory;p.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return f},update:function(){a=this.end()},domElement: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,u=48*h,p=3*h,f=2*h,d=3*h,m=15*h,g=74*h,y=30*h,w=document.createElement("canvas");w.width=c,w.height=u,w.style.cssText="width:80px;height:48px";var x=w.getContext("2d");return x.font="bold "+9*h+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,c,u),x.fillStyle=i,x.fillText(n,p,f),x.fillRect(d,m,g,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(d,m,g,y),{dom:w,update:function(v,b){r=Math.min(r,v),a=Math.max(a,v),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,c,m),x.fillStyle=i,x.fillText(l(v)+" "+n+" ("+l(r)+"-"+l(a)+")",p,f),x.drawImage(w,d+h,m,g-h,y,d,m,g-h,y),x.fillRect(d+g-h,m,h,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(d+g-h,m,h,l((1-v/b)*y))}}},t})})(Kn)),Kn.exports}var qc=Zc();const Kc=Us(qc);var Zt=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-Zt.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?Zt.Bounce.In(o*2)*.5:Zt.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}}}}),cn=function(){return performance.now()},Yc=(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=cn()),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})(),Zi={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=Zi.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}}},jr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),qi=new Yc,$c=(function(){function o(e,t){t===void 0&&(t=qi),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=Zt.Linear.None,this._interpolationFunction=Zi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=jr.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=cn()),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 u=n[r];if(u.length===0)continue;for(var p=[a],f=0,d=u.length;f<d;f+=1){var m=this._handleRelativeValue(a,u[f]);if(isNaN(m)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(m)}c&&(n[r]=p)}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 u=n[r];if(!this._isDynamic){var w={};for(var y in u)w[y]=u[y];n[r]=u=w}this._setupProperties(g,t[r],u,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=cn()),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=cn()),!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=qi),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=Zt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Zi.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=cn()),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,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},u=c(),p=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var d=0,m=this._chainedTweens.length;d<m;d++)this._chainedTweens[d].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},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})();jr.nextId;var et=qi;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var hn={Easing:Zt,Tween:$c};function Jc(){return new A.Scene}function Qc(o,e){o.appendChild(e.domElement)}function Hc(o,e,t){var n=new Object;n.visible=!0;let i=null,s,r,a=[];n.init=function(){s||(h(),c(),u())},n.Hide=function(){s.style.display="none",n.visible=!1},n.Show=function(){s.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);const d=new A.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(d.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(d){var m=new A.Vector3(0,0,0);d=="top"?m=new A.Vector3(0,1,1e-5):d=="down"?m=new A.Vector3(0,-1,1e-5):d=="front"?m=new A.Vector3(0,0,1):d=="left"?m=new A.Vector3(-1,0,0):d=="back"?m=new A.Vector3(0,0,-1):d=="right"?m=new A.Vector3(1,0,0):d=="top_front"?m=new A.Vector3(1,1,0):d=="top_left"?m=new A.Vector3(0,1,-1):d=="top_back"?m=new A.Vector3(-1,1,0):d=="top_right"?m=new A.Vector3(0,1,1):d=="down_front"?m=new A.Vector3(1,-1,0):d=="down_left"?m=new A.Vector3(0,-1,-1):d=="down_back"?m=new A.Vector3(-1,-1,0):d=="down_right"?m=new A.Vector3(0,-1,1):d=="front_right"?m=new A.Vector3(1,0,1):d=="right_back"?m=new A.Vector3(-1,0,1):d=="back_left"?m=new A.Vector3(-1,0,-1):d=="left_front"?m=new A.Vector3(1,0,-1):d=="top_left_front"?m=new A.Vector3(1,1,-1):d=="top_front_right"?m=new A.Vector3(1,1,1):d=="top_right_back"?m=new A.Vector3(-1,1,1):d=="top_back_left"?m=new A.Vector3(-1,1,-1):d=="button_left_front"?m=new A.Vector3(1,-1,-1):d=="button_front_right"?m=new A.Vector3(1,-1,1):d=="button_right_back"?m=new A.Vector3(-1,1,1):d=="button_back_left"&&(m=new A.Vector3(-1,-1,-1));var g=o.octreeBox.getBoundingBox(),y=g.min,w=g.max,x=y.clone().add(w.clone()).multiplyScalar(.5),v=x.clone().add(m.multiplyScalar(1*w.distanceTo(y)));l(e.camera.position,v,o.controls.target.clone(),x)},n.GetCameraPose=function(){var d=e.camera.quaternion,m=e.camera.position,g=o.controls.target,y={quaternion:d,position:m,target:g};return y},n.ReductionCameraPose=function(d,m=1e3,g){var y=new A.Quaternion(d.quaternion._x,d.quaternion._y,d.quaternion._z,d.quaternion._w),w=new A.Vector3(d.position.x,d.position.y,d.position.z),x=new A.Vector3(d.target.x,d.target.y,d.target.z);let v=!1;l(e.camera.position,w,o.controls.target.clone(),x,e.camera.quaternion,y,m,b=>{g&&(v||(g(b),v=!0))}),g&&setTimeout(()=>{v||(g(!0),v=!0)},m+10)},n.CameraGoHome=function(){var d=o.octreeBox.getBoundingBox(),m=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let g=new A.Vector3(1,1,1);var y=d.max.distanceTo(d.min),w=m.clone().add(g.multiplyScalar(y));if(e.camera.isOrthographicCamera){var x=o.container.clientWidth/o.container.clientHeight,v=y*.6;e.camera.left=-v*x,e.camera.right=v*x,e.camera.top=v,e.camera.bottom=-v,e.camera.zoom=1,e.camera.updateProjectionMatrix()}l(e.camera.position,w,o.controls.target.clone(),m)},n.zoomToBox=function(d){var m=d.min.clone().add(d.max.clone()).multiplyScalar(.5),g=e.camera.position.clone().sub(o.controls.target.clone()).normalize(),y=e.camera.position.distanceTo(o.controls.target),w=m.clone().add(g.multiplyScalar(y)),x=e.camera.zoom;if(e.camera.isOrthographicCamera){var v=new A.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),b=new A.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new A.Vector3(d.min.x,d.min.y,d.min.z),new A.Vector3(d.max.x,d.min.y,d.min.z),new A.Vector3(d.min.x,d.max.y,d.min.z),new A.Vector3(d.max.x,d.max.y,d.min.z),new A.Vector3(d.min.x,d.min.y,d.max.z),new A.Vector3(d.max.x,d.min.y,d.max.z),new A.Vector3(d.min.x,d.max.y,d.max.z),new A.Vector3(d.max.x,d.max.y,d.max.z)],P=1/0,k=-1/0,D=1/0,E=-1/0;for(var O of T){var C=O.dot(v),I=O.dot(b);P=Math.min(P,C),k=Math.max(k,C),D=Math.min(D,I),E=Math.max(E,I)}var M=(k-P)/2,z=(E-D)/2,Z=(e.camera.right-e.camera.left)/2,G=(e.camera.top-e.camera.bottom)/2;x=Math.min(Z/M,G/z)*.75}var ee=e.camera.position.clone(),W=o.controls.target.clone(),H=e.camera.zoom,R=new hn.Tween({x1:ee.x,y1:ee.y,z1:ee.z,x2:W.x,y2:W.y,z2:W.z,zoom:H}).to({x1:w.x,y1:w.y,z1:w.z,x2:m.x,y2:m.y,z2:m.z,zoom:x},1e3);R.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())}),R.onComplete(function(){o.controls&&(o.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),R.easing(hn.Easing.Cubic.InOut),R.start();function F(){i=requestAnimationFrame(F),R.update()}F()};function l(d,m,g,y,w,x,v=1e3,b){var T;w&&x?(T=new hn.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w}),T.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z,_x:x._x,_y:x._y,_z:x._z,_w:x._w},v)):(T=new hn.Tween({x1:d.x,y1:d.y,z1:d.z,x2:g.x,y2:g.y,z2:g.z}),T.to({x1:m.x,y1:m.y,z1:m.z,x2:y.x,y2:y.y,z2:y.z},v)),T.onUpdate(function(k){o.controls&&(w&&x?(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(),b&&b(!0),cancelAnimationFrame(i),i=null)}),T.easing(hn.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 d=document.createElement("div");d.className="homeViewWrapper",d.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(d);const m=document.createElement("div");m.className="cameraToggleWrapper",m.title="切换正交/透视视图",m.innerHTML="⊞",m.addEventListener("mousedown",function(v){v.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),w()}),s.appendChild(m);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(v){v.stopPropagation(),console.log("截图"),n.TakeScreenshot(),w()}),s.appendChild(g);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(v){v.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),w()}),s.appendChild(y),r.addEventListener("mousedown",function(v){v.stopPropagation(),m.classList.contains("show")?(w(),console.log("隐藏功能按钮")):(x(),console.log("显示功能按钮"))});function w(){m.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function x(){m.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function c(){n.sceneOrtho=Jc();var g=t.clientWidth,y=t.clientWidth,d=g>y?g/y:y/g,m=300;n.camera=new A.OrthographicCamera(m*d/-2,m*d/2,m/2,m/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,w=new A.WebGLRenderer({alpha:!0});w.setSize(g,y),w.setClearAlpha(0),n.sceneOrtho.renderer=w;let x=new A.AmbientLight(16777215,.8);n.sceneOrtho.add(x),Qc(s,w)}function u(){const d="/assets/viewcube/";let m=[{label:"右",icon:d+"cn_right.png"},{label:"左",icon:d+"cn_left.png"},{label:"顶",icon:d+"cn_top.png"},{label:"底",icon:d+"cn_bottom.png"},{label:"前",icon:d+"cn_front.png"},{label:"后",icon:d+"cn_back.png"}];var g=[];for(const w of m)g.push(new A.MeshBasicMaterial({color:16777215,map:new A.TextureLoader().load(w.icon)}));new A.MeshLambertMaterial({color:255});var y=new A.Mesh(new A.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),p(122),s.addEventListener("mousedown",w=>{var x={};x.x=w.offsetX/s.clientWidth*2-1,x.y=-(w.offsetY/s.clientHeight)*2+1;var v=new A.Raycaster;v.setFromCamera(x,n.camera);const b=v.intersectObjects(a,!1);b.length>0&&n.ToggleDirectionView(b[0].object.name)}),s.addEventListener("mousemove",w=>{var x={};x.x=w.offsetX/s.clientWidth*2-1,x.y=-(w.offsetY/s.clientHeight)*2+1;var v=new A.Raycaster;v.setFromCamera(x,n.camera);const b=v.intersectObjects(a,!1);for(var T of a)T.material.opacity=.01;b.length>0&&(b[0].object.material.opacity=.2)})}function p(d){for(var m=d*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new A.Vector3(m,0,0)},{name:"back",a:75,b:75,c:30,point:new A.Vector3(0,0,-m)},{name:"left",a:30,b:75,c:75,point:new A.Vector3(-m,0,0)},{name:"front",a:75,b:75,c:30,point:new A.Vector3(0,0,m)},{name:"top",a:75,b:30,c:75,point:new A.Vector3(0,m,0)},{name:"button",a:75,b:30,c:75,point:new A.Vector3(0,-m,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new A.Vector3(-m,m,m)},{name:"button_front_right",a:30,b:30,c:30,point:new A.Vector3(-m,-m,m)},{name:"top_front_right",a:30,b:30,c:30,point:new A.Vector3(m,m,m)},{name:"button_right_back",a:30,b:30,c:30,point:new A.Vector3(m,-m,m)},{name:"top_back_left",a:30,b:30,c:30,point:new A.Vector3(-m,m,-m)},{name:"button_back_left",a:30,b:30,c:30,point:new A.Vector3(-m,-m,-m)},{name:"top_left_front",a:30,b:30,c:30,point:new A.Vector3(m,m,-m)},{name:"button_left_front",a:30,b:30,c:30,point:new A.Vector3(m,-m,-m)}],w=[{name:"top_front",a:30,b:30,c:75,point:new A.Vector3(m,m,0)},{name:"top_right",a:75,b:30,c:30,point:new A.Vector3(0,m,m)},{name:"top_back",a:30,b:30,c:75,point:new A.Vector3(-m,m,0)},{name:"top_left",a:75,b:30,c:30,point:new A.Vector3(0,m,-m)},{name:"button_front",a:30,b:30,c:75,point:new A.Vector3(m,-m,0)},{name:"button_right",a:75,b:30,c:30,point:new A.Vector3(0,-m,m)},{name:"button_back",a:30,b:30,c:75,point:new A.Vector3(-m,-m,0)},{name:"button_left",a:75,b:30,c:30,point:new A.Vector3(0,-m,-m)},{name:"front_right",a:30,b:75,c:30,point:new A.Vector3(m,0,m)},{name:"right_back",a:30,b:75,c:30,point:new A.Vector3(-m,0,m)},{name:"back_left",a:30,b:75,c:30,point:new A.Vector3(-m,0,-m)},{name:"left_front",a:30,b:75,c:30,point:new A.Vector3(m,0,-m)}],x=0;x<g.length;x++)a.push(f(g[x]));for(var x=0;x<y.length;x++)a.push(f(y[x]));for(var x=0;x<w.length;x++)a.push(f(w[x]))}function f(d){const m=new A.BoxGeometry(d.a,d.b,d.c),g=new A.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new A.Matrix4().makeTranslation(d.point.x,d.point.y,d.point.z);let w=m.applyMatrix4(y),x=new A.Mesh(w,g);return x.name=d.name,n.sceneOrtho.add(x),x}return n.ToggleCameraType=function(){o.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!o.renderer){console.error("渲染器未初始化");return}o.renderer.render(e,e.camera);const m=o.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=m,g.click(),console.log("截图已保存")}catch(d){console.error("截图失败:",d)}},n.ToggleFullscreen=function(){const d=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(d.requestFullscreen?d.requestFullscreen():d.webkitRequestFullscreen?d.webkitRequestFullscreen():d.mozRequestFullScreen?d.mozRequestFullScreen():d.msRequestFullscreen&&d.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class eh{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Hc(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function th(o){let e=new Object;return e.getBoundingBox=function(){let t=o.models,n=new A.Vector3(1e8,1e9,1e10),i=new A.Vector3(-1e8,-1e9,-1e10);t.forEach(u=>{let p=u.boundingBox.min,f=u.boundingBox.max;p.x<n.x&&(n.x=p.x),p.y<n.y&&(n.y=p.y),p.z<n.z&&(n.z=p.z),f.x>i.x&&(i.x=f.x),f.y>i.y&&(i.y=f.y),f.z>i.z&&(i.z=f.z)});let s=Math.min(n.x,i.x),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 A.Vector3(s,r,a),max:new A.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)})}),t.intersectObjects(n,!1);function s(r,a,l){if(a==null)return;let h=new A.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),c=new A.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),u=new A.Vector3(Math.min(h.x,c.X),Math.min(h.y,c.y),Math.min(h.z,c.z)),p=new A.Vector3(Math.max(c.x,h.x),Math.max(c.y,h.y),Math.max(c.z,h.z)),f=new A.Box3(u,p),d=r.ray.intersectsBox(f);if(!(d==null||d==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var m of a.elements){let g=o.engineStatus.hideModels.find(v=>v.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let y=o.engineStatus.translucentModels.find(v=>v.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let x=o.models.find(v=>v.url==l.url).nodesMap.get(m);x!=null&&!x.instance&&x.infos.map(b=>b.mesh).forEach(b=>{n.push(b)})}}else{if(a.elements!=null)for(var m of a.elements){let y=o.engineStatus.hideModels.find(b=>b.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let w=o.engineStatus.translucentModels.find(b=>b.url==l.url)?.ids;if(w!=null&&w.includes(m))continue;let v=o.models.find(b=>b.url==l.url).nodesMap.get(m);v!=null&&!v.instance&&v.infos.map(T=>T.mesh).forEach(T=>{n.push(T)})}for(let g of a.children)s(r,g,l)}}},e}class nh{engine;isDrawing=!1;startPoint=new A.Vector2;endPoint=new A.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 Fe(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 u=this.worldToScreen.screenToWorld(c.x,c.y);u&&a.push(u)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const h=new A.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 A.Vector3;e.getCenter(i);const s=new A.Vector3;e.getSize(s);const r=Math.max(s.x,s.y,s.z);if(t instanceof A.PerspectiveCamera){const a=t.fov*(Math.PI/180),h=r/(2*Math.tan(a/2))*1.2,c=new A.Vector3;t.getWorldDirection(c);const u=i.clone().sub(t.position);c.dot(u.normalize())<0&&c.negate();const f=i.clone().sub(c.multiplyScalar(h));t.position.copy(f),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof A.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 u=new A.Vector3;t.getWorldDirection(u);const p=r*1.5,f=i.clone().sub(u.multiplyScalar(p));t.position.copy(f),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class ih{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 A.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof A.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof A.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof A.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof A.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 A.DirectionalLight);t&&(t.castShadow=e),this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e)}setGTAOEnabled(e){if(!this.engine.composerModule?.composer){console.warn("Composer not initialized");return}const t=this.engine.composerModule.composer,n=t.passes.find(i=>i instanceof ze);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),r=new ze(this.engine.scene,this.engine.camera,i,s);r.output=ze.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 A.PlaneGeometry(n,n),a=new A.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:A.DoubleSide});this.ground=new A.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 it(){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 st{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=Ci(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(d=>{f(d)}),this.engine.measure.annotationData.elevationAnnotation.forEach(d=>{p(d)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(d=>{u(d)}),this.engine.measure.annotationData.angleAnnotation.forEach(d=>{l(d)}),this.engine.measure.annotationData.areaAnnotation.forEach(d=>{h(d)}),this.engine.measure.annotationData.slopeAnnotation.forEach(d=>{c(d)});function l(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="angle-annotation",d.container.id=d.id,d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(_e.MeasureClick,d)})}let m=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point3),w=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;m.x+=w,m.y+=x,g.x+=w,g.y+=x,y.x+=w,y.y+=x;let v=d.container;v.getElementsByTagName("circle")[0].setAttribute("cx",m.x),v.getElementsByTagName("circle")[0].setAttribute("cy",m.y),v.getElementsByTagName("circle")[1].setAttribute("cx",g.x),v.getElementsByTagName("circle")[1].setAttribute("cy",g.y),v.getElementsByTagName("circle")[2].setAttribute("cx",y.x),v.getElementsByTagName("circle")[2].setAttribute("cy",y.y),v.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y),v.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let b=g.x,T=g.y-30;v.getElementsByTagName("rect")[0].setAttribute("x",b-40),v.getElementsByTagName("rect")[0].setAttribute("y",T-12.5),v.getElementsByTagName("text")[0].setAttribute("x",b),v.getElementsByTagName("text")[0].setAttribute("y",T+4),v.getElementsByTagName("text")[0].innerHTML=d.text,v.style.top="0px",v.style.left="0px"}function h(d){if(d.container==null){let k=['<svg class="measureSvg">','<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,2)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="area-annotation",d.container.id=d.id,d.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(_e.MeasureClick,d)})}if(!d.points||d.points.length<3)return;let m=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],w=0,x=0;for(let k=0;k<d.points.length;k++){let D=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.points[k]);D.x+=m,D.y+=g,y.push(D),w+=D.x,x+=D.y}w=w/y.length,x=x/y.length;let v=y.map(k=>k.x+","+k.y).join(" "),b=d.container;b.getElementsByTagName("polygon")[0].setAttribute("points",v),b.getElementsByTagName("polyline")[0].setAttribute("points",v);let T=w,P=x;b.getElementsByTagName("rect")[0].setAttribute("x",T-40),b.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),b.getElementsByTagName("text")[0].setAttribute("x",T),b.getElementsByTagName("text")[0].setAttribute("y",P+4),b.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,2),b.style.top="0px",b.style.left="0px"}function c(d){if(d.container==null){let T=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+d.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+d.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+d.text+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="slope-annotation",d.container.id=d.id,d.container.innerHTML=T,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(_e.MeasureClick,d)})}let m=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.x+=y,m.y+=w,g.x+=y,g.y+=w;let x=d.container;x.getElementsByTagName("polyline")[0].setAttribute("points",m.x+","+m.y+" "+g.x+","+g.y);let v=(m.x+g.x)/2,b=(m.y+g.y)/2-30;x.getElementsByTagName("rect")[0].setAttribute("x",v-50),x.getElementsByTagName("rect")[0].setAttribute("y",b-12.5),x.getElementsByTagName("text")[0].setAttribute("x",v),x.getElementsByTagName("text")[0].setAttribute("y",b+4),x.getElementsByTagName("text")[0].innerHTML=d.text,x.style.top="0px",x.style.left="0px"}function u(d){if(d.container==null){let P=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(d.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-d.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(d.textY,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="coordinate-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(_e.MeasureClick,d)})}let m=d.container,g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=w,m.style.top="0px",m.style.left="0px";let x=m.getElementsByTagName("circle")[0];x&&(x.setAttribute("cx",g.x),x.setAttribute("cy",g.y));let v=m.getElementsByTagName("rect"),b=m.getElementsByTagName("text"),T=-55;v[0]&&(v[0].setAttribute("x",g.x+10),v[0].setAttribute("y",g.y+10+T)),b[0]&&(b[0].setAttribute("x",g.x+10+40),b[0].setAttribute("y",g.y+10+16+T)),v[1]&&(v[1].setAttribute("x",g.x+10),v[1].setAttribute("y",g.y+10+30+T)),b[1]&&(b[1].setAttribute("x",g.x+10+40),b[1].setAttribute("y",g.y+10+46+T)),v[2]&&(v[2].setAttribute("x",g.x+10),v[2].setAttribute("y",g.y+10+60+T)),b[2]&&(b[2].setAttribute("x",g.x+10+40),b[2].setAttribute("y",g.y+10+76+T)),b[0]&&(b[0].innerHTML="X: "+e.getMeasureText(d.textX,1)),b[1]&&(b[1].innerHTML="Y: "+e.getMeasureText(-d.textZ,1)),b[2]&&(b[2].innerHTML="Z: "+e.getMeasureText(d.textY,1))}function p(d){if(d.container==null){let x=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");d.container=document.createElement("div"),d.container.className="elevation-annotation",d.container.id=d.id,d.container.style.position="absolute",d.container.style.pointerEvents="none",d.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(_e.MeasureClick,d)})}let m=d.container,g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point),y=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;m.style.top=g.y+w-48+"px",m.style.left=g.x+y-16+"px",m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1)}function f(d){if(d.container==null){let v=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(d.text,1)+"</text>","</svg>"].join("");d.container=document.createElement("div"),d.container.className="normal-annotation",d.container.id=d.id,d.container.innerHTML=v,e.engine.measure.annotationContainer.appendChild(d.container),d.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),d.container.getElementsByTagName("svg")[0].classList.add("Hight"),d.highlight=!0,e.engine.events.trigger(_e.MeasureClick,d)})}let m=d.container;if(d.point1==null||d.point2==null){m.style.display="none";return}else m.style.display="block";let g=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point1),y=new Fe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(d.point2),w=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;g.x+=w,g.y+=x,y.x+=w,y.y+=x,m.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),m.getElementsByTagName("circle")[0].setAttribute("cx",g.x),m.getElementsByTagName("circle")[0].setAttribute("cy",g.y),m.getElementsByTagName("circle")[1].setAttribute("cx",y.x),m.getElementsByTagName("circle")[1].setAttribute("cy",y.y),m.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),m.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),m.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(d.text,1),m.style.top="0px",m.style.left="0px"}}}class sh{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new st(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 A.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:it(),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 A.Raycaster(i.add(new A.Vector3(0,.01,0)),new A.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(_e.MeasureChanged,t)}else{let i=new A.Raycaster(e.catch.point.clone().add(new A.Vector3(0,.01,0)),new A.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(_e.MeasureChanged,t)}}}class rh{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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(_e.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:it(),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 oh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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:it(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new A.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(_e.MeasureChanged,t)}}class ah{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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:it(),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(_e.MeasureChanged,t))}}class lh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:it(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,this.engine.events.trigger(_e.MeasureChanged,t))}}class ch{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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 A.Vector3().subVectors(e,t),s=new A.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(_e.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:it(),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 hh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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:it(),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:it(),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(_e.MeasureChanged,e))}}class uh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new st(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(_e.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:it(),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 dh{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 sh(e),this.distanceMeasure=new rh(e),this.clearDistanceMeasure=new oh(e),this.elevationMeasure=new ah(e),this.pointMeasure=new lh(e),this.angleMeasure=new ch(e),this.areaMeasure=new hh(e),this.slopeMeasure=new uh(e),this.tools=new st(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 Gr=0,fh=1,ph=2,Wr=2,Ki=1.25,Xr=1,Ie=32,Me=Ie/4,Zr=65535,mh=Math.pow(2,-24),Yi=Symbol("SKIP_GENERATION");function gh(o){return o.index?o.index.count:o.attributes.position.count}function Dt(o){return gh(o)/3}function yh(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function wh(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=yh(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function qr(o,e){const t=Dt(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 Kr(o,e){if(!o.groups||!o.groups.length)return qr(o,e);const t=[],n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=Dt(o),a=[];for(const c of o.groups){const{start:u,count:p}=c,f=u/3,d=isFinite(p)?p:r*3-u,m=(u+d)/3;f<s&&m>i&&(a.push({pos:Math.max(i,f),isStart:!0}),a.push({pos:Math.min(s,m),isStart:!1}))}a.sort((c,u)=>c.pos!==u.pos?c.pos-u.pos:c.type==="end"?-1:1);let l=0,h=null;for(const c of a){const u=c.pos;l!==0&&u!==h&&t.push({offset:h,count:u-h}),l+=c.isStart?1:-1,h=u}return t}function $i(o,e,t,n,i){let s=1/0,r=1/0,a=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,p=1/0,f=1/0,d=-1/0,m=-1/0,g=-1/0;const y=o.offset||0;for(let w=(e-y)*6,x=(e+t-y)*6;w<x;w+=6){const v=o[w+0],b=o[w+1],T=v-b,P=v+b;T<s&&(s=T),P>l&&(l=P),v<u&&(u=v),v>d&&(d=v);const k=o[w+2],D=o[w+3],E=k-D,O=k+D;E<r&&(r=E),O>h&&(h=O),k<p&&(p=k),k>m&&(m=k);const C=o[w+4],I=o[w+5],M=C-I,z=C+I;M<a&&(a=M),z>c&&(c=z),C<f&&(f=C),C>g&&(g=C)}n[0]=s,n[1]=r,n[2]=a,n[3]=l,n[4]=h,n[5]=c,i[0]=u,i[1]=p,i[2]=f,i[3]=d,i[4]=m,i[5]=g}function Yr(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 u=["getX","getY","getZ"],p=i.offset;for(let f=e,d=e+t;f<d;f++){const g=(n?n[f]:f)*3,y=(f-p)*6;let w=g+0,x=g+1,v=g+2;r&&(w=r[w],x=r[x],v=r[v]),a||(w=w*c+h,x=x*c+h,v=v*c+h);for(let b=0;b<3;b++){let T,P,k;a?(T=s[u[b]](w),P=s[u[b]](x),k=s[u[b]](v)):(T=l[w+b],P=l[x+b],k=l[v+b]);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,C=b*2;i[y+C+0]=D+O,i[y+C+1]=O+(Math.abs(D)+O)*mh}}return i}function we(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 $r(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 Jr(o,e){e.set(o)}function Qr(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 Yn(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 un(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 rt=32,xh=(o,e)=>o.candidate-e.candidate,ft=new Array(rt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),$n=new Float32Array(6);function vh(o,e,t,n,i,s){let r=-1,a=0;if(s===Gr)r=$r(e),r!==-1&&(a=(e[r]+e[r+3])/2);else if(s===fh)r=$r(o),r!==-1&&(a=bh(t,n,i,r));else if(s===ph){const l=un(o);let h=Ki*i;const c=t.offset||0,u=(n-c)*6,p=(n+i-c)*6;for(let f=0;f<3;f++){const d=e[f],y=(e[f+3]-d)/rt;if(i<rt/4){const w=[...ft];w.length=i;let x=0;for(let b=u;b<p;b+=6,x++){const T=w[x];T.candidate=t[b+2*f],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;Yn(b,t,P)}w.sort(xh);let v=i;for(let b=0;b<v;b++){const T=w[b];for(;b+1<v&&w[b+1].candidate===T.candidate;)w.splice(b+1,1),v--}for(let b=u;b<p;b+=6){const T=t[b+2*f];for(let P=0;P<v;P++){const k=w[P];T>=k.candidate?Yn(b,t,k.rightCacheBounds):(Yn(b,t,k.leftCacheBounds),k.count++)}}for(let b=0;b<v;b++){const T=w[b],P=T.count,k=i-T.count,D=T.leftCacheBounds,E=T.rightCacheBounds;let O=0;P!==0&&(O=un(D)/l);let C=0;k!==0&&(C=un(E)/l);const I=Xr+Ki*(O*P+C*k);I<h&&(r=f,h=I,a=T.candidate)}}else{for(let v=0;v<rt;v++){const b=ft[v];b.count=0,b.candidate=d+y+v*y;const T=b.bounds;for(let P=0;P<3;P++)T[P]=1/0,T[P+3]=-1/0}for(let v=u;v<p;v+=6){let P=~~((t[v+2*f]-d)/y);P>=rt&&(P=rt-1);const k=ft[P];k.count++,Yn(v,t,k.bounds)}const w=ft[rt-1];Jr(w.bounds,w.rightCacheBounds);for(let v=rt-2;v>=0;v--){const b=ft[v],T=ft[v+1];Qr(b.bounds,T.rightCacheBounds,b.rightCacheBounds)}let x=0;for(let v=0;v<rt-1;v++){const b=ft[v],T=b.count,P=b.bounds,D=ft[v+1].rightCacheBounds;T!==0&&(x===0?Jr(P,$n):Qr(P,$n,$n)),x+=T;let E=0,O=0;x!==0&&(E=un($n)/l);const C=i-x;C!==0&&(O=un(D)/l);const I=Xr+Ki*(E*x+O*C);I<h&&(r=f,h=I,a=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:r,pos:a}}function bh(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 Ji{constructor(){this.boundingData=new Float32Array(6)}}function _h(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 u=0;u<3;u++){let p=e[r*3+u];e[r*3+u]=e[a*3+u],e[a*3+u]=p}for(let u=0;u<6;u++){const p=r-c,f=a-c,d=t[p*6+u];t[p*6+u]=t[f*6+u],t[f*6+u]=d}r++,a--}else return r}}function Mh(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 u=o[r];o[r]=o[a],o[a]=u;for(let p=0;p<6;p++){const f=r-c,d=a-c,m=t[f*6+p];t[f*6+p]=t[d*6+p],t[d*6+p]=m}r++,a--}else return r}}let Hr,Jn,Qi,eo;const Sh=Math.pow(2,32);function Hi(o){return"count"in o?1:1+Hi(o.left)+Hi(o.right)}function Ah(o,e,t){return Hr=new Float32Array(t),Jn=new Uint32Array(t),Qi=new Uint16Array(t),eo=new Uint8Array(t),es(o,e)}function es(o,e){const t=o/4,n=o/2,i="count"in e,s=e.boundingData;for(let r=0;r<6;r++)Hr[t+r]=s[r];if(i)return e.buffer?(eo.set(new Uint8Array(e.buffer),o),o+e.buffer.byteLength):(Jn[t+6]=e.offset,Qi[n+14]=e.count,Qi[n+15]=Zr,o+Ie);{const{left:r,right:a,splitAxis:l}=e,h=o+Ie;let c=es(h,r);const u=o/Ie,f=c/Ie-u;if(f>Sh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Jn[t+6]=f,Jn[t+7]=l,es(c,a)}}function Ch(o,e,t){const i=(o.index?o.index.count:o.attributes.position.count)/3>2**16,s=t.reduce((c,u)=>c+u.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:u,count:p}=t[c];for(let f=0;f<p;f++)l[h+f]=u+f;h+=p}return l}function Th(o,e,t,n,i){const{maxDepth:s,verbose:r,maxLeafTris:a,strategy:l,onProgress:h,indirect:c}=i,u=o._indirectBuffer,p=o.geometry,f=p.index?p.index.array:null,d=c?Mh:_h,m=Dt(p),g=new Float32Array(6);let y=!1;const w=new Ji;return $i(e,t,n,w.boundingData,g),v(w,t,n,g),w;function x(b){h&&h(b/m)}function v(b,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(p))),P<=a||D>=s)return x(T+P),b.offset=T,b.count=P,b;const E=vh(b.boundingData,k,e,T,P,l);if(E.axis===-1)return x(T+P),b.offset=T,b.count=P,b;const O=d(u,f,e,T,P,E);if(O===T||O===T+P)x(T+P),b.offset=T,b.count=P;else{b.splitAxis=E.axis;const C=new Ji,I=T,M=O-T;b.left=C,$i(e,I,M,C.boundingData,g),v(C,I,M,g,D+1);const z=new Ji,Z=O,G=P-M;b.right=z,$i(e,Z,G,z.boundingData,g),v(z,Z,G,g,D+1)}return b}}function Ph(o,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=o.geometry;let i,s;if(e.indirect){const r=Kr(n,e.range),a=Ch(n,e.useSharedArrayBuffer,r);o._indirectBuffer=a,i=Yr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{wh(n,e);const r=qr(n,e.range)[0];i=Yr(n,r.offset,r.count),s=Kr(n,e.range)}o._roots=s.map(r=>{const a=Th(o,i,r.offset,r.count,e),l=Hi(a),h=new t(Ie*l);return Ah(0,a,h),h})}class ot{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}}ot.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 u=t.dot(o);r=Math.min(u,r),a=Math.max(u,a)}this.min=r,this.max=a}})();const Dh=(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 u=t.dot(c),p=c.dot(l),f=c.dot(c),d=t.dot(l),g=l.dot(l)*f-p*p;let y,w;g!==0?y=(u*p-d*f)/g:y=0,w=(u+y*p)/f,r.x=y,r.y=w}})(),ts=(function(){const o=new _.Vector2,e=new _.Vector3,t=new _.Vector3;return function(i,s,r,a){Dh(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 u;h<0?u=s.start:u=s.end;const p=e,f=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(c,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(c)){r.copy(p),a.copy(u);return}else{r.copy(c),a.copy(f);return}}}})(),kh=(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:u}=r;if(n.start=h,n.end=c,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(n.start=h,n.end=u,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(n.start=c,n.end=u,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const m=r.getPlane(t);if(Math.abs(m.distanceToPoint(l))<=a){const y=m.projectPoint(l,e);if(r.containsPoint(y))return!0}return!1}})(),Ih=["x","y","z"],at=1e-15,to=at*at;function je(o){return Math.abs(o)<at}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 ot),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 kh(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 u=s[2],p=r[2];u.subVectors(t,n),p.setFromPoints(u,i);const f=s[3],d=r[3];f.subVectors(n,e),d.setFromPoints(f,i);const m=h.length(),g=u.length(),y=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<at?g<at||y<at?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<at?y<at?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<at&&(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,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(h[p]),t.end.copy(h[f]),ts(t,i,o,e),c=o.distanceToSquared(e),c<u&&(u=c,s&&s.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),c=a.distanceToSquared(o),c<u&&(u=c,s&&s.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),c=l.distanceToSquared(o),c<u&&(u=c,s&&s.copy(o),r&&r.copy(l)),Math.sqrt(u)}})(),Ge.prototype.intersectsTriangle=(function(){const o=new Ge,e=new ot,t=new ot,n=new _.Vector3,i=new _.Vector3,s=new _.Vector3,r=new _.Vector3,a=new _.Line3,l=new _.Line3,h=new _.Vector3,c=new _.Vector2,u=new _.Vector2;function p(x,v,b,T){const P=n;!x.isDegenerateIntoPoint&&!x.isDegenerateIntoSegment?P.copy(x.plane.normal):P.copy(v.plane.normal);const k=x.satBounds,D=x.satAxes;for(let C=1;C<4;C++){const I=k[C],M=D[C];if(e.setFromPoints(M,v.points),I.isSeparated(e)||(r.copy(P).cross(M),e.setFromPoints(r,x.points),t.setFromPoints(r,v.points),e.isSeparated(t)))return!1}const E=v.satBounds,O=v.satAxes;for(let C=1;C<4;C++){const I=E[C],M=O[C];if(e.setFromPoints(M,x.points),I.isSeparated(e)||(r.crossVectors(P,M),e.setFromPoints(r,x.points),t.setFromPoints(r,v.points),e.isSeparated(t)))return!1}return b&&(T||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),b.start.set(0,0,0),b.end.set(0,0,0)),!0}function f(x,v,b,T,P,k,D,E,O,C,I){let M=D/(D-E);C.x=T+(P-T)*M,I.start.subVectors(v,x).multiplyScalar(M).add(x),M=D/(D-O),C.y=T+(k-T)*M,I.end.subVectors(b,x).multiplyScalar(M).add(x)}function d(x,v,b,T,P,k,D,E,O,C,I){if(P>0)f(x.c,x.a,x.b,T,v,b,O,D,E,C,I);else if(k>0)f(x.b,x.a,x.c,b,v,T,E,D,O,C,I);else if(E*O>0||D!=0)f(x.a,x.b,x.c,v,b,T,D,E,O,C,I);else if(E!=0)f(x.b,x.a,x.c,b,v,T,E,D,O,C,I);else if(O!=0)f(x.c,x.a,x.b,T,v,b,O,D,E,C,I);else return!0;return!1}function m(x,v,b,T){const P=v.degenerateSegment,k=x.plane.distanceToPoint(P.start),D=x.plane.distanceToPoint(P.end);return je(k)?je(D)?p(x,v,b,T):(b&&(b.start.copy(P.start),b.end.copy(P.start)),x.containsPoint(P.start)):je(D)?(b&&(b.start.copy(P.end),b.end.copy(P.end)),x.containsPoint(P.end)):x.plane.intersectLine(P,n)!=null?(b&&(b.start.copy(n),b.end.copy(n)),x.containsPoint(n)):!1}function g(x,v,b){const T=v.a;return je(x.plane.distanceToPoint(T))&&x.containsPoint(T)?(b&&(b.start.copy(T),b.end.copy(T)),!0):!1}function y(x,v,b){const T=x.degenerateSegment,P=v.a;return T.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<to?(b&&(b.start.copy(P),b.end.copy(P)),!0):!1}function w(x,v,b,T){if(x.isDegenerateIntoSegment)if(v.isDegenerateIntoSegment){const P=x.degenerateSegment,k=v.degenerateSegment,D=i,E=s;P.delta(D),k.delta(E);const O=n.subVectors(k.start,P.start),C=D.x*E.y-D.y*E.x;if(je(C))return!1;const I=(O.x*E.y-O.y*E.x)/C,M=-(D.x*O.y-D.y*O.x)/C;if(I<0||I>1||M<0||M>1)return!1;const z=P.start.z+D.z*I,Z=k.start.z+E.z*M;return je(z-Z)?(b&&(b.start.copy(P.start).addScaledVector(D,I),b.end.copy(P.start).addScaledVector(D,I)),!0):!1}else return v.isDegenerateIntoPoint?y(x,v,b):m(v,x,b,T);else{if(x.isDegenerateIntoPoint)return v.isDegenerateIntoPoint?v.a.distanceToSquared(x.a)<to?(b&&(b.start.copy(x.a),b.end.copy(x.a)),!0):!1:v.isDegenerateIntoSegment?y(v,x,b):g(v,x,b);if(v.isDegenerateIntoPoint)return g(x,v,b);if(v.isDegenerateIntoSegment)return m(x,v,b,T)}}return function(v,b=null,T=!1){this.needsUpdate&&this.update(),v.isExtendedTriangle?v.needsUpdate&&v.update():(o.copy(v),o.update(),v=o);const P=w(this,v,b,T);if(P!==void 0)return P;const k=this.plane,D=v.plane;let E=D.distanceToPoint(this.a),O=D.distanceToPoint(this.b),C=D.distanceToPoint(this.c);je(E)&&(E=0),je(O)&&(O=0),je(C)&&(C=0);const I=E*O,M=E*C;if(I>0&&M>0)return!1;let z=k.distanceToPoint(v.a),Z=k.distanceToPoint(v.b),G=k.distanceToPoint(v.c);je(z)&&(z=0),je(Z)&&(Z=0),je(G)&&(G=0);const ee=z*Z,W=z*G;if(ee>0&&W>0)return!1;i.copy(k.normal),s.copy(D.normal);const H=i.cross(s);let R=0,F=Math.abs(H.x);const te=Math.abs(H.y);te>F&&(F=te,R=1),Math.abs(H.z)>F&&(R=2);const Y=Ih[R],de=this.a[Y],fe=this.b[Y],se=this.c[Y],oe=v.a[Y],he=v.b[Y],pe=v.c[Y];if(d(this,de,fe,se,I,M,E,O,C,c,a))return p(this,v,b,T);if(d(v,oe,he,pe,ee,W,z,Z,G,u,l))return p(this,v,b,T);if(c.y<c.x){const Ae=c.y;c.y=c.x,c.x=Ae,h.copy(a.start),a.start.copy(a.end),a.end.copy(h)}if(u.y<u.x){const Ae=u.y;u.y=u.x,u.x=Ae,h.copy(l.start),l.start.copy(l.end),l.end.copy(h)}return c.y<u.x||u.y<c.x?!1:(b&&(u.x>c.x?b.start.copy(l.start):b.start.copy(a.start),u.y<c.y?b.end.copy(l.end):b.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 u=0;u<3;u++){let p;const f=t[u],d=r[f];this.closestPointToPoint(d,o),p=d.distanceToSquared(o),p<c&&(c=p,a&&a.copy(o),l&&l.copy(d));const m=this[f];r.closestPointToPoint(m,o),p=m.distanceToSquared(o),p<c&&(c=p,a&&a.copy(m),l&&l.copy(o))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let d=0;d<3;d++){const m=t[d],g=t[(d+1)%3];i.set(r[m],r[g]),ts(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 Le{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 ot),this.alignedSatBounds=new Array(3).fill().map(()=>new ot),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}}Le.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let h=0;h<=1;h++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){const p=1*h|2*c|4*u,f=i[p];f.x=h?n.x:t.x,f.y=c?n.y:t.y,f.z=u?n.z:t.z,f.applyMatrix4(e)}const s=this.satBounds,r=this.satAxes,a=i[0];for(let h=0;h<3;h++){const c=r[h],u=s[h],p=1<<h,f=i[p];c.subVectors(a,f),u.setFromPoints(c,i)}const l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Le.prototype.intersectsBox=(function(){const o=new ot;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}})(),Le.prototype.intersectsTriangle=(function(){const o=new Ge,e=new Array(3),t=new ot,n=new ot,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 p=0;p<3;p++){const f=a[p],d=l[p];if(t.setFromPoints(d,e),f.isSeparated(t))return!1}const h=r.satBounds,c=r.satAxes,u=this.points;for(let p=0;p<3;p++){const f=h[p],d=c[p];if(t.setFromPoints(d,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=l[p];for(let d=0;d<4;d++){const m=c[d];if(i.crossVectors(f,m),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}})(),Le.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}})(),Le.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Le.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,u=r.min,p=r.max,f=this.points;let d=1/0;for(let g=0;g<8;g++){const y=f[g];i.copy(y).clamp(u,p);const w=y.distanceToSquared(i);if(w<d&&(d=w,l&&l.copy(y),h&&h.copy(i),w<c))return Math.sqrt(w)}let m=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){const x=(g+1)%3,v=(g+2)%3,b=y<<x|w<<v,T=1<<g|y<<x|w<<v,P=f[b],k=f[T];e[m].set(P,k);const E=o[g],O=o[x],C=o[v],I=t[m],M=I.start,z=I.end;M[E]=u[E],M[O]=y?u[O]:p[O],M[C]=w?u[C]:p[O],z[E]=p[E],z[O]=y?u[O]:p[O],z[C]=w?u[C]:p[O],m++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let w=0;w<=1;w++){i.x=g?p.x:u.x,i.y=y?p.y:u.y,i.z=w?p.z:u.z,this.closestPointToPoint(i,n);const x=i.distanceToSquared(n);if(x<d&&(d=x,l&&l.copy(n),h&&h.copy(i),x<c))return Math.sqrt(x)}for(let g=0;g<12;g++){const y=e[g];for(let w=0;w<12;w++){const x=t[w];ts(y,x,n,i);const v=n.distanceToSquared(i);if(v<d&&(d=v,l&&l.copy(n),h&&h.copy(i),v<c))return Math.sqrt(v)}}return Math.sqrt(d)}})();class ns{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 Lh extends ns{constructor(){super(()=>new Ge)}}const We=new Lh;function Se(o,e){return e[o+15]===Zr}function Ue(o,e){return e[o+6]}function Xe(o,e){return e[o+14]}function Te(o){return o+Me}function Pe(o,e){const t=e[o+6];return o+t*Me}function is(o,e){return e[o+7]}function Kd(o){return o}class Eh{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 Eh;let pt,qt;const Kt=[],Qn=new ns(()=>new _.Box3);function Bh(o,e,t,n,i,s){pt=Qn.getPrimitive(),qt=Qn.getPrimitive(),Kt.push(pt,qt),me.setBuffer(o._roots[e]);const r=ss(0,o.geometry,t,n,i,s);me.clearBuffer(),Qn.releasePrimitive(pt),Qn.releasePrimitive(qt),Kt.pop(),Kt.pop();const a=Kt.length;return a>0&&(qt=Kt[a-1],pt=Kt[a-2]),r}function ss(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 p=Ue(o,h),f=Xe(c,l);return we(o,a,pt),n(p,f,!1,r,s+o/Me,pt)}else{let E=function(C){const{uint16Array:I,uint32Array:M}=me;let z=C*2;for(;!Se(z,I);)C=Te(C),z=C*2;return Ue(C,M)},O=function(C){const{uint16Array:I,uint32Array:M}=me;let z=C*2;for(;!Se(z,I);)C=Pe(C,M),z=C*2;return Ue(C,M)+Xe(z,I)};const p=Te(o),f=Pe(o,h);let d=p,m=f,g,y,w,x;if(i&&(w=pt,x=qt,we(d,a,w),we(m,a,x),g=i(w),y=i(x),y<g)){d=f,m=p;const C=g;g=y,y=C,w=x}w||(w=pt,we(d,a,w));const v=Se(d*2,l),b=t(w,v,g,r+1,s+d/Me);let T;if(b===Wr){const C=E(d),M=O(d)-C;T=n(C,M,!0,r+1,s+d/Me,w)}else T=b&&ss(d,e,t,n,i,s,r+1);if(T)return!0;x=qt,we(m,a,x);const P=Se(m*2,l),k=t(x,P,y,r+1,s+m/Me);let D;if(k===Wr){const C=E(m),M=O(m)-C;D=n(C,M,!0,r+1,s+m/Me,x)}else D=k&&ss(m,e,t,n,i,s,r+1);return!!D}}const dn=new _.Vector3,rs=new _.Vector3;function Oh(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=>(dn.copy(e).clamp(c.min,c.max),dn.distanceToSquared(e)),intersectsBounds:(c,u,p)=>p<a&&p<r,intersectsTriangle:(c,u)=>{c.closestPointToPoint(e,dn);const p=e.distanceToSquared(dn);return p<a&&(rs.copy(dn),a=p,l=u),p<s}}),a===1/0)return null;const h=Math.sqrt(a);return t.point?t.point.copy(rs):t.point=rs.clone(),t.distance=h,t.faceIndex=l,t}const Hn=parseInt(_.REVISION)>=169,zh=parseInt(_.REVISION)<=161,kt=new _.Vector3,It=new _.Vector3,Lt=new _.Vector3,ei=new _.Vector2,ti=new _.Vector2,ni=new _.Vector2,no=new _.Vector3,io=new _.Vector3,so=new _.Vector3,fn=new _.Vector3;function Nh(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 ro(o,e,t,n,i,s,r,a,l,h,c){kt.fromBufferAttribute(e,s),It.fromBufferAttribute(e,r),Lt.fromBufferAttribute(e,a);const u=Nh(o,kt,It,Lt,fn,l,h,c);if(u){if(n){ei.fromBufferAttribute(n,s),ti.fromBufferAttribute(n,r),ni.fromBufferAttribute(n,a),u.uv=new _.Vector2;const f=_.Triangle.getInterpolation(fn,kt,It,Lt,ei,ti,ni,u.uv);Hn||(u.uv=f)}if(i){ei.fromBufferAttribute(i,s),ti.fromBufferAttribute(i,r),ni.fromBufferAttribute(i,a),u.uv1=new _.Vector2;const f=_.Triangle.getInterpolation(fn,kt,It,Lt,ei,ti,ni,u.uv1);Hn||(u.uv1=f),zh&&(u.uv2=u.uv1)}if(t){no.fromBufferAttribute(t,s),io.fromBufferAttribute(t,r),so.fromBufferAttribute(t,a),u.normal=new _.Vector3;const f=_.Triangle.getInterpolation(fn,kt,It,Lt,no,io,so,u.normal);u.normal.dot(o.direction)>0&&u.normal.multiplyScalar(-1),Hn||(u.normal=f)}const p={a:s,b:r,c:a,normal:new _.Vector3,materialIndex:0};if(_.Triangle.getNormal(kt,It,Lt,p.normal),u.face=p,u.faceIndex=s,Hn){const f=new _.Vector3;_.Triangle.getBarycoord(fn,kt,It,Lt,f),u.barycoord=f}}return u}function oo(o){return o&&o.isMaterial?o.side:o}function ii(o,e,t,n,i,s,r){const a=n*3;let l=a+0,h=a+1,c=a+2;const{index:u,groups:p}=o;o.index&&(l=u.getX(l),h=u.getX(h),c=u.getX(c));const{position:f,normal:d,uv:m,uv1:g}=o.attributes;if(Array.isArray(e)){const y=n*3;for(let w=0,x=p.length;w<x;w++){const{start:v,count:b,materialIndex:T}=p[w];if(y>=v&&y<v+b){const P=oo(e[T]),k=ro(t,f,d,m,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=oo(e),w=ro(t,f,d,m,g,l,h,c,y,s,r);if(w)if(w.faceIndex=n,w.face.materialIndex=0,i)i.push(w);else return w}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 Rh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:h}=o;for(let c=n,u=n+i;c<u;c++)ii(l,e,t,c,s,r,a)}function Fh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let h=1/0,c=null;for(let u=n,p=n+i;u<p;u++){let f;f=ii(a,e,t,u,null,s,r),f&&f.distance<h&&(c=f,h=f.distance)}return c}function Uh(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=o,u=e+o;c<u;c++){let p;if(p=c,be(r,p*3,l,h),r.needsUpdate=!0,n(r,p,i,s))return!0}return!1}function Vh(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 p=0,f=c.length;p<f;p++)s=c[p],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(p,f,d=!1){const m=p*2;if(Se(m,a)){const g=r[p+6],y=a[m+14];let w=1/0,x=1/0,v=1/0,b=-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),C=i.getY(E),I=i.getZ(E);O<w&&(w=O),O>b&&(b=O),C<x&&(x=C),C>T&&(T=C),I<v&&(v=I),I>P&&(P=I)}return l[p+0]!==w||l[p+1]!==x||l[p+2]!==v||l[p+3]!==b||l[p+4]!==T||l[p+5]!==P?(l[p+0]=w,l[p+1]=x,l[p+2]=v,l[p+3]=b,l[p+4]=T,l[p+5]=P,!0):!1}else{const g=Te(p),y=Pe(p,r);let w=d,x=!1,v=!1;if(e){if(!w){const E=g/Me+f/Ie,O=y/Me+f/Ie;x=e.has(E),v=e.has(O),w=!x&&!v}}else x=!0,v=!0;const b=w||x,T=w||v;let P=!1;b&&(P=u(g,f,w));let k=!1;T&&(k=u(y,f,w));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,C=y+E,I=l[O],M=l[O+3],z=l[C],Z=l[C+3];l[p+E]=I<z?I:z,l[p+E+3]=M>Z?M:Z}return D}}}function mt(o,e,t,n,i){let s,r,a,l,h,c;const u=1/t.direction.x,p=1/t.direction.y,f=1/t.direction.z,d=t.origin.x,m=t.origin.y,g=t.origin.z;let y=e[o],w=e[o+3],x=e[o+1],v=e[o+3+1],b=e[o+2],T=e[o+3+2];return u>=0?(s=(y-d)*u,r=(w-d)*u):(s=(w-d)*u,r=(y-d)*u),p>=0?(a=(x-m)*p,l=(v-m)*p):(a=(v-m)*p,l=(x-m)*p),s>l||a>r||((a>s||isNaN(s))&&(s=a),(l<r||isNaN(r))&&(r=l),f>=0?(h=(b-g)*f,c=(T-g)*f):(h=(T-g)*f,c=(b-g)*f),s>c||h>r)?!1:((h>s||s!==s)&&(s=h),(c<r||r!==r)&&(r=c),s<=i&&r>=n)}function jh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:h}=o;for(let c=n,u=n+i;c<u;c++){let p=h?h[c]:c;ii(l,e,t,p,s,r,a)}}function Gh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let h=1/0,c=null;for(let u=n,p=n+i;u<p;u++){let f;f=ii(a,e,t,l?l[u]:u,null,s,r),f&&f.distance<h&&(c=f,h=f.distance)}return c}function Wh(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,h=a.attributes.position;for(let c=o,u=e+o;c<u;c++){let p;if(p=t.resolveTriangleIndex(c),be(r,p*3,l,h),r.needsUpdate=!0,n(r,p,i,s))return!0}return!1}function Xh(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),os(0,o,t,n,i,s,r),me.clearBuffer()}function os(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=o*2;if(Se(c,l)){const p=Ue(o,h),f=Xe(c,l);Rh(e,t,n,p,f,i,s,r)}else{const p=Te(o);mt(p,a,n,s,r)&&os(p,e,t,n,i,s,r);const f=Pe(o,h);mt(f,a,n,s,r)&&os(f,e,t,n,i,s,r)}}const Zh=["x","y","z"];function qh(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=as(0,o,t,n,i,s);return me.clearBuffer(),r}function as(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let h=o*2;if(Se(h,a)){const u=Ue(o,l),p=Xe(h,a);return Fh(e,t,n,u,p,i,s)}else{const u=is(o,l),p=Zh[u],d=n.direction[p]>=0;let m,g;d?(m=Te(o),g=Pe(o,l)):(m=Pe(o,l),g=Te(o));const w=mt(m,r,n,i,s)?as(m,e,t,n,i,s):null;if(w){const b=w.point[p];if(d?b<=r[g+u]:b>=r[g+u+3])return w}const v=mt(g,r,n,i,s)?as(g,e,t,n,i,s):null;return w&&v?w.distance<=v.distance?w:v:w||v||null}}const si=new _.Box3,Yt=new Ge,$t=new Ge,pn=new _.Matrix4,ao=new Le,ri=new Le;function Kh(o,e,t,n){me.setBuffer(o._roots[e]);const i=ls(0,o,t,n);return me.clearBuffer(),i}function ls(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(),ao.set(t.boundingBox.min,t.boundingBox.max,n),i=ao),Se(l,r)){const c=e.geometry,u=c.index,p=c.attributes.position,f=t.index,d=t.attributes.position,m=Ue(o,a),g=Xe(l,r);if(pn.copy(n).invert(),t.boundsTree)return we(o,s,ri),ri.matrix.copy(pn),ri.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>ri.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let x=m*3,v=(g+m)*3;x<v;x+=3)if(be($t,x,u,p),$t.needsUpdate=!0,w.intersectsTriangle($t))return!0;return!1}});{const y=Dt(t);for(let w=m*3,x=(g+m)*3;w<x;w+=3){be(Yt,w,u,p),Yt.a.applyMatrix4(pn),Yt.b.applyMatrix4(pn),Yt.c.applyMatrix4(pn),Yt.needsUpdate=!0;for(let v=0,b=y*3;v<b;v+=3)if(be($t,v,f,d),$t.needsUpdate=!0,Yt.intersectsTriangle($t))return!0}}}else{const c=Te(o),u=Pe(o,a);return we(c,s,si),!!(i.intersectsBox(si)&&ls(c,e,t,n,i)||(we(u,s,si),i.intersectsBox(si)&&ls(u,e,t,n,i)))}}const oi=new _.Matrix4,cs=new Le,mn=new Le,Yh=new _.Vector3,$h=new _.Vector3,Jh=new _.Vector3,Qh=new _.Vector3;function Hh(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),cs.set(e.boundingBox.min,e.boundingBox.max,t),cs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,p=We.getPrimitive(),f=We.getPrimitive();let d=Yh,m=$h,g=null,y=null;i&&(g=Jh,y=Qh);let w=1/0,x=null,v=null;return oi.copy(t).invert(),mn.matrix.copy(oi),o.shapecast({boundsTraverseOrder:b=>cs.distanceToBox(b),intersectsBounds:(b,T,P)=>P<w&&P<r?(T&&(mn.min.copy(b.min),mn.max.copy(b.max),mn.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>mn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<w&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){be(f,3*E,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let C=b,I=b+T;C<I;C++){be(p,3*C,h,l),p.needsUpdate=!0;const M=p.distanceToTriangle(f,d,g);if(M<w&&(m.copy(d),y&&y.copy(g),w=M,x=C,v=E),M<s)return!0}}}});{const P=Dt(e);for(let k=0,D=P;k<D;k++){be(f,3*k,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let E=b,O=b+T;E<O;E++){be(p,3*E,h,l),p.needsUpdate=!0;const C=p.distanceToTriangle(f,d,g);if(C<w&&(m.copy(d),y&&y.copy(g),w=C,x=E,v=k),C<s)return!0}}}}}),We.releasePrimitive(p),We.releasePrimitive(f),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(oi),m.applyMatrix4(oi),i.distance=m.sub(i.point).length(),i.faceIndex=v),n)}function eu(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 p=0,f=c.length;p<f;p++)s=c[p],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,h),h+=s.byteLength;function u(p,f,d=!1){const m=p*2;if(Se(m,a)){const g=r[p+6],y=a[m+14];let w=1/0,x=1/0,v=1/0,b=-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 C=E+O;C=n?n[C]:C;const I=i.getX(C),M=i.getY(C),z=i.getZ(C);I<w&&(w=I),I>b&&(b=I),M<x&&(x=M),M>T&&(T=M),z<v&&(v=z),z>P&&(P=z)}}return l[p+0]!==w||l[p+1]!==x||l[p+2]!==v||l[p+3]!==b||l[p+4]!==T||l[p+5]!==P?(l[p+0]=w,l[p+1]=x,l[p+2]=v,l[p+3]=b,l[p+4]=T,l[p+5]=P,!0):!1}else{const g=Te(p),y=Pe(p,r);let w=d,x=!1,v=!1;if(e){if(!w){const E=g/Me+f/Ie,O=y/Me+f/Ie;x=e.has(E),v=e.has(O),w=!x&&!v}}else x=!0,v=!0;const b=w||x,T=w||v;let P=!1;b&&(P=u(g,f,w));let k=!1;T&&(k=u(y,f,w));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,C=y+E,I=l[O],M=l[O+3],z=l[C],Z=l[C+3];l[p+E]=I<z?I:z,l[p+E+3]=M>Z?M:Z}return D}}}function tu(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),hs(0,o,t,n,i,s,r),me.clearBuffer()}function hs(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:h}=me,c=o*2;if(Se(c,l)){const p=Ue(o,h),f=Xe(c,l);jh(e,t,n,p,f,i,s,r)}else{const p=Te(o);mt(p,a,n,s,r)&&hs(p,e,t,n,i,s,r);const f=Pe(o,h);mt(f,a,n,s,r)&&hs(f,e,t,n,i,s,r)}}const nu=["x","y","z"];function iu(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=us(0,o,t,n,i,s);return me.clearBuffer(),r}function us(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let h=o*2;if(Se(h,a)){const u=Ue(o,l),p=Xe(h,a);return Gh(e,t,n,u,p,i,s)}else{const u=is(o,l),p=nu[u],d=n.direction[p]>=0;let m,g;d?(m=Te(o),g=Pe(o,l)):(m=Pe(o,l),g=Te(o));const w=mt(m,r,n,i,s)?us(m,e,t,n,i,s):null;if(w){const b=w.point[p];if(d?b<=r[g+u]:b>=r[g+u+3])return w}const v=mt(g,r,n,i,s)?us(g,e,t,n,i,s):null;return w&&v?w.distance<=v.distance?w:v:w||v||null}}const ai=new _.Box3,Jt=new Ge,Qt=new Ge,gn=new _.Matrix4,lo=new Le,li=new Le;function su(o,e,t,n){me.setBuffer(o._roots[e]);const i=ds(0,o,t,n);return me.clearBuffer(),i}function ds(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(),lo.set(t.boundingBox.min,t.boundingBox.max,n),i=lo),Se(l,r)){const c=e.geometry,u=c.index,p=c.attributes.position,f=t.index,d=t.attributes.position,m=Ue(o,a),g=Xe(l,r);if(gn.copy(n).invert(),t.boundsTree)return we(o,s,li),li.matrix.copy(gn),li.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:w=>li.intersectsBox(w),intersectsTriangle:w=>{w.a.applyMatrix4(n),w.b.applyMatrix4(n),w.c.applyMatrix4(n),w.needsUpdate=!0;for(let x=m,v=g+m;x<v;x++)if(be(Qt,3*e.resolveTriangleIndex(x),u,p),Qt.needsUpdate=!0,w.intersectsTriangle(Qt))return!0;return!1}});{const y=Dt(t);for(let w=m,x=g+m;w<x;w++){const v=e.resolveTriangleIndex(w);be(Jt,3*v,u,p),Jt.a.applyMatrix4(gn),Jt.b.applyMatrix4(gn),Jt.c.applyMatrix4(gn),Jt.needsUpdate=!0;for(let b=0,T=y*3;b<T;b+=3)if(be(Qt,b,f,d),Qt.needsUpdate=!0,Jt.intersectsTriangle(Qt))return!0}}}else{const c=Te(o),u=Pe(o,a);return we(c,s,ai),!!(i.intersectsBox(ai)&&ds(c,e,t,n,i)||(we(u,s,ai),i.intersectsBox(ai)&&ds(u,e,t,n,i)))}}const ci=new _.Matrix4,fs=new Le,yn=new Le,ru=new _.Vector3,ou=new _.Vector3,au=new _.Vector3,lu=new _.Vector3;function cu(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),fs.set(e.boundingBox.min,e.boundingBox.max,t),fs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,u=e.index,p=We.getPrimitive(),f=We.getPrimitive();let d=ru,m=ou,g=null,y=null;i&&(g=au,y=lu);let w=1/0,x=null,v=null;return ci.copy(t).invert(),yn.matrix.copy(ci),o.shapecast({boundsTraverseOrder:b=>fs.distanceToBox(b),intersectsBounds:(b,T,P)=>P<w&&P<r?(T&&(yn.min.copy(b.min),yn.max.copy(b.max),yn.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>yn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<w&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){const C=P.resolveTriangleIndex(E);be(f,3*C,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let I=b,M=b+T;I<M;I++){const z=o.resolveTriangleIndex(I);be(p,3*z,h,l),p.needsUpdate=!0;const Z=p.distanceToTriangle(f,d,g);if(Z<w&&(m.copy(d),y&&y.copy(g),w=Z,x=I,v=E),Z<s)return!0}}}})}else{const P=Dt(e);for(let k=0,D=P;k<D;k++){be(f,3*k,u,c),f.a.applyMatrix4(t),f.b.applyMatrix4(t),f.c.applyMatrix4(t),f.needsUpdate=!0;for(let E=b,O=b+T;E<O;E++){const C=o.resolveTriangleIndex(E);be(p,3*C,h,l),p.needsUpdate=!0;const I=p.distanceToTriangle(f,d,g);if(I<w&&(m.copy(d),y&&y.copy(g),w=I,x=E,v=k),I<s)return!0}}}}}),We.releasePrimitive(p),We.releasePrimitive(f),w===1/0?null:(n.point?n.point.copy(m):n.point=m.clone(),n.distance=w,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(ci),m.applyMatrix4(ci),i.distance=m.sub(i.point).length(),i.faceIndex=v),n)}function hu(){return typeof SharedArrayBuffer<"u"}const wn=new me.constructor,hi=new me.constructor,gt=new ns(()=>new _.Box3),Ht=new _.Box3,en=new _.Box3,ps=new _.Box3,ms=new _.Box3;let gs=!1;function uu(o,e,t,n){if(gs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");gs=!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,u=i.length;c<u;c++){wn.setBuffer(i[c]),l=0;const p=gt.getPrimitive();we(0,wn.float32Array,p),p.applyMatrix4(h);for(let f=0,d=s.length;f<d&&(hi.setBuffer(s[f]),r=Ke(0,0,t,h,n,a,l,0,0,p),hi.clearBuffer(),l+=s[f].byteLength/Ie,!r);f++);if(gt.releasePrimitive(p),wn.clearBuffer(),a+=i[c].byteLength/Ie,r)break}return gs=!1,r}function Ke(o,e,t,n,i,s=0,r=0,a=0,l=0,h=null,c=!1){let u,p;c?(u=hi,p=wn):(u=wn,p=hi);const f=u.float32Array,d=u.uint32Array,m=u.uint16Array,g=p.float32Array,y=p.uint32Array,w=p.uint16Array,x=o*2,v=e*2,b=Se(x,m),T=Se(v,w);let P=!1;if(T&&b)c?P=i(Ue(e,y),Xe(e*2,w),Ue(o,d),Xe(o*2,m),l,r+e/Me,a,s+o/Me):P=i(Ue(o,d),Xe(o*2,m),Ue(e,y),Xe(e*2,w),a,s+o/Me,l,r+e/Me);else if(T){const k=gt.getPrimitive();we(e,g,k),k.applyMatrix4(t);const D=Te(o),E=Pe(o,d);we(D,f,Ht),we(E,f,en);const O=k.intersectsBox(Ht),C=k.intersectsBox(en);P=O&&Ke(e,D,n,t,i,r,s,l,a+1,k,!c)||C&&Ke(e,E,n,t,i,r,s,l,a+1,k,!c),gt.releasePrimitive(k)}else{const k=Te(e),D=Pe(e,y);we(k,g,ps),we(D,g,ms);const E=h.intersectsBox(ps),O=h.intersectsBox(ms);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(b)P=Ke(o,k,t,n,i,s,r,a,l+1,h,c);else{const C=gt.getPrimitive();C.copy(ps).applyMatrix4(t);const I=Te(o),M=Pe(o,d);we(I,f,Ht),we(M,f,en);const z=C.intersectsBox(Ht),Z=C.intersectsBox(en);P=z&&Ke(k,I,n,t,i,r,s,l,a+1,C,!c)||Z&&Ke(k,M,n,t,i,r,s,l,a+1,C,!c),gt.releasePrimitive(C)}else if(O)if(b)P=Ke(o,D,t,n,i,s,r,a,l+1,h,c);else{const C=gt.getPrimitive();C.copy(ms).applyMatrix4(t);const I=Te(o),M=Pe(o,d);we(I,f,Ht),we(M,f,en);const z=C.intersectsBox(Ht),Z=C.intersectsBox(en);P=z&&Ke(D,I,n,t,i,r,s,l,a+1,C,!c)||Z&&Ke(D,M,n,t,i,r,s,l,a+1,C,!c),gt.releasePrimitive(C)}}return P}const ui=new Le,co=new _.Box3,du={strategy:Gr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class ys{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 ys(t,{...n,[Yi]:!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 u=h[c],p=new Uint32Array(u),f=new Uint16Array(u);for(let d=0,m=u.byteLength/Ie;d<m;d++){const g=Me*d,y=2*g;Se(y,f)||(p[g+6]=p[g+6]/Me-d)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...du,[Yi]:!1},t),t.useSharedArrayBuffer&&!hu())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Yi]||(Ph(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/Ie;for(let h=0;h<l;h++){const c=Me*h,u=2*c;Se(u,a)&&(r[c+6]+=e)}}}}refit(e=null){return(this.indirect?eu:Vh)(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 u=i[a+6],p=s[h+14];e(l,c,new Float32Array(n,a*4,6),u,p)}else{const u=Te(a),p=Pe(a,i),f=is(a,i);e(l,c,new Float32Array(n,a*4,6),f)||(r(u,l+1),r(p,l+1))}}}raycast(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots,r=[],a=this.indirect?tu:Xh;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?iu: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?su:Kh;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?Wh:Uh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const u=r;r=(p,f,d,m,g)=>u(p,f,d,m,g)?!0:n(p,f,this,a,d,m,t)}else r||(a?r=(u,p,f,d)=>n(u,p,this,a,f,d,t):r=(u,p,f)=>f);let l=!1,h=0;const c=this._roots;for(let u=0,p=c.length;u<p;u++){const f=c[u];if(l=Bh(this,u,s,r,i,h),l)break;h+=f.byteLength/Ie}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?d=>{const m=this.resolveTriangleIndex(d);be(r,m*3,a,l)}:d=>{be(r,d*3,a,l)},c=We.getPrimitive(),u=e.geometry.index,p=e.geometry.attributes.position,f=e.indirect?d=>{const m=e.resolveTriangleIndex(d);be(c,m*3,u,p)}:d=>{be(c,d*3,u,p)};if(s){const d=(m,g,y,w,x,v,b,T)=>{for(let P=y,k=y+w;P<k;P++){f(P),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let D=m,E=m+g;D<E;D++)if(h(D),r.needsUpdate=!0,s(r,c,D,P,x,v,b,T))return!0}return!1};if(i){const m=i;i=function(g,y,w,x,v,b,T,P){return m(g,y,w,x,v,b,T,P)?!0:d(g,y,w,x,v,b,T,P)}}else i=d}return uu(this,e,t,i)}intersectsBox(e,t){return ui.set(e.min,e.max,t),ui.needsUpdate=!0,this.shapecast({intersectsBounds:n=>ui.intersectsBox(n),intersectsTriangle:n=>ui.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?cu:Hh)(this,e,t,n,i,s,r)}closestPointToPoint(e,t={},n=0,i=1/0){return Oh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{we(0,new Float32Array(n),co),e.union(co)}),e}}const ho=1e-6,fu=ho*.5,uo=Math.pow(10,-Math.log10(ho)),pu=fu*uo;function tt(o){return~~(o*uo+pu)}function mu(o){return`${tt(o.x)},${tt(o.y)}`}function fo(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)}`}function gu(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)},${tt(o.w)}`}function yu(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 po(){return typeof SharedArrayBuffer<"u"}function wu(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 xu(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function vu(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=xu(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function bu(o){return o.index?o.index.count:o.attributes.position.count}function ws(o){return bu(o)/3}const _u=1e-8,Mu=new _.Vector3;function Su(o){return~~(o/3)}function Au(o){return o%3}function mo(o,e){return o.start-e.start}function go(o,e){return Mu.subVectors(e,o.origin).dot(o.direction)}function Cu(o,e,t,n=_u){o.sort(mo),e.sort(mo);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 u=l.end;l.end=c.start,c.start=u}else if(l.start>=c.start&&l.end>=c.end){const u=c.end;c.end=l.start,l.start=u}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(c.index)||t.set(c.index,[]),t.get(l.index).push(c.index),t.get(c.index).push(l.index),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 yo=1e-5,wo=1e-4;class Tu{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 u=a(c,e),p=a(c,n),f=Math.min(u,p);f<i&&(i=f,s=c)}return s;function r(l,h){const c=l.origin.distanceTo(h.origin)>yo;return l.direction.angleTo(h.direction)>wo||c}function a(l,h){const c=l.origin.distanceTo(h.origin),u=l.direction.angleTo(h.direction);return c/yo+u/wo}}}const xs=new _.Vector3,vs=new _.Vector3,di=new _.Ray;function Pu(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 Tu;for(let c=0,u=l.length;c<u;c++){const p=l[c],f=Su(p),d=Au(p);let m=3*f+d,g=3*f+(d+1)%3;i&&(m=i.getX(m),g=i.getX(g)),xs.fromBufferAttribute(s,m),vs.fromBufferAttribute(s,g),yu(xs,vs,di);let y,w=h.findClosestRay(di);w===null&&(w=di.clone(),h.addRay(w)),a.has(w)||a.set(w,{forward:[],reverse:[],ray:w}),y=a.get(w);let x=go(w,xs),v=go(w,vs);x>v&&([x,v]=[v,x]),di.direction.dot(w.direction)<0?y.reverse.push({start:x,end:v,index:p}):y.forward.push({start:x,end:v,index:p})}return a.forEach(({forward:c,reverse:u},p)=>{Cu(c,u,r,t),c.length===0&&u.length===0&&a.delete(p)}),{disjointConnectivityMap:r,fragmentMap:a}}const Du=new _.Vector2,bs=new _.Vector3,ku=new _.Vector4,_s=["","",""];class Iu{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?x:w,a=new Map,{attributes:l}=e,h=t?Object.keys(l):null,c=e.index,u=l.position;let p=ws(e);const f=p;let d=0;n&&(d=e.drawRange.start,e.drawRange.count!==1/0&&(p=~~(e.drawRange.count/3)));let m=this.data;(!m||m.length<3*f)&&(m=new Int32Array(3*f)),m.fill(-1);let g=0,y=new Set;for(let v=d,b=p*3+d;v<b;v+=3){const T=v;for(let P=0;P<3;P++){let k=T+P;c&&(k=c.getX(k)),_s[P]=r(k)}for(let P=0;P<3;P++){const k=(P+1)%3,D=_s[P],E=_s[k],O=`${E}_${D}`;if(a.has(O)){const C=T+P,I=a.get(O);m[C]=I,m[I]=C,a.delete(O),g+=2,y.delete(I)}else{const C=`${D}_${E}`,I=T+P;a.set(C,I),y.add(I)}}}if(i){const{fragmentMap:v,disjointConnectivityMap:b}=Pu(e,y,s);y.clear(),v.forEach(({forward:T,reverse:P})=>{T.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=v,this.disjointConnections=b,g=p*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=m;function w(v){return bs.fromBufferAttribute(u,v),fo(bs)}function x(v){let b="";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(v));break;case 2:D=mu(Du.fromBufferAttribute(k,v));break;case 3:D=fo(bs.fromBufferAttribute(k,v));break;case 4:D=gu(ku.fromBufferAttribute(k,v));break}b!==""&&(b+="|"),b+=D}return b}}}class fi 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=po();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=wu(s.array)}if(e.boundsTree||(vu(e,{useSharedArrayBuffer:n}),e.boundsTree=new ys(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Iu(e)),!e.groupIndices){const i=ws(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 u=h/3,p=(h+c)/3;u<p;u++)s[u]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Lu=1e-14,Ms=new _.Vector3,xo=new _.Vector3,vo=new _.Vector3;function yt(o,e=Lu){Ms.subVectors(o.b,o.a),xo.subVectors(o.c,o.a),vo.subVectors(o.b,o.c);const t=Ms.angleTo(xo),n=Ms.angleTo(vo),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 Ss=1e-10,xn=1e-10,Eu=1e-10,lt=new _.Line3,xe=new _.Line3,ct=new _.Vector3,As=new _.Vector3,bo=new _.Vector3,pi=new _.Plane,Cs=new Ge;class Bu{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 Ou{constructor(){this.trianglePool=new Bu,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(ct).dot(i))>Ss)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(As).normalize(),Math.abs(1-Math.abs(As.dot(t)))<Eu){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];ct.subVectors(l,a).normalize(),bo.crossVectors(As,ct),pi.setFromNormalAndCoplanarPoint(bo,a),this.splitByPlane(pi,e)}}else e.getPlane(pi),this.splitByPlane(pi,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;Cs.copy(t),Cs.needsUpdate=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];if(!Cs.intersectsTriangle(a,lt,!0))continue;const{a:l,b:h,c}=a;let u=0,p=-1,f=!1,d=[],m=[];const g=[l,h,c];for(let y=0;y<3;y++){const w=(y+1)%3;lt.start.copy(g[y]),lt.end.copy(g[w]);const x=e.distanceToPoint(lt.start),v=e.distanceToPoint(lt.end);if(Math.abs(x)<xn&&Math.abs(v)<xn){f=!0;break}if(x>0?d.push(y):m.push(y),Math.abs(x)<xn)continue;let b=!!e.intersectLine(lt,ct);!b&&Math.abs(v)<xn&&(ct.copy(lt.end),b=!0),b&&!(ct.distanceTo(lt.start)<Ss)&&(ct.distanceTo(lt.end)<Ss&&(p=y),u===0?xe.start.copy(ct):xe.end.copy(ct),u++)}if(!f&&u===2&&xe.distance()>xn)if(p!==-1){p=(p+1)%3;let y=0;y===p&&(y=(y+1)%3);let w=y+1;w===p&&(w=(w+1)%3);const x=i.getTriangle();x.a.copy(g[w]),x.b.copy(xe.end),x.c.copy(xe.start),yt(x)||n.push(x),a.a.copy(g[y]),a.b.copy(xe.start),a.c.copy(xe.end),yt(a)&&(n.splice(s,1),s--,r--)}else{const y=d.length>=2?m[0]:d[0];if(y===0){let T=xe.start;xe.start=xe.end,xe.end=T}const w=(y+1)%3,x=(y+2)%3,v=i.getTriangle(),b=i.getTriangle();g[w].distanceToSquared(xe.start)<g[x].distanceToSquared(xe.end)?(v.a.copy(g[w]),v.b.copy(xe.start),v.c.copy(xe.end),b.a.copy(g[w]),b.b.copy(g[x]),b.c.copy(xe.start)):(v.a.copy(g[x]),v.b.copy(xe.start),v.c.copy(xe.end),b.a.copy(g[w]),b.b.copy(g[x]),b.c.copy(xe.end)),a.a.copy(g[y]),a.b.copy(xe.end),a.c.copy(xe.start),yt(v)||n.push(v),yt(b)||n.push(b),yt(a)&&(n.splice(s,1),s--,r--)}else u===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function zu(o){return o=~~o,o+4-o%4}class _o{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=po()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(zu(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 Nu{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 _o(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 _o(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 Mo{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 Ru=0,Fu=1,Uu=2,So=3,Vu=4,Ao=5,Co=6,Ze=new _.Ray,To=new _.Matrix4,Ee=new _.Triangle,ht=new _.Vector3,Po=new _.Vector4,Do=new _.Vector4,ko=new _.Vector4,Ts=new _.Vector4,mi=new _.Vector4,gi=new _.Vector4,Io=new _.Line3,Ps=new _.Vector3,Ds=1e-8,ju=1e-15,Et=-1,Bt=1,yi=-2,wi=2,vn=0,Ot=1,ks=2,Gu=1e-14;let xi=null;function Lo(o){xi=o}function Eo(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)?Et:Bt}function Wu(o,e){function t(){return Math.random()-.5}o.getNormal(Ps),Ze.direction.copy(Ps),o.getMidpoint(Ze.origin);const n=3;let i=0,s=1/0;for(let r=0;r<n;r++){Ze.direction.x+=t()*Ds,Ze.direction.y+=t()*Ds,Ze.direction.z+=t()*Ds,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<=ju)return a.face.normal.dot(Ps)>0?wi:yi;if(i/n>.5||(r-i+1)/n>.5)break}return i/n>.5?Et:Bt}function Xu(o,e){const t=new Mo,n=new Mo;return To.copy(o.matrixWorld).invert().multiply(e.matrixWorld),o.geometry.boundsTree.bvhcast(e.geometry.boundsTree,To,{intersectsTriangles(i,s,r,a){if(!yt(i)&&!yt(s)){let l=i.intersectsTriangle(s,Io,!0);if(!l){const h=i.plane,c=s.plane,u=h.normal,p=c.normal;u.dot(p)===1&&Math.abs(h.constant-c.constant)<Gu&&(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),xi&&(xi.addEdge(Io),xi.addIntersectingTriangles(r,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function Zu(o,e,t,n,i,s,r=!1){const a=t.attributes,l=t.index,h=o*3,c=l.getX(h+0),u=l.getX(h+1),p=l.getX(h+2);for(const f in s){const d=a[f],m=s[f];if(!(f in a))throw new Error(`CSG Operations: Attribute ${f} not available on geometry.`);const g=d.itemSize;f==="position"?(Ee.a.fromBufferAttribute(d,c).applyMatrix4(n),Ee.b.fromBufferAttribute(d,u).applyMatrix4(n),Ee.c.fromBufferAttribute(d,p).applyMatrix4(n),Is(Ee.a,Ee.b,Ee.c,e,3,m,r)):f==="normal"?(Ee.a.fromBufferAttribute(d,c).applyNormalMatrix(i),Ee.b.fromBufferAttribute(d,u).applyNormalMatrix(i),Ee.c.fromBufferAttribute(d,p).applyNormalMatrix(i),r&&(Ee.a.multiplyScalar(-1),Ee.b.multiplyScalar(-1),Ee.c.multiplyScalar(-1)),Is(Ee.a,Ee.b,Ee.c,e,3,m,r,!0)):(Po.fromBufferAttribute(d,c),Do.fromBufferAttribute(d,u),ko.fromBufferAttribute(d,p),Is(Po,Do,ko,e,g,m,r))}}function qu(o,e,t,n,i,s,r,a=!1){Ls(o,n,i,s,r,a),Ls(a?t:e,n,i,s,r,a),Ls(a?e:t,n,i,s,r,a)}function Bo(o,e,t=!1){switch(o){case Ru:if(e===Bt||e===wi&&!t)return Ot;break;case Fu:if(t){if(e===Et)return vn}else if(e===Bt||e===yi)return Ot;break;case Uu:if(t){if(e===Bt||e===yi)return Ot}else if(e===Et)return vn;break;case Vu:if(e===Et)return vn;if(e===Bt)return Ot;break;case So:if(e===Et||e===wi&&!t)return Ot;break;case Ao:if(!t&&(e===Bt||e===yi))return Ot;break;case Co:if(!t&&(e===Et||e===wi))return Ot;break;default:throw new Error(`Unrecognized CSG operation enum "${o}".`)}return ks}function Is(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)};Ts.set(0,0,0,0).addScaledVector(o,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),mi.set(0,0,0,0).addScaledVector(o,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),gi.set(0,0,0,0).addScaledVector(o,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Ts.normalize(),mi.normalize(),gi.normalize()),l(Ts),r?(l(gi),l(mi)):(l(mi),l(gi))}function Ls(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"?(ht.fromBufferAttribute(a,o).applyMatrix4(t),l.push(ht.x,ht.y,ht.z)):r==="normal"?(ht.fromBufferAttribute(a,o).applyNormalMatrix(n),s&&ht.multiplyScalar(-1),l.push(ht.x,ht.y,ht.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 Ku{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 Oo{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new Ku(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 Yu{constructor(){this.enabled=!1,this.triangleIntersectsA=new Oo,this.triangleIntersectsB=new Oo,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(),Lo(this))}complete(){this.enabled&&Lo(null)}}const wt=new _.Matrix4,vi=new _.Matrix3,zt=new _.Triangle,bi=new _.Triangle,xt=new _.Triangle,_i=new _.Triangle,Ye=[],Nt=[];function $u(o){for(const e of o)return e}function Ju(o,e,t,n,i,s={}){const{useGroups:r=!0}=s,{aIntersections:a,bIntersections:l}=Xu(o,e),h=[];let c=null,u;return u=r?0:-1,zo(o,e,a,t,!1,n,i,u),No(o,e,a,t,!1,i,u),t.findIndex(f=>f!==Co&&f!==Ao)!==-1&&(u=r?o.geometry.groups.length||1:-1,zo(e,o,l,t,!0,n,i,u),No(e,o,l,t,!0,i,u)),Ye.length=0,Nt.length=0,{groups:h,materials:c}}function zo(o,e,t,n,i,s,r,a=0){const l=o.matrixWorld.determinant()<0;wt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),vi.getNormalMatrix(o.matrixWorld).multiplyScalar(l?-1:1);const h=o.geometry.groupIndices,c=o.geometry.index,u=o.geometry.attributes.position,p=e.geometry.boundsTree,f=e.geometry.index,d=e.geometry.attributes.position,m=t.ids,g=t.intersectionSet;for(let y=0,w=m.length;y<w;y++){const x=m[y],v=a===-1?0:h[x]+a,b=3*x,T=c.getX(b+0),P=c.getX(b+1),k=c.getX(b+2);zt.a.fromBufferAttribute(u,T).applyMatrix4(wt),zt.b.fromBufferAttribute(u,P).applyMatrix4(wt),zt.c.fromBufferAttribute(u,k).applyMatrix4(wt),s.reset(),s.initialize(zt);const D=g[x];for(let O=0,C=D.length;O<C;O++){const I=3*D[O],M=f.getX(I+0),z=f.getX(I+1),Z=f.getX(I+2);bi.a.fromBufferAttribute(d,M),bi.b.fromBufferAttribute(d,z),bi.c.fromBufferAttribute(d,Z),s.splitByTriangle(bi)}const E=s.triangles;for(let O=0,C=E.length;O<C;O++){const I=E[O],M=s.coplanarTriangleUsed?Wu(I,p):Eo(I,p);Ye.length=0,Nt.length=0;for(let z=0,Z=n.length;z<Z;z++){const G=Bo(n[z],M,i);G!==ks&&(Nt.push(G),Ye.push(r[z].getGroupAttrSet(v)))}if(Ye.length!==0){zt.getBarycoord(I.a,_i.a),zt.getBarycoord(I.b,_i.b),zt.getBarycoord(I.c,_i.c);for(let z=0,Z=Ye.length;z<Z;z++){const G=Ye[z],W=Nt[z]===vn;Zu(x,_i,o.geometry,o.matrixWorld,vi,G,l!==W)}}}}return m.length}function No(o,e,t,n,i,s,r=0){const a=o.matrixWorld.determinant()<0;wt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),vi.getNormalMatrix(o.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,h=o.geometry.groupIndices,c=o.geometry.index,u=o.geometry.attributes,p=u.position,f=[],d=o.geometry.halfEdges,m=new Set,g=ws(o.geometry);for(let y=0,w=g;y<w;y++)y in t.intersectionSet||m.add(y);for(;m.size>0;){const y=$u(m);m.delete(y),f.push(y);const w=3*y,x=c.getX(w+0),v=c.getX(w+1),b=c.getX(w+2);xt.a.fromBufferAttribute(p,x).applyMatrix4(wt),xt.b.fromBufferAttribute(p,v).applyMatrix4(wt),xt.c.fromBufferAttribute(p,b).applyMatrix4(wt);const T=Eo(xt,l);Nt.length=0,Ye.length=0;for(let P=0,k=n.length;P<k;P++){const D=Bo(n[P],T,i);D!==ks&&(Nt.push(D),Ye.push(s[P]))}for(;f.length>0;){const P=f.pop();for(let k=0;k<3;k++){const D=d.getSiblingTriangleIndex(P,k);D!==-1&&m.has(D)&&(f.push(D),m.delete(D))}if(Ye.length!==0){const k=3*P,D=c.getX(k+0),E=c.getX(k+1),O=c.getX(k+2),C=r===-1?0:h[P]+r;if(xt.a.fromBufferAttribute(p,D),xt.b.fromBufferAttribute(p,E),xt.c.fromBufferAttribute(p,O),!yt(xt))for(let I=0,M=Ye.length;I<M;I++){const z=Nt[I],Z=Ye[I].getGroupAttrSet(C),G=z===vn;qu(D,E,O,u,o.matrixWorld,vi,Z,G!==a)}}}}}function Qu(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 Hu(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 ed(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),u=e.getItemSize(l),p=e.getNormalized(l);let f=s[l];(!f||f.array.length<h)&&(f=new _.BufferAttribute(new c(h),u,p),o.setAttribute(l,f),n=!0);let d=0;for(let m=0,g=Math.min(t.length,e.groupCount);m<g;m++){const y=t[m].index,{array:w,type:x,length:v}=e.groupAttributes[y][l],b=new x(w.buffer,0,v);f.array.set(b,d),d+=b.length}f.needsUpdate=!0,i=h/f.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:u}=t[l],p=e.getCount(c);p!==0&&(o.addGroup(a,p,u),a+=p)}o.setDrawRange(0,i),o.boundsTree=null,n&&o.dispose()}function Ro(o,e){let t=e;return Array.isArray(e)||(t=[],o.forEach(n=>{t[n.materialIndex]=e})),t}class td{constructor(){this.triangleSplitter=new Ou,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new Yu}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 fi){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:u}=this;for(;a.length<i.length;)a.push(new Nu);i.forEach((y,w)=>{Hu(e.geometry,y.geometry,a[w],l)}),u.init(),Ju(e,t,n,r,a,{useGroups:h}),u.complete();const p=this.getGroupRanges(e.geometry),f=Ro(p,e.material),d=this.getGroupRanges(t.geometry),m=Ro(d,t.material);d.forEach(y=>y.materialIndex+=f.length);let g=[...p,...d].map((y,w)=>({...y,index:w}));if(h){const y=[...f,...m];c&&(g=g.map(x=>{const v=y[x.materialIndex];return x.materialIndex=y.indexOf(v),x}).sort((x,v)=>x.materialIndex-v.materialIndex));const w=[];for(let x=0,v=y.length;x<v;x++){let b=!1;for(let T=0,P=g.length;T<P;T++){const k=g[T];k.materialIndex===x&&(b=!0,k.materialIndex=w.length)}b&&w.push(y[x])}i.forEach(x=>{x.material=w})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=f[0]});return i.forEach((y,w)=>{const x=y.geometry;ed(x,a[w],g),c&&Qu(x.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new fi){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 u=r[h];a=i(u)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let h;return n(s,c=>{h?h=this.evaluate(h,c,c.operation):h=this.evaluate(s,c,c.operation)}),s._cachedGeometry=h.geometry,s._cachedMaterials=h.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class nd{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 td,this.planeGroup=new A.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 A.BufferGeometry,i=new A.MeshStandardMaterial({color:new A.Color(33023),metalness:.1,roughness:.75,side:A.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((r,a)=>a!==t)}),s=new A.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),u=new fi(r.geometry);r.updateMatrixWorld(!0),u.matrix.copy(r.matrixWorld),u.updateMatrixWorld();const p=this.evaluator.evaluate(c,u,So);p&&p.geometry.attributes.position.count>0?(s.push(p.geometry),this.geometryCache.set(l,{geometry:p.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(c){console.warn(`CSG intersection failed for mesh ${a}:`,c)}}),s.length>0){const 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 A.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new A.Quaternion().setFromUnitVectors(new A.Vector3(0,-1,0),e.normal));const n=new A.Mesh(t),i=new fi(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new A.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 A.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new A.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new A.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new A.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new A.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 A.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 id{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 nd(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 A.Plane;n.setFromNormalAndCoplanarPoint(new A.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new A.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new A.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 A.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(_e.SectionMove,c)}updata_face(e){let t=this,n=[new A.Vector3(e.min.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.min.z),new A.Vector3(e.min.x,e.max.y,e.min.z)],i=[new A.Vector3(e.min.x,e.min.y,e.max.z),new A.Vector3(e.max.x,e.min.y,e.max.z),new A.Vector3(e.max.x,e.max.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.max.z)],s=[new A.Vector3(e.max.x,e.min.y,e.max.z),new A.Vector3(e.max.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.max.z)],r=[new A.Vector3(e.min.x,e.min.y,e.min.z),new A.Vector3(e.min.x,e.min.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.min.z)],a=[new A.Vector3(e.min.x,e.max.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.min.z),new A.Vector3(e.max.x,e.max.y,e.max.z),new A.Vector3(e.min.x,e.max.y,e.max.z)],l=[new A.Vector3(e.min.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.min.y,e.min.z),new A.Vector3(e.max.x,e.min.y,e.max.z),new A.Vector3(e.min.x,e.min.y,e.max.z)];h(n,new A.Vector3(0,0,-1),"前"),h(i,new A.Vector3(0,0,1),"后"),h(s,new A.Vector3(1,0,0),"右"),h(r,new A.Vector3(-1,0,0),"左"),h(a,new A.Vector3(0,1,0),"顶"),h(l,new A.Vector3(0,-1,0),"底");function h(c,u,p){const f=new A.BufferGeometry,d=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z]),m=[0,1,2,0,2,3];f.setAttribute("position",new A.BufferAttribute(d,3)),f.setIndex(m);let g=t.engine.scene.children.find(T=>T.type=="Group"&&T.name=="ClippingBox");g==null&&(g=new A.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(T=>T.name==p);if(y==null){const T=new A.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:A.DoubleSide});T.polygonOffset=!0,T.polygonOffsetFactor=1,T.polygonOffsetUnits=4;const P=new A.Mesh(f,T);P.normal=u,P.name=p,g.add(P),t.meshs.push(P)}else y.geometry=f;const w=new Float32Array([c[0].x,c[0].y,c[0].z,c[1].x,c[1].y,c[1].z,c[2].x,c[2].y,c[2].z,c[3].x,c[3].y,c[3].z,c[0].x,c[0].y,c[0].z]);let x=new A.LineBasicMaterial({color:255}),v=new A.BufferGeometry;v.setAttribute("position",new A.BufferAttribute(w,3));let b=t.meshs.find(T=>T.name==p+"Line");b==null&&(b=new A.Line(v,x),b.name=p+"Line",g.add(b),t.meshs.push(b)),b.geometry=v,b.material=x,p=="前"||p=="左"||p=="底"?t.engine.sectionPlane.find(T=>T.name==p).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.min):t.engine.sectionPlane.find(T=>T.name==p).setFromNormalAndCoplanarPoint(u.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 sd{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new A.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 A.Vector3(0,1,0).applyAxisAngle(new A.Vector3(1,0,0),e).applyAxisAngle(new A.Vector3(0,0,1),t).applyAxisAngle(new A.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 A.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new A.Vector3(1,0,0),s=new A.Vector3(0,1,0),r=new A.Vector3(0,0,1),a,l,h=this.normal.clone().normalize(),c=Math.abs(h.dot(i)),u=Math.abs(h.dot(s)),p=Math.abs(h.dot(r));c<=u&&c<=p?a=i:u<=c&&u<=p?a=s:a=r,a=a.clone().sub(h.clone().multiplyScalar(a.dot(h))).normalize(),l=new A.Vector3().crossVectors(h,a).normalize();let f=null;this.center==null?(f=new A.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),this.center=f.clone()):f=this.center.clone();let d=this.box.max.x-this.box.min.x,m=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*d,Math.abs(a.y)*m,Math.abs(a.z)*g),w=Math.max(Math.abs(l.x)*d,Math.abs(l.y)*m,Math.abs(l.z)*g),x=f.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-w/2)),v=f.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-w/2)),b=f.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(w/2)),T=f.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(w/2));x.add(h.clone().multiplyScalar(e)),v.add(h.clone().multiplyScalar(e)),b.add(h.clone().multiplyScalar(e)),T.add(h.clone().multiplyScalar(e)),this.current_center=f.clone().add(h.clone().multiplyScalar(e)),k([x,v,b,T],h,"face");function k(D,E,O){const C=new A.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]),M=[0,1,2,0,2,3];C.setAttribute("position",new A.BufferAttribute(I,3)),C.setIndex(M);let z=t.meshs.find(H=>H.name==O);if(z==null){const H=new A.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:A.DoubleSide});H.polygonOffset=!0,H.polygonOffsetFactor=1,H.polygonOffsetUnits=4;const R=new A.Mesh(C,H);R.normal=E,R.name=O,n.add(R),t.meshs.push(R)}else z.geometry=C;const Z=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 G=new A.LineBasicMaterial({color:255}),ee=new A.BufferGeometry;ee.setAttribute("position",new A.BufferAttribute(Z,3));let W=t.meshs.find(H=>H.name==O+"Line");W==null&&(W=new A.Line(ee,G),W.name=O+"Line",n.add(W),t.meshs.push(W)),W.geometry=ee,W.material=G,t.engine.sectionPlane.find(H=>H.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 A.Plane;n.setFromNormalAndCoplanarPoint(new A.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new A.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new A.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 A.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 rd{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 od{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new A.Plane(new A.Vector3(0,0,1),1e5);t.name="前";let n=new A.Plane(new A.Vector3(0,0,1),1e5);n.name="左";let i=new A.Plane(new A.Vector3(0,0,1),1e5);i.name="后";let s=new A.Plane(new A.Vector3(0,0,1),1e5);s.name="右";let r=new A.Plane(new A.Vector3(0,0,1),1e5);r.name="顶";let a=new A.Plane(new A.Vector3(0,0,1),1e5);a.name="底";let l=new A.Plane(new A.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,r,a,l]}init(){this.sectionBox=new id(this.engine),this.sectionFace=new sd(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 A.Vector3(1e8,1e9,1e10),a=new A.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 A.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 rd(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 A.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 ad{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 ld{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 A.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 cd{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&&Dr(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()||""],u=c.map(p=>p[0]);u=u.filter((p,f)=>u.indexOf(p)===f),u.forEach(p=>{let f={name:r.categorys[p],children:[]};h.push(f),c.filter(d=>d[0]===p).forEach(d=>{f.children.push({name:r.names[d[1]],value:r.values[d[2]]})})}),l?.({properties:h,materials:h})}}}class hd{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 ud{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 A.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 A.BufferGeometry;i.setAttribute("position",new A.Float32BufferAttribute(n,3));let s=new A.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 u=s;u<r;u+=3){const p=Math.floor(c/6),f=c%6>=3;if(a[p]&&a[p].length===2){const d=f?a[p][1]:a[p][0];h[u]=d.X,h[u+1]=d.Z,h[u+2]=-d.Y}c+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class dd{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(`网络请求失败,请检查:
|
|
760
968
|
1. 网络连接
|
|
761
969
|
2. API地址是否正确
|
|
762
970
|
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 u=l.split(`
|
|
763
|
-
`);l=u.pop()||"";for(const p of u){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const d=f.slice(6);if(d!=="[DONE]")try{const g=JSON.parse(d).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(m){console.warn("解析流式数据失败:",m)}}}}catch(s){throw clearTimeout(i),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error("网络请求失败,请检查网络连接"):s}}updateConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}}class
|
|
971
|
+
`);l=u.pop()||"";for(const p of u){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const d=f.slice(6);if(d!=="[DONE]")try{const g=JSON.parse(d).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(m){console.warn("解析流式数据失败:",m)}}}}catch(s){throw clearTimeout(i),s.name==="AbortError"?new Error("请求超时,请重试"):s.message.includes("Failed to fetch")?new Error("网络请求失败,请检查网络连接"):s}}updateConfig(e){this.config={...this.config,...e}}getConfig(){return{...this.config}}}class fd{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 dd(i.llmConfig);try{const s=await Promise.resolve().then(()=>Md);this.prompts.main=s.default;const r=await Promise.resolve().then(()=>Sd);this.prompts.step=r.default;const a=await Promise.resolve().then(()=>Ad);this.prompts.apiDoc=a.default}catch(s){throw console.error("[AI Manager] 提示词文件加载失败:",s),new Error(`提示词文件加载失败: ${s.message||"未知错误"}`)}}catch(s){throw console.error("[AI Manager] 初始化失败:",s),s}}async conversationV2(e){if(this.conversationHistory.length===0){const i={role:"system",content:`${this.prompts.main}`},s={role:"system",content:`## BIM引擎API文档
|
|
764
972
|
${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} 次生成的代码:
|
|
765
973
|
${c}`);try{const u=await this.executeCode(c,t);if(u instanceof Object&&u.success==!1||u instanceof String&&(u.includes("undefined")||u.includes("not"))){s=u,r=!0;debugger;throw u}debugger;return u}catch(u){debugger;throw s=u,r=!0,u}}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:`
|
|
766
974
|
|
|
@@ -803,7 +1011,7 @@ ${JSON.stringify(l,null,2)}
|
|
|
803
1011
|
4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},c=await this.llmApi.chat([r,a,h]);try{return this.extractCodeFromResponse(c)}catch(u){throw new Error(`无法从大模型响应中提取代码(修复重试阶段):${u.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",`
|
|
804
1012
|
'use strict';
|
|
805
1013
|
${i}
|
|
806
|
-
`)(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 hd{engine;points=[];isPlaying=!1;animationFrameId=null;playStartTime=0;playFromIndex=0;playToIndex=0;playOptions={};stayTimerId=null;playRangeToIndex=0;constructor(e){this.engine=e}init(){this.points=[],this.stop()}getCurrentPoint(){return{...this.engine.cameraModule.getCameraPose(),stayTime:0}}addPoint(e=0){const t=this.getCurrentPoint();return t.stayTime=e,this.points.push(t),this.points.length}addPoints(e){for(const t of e)this.points.push({...t});return this.points.length}savePoints(e){return this.addPoints(e)}removePoint(e){return e>=0&&e<this.points.length?(this.points.splice(e,1),!0):!1}clearPoints(){this.stop(),this.points=[]}getPoints(){return[...this.points]}getPointCount(){return this.points.length}updatePoint(e,t){return e>=0&&e<this.points.length?(this.points[e]={...t},!0):!1}jumpToPoint(e){return e>=0&&e<this.points.length?(this.stop(),this.engine.cameraModule.restoreCameraPose(this.points[e]),!0):!1}play(e={}){return this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...e},this.engine.controlModule.disActive(),this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate(),!0)}playRange(e,t,n={}){return e<0||t>=this.points.length||e>=t?(console.warn("PathRoaming: 无效的索引范围"),!1):this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...n},this.engine.controlModule.disActive(),this.playFromIndex=e,this.playToIndex=e+1,this.playStartTime=performance.now(),this.playRangeToIndex=t,this.animate(),!0)}stop(){this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null),this.engine.controlModule.active()}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null))}getIsPlaying(){return this.isPlaying}animate=()=>{if(!this.isPlaying)return;const t=performance.now()-this.playStartTime,n=this.playOptions.duration||3e3,i=Math.min(t/n,1),s=this.points[this.playFromIndex],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:A.MathUtils.lerp(e.position.x,t.position.x,i),y:A.MathUtils.lerp(e.position.y,t.position.y,i),z:A.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:A.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:A.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:A.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:A.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:A.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:A.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:A.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:A.MathUtils.lerp(e.target.x,t.target.x,i),y:A.MathUtils.lerp(e.target.y,t.target.y,i),z:A.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=A.MathUtils.lerp(e.zoom,t.zoom,i)),s}easeInOutCubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}dispose(){this.stop(),this.points=[],this.playOptions={}}}class ud{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 A.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 A.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 A.Vector3().copy(i.target).sub(n.position),u=new A.Spherical().setFromVector3(c);u.theta-=h,c.setFromSpherical(u),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 A.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,u=-Math.cos(l)*a,p=Math.sin(l)*a,f=-Math.cos(l)*a;e.beginPath(),e.moveTo(0,0),e.lineTo(c,u),e.lineTo(p,f),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 dd=[{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 fd{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new A.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(dd)}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 A.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 A.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 A.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 A.Group;s.name=`GridAxis_${e.data.Id}`;const r=new A.BufferGeometry().setFromPoints([t,n]),a=new A.LineBasicMaterial({color:1609983,depthTest:!1}),l=new A.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 A.CanvasTexture(i),c=new A.SpriteMaterial({map:h,depthTest:!1,transparent:!0}),u=new A.Sprite(c);return u.position.copy(t),u.scale.set(.5,.5,1),u.renderOrder=999,u}}const pd=[{Id:"339",Name:"站台",Elevation:-.32808398950131235},{Id:"2787",Name:"站厅",Elevation:16.896325459317584},{Id:"236633",Name:"顶板",Elevation:36.745406824146976}];class md{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(pd)}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 Fe(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 A.Group,s=new A.PlaneGeometry(n*2,n*2);s.rotateX(-Math.PI/2);const r=new A.MeshBasicMaterial({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:A.DoubleSide,depthWrite:!1}),a=new A.Mesh(s,r);a.position.y=t,i.add(a);const l=[new A.Vector3(-n,t,-n),new A.Vector3(n,t,-n),new A.Vector3(n,t,n),new A.Vector3(-n,t,n),new A.Vector3(-n,t,-n)],h=new A.BufferGeometry().setFromPoints(l),c=new A.LineBasicMaterial({color:this.COLOR,transparent:!0,opacity:.7});if(i.add(new A.Line(h,c)),i.visible=this.isVisible,this.engine.scene.add(i),e.group=i,this.svgOverlay){const u=document.createElementNS("http://www.w3.org/2000/svg","g");u.dataset.levelId=e.data.Id;for(let p=0;p<4;p++)u.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(u),e.svgGroup=u}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new A.Vector3(-t,n,-t),new A.Vector3(t,n,-t),new A.Vector3(t,n,t),new A.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 gd{engine;constructor(e){}update(){}}class yd{options;DeviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;text;models=[];reactBoundingClientRect={left:0,top:0};version="2.0.2";container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.engineModelModule=new Uc(this),this.engineModelModule.init(),this.ai=new cd(this),this.deviceModule=new Ro(this),this.DeviceType=this.deviceModule.getDeviceType(),this.cameraModule=new No(this),this.sceneModule=new zo(this),this.scene=this.sceneModule.scene,this.renderModule=new Fo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ea(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new pa(this),this.composerModule.init(),this.events=new Bc,this.engineStatus=new Ec(this),this.engineStatus.init(),this.loaderModule=new Ic(this),this.lightModule=new Lc(this),this.lightModule.init(),this.viewCube=new $c(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Hc(this),this.rangeScale=new Jc(this),this.rangeScale.init(),this.clipping=new nd(this),this.clipping.init(),this.setting=new Qc(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=_i(this),this.modelMapperBatch=new od(this),this.measure=new lh(this),this.modelToolModule=new zc(this),this.modelProperties=new rd(this),this.interactionModule=new Oc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new jn(this),this.modelEdge=new ad(this),this.modelTree=new id(this),this.engineInfo=new sd(this),this.pathRoaming=new hd(this),this.pathRoaming.init(),this.minMap=new ud(this),this.grid=new fd(this),this.level=new md(this),this.text=new gd(this),this.worldToScreen=new Fe(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Xc,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",t.innerHTML=`v${this.version}`,this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none";const i=this.renderer?.domElement.width||1920,s=this.renderer?.domElement.height||1080;n.setAttribute("viewBox",`0 0 ${i} ${s}`),n.setAttribute("preserveAspectRatio","none"),this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let r=this;this.controls.addEventListener("start",()=>{r.events.trigger(ht.EngineBusy)}),this.controls.addEventListener("end",()=>{r.events.trigger(ht.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}if(this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this.scene){let a=this.scene?.dirLight;a&&this.camera&&this.updateLightPosition(this.camera,a)}},this.animate()}updateLightPosition(e,t){const n=new A.Vector3;e.getWorldDirection(n);const i=new A.Vector3().copy(n).multiplyScalar(-100);t.position.copy(e.position).add(i);const s=new A.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(s),t.target.updateMatrixWorld()}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,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.renderer.domElement.width,s=this.renderer.domElement.height;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ht.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.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 A.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 A.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof A.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof A.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 A.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 A.Texture&&i.dispose()}),e.dispose()}}function wd(o){return new yd(o)}const xd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
|
1014
|
+
`)(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 pd{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:A.MathUtils.lerp(e.position.x,t.position.x,i),y:A.MathUtils.lerp(e.position.y,t.position.y,i),z:A.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:A.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:A.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:A.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:A.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:A.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:A.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:A.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:A.MathUtils.lerp(e.target.x,t.target.x,i),y:A.MathUtils.lerp(e.target.y,t.target.y,i),z:A.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=A.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 md{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 A.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 A.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 A.Vector3().copy(i.target).sub(n.position),u=new A.Spherical().setFromVector3(c);u.theta-=h,c.setFromSpherical(u),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 A.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,u=-Math.cos(l)*a,p=Math.sin(l)*a,f=-Math.cos(l)*a;e.beginPath(),e.moveTo(0,0),e.lineTo(c,u),e.lineTo(p,f),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 gd=[{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 yd{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new A.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(gd)}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 A.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 A.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 A.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 A.Group;s.name=`GridAxis_${e.data.Id}`;const r=new A.BufferGeometry().setFromPoints([t,n]),a=new A.LineBasicMaterial({color:1609983,depthTest:!1}),l=new A.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 A.CanvasTexture(i),c=new A.SpriteMaterial({map:h,depthTest:!1,transparent:!0}),u=new A.Sprite(c);return u.position.copy(t),u.scale.set(.5,.5,1),u.renderOrder=999,u}}const wd=[{Id:"339",Name:"站台",Elevation:-.32808398950131235},{Id:"2787",Name:"站厅",Elevation:16.896325459317584},{Id:"236633",Name:"顶板",Elevation:36.745406824146976}];class xd{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(wd)}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 Fe(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 A.Group,s=new A.PlaneGeometry(n*2,n*2);s.rotateX(-Math.PI/2);const r=new A.MeshBasicMaterial({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:A.DoubleSide,depthWrite:!1}),a=new A.Mesh(s,r);a.position.y=t,i.add(a);const l=[new A.Vector3(-n,t,-n),new A.Vector3(n,t,-n),new A.Vector3(n,t,n),new A.Vector3(-n,t,n),new A.Vector3(-n,t,-n)],h=new A.BufferGeometry().setFromPoints(l),c=new A.LineBasicMaterial({color:this.COLOR,transparent:!0,opacity:.7});if(i.add(new A.Line(h,c)),i.visible=this.isVisible,this.engine.scene.add(i),e.group=i,this.svgOverlay){const u=document.createElementNS("http://www.w3.org/2000/svg","g");u.dataset.levelId=e.data.Id;for(let p=0;p<4;p++)u.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(u),e.svgGroup=u}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new A.Vector3(-t,n,-t),new A.Vector3(t,n,-t),new A.Vector3(t,n,t),new A.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 vd{engine;constructor(e){}update(){}}class bd{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;models=[];reactBoundingClientRect={left:0,top:0};version="2.0.3";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 Wc(this),this.engineModelModule.init(),this.ai=new fd(this),this.deviceModule=new Go(this),this.DeviceType=this.deviceModule.getDeviceType(),this.cameraModule=new jo(this),this.sceneModule=new Vo(this),this.scene=this.sceneModule.scene,this.renderModule=new Wo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ra(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new wa(this),this.composerModule.init(),this.events=new Nc,this.engineStatus=new zc(this),this.engineStatus.init(),this.loaderModule=new Oc(this),this.lightModule=new Rc(this),this.lightModule.init(),this.viewCube=new eh(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=th(this),this.rangeScale=new nh(this),this.rangeScale.init(),this.clipping=new od(this),this.clipping.init(),this.setting=new ih(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=Ci(this),this.modelMapperBatch=new hd(this),this.measure=new dh(this),this.modelToolModule=new Uc(this),this.modelProperties=new cd(this),this.interactionModule=new Fc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new qn(this),this.modelEdge=new ud(this),this.modelTree=new ad(this),this.engineInfo=new ld(this),this.pathRoaming=new pd(this),this.pathRoaming.init(),this.minMap=new md(this),this.grid=new yd(this),this.level=new xd(this),this.text=new vd(this),this.worldToScreen=new Fe(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Kc,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.width="100%",n.style.height="100%",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none";const i=this.renderer?.domElement.width||1920,s=this.renderer?.domElement.height||1080;n.setAttribute("viewBox",`0 0 ${i} ${s}`),n.setAttribute("preserveAspectRatio","none"),this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let r=this;this.controls.addEventListener("start",()=>{r.events.trigger(ut.EngineBusy)}),this.controls.addEventListener("end",()=>{r.events.trigger(ut.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.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 a=performance.now();if(a-this._fpsLastCheck>=this._fpsCheckInterval){const l=a-this._fpsLastCheck,h=this._fpsFrameCount/l*1e3;this._fpsFrameCount=0,this._fpsLastCheck=a,h<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&a-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=a,this._lowFpsCount=0)):h>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0,this._highFpsCount>=this._highFpsRequired&&a-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingUpgrade(),this._fpsLastSwitch=a,this._highFpsCount=0)):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let l=this.scene?.dirLight;l&&this.camera&&this.updateLightPosition(this.camera,l)}},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 A.Vector3;e.getWorldDirection(n);const i=new A.Vector3().copy(n).multiplyScalar(-100);t.position.copy(e.position).add(i);const s=new A.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(s),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.renderer.domElement.width,s=this.renderer.domElement.height;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ut.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.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 A.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 A.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof A.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof A.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 A.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 A.Texture&&i.dispose()}),e.dispose()}}function _d(o){return new bd(o)}const Md=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
|
807
1015
|
\r
|
|
808
1016
|
## 角色定位\r
|
|
809
1017
|
\r
|
|
@@ -973,7 +1181,7 @@ json内容\r
|
|
|
973
1181
|
5. **用户友好**:步骤描述要清晰易懂,便于用户理解整个执行流程\r
|
|
974
1182
|
\r
|
|
975
1183
|
\r
|
|
976
|
-
''`},Symbol.toStringTag,{value:"Module"})),
|
|
1184
|
+
''`},Symbol.toStringTag,{value:"Module"})),Sd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家\r
|
|
977
1185
|
\r
|
|
978
1186
|
## 角色定位\r
|
|
979
1187
|
\r
|
|
@@ -1219,7 +1427,7 @@ try {\r
|
|
|
1219
1427
|
5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"写法\r
|
|
1220
1428
|
6. **注释清晰**:关键逻辑要有注释,但不要过度注释\r
|
|
1221
1429
|
7. **性能考虑**:对于大量数据的处理,考虑性能优化\r
|
|
1222
|
-
8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),
|
|
1430
|
+
8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),Ad=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
|
|
1223
1431
|
|
|
1224
1432
|
本文档为 BIM Engine SDK 的完整 API 参考,适合大模型阅读和理解引擎的功能结构。
|
|
1225
1433
|
|
|
@@ -2723,5 +2931,5 @@ BIM Engine SDK 提供了完整的 3D BIM 模型渲染和交互能力,主要特
|
|
|
2723
2931
|
- 施工模拟
|
|
2724
2932
|
- 运维管理
|
|
2725
2933
|
- AI 辅助设计
|
|
2726
|
-
`},Symbol.toStringTag,{value:"Module"}));_t.createEngine=
|
|
2934
|
+
`},Symbol.toStringTag,{value:"Module"}));_t.createEngine=_d,Object.defineProperty(_t,Symbol.toStringTag,{value:"Module"})}));
|
|
2727
2935
|
//# sourceMappingURL=bim-engine-sdk.umd.js.map
|